How to run P / Invoke in kernel32.dll on WinRT 8.1

I am trying to use my own API method ( GetNativeSystemInfo), which is marked as supported for both phone and desktop applications in Windows 8.1. In the documentation, she is listed as living in kernel32.dll. Big! So, my first P / Invoke attempt looked like this:

[DllImport("kernel32.dll", CharSet = CharSet.Unicode, ExactSpelling = false, PreserveSig = true)]
private static extern void GetNativeSystemInfo(ref SYSTEM_INFO lpSysInfo);

Unfortunately, this does not work on real devices - kernel32 was not found! As it happens, there is kernelBase.dll, and therefore, my second attempt:

[DllImport("kernelBase.dll", CharSet = CharSet.Unicode, ExactSpelling = false, PreserveSig = true)]
private static extern void GetNativeSystemInfo(ref SYSTEM_INFO lpSysInfo);

While this works fine on my phone, this leads to the completion of the certification of the application; the method name and "kernelBase.dll" do not seem to be white.

Is this WACK surveillance or a bug that makes this API unusable in Store apps? My goal is to get information about the running processor (architecture, type, etc.), and I would prefer not to go to C ++ for something so simple. If this API is not practical, is there any other way to get this information?

+4
source share
1 answer

For Windows Phone and versions of the Windows Store, you'll need different pinvoke signatures. For the phone link GetNativeSystemInfo from api-ms-win-core-sysinfo-l1-2-0.dll

#if WINDOWS_PHONE_APP
     [DllImport("api-ms-win-core-sysinfo-l1-2-0.dll", CharSet = CharSet.Unicode, ExactSpelling = false, PreserveSig = true)]
     private static extern void GetNativeSystemInfo(ref SYSTEM_INFO lpSysInfo);
#else
     [DllImport("kernel32.dll", CharSet = CharSet.Unicode, ExactSpelling = false, PreserveSig = true)]
     private static extern void GetNativeSystemInfo(ref SYSTEM_INFO lpSysInfo);
#endif

API- Win32 Windows Phone 8 ( SL, Runtime). , , , pinvoke. Windows Runtime , p-invoke, p-.

+9

All Articles