Date: 02-16-2022
Return to Index
created by gbSnippets
'this example runs an external application - in this case "notepad.exe"
'Primary Code:
'Example #1: runs and external app and waits for it to finish
Shell("notepad.exe", WndStyle&) 'waits
'Example #2; runs and external app - does NOT wait for it to finish
'return value is the external application process id, assigned by Windows
Dim ProcessID&, wStyle&
wStyle& = 1
ProcessID& = Shell("notepad.exe", wStyle&) 'does not wait
'WndStyle (optional) values affect how the external app is display:
'0 - Hide window
'1 - Normal With focus (default)
'2 - Minimized With focus
'3 - Maximized With focus
'4 - Normal without focus
'6 - Minimized without focus
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As Dword
%IDC_Button1 = 100 : %IDC_Button2 = 102
Function PBMain() As Long
Dialog New Pixels, 0, "External App Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Button1, "Push (not wait)", 50,10,120,20
Control Add Button, hDlg, %IDC_Button2, "Push (waits)", 50,40,120,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local ProcessID&
If CB.Msg = %WM_Command AND CB.Ctl = %IDC_Button1 AND CB.Ctlmsg = %BN_Clicked Then
ProcessID& = Shell("notepad.exe", 1) 'does not wait
MsgBox "Notepad is still going, yes?", , "External App Test"
End If
If CB.Msg = %WM_Command AND CB.Ctl = %IDC_Button2 AND CB.Ctlmsg = %BN_Clicked Then
Shell("notepad.exe", 1) 'waits
MsgBox "Notepad has closed, yes?", , "External App Test"
End If
End Function
'gbs_00061
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm