The GetModuleFileName()
takes a buffer and size of buffer as input; however its return value can only tell us how many characters is has copied, and if the size is not enough (ERROR_INSUFFICIENT_BUFFER
).
How do I determine the real required buffer size to hold entire file name for GetModuleFileName()
?
Most people use MAX_PATH
but I remember the path can exceed that (260 by default definition)...
(The trick of using zero as size of buffer does not work for this API - I've already tried before)
Using
might work.
From the documentation of GetModuleFileName:
But if I read about _pgmptr:
Anyone who knows how _pgmptr is initialized? If SO had support for follow-up questions I would posted this question as a follow up.