programming-examples/perl/Win32/Convert a Windows-specific error to a text string using the Win32_FormatMessage function.pl
2019-11-15 12:59:38 +01:00

18 lines
504 B
Perl

# This function takes the error number returned by the Win32::GetLastError function.
#!/usr/bin/perl -w
use Win32;
$ApplicationName = 'c:\winnt\system32\notepad.exe';
$CommandLine = "notepad";
# Spawn the process.
$status = Win32::Spawn( $ApplicationName,$CommandLine,$ProcessId );
if ( $status != 0 ) {
print "Launched process with ID $ProcessId.\n";
} else {
print "Failed to launch process.\n";
print Win32::FormatMessage( Win32::GetLastError() );
}