realbasic-nug
[Top] [All Lists]

Re: Launching a Program And Passing Parameters

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Launching a Program And Passing Parameters
From: Brian Rathbone <brianrathbone at bellsouth dot net>
Date: Tue, 31 Jan 2006 21:14:06 -0500
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <20060131220844 dot D19C110A6CAA at lists dot realsoftware dot com> <F5B672C8-2E9C-423C-9370-1C9B5012469C at elfdata dot com> <43DFFD0E dot 1020505 at utoronto dot ca> <43E007C0 dot 4000809 at ix dot netcom dot com>


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>


<Prev in Thread] Current Thread [Next in Thread>