在项目中加载DLL后获取地址的问题 [英] Problem in Getting Address after loading DLL in Project

查看:69
本文介绍了在项目中加载DLL后获取地址的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在VS2003中创建了一个解决方案,其中包含两个项目,一个是ABD.exe,另一个是ABC.DLL.
DLL类声明为

Hi,

I have created one solution in VS2003 which contain two project one is ABD.exe and another one is ABC.DLL.
DLL class is declared as

class __declspec(dllexport) Class Name



在DLL类中,我的入口是



In DLL class, my entry point is

unsigned int Convert(string, string)



在我的另一个项目中,我试图通过使用以下代码来调用ABC.dll



From my another project, I am trying to call ABC.dll by using below code

typedef unsigned int (*EntryPointfuncPtr)(string argv_1, string argv_2);

string Lib_File = "ABC.dll";
HINSTANCE LoadMe = LoadLibrary(Lib_File.c_str());

if(LoadME != NULL)
{
  EntryPointfuncPtr LibMain = (EntryPointfuncPtr)GetProcAddress(LoadMe, "Convert");
}

if (LibMain != NULL)
{
  unsigned int nRetVal = LibMain(strIn, strOut);
}
else
{
  cout << "ERROR OCCURED" << endl;
}



我收到一条错误消息:发生了错误".这意味着LibMain为Null.



I am getting an Error Message : "ERROR OCCURED". This means that LibMain is Null.

Can anyone HELP me where I went wrong.?

推荐答案

您的函数名称可能由C++编译器破坏了,您必须使用
Probably the name of your function is mangled by the C++ compiler, you have to use the
extern "C" {
//..
}


构造,请参见此处 [此处 [


construct, see here[^] and here[^]to wrap your function.



帕里尼,

我所有的函数都在一个名为"ABC"的类中声明,其减速度为:

Hi Pallini,

All of my function are declared in one class named as "ABC" and it''s decelration is :

class __declspec(dllexport) ABC
{
  public:
   Convert (string, string);
};



您回复后,我确实是这样的:



After you reply, i did like this:

extern "C"
{
  class __declspec(dllexport) ABC
  {
    public:
     Convert (string, string);
  };
}



并重建了我的dll,但LibMain仍然为NULL

还有其他建议或帮助吗?



And rebuilt my dll but still LibMain is NULL

Any more suggestion or help?


这篇关于在项目中加载DLL后获取地址的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆