BCB 编写dll文件时出现:[Linker Error] Unresolved external '__stdcall System::AnsiString:

luohuayouy 2012-12-24 09:46:43
//---------------------------------------------------------------------------

#include <vcl.h>
#include <windows.h>
#pragma hdrstop
//---------------------------------------------------------------------------
// Important note about DLL memory management when your DLL uses the
// static version of the RunTime Library:
//
// If your DLL exports any functions that pass String objects (or structs/
// classes containing nested Strings) as parameter or function results,
// you will need to add the library MEMMGR.LIB to both the DLL project and
// any other projects that use the DLL. You will also need to use MEMMGR.LIB
// if any other projects which use the DLL will be performing new or delete
// operations on any non-TObject-derived classes which are exported from the
// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
// EXE's to use the BORLNDMM.DLL as their memory manager. In these cases,
// the file BORLNDMM.DLL should be deployed along with your DLL.
//
// To avoid using BORLNDMM.DLL, pass string information using "char *" or
// ShortString parameters.
//
// If your DLL uses the dynamic version of the RTL, you do not need to
// explicitly add MEMMGR.LIB as this will be done implicitly for you
//---------------------------------------------------------------------------

#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------------------------------------------
extern "C" __declspec(dllexport) AnsiString __stdcall PassWord(AnsiString cz0003_6,int cz0003_a)
{// 字符串加解密处理函数
// 参数说明:cz0003_6 --- 待处理字符串
// cz0003_a --- 处理方式(1.加密;-1.解密)
AnsiString cz0003_0,cz0003_1,cz0003_2,cz0003_3,cz0003_4,cz0003_8;
int cz0003_7,cz0003_5,cz0003_9;
AnsiString s1,s2;
int j=0;

cz0003_0="#$%$%$^%#%$DF^RDTYDCJV<P)*_)(*^&%^$%EDCFFVC GHGR^&FV#!@#$$^%&^(*)_ZXCVBNM<>>?<>";
cz0003_1="1203.645987987ZXNFDADUQRETYPU]IO[]I'\K;G'HJLG'./,NXJKBqwepwqort][po=-=009886723465";
cz0003_2="186548641618bfsiudfhsdZQWSQYHEWDIOUFPQPOWERUWEIOFHONFDLK;DSBVZVBSBDGFVSDLGIOSDHG";
//cz0003_3="版本 Ver 1.0";
cz0003_4=cz0003_0 + cz0003_1 + cz0003_2; // 加密字符串
cz0003_5=cz0003_4.Length(); // 加密字符串长度
cz0003_8=""; // 加密后的字符串
cz0003_9=0;
if(cz0003_a==-1)
{
for(cz0003_7=1;cz0003_7<=cz0003_6.Length();cz0003_7++)
{
//s1:=copy(cz0003_6,cz0003_7,1);
s1 = cz0003_6.SubString(cz0003_7,1);
//s2:=copy(cz0003_4,(cz0003_7-1) mod cz0003_5+1,1);
if(cz0003_7/2==0)
{
s2 = cz0003_4.SubString((cz0003_7-1) % cz0003_5+2,1);
}
else if(cz0003_7/3==0)
{
s2 = cz0003_4.SubString((cz0003_7-1) % cz0003_5+3,1);
}
else
{
s2 = cz0003_4.SubString((cz0003_7-1) % cz0003_5+1,1);
}
cz0003_9=int(s1[1])-int(s2[1]);
if(cz0003_9<0)
cz0003_8=cz0003_8+String(char(cz0003_9+256));
else
cz0003_8=cz0003_8+String(char(cz0003_9));
}

}
else
{
// 加密运算
for(cz0003_7=1;cz0003_7<=cz0003_6.Length();cz0003_7++)
{
s1=cz0003_6.SubString(cz0003_7,1);
if(cz0003_7/2==0)
{
s2=cz0003_4.SubString((cz0003_7-1) % cz0003_5+2,1);
}
else if(cz0003_7/3==0)
{
s2=cz0003_4.SubString((cz0003_7-1) % cz0003_5+3,1);
}
else
{
s2=cz0003_4.SubString((cz0003_7-1) % cz0003_5+1,1);
}
cz0003_9=int(s1[1])+int(s2[1]);
if(cz0003_9>255)
cz0003_8=cz0003_8+String(char(cz0003_9-256));
else
cz0003_8=cz0003_8+String(char(cz0003_9));
//j++;
}

}
cz0003_6=cz0003_8;
return cz0003_8;
}

以上代码是我在写DLL文件时的源码,按Ctrl+F9编译时出现一个错误:[Linker Error] Unresolved external '__stdcall System::AnsiString::ThrowIfOutOfRange(int) const' referenced from C:\DOCUMENTS AND SETTINGS\CBC\桌面\BCB DLL文件2\UNIT1.OBJ 。请问该问题怎么解决呢?
注:进入DLL wizard 我选的是C++
...全文
1062 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
key_leung 2013-01-18
  • 打赏
  • 举报
回复
我也遇到同样的问题,我在dll中加入一个UDP控件,但在配置UDP时,出现了[Linker Error] Unresolved external '__fastcall Nmudp::TNMUDP::SendBuffer(const char *, const int, int)' referenced from E:\BCBWORK\UDPDLLTEST\U_MYUDPDLL.OBJ
key_leung 2013-01-18
  • 打赏
  • 举报
回复
妖哥,简直是神啊!!
ccrun.com 2013-01-18
  • 打赏
  • 举报
回复
引用 5 楼 key_leung 的回复:
我也遇到同样的问题,我在dll中加入一个UDP控件,但在配置UDP时,出现了[Linker Error] Unresolved external '__fastcall Nmudp::TNMUDP::SendBuffer(const char *, const int, int)' referenced from E:\BCBWORK\UDPDLLTEST\U_MYUDP……
你这个需要将nmfast.lib添加到工程中。
luohuayouy 2012-12-24
  • 打赏
  • 举报
回复
引用 3 楼 ccrun 的回复:
你的代码看着头疼,就不细看了.我的建议是: DLL的导出函数的参数和返回值,尽量不要用String类.
谢谢你的建议。但是我返回值必须是处理好的string类型的值。我做的是一个加密数据的DLL,在主程序中把需要处理的数据传给DLL,DLL处理完成以后返回处理后所得的数据。所以返回值还是得用String
ccrun.com 2012-12-24
  • 打赏
  • 举报
回复
你的代码看着头疼,就不细看了.我的建议是: DLL的导出函数的参数和返回值,尽量不要用String类.
luohuayouy 2012-12-24
  • 打赏
  • 举报
回复
引用 1 楼 ccrun 的回复:
你的工程中用到了VCL,但是建立DLL工程的时候,没有选中Use VCL前的对钩吧?
选了的!
ccrun.com 2012-12-24
  • 打赏
  • 举报
回复
你的工程中用到了VCL,但是建立DLL工程的时候,没有选中Use VCL前的对钩吧?

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧