日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java父系调用子系,获取usb设备父系或子代

發布時間:2024/1/23 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java父系调用子系,获取usb设备父系或子代 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

///

/// 獲取設備父系

///

///

///

private static bool TryGetDriverIdParent(string driver, out string resultDeviceID)

{

resultDeviceID = "";

try

{

int CM_LOCATE_DEVNODE_NORMAL = 0x00000000;

int CR_SUCCESS = 0x00000000;

UInt32 parentInst;

;

;

int apiResult = Win32.CM_Locate_DevNodeA(ref curInst, driver, CM_LOCATE_DEVNODE_NORMAL);

if (apiResult != CR_SUCCESS)

{

return false;

}

apiResult = Win32.CM_Get_Parent(out parentInst, (UInt32)curInst, CM_LOCATE_DEVNODE_NORMAL);

if (apiResult != CR_SUCCESS)

{

return false;

}

apiResult = Win32.CM_Get_Device_ID_Size(out pLen, parentInst, CM_LOCATE_DEVNODE_NORMAL);

if (apiResult != CR_SUCCESS)

{

return false;

}

];

//獲取設備id字符串地址

apiResult = Win32.CM_Get_Device_ID(parentInst, ptrInstanceBuf, pLen, );

if (apiResult != CR_SUCCESS)

{

return false;

}

resultDeviceID = new string(ptrInstanceBuf);

return true;

}

catch (Exception ecException)

{

LogHelper.WriteErrorLog("獲取父代" + ecException.Message, ecException);

return false;

}

}

[DllImport("setupapi.dll", SetLastError = true)]

public static extern int CM_Locate_DevNodeA(ref int pdnDevInst, string pDeviceID, int ulFlags);

[DllImport("setupapi.dll")]

public static extern int CM_Get_Parent(out UInt32 pdnDevInst, UInt32 dnDevInst, int ulFlags);

[DllImport("setupapi.dll", SetLastError = true)]

);

[DllImport("setupapi.dll", CharSet = CharSet.Unicode)]

public static extern int CM_Get_Device_ID(UInt32 dnDevInst, char[] buffer, int bufferLen, int flags);

總結

以上是生活随笔為你收集整理的java父系调用子系,获取usb设备父系或子代的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。