BigSandwich
BigSandwich

Reputation: 2816

_get_pgmptr vs GetModuleFileName

What difference is there (if any) between these two? MSDN is very unclear.

Here it sounds like they are equivalent: https://msdn.microsoft.com/en-us/library/windows/desktop/ms683197%28v=vs.85%29.aspx

But here it sounds like _pgmptr may not always give me a full path, but it doesn't really explain under what circumstances. https://msdn.microsoft.com/en-us/library/tza1y5f7.aspx

_pgmptr Seems far more attractive to me because I don't have to play buffer size guessing games with it.

Upvotes: 3

Views: 2778

Answers (2)

André Rodrigues
André Rodrigues

Reputation: 131

There at least one difference: _get_pgmptr() isn't available early in an application initialization, whilst GetModuleFileName() is. I've just been bitten by the Static Initialization Order Fiasco because of this :(

Upvotes: 4

Jonathan Potter
Jonathan Potter

Reputation: 37202

_pgmptr is initialised using GetModuleFileName internally, so the answer is there's no difference - they will return the same string.

Upvotes: 4

Related Questions