PB调用自制的DLL,可以正常运行,但是最后PB崩溃

zch889 2015-07-26 06:50:02
这个是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 <vcl.h>
#include <windows.h>
#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);
}
...全文
3965 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
tomok 2016-05-25
  • 打赏
  • 举报
回复
dll 程序的 问题
zhangyangziwo 2016-05-24
  • 打赏
  • 举报
回复
预分配内存问题
wptao 2016-05-04
  • 打赏
  • 举报
回复
pb不稳定
提前十分钟 2016-05-03
  • 打赏
  • 举报
回复
内存回收问题
pb8 2015-07-26
  • 打赏
  • 举报
回复
pb调用的代码在哪?变量有没有预分配空间?

740

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 脚本语言
社区管理员
  • 脚本语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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