vc调用bcb的dll(二)

(一是调用函数,二是调用类)

bcb中:

class xout
{
  virtual void  __fastcall fun(){ShowMessage("mmmmmmmmmmmmmm");};

};

xout out;

extern "C" __declspec(dllexport) xout * __stdcall GetOutClass()
{
    return &out;
}

 

c++中:

.h中

 class xout
 {
 public:
  virtual void  __fastcall fun();
 
 };
 typedef xout* (*Fn)();

 

.cpp中:

void CdllllllllDlg::OnBnClickedOk()
{
    
   //xout (*GetOutClass)(xout);
   HINSTANCE hInst = LoadLibrary(_T("C:\\dlllllllllllllllllllllllllllll\\dllllllll\\dllllllll\\Debug\\ExpClssDll.dll"));
   if (hInst == NULL)
   {
    int xx = GetLastError();
    FreeLibrary(hInst);
    system("pause");
    return;
   }
  Fn GetOutClass = (Fn)GetProcAddress(hInst, "GetOutClass");

  xout* out = GetOutClass();
  out->fun();

  
   FreeLibrary(hInst);
  


 OnOK();
}

 

 

你可能感兴趣的:(vc调用bcb的dll(二))