Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determine existence of objects (Outlook, custom App obje
Message
From
12/10/2000 10:38:34
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00428456
Message ID:
00428478
Views:
14
>I have a couple of questions that probably have simple answer (hence, I couldn't figure them out myself :).
>
>1. I have error handling in my app that prints a report in the event of an unhandled error and then gracefully shots down the app. I would like to have the error report e-mailed to us if the user has Outlook. I know how to handle the e-mail peice, but I would like to check for the existence of Microsoft Outlook on a users P.C. - if they have Outlook, an e-mail is fired off - if not, a report is printed that would have to be faxed to us. How would I check to see if Outlook is intalled on the workstation? (I would have tried a few things here before posting this - except that all our internal P.C.'s have Outlook.)
>

Here's the code from Della Martin's and my book "Microsoft Office Automation with Visual FoxPro" that lets you check whether a server is present and properly registered:

* 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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform