Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Instantiating Outlook through VFP 6.0
Message
From
09/05/2000 14:51:36
Jared Anderson
Marketing Support Solutions, Inc.
Forest, Virginia, United States
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00367348
Message ID:
00367771
Views:
31
>Jared,
>
>You're quite welcome.
>
>A couple of things here. First, you can retrieve the path to Outlook using the
>FindExecutable() API call. All you have to do is create a temporary file with
>one of the extensions associated with Outlook (FAV, MSG, OFT). There's an
>example and details in the MS KB article Q197192.
>
>Second, the program name will come back in a buffer from the function. To
>launch Outlook:
>* lcbuffer contains the fully qualified filename of Outlook.exe
>lnpt = AT(CHR(0), lcbuffer)
>lcbuffer = LEFT(lcbuffer, lnpt - 1)
>RUN /n &lcbuffer
>As a side note, I tried the API call to ShowWindow() to attempt to see if I
>could make Outlook visible if it were already running. Sorry, no luck.
>
>hth,
>

George,

Thanks again. I'll definitely keep this in mind, though I did find another way of working this out ...... and while my mind is going in circles by this point, maybe it'll be more straight-forward for others facing the same problem.

The following example makes use of the "registry.vcx" class (as well as registry.vct and registry.h) that is in Vfp98\FFC

First, as I mentioned before, it is necessary to find the Default Mail in the registry (which would hopefully be Outlook). This is found at HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail ... The class provides a function, "getregkey" which finds the value.

Once the name of the Default Mail program is found, it is appended to HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\ ... which is then appended by \Shell\Open\Command ... this is passed back into "getregkey".

This gives the full (with spaces & quotes) path to Outlook, including the flag "Outlook:Inbox".

Then, I chop off the flag and remove the quotes, and using the GetShortPathName function from the win32API, I find the "short-version" ("C:\PROGRA~1\..." etc.) of the path to the EXE

Then I re-append "Outlook : Inbox" (I'll have to add a check to make sure it IS outlook first, since there is a possibility of Outlook not being the default mail program)

And THEN (YAY!) ! / RUN can handle it!

Here's my code ... it probably will undergo some cleanup, but it works:

"getmail.prg":


************************************************************************
*!* I made a copy of registry.vcx, registry.vct, and registry.h
*!* ... and put them in a "temp"/test directory.
#INCLUDE C:\REGISTRYTEST\REGISTRY.H
*!* This is included to get HKEY_LOCAL_MACHINE, which is defined as -2147483646


LOCAL cValue, cPrg, oRegistry


*!* Access the win32api for GetShortPathName
DECLARE INTEGER GetShortPathName in win32api;
STRING @lpsource, STRING @lptarget, INTEGER nLength
lcbuffer = SPACE(260)


CLEAR


*!* Initialize
cValue = ""
cPrg = ""


*!* I made a copy of registry.vcx, registry.vct, and registry.h
*!* ... and put them in a "temp"/test directory.
set classlib to c:\registrytest\registry additive


*!* Instantiate the "registry" object
oregistry = createobject("registry")


*!* Find the name of the default mail program, put it in cValue
oregistry.getregkey("",@cValue,"SOFTWARE\Clients\Mail", HKEY_LOCAL_MACHINE)
*!* EXAMPLE FOR MY OUTLOOK: cValue now = 'Microsoft Outlook'


*!* Find the command path to the default mail program,
*!* using cvalue to find the key. Put it in cPrg
oregistry.getregkey("",@cprg,"SOFTWARE\Clients\Mail\"+cvalue+"\Shell\Open\Command", ;
HKEY_LOCAL_MACHINE)
*!* EXAMPLE FOR MY OUTLOOK: cPrg now =
*!* '"C:\Program Files\Microsoft Office\Office\outlook.exe" Outlook:Inbox'


*!* Take off quotes, take off flag (if appropriate)
cprg = SUBSTR(cprg,2,RAT('"',cprg))
cprg = SUBSTR(cprg,1,AT('"',cprg)-1)

*!* Get the Short Path Name through Win32API, put it in lcbuffer
lnResult = GetShortPathName(@cprg, @lcbuffer, LEN(lcbuffer))
*!* EXAMPLE FOR MY OUTLOOK: lcbuffer now =
*!* 'C:\PROGRA~1\MICROS~1\Office\outlook.exe'


*!* Re-append run flag for outlook
ACTIVATE SCREEN
IF lnResult > 0
? LEFT(lcbuffer, lnresult) + " Outlook:Inbox"
ELSE
? lnResult
ENDIF


*!* Re-append run flag for outlook, return
RETURN LEFT(lcBuffer,lnResult) + " Outlook:Inbox"
*!* EXAMPLE FOR MY OUTLOOK: the returned value is
*!* 'C:\PROGRA~1\MICROS~1\Office\outlook.exe Outlook:Inbox'

*************************************************************************
end "getmail.prg"

I've tested at the command prompt with:

cnew = grabpath()
! &cnew

And Outlook runs!



Hope that made SOME sense ;-P
Just thought I'd post my approach for constructive criticism, support, and/or to help direct others w/ possibly the same questions.

Thanks again all

Jared M Anderson
Interactive Data Systems, Inc.
janderson@idevgroup.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform