调用时出现0xC0000005: Access Violation.错误
我的代码如下:
CString m_Currpath="D:\\";
CString P02subpath="P02\\";
HINSTANCE hTrans;
hTrans=::LoadLibrary("testp.dll");
char* SInfo="C:\\Program Files\\";
CString temp=m_Currpath+P02subpath;
char* PInfo=NULL;
int i=temp.GetLength();
LPTSTR p=temp.GetBuffer(i);
PInfo=(char*)p;
temp.ReleaseBuffer();
int (*TRANSFORM)(char* PathInfo,char* SourceInfo);
if(hTrans)
{
TRANSFORM=(int(*)(char*,char*))::GetProcAddress(hTrans,"Mytest");
if(TRANSFORM)
//错误在这一句出现
TRANSFORM(PInfo,SInfo);
FreeLibrary(hTrans);
}Delphi中export的函数原型是:
Function Mytest(PathInfo:PChar;SInfo:PChar):Integer;export;我想应该是参数传递的问题吧?希望高手指教!谢谢!
我的代码如下:
CString m_Currpath="D:\\";
CString P02subpath="P02\\";
HINSTANCE hTrans;
hTrans=::LoadLibrary("testp.dll");
char* SInfo="C:\\Program Files\\";
CString temp=m_Currpath+P02subpath;
char* PInfo=NULL;
int i=temp.GetLength();
LPTSTR p=temp.GetBuffer(i);
PInfo=(char*)p;
temp.ReleaseBuffer();
int (*TRANSFORM)(char* PathInfo,char* SourceInfo);
if(hTrans)
{
TRANSFORM=(int(*)(char*,char*))::GetProcAddress(hTrans,"Mytest");
if(TRANSFORM)
//错误在这一句出现
TRANSFORM(PInfo,SInfo);
FreeLibrary(hTrans);
}Delphi中export的函数原型是:
Function Mytest(PathInfo:PChar;SInfo:PChar):Integer;export;我想应该是参数传递的问题吧?希望高手指教!谢谢!
解决方案 »
- 怎么动态调用API啊?
- PNG透明
- GetWindowText(abc)与GetDlgItmetext(IDC_EDIT1,abc)区别是什么
- 在release下面可以通过,但是debug不行,怎么回事啊?
- 请问各位前辈,如何把一个文件以二进制形式存入MS SQL Server数据库的某一个字段里?
- 重载操作符的错误!
- 在VC中如何检查一个文本框中的字符串是否为有效的的日期格式和时间格式?
- 请问那里有MSDN,VC部分的汉化版,哪里可以下载???
- c:\aaa\bbb\ccc.txt如何得到bbb\ccc.txt字符串
- 我是一个刚学完C语言的,我想成为程序员,不知道下一步怎么走,恳请高手指点
- CFileDialog的数据交换?(急)
- 求助:请问有没有做过VC和研华ADAM5510的串口通信啊?
改为Function Mytest(PathInfo:PChar;SInfo:PChar):Integer;stdcall;且将int (*TRANSFORM)(char* PathInfo,char* SourceInfo);
改为int (__stdcall *TRANSFORM)(char* PathInfo,char* SourceInfo);