I just tried
samtregar's suggestion with a gash C .exe that exits with the return code of the argument (don't ask). Thought it might be helpful if I posted the code:
use warnings;
use strict;
use Win32::Process;
use Win32;
my $code = 'C:\\Perl Modules\\Win32\\ExitCode\\Debug\\FileClose.exe';
my $ProcessHandle;
Win32::Process::Create (
$ProcessHandle,
$code,
qq("$code" 1289), # Note syntax because path has an embedded space
+
0,
NORMAL_PRIORITY_CLASS,
".") || die "Oops: $^E";
$ProcessHandle->Wait(INFINITE);
my $ExitCode;
$ProcessHandle->GetExitCode($ExitCode);
print "Exit code: $ExitCode\n";
The perl program correctly reports an exit code of 1289. By the way, I tried the C program using ExitProcess and exit() (C RTL) and both worked. The MSDN gives the return type in ExitProcess as UINT (unsigned int), which is 32 bits.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.