1 2 3 4 5
my @printer = Printers(1); foreach(@printer) { print $_{PrinterName}; }
1 2 3 4 5 6 7
use Win32::API; my $GetDefaultPrinter = Win32::API->new( "rundll32", "int GetDefaultPrinter()" ); my $PID = $GetDefaultPrinter->Call(); print $PID;
Can't call method "Call" on an undefined value
1 2 3 4 5 6 7 8 9 10 11 12 13 14
use warnings; use strict; use Win32::API; my $winspool_path = 'c:\\windows\system\winspool.drv'; my $printer_name_size = 256; my $printer_name = " " x $printer_name_size; # Speicher allozieren my $GetDefaultPrinter = Win32::API->new($winspool_path, 'GetDefaultPrinter', 'PP', 'I'); $GetDefaultPrinter->Call($printer_name, $printer_name_size); print $printer_name;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use warnings;
use strict;
use Win32::API;
my $winspool_path = 'winspool.drv';
my $printer_name_size = 256;
my $printer_name = " " x $printer_name_size; # Speicher allozieren
my $GetDefaultPrinter = Win32::API->new($winspool_path, 'GetDefaultPrinter', 'PP', 'I');
$GetDefaultPrinter->Call($printer_name, $printer_name_size);
print $printer_name;