c++builder如何调用vc++MFC DLL 中带有参数的函数(急!!! 在线等)
syy64 2004-05-14 10:47:15 程序如下:
h文件:
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Dialogs.hpp>
#include <Menus.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TOpenDialog *ttt;
TMainMenu *MainMenu1;
TEdit *Edit1;
TLabel *Label1;
TPopupMenu *PopupMenu1;
TButton *Button1;
void __fastcall Edit1Change(TObject *Sender);
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern "C" __declspec(dllimport) double __stdcall Ex21cSquareRoot(double d);
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
*.cpp 文件:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int jj;
double d, d1;
// extern "C" __declspec(dllimport) double __stdcall Ex21cSquareRoot(double d);
HINSTANCE h;
FARPROC pp;
// int _stdcall (*t)(void);
// double _stdcall (*t(double))(void);
h=LoadLibrary("ex21c.dll"); //导入库
pp = GetProcAddress(h,"Ex21cSquareRoot"); //指出库中函数的位置
d = 9.0;
// d1 = Ex21cSquareRoot(d);
d1 = pp(d); 这一行编译出错:[C++ Error] Unit1.cpp(42): E2226 Extra parameter in call
// ShowMessage(IntToStr(t()));
FreeLibrary(h);
jj = 2;
}
//---------------------------------------------------------------------------
高手帮帮忙!!!