how close ms dos application

  • 14 years ago
        Hi

    I know how to start the application
       Call Shell("path", AppWinStyle.NormalFocus)

    very easy,
    but i want to close it too

    i searched a lot but noting works, like:
        Private Const wm_exit = &H10
        Private Declare Function GetForegroundWindow Lib "user32" () As Long
        Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

    Call SendMessage(prog, wm_exit, 0, 0)







    does somebody know a working code to close applications?






















  • 14 years ago
    Have you tried WM_DESTROY instead of WM_EXIT? In addition, you didn't show how the variable 'prog' was set so that makes it harder to understand
  • 14 years ago
      Well, I tried and it was the same
    i knew it would be the same because it is just the name of de constant: wm_exit, so it doesn't matter ( i think :) )






  • 14 years ago

    I think i have tried this a few years ago, and if i got it right you couldnt close a terminal/console-window via windows-messages.

    If your using 2k/xp then there is a program called 'taskkill'. If you can find out the pid of the process than just run that. However, to find the pid might be hard.

    EDIT:
    I dont think that WMEXIT, WMDESTROY etc. have the same value.






  • 14 years ago

    hmm, that is something
    i will search for it


  • 14 years ago

     I found it

    Call Shell("Taskkill -F -IM " & "hltv.exe")



    thx for helping



  • 14 years ago

    No problem!

    Good luck, and happy programming.



Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter” - Eric Raymond