写程序的时候遇到一点困难,怎样得知驱动器中有没有插入盘?譬如插入SD卡的移动存储器?
解决方案 »
- mfc app wizard(dll) 与mfc app wizard(exe) 的区别
- BCG OUTLOOKBAR高手进,很急
- Form1中的组建怎么在除Form1.h外的源代码的操作?
- 7-zip编译?
- visual c++技术内幕第四版和第五版有什么区别?
- debug输出在程序运行是怎么查看???
- 我想將cstring"10.132.226.24"中的"226."後面的字符串替換掉,,如何辦到呢?
- 如何改变字体的颜色?
- m_edit.SetWindowText(str),怎样改变编辑框中文本字体的大小?
- 如何入手:一个类似彩票走势图的数据显示报表啊?
- 有没有什么工具可以将rm转为Mp3或wav的?
- 菜鸟问题系列,谢谢~
看GetLastError
自己试验一下不同情况下的ERROR是什么值
The IOCTL_STORAGE_CHECK_VERIFY DeviceIoControl operation determines whether a device's media is accessible; for example, whether the media is in the device. BOOL DeviceIoControl(
(HANDLE) hDevice, // handle to device of interest
IOCTL_STORAGE_CHECK_VERIFY, // dwIoControlCode, control code of
// operation to perform
NULL, // lpInBuffer is not used; must be NULL
0, // nInBufferSize is not used; must be zero
NULL, // lpOutBuffer is not used; must be NULL
0, // nOutBufferSize is not used;
// must be zero
(LPDWORD) lpBytesReturned, // pointer to variable to receive
// output byte count
(LPOVERLAPPED) lpOverlapped // pointer to OVERLAPPED structure
// for asynchronous operation
);
{
char DeviceName[MAX_PATH];
HANDLE hDevice;
DWORD cbBytesAct = 0;
bool fMediaExist = false; sprintf(DeviceName, "\\\\.\\%s", Drive); hDevice = CreateFile(
DeviceName,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
NULL,
NULL); if (hDevice != INVALID_HANDLE_VALUE) {
if (DeviceIoControl(
hDevice,
IOCTL_DISK_CHECK_VERIFY,
NULL,
0,
NULL,
0,
&cbBytesAct,
NULL)) {
fMediaExist = true;
} CloseHandle(hDevice);
} return( fMediaExist );
}