Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GetShortPathName does not work

241 views
Skip to first unread message

greenfish

unread,
Sep 1, 2008, 10:35:19 PM9/1/08
to
::GetShortPathName does not return always a fully short path on VISTA.

::GetShortPathName("C:\Program Files\AAA\AAA BBB");
returns
"C:\PROGRA~1\AAA\AAA BBB".
and ::GetLastError() was ERROR_SUCCESS.

file system is NTFS, of course.


jerome

unread,
Sep 2, 2008, 2:15:52 AM9/2/08
to
"greenfish" <green...@gmail.com> wrote in message
news:g9i8pl$n99$1...@aioe.org...

> ::GetShortPathName does not return always a fully short path on VISTA.
>
> ::GetShortPathName("C:\Program Files\AAA\AAA BBB");
> returns
> "C:\PROGRA~1\AAA\AAA BBB".

Then, it works : "PROGRA~1\" is the short path of "Program Files"
What did you expect ?!


Jeroen Mostert

unread,
Sep 2, 2008, 2:30:19 AM9/2/08
to
I'm not the OP, but even I can guess he expected "AAA BBB" to be reduced to
its short form as well ("AAABBB~1"). My tests show this does what you expect
it to on Windows XP.

Try verifying the file's actual short name with "dir /x". I don't know the
details for Vista, but it's possible, for example, that it turns off short
file name generation after installation. In this case "Program Files" would
have a short name but "AAA BBB" would not.

--
J.

Uwe Kotyczka

unread,
Sep 3, 2008, 4:50:37 AM9/3/08
to
Did you mean

::GetShortPathName("C:\\Program Files\\AAA\\AAA BBB");
instad of

::GetShortPathName("C:\Program Files\AAA\AAA BBB");
?

greenfish

unread,
Sep 3, 2008, 5:01:45 AM9/3/08
to
i'm sorry.
there's some ambiguity in my article.

i found that the result of ::GetShortPathName(...) are composed of long path
and short path in VISTA.

ex)
::GetShortPathName("C:\Program Files\FIRST LONG PATH\AAA\SECOND LONG PATH")
returns
"C:\PROGRA~1\FIRSTL~1\AAA\SECOND LONG PATH"

i can not understand why last folder name was long path name.

**************************************************************
"Uwe Kotyczka" <uwe.ko...@web.de> wrote in message
news:fc3ddaa6-96cf-428c...@34g2000hsh.googlegroups.com...

Man-wai Chang ToDie (33.6k)

unread,
Sep 3, 2008, 5:05:28 AM9/3/08
to

needs to escape the "\" with another "\"?

--
@~@ Might, Courage, Vision, SINCERITY.
/ v \ Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Xubuntu 8.04.1) Linux 2.6.26.2
^ ^ 17:05:01 up 27 days 1:17 3 users load average: 1.03 1.01 1.00
? ? (CSSA):
http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa/

Dean Earley

unread,
Sep 3, 2008, 5:19:51 AM9/3/08
to
greenfish wrote:
> i'm sorry.
> there's some ambiguity in my article.
>
> i found that the result of ::GetShortPathName(...) are composed of long path
> and short path in VISTA.
>
> ex)
> ::GetShortPathName("C:\Program Files\FIRST LONG PATH\AAA\SECOND LONG PATH")
> returns
> "C:\PROGRA~1\FIRSTL~1\AAA\SECOND LONG PATH"
>
> i can not understand why last folder name was long path name.

Did you try what Jeroen suggested and see what its real "short" name is?
It is possible that short file names is disabled on that system and the
shortened folders either already had them or were created for compatibility.

What is the value (if it exists) of the value:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\NtfsDisable8dot3NameCreation

--
Dean Earley (dean....@icode.co.uk)
i-Catcher Development Team

iCode Systems

greenfish

unread,
Sep 3, 2008, 5:43:48 AM9/3/08
to

Oh, that value was 1.
i guess some program must change that value.

thank you a lot.

**************************************************************
"Dean Earley" <dean....@icode.co.uk> wrote in message
news:48be56b7$0$26086$db0f...@news.zen.co.uk...

Uwe Kotyczka

unread,
Sep 3, 2008, 6:46:44 AM9/3/08
to
You missed my point. I meant that you should
use double backslashes in your source code.

greenfish

unread,
Sep 3, 2008, 8:13:14 PM9/3/08
to
double backslashes in my example code are not important.
it's just pseudo code rewrited my source code for a easy look and feel.

i solve the problem.
http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/regentry/28231.mspx?mfr=true

**************************************************************
"Uwe Kotyczka" <uwe.ko...@web.de> wrote in message

news:48c8d059-33d1-4cd1...@z66g2000hsc.googlegroups.com...

0 new messages