I'm trying to get information about a Windows Mobile device from a desktop application (written in C#). I searched the MSDN and found that the function I need is in rapi.dll:
VOID CeGetSystemInfo (LPSYSTEM_INFO lpSystemInfo);
The parameter is a pointer to a struct which is deffined like this:
typedef struct _SYSTEM_INFO {
union {
DWORD dwOemId;
struct {
WORD wProcessorArchitecture;
WORD wReserved;
};
};
DWORD dwPageSize;
LPVOID lpMinimumApplicationAddress;
LPVOID lpMaximumApplicationAddress;
DWORD dwActiveProcessorMask;
DWORD dwNumberOfProcessors;
DWORD dwProcessorType;
DWORD dwAllocationGranularity;
WORD wProcessorLevel;
WORD wProcessorRevision;
} SYSTEM_INFO, *LPSYSTEM_INFO;
Here is how I mapped it all to managed code:
[DllImport("rapi.dll")]
public static extern void CeGetSystemInfo([MarshalAs(UnmanagedType.Struct)]ref SYSTEM_INFO info);
[StructLayout(LayoutKind.Sequential)]
public struct SYSTEM_INFO
{
internal PROCESSOR_INFO_UNION uProcessorInfo;
public uint dwPageSize;
public IntPtr lpMinimumApplicationAddress;
public IntPtr lpMaximumApplicationAddress;
public uint dwActiveProcessorMask;
public uint dwNumberOfProcessors;
public uint dwProcessorType;
public uint dwAllocationGranularity;
public ushort wProcessorLevel;
public ushort wProcessorRevision;
}
[StructLayout(LayoutKind.Explicit)]
public struct PROCESSOR_INFO_UNION
{
[FieldOffset(0)]
internal uint dwOemId;
[FieldOffset(1)]
internal ushort wProcessorArchitecture;
[FieldOffset(2)]
internal ushort wReserved;
}
When I call the function passing the SYSTEM_INFO struct nothing happens. The function does not alter the values of the struct in any way. Have I mapped the struct wrong or something?
Thanks in advance