Convert a Windows-specific error to a text string using the Win32::FormatMessage function. : Win32 « Win32 « Perl






Convert a Windows-specific error to a text string using the Win32::FormatMessage function.

  

# 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() );
}

   
    
  








Related examples in the same category

1.Is windows 95
2.Is windows NT
3.OS version
4.Gets user login name on Windows
5.Node and domain information
6.The Win32::Spawn function acts much like the system function and the Windows start command.