Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if registered OCX

Status
Not open for further replies.

lucian81

Programmer
Joined
Feb 11, 2008
Messages
14
Hello,

I want to test when my application starts, if an OCX file is registered. The OCX I am talking about is mschrt20.ocx. I embedded the control in a class (I attached this class), and tried to check is the OCX is registered using the following code:

SET CLASSLIB TO pcAppPath+'Libs\Charts\charttest.vcx' ADDITIVE
STORE .T. TO lChrtOK
TRY
loTest=CREATEOBJECT('MSChart20Lib.MSChart.2')
CATCH
STORE .F. TO lChrtOK
ENDTRY

The problem is that this code returns .F. and the application works just fine, using the OCX file. Why is this happening?

Thank you very much.

All best,
Lucian
 
Lucian,

Try this:

Code:
loError = NULL
lnErrorNo = 0
TRY
  loTest=CREATEOBJECT('MSChart20Lib.MSChart.2')
CATCH TO loError
  lnErrorNo = loError.ErrorNo
ENDTRY 

IF lnErrorNo <> 0
  MESSAGEBOX(lnErrorNo)
ENDIF

The message will tell you the error number.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hello.

The code you provided helped me understand what was the problem with this check. So, there are two situations:

1.My application is installed and the mschrt20.ocx is registered. The application that uses it displays charts correctly. The error code displayed is 1426 and the Details of the error - "80040112: Appropriate license for this file not found" (for Windows 98SE) and "80040112: Class is not licensed for use" (for WinXP SP2)

2.The application is not installed, so the mschrt20.ocx is NOT registered. In this case the error code is 1733 and the details - "MSCHART20LIB.MSCHART.2" - this is correct because the OCX should not be registered.

My question is - why does the first situation occures? Is this a legal issue I should have to take care of (as I found in redist.txt in the HOME() directory of VFP, it is legal to redistribute this OCX with my application)?

Both these cases occured on Windows 98 SE.

Thank you very much.
Lucian
 
Lucian,

This is not really a legal issue. The licence that the message refers to is simply a set of registry keys that identify the computer as a development system.

The idea was that users should be able to freely run applications that call the charting control, but not necessarily open the control in a development environment.

If your computer has certain Microsoft development tools installed, there is no problem, because the relevant registry keys would be installed. But that didn't apply to VFP (at least not to the earlier versions).

The solution was to run a file called FOX.REG, which installed the necessary keys. I believe that this file used to be available from the Microsoft site, but I have no idea whereabouts to find it. Alternatively, do a Google search.

I use the past tense in this reply because the problem has pretty well disappeared. It only applied to older versions of VFP, and only when running under Windows 9x.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,

I don't have this problem on my computer, the one I use to create the application. The problem occurs on computers with no development tools installed (Win 9x and Win XP). Can this be an issue at a later time (for my clients I mean), something like crashes or other stuff like that? If not, I can consider that, if the error code is the one corresponding to the missing license keys (1426), the OCX is correctly registered and functional. So, I won't warn the user about it. Is this a correct approach?

Thank you.
Lucian
 
Lucian,

Yes, I think that's right The user should never see this message. It should only occur when you try to open the control at design time (at least, that's my understanding).

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thank you very much Mike.

All best,
Lucian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top