C# 检测Windows Mobile vs.“;普通的;Windows CE
我的Compact Framework应用程序如何检测它是否在Windows Mobile(顶部的开始菜单,底部的菜单栏)下运行,而不是“普通”Windows CE(底部的开始菜单,应用程序内部的菜单栏)C# 检测Windows Mobile vs.“;普通的;Windows CE,c#,.net,windows-mobile,compact-framework,windows-ce,C#,.net,Windows Mobile,Compact Framework,Windows Ce,我的Compact Framework应用程序如何检测它是否在Windows Mobile(顶部的开始菜单,底部的菜单栏)下运行,而不是“普通”Windows CE(底部的开始菜单,应用程序内部的菜单栏) 由于Windows Mobile在Windows CE内核上运行,Environment.OSVersion.Version在这里没有真正的帮助(它只返回CE内核版本号)。从Framework 3.5开始,Microsoft.WindowsCE.Forms命名空间中有一个属性提供此信息(返回W
由于Windows Mobile在Windows CE内核上运行,
Environment.OSVersion.Version
在这里没有真正的帮助(它只返回CE内核版本号)。从Framework 3.5开始,Microsoft.WindowsCE.Forms命名空间中有一个属性提供此信息(返回WinCEGeneric
,PocketPC
或Smartphone
)。我们使用类似的方法。但每个CE设备可能会返回不同的字符串
[DllImport("coredll.dll", SetLastError = true)]
public static extern bool SystemParametersInfoGetString(uint uiAction, uint uiParam, System.Text.StringBuilder pvParam, uint fWinIni);
System.Text.StringBuilder platformBuff = new System.Text.StringBuilder(100);
if (SystemParametersInfoGetString(SPI_GETPLATFORMTYPE, (uint)platformBuff.Capacity, platformBuff, 0))
return platformBuff.ToString();
您还可以检查是否存在Microsoft.WindowsMobile和Microsoft.WindowsMobile.Status程序集…CE不包含这些附加组件,这些附加组件是WM分层在CE代码基础之上的。如果您愿意参考下面的Microsoft MSDN FAQ发布 我会转载,但有一个小的代码样本和几个链接在文章中,这将是费时在这里复制