我在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);
         }
}
大家帮我看看,多个参数该怎么传进去,谢谢!

解决方案 »

  1.   

    多个参数?如果你要传多个参数的话,那么你的DLL中那个函数需要更改
    CString __cdecl GetStringCode(CString str1, CString str2,CString str3,……);
      

  2.   

    默认的就是__cdecl,不用再加了
    还有,你为什么要加FAR?
      

  3.   

    加不加Far这里好像无所谓吧!
      

  4.   

    //  in mydll.cpp 
    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);
             }
    }
      

  5.   

    把DLL中间的函数的参数改了就好了
    不过不知道还有没有更好的办法