如何动态刷新硬盘分区?急 我在修改了分区表之后,比如将第二个逻辑分区隐藏了,但是每次必须重新启动才能看到结果,如何动态的刷新硬盘分区,不用重起就能将第二个逻辑分区隐藏? 请高手指点!!!!!!! 急等!!!!!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 intNT_Device_Dismount(char *pDeviceLetter, int nForceFlag){ HANDLE hFile; UCHAR bRc; DWORD dwError = 0; int status; ULONG bytesReturned; char devicePath[256]; // // Open the device // sprintf(devicePath, "\\\\.\\%s", pDeviceLetter); hFile = CreateFile( devicePath, GENERIC_READ | GENERIC_WRITE, (FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE), NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_NO_BUFFERING, NULL); if ( hFile == INVALID_HANDLE_VALUE ){ if(nForceFlag == TRUE) { // // Go ahead and remove the Device letter // NT_Remove_Device_Letter(pDeviceLetter); } dwError = GetLastError(); SetLastError(dwError); return ( -1 ); } bRc = DeviceIoControl ( hFile, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &bytesReturned, NULL ); if ( bRc ) { // // Remove the Device letter // NT_Remove_Device_Letter(pDeviceLetter); // // syncronously flush file system cache before attempting dismount // to ensure the dismount doesn't need to schedule a flush. // (void) FlushFileBuffers(hFile); // // Performing Ioctl dismount the volume // bRc = DeviceIoControl ( hFile, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, &bytesReturned, NULL ); if ( !bRc ) { dwError = GetLastError(); status = -1; } else { dwError = 0; status = 0; } bRc = DeviceIoControl ( hFile, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, &bytesReturned, NULL ); if ( !bRc ) { dwError = GetLastError(); status = -1; } } else { if(nForceFlag == TRUE) { // // Go ahead and remove the Device letter // NT_Remove_Device_Letter(pDeviceLetter); } dwError = GetLastError(); status = -1; } CloseHandle ( hFile ); SetLastError(dwError); return ( status );} 很简单,主要是通过FSCTL_DISMOUNT_VOLUME来对分区进行卸载卷操作,这样盘符就会消失了。 FSCTL_MOUNT_VOLUME动态加载一个卷,你只能通过自己加载卷和卸载卷来显示隐藏分区。 MFC 点击一个编辑框弹出一个对话框 录制的视频avi过大,达到了一个小时5g的程度 问一个c++中的异常处理问题 想问一下,有没有用来直接删除目录的api函数 如果根据线程ID取线程句柄? 请教如何向TreeCtrl控件发送消息 win98 下拖动窗口如何不现实虚线边框 关于dll文件的入口函数dllmain 怎么调试STL的iterator? CListBox?????? VC中启动另外一个程序,有没有办法让VC的程序死掉一直等到那个程序运行完? 急!如何在主线程结束保持工作线程继续阿?
NT_Device_Dismount(char *pDeviceLetter, int nForceFlag)
{ HANDLE hFile;
UCHAR bRc;
DWORD dwError = 0;
int status;
ULONG bytesReturned;
char devicePath[256];
//
// Open the device
//
sprintf(devicePath, "\\\\.\\%s", pDeviceLetter); hFile = CreateFile( devicePath,
GENERIC_READ | GENERIC_WRITE,
(FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE),
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL|FILE_FLAG_NO_BUFFERING,
NULL);
if ( hFile == INVALID_HANDLE_VALUE ){
if(nForceFlag == TRUE) {
//
// Go ahead and remove the Device letter
//
NT_Remove_Device_Letter(pDeviceLetter);
}
dwError = GetLastError();
SetLastError(dwError);
return ( -1 );
} bRc = DeviceIoControl ( hFile,
FSCTL_LOCK_VOLUME,
NULL,
0,
NULL,
0,
&bytesReturned,
NULL
); if ( bRc ) { //
// Remove the Device letter
//
NT_Remove_Device_Letter(pDeviceLetter); //
// syncronously flush file system cache before attempting
dismount
// to ensure the dismount doesn't need to schedule a flush.
//
(void) FlushFileBuffers(hFile); //
// Performing Ioctl dismount the volume
//
bRc = DeviceIoControl ( hFile,
FSCTL_DISMOUNT_VOLUME,
NULL,
0,
NULL,
0,
&bytesReturned,
NULL
); if ( !bRc ) {
dwError = GetLastError();
status = -1;
} else {
dwError = 0;
status = 0;
} bRc = DeviceIoControl ( hFile,
FSCTL_UNLOCK_VOLUME,
NULL,
0,
NULL,
0,
&bytesReturned,
NULL
); if ( !bRc ) {
dwError = GetLastError();
status = -1;
} } else {
if(nForceFlag == TRUE) {
//
// Go ahead and remove the Device letter
//
NT_Remove_Device_Letter(pDeviceLetter);
}
dwError = GetLastError();
status = -1;
}
CloseHandle ( hFile );
SetLastError(dwError);
return ( status );}
动态加载一个卷,
你只能通过自己加载卷和卸载卷来显示隐藏分区。