码迷,mamicode.com
首页 > Windows程序 > 详细

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

时间:2019-05-26 11:04:31      阅读:477      评论:0      收藏:0      [点我收藏+]

标签:硬件   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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!