我在C++builder中写了个dll
在C++builder中的代码:
extern "C" void __declspec(dllexport) __stdcall Printbmp(char bmpfile[]);void Printbmp(char bmpfile[])
{
//函数体
}下面的代码是在VC中调用该dll:
UpdateData(TRUE);
HINSTANCE handle; //DLL 模块的句柄
FARPROC lpFarProc; //
void(__stdcall *print)(char*);
handle = LoadLibrary("qaz.dll"); //
int code =GetLastError(); //code=2
lpFarProc = GetProcAddress(handle,"Printbmp");
code =GetLastError(); //code=2
print = (void(__stdcall*)(char*))lpFarProc; //指针类型转换 char ch[500]="f:\\facebmp\\2100.bmp";
print(ch);//调用函数
code =GetLastError(); //code=0
FreeLibrary(handle);
code =GetLastError(); //code=0在vc中 当 FreeLibrary(handle); 后退出时出错 报告内存不能为读程序退出。
但是在print(ch)调用函数没有报错什么原因 ??怎样解决???各位帮忙!
在C++builder中的代码:
extern "C" void __declspec(dllexport) __stdcall Printbmp(char bmpfile[]);void Printbmp(char bmpfile[])
{
//函数体
}下面的代码是在VC中调用该dll:
UpdateData(TRUE);
HINSTANCE handle; //DLL 模块的句柄
FARPROC lpFarProc; //
void(__stdcall *print)(char*);
handle = LoadLibrary("qaz.dll"); //
int code =GetLastError(); //code=2
lpFarProc = GetProcAddress(handle,"Printbmp");
code =GetLastError(); //code=2
print = (void(__stdcall*)(char*))lpFarProc; //指针类型转换 char ch[500]="f:\\facebmp\\2100.bmp";
print(ch);//调用函数
code =GetLastError(); //code=0
FreeLibrary(handle);
code =GetLastError(); //code=0在vc中 当 FreeLibrary(handle); 后退出时出错 报告内存不能为读程序退出。
但是在print(ch)调用函数没有报错什么原因 ??怎样解决???各位帮忙!
解决方案 »
- public的用法
- 如何修改VC6编辑控件editbox中的Read-only属性
- vfw里capEditCopy和capGrabFrameNoStop函数疑问!高分赠送!
- 请问:
- [菜鸟求助]关于VC++*ActiveMovie控件
- winsocket api 阻塞方式编程
- 如何最简单的连入一个数据库并且执行一个存储过程啊?
- 请教: ATL/WTL->Dialog Based + Com Server, 如何整合Maindlg和Com Interface?
- 编译出的EXE怎么在其他机子上老提示差这差那的
- 在NT上使用regsvr32注册mycom.dll时提示“load libary 'mycom.dll' failed ".为什么?????
- 进程句柄和窗口句柄的关系
- ocx注册的问题
to zfive5(醉马不肖) 按照你的办法做了 报同样的错
Func lpFarProc;
lpFarProc = (Func *)GetProcAddress(handle,"Printbmp");
print = (void(__stdcall*)(char*))lpFarProc; //指针类型转换_stdcall也不对
注意:_stdcall与extern “c"的函数返回处理不同