git-svn-id: trunk@25610 -
This commit is contained in:
michael 2013-09-30 13:23:01 +00:00
parent bb00c76fe7
commit 5799ff1789

View File

@ -3378,7 +3378,7 @@ uses ctypes,
{$include ociap.inc}
{$IFDEF LinkDynamically}
Procedure InitialiseOCI;
Procedure InitialiseOCI(LibraryName: AnsiString = ocilib);
Procedure ReleaseOCI;
var OCILibraryHandle : TLibHandle;
@ -3390,20 +3390,31 @@ implementation
{$IFDEF LinkDynamically}
var RefCount : integer;
var
RefCount : integer;
LibName : AnsiString;
Procedure InitialiseOCI;
Procedure InitialiseOCI(LibraryName: AnsiString = ocilib);
begin
inc(RefCount);
if RefCount = 1 then
if RefCount > 1 then
begin
if CompareText(LibName,LibraryName)<>0 then
Raise EInOutError.CreateFmt('Can not load Oracle client library "%s". it is already loaded as "%s".',[LibraryName,LibName]);
exit;
end
else
begin
OCILibraryHandle:=loadlibrary(ocilib);
if (OCILibraryHandle=nilhandle) then
begin
RefCount := 0;
Raise EInOutError.Create('Can not load Oracle client. Is it installed? ('+ocilib+')');
Raise EInOutError.CreateFmt('Can not load Oracle client library "%s". Is it installed?',[LibraryName]);
end;
libName:=LibraryName;
end;
{ ORL.inc}
pointer(OCINumberInc) := GetProcedureAddress(OCILibraryHandle,'OCINumberInc');
pointer(OCINumberDec) := GetProcedureAddress(OCILibraryHandle,'OCINumberDec');
@ -3890,17 +3901,18 @@ begin
pointer(OCIDBShutdown) := GetProcedureAddress(OCILibraryHandle,'OCIDBShutdown');
pointer(OCIClientVersion) := GetProcedureAddress(OCILibraryHandle,'OCIClientVersion');
pointer(OCIInitEventHandle) := GetProcedureAddress(OCILibraryHandle,'OCIInitEventHandle');
end;
end;
Procedure ReleaseOCI;
begin
if RefCount > 0 then dec(RefCount);
if RefCount > 0 then
dec(RefCount);
if RefCount = 0 then
begin
if not UnloadLibrary(OCILibraryHandle) then inc(RefCount);
if not UnloadLibrary(OCILibraryHandle) then
inc(RefCount);
LibName:='';
end;
end;