[REBOL] Re: Exploring System Port
From: james:mustard at: 15-Oct-2002 19:47
Ashley wrote:
> Err, this lost me a bit. ;) Could you provide an example of a "simple
shell
> call using the ShellExecute API" ...
Someone may need to correct bits of this as I only have the free version of
View/Core but according to my interpretation of the docs the following
should be correct.
;---------------------------------------------------
shell-lib: load/library shell32.dll
ShellExecute: make routine! [
"this will execute an operation on a file"
hwnd [integer!] ; handle to the window of the calling app (for focus
issues) if you dont care use 0
lpOperation [string!] ; something like "OPEN" , "PRINT" , "EXPLORE" ,
FIND
etc.. depending on app.
lpFile [string!] ; file name (including path)
lpParameters [string!] ; if lpfile is an executable file you can add
parameters here
lpDirectory [string!] ; default directory
nShowCmd [integer!] ; one of the values shown below
] shell-lib "ShellExecuteA"
; options for the nShowCmd parameter (most people use 4 or 5)
SW_HIDE: 0 ; Hides the window and activates another window.
SW_SHOWNORMAL: 1 ; Activates and displays a window. If the window is
minimized or maximized, Windows restores it to its original size and
position. An application should specify this flag when displaying the window
for the first time.
SW_SHOWMINIMIZED: 2 ; Activates the window and displays it as a minimized
window.
SW_MAXIMIZE: 3 ; Maximizes the specified window.
SW_SHOWMAXIMIZED: 3 ; Activates the window and displays it as a maximized
window.
SW_SHOWNOACTIVATE: 4 ; Displays a window in its most recent size and
position. The active window remains active.
SW_SHOW: 5 ; Activates the window and displays it in its current size and
position.
SW_MINIMIZE: 6 ; Minimizes the specified window and activates the next
top-level window in the z-order.
SW_SHOWMINNOACTIVE: 7 ; Displays the window as a minimized window. The
active window remains active.
SW_SHOWNA: 8 ; Displays the window in its current state. The active window
remains active.
SW_RESTORE: 9 ; Activates and displays the window. If the window is
minimized or maximized, Windows restores it to its original size and
position. An application should specify this flag when restoring a minimized
window.
SW_SHOWDEFAULT: 10 ; Sets the show state based on the SW_ flag specified in
the STARTUPINFO structure passed to the CreateProcess function by the
program that started the application. An application should call ShowWindow
with this flag to set the initial show state of its main window.
; ----------------------------
; usage examples (I don't have /command or /pro to verify these but they
are correct according to the docs..)
;
; ShellExecute 0 "OPEN" "BananaEdit.exe" "a_new_doc.ban" "c:\" 5
;
; ShellExecute 0 "OPEN" "c:\my documents\status reports.doc" "" "c:\my
documents" 3
;
; ShellExecute 0 "PRINT" "c:\my documents\status reports.doc" "" "c:\my
documents" 0
;
; ShellExecute 0 "OPEN" "c:\shortcut.sh" "" "c:\" 4
;---------------------------------------------------------------------------
------------
James.