exdll.c 1.3 KB

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