UninstallCodeDll.iss 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. ; -- UninstallCodeDll.iss --
  2. ;
  3. ; This script shows how to call DLL functions at uninstall time from a [Code] section.
  4. [Setup]
  5. AppName=My Program
  6. AppVerName=My Program version 1.5
  7. DefaultDirName={pf}\My Program
  8. DisableProgramGroupPage=yes
  9. UninstallDisplayIcon={app}\MyProg.exe
  10. OutputDir=userdocs:Inno Setup Examples Output
  11. [Files]
  12. ; Install our DLL to {app} so we can access it at uninstall time
  13. Source: "MyDll.dll"; DestDir: "{app}"
  14. [Code]
  15. const
  16. MB_ICONINFORMATION = $40;
  17. // Importing our custom DLL function
  18. procedure MyDllFunc(hWnd: Integer; lpText, lpCaption: String; uType: Cardinal);
  19. external 'MyDllFunc@{app}\MyDll.dll stdcall uninstallonly';
  20. procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
  21. begin
  22. // Call our function just before the actual uninstall process begins
  23. if CurUninstallStep = usUninstall then
  24. begin
  25. MyDllFunc(0, 'Hello from custom DLL function', 'MyDllFunc', MB_OK or MB_ICONINFORMATION);
  26. // Now that we're finished with it, unload MyDll.dll from memory.
  27. // We have to do this so that the uninstaller will be able to remove the DLL and the {app} directory.
  28. UnloadDLL(ExpandConstant('{app}\MyDll.dll'));
  29. end;
  30. end;