Restored from previous forum. Originally posted by wayne1.
Code: Select all
;Several useful functions
;run one at a time in the sample else the windows will be covered by one another
If OpenWindow(0, 100, 100, 195, 260, "PureBasic Window", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
a=ShellExecute_(WindowID(0),"print","d:\\program Files\\context\\readme.txt",NULL, NULL, 0);set this to a to valid path
;prints file with program associated with extension, here it's notepad
MessageRequester("Information 1st Printing","Return Value Is "+Str(a)+Chr(10)+"If greater than 32 it succeeded Else it failed.", 0)
;a=ShellExecute_(windowID(0),"print","d:\\program Files\\context\\document.doc",NULL, NULL, 0);set this to a to valid path
;MessageRequester("Information 2nd Printing","Return Value Is "+str(a)+chr(10)+"If greater than 32 it succeeded Else it failed.", 0)
;prints file with program associated with extension, here it's wordpad
a=ShellExecute_(WindowID(0), "open", "d:\\program Files\\context\\", NULL, NULL, #SW_SHOWNORMAL);set this to a to valid path
MessageRequester("Information Open Folder","Return Value Is "+Str(a)+Chr(10)+"If greater than 32 it succeeded Else it failed.", 0)
;opens folder
a=ShellExecute_(WindowID(0), "open", "d:\\program Files\\context\\readme.txt", NULL, NULL, #SW_SHOWNORMAL);set this to a to valid path
MessageRequester("Information Open File in NotePad","Return Value Is "+Str(a)+Chr(10)+"If greater than 32 it succeeded Else it failed.", 0)
;opens text with program associated with extension, here it's notepad
a=ShellExecute_(WindowID(0), "explore", "d:\\program Files\\context\\", NULL, NULL, #SW_SHOWNORMAL);set this to a to valid path
MessageRequester("Information Explore Folder","Return Value Is "+Str(a)+Chr(10)+"If greater than 32 it succeeded Else it failed.", 0)
;opens folder with explorer
a=ShellExecute_(WindowID(0), "find", "d:\\program Files\\context\\", NULL, NULL, 0);set this to a to valid path
MessageRequester("Information Launch Search","Return Value Is "+Str(a)+Chr(10)+"If greater than 32 it succeeded Else it failed.", 0)
;launches file searcher to start in indicated path
;ShellExecute
;Performs an operation on a specified file.
;HINSTANCE ShellExecute(
; HWND hwnd,
; LPCTSTR lpVerb,
; LPCTSTR lpFile,
; LPCTSTR lpParameters,
; LPCTSTR lpDirectory,
; INT nShowCmd
;)
;Parameters
;hwnd
;Handle to a parent window. This window receives any message boxes
;that an application produces. For example, an application may report
;an error by producing a message box.
;lpVerb
;A string, referred to as a verb, that specifies the action to be performed.
;The set of available verbs depends on the particular file or folder.
; Generally, the actions available from an object's context menu are available verbs.
; For more information about verbs and their availability, see Object Verbs.
; See Extending Context Menus for further discussion of context menus.
; The following verbs are commonly used: Verb Description
;edit Launches an editor and opens the document for editing. If lpFile is not a document file, the function will fail.
;explore Explores the folder specified by lpFile.
;find Initiates a search starting from the specified directory.
;open Opens the file specified by the lpFile parameter. The file can be an executable file, a document file, or a folder.
;print Prints the document file specified by lpFile. If lpFile is not a document file, the function will fail.
;properties Displays the file or folder's properties.
;SW_HIDE Hides the window And activates another window.
;SW_MAXIMIZE Maximizes the specified window.
;SW_MINIMIZE Minimizes the specified window And activates the Next top-level window in the z-order.
;SW_RESTORE 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_SHOW Activates the window And displays it in its current size And position.
; SW_SHOWDEFAULT 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.
; SW_SHOWMAXIMIZED Activates the window And displays it as a maximized window.
; SW_SHOWMINIMIZED Activaes the window And displays it as a minimized window.
;SWSHOWMINNOACTIVE Displays the window as a minmized window. The active window remains active.
; SW_SHOWNA Displays the window in its current state The active window remains active.
;SW_SHOWNOACTIVATE Displays a window in its most recet size And position. The active window remains active.
;SW_SHOWNORMAL Activates And displays a window. If the window is minimized o maximized,
; Windows restores it To its original size And position. An applicatin should specify this flag when displaying the window For the first time.
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
Until Quit = 1
EndIf
End