Hi,
How do I make a program run hidden in the background?? Can't figure out how to do this. Please help.
Thanks,
Kevin
Printable View
Hi,
How do I make a program run hidden in the background?? Can't figure out how to do this. Please help.
Thanks,
Kevin
Be more clear, do you still want it in ctrl+alt+del menu? etc.
No, I would like it to be completely hidden, or as hidden as possible. I don't want it in the ctrl, alt, del menu.
Thanks,
Kevin
to hide you're app on win9X machines in the CTRL+ALT+DEL List, here the code : (dont work on NT machines)
-----------------
Public Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Public Declare Function GetCurrentProcess Lib "kernel32" () As Long
Public Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long
Public Const RSP_SIMPLE_SERVICE = 1
Public Const RSP_UNREGISTER_SERVICE = 0
Public Sub MakeMeService()
Dim pid As Long
Dim reserv As Long
pid = GetCurrentProcessId()
regserv = RegisterServiceProcess(pid, RSP_SIMPLE_SERVICE)
End Sub
Public Sub UnMakeMeService()
Dim pid As Long
Dim reserv As Long
pid = GetCurrentProcessId()
regserv = RegisterServiceProcess(pid, _
RSP_UNREGISTER_SERVICE)
End Sub
That did not work. Where do I put it in a module?? What I want to do is completely hide the program. Right, know what I see when I run it in vb5 is the normal form window. I want to make it run in the background at startup, and be hidden, so that it can not be seen.
Thanks,
Kevin
If you want to hide the form, set Visible and ShowInTaskbar to false.
To make it run at startup, add a new key with your executable name as the value in the registry at HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
KevDog , taLon has given u the answer , yes u have to put the code he gave u in a module but u have to call the function MakeMeService() from the form_load() .... and as wade told u , u can also put it in the registry so that it runs with windows , but beware if the user Presses Ctrl-Alt-Del just when windows starts , and before "rundll.exe" loads the program will show in the list , but once rundll has completed running the program is practically untracable unless the user has made his own code to list active programs running under windows ....
I tried taLON's code but get an error msg saying
--
Can't find DLL Entry Point RegisterServiceProcess in Kernel 32
--
And I checked Register... API declare from my API VIEW and find no name match. What am I missing? I am using VB6 pro.
Oops!, I missed taLon's note : don't work on NT. I am using NT! Is that the reason why there is no RegisterServiceProcess API in my API View?
I can get the program to not show up in the ctrl + alt + del menu, that codes works great, thanks! However, when I make the program set to not show up in the taskbar and not be visible it will not run, it runs but will not work. it does nothing, However when I change the settings to show in taskbar and be visible it works. Why?? How can I make it work and be hidden at the same time??
Thanks Again,
Kevin
The app is doing nothing b/c it doesn't have any type of focus. If it doesn't have any focus then it's not going to resoond to any events. I'm not sure how to fix it but I'd be interested in hearing. I'm assuming it will be something w/ the API.
i also have a question similiarly to KevDog.
But I want my program to check all the time for specific even.
I know that it is a kind of Hooks but I don't know where to start.
What I can hook just when my form gotfocus not when it lostfocus or minimize.
What I really want to know is like some anti-virus program do. They check all the time for file process or whatever to protect our computer. That great
Anyone know how to do.
Thanks
vbkids
Make a new procedure called Sub Main() and put your form_load code in it. Then make Sub Main your Startup Object (in Project Properties).
Wade,
How's question are you answering mine or vbkids??
Kevin
Yours Kevin. I made a program recently that closes down an antivirus program, updates a set of files if necessary, and relaunches the antivirus. It's transparent to the user, and I used Sub_Main instead of Form_Load.
Wade,
Thanks. However, it is still not working, I renamed my Sub_Load to Sub_Main, and set it as startup in properties, but it gives me an invaild outside procedure error when I try to run it. My Sub_Main code looks like this:
Private Sub_Main()
MakeMeService
Dim tdFile As Integer
tdFile = FreeFile
Open "C:\Log.txt" For Append As tdFile
Print #tdFile, ""
Print #tdFile, "Date: " & CStr(Date)
Print #tdFile, "Time: " & CStr(Time)
Close #tdFile
End Sub
Thanks,
Kevin
I didn't declare mine as private. Which line is it giving you the error message for?
Private Sub_Main() should beQuote:
Wade,
Thanks. However, it is still not working, I renamed my Sub_Load to Sub_Main, and set it as startup in properties, but it gives me an invaild outside procedure error when I try to run it. My Sub_Main code looks like this:
Private Sub_Main()
MakeMeService
Dim tdFile As Integer
tdFile = FreeFile
Open "C:\Log.txt" For Append As tdFile
Print #tdFile, ""
Print #tdFile, "Date: " & CStr(Date)
Print #tdFile, "Time: " & CStr(Time)
Close #tdFile
End Sub
Thanks,
Kevin
Private Sub Main()
With out the underscore _
Wade,
Every line that is in the Sub_Main is giving me a error message that same invaild outside procedure error.
Thanks,
Kevin
Kevin, to use a Sub Main, you have to add a module to your program. And place code for it there. Are you doing that?
Larisa
No, I was not. I put the Sub Main in a new module, and set the properties to load Sub Main at startup, but it still wont work, should I place the sub main code somewhere else also? And should I set the form to be visible or not?
Thanks,
Kevin
Kevin,
Vincent and Larisa are right. In my app, I have a form that I used for testing, but Sub Main() was in a module and it doesn't have an underscore.
I have was is in my Sub Form_Load in a new module, and also in my form under Sub Main without the underscore. I completely deleted my Form_Load Sub. What loads at startup loads fine, the code is setup to print the date and time to a text file, that works fine, however it will not run any of my other code, it is supposed to send keystrokes to the text file also. When I set my form to run at startup (instead of Sub Main), everything works fine when I set it to visible. But then when I set it to invisible, it only will send the date and time to the text file.
How are you sending the keystrokes?
Using the Form_KeyDown (keycode As Interger, Shift As Interger)
If keycode = 65 Then
Dim aFile As Interger
aFile = FreeFile
Open C:\Log.txt For Append As aFile
Print #afile, "a";
End If
That is how I am sending keystrokes.
Thanks,
Kevin
Kevin,
Since the form's not visible, the form events (such as Form_KeyDown) are not executed. Are you trying to log what a user types in other programs, since you said you want yours to run in the background?
Yes, that is what I am trying to do. Why won't it load it when it is not visible??
Thanks,
Kevin
It does load, but your form can't be clicked on if it's not visible. Even if it were visible, if the user was in another program, you wouldn't be able to log their keys. You need to use the API to do this.
How do I use the API to do it??
Kevin
Kevin,
Email me (or post your email address) and I'll send you a small project.
Wade,
I posted my e-mail address, and sent you an e-mail.
Thanks,
Kevin
To summ this thread up, for those of you who are just reading along (and don't care about the key capturing part). This is what you should do to create an INVISIBLE program.
1. Add a new module to your program.
2. Create a sub procedure called MAIN() in the new module.
3. Delete the form (if your not using it).
4. Set your startup object to SUB MAIN (see previous message).
If you want to hide the program form the task list, use the API that was talked about previously (for Win95/98). You can probably get one for NT/2000 from the Microsoft Knowledgebase. You'll have to do some searching.
----------------------------------------------------
ButtonWiz - Create Stylish Buttons for your Web Page
Joel Ryan Software
http://www.joelryan.com
----------------------------------------------------
in vb 6, you can select (at ProjectProperties) UNATTEND EXECUTION ..... (this option is ghosted, if u have a form in you're project, delete all forms , than u can use it)
taLON
btw: if anyone know the code to make a app as service (without rebooting) under NT / Win2k..... please email me ;)
To vbkids,
You can only hook from a really dll, not an activex one, so you can't write it in VB. look to c++, and you want a system hook. you'll get a copy of every event issued. Also, I think you have the option of pooping the message, so other apps don't get it. food for thought
I`m trying to do the same thisn :make a program running in the background
what do you mean by
4. Set your startup object to SUB MAIN (see previous message).