1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#include <windows.h>
#include <list>
#include <pluginapi.h> //this is necessary, PLUGININFO structure, other related to load/unload plugin code
#include <plugin_helper.h> //just helper, not necessary
#include <core_services.h>
PLUGINLINK *pluginLink;
HINSTANCE hInst;
BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) //default dll entry point
{
hInst = hinstDLL;
return TRUE;
}
PLUGININFO pluginInfo =
{
sizeof(PLUGININFO), //size of structure
(char*)"example plugin", //short name
0, //description
0, //author
0, //author email
PLUGIN_MAKE_VERSION(0,0,0,1), //version
F_GLOBAL_ACCESS //flags
};
extern "C" __declspec(dllexport) PLUGININFO* SetPluginInfo()
{
return &pluginInfo;
}
extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) //basic initialisation, registering new functions, do other basic initialisation, you can create infinite loop, or other code which use many time here, only fast basic initialisation
{
pluginLink = link; //necessary
MessageBoxA(0, "Simple plugin initialisation done", "INFO", MB_OK);
TestService(); //only core servisec avaible in load
return 0; //all ok, retrun 0
}
extern "C" int __declspec(dllexport) OnModulesLoaded() //load main code from here, all services from other plugins must be avaible here
{
MessageBoxA(0, "Advanced plugin features needed services from other plugins are working from now", "INFO", MB_OK);
CallService("Core/Test", 0, 0); //usage example of service registered in core
TestService(); //same as above, look in core_services.h
Shutdown(); //same as CallService("Core/Shutdown", 0, 0); ,this will shutdown program
return 0;
}
extern "C" int __declspec(dllexport) Unload()
{
//close open files, databases, save settings in memory to db, e.t.c. here.
return 0;
}
|