|
-
Mar 26th, 2002, 01:42 PM
#1
Thread Starter
Hyperactive Member
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)
-
Mar 26th, 2002, 02:11 PM
#2
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
-
Mar 26th, 2002, 02:12 PM
#3
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.
-
Mar 26th, 2002, 03:08 PM
#4
New Member
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
-
Mar 26th, 2002, 11:45 PM
#5
Thread Starter
Hyperactive Member
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)
-
Mar 26th, 2002, 11:56 PM
#6
Thread Starter
Hyperactive Member
Can't imagine life without VB
(Various Boyfriends)
-
Mar 27th, 2002, 01:00 AM
#7
Frenzied Member
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??
-
Mar 28th, 2002, 11:57 AM
#8
Thread Starter
Hyperactive Member
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)
-
Mar 28th, 2002, 12:47 PM
#9
Thread Starter
Hyperactive Member
Can't imagine life without VB
(Various Boyfriends)
-
Mar 28th, 2002, 01:12 PM
#10
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
-
Mar 28th, 2002, 02:56 PM
#11
Member
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
-
Mar 28th, 2002, 03:11 PM
#12
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..
-
Mar 28th, 2002, 08:03 PM
#13
Frenzied Member
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...
-
Apr 8th, 2002, 06:34 AM
#14
Thread Starter
Hyperactive Member
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)
-
Apr 8th, 2002, 07:04 AM
#15
Thread Starter
Hyperactive Member
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)
-
Apr 8th, 2002, 07:05 AM
#16
Thread Starter
Hyperactive Member
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)
-
Apr 8th, 2002, 11:07 AM
#17
Frenzied Member
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).
-
Apr 8th, 2002, 06:44 PM
#18
Frenzied Member
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
-
Apr 9th, 2002, 08:21 AM
#19
Thread Starter
Hyperactive Member
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)
-
Apr 9th, 2002, 10:16 AM
#20
Frenzied Member
Don't tell me that you are using NT!!!!!!!!!
-
Apr 9th, 2002, 11:16 AM
#21
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|