I'm developing for Windows Mobile 5.0 and ran across this also.
There are some problems with Rapi.GetDeviceVersion() that prevent it from working. I don't know if there is a workaround other than to get the source code and fix it there.
(1) The pinvoke code is wrong, it uses
CeGetVersionEx(out verinfo)
when it should be doing
CeGetVersionEx(ref verinfo)
Since we're setting the size of the structure and passing it down, this has to use a ref.
(2) For some reason, using the OSVERSIONINFO (if I don't include the szCSDVersion, my app crashes without any exceptions being thrown). So you will have to use the CEOSVERSIONINFO that includes the szCSDVersion.
Thus the pinvoke code should look like this
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct CEOSVERSIONINFO
{
internal int dwOSVersionInfoSize;
public int dwMajorVersion;
public int dwMinorVersion;
public int dwBuildNumber;
public PlatformType dwPlatformId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=128)]
public string szCSDVersion;
}
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern int CeGetVersionEx(ref CEOSVERSION lpVersionInformation);
--Kenn