Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

_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.

like image 811
BigSandwich Avatar asked Jun 29 '26 17:06

BigSandwich


2 Answers

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

like image 180
Jonathan Potter Avatar answered Jul 01 '26 06:07

Jonathan Potter


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 :(

like image 20
André Rodrigues Avatar answered Jul 01 '26 07:07

André Rodrigues



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!