c#实现"扫描检测硬件改动"

2021-06-03 01:03

阅读:779

标签:硬件   war   扫描   overflow   mgr   last   extern   device   err   

public static class Win32Api
{
    public const int CM_LOCATE_DEVNODE_NORMAL = 0x00000000;
    public const int CM_REENUMERATE_NORMAL = 0x00000000;
    public const int CR_SUCCESS = 0x00000000;

    [DllImport("CfgMgr32.dll", SetLastError=true)]
    public static extern int CM_Locate_DevNodeA(ref int pdnDevInst, string pDeviceID, int ulFlags);

    [DllImport("CfgMgr32.dll", SetLastError=true)]
    public static extern int CM_Reenumerate_DevNode(int dnDevInst, int ulFlags);
}

  

调用方法:

int pdnDevInst = 0;
Win32Api.CM_Locate_DevNodeA(ref pdnDevInst, null, Win32Api.CM_LOCATE_DEVNODE_NORMAL); Win32Api.CM_Reenumerate_DevNode(pdnDevInst, Win32Api.CM_REENUMERATE_NORMAL);

 

 

参考链接:

https://stackoverflow.com/questions/2181525/is-there-an-api-call-to-start-a-scan-for-hardware-devices

c#实现"扫描检测硬件改动"

标签:硬件   war   扫描   overflow   mgr   last   extern   device   err   

原文地址:https://www.cnblogs.com/sherlock-merlin/p/10925310.html


评论


亲,登录后才可以留言!