Results 1 to 18 of 18

Thread: Stoping a program

  1. #1

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901

    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

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629

    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 ...
    -= a peet post =-

  3. #3

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    Whooosshh ```````````````>
    over my head.
    How would i do that. timers?

  4. #4
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    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:
    1. If GetSetting(App.ExeName, "Upgrade", "Requested", False) Then
    2.    'Run u'r shutdown sequens
    3. Endif
    -= a peet post =-

  5. #5

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    Is that the only way>> Yikes

    Problem is its on other computer...

    What a mess..
    Thanks for your help

  6. #6
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    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
    -= a peet post =-

  7. #7

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    I found this...


    VB Code:
    1. 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
    2. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    3.  
    4. Const WM_CLOSE = &H10
    5.  
    6. Private Sub Command1_Click()
    7.  
    8. Dim intHwnd As Long
    9.  
    10. intHwnd = FindWindow(vbNullString, "Calculator") ' Must match the caption of the window exactly
    11. SendMessage intHwnd, WM_CLOSE, 0&, 0&
    12.  
    13. End Sub


    Works great except for stuff running in the taskbar...


    Arggg

  8. #8
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Originally posted by SeaHag
    I found this...


    VB Code:
    1. 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
    2. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    3.  
    4. Const WM_CLOSE = &H10
    5.  
    6. Private Sub Command1_Click()
    7.  
    8. Dim intHwnd As Long
    9.  
    10. intHwnd = FindWindow(vbNullString, "Calculator") ' Must match the caption of the window exactly
    11. SendMessage intHwnd, WM_CLOSE, 0&, 0&
    12.  
    13. End Sub





    Works great except for stuff running in the taskbar...


    Arggg
    u find that less messy than what I suggested ???
    -= a peet post =-

  9. #9

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    Dont' know. I am the cut and paste King!

    did you try it?.. works pretty nifty!

  10. #10
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    when u say taskbar u mean the system tray?

    if thats the case, does u'r app have any windows at all?
    -= a peet post =-

  11. #11

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    Yes your right.. System tray..

    Ya its got windows.

    Why it doesn't work is because ..

    VB Code:
    1. Private Sub Form_Unload(Cancel As Integer)
    2. Cancel = -1
    3. Form1.WindowState = vbMinimized
    4. 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..

  12. #12
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    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 ?
    -= a peet post =-

  13. #13

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901

    Arggggggg.....

    Thanks!

  14. #14

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    Peet.. Something LIke this?



    VB Code:
    1. Sub RegEdit()
    2. Dim WshShell As Object
    3. Dim temp
    4.  
    5. Set WshShell = CreateObject("WScript.Shell")
    6.  
    7. On Error GoTo errorhandler
    8. temp = WshShell.RegRead("HKLM\software\Value")
    9.  
    10.  
    11. If temp = "Update" Then
    12. WshShell.RegWrite "HKLM\software\Value", "Updated", "REG_SZ"
    13. 'Shell "f:\files\sales\rep3\1036\toolbox\KillMail.exe"
    14. DeleteIcon
    15. Call mnuitemExit_Click
    16. End If
    17. Exit Sub
    18.  
    19. errorhandler:
    20. WshShell.RegWrite "HKLM\software\Value", "Update", "REG_SZ"
    21. temp = WshShell.RegRead("HKLM\software\Value")
    22.         Resume
    23. End Sub


    Took all day.. I better get better at this stuff.
    Seahag

  15. #15
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    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:
    1. If GetSetting(App.ExeName, "Upgrade", "Requested", False) Then
    2.    'Run u'r shutdown sequens
    3. Endif

    now the save to reg version would be

    VB Code:
    1. 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
    -= a peet post =-

  16. #16

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    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!

  17. #17
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    nasty VB dreams 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?
    -= a peet post =-

  18. #18

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    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
  •  



Click Here to Expand Forum to Full Width