Results 1 to 36 of 36

Thread: Making a program run in hidden in the background

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Seattle, WA, USA
    Posts
    46

    Post

    Hi,

    How do I make a program run hidden in the background?? Can't figure out how to do this. Please help.


    Thanks,

    Kevin

  2. #2
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    Post ambiguous question

    Be more clear, do you still want it in ctrl+alt+del menu? etc.

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Seattle, WA, USA
    Posts
    46

    Post

    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

  4. #4
    Guest

    Post solution for win9x

    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

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Seattle, WA, USA
    Posts
    46

    Post

    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

  6. #6
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    If you want to hide the form, set Visible and ShowInTaskbar to false.
    Wade

  7. #7
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    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
    Wade

  8. #8
    Hyperactive Member razzaj's Avatar
    Join Date
    Oct 1999
    Location
    jounieh
    Posts
    261

    Post

    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 ....
    - regards -
    - razzaj -

  9. #9
    Addicted Member
    Join Date
    Jan 2000
    Location
    BC, Canada
    Posts
    142

    Post

    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.

  10. #10
    Addicted Member
    Join Date
    Jan 2000
    Location
    BC, Canada
    Posts
    142

    Post

    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?

  11. #11

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Seattle, WA, USA
    Posts
    46

    Post

    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

  12. #12
    Member
    Join Date
    Jun 1999
    Posts
    52

    Post

    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.
    -Adam
    Yahoo!: _eclipsed_
    ICQ:18534929

  13. #13
    Junior Member
    Join Date
    Feb 2000
    Posts
    19

    Post

    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

  14. #14
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    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

  15. #15

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Seattle, WA, USA
    Posts
    46

    Post

    Wade,

    How's question are you answering mine or vbkids??


    Kevin

  16. #16
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    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

  17. #17

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Seattle, WA, USA
    Posts
    46

    Post

    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

  18. #18
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    I didn't declare mine as private. Which line is it giving you the error message for?
    Wade

  19. #19
    Guest

    Post


    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() should be
    Private Sub Main()

    With out the underscore _

  20. #20

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Seattle, WA, USA
    Posts
    46

    Post

    Wade,

    Every line that is in the Sub_Main is giving me a error message that same invaild outside procedure error.


    Thanks,

    Kevin

  21. #21
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308

    Post

    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

  22. #22

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Seattle, WA, USA
    Posts
    46

    Post

    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

  23. #23
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    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.

    Wade

  24. #24

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Seattle, WA, USA
    Posts
    46

    Post

    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.

  25. #25
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    How are you sending the keystrokes?
    Wade

  26. #26

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Seattle, WA, USA
    Posts
    46

    Post

    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

  27. #27
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    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?
    Wade

  28. #28

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Seattle, WA, USA
    Posts
    46

    Post

    Yes, that is what I am trying to do. Why won't it load it when it is not visible??


    Thanks,

    Kevin

  29. #29
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    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.
    Wade

  30. #30

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Seattle, WA, USA
    Posts
    46

    Post

    How do I use the API to do it??


    Kevin

  31. #31
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Post

    Kevin,

    Email me (or post your email address) and I'll send you a small project.
    Wade

  32. #32

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Seattle, WA, USA
    Posts
    46

    Post

    Wade,

    I posted my e-mail address, and sent you an e-mail.


    Thanks,

    Kevin


  33. #33
    New Member
    Join Date
    Sep 1999
    Location
    Utah
    Posts
    11

    Post Sum it Up

    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
    ----------------------------------------------------

  34. #34
    Guest

    Post

    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



  35. #35
    New Member
    Join Date
    Feb 2000
    Posts
    8

    Post

    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

  36. #36
    New Member
    Join Date
    Feb 2000
    Posts
    14

    Post

    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).


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width