Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP5: Determining if COM object exists at runtime
Message
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00273716
Message ID:
00273754
Views:
20
>How would I go about determining if a certain COM object exists at runtime? Is there some general registration facility? Do I need to poke through the registry?
>
>For instance, let's say I want to know whether MS Graph ha sbeen installed on a client machine, and if so, what version. What kind of facility would I need to check that?
>
>-- jas

Hi Jeff,

Probably have to open the registry key associated with it. In order to do that, you'll have to know what the key is and where it's located. The code snippet below will return the version number of MSGraph if installed in the format of MSGraph.Application.n (where n is the version number). Otherwise, it''l return an empty string. The references to REGISTRY.PRG and REGISTRY.H, as I recall where shipped with VFP 5.0 samples.
FUNCTION MsGraphVer
  #INCLUDE REGISTRY.H
  #DEFINE GRAPHKEYSTRING 'SOFTWARE\Classes\MSGraph.Application\CurVer'
  #DEFINE NO_ERROR 0
  LOCAL loReg, lcValue, lcresult
  SET PROCEDURE TO Registry.prg ADDITIVE
  loReg = CREATEOBJECT("Registry")
  lcresult = ""
  IF loReg.OpenKey(GRAPHKEYSTRING, HKEY_LOCAL_MACHINE, .F.) = NO_ERROR
    lcValue = ""
    IF loReg.GetKeyValue("", @lcValue) = NO_ERROR
      lcresult = lcvalue
    ENDIF
  ENDIF
  RETURN lcresult
ENDFUNC
hth,
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform