Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Launching external applications from within VFP app
Message
 
 
To
30/03/2000 13:30:52
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00352778
Message ID:
00352877
Views:
17
Lets review what the guy is asking for....

A way to VIEW documents...

Here are some novel approaches that actually give this guy what he asked for..

All that said, automation is NOT the best way to go. In fact, unless there is some need for communication between the applications, automation is overkill..

As far as Notepad not being a server, not everything has to be an automation server in order for VFP to have the ability to open the application.

There are two basic ways of accomplishing this task,

The first is to use the the Shell.Application ProgID
oShell = CREATEOBJECT('Shell.Application')

*/ Notepad opens
oshell.open("foo.txt") 

*/ Word or Wordpad will open, depending on what is associated with .DOC files..
oshell.open("foo.doc")
Another way is to use the ShellExecute function of the Win32API:
Declare long ShellExecute in "shell32.dll" long hwnd, string lpszOp, ;
                    string lpszFile, string lpszParams, ;
                    string lpszDir, long nShowCmd


ShellExecute( 0, "open", "foo.doc", "", "", 1 )
ShellExecute( 0, "open", "foo.txt", "", "", 1 )
Pick your poison. Of the two, I think the first is the way to go.

The deal is that not every problem should be solved by automation, especially if all folks need to do is open documents and work with the applications thems on a direct basis. And, if the user happens to change the association of a file extension, everything will work automatically, because it is dictated by how things are set in Explorer...


HTH...






>>It seems like OLE Automation might be useful but I have no way of knowing what the appropriate load commands are for the various applications associated with the documents. If I could only emulate what Explorer is doing.
>>
>
>Use the GetObject() function to launch the application, passing only the first parameter (the document). That'll launch or connect to the appropriate application, if it's an Automation server and return a reference to the document object within the server:
>
>oDocument = GetObject( cFileName )
>
>There are issues you'll have to deal with, of course. The biggest is that some of the associated applications may not be servers. You mentioned Notepad, for example - I'm pretty sure it's not an Automation server.
>
>Tamar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform