VB5 and Shelling a DOS program...Used to use getmoduleusage but not for 32bit 
Author Message
 VB5 and Shelling a DOS program...Used to use getmoduleusage but not for 32bit

Hi,

Okay, in the old days, (16bit apps), I used to do the following for any
DOS (yuck!) commands/programs that I need to shell to:

batchfile = "whatever.exe"
batchstat = Shell(batchfile, 1)

Do
    x = DoEvents()
loop While getmodulehandle(batchfile) > 0

But, now when I look for the API getmodulehandle in 32bit form, there is
none.

Does someone have an example/idea how to do this via VB5?

Thanks in advance...

Geo...



Tue, 06 Feb 2001 03:00:00 GMT  
 VB5 and Shelling a DOS program...Used to use getmoduleusage but not for 32bit
Go to the Microsoft Knowledgebase (http://www.microsoft.com/kb/default.asp)
and search for Article Q129796.  It will give you what you need.

Lee Weiner
weiner AT fuse DOT net



Quote:
>Hi,

>Okay, in the old days, (16bit apps), I used to do the following for any
>DOS (yuck!) commands/programs that I need to shell to:

>batchfile = "whatever.exe"
>batchstat = Shell(batchfile, 1)

>Do
>    x = DoEvents()
>loop While getmodulehandle(batchfile) > 0

>But, now when I look for the API getmodulehandle in 32bit form, there is
>none.

>Does someone have an example/idea how to do this via VB5?

>Thanks in advance...

>Geo...



Tue, 06 Feb 2001 03:00:00 GMT  
 VB5 and Shelling a DOS program...Used to use getmoduleusage but not for 32bit
Here's some code I picked up somewhere... (simple huh?)

Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle
As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess
As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess
As Long, lpExitCode As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long)
As Long
Const STILL_ACTIVE = &H103
Const PROCESS_QUERY_INFORMATION = &H400
Const INFINITE = &HFFFF
Const WAIT_FAILED = &HFFFFFFFF
Const PROCESS_ALL_ACCESS = &H1F0FFF

Function SyncShell(ByVal strProgName As String, Optional ByVal WaitDead As
Boolean) As Long
   Dim cRead As Long
   Dim iExit As Long
   Dim hProg As Long
   Dim idProg As Long
   idProg = Shell(strProgName, vbNormalNoFocus)
   ' Get process handle
   hProg = OpenProcess(PROCESS_ALL_ACCESS, False, idProg)
   If WaitDead Then
      ' Stop dead until process terminates
      Dim iResult As Long
      iResult = WaitForSingleObject(hProg, INFINITE)
      If iResult = WAIT_FAILED Then Err.Raise Err.LastDllError
      ' Get the return value
      GetExitCodeProcess hProg, iExit
   Else
      ' Get the return value
      GetExitCodeProcess hProg, iExit
      ' Wait, but allow painting and other processing
      Do While iExit = STILL_ACTIVE ' And Not TerminateApp
         Sleep 1000
         GetExitCodeProcess hProg, iExit
      Loop
   End If
   CloseHandle hProg
   SyncShell = iExit
End Function

Quote:

>Hi,

>Okay, in the old days, (16bit apps), I used to do the following for any
>DOS (yuck!) commands/programs that I need to shell to:

>batchfile = "whatever.exe"
>batchstat = Shell(batchfile, 1)

>Do
>    x = DoEvents()
>loop While getmodulehandle(batchfile) > 0

>But, now when I look for the API getmodulehandle in 32bit form, there is
>none.

>Does someone have an example/idea how to do this via VB5?

>Thanks in advance...

>Geo...



Tue, 06 Feb 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. How do I use the %USERNAME% to map a drive using VBScript and not Dos Shell

2. Using SHELL and GETMODULEUSAGE

3. launching a program using its registry entry NOT Shell()

4. Program not closing using Shell command

5. Using a VB5 program as a Windows Shell

6. detecting close of a shelled dos program in vb5

7. detecting close of a shelled dos program in vb5

8. detecting close of a shelled dos program in vb5

9. Dos programs (shell) running in VB5

10. detecting close of a shelled dos program in vb5

11. detecting close of a shelled dos program in vb5

12. detecting close of a shelled dos program in vb5

 

 
Powered by phpBB® Forum Software