CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2021
    Posts
    51

    Can't CreateProcess application?

    Hi,
    I use the following code to launch excel:

    HTML Code:
       STARTUPINFO Start;
        PROCESS_INFORMATION ProcInfo;
        ZeroMemory(&Start, sizeof(STARTUPINFO));
        Start.cb = sizeof(Start);
        Start.dwFlags = STARTF_USESHOWWINDOW;
    
        
        LPWSTR pszExcelPath =
    	 L"C:\\Program Files\\Microsoft Office\\Office14\\EXCEL.EXE";
    
        ::CreateProcess(NULL, pszExcelPath, 0, 0, 1,
    	  NORMAL_PRIORITY_CLASS, 0, NULL, &Start, &ProcInfo);
    but i always get this error,

    Exception thrown at 0x00007FF8AB5B7500 (KernelBase.dll) in sap.exe: 0xC0000005: Access violation writing location 0x00007FF81E0E04D4.

    How do I fix it?
    Thanks you!

  2. #2
    Join Date
    Jun 2021
    Posts
    51

    Re: Can't CreateProcess application?

    Hi,
    I'm not sure but changing the code to worked for me.
    ::CreateProcess(pszExcelPath,NULL, 0, 0, 1,
    NORMAL_PRIORITY_CLASS, 0, NULL, &Start, &ProcInfo);
    I've got a new question here.
    Please help!

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,219

    Re: Can't CreateProcess application?

    Quote Originally Posted by Dang.D.Khanh View Post
    Hi,
    I'm not sure but changing the code to worked for me.
    ::CreateProcess(pszExcelPath,NULL, 0, 0, 1,
    NORMAL_PRIORITY_CLASS, 0, NULL, &Start, &ProcInfo);
    I've got a new question here.
    Please help!
    It is very clear described in CreateProcess documentation:
    lpCommandLine

    The command line to be executed.

    The maximum length of this string is 32,767 characters, including the Unicode terminating null character. If lpApplicationName is NULL, the module name portion of lpCommandLine is limited to MAX_PATH characters.

    The Unicode version of this function, CreateProcessW, can modify the contents of this string. Therefore, this parameter cannot be a pointer to read-only memory (such as a const variable or a literal string). If this parameter is a constant string, the function may cause an access violation.
    Victor Nijegorodov

  4. #4
    Join Date
    Jun 2021
    Posts
    51

    Re: Can't CreateProcess application?

    Hi Sir, Thanks for clarifying.
    my big mistake. I corrected my code.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured