home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 March / CMCD0304.ISO / Software / Freeware / Programare / nullsoft / nsis20.exe / Contrib / ExDLL / nsis.pas < prev   
Pascal/Delphi Source File  |  2003-11-16  |  3KB  |  127 lines

  1. {
  2.     Original Code from
  3.     (C) 2001 - Peter Windridge
  4.  
  5.     Code in seperate unit and some changes
  6.     2003 by Bernhard Mayer
  7.  
  8.     Fixed and formatted by Brett Dever
  9.     http://editor.nfscheats.com/
  10.  
  11.     simply include this unit in your plugin project and export
  12.     functions as needed
  13. }
  14.  
  15.  
  16. unit nsis;
  17.  
  18. interface
  19.  
  20. uses
  21.   windows;
  22.  
  23. type
  24.   VarConstants = (
  25.     INST_0,       // $0
  26.     INST_1,       // $1
  27.     INST_2,       // $2
  28.     INST_3,       // $3
  29.     INST_4,       // $4
  30.     INST_5,       // $5
  31.     INST_6,       // $6
  32.     INST_7,       // $7
  33.     INST_8,       // $8
  34.     INST_9,       // $9
  35.     INST_R0,      // $R0
  36.     INST_R1,      // $R1
  37.     INST_R2,      // $R2
  38.     INST_R3,      // $R3
  39.     INST_R4,      // $R4
  40.     INST_R5,      // $R5
  41.     INST_R6,      // $R6
  42.     INST_R7,      // $R7
  43.     INST_R8,      // $R8
  44.     INST_R9,      // $R9
  45.     INST_CMDLINE, // $CMDLINE
  46.     INST_INSTDIR, // $INSTDIR
  47.     INST_OUTDIR,  // $OUTDIR
  48.     INST_EXEDIR,  // $EXEDIR
  49.     INST_LANG,    // $LANGUAGE
  50.     __INST_LAST
  51.     );
  52.   TVariableList = INST_0..__INST_LAST;
  53.   pstack_t = ^stack_t;
  54.   stack_t = record
  55.     next: pstack_t;
  56.     text: PChar;
  57.   end;
  58.  
  59. var
  60.   g_stringsize: integer;
  61.   g_stacktop: ^pstack_t;
  62.   g_variables: PChar;
  63.   g_hwndParent: HWND;
  64.  
  65. procedure Init(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer);
  66. function PopString(): string;
  67. procedure PushString(const str: string='');
  68. function GetUserVariable(const varnum: TVariableList): string;
  69. procedure SetUserVariable(const varnum: TVariableList; const value: string);
  70. procedure NSISDialog(const text, caption: string; const buttons: integer);
  71.  
  72. implementation
  73.  
  74. procedure Init(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer);
  75. begin
  76.   g_stringsize := string_size;
  77.   g_hwndParent := hwndParent;
  78.   g_stacktop   := stacktop;
  79.   g_variables  := variables;
  80. end;
  81.  
  82. function PopString(): string;
  83. var
  84.   th: pstack_t;
  85. begin
  86.   if integer(g_stacktop^) <> 0 then begin
  87.     th := g_stacktop^;
  88.     Result := PChar(@th.text);
  89.     g_stacktop^ := th.next;
  90.     GlobalFree(HGLOBAL(th));
  91.   end;
  92. end;
  93.  
  94. procedure PushString(const str: string='');
  95. var
  96.   th: pstack_t;
  97. begin
  98.   if integer(g_stacktop) <> 0 then begin
  99.     th := pstack_t(GlobalAlloc(GPTR, SizeOf(stack_t) + g_stringsize));
  100.     lstrcpyn(@th.text, PChar(str), g_stringsize);
  101.     th.next := g_stacktop^;
  102.     g_stacktop^ := th;
  103.   end;
  104. end;
  105.  
  106. function GetUserVariable(const varnum: TVariableList): string;
  107. begin
  108.   if (integer(varnum) >= 0) and (integer(varnum) < integer(__INST_LAST)) then
  109.     Result := g_variables + integer(varnum) * g_stringsize
  110.   else
  111.     Result := '';
  112. end;
  113.  
  114. procedure SetUserVariable(const varnum: TVariableList; const value: string);
  115. begin
  116.   if (value <> '') and (integer(varnum) >= 0) and (integer(varnum) < integer(__INST_LAST)) then
  117.     lstrcpy(g_variables + integer(varnum) * g_stringsize, PChar(value))
  118. end;
  119.  
  120. procedure NSISDialog(const text, caption: string; const buttons: integer);
  121. begin
  122.   MessageBox(g_hwndParent, PChar(text), PChar(caption), buttons);
  123. end;
  124.  
  125. begin
  126. end.
  127.