get processor architecture in MQL

66 Views Asked by At

i use GetNativeSystemInfo from windows api but when i use structure like microsoft i can not get parameter correctly

at the first i use this structure:

struct _SYSTEM_INFO {
  union DUMMYUNIONNAME {
    int dwOemId;
    struct DUMMYSTRUCTNAME {
      int wProcessorArchitecture;
      int wReserved;
    };
  };
  int     dwPageSize;
  int    lpMinimumApplicationAddress;
  int    lpMaximumApplicationAddress;
  int  dwActiveProcessorMask;
  int     dwNumberOfProcessors;
  int     dwProcessorType;
  int     dwAllocationGranularity;
  int      wProcessorLevel;
  int      wProcessorRevision;
};

but i can not access to wProcessorArchitecture parameter.

also i have trying to edit structucture like this :

struct _SYSTEM_INFO
  {

   int               dwOemId;
   uint              wProcessorArchitecture;
   ulong             wReserved;

   int               dwPageSize;
   ulong             lpMinimumApplicationAddress;
   ulong             lpMaximumApplicationAddress;
   ulong             dwActiveProcessorMask;
   int               dwNumberOfProcessors;
   int               dwProcessorType;
   int               dwAllocationGranularity;
   ulong             wProcessorLevel;
   ulong             wProcessorRevision;
  };

now, when i get wProcessorArchitecture parameter, it return 4096, but microsoft msdn says that it return parameter like this :

9 5 12 6 0

can anyone help me?

this is my entire code in MQL5:

struct _SYSTEM_INFO
  {
   uint              dwOemId;
   uint              wProcessorArchitecture;
   ulong             wReserved;
   uint              dwPageSize;
   ulong             lpMinimumApplicationAddress;
   ulong             lpMaximumApplicationAddress;
   ulong             dwActiveProcessorMask;
   uint              dwNumberOfProcessors;
   uint              dwProcessorType;
   uint              dwAllocationGranularity;
   ulong             wProcessorLevel;
   ulong             wProcessorRevision;
  };

#import "kernel32.dll"
void GetNativeSystemInfo(_SYSTEM_INFO &lpSystemInfo);
#import


int OnInit()
  {
   _SYSTEM_INFO hos;
   GetNativeSystemInfo(hos);
   Alert(hos.wProcessorArchitecture);
  }

1

There are 1 best solutions below

0
PaulB On

Try the following:

struct _SYSTEM_INFO
{
   uint     wProcessorArchitecture;
   uint     wReserved;
   uint     dwPageSize;
   ulong    lpMinimumApplicationAddress;
   ulong    lpMaximumApplicationAddress;
   ulong    dwActiveProcessorMask;
   uint     dwNumberOfProcessors;
   uint     dwProcessorType;
   uint     dwAllocationGranularity;
   uint     wProcessorLevel;
   uint     wProcessorRevision;
};

#import "kernel32.dll"
void GetNativeSystemInfo(_SYSTEM_INFO &lpSystemInfo);
#import

int OnInit()
{
   _SYSTEM_INFO hos;
   GetNativeSystemInfo(hos);
   Alert(hos.wProcessorArchitecture);
}