在Windows Mobile中检测应用程序是否运行在模拟器中
2011-04-11 23:40
302 查看
原文地址:http://blogs.msdn.com/b/netcfteam/archive/2006/09/15/756755.aspx
代码如下:
代码如下:
using System; using System.IO; using System.Windows.Forms; using Microsoft.Win32; using System.Runtime.InteropServices; using System.Text; namespace PlatformDetection { internal partial class PInvoke { [DllImport("Coredll.dll", EntryPoint = "SystemParametersInfoW", CharSet = CharSet.Unicode)] static extern int SystemParametersInfo4Strings(uint uiAction, uint uiParam, StringBuilder pvParam, uint fWinIni); public enum SystemParametersInfoActions : uint { SPI_GETPLATFORMTYPE = 257, // this is used elsewhere for Smartphone/PocketPC detection SPI_GETOEMINFO = 258, } public static string GetOemInfo() { StringBuilder oemInfo = new StringBuilder(50); if (SystemParametersInfo4Strings((uint)SystemParametersInfoActions.SPI_GETOEMINFO, (uint)oemInfo.Capacity, oemInfo, 0) == 0) throw new Exception("Error getting OEM info."); return oemInfo.ToString(); } } internal partial class PlatformDetection { private const string MicrosoftEmulatorOemValue = "Microsoft DeviceEmulator"; public static bool IsEmulator() { return PInvoke.GetOemInfo() == MicrosoftEmulatorOemValue; } } class EmulatorProgram { static void Main(string[] args) { MessageBox.Show("Emulator: " + (PlatformDetection.IsEmulator() ? "Yes" : "No")); } } }
相关文章推荐
- 检测iOS Web应用程序是否运行在全屏模式
- 八种方法检测是否在模拟器上运行
- android-检测是否在模拟器中运行
- 如何使用 C# 检测应用程序是否已停止响应
- 让Windows Mobile 6.1的手机可以运行控制台应用程序
- Android中判断当前应用程序是否在运行 推送时进行判断
- 嵌入式 检测一个进程是否运行
- Android 如何检测一个服务是否还在运行?
- Shell编程实例-检测Nginx服务是否正常运行(详解)
- Android检测服务是否运行
- 使用JavaScript的ActiveXObject对象检测应用程序是否安装的方法
- mac下判断当前应用程序是否已经运行了一个实例
- 用Linux守护进程检测某个程序是否运行
- C# 检测程序是否已经运行
- WINCE检测进程是否运行
- 用Linux守护进程检测某个程序是否运行2
- Installshield 2015 实现检测某安装文件是否存在并运行安装
- RabbitMQ监控(一):使用AMQP模拟检测来确认RabbitMQ是否运行
- 如何检测系统是否已经运行了相同的程序
- Xcode5 运行程序 提示IOS 模拟器未能安装此应用程序