The following crashes for me, if I don't delete $func->{proto}... Surely that must be a bug? Otherwise, I must be misunderstanding something really badly...# Old Skool calls use Win32::API; my $getwindir = new Win32::API(kernel32 => GetWindowsDirectoryA => [qw +(P N)], "N") or die "Can't locate function: $!"; # ... or use 'PN' for the 3rd parameter, if Win32::API is recent enoug +h (version?) my $buffer = "\0" x 300; my $length = $getwindir->Call($buffer, length $buffer); print substr $buffer, 0, $length;
And of course, you can replace "GetWindowsDirectory"/"GetWindowsDirectoryA" everywhere with "GetSystemDirectory"/"GetSystemDirectoryA", to get the Windows/System subdirectory# New Skool calls ($Win32::API::VERSION >= 0.40) use Win32::API; my $getwindir = new Win32::API(kernel32 => 'LONG GetWindowsDirectoryA( + LPSTR buffer, LONG maxlength )') or die "Can't locate function: $!"; # Do this, or bear the consequences: delete $getwindir->{proto}; my $buffer = "\0" x 200; my $length = $getwindir->Call($buffer, length $buffer); print substr $buffer, 0, $length;
In reply to Re: Using Window System Path Variable in Perl Script
by bart
in thread Using Window System Path Variable in Perl Script
by devgoddess
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |