COM/ActiveX objects and Windows Vista and newer
2012-02-02 21:55
i3008
[permalink]
Applications that provide one or more ActiveX/COM automation objects, created with older versions of Delphi, running without administrative privileges, throw an EOleSysError when strarting up (typically from within the Application.Initialize;). This is because the application will try to register its type library and class registrations when it starts. Add this unit to the project to silent this error at run-time:
unit comFixW6;
interface
implementation
uses Windows, SysUtils, ComObj;
var
SaveInitProc:pointer=nil;
procedure FixComInitProc;
begin
try
if SaveInitProc<>nil then TProcedure(SaveInitProc);
except
on e:EOleSysError do if e.ErrorCode<>TYPE_E_REGISTRYACCESS then raise;
end;
end;
initialization
SaveInitProc:=InitProc;
InitProc:=@FixComInitProc;
end.