• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

Checking for existance of an activex control

I've got an app that has a reealplayer activex control in it.  If the user doesnt have realplayer, it errors out horribly.  How can I gracefully check for the control in the registry and exit if its not there?

0
hibbidiji
Asked:
hibbidiji
  • 3
  • 2
1 Solution
 
Russell LibbySoftware Engineer, Advisory Commented:

If you have placed the AX control on one of your forms, then Delphi will attempt to instantiate the control when the form is created. If this is the case, then you should be handling the check in the project source. An example of handling this (displays a message) is shown below. You may need to double check the CLSID for the control, as I got it from a google search (check the type library pas file), but the rest of the code is valid for the handling.

Regards,
Russell

----

program Project1;

uses
  Windows,
  Forms,
  ActiveX,
  ComObj,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.RES}

// Real player CLSID - check your type library for the real player control to
// ensure this CLSID is correct
const
  CLASS_RealPlayer:    TGUID = '{CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA}';

var
  pvUnk:      IUnknown;

begin

  Application.Initialize;

  // Attempt to create an instance of the real player
  if (CoCreateInstance(CLASS_RealPlayer, nil, CLSCTX_ALL, IUnknown, pvUnk) = S_OK) then
  begin
     // Release the interface
     pvUnk:=nil;
     // Allow application to continue
     Application.CreateForm(TForm1, Form1);
     Application.Run;
  end
  else
    // Not installed, or missing components
     MessageBox(0, 'Please install the Real Player ActiveX control', nil, MB_OK);

end.
0
 
hibbidijiAuthor Commented:
Perfect code that worked first try!

Thanks!
0
 
Russell LibbySoftware Engineer, Advisory Commented:

You are very welcome (and don't forget to close this question out ;-)

Regards,
Russell
0
 
hibbidijiAuthor Commented:
Oops! you'd think after dozens of questions I'd remember.  I think the working first try code had me so excited I forgot :)   (I tend to get a lot of code with missing pieces)

Thanks again
0
 
Russell LibbySoftware Engineer, Advisory Commented:
Again, very welcome. I completely understand too, which is why I try to "get it all there" the first time around...  less aggravation for all involved. <g>

Happy coding,
Russell

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now