Can you stop your program from another program.
I mean.. I need to update a program. Trick is that the program runs in the taskbar. I need to stop it, update it, then restart.
Any Help?
Seahag
Printable View
Can you stop your program from another program.
I mean.. I need to update a program. Trick is that the program runs in the taskbar. I need to stop it, update it, then restart.
Any Help?
Seahag
set a flag in the registry, when true, make u'r app shut down,Quote:
Originally posted by SeaHag
Can you stop your program from another program.
I mean.. I need to update a program. Trick is that the program runs in the taskbar. I need to stop it, update it, then restart.
Any Help?
Seahag
from the inst. after upgrade has finished, start ur app ...
Whooosshh ```````````````>
over my head.
How would i do that. timers?
yes u could use a timer, set it to 60000 (1min) in the timer event, u check if a flag has been sat.
eg
VB Code:
If GetSetting(App.ExeName, "Upgrade", "Requested", False) Then 'Run u'r shutdown sequens Endif
Is that the only way>> Yikes
Problem is its on other computer...
What a mess..
Thanks for your help
use a file instead of the registry then :)Quote:
Originally posted by SeaHag
Is that the only way>> Yikes
Problem is its on other computer...
What a mess..
Thanks for your help
it will get a bit messy, but I don't know of any other way :)
I found this...
VB Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Const WM_CLOSE = &H10 Private Sub Command1_Click() Dim intHwnd As Long intHwnd = FindWindow(vbNullString, "Calculator") ' Must match the caption of the window exactly SendMessage intHwnd, WM_CLOSE, 0&, 0& End Sub
Works great except for stuff running in the taskbar...
Arggg
:confused:
u find that less messy than what I suggested ??? :eek: :)Quote:
Originally posted by SeaHag
I found this...
VB Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Const WM_CLOSE = &H10 Private Sub Command1_Click() Dim intHwnd As Long intHwnd = FindWindow(vbNullString, "Calculator") ' Must match the caption of the window exactly SendMessage intHwnd, WM_CLOSE, 0&, 0& End Sub
Works great except for stuff running in the taskbar...
Arggg
:confused:
Dont' know. I am the cut and paste King! :)
did you try it?.. works pretty nifty!
when u say taskbar u mean the system tray?
if thats the case, does u'r app have any windows at all?
Yes your right.. System tray..
Ya its got windows.
Why it doesn't work is because ..
VB Code:
Private Sub Form_Unload(Cancel As Integer) Cancel = -1 Form1.WindowState = vbMinimized End Sub
and on minimize i go app.taskvisible = False
Plus I think the program has to be on the task bar to work..
Sigh..
oh... I see... well.. then u have to do it the way I suggested :)
or.. maybe someone else in here has a good solution to this ?
anyone ?
Thanks! :)
Peet.. Something LIke this?
VB Code:
Sub RegEdit() Dim WshShell As Object Dim temp Set WshShell = CreateObject("WScript.Shell") On Error GoTo errorhandler temp = WshShell.RegRead("HKLM\software\Value") If temp = "Update" Then WshShell.RegWrite "HKLM\software\Value", "Updated", "REG_SZ" 'Shell "f:\files\sales\rep3\1036\toolbox\KillMail.exe" DeleteIcon Call mnuitemExit_Click End If Exit Sub errorhandler: WshShell.RegWrite "HKLM\software\Value", "Update", "REG_SZ" temp = WshShell.RegRead("HKLM\software\Value") Resume End Sub
Took all day.. I better get better at this stuff.
Seahag
Hi again SeaHag, I never used WScript.Shell meself, but it looks ok.
I should have explained the above sample of mine a little bit better....
There ar two ready to go functions built into vb that handle simple registry reading and saving of settings.
GetSetting wich I showed u
VB Code:
If GetSetting(App.ExeName, "Upgrade", "Requested", False) Then 'Run u'r shutdown sequens Endif
now the save to reg version would be
VB Code:
SaveSetting "TheOtherAppsName", "Upgrade", "Reguested", True
wich is what goes in u'r inst. app.
disadvantage here is that u can not decide where in the registry to put it, so I would keep the code u have... if its working that is :)
Working Fine...
ARGGGG!!!!
I am loosing my hair.. I really cornered myself this time.
The above code works fine.. just the rest aint going so well
I am going to get those nasty VB dreams. :confused:
HAVE A GREAT DAY!
nasty VB dreams :eek: know what u mena :)
well... I won't be able to tell u what u'r dreams mean, but I might help u with some code :)
any particular problem?
Look at another thread
Termanate NOW>>>
Still up on the boared