gpt4 book ai didi

c++ - 'HMODULE GetModuleHandleW(LPCWSTR )': cannot convert argument 1 from ' const char *' to ' LPCWSTR'

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:14:11 29 4
gpt4 key购买 nike

我还是 C++ 的新手,但我遇到了一个我无法解决的问题,这是我的错误信息:

'HMODULE GetModuleHandleW(LPCWSTR)': cannot convert argument 1 from 'const char *' to 'LPCWSTR'

这是抛出错误的行:

        ModuleHandle = (DWORD)GetModuleHandle(moduleName.c_str());

最佳答案

您正在将 char * 传递给需要 wchar_t * 的对象。您必须将字符串类型转换为 wchar_t *,例如使用 MultiByteToWideChar 函数 (https://msdn.microsoft.com/en-us/library/windows/desktop/dd319072%28v=vs.85%29.aspx),或者您可以通过调用 GetModuleHandleA() 而不是 GetModuleHandleW() 来使用非宽版本的 GetModuleHandle。

关于c++ - 'HMODULE GetModuleHandleW(LPCWSTR )': cannot convert argument 1 from ' const char *' to ' LPCWSTR',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36111384/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com