-
Need some VB help.
I know this is forum is for sercuirty related programing but I'm already here and I just have a lil question to ask so anyway.
I need to make a program that will run in the back ground and will just stay there and every 5 min or so it see if a program is runing and if it is it will kill it, I have no idea how I could do this.
I was thinking that I could just use a timer but then I relized that I would get a run time error becouse once it trys to close it and its not there it will close.
Well any help would be aprecated.
-
Sorry I can't help, but, ummm...why would you like a program like that?
-
ok ok no its not for some kind of weird virus or something lol.....My freinds (for real) wants me to make him a program that does that, becouse his lil brother is addicted to ever quest and he can never get on the computer so he wants me make him that app and I figuered that would be the best way.
-
Sounds fun...would like to see the results when you're done.
I'd look for the proper code now, but I have a big report due in the morning and I have done nothing on it yet, sorry.
-
I've been learning to program in C/C++ by myself for a couple of months an haven't got up to doing anything like that
.... but i remeber i downloaded this program for a websight that ran hidden and every 5 minutes it logged off windows.. i have the guys websight and you can email him from it asking what u posted.
hope this helps you-*** http://crayzee.host.sk/ ***
-
thanks, x718xpimpm, but thats not what I was really looking for his brother is not all that smart but he knows how to reinstall the game and to close all programs running (thats why I made it hidden) but anyway I have it pretty much done but I just need that section of code that will do what i was saying but I can't find it.....
-
if i understand you correctly you would like to have an app which can kill a specific runnign app
this code is noramly used for install routins to kill an app with an earlyier version, but i think if you change the code slightly it should work for you:
this code searches for a specific window caption, gets the window handle and kills it via sendkey
'begin code listing
Option Explicit
DefInt A-Z
Declare Function Findwindow Lib "User" (ByVal Class&, ByVal Caption&)
Declare Function GetWindow Lib "User" (ByVal hWnd, ByVal wCmd)
Declare Function GetNextWindow Lib "User" (ByVal hWnd, ByVal wCmd)
Declare Function GetWindowText Lib "User" (ByVal hWnd, ByVal Buf$, ByVal lBuf)
Declare Sub ShowWindow Lib "User" (ByVal hWnd, ByVal nCmd)
Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Any) As Long
Const WM_CLOSE = &H10
Const GW_HWNDFIRST = 0
Const GW_HWNDNEXT = 2
Function GetWinCaption$ (hWnd)
Dim strCaption As String * 256
Dim NumChars
NumChars = GetWindowText(hWnd, strCaption, 256)
GetWinCaption$ = Left$(strCaption, NumChars)
End Function
Sub Main ()
Dim Wnd, lResult As Long, iResult
Wnd = SearchWindow("Your application name")
If Wnd <> 0 Then
Result = MsgBox("Another copy of *** is running, do you want to terminate it before starting the installation?", 4, "KillApp")
If iResult = 6 Then
lResult = SendMessage(Wnd, WM_CLOSE, 0, 0&)
End If
End
End If
End Sub
Function SearchWindow (ByVal strSearch$)
Dim hWnd
' Find the first window's handle
hWnd = Findwindow(0, 0)
hWnd = GetWindow(hWnd, GW_HWNDFIRST)
' Set all comparison to upper case
strSearch$ = UCase$(strSearch$)
' Start the loop for all windows
Do While hWnd <> 0
' If the searching caption is a sub string of the current window's caption
If InStr(UCase$(GetWinCaption(hWnd)), strSearch$) Then
' Return the window's handle
SearchWindow = hWnd
Exit Function
End If
' Get the next window handle
hWnd = GetNextWindow(hWnd, GW_HWNDNEXT)
Loop
End Function
'end code listing
now for preventing that anybody can end this prog try to disable strg-alt-entf
hope that will help you
----------------------------------------------------------------------------------------------------------------------
"Knowledge is the Real Power"
-
-
thanks meister, I think that was what I was looking for, but one question,
Wnd = SearchWindow("Your application name") <- what should I put for the aplication name, I mean like just what apperas at the top of the program or the excutable?
-
Get a program like a game code cheater. And run it the same time as the game. It will show all its handlers and other codes. I you have Microsoft Visual C++ then you can do the same thing with the program called spy++.
-
ahhhhhhh I can't get it working....well I can run it with out errors but its just not doing anything so I'm guessing I'm putting some thing wrong in Wnd = SearchWindow but i dunno, any help? :)
-
sorry Mucolaca ;)
after cutting out some unneeded things it should work now
'begin code listing
Attribute VB_Name = "Module1"
Option Explicit
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_CLOSE = &H10
Sub main()
Dim number, ending
number = FindWindow(vbNullString, "Unbenannt - Editor")
ending = SendMessage(number, WM_CLOSE, 0, 0&)
End Sub
'end code listing
i know it looks shorter than befor but it works...
in findwindow input the window name
-----------------------------------------------------------------------------------------------------------------------
"Knowledge is the Real Power"
-
lol its ok but thanks for the help, but I keep getting a syntax error w/ Attribute VB_Name = "Module1" I still got to play around with it some so I will see if i can get it working later to night.
-
Hey Muco, I didn't bother to read the whole code, but it would be a good idea to check up all those APIs... Use API Viewer (standard w/ vss 6.0)
You don't need to add attribute_vbname, thats just to say he's put the code in "module1".
And take out option explicit, it will conflict with "dim number, ending"
-
Haha, my friend and I made a computer prank that you input the time and it will shutdown the computer at that specific time. Not what you are looking for though sorry.