Checking The Return Code From An Application Executed In PowerBuilder
Create Structure Object str_startupinfo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
//Structure Object str_startupinfo //ObjectStructure str_startupinfo ULong cb String lpreserved String lpdesktop String lptitle ULong dwx ULong dwy ULong dwxsize ULong dwysize ULong dwxcountchars ULong dwycountchars ULong dwfillattribute ULong dwflags UInt wshowwindow UInt cbreserved2 String lpreserved2 UInt hstdinput UInt hstdoutput UInt hstderror |
Create Structure Object str_startupinfo
1 2 3 4 5 6 7 |
//Structure Object str_processinformation //ObjectStructure str_processinformation UnsignedLong hProcess UnsignedLong hthread Long dwprocessid Long dwthreadid |
Create External Function Prototypes Declaration
1 2 3 4 5 |
//External Function Prototypes Declaration Function Boolean CreateProcess(String AppName, String CommLine, Long l1, Long l2, Boolean binh, Long creationflags, Long l3, String dir, str_startupinfo startupinfo, Ref str_processinformation Pi ) Library 'kernel32.dll' Alias For "CreateProcessW" Function Long WaitForSingleObject ( ULong ul_Notification, Long lmillisecs ) Library "kernel32.dll" Function Long GetExitCodeProcess(ULong hProcess,Ref ULong lpExitCode) Library "kernel32.dll" Function Boolean CloseHandle(ULong h) Library 'kernel32.dll' |
Create PowerScript Function of_runandwait
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
//Function of_runandwait //Function of_runandwait (String as_command, Boolean ab_Visible) returns ULong Constant Long STARTF_USESHOWWINDOW = 1 Constant Long CREATE_NEW_CONSOLE = 16 Constant Long NORMAL_PRIORITY_CLASS = 32 Constant Long INFINITE = -1 Boolean lb_Return Long ll_Null, ll_CreationFlags, ll_Return ULong lul_ProcessReturn String ls_CurDir, ls_Null str_startupinfo lstr_Start str_processinformation lstr_PI SetNull(ll_Null) SetNull(ls_Null) SetNull(ls_CurDir) lstr_Start.cb = 72 lstr_Start.dwflags = STARTF_USESHOWWINDOW If ab_Visible Then lstr_Start.wshowwindow = 1 Else lstr_Start.wshowwindow = 0 End If ll_CreationFlags = CREATE_NEW_CONSOLE + NORMAL_PRIORITY_CLASS lb_Return = CreateProcess (ls_Null, as_command, ll_Null, ll_Null, False, ll_CreationFlags, ll_Null, ls_CurDir, lstr_Start, lstr_PI) ll_Return = WaitForSingleObject (lstr_PI.hProcess, INFINITE) ll_Return = GetExitCodeProcess (lstr_PI.hProcess, lul_ProcessReturn) CloseHandle(lstr_PI.hProcess) CloseHandle(lstr_PI.hthread) Return lul_ProcessReturn |
Good Luck!
Subscribe
Login
0 Comments
Oldest