Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Outlook is closed after release an object
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00458982
Message ID:
00459729
Views:
24
>However - where do I find the location of Outlook - I assume somewhere in the Registry ?
>
>I think I've tracked it down to
>HKEY_LOCAL_MACHINE/SOFTWARE/MICROSOFT/WINDOWS/CURRENT VERSION/APP PATHS/OUTLOOK.EXE
>on my Win NT and Win 95 machines - but I'm not sure if this is the best (and most global) way of locating

My favorite way of getting the path/filename for an Automation server's EXE is to first find the CLSID, then look up the CLSID and find its LocalServer32 key, which holds the path/filename of the EXE (and is what Automation uses to locate the server). Here's some code that does just that:
* CheckServer.prg
* © 2000, Tamar E. Granor and Della Martin
* From:  Microsoft Office Automation with Visual FoxPro
* Hentzenwerke Publishing. www.hentzenwerke.com

LPARAMETER cServerName

LOCAL oRegistry, cClassID, cEXEName, lEXEExists, ;
      aClassIDValues, aClassIDValues, aServerNameValues

IF VERSION() = "Visual FoxPro 06"
  oRegistry = NewObject("Registry", HOME() + "FFC\Registry")
ELSE
  SET PROCEDURE TO HOME() + "samples\classes\registry.prg" ADDITIVE
  oRegistry = CreateObject("Registry")
ENDIF

lEXEExists = .F.
DECLARE aClassIDValues[1], aServerNameValues[1]

WITH oRegistry

  * Find the CLSID of the server. First, look for
  * the Class's Key.
  IF .OpenKey(cServerName + "\CLSID") = 0

    * The Class's Key is open, now enumerate its values
    .EnumKeyValues(@aClassIDValues)
    
    * The data portion of the first (only) value returned
    * is the CLSID. Find the LocalServer32 key for the CLSID
    IF .OpenKey("CLSID\" + aClassIDValues[1,2] + "\LocalServer32") = 0

      * Enumerate the LocalServer32 values
      .EnumKeyValues(@aServerNameValues)
      
      * The EXE file is stored in the first (only) data value returned. 
      cEXEName = aServerNameValues[2]
      
      * The value that's returned may have " -Automation" or " /Automation" or
      * " /AUTOMATION" & other trailing stuff at the end. Strip it off.
      IF "AUTO" $ UPPER(cEXEName)
        cEXEName = LEFT(cEXEName, ATC("AUTO", UPPER(cEXEName)) - 2)
      ENDIF
      
      * Verify that the file exists      
      lEXEExists = FILE(cEXEName)   

    ENDIF     
  ENDIF
ENDWITH

RETURN lEXEExists
Hope this helps,

- della Martin
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform