Advertisement
deseven

rcons-proc

Nov 9th, 2012
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Procedure ShellCallback(hWnd,uMsg,wParam,lParam)
  2.   Define Result = #PB_ProcessPureBasicEvents
  3.   If Not hidden
  4.     SetWindowPos_(*wrapperWnd,#HWND_TOP,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE)
  5.   EndIf
  6.   ProcedureReturn Result
  7. EndProcedure
  8.  
  9. Procedure SpawnShell(file$,param$,dir$,showflag)
  10.   If Left(param$,1)<>" " : param$=" "+param$ : EndIf
  11.   Define Info.STARTUPINFO : Info\cb=SizeOf(STARTUPINFO) : Info\dwFlags=1
  12.   Info\wShowWindow=showflag : Define ProcessInfo.PROCESS_INFORMATION
  13.   If CreateProcess_(@file$,@param$,0,0,0,#NORMAL_PRIORITY_CLASS,0,@dir$,@Info,@ProcessInfo)
  14.     Delay(300) ; just in case
  15.     Define ProcessID = ProcessInfo\dwProcessId
  16.     Define win = FindWindow_(0,0)
  17.     Define pid, WinHandle
  18.     Define time
  19.     Repeat
  20.       While win<>0
  21.         GetWindowThreadProcessId_(win,@pid)
  22.         If pid=ProcessID : WinHandle=win : Break : EndIf
  23.         win=GetWindow_(win,#GW_HWNDNEXT)
  24.         Delay(1)
  25.         time + 1
  26.         If time => 10000
  27.           MessageRequester("rcons","Can't find the handle of the shell! Check whether there's enough rights to access the shell's window.")
  28.           End
  29.         EndIf
  30.       Wend
  31.     Until WinHandle
  32.   Else
  33.     MessageRequester("rcons","Can't run the requested shell! Check your config.")
  34.   EndIf
  35.   ProcedureReturn WinHandle
  36. EndProcedure
  37.  
  38. ; IDE Options = PureBasic 5.00 (Windows - x86)
  39. ; CursorPosition = 14
  40. ; Folding = -
  41. ; EnableXP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement