Is there any function that i can call to close a application?

i want a program that can run a application, for example, notepad.exe.
After i run it, i want to close this Application...

Therefore, i called the function WinExec("notepad.exe", SM_SHOW);
but my question is: after i call this function, is there any way to close the application that i have just opened?

Please help me~ thanks ^_^
Steve~

Comments

  • : i want a program that can run a application, for example, notepad.exe.
    : After i run it, i want to close this Application...
    :
    : Therefore, i called the function WinExec("notepad.exe", SM_SHOW);
    : but my question is: after i call this function, is there any way to close the application that i have just opened?
    :
    : Please help me~ thanks ^_^
    : Steve~
    :
    [code]
    PostMessage(WM_CLOSE,0,0);
    [/code]

  • : : i want a program that can run a application, for example, notepad.exe.
    : : After i run it, i want to close this Application...
    : :
    : : Therefore, i called the function WinExec("notepad.exe", SM_SHOW);
    : : but my question is: after i call this function, is there any way to close the application that i have just opened?
    : :
    : : Please help me~ thanks ^_^
    : : Steve~
    : :
    : [code]
    : [red][b]::[/b][/red]PostMessage([red][b]hwndOfNotepad[/b][/red],WM_CLOSE,0,0);
    : [/code]
    :
    :
    [blue]See RED. You have to locate the HWND of the NOTEPAD you opened and post that message to it. The better way to run another application is [italic]CreateProcess()[/italic], because it returns a process handle, so you can close it from outside without looking for HWND of the main frame of the launched application.[/blue]
  • I misunderstood the question -- I thought he wanted to close the application that created the new process.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories