Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shell and wait till end - microsoft example bug

Status
Not open for further replies.

tjbradford

Technical User
Dec 14, 2007
229
GB
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
Sub Form_Click()
lRet& = Shell("tcpdump -i 3 ") ' Modify the path as necessary.
MsgBox "1"
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

is this a bad example from microsoft?

I want to shell a dos program and from what i understand cmd is a 16bit enviroment is that correct?
 
I've used this technique and it works (even with Vista-64 bit).

faq222-428


-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Erm ... did you read the article yuo got the code from? If so, you would have noted:

1) The code you have is for ancient versions of VB
2) GetModuleUsage() function does not exist in Windows NT -and hence 2000, XP, 2003, Vista, 7.

And finally I'm afraid that your assumption that CMD is 16-bit is incorrect, it is 32-bit.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top