i want lock one drive such as C:\ . this is my code but doesnt work please help why ?
#include <windows.h>
#include <winioctl.h>
#include <stdio.h>
int main(){
char szVolume[] = "\\\\.\\C:";
HANDLE hVolume;
DWORD dwBytes = 0;
PREVENT_MEDIA_REMOVAL pmr;
pmr.PreventMediaRemoval = TRUE;
hVolume = CreateFile(szVolume,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL);
if(hVolume==INVALID_HANDLE_VALUE){
exit(1);
}
if(DeviceIoControl(hVolume,IOCTL_STORAGE_EJECTION_CONTROL,(LPVOID)&pmr,(DWORD)sizeof(pmr),NULL,0,&dwBytes,NULL)==FALSE){
exit(1);
}
CloseHandle(hVolume);
return 0;
}
and i dont want use Registry code please help me how can i fix this code to work it
This post has been edited by ahura_24: 26 July 2011 - 01:59 PM

New Topic/Question
Reply



MultiQuote








|