other-licenses/nsis/Contrib/ExDLL/nsis.pas

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/other-licenses/nsis/Contrib/ExDLL/nsis.pas	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,126 @@
     1.4 +{
     1.5 +    Original Code from
     1.6 +    (C) 2001 - Peter Windridge
     1.7 +
     1.8 +    Code in seperate unit and some changes
     1.9 +    2003 by Bernhard Mayer
    1.10 +
    1.11 +    Fixed and formatted by Brett Dever
    1.12 +    http://editor.nfscheats.com/
    1.13 +
    1.14 +    simply include this unit in your plugin project and export
    1.15 +    functions as needed
    1.16 +}
    1.17 +
    1.18 +
    1.19 +unit nsis;
    1.20 +
    1.21 +interface
    1.22 +
    1.23 +uses
    1.24 +  windows;
    1.25 +
    1.26 +type
    1.27 +  VarConstants = (
    1.28 +    INST_0,       // $0
    1.29 +    INST_1,       // $1
    1.30 +    INST_2,       // $2
    1.31 +    INST_3,       // $3
    1.32 +    INST_4,       // $4
    1.33 +    INST_5,       // $5
    1.34 +    INST_6,       // $6
    1.35 +    INST_7,       // $7
    1.36 +    INST_8,       // $8
    1.37 +    INST_9,       // $9
    1.38 +    INST_R0,      // $R0
    1.39 +    INST_R1,      // $R1
    1.40 +    INST_R2,      // $R2
    1.41 +    INST_R3,      // $R3
    1.42 +    INST_R4,      // $R4
    1.43 +    INST_R5,      // $R5
    1.44 +    INST_R6,      // $R6
    1.45 +    INST_R7,      // $R7
    1.46 +    INST_R8,      // $R8
    1.47 +    INST_R9,      // $R9
    1.48 +    INST_CMDLINE, // $CMDLINE
    1.49 +    INST_INSTDIR, // $INSTDIR
    1.50 +    INST_OUTDIR,  // $OUTDIR
    1.51 +    INST_EXEDIR,  // $EXEDIR
    1.52 +    INST_LANG,    // $LANGUAGE
    1.53 +    __INST_LAST
    1.54 +    );
    1.55 +  TVariableList = INST_0..__INST_LAST;
    1.56 +  pstack_t = ^stack_t;
    1.57 +  stack_t = record
    1.58 +    next: pstack_t;
    1.59 +    text: PChar;
    1.60 +  end;
    1.61 +
    1.62 +var
    1.63 +  g_stringsize: integer;
    1.64 +  g_stacktop: ^pstack_t;
    1.65 +  g_variables: PChar;
    1.66 +  g_hwndParent: HWND;
    1.67 +
    1.68 +procedure Init(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer);
    1.69 +function PopString(): string;
    1.70 +procedure PushString(const str: string='');
    1.71 +function GetUserVariable(const varnum: TVariableList): string;
    1.72 +procedure SetUserVariable(const varnum: TVariableList; const value: string);
    1.73 +procedure NSISDialog(const text, caption: string; const buttons: integer);
    1.74 +
    1.75 +implementation
    1.76 +
    1.77 +procedure Init(const hwndParent: HWND; const string_size: integer; const variables: PChar; const stacktop: pointer);
    1.78 +begin
    1.79 +  g_stringsize := string_size;
    1.80 +  g_hwndParent := hwndParent;
    1.81 +  g_stacktop   := stacktop;
    1.82 +  g_variables  := variables;
    1.83 +end;
    1.84 +
    1.85 +function PopString(): string;
    1.86 +var
    1.87 +  th: pstack_t;
    1.88 +begin
    1.89 +  if integer(g_stacktop^) <> 0 then begin
    1.90 +    th := g_stacktop^;
    1.91 +    Result := PChar(@th.text);
    1.92 +    g_stacktop^ := th.next;
    1.93 +    GlobalFree(HGLOBAL(th));
    1.94 +  end;
    1.95 +end;
    1.96 +
    1.97 +procedure PushString(const str: string='');
    1.98 +var
    1.99 +  th: pstack_t;
   1.100 +begin
   1.101 +  if integer(g_stacktop) <> 0 then begin
   1.102 +    th := pstack_t(GlobalAlloc(GPTR, SizeOf(stack_t) + g_stringsize));
   1.103 +    lstrcpyn(@th.text, PChar(str), g_stringsize);
   1.104 +    th.next := g_stacktop^;
   1.105 +    g_stacktop^ := th;
   1.106 +  end;
   1.107 +end;
   1.108 +
   1.109 +function GetUserVariable(const varnum: TVariableList): string;
   1.110 +begin
   1.111 +  if (integer(varnum) >= 0) and (integer(varnum) < integer(__INST_LAST)) then
   1.112 +    Result := g_variables + integer(varnum) * g_stringsize
   1.113 +  else
   1.114 +    Result := '';
   1.115 +end;
   1.116 +
   1.117 +procedure SetUserVariable(const varnum: TVariableList; const value: string);
   1.118 +begin
   1.119 +  if (value <> '') and (integer(varnum) >= 0) and (integer(varnum) < integer(__INST_LAST)) then
   1.120 +    lstrcpy(g_variables + integer(varnum) * g_stringsize, PChar(value))
   1.121 +end;
   1.122 +
   1.123 +procedure NSISDialog(const text, caption: string; const buttons: integer);
   1.124 +begin
   1.125 +  MessageBox(g_hwndParent, PChar(text), PChar(caption), buttons);
   1.126 +end;
   1.127 +
   1.128 +begin
   1.129 +end.

mercurial