From: Steve on
I am creating a fairly straight forward VB6 interface which will
utilize
another external application's command line features. This is kind
of
the reverse use for command lines, as I am not creating them for use
with my VB6 app, but want to send command line instructions to the
external 3rd party app which has nice command line functionality for
dealing with image formats.

The only way I can think to accomplish this is by the following
process:
(1) Write the command line to a text file with a *.bat extension.
(2) Shell Execute the batch file.
(3) Handle the results of the command line operation.
(4) Loop back to (1) as many times as necessary until complete.

I'm thinking there has to be a more refined way to feed command line
arguements to this application. Any insight?

Thank you,

~Steve
From: Steve on
Norm,

Thank you for your response. Prior to your post I was dealing
ingloriously with waiting for the invoked command line request
to finish executing, juggling the asynchronous Shell situation.

Far from being an accomplished API user I was wondering if you
mind explaining what was happening here, particularly with the
'WaitForSingleObject' portion after the ExecCmd is called?

Thank you ~ Steve

Public Function ExecCmd(ByVal CmdLine As String)
Dim Proc As PROCESS_INFORMATION
Dim Start As STARTUPINFO
Dim Ret As Long
Start.cb = Len(Start)
Ret = CreateProcessA(vbNullString, CmdLine, 0&, 0&, 1&,
NORMAL_PRIORITY_CLASS, 0&, vbNullString, Start, Proc)
Ret = WaitForSingleObject(Proc.hProcess, INFINITE)
Call GetExitCodeProcess(Proc.hProcess, Ret)
Call CloseHandle(Proc.hThread)
Call CloseHandle(Proc.hProcess)
ExecCmd = Ret
End Function
From: Mike Williams on
On 20 Apr, 22:11, Steve <stevegd...(a)yahoo.com> wrote:

> I was wondering if you mind explaining what was happening
> here, particularly with the 'WaitForSingleObject' portion
> after the ExecCmd is called?

Have a look at this:

http://msdn.microsoft.com/en-us/library/ms687032(VS.85).aspx

Mike

From: Steve on

Thanks Mike.

I think I understand the API sequence now.

~Steve

On Apr 20, 5:25 pm, Mike Williams <gagam...(a)yahoo.co.uk> wrote:
> On 20 Apr, 22:11, Steve <stevegd...(a)yahoo.com> wrote:
>
> > I was wondering if you mind explaining what was happening
> > here, particularly with the 'WaitForSingleObject' portion
> > after the ExecCmd is called?
>
> Have a look at this:
>
>    http://msdn.microsoft.com/en-us/library/ms687032(VS.85).aspx
>
> Mike

From: Steve on


Thanks Norm. I have put your code through some rigid testing
and found it works great. I did alter it by implementing a "finite"
wait period and testing the return value of the
WaitForSingleObject(Proc.hProcess, INFINITE) call, in order to
remedy the one situation where the application being sent the
command line instructions remains instantiated indefinetly when
it cannot decode a corrupt or unknown image type.

Fabulous stuff.

~Steve Gdula