Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: createFile invalid handle

05 Mar 2010   #1
kreljm

windows
 
 
createFile invalid handle

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 System SpecsSystem Spec
.

05 Mar 2010   #2
MilesAhead

Windows 7 32 bit
 
 

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

Name:  med3d-virus.gif
Views: 1480
Size:  20.6 KB


My System SpecsSystem Spec
Reply

 createFile invalid handle




Thread Tools





Similar help and support threads
Thread Forum
Can't backup - Invalid window handle (Error code: 0x80070578)
On a Windows 7 laptop, I noticed that Windows Backup hadn't backed up anything in about a year since the USB drive it was backing up to was full. (I thought Windows 7 would delete old backups if the backup drive was full, but that's another issue.) So I deleted all the backups off the USB drive...
Backup and Restore
Handle is invalid when printing
I have a HP M1530 printer working fine on Windows 7. I get the error message:the handle is invalid after I update .Net framework to V4.0. I tried to uninstalled/re-installed printer driver. It seems the printer can only print for one time after that , then show up same error message. Any ideas?...
Hardware & Devices
BSOD-Invalid Kernel Handle-ntoskrnl.exe
the other day i went to shut down my computer and i got an error dialog box popup from evga precision x, then it blue screened on me. invalid kernel handle, driver-ntoskrnl.exe, address-ntoskrnl.exe+7efc0. i would like to try and fix this problem. i have attached the dump file
BSOD Help and Support
What is "Invalid Handle" and how can I fix it?
I volunteer at the State of California's Employment Development Department Experience Unlimited job club. A few weeks ago the state installed 15 identical HP AU1245AV workstations with a customized image. The bureaucracy, a bit better than DMV, doesn't give me access to the person who build the...
Installation & Setup
invalid kernel handle
hi, have recently started getting a bsod on startup. I am running windows 7 professional 64 bit on a recently built pc by myself. thanks in advance for your help
BSOD Help and Support
Backup error: The handle is invalid
I have setup the backup utility to use my network drive and create an image and copy the my doc folder. When I run the utility it will go through it's process for a long time before providing the following error information: Check your backup One of the backup files could not be created. ...
Backup and Restore

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 21:49.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App