没有找到函数使用GetProcAddress() c++ VBexpress
Not finding function using GetProcAddress() C++ VBexpress 13
好吧,所以我在这里危险地接近于转发,但我的情况与许多其他关于这个函数的海报有点不同。我与一个DLL的接口是写在一天的方式,我所拥有的是文件。我没有。lib文件,所以我使用LoadLibrary和GetProcessAddress函数。我按照MSDN网站上的教程获得了基本结构。DLL位于项目文件夹中。它编译。在运行时,我得到了"hinstLib"的数值,所以我假设找到了DLL。我得到一个空值"ProcAdd"变量。其他海报通过在DLL函数中放入外部C来解决问题,但我真的没有那个选项。更不用说,据我所知,这个DLL是用纯c编写的。我确实有一个接口文档,我很确定我的函数名是正确的(为了这些目的,用一个通用的例子代替)。老实说,我没有运行任何超过ProcAdd赋值,因为它出来NULL。任何关于为什么这给我一个0值的函数分配的想法将是非常感激的。注:不幸的是,由于各种原因,我不能上传DLL。
#include <iostream>
#include "stdafx.h"
#include "Windows.h"
#include <stdio.h>
typedef int(__cdecl *MYPROC)(LPWSTR);
using namespace std;
int main()
{
HINSTANCE hinstLib;
MYPROC ProcAdd;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
hinstLib = LoadLibrary(TEXT("dllName.dll"));
if (hinstLib != NULL)
{
ProcAdd = (MYPROC) GetProcAddress(hinstLib, "funcName");
// If the function address is valid, call the function.
if (NULL != ProcAdd)
{
fRunTimeLinkSuccess = TRUE;
//(ProcAdd) (L"Message sent to the DLL functionn");
}
// Free the DLL module.
fFreeResult = FreeLibrary(hinstLib);
}
// If unable to call the DLL function, use an alternative.
if (! fRunTimeLinkSuccess)
printf("Message printed from executablen");
return 0;
}
编译器通常会混淆函数名,那么一个名为funcName
的函数可能会以funcName@16
的名称出现在DLL中,例如…它取决于调用约定,对于正确调用函数非常重要。对于__cdecl
调用约定,您可能需要_funcName
:-)。
相关文章:
- 使用 NTAllocateVirtualMemory 和 GetProcAddress 的内存分配问题不起作用
- GetProcAddress vs __declspec( dllimport )
- 'dll_file'可以是"0":这不符合函数的规范'GetProcAddress'
- 如何将 GetProcAddress 与 JNA 一起使用?
- GetProcAddress 无法正常工作
- 从 GetProcAddress 获取的函数指针在使用 stdlib 时会使程序崩溃
- 如何使用 WinDbg 查找"GetProcAddress"函数的进程名称
- GetProcAddress fails
- 在 GetProcAddress 的 lpProcName 中是否有 DLL 函数修饰的参考
- 为什么传统的 GetProcAddress 到 std::function 并不简单
- 为什么 GetProcAddress 在实现时会引发异常
- GetProcAddress 在 c++ 中返回错误代码 127
- 如何在没有类型转换的情况下使用getProcAddress()
- C++ GetProcAddress 64 位返回 32 位地址
- 指向多个参数的函数指针 C++11 std::function:模板化 GetProcAddress
- 铸造getProcaddress在C 中返回指针
- getProcAddress()为我的Hello World功能返回null
- getprocaddress的类似函数使用结构
- IIS:在 ISAPI 筛选器上调用 GetProcAddress 失败
- getProcAddress - NULL is returned