vinayak_j
asked on
GetModuleUsage file kernel.exe not found
i used the following from MSDN library for determining when the shelled application has
terminated.It gave me an error saying that "kernel" not found.The kernel.exe file in which
the GetModuleUsage API is present is not on my system.how can I solve this problem.
Extract from MSDN is as shown below:
HOWTO: Determine When a Shelled Process Has Terminated
Last reviewed: October 13, 1997
Article ID: Q96844
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
terminated.It gave me an error saying that "kernel" not found.The kernel.exe file in which
the GetModuleUsage API is present is not on my system.how can I solve this problem.
Extract from MSDN is as shown below:
HOWTO: Determine When a Shelled Process Has Terminated
Last reviewed: October 13, 1997
Article ID: Q96844
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
yeah, that function is not supported in 32-bit.
It can be done, search for CreateProcessA and WaitForSingleObject on MSDN. I agree, It's annoying that GetModuleUsage was removed.
Hi vinayak_j,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Accept PaulHews's comment(s) as an answer.
vinayak_j, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you. DO NOT accept this comment as an answer.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:
Accept PaulHews's comment(s) as an answer.
vinayak_j, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you. DO NOT accept this comment as an answer.
EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
per recommendation
SpideyMod
Community Support Moderator @Experts Exchange
SpideyMod
Community Support Moderator @Experts Exchange