开发者

Is there compilation symbol to detect compact framework?

Is there a compilation symbol to detect if it's run开发者_JS百科ning on a compact framework platform


You have a discontinuity in your question. You're asking about a compile symbol, so something that exists only at design time, and detecting a condition while running. So the question for you is which one are you actually after?

If you want to know at run time if you're under the CF, then check the Environment.OSVersion.Platform property to see if it's WinCE.

if(Environment.OSVersion.Platform == PlatformID.WinCE)
{
  // this is CF
}

At compile time it's not quite as straightforward. The default project Wizards add the compilation Symbols "PocketPC" for PPC/WinMo projects, "WindowsCE" for WinCE projects and "WINDOWS_PHONE" for Phone7 projects so you can do something like this:

#if WindowsCE || PocketPC || WINDOWS_PHONE
// this is CF
#endif

But there's nothing to say that a developer can't delete that symbol (or add it on a desktop project).


Or in simple words :

The basic idea would be to decorate your code with #if compiler directives for each framework version?

#if CFNET
// .net CF code
#else
// .net code
#endif

The thread here answers your question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜