Files
lazarus-ccr/components/geckoport/Components/GeckoInit.pas
macpgmr f7642d12d1 First commit of GeckoPort source
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1009 8e941d3f-bd1b-0410-a28a-d453659cc2b4
2009-11-15 23:34:54 +00:00

59 lines
972 B
ObjectPascal

unit GeckoInit;
interface
procedure GeckoComponentsStartup;
procedure GeckoComponentsShutdown;
implementation
uses
nsXPCOM, nsInit, nsGeckoStrings, nsTypes, nsConsts, nsErrorUtils, nsError,
nsXPCOMGlue, nsXRE {$IFDEF MSWINDOWS}, Windows {$ENDIF};
var
sInitCount: Integer = 0;
procedure GeckoComponentsStartup();
var
rv: nsresult;
errorStr: AnsiString;
begin
if sInitCount>0 then
begin
Inc(sInitCount);
Exit;
end;
rv := XRE_Startup('1.9', True, '2.0', False);
if NS_FAILED(rv) then
begin
errorStr := NS_GetErrorStringBundleKey(rv);
XPCOMGlueShutdown;
raise EGeckoError.Create(string(errorStr));
end;
Inc(sInitCount);
end;
procedure GeckoComponentsShutdown();
begin
if sInitCount = 0 then
begin
raise EGeckoError.Create(
'ERROR: Too many calls for GeckoComponentsShutdown then GeckoComponentsStartup');
end;
Dec(sInitCount);
if sInitCount = 0 then
begin
XRE_Shutdown();
end;
end;
end.