Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. invalid page fault - code

invalid page fault - code

Scheduled Pinned Locked Moved The Lounge
c++helpquestionjsontutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    P S Thakur
    wrote on last edited by
    #1

    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:

    L M 2 Replies Last reply
    0
    • P P S Thakur

      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:

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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:

      1 Reply Last reply
      0
      • P P S Thakur

        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:

        M Offline
        M Offline
        Matt Philmon
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups