It is the ExitCode you need to test for.

GetExitCodeProcess(ProcessInfo.hProcess,ExitCode);

You can test ExitCode = Still_Active if you wish to wait in a loop until the
process finishes.

Ross.

-----Original Message-----
From: delphi-boun...@elists.org [mailto:delphi-boun...@elists.org] On Behalf
Of John Dammeyer
Sent: Friday, 9 October 2009 8:58 p.m.
To: 'Borland's Delphi Discussion List'
Subject: Captures information from a ShellExecute

Hi,

I'm launching a windows command line PIC programmer as follows:

    res := ShellExecute(Self.Handle, nil, 'pk2cmd.exe', '/PPIC18F2680
/FTricolourNode.hex /M /A5.00',
    'C:\Firmware', SW_SHOWNORMAL);

The shell executes and returns immediately as it probably should.  The
Command Line window stays open until the pktcmd.exe finishes.  Once the
pk2cmd.exe finishes it closes the window immediately.  If it's failed to
program th PIC microntroller I don't see the information before the window
closes.

If I use CreateProcess I can then hang around until the app is done but
then it's the same issue.  The Command Window closes when the app closes
and I can't seem to catch an error code from the pk2cmd.exe as outlined
below:

11. Return Codes
--------------------------------------------------------------------------
--
Value   Code                    Notes
-----   ----                    -----
0       OPSUCCESS               Returned if all selected operations
complete
                                successfully.
5       VOLTAGE_ERROR           A Vdd and/or Vpp voltage error was
detected.
                                This could be due to PICkit 2 being
                                improperly connected to a part, incorrect
                                part selection, or interference from other
                                circuitry on the target board.
...

39      AUTODETECT_FAILED       A part autodetect operation failed to find
                                a known part.

Is there a way to lauch a window and capture the return code of the
application as opposed to the success or failure of launching the command
line window?

GetLastError just returns 0.

I've tried >>results.txt with no luck to try and catch the text output.

Googling on this subject seems to always refer to the Windows Error Code
which GetLastError would return.

Thanks

John


Automation Artisans Inc.
http://www.autoartisans.com/ELS/
Ph. 1 250 544 4950


_______________________________________________
Delphi mailing list -> Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi


_______________________________________________
Delphi mailing list -> Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Reply via email to