Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Procedure ShellCallback(hWnd,uMsg,wParam,lParam)
- Define Result = #PB_ProcessPureBasicEvents
- If Not hidden
- SetWindowPos_(*wrapperWnd,#HWND_TOP,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE)
- EndIf
- ProcedureReturn Result
- EndProcedure
- Procedure SpawnShell(file$,param$,dir$,showflag)
- If Left(param$,1)<>" " : param$=" "+param$ : EndIf
- Define Info.STARTUPINFO : Info\cb=SizeOf(STARTUPINFO) : Info\dwFlags=1
- Info\wShowWindow=showflag : Define ProcessInfo.PROCESS_INFORMATION
- If CreateProcess_(@file$,@param$,0,0,0,#NORMAL_PRIORITY_CLASS,0,@dir$,@Info,@ProcessInfo)
- Delay(300) ; just in case
- Define ProcessID = ProcessInfo\dwProcessId
- Define win = FindWindow_(0,0)
- Define pid, WinHandle
- Define time
- Repeat
- While win<>0
- GetWindowThreadProcessId_(win,@pid)
- If pid=ProcessID : WinHandle=win : Break : EndIf
- win=GetWindow_(win,#GW_HWNDNEXT)
- Delay(1)
- time + 1
- If time => 10000
- MessageRequester("rcons","Can't find the handle of the shell! Check whether there's enough rights to access the shell's window.")
- End
- EndIf
- Wend
- Until WinHandle
- Else
- MessageRequester("rcons","Can't run the requested shell! Check your config.")
- EndIf
- ProcedureReturn WinHandle
- EndProcedure
- ; IDE Options = PureBasic 5.00 (Windows - x86)
- ; CursorPosition = 14
- ; Folding = -
- ; EnableXP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement