§§一个Delphi写的DLL,我在VC中调用,出错§为什么?§§
Delphi中定义是:
procedure EncryptString(str : shortstring; sel : integer); Stdcall;
我在vc中这么用:
HINSTANCE dllInstance;
dllInstance=::LoadLibrary(_T("Encrypt.dll"));
if(dllInstance==NULL)
{
AfxMessageBox("Can't open dll file");
}
typedef void(__stdcall *MYFUN)(char *,int);
MYFUN StrChang;
StrChang=(MYFUN)GetProcAddress(dllInstance,"EncryptString");
if(StrChang== NULL)
{
AfxMessageBox("Can't find function");
}
else
{
// 开始转换,StrChang
char *szstr= "中华人民共和国";
StrChang( szstr, 3 );
}执行到StrChang时出错:
Unhandled exception in Encrypt.exe: 0xc000005:access Violation!
Delphi中定义是:
procedure EncryptString(str : shortstring; sel : integer); Stdcall;
我在vc中这么用:
HINSTANCE dllInstance;
dllInstance=::LoadLibrary(_T("Encrypt.dll"));
if(dllInstance==NULL)
{
AfxMessageBox("Can't open dll file");
}
typedef void(__stdcall *MYFUN)(char *,int);
MYFUN StrChang;
StrChang=(MYFUN)GetProcAddress(dllInstance,"EncryptString");
if(StrChang== NULL)
{
AfxMessageBox("Can't find function");
}
else
{
// 开始转换,StrChang
char *szstr= "中华人民共和国";
StrChang( szstr, 3 );
}执行到StrChang时出错:
Unhandled exception in Encrypt.exe: 0xc000005:access Violation!
解决方案 »
- 为什么我用directshow作音频视频同时采集图像画面有问题?而只采集视频没问题?_______________waiting on line
- 在VC中,如何显示一个Unicode字符?[菜鸟求救]
- 新手的问题
- 新手问题:关于CBitmap,请问如何在内存中开一个bitmap,又如何向该bitmap中写入一些图形,并且显示在屏幕上?
- 高手来吧:IPHLPAPI的问题
- 简单问题:如何给一个控件添加图片背景?
- 请问:哪里有BSTR的详细说明
- 这是什么错误
- 高手看看:http://www.csdn.net/expert/topic/542/542625.xml
- 透明PNG图片,鼠标单击检测,忽略透明区域的方法
- 注册表函数问题
- 请问一个问题
怎么改,谢谢
改为:
procedure EncryptString(str : PChar; sel : integer); Stdcall;
但是我没有delphi的源程序呀,改不了他的定义!
ShortString 255 characters 2 to 256 bytes backward compatibility如果是这样(不能改DLL),此DLL只能用于Delphi程序。
不过可以再用Delphi封装一次此函数,改用PChar类型。