|
-
Nov 16th, 2001, 09:15 AM
#1
Thread Starter
Fanatic Member
Stoping a program
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
-
Nov 16th, 2001, 09:22 AM
#2
-= B u g S l a y e r =-
Re: Stoping a program
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
set a flag in the registry, when true, make u'r app shut down,
from the inst. after upgrade has finished, start ur app ...
-
Nov 16th, 2001, 09:26 AM
#3
Thread Starter
Fanatic Member
Whooosshh ```````````````>
over my head.
How would i do that. timers?
-
Nov 16th, 2001, 09:37 AM
#4
-= B u g S l a y e r =-
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
-
Nov 16th, 2001, 09:40 AM
#5
Thread Starter
Fanatic Member
Is that the only way>> Yikes
Problem is its on other computer...
What a mess..
Thanks for your help
-
Nov 16th, 2001, 09:45 AM
#6
-= B u g S l a y e r =-
Originally posted by SeaHag
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 
it will get a bit messy, but I don't know of any other way
-
Nov 16th, 2001, 09:57 AM
#7
Thread Starter
Fanatic Member
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
-
Nov 16th, 2001, 10:04 AM
#8
-= B u g S l a y e r =-
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
u find that less messy than what I suggested ???
-
Nov 16th, 2001, 10:05 AM
#9
Thread Starter
Fanatic Member
Dont' know. I am the cut and paste King! 
did you try it?.. works pretty nifty!
-
Nov 16th, 2001, 10:11 AM
#10
-= B u g S l a y e r =-
when u say taskbar u mean the system tray?
if thats the case, does u'r app have any windows at all?
-
Nov 16th, 2001, 10:19 AM
#11
Thread Starter
Fanatic Member
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..
-
Nov 16th, 2001, 10:28 AM
#12
-= B u g S l a y e r =-
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 ?
-
Nov 16th, 2001, 10:30 AM
#13
Thread Starter
Fanatic Member
Arggggggg.....
Thanks!
-
Nov 16th, 2001, 01:28 PM
#14
Thread Starter
Fanatic Member
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
-
Nov 16th, 2001, 02:42 PM
#15
-= B u g S l a y e r =-
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
-
Nov 16th, 2001, 03:40 PM
#16
Thread Starter
Fanatic Member
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.
HAVE A GREAT DAY!
-
Nov 16th, 2001, 04:57 PM
#17
-= B u g S l a y e r =-
-
Nov 16th, 2001, 04:59 PM
#18
Thread Starter
Fanatic Member
Look at another thread
Termanate NOW>>>
Still up on the boared
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
|