C++ Winapi - System(), CreateProcess, ShellExecute
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: C++ Winapi - System(), CreateProcess, ShellExecute

  1. #1
    Join Date
    Apr 2008
    Posts
    214

    C++ Winapi - System(), CreateProcess, ShellExecute

    So, I need to have some things uninstalled and as the user, I can uninstall anything, so the format of the string can be anything:

    Here are some for example
    Code:
    MsiExec.exe /I{A040AC77-C1AA-4CC9-8931-9F648AF178F6}
    
    RunDll32 C:\PROGRA~1\COMMON~1\INSTAL~1\engine\6\INTEL3~1\Ctor.dll,LaunchSetup "C:\Program Files\InstallShield Installation Information\{8B12BA86-ADAC-4BA6-B441-FFC591087252}\Setup.exe"  /uninstall
    
    C:\WINDOWS\IsUninst.exe -fC:\Program Files\TOSHIBA\Power Saver\Uninst.isu" -c"C:\WINDOWS\system32\TPSDel.dll
    
    "C:\Program Files\Windows Media Player\wmsetsdk.exe" /UninstallAll
    
    rundll32.exe "C:\Program Files\Synaptics\SynTP\SynISDLL.dll",standAloneUninstall
    
    C:\WINDOWS\system32\\MSIEXEC.EXE /x {9541FED0-327F-4df0-8B96-EF57EF622F19}
    
    "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Updates\hotfix.exe" "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Updates\M928366\M928366Uninstall.msp"
    
    C:\PROGRA~1\MAGICD~1\UNWISE.EXE C:\PROGRA~1\MAGICD~1\INSTALL.LOG
    
    RUNDLL32.EXE C:\WINDOWS\system32\ialmrem.dll,UninstallW2KIGfx2ID PCI\VEN_8086&DEV_27A6 PCI\VEN_8086&DEV_27A2
    As the person writing the code:

    I could use system(variable); and everything would be all good, except for the cmd box that pops up with it.

    I could use ShellExecute with some of them working (as long as i removed beginning and trailing quotes), and having the programs mem usage jump from about 4,000K to 6,000K and try to figure out how to get the rest to work

    or I could use CreateProcess, which doesnt change mem usage that much (which is why i was wanting to use it) but for all entries brings up "The application failed to initialize properly (0xc0000005)". (0xc0000005) is an access violation memory error. This is actually quite weird since just a day or two ago, CreateProcess was acting more like what ShellExecute was doing. Don't ask me what I had when this was happening...I have changed much of my code since then, but the below is basically what I had to execute it.

    Code:
    void StartProcess(char* szExe)
    {
    
        STARTUPINFO startupInfo;
        PROCESS_INFORMATION processInfo;
    
        ZeroMemory( &startupInfo, sizeof(processInfo) );
        startupInfo.cb = sizeof(startupInfo);
        ZeroMemory( &processInfo, sizeof(processInfo) );
    
        if (CreateProcess(0, szExe, 0, 0, FALSE, 0, 0, 0, &startupInfo, &processInfo))
        {
            WaitForSingleObject( processInfo.hProcess, INFINITE );
        }
        else
        {
            MessageBox(NULL, szExe, "", MB_OK); //just using this to see what shows and doesnt show...will change eventually.
        }
        CloseHandle( processInfo.hProcess );
        CloseHandle( processInfo.hThread );
    }
    So, I could try to use ShellExecute, but then I would have to figure out a way to parse every single known format, but because people have their different preferences it would almost be endless, in my opinion

    or if there was a way to do something like system() but without the console application box..then that would be awesome...


    any ideas?

  2. #2
    Join Date
    Feb 2002
    Posts
    4,640

    Re: C++ Winapi - System(), CreateProcess, ShellExecute

    Code:
        STARTUPINFO startupInfo;
        PROCESS_INFORMATION processInfo;
    
        ZeroMemory( &startupInfo, sizeof(processInfo) );
        startupInfo.cb = sizeof(startupInfo);
        ZeroMemory( &processInfo, sizeof(processInfo) );
    'startupInfo' is not the same type as 'processInfo'. I don't think they are the same size...

    Viggy

  3. #3
    Join Date
    Apr 2008
    Posts
    214

    Re: C++ Winapi - System(), CreateProcess, ShellExecute

    Wow, I didn't notice that, obviously. Thanks. Things are working now.

  4. #4
    Join Date
    Feb 2002
    Posts
    4,640

    Re: C++ Winapi - System(), CreateProcess, ShellExecute

    No problem!

    Viggy

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center