cdll.cpp

来自「《Delphi开发人员指南》配书原码」· C++ 代码 · 共 50 行

CPP
50
字号
#include <windows.h>

// objects
class TFoo
{
  virtual int function1(char *);
  virtual int function2(int);
};

//member functions
int TFoo::function1(char * str1)
{
  MessageBox(NULL, str1, "Hello from C++ DLL", MB_OK);
  return 0;
}

int TFoo::function2(int i)
{
  return i * i;
}

#ifdef __cplusplus
extern "C"  {
#endif

//prototypes                
TFoo * __declspec(dllexport) ClassFactory(void);
void __declspec(dllexport) ClassKill(TFoo *);

TFoo * __declspec(dllexport) CLASSFACTORY(void)
{
  TFoo * Foo;
  Foo = new TFoo;
  return Foo;
}

void __declspec(dllexport) CLASSKILL(TFoo * Foo)
{
  delete Foo;
}

int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
{
	return 1;
}

#ifdef __cplusplus
}
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?