CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: executable

  1. #1
    Guest

    executable

    How to use this command :

    WinExec()
    or
    ShellExecute()
    or
    CreateProcess()

    I need to execute and esecutable program by un program (c:\projet.exe).
    please help me .
    [email protected]



  2. #2
    Join Date
    Apr 1999
    Posts
    23

    Re: executable

    Hi,

    you can run an exe file, or for that matter, open any file by using shellexec:

    ShellExecute(NULL,"open",filename,parameters,default_path,SW_RESTORE);

    parameters are arguments passed to the exe app
    refer to msdn help on shellexec.

    hope that helps

    Chao


  3. #3
    Join Date
    May 1999
    Posts
    26

    Re: executable


    You can use CreateProcess as follows:

    STARTUPINFO StartupInfo;

    memset(&StartupInfo, 0, sizeof(StartupInfo));
    StartupInfo.cb = sizeof(StartupInfo);

    StartupInfo.lpReserved = NULL;
    StartupInfo.dwFlags = STARTF_USESHOWWINDOW; // if you want to show the window
    StartupInfo.wShowWindow = SW_SHOW; // if you want to show the window
    StartupInfo.cbReserved2 = 0;
    StartupInfo.lpReserved2 = NULL;

    PROCESS_INFORMATION ProcessInformation;

    // Suppose strExeName is the name of the exe (C:\project.exe)
    // strCommandLine is the command line arguments string
    // strWorkingDir is the working directory for the exe

    BOOL bSuccess;
    bSuccess = CreateProcess(strexeName, // pointer to name of executable module
    (LPTSTR)(LPCTSTR)strCommandLine, // pointer to command line string
    NULL, // process security attributes (cannot be inherited)
    NULL, // thread security attributes (cannot be inherited)
    TRUE, // handle inheritance flag
    0, // creation flags
    NULL, // pointer to new environment block
    strWorkingDir, // pointer to current directory name
    &StartupInfo, // pointer to STARTUPINFO
    &ProcessInformation); // pointer to PROCESS_INFORMATION


    Hope this helps...
    Santhosh



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