Results 1 to 3 of 3

Thread: How to launch exe under W2K & W98 other tan with CreateProcess API or Shell func ?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Location
    Strasbourg
    Posts
    30

    Question How to launch exe under W2K & W98 other tan with CreateProcess API or Shell func ?

    I have an application (EXE file) that perfectly works under NT when I launch it with the API CreateProcess :


    Public Function ExecCmd(cmdline As String, intWindowDisplay As Integer)
    'Public Function ExecCmd(cmdline As String)

    Dim proc As PROCESS_INFORMATION
    Dim start As STARTUPINFO
    Dim lReturndVal As Long

    ' Initialize the STARTUPINFO structure:
    start.cb = Len(start)
    start.dwFlags = start.dwFlags + STARTF_USESHOWWINDOW ' 1 = Bit positon of STARTF_USESHOWWINDOW
    start.wShowWindow = intWindowDisplay ' Gives the way the window is displayed

    ' Start the shelled application:
    lReturndVal = CreateProcessA(vbNullString, cmdline, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, _
    vbNullString, start, proc)

    ' Wait for the shelled application to finish:
    lReturndVal = WaitForSingleObject(proc.hProcess, INFINITE)
    Call GetExitCodeProcess(proc.hProcess, lReturndVal)
    Call CloseHandle(proc.hThread)
    Call CloseHandle(proc.hProcess)
    ExecCmd = lReturndVal

    End Function


    When I execute the same function under W2K or W98, the EXE does not work as it should.
    Nevetheless, when I launch the EXE in W2K or W98 command line (Execute operation in startup menu), the EXE works properly !

    Where could be the problem ?
    Is there something to modify in the Function above ?

    Thank you all for your answers.

    she

  2. #2
    jim mcnamara
    Guest
    There are other api calls - ShellExecuteEx and ShellExecute -
    these are useful because they can start an app based on file association, ie., fire up internet explorer if the argument is an url.

  3. #3
    Hyperactive Member rplcmint's Avatar
    Join Date
    Jan 2001
    Location
    Stockton, CA
    Posts
    333

    WaitForSingleObject(proc.hProcess, INFINITE)

    I have a question about CreateProcess and how to use it properly.

    Currently I am starting an executable that constantly runs. I receive the process handle, but what do I do with it. Does WaitForSingleObject function tell us when the application is completely started? What is this function used for? From what I see, it provides us with the information to kill threads after the program is executing. Then we use the process info to kill any threads that started the app, yet does not kill the app from running.

    I am new to the API functions, I use them but not sure what the idea behind all this is.

    I appreciate your help.


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