惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

腾讯CDC
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog
S
SegmentFault 最新的问题
WordPress大学
WordPress大学
P
Proofpoint News Feed
Hugging Face - Blog
Hugging Face - Blog
MyScale Blog
MyScale Blog
A
About on SuperTechFans
雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
The Blog of Author Tim Ferriss
MongoDB | Blog
MongoDB | Blog
博客园 - 【当耐特】
The Cloudflare Blog
F
Fortinet All Blogs
小众软件
小众软件
博客园 - 三生石上(FineUI控件)
宝玉的分享
宝玉的分享
罗磊的独立博客
量子位
有赞技术团队
有赞技术团队
V
V2EX
Engineering at Meta
Engineering at Meta

博客园 - 钟少

关于 MonoDevelop on Linux 单步调试问题的解决 MonoDevelop 4.2.2/Mono 3.4.0 in CentOS 6.5 安装笔记 在ASP.NET MVC 4 on Mono中使用OracleClient in CentOS 6.x的问题记录 在CentOS 6.4 x86_32中使用Rhythmbox听MP3 MonoDevelop 4.0.9 on CentOS 6.3 安装笔记 MemoryMappedFile 在 Mono in Linux 的开发笔记 Mono on CentOS 6.3 安装笔记 在OpenSUSE中听歌 ASP.NET MVC 3.0 源码阅读手记(1) Mono on Linux 开发与实践札记(1) 数据库连接字符串解析的正则表达式 我的WPF学习札记(1) 我的插件框架·前传 恢复Ico图标文件在资源管理器中的显示 深入剖析 ASP.NET 1.x 中 Forms 身份验证(1) 北大青鸟(深圳中青)培训中心招聘: .NET 讲师 .NET 2.0 中的自定义配置处理 一个三层架构的WinForms程序的完整范例(.NET 1.1/Northwind) IIS6.0服务器架站无法访问解决方案总结(转贴)
在Windows Mobile中检测应用程序是否运行在模拟器中
钟少 · 2011-04-11 · via 博客园 - 钟少

原文地址: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"));
}
}
}