// PluginInterface.h
#pragma once
class PluginInterface {
public:
virtual void performAction() = 0;
virtual ~PluginInterface() {}
};
// 函数指针类型定义,用于获取插件工厂函数
typedef PluginInterface* (*CreatePluginFunction)();
// 函数指针类型定义,用于释放插件
typedef void (*ReleasePluginFunction)(PluginInterface*);
// Plugin1.cpp
#include "PluginInterface.h"
#include <iostream>
class Plugin1 : public PluginInterface {
public:
virtual void performAction() override {
std::cout << "Plugin1 performing action." << std::endl;
}
};
// 导出插件工厂函数
extern "C" __declspec(dllexport) PluginInterface* CreatePlugin() {
return new Plugin1();
}
// 导出释放插件的函数
extern "C" __declspec(dllexport) void ReleasePlugin(PluginInterface* plugin) {