How does my Perl script know that it works under Win64?

How can I configure a Perl script on a 64-bit Windows machine, even if it is 32-bit perl?

+3
source share
5 answers

See this question . You are checking the environment variable %PROCESSOR_ARCHITECTURE%.

+6
source

Thanks Ben S.

From the link in the question you linked to: msdn blog on how to cut a process bit

Executed the following code: print "WIN64 ?: $ ENV {PROCESSOR_ARCHITECTURE} \ n"; print "WIN64 ?: $ ENV {PROCESSOR_ARCHITEW6432} \ n";

And the following output (32-bit perl on xp64)

WIN64 ?: x86

WIN64 ?: AMD64

, 32- 64- , PROCESSOR_ARCHITEW6432.

+4
if (($ENV{'PROCESSOR_ARCHITECTURE'} eq "AMD64") or
    ($ENV{'PROCESSOR_ARCHITEW6432'} eq "AMD64")) {
   $arch = "win64";
} else {
   $arch = "win32";
}

: http://blogs.msdn.com/b/david.wang/archive/2006/03/26/howto-detect-process-bitness.aspx

+3

, , Windows API IsWow64Process. , ( Delphi), .

+1
    my @CPUIdentifierArray = split ' ', $ENV{PROCESSOR_IDENTIFIER};
    my %ArcHash        = ('x86' => 32, 'AMD64' => 64, 'Intel64' => 64);
    my $Arch           = $ArcHash{$CPUIdentifierArray[0]};

32 64

0

Source: https://habr.com/ru/post/1718055/


All Articles