Home > Microsoft Access Help > Windows API calls

Windows API calls



I need to have a button on a form initiate an executable using the "shell" command, then "wait" for the executable to complete, and then (and only then) begin some processing.



The executable is an external (non-access) program that updates some SQL tables, and i need to process these tables once the executable has completed the update process.



The SHELL command returns a Windows handler ID for the process that it initiates - can anyone help me with the API call that I would have to execute in a "do...while" loop to wait for the process to terminate?



Thanks!



Vinay

URL

    
Guest


The eternal problem with shell. There is no direct way to know if the program has finished. What you can do is check Task Manager (with APIs, of course) if the program can be found there. Check this great site about APIs:



www.AllAPI.net



'*** This routine launches a program ("BladeEnc.exe") with some cmd line params. The Shell command returns a process ID with which you can "query" the Task Manager (in simple words)

Public Sub Encode(ByVal FileName As String)

Dim HEncoderProcess As Long

Dim CurrentExitCode As Long

Dim EncoderProcessID As Long



EncoderProcessID = Shell(mvarEncoderPath & "\BladeEnc.exe -32 -q -quiet -outdir=" & mvarEncodedFilePath & " " & FileName)



'Wait for encoding to be terminated

'Get a handle to the Process and Open

HEncoderProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, EncoderProcessID)

'Loop until process exits

Do

DoEvents

GetExitCodeProcess HEncoderProcess, CurrentExitCode

Loop Until CurrentExitCode = 0

'raise the EncodingFinished event

RaiseEvent EncodingFinished(FileName)

End Sub

Was this answer helpful ? Yes No   
Guest


btw you will need to compile this stuff into a DLL which you can call then with CreateObject. This is because you cannot make API calls directly in ASP, instead you need to create objects which enclose these APIs.

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved