From: Zack on
Hi
I am trying to copy to the usb , raw data, with function writefile(..),
and i get the error number 5 =Access is denied,
I am working with vista SP1, and i guess it got to be connected to my
priviliges.
I have tried to run the *.exe file with "run as administrator" option and it
doesn't help.
Also tried to enable the checkbox "run this program as administrator"

Do you know how to avoid this ERROR ?
any code sample maybe ?
-I have successed to read from the usb all the raw data in the same way.
I also debug my code and make sure the the "drive letter" is the real one i
want.

here is the code i am using:

char _devicename[] = "\\\\.\\A:";
_devicename[4] = Drive_letter;
hDevice = CreateFileA( _devicename,
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
if (hDevice == INVALID_HANDLE_VALUE)
return ;

SetFilePointer (hDevice, (i*SectorNumber_for_each_read*512),
NULL,FILE_BEGIN);

if (!WriteFile (hDevice, sectorBuffer, 512*SectorNumber_for_each_read,
&numberOfBytesWrite, NULL) )
{
win = GetLastError();
break;
}
CloseHandle(hDevice);
// win = 5 = permition denied