On 27.11.2011 02:29, Burak Gürsoy wrote:
Hi,
I'm wondering about how to create a SYSTEM_INFO structure from Perl:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724958(v=vs.85).aspx
to pass this to GetNativeSystemInfo(). Win32::API::Struct->typedef()
seems to support
simple structs only. Is there a way to create such a nested struct?
Otherwise, is there any
other way apart from XS?
hi Burak,
short answer is: you can't :-)
more elaborate answer: nested structs are not a problem, first define
the inner struct and then use its name as type of one of the outer
struct member.
union members, on the other hand, are not supported. for SYSTEM_INFO,
however, the DWORD member (dwOemId) is obsolete and you should not need
it at all.
should you really need to access both the DWORD and the corresponding
two WORDs, you have to convert the data yourself (which in this case
means some bit-shifting). for example, if you define the struct having
the DWORD:
my $wProcessorArchitecture = $system_info->{dwOemId} & 0xffff;
my $wReserved = $system_info->{dwOemId} >> 16;
or the other way around, if you define the struct having two WORDs:
my $dwOemId = $system_info->{wProcessorArchitecture} |
$system_info->{wReserved} << 16;
hope this helps!
cheers,
Aldo