I have "Test.c" in the working directory. It's valid cause I used FindFirstFile to get that name using "./Test*.c".

But when I use GetShortPathName on "Test.c" (works on NT), "./Test.c", or ".\Test.c" it fails with:
ERROR_BAD_PATHNAME (000000A1)

Anyone ever heard of this?

Thanks,
Mike
Posted on 2002-05-23 00:51:28 by eet_1024
The SDK says that LPCTSTR lpszLongPath is a path, so im assuming that it means full path.
Posted on 2002-05-23 02:10:55 by huh
Nope. I found this in another executable


LEA EDX,DWORD PTR SS:[ESP+C]
PUSH 100 ; /MaxShortPathSize = 100 (256.)
PUSH EDX ; |ShortPath
PUSH EAX ; |LongPath
CALL DWORD PTR DS:[<&KERNEL32.>; \GetShortPathNameA
MOV EBX,DWORD PTR DS:[ESI]
LEA EAX,DWORD PTR SS:[ESP+C]


It too returns the same error, but the last line magically makes eax point to "TESTMI~1.C" if the input string was "Test Mike.c"

It's doing some pretty weird stuff.
Posted on 2002-05-23 03:21:19 by eet_1024


PUSH 104 ; /MaxShortPathSize = 104 (260.)
PUSH LS.0040238B ; |ShortPath = LS.0040238B
PUSH DWORD PTR SS:[EBP+8] ; |LongPath = "E:\zMakeUt\Test Mike.c"
CALL DWORD PTR DS:[<&KERNEL32.>; \GetShortPathNameA


Give the error also
Posted on 2002-05-23 03:27:21 by eet_1024
Seeing im not getting alot of info, i cant be too specific. But here are some general things to check:

    [*]I dunno what a "TCHAR" is, but the MSDN says the length must be given in this.
    [*]Valid path types: Look here. . There is a clause at the bottom that talks about reserved words that cant be used as file names. ie) nul.txt, perhaps your testing with a 'bad' name to begin with.
    [*]Na.. just disproved any chance of it being point three... ;)


    Hope this is some help.
    :NaN:
Posted on 2002-05-23 03:43:47 by NaN
I found a workaround at MS (for some other problems with this function), maybe you can use it:
To work around this problem, use the FindFirstFile function. The returned WIN32_FIND_DATA structure contains a cAlternateFileName member that is filled out with the short file name but not the full path.
Posted on 2002-05-23 04:59:13 by beaster
The GetShortPathName function retrieves the short path form of a specified input path.

Give it a long path,It return a 8.3 path

So.............................
Posted on 2002-05-23 08:23:19 by purefiring
You Also Must Have Your "E:\zMakeUt\Test Mike.c"File in Your Dir!
Posted on 2002-05-23 08:51:27 by purefiring
I'm creating a app that will compile (and Asm), link, and create a download file for an embedded computer. The user will supply The File Base Name. For example: ls Test -M
The -M means multiple files of the same base name.

My program will then use Find File to get a list of BaseName*.c, but it will strip off the .c.

From this list it will get the ShortPathName of each file, adding the .c extension and call the compiler (The compiler can't handle spaces in the file name).

When the Compiling is done, my app will create a linker command file and give that to the linker.

The problem doesn't exist on WinNt. And there's a workaround for Win98. I just don't know what it is.

------------------------------------------------------------------------
I just tested it on another Win98 Machine. Same error too.

I've changed the GetShortPathName syscalls to FindFirst file. It works fine on both Win98 and NT.

I still would like to know what's going on with GetShortPathName though.

Thanks for the FindFile suggestion.
Posted on 2002-05-23 15:00:24 by eet_1024