lgallion
asked on
How to detect if a OCX is registered before app generates an error because it is not
I have a Delphi app and I have integrated a 3rd party PDF reader OCX, however the problem is I can't check to see if the OCX is registered (and fix the problem by registering it) before the app crashes with a Kernal32 error (because the OCX is embedded in the main form). I know I could fix this with an installer (which registers the OCX) but it would be alot more elegant if the program could check for the proper registration and then register it before finishing initialization. Is there any way to do this?
First thing in my main form's OnCreate I am calling this code (but unfortunately it never gets called):
procedure RegisterOCX;
var
OCXHand: THandle;
begin
OCXHand:=LoadLibrary('L:\A PPS\Family Services\FSWorkflow\VSPDFV iewerX.ocx ');
// If OCX didn't load (OCXHand = 0) then attempt to register it
if OCXHand = 0 then
begin
if (GetProcAddress(OCXHand,'D llRegister Server')<> nil) then
begin
StandardEurekaError('Error Registering OCX VSPDFViewerX');
end;
end;
FreeLibrary(OCXHand);
end;
First thing in my main form's OnCreate I am calling this code (but unfortunately it never gets called):
procedure RegisterOCX;
var
OCXHand: THandle;
begin
OCXHand:=LoadLibrary('L:\A
// If OCX didn't load (OCXHand = 0) then attempt to register it
if OCXHand = 0 then
begin
if (GetProcAddress(OCXHand,'D
begin
StandardEurekaError('Error
end;
end;
FreeLibrary(OCXHand);
end;
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Too slow on this one ;-)
Russell
Russell
Run regsvr32 YourOCX.ocx to register it (it the file exists)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks guys excellent feedback! Kudos to mokule for a quick reply, nods to atul_parmar for pointing me in a better direction and a big thanks to rllibby for a super indepth answer.
Regards,
Russell