我在修改了分区表之后,比如将第二个逻辑分区隐藏了,但是每次必须重新启动才能看到结果,如何动态的刷新硬盘分区,不用重起就能将第二个逻辑分区隐藏?   请高手指点!!!!!!!  急等!!!!!!!

解决方案 »

  1.   

    int
    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 );}
      

  2.   

    很简单,主要是通过FSCTL_DISMOUNT_VOLUME来对分区进行卸载卷操作,这样盘符就会消失了。
      

  3.   

    FSCTL_MOUNT_VOLUME
    动态加载一个卷,
    你只能通过自己加载卷和卸载卷来显示隐藏分区。