How to get ShellExecute () in vc++/c++

Discussion in 'Programming' started by visweswaran28, Jan 19, 2010.

  1. #1
    Hi,

    I am developing an application using vc++, in that, i have to execute shell command. I executed successfully using ShellExecute(). Now i want to know how to get the return value of that shell command, while executing mountvol like this command, it return list of drives, if I run using the above method, how can i get that return value.. can any one help me
     
    visweswaran28, Jan 19, 2010 IP
  2. NeoCambell

    NeoCambell Peon

    Messages:
    456
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Since you use VC++, I suggest you to use CreateProcess command since it gives you more control over the created application.

    If you use that you can use GetExitCodeProcess function to determine the return value.

    You may use following APIs for this.

    CreateProcess
    WaitForSingleObject
    TerminateProcess
    GetExitCodeProcess


    If you are interested in using ShellExecute, then use ShellExecuteEx which will return the process id that can be used with GetExitCodeProcess.
     
    NeoCambell, Jan 22, 2010 IP