如何检测WinCE运行平台

#define POCKETPCV1        1
#define SMARTPHONEV1      2
#define POCKETPCV2        3
#define SMARTPHONEV2      4

int MyDeviceType()
{
    TCHAR szPlatform[MAX_STRING_BUFFER];
    int iDeviceType=0;
    OSVERSIONINFO osVer;
    GetVersionEx(&osVer);
    if (osVer.dwMajorVersion==3)
    { 
        if (SystemParametersInfo(SPI_GETPLATFORMTYPE, sizeof(szPlatform), szPlatform, 0)!=0)
        {
            if (lstrcmp(szPlatform,TEXT("PocketPC"))==0)
                iDeviceType= POCKETPCV1; // runs on Pocket PC 2000 and 2002
            else if (lstrcmp(szPlatform,TEXT("Smartphone"))==0)
                iDeviceType= SMARTPHONEV1; // runs on Smartphone 2002
        }    
        else
        { 
            if (GetLastError()==ERROR_ACCESS_DENIED)    //(5)
                iDeviceType= SMARTPHONEV1;       // is a smartphone:
            // Smartphone creates an access denied error on
            // SystemParametersInfo() 
        }
    }
    else
    {
        if (osVer.dwMajorVersion==4)
        { 
            if (SystemParametersInfo(SPI_GETPLATFORMTYPE, sizeof(szPlatform), szPlatform,0)!=0)
            {
                if (lstrcmp(szPlatform,TEXT("PocketPC"))==0)
                    iDeviceType= POCKETPCV2;       // runs on Pocket PC 2003
                else if (lstrcmp(szPlatform,TEXT("Smartphone"))==0)
                    iDeviceType= SMARTPHONEV2;       // runs on Smartphone 2003
            }    
            else
            { 
                if (GetLastError()==ERROR_ACCESS_DENIED) //(5)
                    iDeviceType= SMARTPHONEV2;          // is a smartphone:
                // Smartphone creates an access denied error on
                // SystemParametersInfo() 
            }
        }
    }
    return iDeviceType;
}
在 Smartphone 上,调用“SystemParametersInfo()”可能会因“Access Denied”而失败,这取决于 Smartphone 是否锁定和应用程序签署的证书。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值