Results 1 to 21 of 21

Thread: Runing constantly at background?

  1. #1

    Thread Starter
    Hyperactive Member anita2002's Avatar
    Join Date
    Dec 2001
    Location
    In u'r Heart
    Posts
    482

    Wink Runing constantly at background?

    I want to know that how to keep my application running constantly at background?? And how to trigger it on specific action? Is there any other way except using timer? And is it possible by using Timer?
    please help me.
    Anita
    Can't imagine life without VB
    (Various Boyfriends)

  2. #2
    DerFarm
    Guest
    These guys have a time and hotkey DLL:

    http://www.merrioncomputing.com/Download/index.htm

    I'm not exactly sure what you're trying to do, but this should give
    you a start.

    HTH

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    I have an application that runs in the background as soon as the PC boots, and polls a server for the presence of a specific text file every 30 minutes. If it finds it performs a task, if it doesn't, it waits for another 30 minutes and checks again, so the answer to your question is: Sure...

    My application is installed in C:\WINDOWS\All Users\Start Menu\Programs\StartUp, so it starts when the PC boots. There is only one form, and it is hidden.

    I'm not sure where else to go with this in so far as I don't know what the specifics of your application needs are, but, I hope this helps.

  4. #4
    New Member xijoi_tech's Avatar
    Join Date
    Mar 2002
    Location
    San Diego, California
    Posts
    6

    Service, Maybe?

    I think you can run your application as a service, that way it is in the background, then you may be able to activate it by another program, it is just a thought
    The Real World... Huh?

  5. #5

    Thread Starter
    Hyperactive Member anita2002's Avatar
    Join Date
    Dec 2001
    Location
    In u'r Heart
    Posts
    482
    Hack,
    Can u give me u'r code..well i just want how to keep my aplication running. U said that in u'r application u r checking the status after some every 20 minutes..I want to do the exactly same thing. But i want to check whether the PC is connected to internet after every 30 seconds..How can i do that..please help me..
    Anita.
    Can't imagine life without VB
    (Various Boyfriends)

  6. #6

    Thread Starter
    Hyperactive Member anita2002's Avatar
    Join Date
    Dec 2001
    Location
    In u'r Heart
    Posts
    482
    Can anyone help me???
    Can't imagine life without VB
    (Various Boyfriends)

  7. #7
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    You'll certainly have to use timer control for that purpose... Create A Standard Exe, put it in StartUp and use the timer event to check the internet connection...What's the problem in it??

  8. #8

    Thread Starter
    Hyperactive Member anita2002's Avatar
    Join Date
    Dec 2001
    Location
    In u'r Heart
    Posts
    482

    Angry

    hello, can anybody tell me how to use timer control to run application on the background constantly? I'm not getting it..
    Please
    Anita
    Can't imagine life without VB
    (Various Boyfriends)

  9. #9

    Thread Starter
    Hyperactive Member anita2002's Avatar
    Join Date
    Dec 2001
    Location
    In u'r Heart
    Posts
    482
    can anybody?
    Can't imagine life without VB
    (Various Boyfriends)

  10. #10
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    well if you put a timer control on a form.. and set its interval to 60000 (i think that is as high as it goes, which should be a minute)

    Have an integer variable in your app...

    on the tmrMyTimer_Timer() event check the value of your variable... if it is >= 30 then run the check and set the variable back to 0 otherwise incriment the variable by 1.

    kinda like
    Code:
    Private Sub MyTmr_Timer()
       if MyVar >= 30 then
           CheckNetConnection
           MyVar = 0
       else
          MyVar = MyVar + 1
       end if
    end sub

  11. #11
    Member
    Join Date
    Mar 2002
    Posts
    42
    There is another way

    Just go to this page and there is a application called firedaemon. This will allow you to make any application to run as service. You can run it with parameters so that should make your life easier.
    Just call it from a shell with some parameters and that should do the trick

  12. #12
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    Originally posted by Mystical
    There is another way

    Just go to this page and there is a application called firedaemon. This will allow you to make any application to run as service. You can run it with parameters so that should make your life easier.
    Just call it from a shell with some parameters and that should do the trick
    that might do the trick.. but does not run on 95,98,Me platforms..

  13. #13
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    Anita...Timer is not used to "Run Programs in Background constantly" actually you'll have to make you exe a service... two years back I did it with some code...and this code is at my home pc... well... i believe i'll be able to post it...as soon as i get home...

  14. #14

    Thread Starter
    Hyperactive Member anita2002's Avatar
    Join Date
    Dec 2001
    Location
    In u'r Heart
    Posts
    482
    Originally posted by moinkhan
    Anita...Timer is not used to "Run Programs in Background constantly" actually you'll have to make you exe a service... two years back I did it with some code...and this code is at my home pc... well... i believe i'll be able to post it...as soon as i get home...
    Is it correct that i can't use Timer to run my application constantly at background? Can anybody help me? Please...How to keep my application running constantly on background? I'm confused...
    Thanks in Advance..
    Anita..
    Can't imagine life without VB
    (Various Boyfriends)

  15. #15

    Thread Starter
    Hyperactive Member anita2002's Avatar
    Join Date
    Dec 2001
    Location
    In u'r Heart
    Posts
    482
    Originally posted by anita2002
    Is it correct that i can't use Timer to run my application constantly at background? Can anybody help me? Please...How to keep my application running constantly on background? I'm confused...
    Thanks in Advance..
    Anita..
    Can anybody help me??
    Please....
    Can't imagine life without VB
    (Various Boyfriends)

  16. #16

    Thread Starter
    Hyperactive Member anita2002's Avatar
    Join Date
    Dec 2001
    Location
    In u'r Heart
    Posts
    482
    Originally posted by anita2002
    Is it correct that i can't use Timer to run my application constantly at background? Can anybody help me? Please...How to keep my application running constantly on background? I'm confused...
    Thanks in Advance..
    Anita..
    Can anybody help me?? Does anyone have some code related to this?
    Please....
    Anita
    Can't imagine life without VB
    (Various Boyfriends)

  17. #17
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    What do you mean by running the program in background constantly? What i understand you want your program to be loaded with the windows and run silently in the background to check something (Internet connection) or to wait something(Dewali maybe)
    To run the program in the background just put its exe name in Registry... I think you've asked the question on the forum. and to check for the special event... for your convenience place a timer in the exe which will check for the special event..
    So the timer is not literally used for <B>Running in Background</B> it just performs a check (in your situation).

  18. #18
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    Here you go Anita...
    This is the code to make your exe a service...
    put this code in module
    Private Declare Function GetCurrentProcessId Lib "Kernel32" () As Long
    Private Declare Function RegisterServiceProcess Lib "Kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long
    Private Const RSP_UNREGISTER_SERVICE = 0
    Private Const RSP_SIMPLE_SERVICE = 1

    Public Sub MakeMeService() 'Call this function in Form_Load
    Dim pID As Long
    Dim regserv As Long
    pID = GetCurrentProcessId
    regserv = RegisterServiceProcess(pID, RSP_SIMPLE_SERVICE)
    End Sub
    Public Sub UnMakeMeService() 'And this on Form_Unload
    Dim pID As Long
    Dim regserv As Long
    pID = GetCurrentProcessId
    regserv = RegisterServiceProcess(pID, RSP_UNREGISTER_SERVICE) 'Clean Sweep
    End Sub

  19. #19

    Thread Starter
    Hyperactive Member anita2002's Avatar
    Join Date
    Dec 2001
    Location
    In u'r Heart
    Posts
    482
    Thanks Moin Kahan,
    but when i put u'r code in module and call the specified function for from form_load then it is giving me error....
    Can't find DLL entry point RegisterServiceProcess in Kernel32"..
    what can i do now??
    please help me..
    Anita
    Can't imagine life without VB
    (Various Boyfriends)

  20. #20
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011
    Don't tell me that you are using NT!!!!!!!!!

  21. #21
    Lively Member
    Join Date
    Mar 2002
    Posts
    75
    try this
    Code:
    'Put this in a module
    Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long
    Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
    Public Const REG_SZ = 1 ' Unicode nul terminated String
    Public Const REG_DWORD = 4 ' 32-bit number
    Public Const HKEY_LOCAL_MACHINE = &H80000002
    
    Public Sub savestring(Hkey As Long, strPath As String, strValue As String, strData As String)
    Dim keyhand As Long
    Dim r As Long
    r = RegCreateKey(Hkey, strPath, keyhand)
    r = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strData, Len(strData))
    r = RegCloseKey(keyhand)
    End Sub
    And this on the form_load
    Code:
    Dim sPath As String
    sPath = App.Path
    If Right$(sPath, 1) <> "\" Then
        sPath = sPath & "\"
    End If
    sPath = sPath & App.EXEName & ".exe"
    Call savestring(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\Currentversion\Run", "keyname", sPath)
    the above code will also get the path of the file and put it on the reg on its own..
    Last edited by SolidWolf; Apr 9th, 2002 at 11:20 AM.

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