Barry Traver wrote:
BUT what I don't remember how to do in REALbasic (and can't even
remember if I ever knew how to do it in RB) is this: Have a REALbasic
program launch Notepad with a particular file loaded in NotePad (such as
"goodnews.txt")
When DOS was still around, you could do this by putting something like
this in a .bat file:
notepad.exe "goodnews.txt"
That is, you could pass along the parameter by putting it right on the
command line.
Visual Basic was less friendly. In Visual Basic, you could either use
"Shell" to open a particular application like Notepad, but with no
specific document loaded. Or you could use the "ShellExecute" API call
to load in a specific document _using the application associated with
that particular type of document_. But neither serves the purpose. I
want to be able to designate both the application _and_ the specific
document to be loaded in.
Is there a way to do this in REALbasic?
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.
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
Aaron has also implemented CreatProcess 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.
hth,
Brian
_______________________________________________
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>
|