檢測本機所有的串並埠 vs2003除錯通過

2021-04-14 08:03:20 字數 3689 閱讀 9124

檢測本機所有的串並埠

#include

typedef hkey (__stdcall setupdiopendevregkey)(hdevinfo, psp_devinfo_data, dword, dword, dword, regsam);

typedef bool (__stdcall setupdiclassguidsfromname)(lpctstr, lpguid, dword, pdword);

typedef bool (__stdcall setupdidestroydeviceinfolist)(hdevinfo);

typedef bool (__stdcall setupdienumdeviceinfo)(hdevinfo, dword, psp_devinfo_data);

typedef hdevinfo (__stdcall setupdigetclassdevs)(lpguid, lpctstr, hwnd, dword);

typedef bool (__stdcall setupdigetdeviceregistryproperty)(hdevinfo, psp_devinfo_data, dword, pdword, pbyte, dword, pdword);

bool isnumeric(lpctstr pszstring, bool bignorecolon)

void testports()

setupdiopendevregkey* lpfnlpsetupdiopendevregkey = (setupdiopendevregkey*) getprocaddress(hsetupapi, "setupdiopendevregkey");

#ifdef _unicode

setupdiclassguidsfromname* lpfnsetupdiclassguidsfromname = (setupdiclassguidsfromname*) getprocaddress(hsetupapi, "setupdiclassguidsfromnamew");

setupdigetclassdevs* lpfnsetupdigetclassdevs = (setupdigetclassdevs*) getprocaddress(hsetupapi, "setupdigetclassdevsw");

setupdigetdeviceregistryproperty* lpfnsetupdigetdeviceregistryproperty = (setupdigetdeviceregistryproperty*) getprocaddress(hsetupapi, "setupdigetdeviceregistrypropertyw");

#else

setupdiclassguidsfromname* lpfnsetupdiclassguidsfromname = (setupdiclassguidsfromname*) getprocaddress(hsetupapi, "setupdiclassguidsfromnamea");

setupdigetclassdevs* lpfnsetupdigetclassdevs = (setupdigetclassdevs*) getprocaddress(hsetupapi, "setupdigetclassdevsa");

setupdigetdeviceregistryproperty* lpfnsetupdigetdeviceregistryproperty = (setupdigetdeviceregistryproperty*) getprocaddress(hsetupapi, "setupdigetdeviceregistrypropertya");

#endif

setupdidestroydeviceinfolist* lpfnsetupdidestroydeviceinfolist = (setupdidestroydeviceinfolist*) getprocaddress(hsetupapi, "setupdidestroydeviceinfolist");

setupdienumdeviceinfo* lpfnsetupdienumdeviceinfo = (setupdienumdeviceinfo*) getprocaddress(hsetupapi, "setupdienumdeviceinfo");

if ((lpfnlpsetupdiopendevregkey == null) || (lpfnsetupdiclassguidsfromname == null) || (lpfnsetupdidestroydeviceinfolist == null) ||

(lpfnsetupdienumdeviceinfo == null) || (lpfnsetupdigetclassdevs == null) || (lpfnsetupdigetdeviceregistryproperty == null))

//first need to convert the name "ports" to a guid using setupdiclassguidsfromname

dword dwguids = 0;

lpfnsetupdiclassguidsfromname(_t("ports"), null, 0, &dwguids);

if (dwguids == 0)

//allocate the needed memory

guid* pguids = new guid[dwguids];

//call the function again

if (!lpfnsetupdiclassguidsfromname(_t("ports"), pguids, dwguids, &dwguids))

//now create a "device information set" which is required to enumerate all the ports

hdevinfo hdevinfoset = lpfnsetupdigetclassdevs(pguids, null, null, digcf_present);

if (hdevinfoset == invalid_handle_value)

//finished with the guids by this time

delete pguids;

pguids = null;

//finally do the enumeration

bool bmoreitems = true;

int nindex = 0;

sp_devinfo_data devinfo;

while (bmoreitems)

//if the port was a serial port, then also try to get its friendly name

if (badded)}}

afxmessagebox(pszportname);

}++nindex;

}//free up the "device information set" now that we are finished with it

lpfnsetupdidestroydeviceinfolist(hdevinfoset);

//unload the setup dll

freelibrary(hsetupapi);

cstring sssss;

sssss.format("共找到%d個埠",(nindex-1));

afxmessagebox(sssss);

獲取本機所有的ADSL連線名稱

真鬱悶呀,就這點 費半天勁,dotras怎麼會沒有這個功能呢?dotras的就只有乙個獲取dotras.rasconnection.getactiveconnections這應該是活動連線 呼叫方法 dim stradsl as string ras.listadsl if stradsl then...

返回所有的最長回文子串 O n

用馬拉車演算法將回文半徑p i 求出來,回文字串的長度就是p i 1,起始的下標就是 i p i 2,遍歷一次p i 陣列將所有最大長度的 字串存到vector就可以了。include using namespace std string solve string s,vector v vector...

口罩外觀視覺檢測裝置 檢測市面上所有的口罩

未耒 lei 智慧型 敬上 還在用人工檢測平面口罩 kn95類口罩 kf系列口罩嗎?成本高不?檢測效果理想不?合格品的合格率達標不?檢測速度跟得上生產速度不?這些問題困擾的煩心不?300字小短文,歡迎您的閱讀,整不好咱就不煩心了呢?先說檢測類目 1 表面字元 logo,有條紋碼咱也可以檢測的 2 異...