nvidia - TNT(NVDeviceID)

来源:互联网 发布:java base64编码方法 编辑:程序博客网 时间:2024/06/08 11:35

本例子通过directx提供的接口获得显卡id,

关键函数:
char * isNVIDIA()
{
    D3DADAPTER_IDENTIFIER9 did;

    LPDIRECT3D9 g_pD3D = NULL;

    if( NULL == (g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)))
        return DIRECT3DCREATE9_ERROR;

    g_pD3D->GetAdapterIdentifier(D3DADAPTER_DEFAULT, 0, &did);

    // The products listed is an example of how to obtain the device id.
    // For a more complete list of NVIDIA device ids, refer to Device_IDs.txt
     
    if(did.VendorId == 0x12D2)
    {
        switch(did.DeviceId)
        {
            case 0x18:
            case 0x19:
                return "RIVA 128";
        }
        return NULL;
    }
    else if(did.VendorId == DT_NVIDIA_VENDOR_ID)        
    {
        unsigned long D3DDeviceId = did.DeviceId;
        for (int i = 0; i<NVIDIA_DEVICE_TOTAL;i++) {
            if (NVIDIA_DEVICE_INFO[i].deviceID == D3DDeviceId)
            {
                return NVIDIA_DEVICE_INFO[i].chipIDName;
            }
        }
        return "Unlisted Device";
    } else {
        return NULL;
    }
}

通过g_pD3D->GetAdapterIdentifier,获得D3DADAPTER_IDENTIFIER9,从而得知vendorid