Post

 Resources 

Console

Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 How does my app end a process that it started

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List Spell Checker
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

   Insert an File
Check here to include your profile signature.
Check here to subscribe to this topic.
    

T O P I C    R E V I E W
milk Posted - Dec 13 2006 : 06:13:30 AM
I want my VB6 App to start a mini server daemon (I'm trying tiny web atm) and then terminate it when my app closes. I can activate it with... TinyPid = Shell("tiny.exe html 8080", vbNormalNoFocus) ...but how do I then close it?

I found a number of lengthy solutions for this already, but they are all too general. I'm just wondering if there is an easy method (not kill!). I have the process ID after all. I take it I'll have to use API calls

Soz if discussed already

Edit.... I've found a solution

Sub KillByPid(ByRef ProcessId As Double, ByRef Result As Integer)
Dim strWQL As String
Dim objProcess As Variant
Dim objResult As Variant
Dim wmi As Variant

Set wmi = GetObject("winmgmts:")
strWQL = "select * from win32_process where ProcessId='" & ProcessId & "'"
Set objResult = wmi.ExecQuery(strWQL)

For Each objProcess In objResult
Result = objProcess.Terminate(0)
Next objProcess
End Sub


I can concieve a problem with this where the launched process self terminates and another process is started with the same PID, so I guess I will need to terminate it by PID and Name. I think I'm there as.... strWQL = "select * from win32_process where ProcessId='" & ProcessId & "' and name='" & NameStr & "'" ...seems to work. comments still very much appriciated as I'm not at all familiar with the winmgmts: object. I'm pretty sure it's a W2K+ only object.
2   L A T E S T    R E P L I E S    (Newest First)
milk Posted - Jan 21 2007 : 12:21:26 PM
Cheers for the info, here's my even later response; funnily enough I'm using SendMessage loads between my main app and the mini CGI app the server calls to transfer the user data... it makes sense to use it to close the server as well. thanks
Almar Joling Posted - Dec 27 2006 : 11:04:49 AM
Kinda late... But you could possibly get the window of the program when knowing the processid, and then use the SendMessage api to send a WM_QUIT message to the window. :)

VBGamer © Go To Top Of Page
This page was generated in 0.08 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.