GetFullPathName() return value question

Started by
2 comments, last by L. Spiro 12 years, 4 months ago
msdn says the following about the return value of GetFullPathName()

[color=#2A2A2A]
[color=#2A2A2A]If the lpBuffer[color=#2A2A2A] buffer is too small to contain the path, the return value is the size, in TCHARs[color=#2A2A2A], of the buffer that is required to hold the path and the terminating null character.[/quote][color=#2A2A2A]

are they saying that if it fails because i needed a 200 size buffer of wchar_t's instead of a 199 size buffer it will return the value of 200*2 as my return value in lpbuffer or will it return just 200?
Advertisement
It essentially returns the length of the string it attempted to copy into the buffer whether it succeed or failed. So the latter was correct, if the buffer size required was 200, then it will return 200. I'm not actually sure how you got the idea that it would be 2*200, care to explain your reasoning?
wchar size = 2 bytes therefore buffer of wchar_t buffer[250]; == size of 250*2=500
It returns the number of characters long your buffer needs to be, not the required number of bytes.
A return of 200 would indicate that you need 200 wchar_t’s.

Additionally, unless you are specifically calling GetFullPathNameW(), always work with type TCHAR. Never work with char or wchar_t unless you are manually calling GetFullPathNameA() or GetFullPathNameW().


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

This topic is closed to new replies.

Advertisement