GetShortPathName v C++

2 отговора 117 прегледа
#1

GetShortPathName v C++

Опитвам се да извлека късият път под Win2000, понеже под DOS Prompt се вижда само - C:\Documents and Settings\... (или не знам как да го кофигурирам да показва c:\docume~1\...), и => не мога да отворя файла който ми трябва, като пиша на C++. Ако някой е ползвал GetShortPathName под С++ ще ми е много полезно да сподели как се ползва(кои библиотеки се включват, какви допълнителни редове се пишат...) <- тия необходими подробности:)

10x

Отговор
в отговор на neon #2

Re: GetShortPathName v C++

The GetShortPathName function obtains the short path form of a specified input path.

DWORD GetShortPathName(
LPCTSTR lpszLongPath, // pointer to a null-terminated path string
LPTSTR lpszShortPath, // pointer to a buffer to receive the
// null-terminated short form of the path
DWORD cchBuffer // specifies the size of the buffer pointed
// to by lpszShortPath
);

Parameters
lpszLongPath
Pointer to a null-terminated path string. The function obtains the short form of this path.
lpszShortPath
Pointer to a buffer to receive the null-terminated short form of the path specified by lpszLongPath.
cchBuffer
Specifies the size, in characters, of the buffer pointed to by lpszShortPath.
Return Values
If the function succeeds, the return value is the length, in characters, of the string copied to lpszShortPath, not including the terminating null character.

If the function fails due to the lpszShortPath buffer being too small to contain the short path string, the return value is the size, in characters, of the short path string. You need to call the function with a short path buffer that is at least as large as the short path string.

If the function fails for any other reason, the return value is zero. To get extended error information, call GetLastError.

QuickInfo
Windows NT: Requires version 3.5 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.

Чети в MSDN-a

Отговор
в отговор на cz #3

Re: GetShortPathName v C++

uf tozi red Header: Declared in winbase.h go bqh propusnal...
no za da trygne programkata trqbvashe: #include <windows.h>,
i to da go postavq predi #include <winbase.h>.

Blagodarq za paste-a

Отговор