Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42220

[RESOLVED] creating an update function

$
0
0
I have a piece of software that is going to be used by people that are not very computer literate. I need to update the software often, so I can't have them trying to download an update and replacing files all the time. I thought about creating a second cmd line program in vb to do the updating automatically. So the whole process would work like this:

user clicks update on main software.

the main software then opens up the updater.exe.

updater.exe then closes the main software.

updater.exe downloads the update and replaces the main softwares exe file with the update.

updater.exe opens the new main software and then closes itself.



This way the user can be completely out of the loop of updating. I have created a cmd line app with vb. And been able to open it from the main software using a shell call. I have the downloading part finished. the only problem is closing the main software from the updater. I have tried using this example: http://support.microsoft.com/kb/153463

Code:

Option Explicit On

Module Module1

    Private Declare Function FindWindow Lib "User" (ByVal lpClassName As String, ByVal lpWindowName As String) As String
    Private Declare Function PostMessage Lib "User" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Integer) As Integer

    Private Const WM_QUIT = &H12

    Sub Main()

        Dim sTitle As String
        Dim iHwnd As Integer
        'Dim ihTask As Integer
        Dim iReturn As Integer
        sTitle = "Calculator"
        iHwnd = FindWindow(0&, sTitle)
        iReturn = PostMessage(iHwnd, WM_QUIT, 0, 0&)
        MsgBox("Notepad has been Closed Down")

        Console.Read()

    End Sub

End Module





But I cannot seem to get it working. I changed the 'As Any' to 'As String' to get that working in the declare statments. but now it is telling me: unable to load DLL 'user' The specified module could not be found. This error is at the iHwnd = FindWindow line. Can someone point me in the right direction. I'm not sure what dll is needing to be loaded. Perhaps I need to include one? Thanks, Victor.

Viewing all articles
Browse latest Browse all 42220

Trending Articles