spawn and kill a process - Programmer

This is a discussion on spawn and kill a process - Programmer ; Folks, I want to spawn an executable (the path is actually a shortcut to the exe) from my program (a console application), and there seems to be no way of doing that using _spawnl() or CreateProcess(). Both return error code ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: spawn and kill a process

  1. spawn and kill a process

    Folks,

    I want to spawn an executable (the path is actually a shortcut to the
    exe) from my program (a console application), and there seems to be no
    way of doing that using _spawnl() or CreateProcess(). Both return
    error code 2 (File not found).

    If i use ShellExecute to launch the exe, it does the job fairly well,
    but the problem is, it returns HINSTANCE, and i can not use this to
    kill the process (i tried TerminateProcess() but it failed; then i
    tried using OpenProcess() to get the handle using this HINSTANCE, but
    even that failed)

    All i want to do is launch a process (using shortcut to the actual
    file) and then after some time kill it, but this obviously simple
    thing has wasted many hours.

    Is there a way to do it folks?

    /S

    P.S. I am not a member of this groups, i'd appreciate it if you Cc the
    replies to me.

  2. Re: spawn and kill a process

    darash@hotmail.com (darash) wrote in message news:...
    > Folks,
    >
    > I want to spawn an executable (the path is actually a shortcut to the
    > exe) from my program (a console application), and there seems to be no
    > way of doing that using _spawnl() or CreateProcess(). Both return
    > error code 2 (File not found).
    >
    > If i use ShellExecute to launch the exe, it does the job fairly well,
    > but the problem is, it returns HINSTANCE, and i can not use this to
    > kill the process (i tried TerminateProcess() but it failed; then i
    > tried using OpenProcess() to get the handle using this HINSTANCE, but
    > even that failed)
    >
    > All i want to do is launch a process (using shortcut to the actual
    > file) and then after some time kill it, but this obviously simple
    > thing has wasted many hours.
    >
    > Is there a way to do it folks?
    >
    > /S
    >
    > P.S. I am not a member of this groups, i'd appreciate it if you Cc the
    > replies to me.


    You can find how Apache Handle the CreateProcess() Win32 API here:

    http://www.slink-software.com/W/SrcD....28.sdoc/N_109

    Here's the code for TerminateProcess().

    http://www.slink-software.com/W/SrcD....28.sdoc/N_110

    --
    The "source" is out there.

+ Reply to Thread