nvidia - TNT(NVDeviceID)

本文介绍了一种使用DirectX API来获取显卡ID的方法。通过调用特定的DirectX函数,可以读取显卡的供应商ID和设备ID,并进一步判断显卡型号。此方法适用于NVIDIA显卡。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本例子通过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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值