Debian Codegraph @

Contrib/ExDLL/exdll.c

raw
1 #include <windows.h>
2 #include <nsis/pluginapi.h> // nsis plugin
3
4 HINSTANCE g_hInstance;
5 HWND g_hwndParent;
6
7 // To work with Unicode version of NSIS, please use TCHAR-type
8 // functions for accessing the variables and the stack.
9
10 void __declspec(dllexport) myFunction(HWND hwndParent, int string_size,
11 LPTSTR variables, stack_t **stacktop,
12 extra_parameters *extra, ...)
13 {
14 EXDLL_INIT();
15 g_hwndParent = hwndParent;
16
17
18 // note if you want parameters from the stack, pop them off in order.
19 // i.e. if you are called via exdll::myFunction file.dat read.txt
20 // calling popstring() the first time would give you file.dat,
21 // and the second time would give you read.txt.
22 // you should empty the stack of your parameters, and ONLY your
23 // parameters.
24
25 // do your stuff here
26 {
27 LPTSTR msgbuf = (LPTSTR) GlobalAlloc(GPTR, (3 + string_size + 1) * sizeof(*msgbuf));
28 if (msgbuf)
29 {
30 wsprintf(msgbuf, TEXT("$0=%s"), getuservariable(INST_0));
31 MessageBox(g_hwndParent, msgbuf, TEXT("Message from example plugin"), MB_OK);
32 GlobalFree(msgbuf);
33 }
34 }
35 }
36
37
38 BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
39 {
40 g_hInstance = hInst;
41 return TRUE;
42 }