【1】新建一个qt库项目
【2】在项目目录图标上右击,选择Add New...
【3】选择模版:Qt->Qt设计师界面类,选择Widget,填写界面类的名称、.h .cpp .ui名称
【4】创建C调用接口(默认是创建C++调用接口)
#ifndef TESTINTERFACE_H
#define TESTINTERFACE_H
#define DllImport __declspec( dllimport )
#define DllExport __declspec( dllexport )extern "C" DllImport bool __stdcall ShowWindows(bool isShow, int param);#endif // #ifndef TESTINTERFACE_H
【5】创建C调用接口的实现代码
#include "TestInterface.h"
#include "mainform.h"
MainForm g_mainForm;
bool __stdcall Show(bool isShow, int param)
{qDebug()<<isShow<<param;g_mainForm.showFullScreen();return true;
}
【6】使用另一个程序调用DLL
1、#include头文件