I want to leave my project on multibyte instead of switching it to Unicode. I'm getting some errors trying to make my types work together as follows (VS2019 set to multibye):
The original error is: argument of type "char *" is incompatible with type "const wchar_t *" for the following line:
if (!wcscmp(ModuleEntry.szModule, ModuleName)
ModuleEntry is of type MODULEENTRY32
If I change the type of ModuleEntry to MODULEENTRY32W
I get the following error:
Argument type "MODULEENTRY32W" is incompatible with type "LPMODULEENTRY32".
Here's the full function for reference:
DWORD GetModuleBaseAddress(const wchar_t* ModuleName, DWORD ProcessId) {
MODULEENTRY32 ModuleEntry = { 0 };
HANDLE SnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ProcessId);
if (!SnapShot)
return NULL;
ModuleEntry.dwSize = sizeof(ModuleEntry);
if (!Module32First(SnapShot, &ModuleEntry))
return NULL;
do {
if (!wcscmp(ModuleEntry.szModule, ModuleName)) {
CloseHandle(SnapShot);
return (DWORD)ModuleEntry.modBaseAddr;
}
} while (Module32Next(SnapShot, &ModuleEntry));
CloseHandle(SnapShot);
return NULL;
}
Thank you.
See Question&Answers more detail:os