Barry Traver wrote:
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?
Correct
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:
Correct. It *can* work the other way around, but it doesn't *have* to.
> 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....)
Not sure about this one, but on Mac there are toolbox calls and the
Carbon Declare Library. Perhaps you should ask this question in a
seperate thread, since I doubt it has caught the notice of the Mac saavy
list members.
P.S. Do you know of any other sample code available other than what is
in Aaron's Windows Functionality Suite?
I have bunches of examples in my personal collection. I usually clean
them up and send them to Aaron for inclusion in the Windows
Functionality Suite. Since it is open source and free, I figure it's a
good central repository for and Win32 API based contributions I want to
make to the community.
Here is a specific example of how to open a file with notepad using
shellexecute vs createprocess: (Watch out for line wrap)
#if TargetWin32
Const SW_SHOWNORMAL = 1
Const SW_HIDE = 0
Const SW_MAXIMIZE = 3
Const SW_MINIMIZED = 6
Declare Sub ShellExecuteA Lib "Shell32" ( hwnd as Integer,
operation as CString, file as CString, params as CString, directory as
CString, show as Integer )
dim params as String
dim f as folderitem
f = getopenFolderItem("special/any")
if f <> nil and f.exists then
///target path enclosed in qoutes so paths with spaces in name are ok
ShellExecuteA( 0, "open", "notepad.exe", """" + f.absolutePath +
"""", "", SW_MAXIMIZE )
end
#endif
/////////////////////////////////////////////////////////////////////////////////////////
#if targetWin32 then
Declare Function CreateProcessA Lib "kernel32" (lpApplicationName
As integer, lpCommandLine As cString, lpProcessAttributes As integer,
lpThreadAttributes As integer, bInheritHandles As integer,
dwCreationFlags As integer, lpEnvironment As integer, lpCurrentDirectory
As integer, lpStartupInfo As ptr, lpProcessInformation As ptr) As integer
Const SW_SHOWNORMAL = 1
Const SW_HIDE = 0
Const SW_MAXIMIZE = 3
Const SW_MINIMIZED = 6
Const NORMAL_PRIORITY_CLASS = &H20
Dim Ret As integer
Dim StartInf As memoryblock
Dim Proc as MemoryBlock
Dim f as folderitem
f = getopenFolderItem("special/any")
if f <> nil and f.exists then
Startinf = newmemoryBlock(76)
Startinf.long(44) = 1 /// set flags to use showwindow
Startinf.long(48) = SW_SHOWNORMAL
StartInf.long(0) = StartInf.size
Proc = newmemoryBlock(16)
Ret = CreateProcessA(0,"notepad.exe" + " " + """" +
f.absolutePath + """", 0, 0, 1,NORMAL_PRIORITY_CLASS, 0, 0, StartInf, Proc)
end
#endif
As you can see, the tricky part is the memoryblocks, which are being
used to simulate VB Types. You can look up each type on MSDN, figure out
their contents, and then determine the size of the memoryblock needed
and the offsets for each member. Not fun stuff, but it gets easier once
you get the hang of it.
If you need something more specific, let me know. I also have more
heavily documented examples that show the breakdown of the memoryblocks.
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>
|