createFile invalid handle

kreljm

New member
Local time
11:54 PM
Messages
1
I could use some help figuring out why createFile will fail on some machines and not on others. Customer's are installing a USB drive on their machines and then running my security application. The security app runs fine for most of the customer except for about 3. It fails every time with an invalid handle error. I have checked the owner and permissions on the drive letter and at the c:\ level and they are all fine. The code I am running is below.


snprintf(devpath, sizeof(devpath)-1, "\\\\?\\");
strcat(devpath, drive);

hDevice = CreateFile(devpath, // drive to open
//0, // no access to the drive
GENERIC_READ,
FILE_SHARE_READ,
NULL, // default security attributes
OPEN_EXISTING, // disposition
0, // file attributes
NULL); // do not copy file attributes


if (hDevice == INVALID_HANDLE_VALUE) // cannot open the drive
{
printf("E1129:Handle invalid\n");
printf("Press return key to continue.");
scanf("%c",answer);
return (FALSE);
}

Any thoughts as to how to fix this would be appreciated. I have actually added the GetLastError() call to the code to get the exact error code for the failure. I am now waiting on a customer call back to try the new code.
 

My Computer My Computer

At a glance

windows
OS
windows
I don't remember using 0 for file attribute in CreateFile.
Have you tried FILE_ATTRIBUTE_NORMAL ??

med3d-virus.gif
 

My Computer My Computer

At a glance

Windows 7 32 bitAMD 5200+ dual core2 GBNVidia GeForce 6150SE 128 MB
Computer Manufacturer/Model Number
HP Media Center
OS
Windows 7 32 bit
CPU
AMD 5200+ dual core
Memory
2 GB
Graphics Card(s)
NVidia GeForce 6150SE 128 MB
Monitor(s) Displays
CRT
Screen Resolution
1280x1024
Hard Drives
500 GB Sata internal :

SIIG USB 3.0 docking stations w/WD Caviar Black 6 Gb/s drives
Keyboard
PS/2
Mouse
PS/2 Wheel Mouse
Other Info
SIIG USB 3.0 PCIexpress card.
Back
Top