读书人

BCB编写DLL文件遇到的有关问题

发布时间: 2012-12-29 10:28:09 作者: rapoo

BCB编写DLL文件遇到的问题
代码如下:


//---------------------------------------

#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;
}


按F9 Run 的时候提示错误:Cannot debug project unless a host application is defined. Use the Run|Parameters... dialog box.
本人初学DLL文件的编写求各位大侠指教。
[解决办法]
DLL调试时需要一个调用的应用程序。选择Run
[解决办法]
Parameters,在Browse里面选择导入你的调试程序EXE图标即可
[解决办法]
引用:
DLL调试时需要一个调用的应用程序。选择Run
[解决办法]
Parameters,在Browse里面选择导入你的调试程序EXE图标即可

正确

要调用自己编写的dll,直接在你调试程序中加入dll。h文件和lib文件,dll的函数就可以直接调用了

读书人网 >C++ Builder

热点推荐