Home > Windows API > How to convert between short and long path names

How to convert between short and long path names

Use GetShortPathName to get short file name for a given long file name.

Use GetLongPathName to get long file name for a given short file name.

Eg:

TCHAR szPath[MAX_PATH] = { 0 };
GetShortPathName( _T( "C:/Program Files/Microsoft Visual Studio" ), szPath, MAX_PATH );
MessageBox( NULL, szPath, _T( "Short path" ), MB_OK );  

TCHAR szShortPath[MAX_PATH];
_tcscpy( szShortPath, szPath );
GetLongPathName( szShortPath, szPath, MAX_PATH );
MessageBox( NULL, szPath, _T( "Long path" ), MB_OK );
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: