Re: Failed to open USB device using CreateFile: ERROR_FILE_NOT_FOUND

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



flashlib@xxxxxxxxx wrote:
On 4?17?, ??11?02?, "Ben Voigt [C++ MVP]" <r...@xxxxxxxxxxxxx> wrote:
flash...@xxxxxxxxx wrote:
On 4ÔÂ16ÈÕ, ÏÂÎç9ʱ26·Ö, chris.aselt...@xxxxxxxxx wrote:
On Apr 13, 10:21 pm, flash...@xxxxxxxxx wrote:

hDeviceHandle=CreateFile(
szDevicePath[i],
GENERIC_READ | GENERIC_WRITE,
0,//FILE_SHARE_READ |
FILE_SHARE_WRITE, NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED |
FILE_ATTRIBUTE_NORMAL, NULL
);

/////////////////////////////////////////////// // it failed here,
always return ERROR_FILE_NOT_FOUND
///////////////////////////////////////////////

For every case that you get ERROR_NOT_FILE_FOUND, give us a dump of
szDevicePath[i] please. My guess is that you've mangled it
somehow.

Hi Chris,

Thanks for your attention! The szDevicePath[i] is as following:
"\\?
\usb#vid_abcd&pid_1234#5&25c045bb&0&1#{a5dcbf10-6530-11d2-901f-00c04fb951ed}"

Check UNICODE vs single byte?



Thanks.

Hi Ben,

I tried both Unicode and single byte, the result is the same. Any more
suggestion would be greate appreciated!

Just that I've only seen the "\\?\" prefix discussed with the Unicode
version, CreateFileW. But your variable naming suggested you are using
single byte characters.


.



Relevant Pages

  • Re: Long, long file names?
    ... > characters long if the unicode versions of some ... Yes, notably CreateFileW, I'd guess. ... > stores file names in unicode. ... On FAT, long filenames, yes. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Toolbar for frequently used symbols
    ... But think of what a mess the Tools | Customize dialog would be if somehow it ... included the whole range of Unicode characters.....'cause it's too easy to ...
    (microsoft.public.word.docmanagement)
  • Re: rtf question
    ... Apparently it doesn't like the somehow. ... character after the special character, even if I put a blank ... that don't understand Unicode. ... because it "ate" the rightmost one, unbalancing them. ...
    (comp.fonts)
  • Re: ATL 7.0 Portability Issue
    ... > Somehow it got "clogged up" or something. ... On Windows 95 Dependency Walker says OLEACC.DLL is ... That may be a unicode enabled DLL. ... Microsoft MVP ...
    (microsoft.public.vc.mfc)
  • Re: Failed to open USB device using CreateFile: ERROR_FILE_NOT_FOUND
    ... somehow. ... suggestion would be greate appreciated! ... So, when I set to Unicode mode, it is a real unicode variable. ...
    (microsoft.public.development.device.drivers)