OK, my eyes are hurting from searching the forums for an answer. Whats the code to close an outside app. Say I wanted to close AIM or something. Thanks. Now im going to go wash my eyeballs.
-quac
Originally posted by duc Im not to good with API's.
Got any examples?
If anyone could show me that would be nice. Also I already tried the code that Hack posted. I am trying to close AIM because it interferes with my cousins program so he wants me to have it close aim when it starts. THX
I tried all of the examples there and none of them worked. The code posted above does not work either....hmm....i tried planet source code too. AIM is invincible :-P
did you try changing the "My Program" to work on aim?? anyway, just so you know, if the value of retval is 0, then it means it didn't find the window! check if it actually finds the hwnd of aim. another way to do it, is to use the sendmessage api and send a wm_close message to aim!
Best Regards,
seec77
If you helped me, cosinder yourself thanked.
Get each and every Garfield strip here! Here you can get all Calvin & Hobes strips!
Damn UComics! It was probably unprofitable for them to allow us to just download Garfield and Calving & Hobes strips... so they made folder indexing unallowed on their server!!!
You have to replace "My Window" with the actual title of the program window. I don't use AIM, but I think that its title should be "AOL Instant Messenger". Check the title bar.
Originally posted by da_haCKEr You have to replace "My Window" with the actual title of the program window. I don't use AIM, but I think that its title should be "AOL Instant Messenger". Check the title bar.
Nothings working. Im gonna search google for some.
what did you change "My Program" to that it didn't work? and did you check if the program actually finds the window?? cause then, that means that the closing part didn't work!
Best Regards,
seec77
If you helped me, cosinder yourself thanked.
Get each and every Garfield strip here! Here you can get all Calvin & Hobes strips!
Damn UComics! It was probably unprofitable for them to allow us to just download Garfield and Calving & Hobes strips... so they made folder indexing unallowed on their server!!!
This code should do the trick if you are using Win9x, but for Windows version running the NT kernel, there's some more things to be done to gain access to the process. I didn't do that because I couldn't find the values of the constants needed to gain access. The MSDN is very bad in that way. They should list the value of the Constant along with its description.
Anyway, If u r using Win9X, this should work. Replace "MSMSGS.EXE" with the exe name of AIM.
BTW, This code is not very good since I have modified the code written by somebody else. (ALLAPI)
VB Code:
Const TH32CS_SNAPHEAPLIST = &H1
Const TH32CS_SNAPPROCESS = &H2
Const TH32CS_SNAPTHREAD = &H4
Const TH32CS_SNAPMODULE = &H8
Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE)
Const TH32CS_INHERIT = &H80000000
Const MAX_PATH As Integer = 260
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * MAX_PATH
End Type
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function Process32First Lib "kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long)
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function OpenProcess Lib "Kernel32.dll" (ByVal dwDesiredAccessas As Long, ByVal bInheritHandle As Long, ByVal dwProcId As Long) As Long
OK, wait....Since AIM just minimizes when you do the code where u fill in "My Program" I need a code where it finds the program and kills the app. I think i found teh handle using spy++ [forgot bout this post]
er one more thing. I already have code posted in the declarations section so what should i do with any new declarations code the people post? I'm in desperate need of a VB book. Obviously