invalid page fault - code
-
I am having a simple dialog based application on visual c++ 5.0 . I am just trying to create one process by CreateProcess() API in which I am trying to open mspaint or msword i.e microsoft office applications. The code I have written on pushbutton event is as follows. void CCreatprocessDlg::OnRun() { STARTUPINFO siStartInfo; PROCESS_INFORMATION piProcInfo; BOOL fPass; fPass = CreateProcess("c:\\Program Files\\Accessories\\Mspaint.exe", NULL, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &siStartInfo, &piProcInfo); if (!fPass) MessageBox("Can not execute WordPad.exe.", "Warning",MB_ICONHAND); } The trouble is that on execution I get error message mspaint caused invalid pagefault in module msvcrt.dll at 0157:7fd796a . When I run this program on other machine which is also similar one ( IBM Pentium ) It runs properly. I have no clue of what is happening with this simple application. When I try opening the applications which are not microsoft applications my program works perfectly well on both the machines.Why is this invalid page fault problem in launching only microsoft apllications??Can someone please guide me???? :mad: :mad:
-
I am having a simple dialog based application on visual c++ 5.0 . I am just trying to create one process by CreateProcess() API in which I am trying to open mspaint or msword i.e microsoft office applications. The code I have written on pushbutton event is as follows. void CCreatprocessDlg::OnRun() { STARTUPINFO siStartInfo; PROCESS_INFORMATION piProcInfo; BOOL fPass; fPass = CreateProcess("c:\\Program Files\\Accessories\\Mspaint.exe", NULL, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &siStartInfo, &piProcInfo); if (!fPass) MessageBox("Can not execute WordPad.exe.", "Warning",MB_ICONHAND); } The trouble is that on execution I get error message mspaint caused invalid pagefault in module msvcrt.dll at 0157:7fd796a . When I run this program on other machine which is also similar one ( IBM Pentium ) It runs properly. I have no clue of what is happening with this simple application. When I try opening the applications which are not microsoft applications my program works perfectly well on both the machines.Why is this invalid page fault problem in launching only microsoft apllications??Can someone please guide me???? :mad: :mad:
Hi there, As far as I know you MUST initialise the STARTUPINFO structure before you do anything with it. I would use code such as this to do what you are doing: StartupInfo.cb = sizeof(STARTUPINFO); StartupInfo.lpReserved = NULL; StartupInfo.lpDesktop = NULL; StartupInfo.lpTitle = NULL; StartupInfo.dwFlags = STARTF_USESHOWWINDOW; StartupInfo.cbReserved2 = 0; StartupInfo.lpReserved2 = NULL; StartupInfo.wShowWindow = SW_SHOWNORMAL; bResult = CreateProcess ("c:\\Program Files\\Accessories\\Mspaint.exe", NULL, NULL, NULL, FALSE, 0, NULL, NULL, &StartupInfo, &ProcessInfo); Bad things can happen if you don't use sizeof! Also, beware of some things like the current directory. CreateProcess won't set the current directory so if the application you are running looks in the current directory for it's files and you have a file with the same name in your directory it will use that one! Always a good idea to set the current directory to where the app is before running it! Stravaiger :cool:
-
I am having a simple dialog based application on visual c++ 5.0 . I am just trying to create one process by CreateProcess() API in which I am trying to open mspaint or msword i.e microsoft office applications. The code I have written on pushbutton event is as follows. void CCreatprocessDlg::OnRun() { STARTUPINFO siStartInfo; PROCESS_INFORMATION piProcInfo; BOOL fPass; fPass = CreateProcess("c:\\Program Files\\Accessories\\Mspaint.exe", NULL, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &siStartInfo, &piProcInfo); if (!fPass) MessageBox("Can not execute WordPad.exe.", "Warning",MB_ICONHAND); } The trouble is that on execution I get error message mspaint caused invalid pagefault in module msvcrt.dll at 0157:7fd796a . When I run this program on other machine which is also similar one ( IBM Pentium ) It runs properly. I have no clue of what is happening with this simple application. When I try opening the applications which are not microsoft applications my program works perfectly well on both the machines.Why is this invalid page fault problem in launching only microsoft apllications??Can someone please guide me???? :mad: :mad:
void CCreatprocessDlg::OnRun() { STARTUPINFO siStartInfo; PROCESS_INFORMATION piProcInfo; BOOL fPass; // ADD THIS memset( &siStartInfo, 0, sizeof( siStartInfo )); siStartInfo.cb = sizeof( siStartInfo ); fPass = CreateProcess("c:\\Program Files\\Accessories\\Mspaint.exe", NULL, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &siStartInfo, &piProcInfo); if (!fPass) MessageBox("Can not execute WordPad.exe.", "Warning",MB_ICONHAND); } That should get it.