为什么GetProcAddress无法与OutputDebugString函数一起使用

时间:2018-11-20 13:28:24

标签: c++ windows winapi getprocaddress

我一直在尝试将GetProcAddress与kernel32.dll中的多个功能一起使用。除“ OutputDebugString”功能外,它运行良好。

我的代码:

typedef void(WINAPI *LPGETNUMBER)(LPCTSTR);

int main() {
    const LPGETNUMBER pAddr = (LPGETNUMBER)GetProcAddress(GetModuleHandle((LPCSTR)("kernel32.dll")), "OutputDebugString");
    if (NULL == pAddr) {
        int32_t nLastErrorCode = GetLastError();
    }
}

2 个答案:

答案 0 :(得分:4)

没有这样的功能。导出的名称分别为OutputDebugStringAOutputDebugStringW

https://msdn.microsoft.com/en-us/library/windows/desktop/aa363362

答案 1 :(得分:3)

OutputDebugString是一个宏,它扩展为OutputDebugStringAOutputDebugStringW,具体取决于您是使用ANSI还是Unicode构建的。因此,您需要选择其中一种(最好,但不一定,取决于您的构建模式)。

相关问题