View Single Post
Old 09-02-2003, 09:44 PM   #5 (permalink)
charliex
Junkie
 
Location: North Hollywood
ick no!!! software that periodcally checks for changes like this, bad, bad! loading regmon or filemon watching all those programs rabidly checking for registry or file changes is horrible.

even on a simple system, you are opening a can of worms.
FindFirstChangeNotification, WaitForSingleObject etc

implement semaphores, windows has some very powerful functions for talking between apps.

http://msdn.microsoft.com arguably has the best technical docs/resources for any OS.

afrer a few mins looking msdn i found this

Code:
Example Program
This program shows how you can use the Shell function and the GetNumTasks function to execute an MS-DOS program. This program assumes that you have the PKUNZIP program stored in the UTILS directory and that you have previously created a destination directory called DESTDIR on your hard drive. 

Create a new project in Visual Basic. Form1 is created by default. 
Add the following statements to the General Declarations section of Form1: 
Dim ActiveApps As Integer
Private Declare Function GetNumTasks Lib "Kernel" () As Integer

Add a Command Button control to Form1. Command1 is created by default. 
Add the following code to the Click event for Command1: 
Private Sub Command1_Click()
    Dim AppDir As String
    Dim Zip As String
    Dim Y As Integer
    Dim X As Integer
    
    AppDir = "c:\destdir"
    ActiveApps = GetNumTasks()
    
    Zip = "c:\utils\pkunzip " & "c:\destdir\" & "test.zip" & " " & AppDir
    X = Shell(Zip, 2)
    SendKeys "%{enter}EXIT%{ }n"
    
    Do While GetNumTasks() <> ActiveApps
        Y = DoEvents()
    Loop
    MsgBox "Pkunzip is finished", 0, "Demo Program"
    
End Sub

Then this
http://support.microsoft.com/default...kb;en-us;96844

Code:
     Private Declare Function GetModuleUsage% Lib "Kernel" _
         (ByVal hModule%)

      Private Function TestFunc(ByVal lVal As Long) As Integer
      'this function is necessary since the value returned by Shell is an
      'unsigned integer and may exceed the limits of a VB integer
         If (lVal And &H8000&) = 0 Then
           TestFunc = lVal And &HFFFF&
         Else
           TestFunc = &H8000 Or (lVal And &H7FFF&)
         End If
      End Function
						
Add the following code to the Form_Click event procedure of Form1:       Sub Form_Click()
        lRet& = Shell("NOTEPAD.EXE")       ' Modify the path as necessary.
        x% = TestFunc(lRet&)
        While GetModuleUsage(x%) > 0    ' Has Shelled program finished?
           z% = DoEvents()              ' If not, yield to Windows.
        Wend
        MsgBox "Shelled application just terminated", 64
      End Sub
charliex is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76