我在vc6下写了一个Regular DLL using shared MFC DLL,导出一个函数,但老是不对,大家帮我看看!
// in mydll.cpp
CString __cdecl GetStringCode(CString str1, CString str2);CString __cdecl GetStringCode(CString str1, CString str2)
{
//code.....
CString strRet = ........
return strRet;
}// in mydll.def file
EXPORTS
; Explicit exports can go here
GetStringCode @1// ----- Use it in another Dialog Based app
typedef CString (FAR __cdecl *PGetStringCode)(CString str1,CString str2);
HMODULE hLibrary;
hLibrary = LoadLibrary("win98type.dll");
if(hLibrary != NULL)
{
PGetStringCode pGetSC = (PGetStringCode)GetProcAddress(hLibrary, "GetStringCode");
if(pGetSC != NULL)
{
CString str = pGetSC("1","2");
//Here, I debugged into the mydll, int function GetStringCode(str1, str2), the str1="2" , str2="", 参数传递得不对,
FreeLibrary(hLibrary);
}
}
大家帮我看看,多个参数该怎么传进去,谢谢!
解决方案 »
- 如何设置单选框的背景透明?
- 编译成exe的程序能直接改成编译成dll的程序吗?
- 3D游戏制作
- http协议问题
- 初学VC,请问VC中如何声明WINDWOSAPI?一般在什么位置?
- 关于反编译网络应用程序的问题。请各位大侠指点。
- ##---BHO遇到的问题---####
- 连接问题求救!请高手帮忙!
- 我用CRichEditView,然后程序往里面写东西,请问右边的滚动条时如何能自动拉到最下方呢? (问题解决,立即给分!)
- 如何快速创建一个大的空文件,大约2-3G
- 调试vc.net编写的dll时,进入用来调试的.exe的时候就报读文件错. 是不是调试时的Apllication的目录不是.exe所在目录啊?
- 100分请问:监控软件的计时器问题
CString __cdecl GetStringCode(CString str1, CString str2,CString str3,……);
还有,你为什么要加FAR?
extern "C"{
CString __declspec(dllexport) WINAPI GetStringCode(CString str1, CString str2);}// in mydll.def file
EXPORTS
; Explicit exports can go here
GetStringCode// ----- Use it in another Dialog Based app
typedef CString (PASCAL * PGetStringCode)(CString str1,CString str2);
HMODULE hLibrary;
hLibrary = LoadLibrary("win98type.dll");
if(hLibrary != NULL)
{
PGetStringCode pGetSC = (PGetStringCode)GetProcAddress (hLibrary, "GetStringCode");
if(pGetSC != NULL)
{
CString str = pGetSC("1","2");
//Here, I debugged into the mydll, int function GetStringCode(str1, str2), the str1="2" , str2="", 参数传递得不对,
FreeLibrary(hLibrary);
}
}
不过不知道还有没有更好的办法