I’m trying to get the version information for a module in some C++ code (basically this) and I’m getting compile time errors. Here’s the code:
WCHAR fileName[MAX_PATH];
HMODULE module = GetModuleHandle(L"some-module");
DWORD size = GetModuleFileName(module, fileName, MAX_PATH);
And the compiler is returning:
error C2664: 'GetModuleFileNameW' : cannot convert parameter 1 from 'WHANDLE' to
'HMODULE'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
What is going on here? GetModuleHandle returns HMODULE and that is the documented first parameter to GetModuleFileName.
Here is the compiler version for what its worth:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
Thanks!
There must be something funky going on with your includes or your libraries, because this compiles and runs fine here: