ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/fbintf/client/include/wloadlibrary.inc
(Generate patch)

Comparing ibx/trunk/fbintf/client/include/wloadlibrary.inc (file contents):
Revision 262 by tony, Tue Oct 17 10:07:58 2017 UTC vs.
Revision 263 by tony, Thu Dec 6 15:55:01 2018 UTC

# Line 1 | Line 1
1 < procedure TFBClientAPI.LoadIBLibrary;
1 > function TFBLibrary.LoadIBLibrary: boolean;
2  
3    function IsValidHandle(aHandle: TLibHandle): boolean;
4    begin
# Line 9 | Line 9 | procedure TFBClientAPI.LoadIBLibrary;
9    begin
10      Result := LoadLibrary(PChar(LibName));
11      if IsValidHandle(Result) then
12    begin
12        FFBLibraryName := ExtractFileName(LibName);
14      FFBLibraryPath := ExtractFileDir(LibName);
15    end;
13    end;
14  
15    function GetSpecialFolder(const CSIDL: integer) : string;
# Line 49 | Line 46 | var InstallDir: string;
46      dllPathName: string;
47      oldFirebirdEV: string;
48   begin
49 <  if IsValidHandle(IBLibrary) then Exit;
49 >  Result := IsValidHandle(FIBLibrary);
50 >  if Result then Exit;
51  
52    curPath := GetEnvironmentVariable('PATH');
53  
# Line 57 | Line 55 | begin
55    dllPathName := GetOverrideLibName;
56    if dllPathName <> '' then
57    begin
58 <    IBLibrary := DoLoadLibrary(dllPathName);
59 <    FOwnsIBLibrary := IsValidHandle(IBLibrary);
58 >    FIBLibrary := DoLoadLibrary(dllPathName);
59 >    Result := IsValidHandle(FIBLibrary);
60      Exit;
61    end;
62  
# Line 69 | Line 67 | begin
67    if FileExists(InstallDir + FIREBIRD_EMBEDDED) then
68    begin
69         dllPathName := InstallDir + FIREBIRD_EMBEDDED;
70 <       IBLibrary := DoLoadLibrary(dllPathName)
70 >       FIBLibrary := DoLoadLibrary(dllPathName)
71    end
72    else
73    //Otherwise look for Firebird Client in installation dir
# Line 80 | Line 78 | begin
78      SetEnvironmentVariable('FIREBIRD',PChar(InstallDir));
79      dllPathName := InstallDir + FIREBIRD_CLIENT;
80      try
81 <      IBLibrary := DoLoadLibrary(dllPathName)
81 >      FIBLibrary := DoLoadLibrary(dllPathName)
82      finally
83 <      if not IsValidHandle(IBLibrary) then
83 >      if not IsValidHandle(FIBLibrary) then
84          SetEnvironmentVariable('FIREBIRD',PChar(oldFirebirdEV)); {restore}
85      end;
86    end;
87  
88   //  writeln('Dir = ',InstallDir);
89    {If FIREBIRD environment variable available then try this}
90 <  if not IsValidHandle(IBLibrary) then
90 >  if not IsValidHandle(FIBLibrary) then
91    begin
92      InstallDir := GetEnvironmentVariable('FIREBIRD');
93      if (length(InstallDir) > 0) and (InstallDir[length(InstallDir)] <> DirectorySeparator) then
# Line 99 | Line 97 | begin
97        //assume firebird.conf and firebird.msg in same dir
98        dllPathName := InstallDir + FIREBIRD_CLIENT;
99        Add2Path(InstallDir);
100 <      IBLibrary := DoLoadLibrary(dllPathName)
100 >      FIBLibrary := DoLoadLibrary(dllPathName)
101      end
102      else
103      if (InstallDir <> '') then
# Line 109 | Line 107 | begin
107        begin
108          dllPathName := InstallDir +  FIREBIRD_CLIENT;
109          Add2Path(InstallDir);
110 <        IBLibrary := DoLoadLibrary(dllPathName)
110 >        FIBLibrary := DoLoadLibrary(dllPathName)
111        end
112      end
113    end;
114  
115 <  if not IsValidHandle(IBLibrary) then
115 >  if not IsValidHandle(FIBLibrary) then
116    {Use Registry key if it exists to locate library Firebird 2 only}
117    begin
118      with TRegistry.Create do
# Line 127 | Line 125 | begin
125            InstallDir := ReadString('DefaultInstance')  + 'bin' + DirectorySeparator ;
126            dllPathName := InstallDir + FIREBIRD_CLIENT;
127            Add2Path(InstallDir);
128 <          IBLibrary := DoLoadLibrary(dllPathName)
128 >          FIBLibrary := DoLoadLibrary(dllPathName)
129          end
130        end
131      finally
# Line 135 | Line 133 | begin
133      end;
134  
135      {Now try default install dir}
136 <    if not IsValidHandle(IBLibrary) then
136 >    if not IsValidHandle(FIBLibrary) then
137      begin
138        InstallDir := GetSpecialFolder(CSIDL_PROGRAM_FILES) +
139          'Firebird' +
140          DirectorySeparator + 'Firebird_3_0' + DirectorySeparator;
141        dllPathName := InstallDir  + FIREBIRD_CLIENT;
142        Add2Path(InstallDir);
143 <      IBLibrary := DoLoadLibrary(dllPathName)
143 >      FIBLibrary := DoLoadLibrary(dllPathName)
144      end;
145  
146 <    if not IsValidHandle(IBLibrary) then
146 >    if not IsValidHandle(FIBLibrary) then
147      begin
148        InstallDir := GetSpecialFolder(CSIDL_PROGRAM_FILES) +
149          'Firebird' +
# Line 153 | Line 151 | begin
151          DirectorySeparator + 'bin' + DirectorySeparator;
152        dllPathName := InstallDir + FIREBIRD_CLIENT;
153        Add2Path(InstallDir);
154 <      IBLibrary := DoLoadLibrary(dllPathName)
154 >      FIBLibrary := DoLoadLibrary(dllPathName)
155      end;
156  
157 <    if not IsValidHandle(IBLibrary) then
157 >    if not IsValidHandle(FIBLibrary) then
158      begin
159        InstallDir := GetSpecialFolder(CSIDL_PROGRAM_FILES) +
160          'Firebird' +
# Line 164 | Line 162 | begin
162          DirectorySeparator + 'bin' + DirectorySeparator;
163        dllPathName := InstallDir + FIREBIRD_CLIENT;
164        Add2Path(InstallDir);
165 <      IBLibrary := DoLoadLibrary(dllPathName)
165 >      FIBLibrary := DoLoadLibrary(dllPathName)
166      end;
167  
168      //Otherwise see if Firebird client is in path
169      //and rely on registry for location of firebird.conf and firebird.msg
170 <    if not IsValidHandle(IBLibrary) then
170 >    if not IsValidHandle(FIBLibrary) then
171      begin
172        SetEnvironmentVariable('PATH',PChar(curPath));
173 <      IBLibrary := DoLoadLibrary(FIREBIRD_CLIENT);
174 <      if IBLibrary <= HINSTANCE_ERROR then
173 >      FIBLibrary := DoLoadLibrary(FIREBIRD_CLIENT);
174 >      if FIBLibrary <= HINSTANCE_ERROR then
175         //well maybe InterBase is present...
176 <       IBLibrary := DoLoadLibrary(IBASE_DLL);
176 >       FIBLibrary := DoLoadLibrary(IBASE_DLL);
177      end;
178    end;
179 <  FOwnsIBLibrary := IsValidHandle(IBLibrary);
179 >  Result := IsValidHandle(FIBLibrary);
180   end;
181  
182 + class procedure TFBLibrary.SetupEnvironment;
183 + begin
184 + end;
185  
186 + function TFBLibrary.GetLibraryFilePath: string;
187 + var buffer: array [0..IBBigLocalBufferLength] of char;
188 +    nSize: DWORD;
189 + begin
190 +  nSize := GetModuleFileNameA(FIBLibrary,@buffer,IBBigLocalBufferLength+1);
191 +  if nSize > IBBigLocalBufferLength then
192 +    buffer[IBBigLocalBufferLength] :=#0;
193 +  Result := strpas(PAnsiChar(@buffer));
194 + end;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines