4
有没有一种方法可以在Windows上以编程方式检测SD卡的驱动器号?该方法是否支持内部和外部SD卡硬件?感谢您的时间。检测SD卡硬件的驱动器号
有没有一种方法可以在Windows上以编程方式检测SD卡的驱动器号?该方法是否支持内部和外部SD卡硬件?感谢您的时间。检测SD卡硬件的驱动器号
您可以尝试GetLogicalDriveStrings获取驱动器号,然后使用GetDriveType来查看驱动器是否可移除。然后你可以得到更多这样的设备信息(例如CD-ROM,但应该显示你的想法):
//handle to the drive to be examined
HANDLE hDevice = CreateFile(TEXT("\\\\.\\G:"), //Drive to open
GENERIC_READ|GENERIC_WRITE, //Access to the drive
FILE_SHARE_READ|FILE_SHARE_WRITE, //Share mode
NULL, //Security
OPEN_EXISTING,0, // no file attributes
NULL);
if (hDevice == INVALID_HANDLE_VALUE) return 0;
CDROM_TOC val; // table of contents for a generic CDROM
DWORD nBytesReturned;
BOOL bResult= DeviceIoControl(
hDevice,
IOCTL_CDROM_READ_TOC,//operation to perform
&val, sizeof(val),//no input buffer
&val, sizeof(val),//output buffer
&nBytesReturned,//#bytes returned
(LPOVERLAPPED) NULL);//synchronous I/O
CloseHandle(hDevice);