File: GrtBindingWizard.dpr

package info (click to toggle)
mysql-query-browser 1.1.6-1sarge0
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 36,320 kB
  • ctags: 24,680
  • sloc: pascal: 203,479; xml: 136,561; ansic: 47,502; cpp: 28,926; sh: 12,433; objc: 4,823; java: 1,849; php: 1,485; python: 1,225; sql: 1,128; makefile: 872
file content (146 lines) | stat: -rw-r--r-- 3,640 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
program GrtBindingWizard;

uses
  Forms,
  Main in 'Main.pas' {MainForm},
  AuxFuncs in '..\AuxFuncs',
  TntSysUtils in '..\TNT\TntSysUtils.pas',
  SysUtils,
  Windows;

{$R *.res}

var
  JavaDevKitHome,
    JavaDevKitRuntimeLibPath,
    JavaHome,
    RuntimeLibPath,
    Path: WideString;
  JavaDevKitHomeFound,
    JavaDevKitRuntimeLibPathFound,
    JavaHomeFound,
    RuntimeLibFound,
    PathModified,
    JavaIsOk,
    QuietOnSuccess: Boolean;


begin
  Application.Initialize;
  Application.Title := 'MySQL GRT Binding Wizard';

  QuietOnSuccess := False;
  JavaIsOk := False;

  if (ParamCount>=1) then
    if (WideSameText(Paramstr(1), 'QuietOnSuccess')) then
      QuietOnSuccess := True;

  // Check SDK
  JavaDevKitHome := WideExcludeTrailingBackslash(
    ReadFromReg(HKEY_LOCAL_MACHINE,
    'SOFTWARE\JavaSoft\Java Development Kit\1.4', 'JavaHome',
    0, '', False));

  if (JavaDevKitHome<>'') then
  begin
    JavaDevKitRuntimeLibPath :=
      WideIncludeTrailingBackslash(JavaDevKitHome) +
      'jre\bin\client\';

    if (WideFileExists(JavaDevKitRuntimeLibPath + 'jvm.dll')) then
      JavaDevKitRuntimeLibPath :=
        WideExcludeTrailingBackslash(JavaDevKitRuntimeLibPath)
    else
      JavaDevKitRuntimeLibPath := '';
  end;

  // Check JRE
  JavaHome := WideExcludeTrailingBackslash(
    ReadFromReg(HKEY_LOCAL_MACHINE,
    'SOFTWARE\JavaSoft\Java Runtime Environment\1.4', 'JavaHome',
    0, '', False));

  RuntimeLibPath := WideExtractFilePath(
    ReadFromReg(HKEY_LOCAL_MACHINE,
      'SOFTWARE\JavaSoft\Java Runtime Environment\1.4', 'RuntimeLib',
      0, '', False));


  // If something is found, check if the paths are in the system path
  if ((JavaDevKitHome <> '') or (JavaHome <> '')) and
    ((JavaDevKitRuntimeLibPath <> '') or (RuntimeLibPath <> '')) then
  begin
    // Get system path
    Path := GetGlobalEnvironment('path', False);

    PathModified := False;

    JavaDevKitHomeFound :=
      (Pos(Tnt_WideUpperCase(JavaDevKitHome + '\bin'),
      Tnt_WideUpperCase(Path)) > 0);

    JavaDevKitRuntimeLibPathFound :=
      (Pos(Tnt_WideUpperCase(JavaDevKitRuntimeLibPath),
      Tnt_WideUpperCase(Path)) > 0);

    JavaHomeFound :=
      (Pos(Tnt_WideUpperCase(JavaHome + '\bin'),
      Tnt_WideUpperCase(Path)) > 0);

    RuntimeLibFound :=
      (Pos(Tnt_WideUpperCase(RuntimeLibPath),
      Tnt_WideUpperCase(Path)) > 0);


    if ((Not(JavaDevKitHomeFound)) and
      (Not(JavaHomeFound))) then
    begin
      if (Copy(Path, Length(Path), 1)<>';')then
        Path := Path + ';';

      if (JavaDevKitHome<>'') then
        Path := Path + JavaDevKitHome + '\bin'
      else
        Path := Path + JavaHome + '\bin';

      PathModified := True;
    end;

    if ((Not(JavaDevKitRuntimeLibPathFound)) and
      (Not(RuntimeLibFound))) then
    begin
      if (Copy(Path, Length(Path), 1)<>';')then
        Path := Path + ';';

      if (JavaDevKitRuntimeLibPath<>'') then
        Path := Path + JavaDevKitRuntimeLibPath
      else
        Path := Path + RuntimeLibPath;

      PathModified := True;
    end;

    if (PathModified) then
      SetGlobalEnvironment('path', Path, False);

    JavaIsOk := True;
  end;

  if (Not(QuietOnSuccess)) then
  begin
    Application.CreateForm(TMainForm, MainForm);

    if (JavaIsOk) then
    begin
      MainForm.TitelLbl.Caption :=
        'Java 1.4.2 Installation Verified';
      MainForm.InfoLbl.Caption :=
        'The Java 1.4.2 Runtime Environment was found and the ' +
        'appropriate directories are in the system path variable. '+
        'It is now safe to run your target application.';
    end;

    Application.Run;
  end;
end.