VC DLL stdcall的名字分裂问题

在delphi6中调用VS2005中写的DLL。由于delphi中一般采用stdcall调用DLL,于是在VC中如下声明DLL:

extern "C" __declspec(dllexport) void  PASCAL test_unicode(LPCTSTR unistring);

编译出来后,用dependency walker查看该DLL,发现导出函数是“_test_unicode@4

而查看delphi生成的exe,导入函数应该是"test_unicode"。

 

在VS2005工程中加入一个def文件,例如"sample.def":

LIBRARY "idisWrapper"
EXPORTS
test_unicode

 

确认在Linker设置中,"Module definition file"包含"sample.def"。

 

然后,VS2005中写的DLL就能被delphi正常调用了。

posted @ 2011-10-16 08:41  keeppoised  阅读(471)  评论(0编辑  收藏  举报