在VC++中,如何获得硬盘卷标号?
发布网友
发布时间:2024-10-10 08:33
我来回答
共2个回答
热心网友
时间:2024-10-30 14:08
#include <windows.h>
#pragma comment(lib, \"advapi32\")
int APIENTRY WinMain(HINSTANCE,HINSTANCE,LPSTR,int) {
HKEY hKey;
DWORD dwType, dwDisp;
CHAR szDiskID[256] = \"Can not get Disk ID on your mechine.\";
LONG ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, \"HARDWARE\\\\DESCRIPTION\\\\System\\\\MultifunctionAdapter\\\\9\\\\DiskController\\\\0\\\\DiskPeripheral\\\\0\", 0, KEY_READ, &hKey);
if(ret == ERROR_SUCCESS) {
ret = RegQueryValueEx(hKey, \"Identifier\", 0, &dwType,
(BYTE*)szDiskID, &dwDisp);
RegCloseKey(hKey);
}
MessageBox(NULL, szDiskID, \"Disk ID\", MB_OK);
return 0;
}
热心网友
时间:2024-10-30 14:08
win32 api
msdn 有