Brian,
Thanks for the excellent thoughts!
Yes, you can do this a number of ways. You were close to a solution
based on your own research. "ShellExecute" API call has a lpParameters
parameter, which Aaron has implemented in the Windows Functionality
Suite folderitem.launch extension. This allows you to specify
notepad.exe as the file to launch and c:\autoexec.bat (or whatever) as
the file to open in notepad.
Aha! So you don't make "goodnews.txt" the target file, but
"RBNotepad.exe" (or whatever) and then pass along the "goodnews.txt" as
a parameter? I don't know why, but I somehow was looking at
ShellExecute the other way around, but ShellExecute indeed can be used
either way. You can use either a document or an application as the
target file:
"You can use the ShellExecute API to launch a document or application.
This launches the application asynchronously as well, but allows you to
start applications based on a document's association." -- Steve Brown,
Visual Basic Developer's Guide to the Windows API, p. 214.
What I missed was the fact of the lpParameters you mentioned.
When you go beyond the limitations of shellexecute and need things
like a process handle for "shell and wait" type functions, you can
user CreateProcess API call to execute an ordinary command line, such as:
notepad.exe c:\autoexec.bat
Steve Brown also says this: "The CreateProcess API is the most powerful
of the three methods [Shell, ShellExecute, and CreateProcess] and is
also the trickiest to use." I note that you also describe CreateProcess
as "more powerful," but also similarly admit that "It's harder to use":
Aaron has also implemented CreateProcess in the Windows Functionality
Suite in the ShellAndWait function. I find myself useing CreateProcess
more and more because of the extra functionality. It's harder to use
(if someone hasn't already coded what you need), but more powerful.
I'm not sure I'm brave enough to try CreateProcess, but I should be able
to do what I want to do with ShellExecute (assuming that I'm working in
Windows, which I am). Thanks for the help; it is much appreciated.
DIFFERENT QUESTION: If I wanted to publish a "CD eZine" for the Mac,
how would I approach that? (Of course, there would be no Windows API
calls to work with. Are there equivalents on the Mac? I don't yet own a
Mac, but I hope that someday....)
Warm regards,
Barry Traver
P.S. Do you know of any other sample code available other than what is
in Aaron's Windows Functionality Suite?
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|