zch889
zch889
采纳率0%
2015-07-25 22:39 阅读 2.0k

pb 调用自制的dll,pb程序崩溃

这个是BCB写的一个DLL文件,调用他可以正常执行,执行完了,PB崩溃。我看了写的也是标准的dll。高手给帮忙看看。
pb 的声明 function int Encrypt(String Str_dwmc,String Str_mac,String Str_Proname,String Str_outdat,String Str_count,ref String Str_ret)
//------------------------------------------------------------------------------------------------------------------------------
#include
#include
#pragma hdrstop
String str_code = "1234567890";

#pragma argsused
extern "C" __declspec(dllexport) __stdcall int Encrypt(char *Str_dwmc,char *Str_mac,char *Str_Proname,char *Str_outdat,char *Str_count,char *Str_ret);

int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------------------------------------------
char * __stdcall (*DesEn)(char *,char *);
char * __stdcall (*DesDe)(char *,char *);

//加密函数------------------------------------------------------------------------------------------------------
__declspec(dllexport) __stdcall int Encrypt(char *Str_dwmc,char *Str_mac,char *Str_Proname,char *Str_outdat,char *Str_count,char *Str_ret)
{
HINSTANCE myDLL;
String Str_dwmc1 ;
String Str_mac1;
String Str_Proname1 ;
String Str_outdat1;
String Str_count1;
String str_ret1;
Str_dwmc1 = Str_dwmc;
Str_mac1 = Str_mac;
Str_Proname1 = Str_Proname;
Str_outdat1 = Str_outdat;
Str_count1 = Str_count;
String str_code2;
String str_out;
String str_out2;
int int_ret;
str_ret1 = "";
str_out="OUT";

str_ret1 = Str_dwmc+ "00[@]";

myDLL = NULL;
myDLL = LoadLibrary("BYSDC.dll");
if(myDLL!=NULL)
{
FARPROC P ;
P = GetProcAddress(myDLL,"DesEn");
if(P !=NULL)
{
try{
DesEn=(char * stdcall(cdecl *)(char *,char *))P;
str_out = DesEn(str_ret1.c_str(),str_code.c_str());
str_out = str_out.SubString(1,str_out.Length() - 5);
} catch(...){
str_out="OUT";
}
}
else
{
str_out="OUT";
}
}
else
{
str_out="OUT";
}
FreeLibrary(myDLL);
myDLL = NULL;
if(str_out!="OUT")
{
int_ret = 1;
strcat(Str_ret,str_out.c_str());
}
else
{
int_ret = 0;
}
return(int_ret);
}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

相关推荐