Re: CreateFile and MAX_PATH and UNICODE



"sienaman" <sienaman@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:991707DC-D931-458D-B108-78CDEA5DD867@xxxxxxxxxxxxxxxx
Seems like CreateFile does not support filename longer than 208 characters.

I've been having weird problems on occasion, and wonder if you might have found an explanation. I didn't try to look for magic numbers unrelated to MAX_PATH but that could be it.

In the SDK docs, it says that "In the ANSI version of this function, the name is limited to MAX_PATH characters.

Yup, the SDK docs do say that. I reported to Microsoft that this is a bug. The fact is that in the ANSI version of this function, the name is limited to MAX_PATH _bytes_ not characters (that is, unless 208 is a magic number as you seem to have discovered). Microsoft replied with an assertion that I had a misunderstanding and an assertion that in ANSI every character is a single byte. That made it pretty clear that Microsoft needs to provide more training to Microsoft employees, so I tried to escalate the issue in hopes (silly me) that Microsoft might understand and provide more training to Microsoft employees. Microsoft retorted that I live in Australia (false), and therefore I should pay a support fee to Microsoft Japan (which happens to be where I live) in hopes of getting Microsoft Japan's support staff to teach Microsoft to provide more training to Microsoft employees. So much for the idea of sending e-mail directly to Microsoft where MSDN pages solicit e-mail. Public postings do tend to get higher quality responses, on average.

To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path". As simple test of this would be to try and create a file with a 255 character name with either a DOS prompt

Wrong. Either the DOS prompt is going to call the ANSI version of the function instead of the Unicode version, or it's going to do something else that yields the same results as if it were calling the ANSI version.

or right clicking on the Desktop to create say a new text file.

I think that Windows Explorer calls Unicode APIs, but still, Windows Explorer is a program with its own limitation. You didn't write the code for Windows Explorer and you didn't put in a buffer allocation routine that could handle 32,767 wide characters. In order to get what Windows will let you get, you have to write your own program.

Both methods fail for filenames longer than 208 characters. Also, any attempt to create a file with a name longer than 208 characters using CreateFile fails (including the extension) fails.

Again I didn't notice 208 being a magic number but I've seen various unexpected behaviour on occasion.

.



Relevant Pages

  • Re: PPT. add-in
    ... If you want to use MSAgent in PowerPoint it's very easy, ... folder in Windows 2000) and see that you have Agent Characters installed, ... Go to the Microsoft Agent ... Or, for the newbies to scripting, ...
    (microsoft.public.powerpoint)
  • Re: Dates and Column Widths in Excel 2007
    ... "If the default font is a non-proportional font, ... 8.43 characters of any type fit into a cell ... I don't think either I or Microsoft can can explain it any more clearly. ... Microsoft Excel 2000 Standard Edition ...
    (microsoft.public.excel.misc)
  • Re: Where is the word count tool?
    ... Note that the people answering questions here do not work for Microsoft. ... What font are you using and what view are you working in. ... Word then doesn't see 'words' just characters, ... live word count /should/ show the number of words in the selected portion ...
    (microsoft.public.word.docmanagement)
  • Re: Indian language fonts to be included as default fonts in windo
    ... Give up, grammatim. ... so, I mean, new version of mangal has 127 characters then that shows ... that Microsoft is making one more blunder. ... specified by Unicode. ...
    (microsoft.public.word.docmanagement)
  • Re: ToUpper() Better solution
    ... be aware that there is a Microsoft VisualBasic method ... European languages (Latin characters). ... characters (which will be the accents) with the empty string. ...
    (microsoft.public.dotnet.general)

Quantcast