in reply to Need a 16 bit returncode from .exe

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.

Replies are listed 'Best First'.
Re^2: Need a 16 bit returncode from .exe
by BrowserUk (Patriarch) on Mar 18, 2008 at 18:54 UTC
      Yes, you are right BrowserUk. It should be easy to change the std file handles in the STARTUPINFO block to CreateProcess, but Win32::Process::Create does not expose that.
        I do need the output from the .exe (as well as the retcode)...

        So... you're saying this solution won't work for me?
      BrowserUk, you kind-o tailed off on your post...
      Are you saying this solution won't work?
      I do need the output and the rc.
      Thanks.