CONST ProcessLow=-2
CONST ProcessBelowNormal=-1
CONST ProcessNormal=0
CONST ProcessHight=2
CONST ProcessAboveNormal=1
CONST ProcessTimeCritical=15
CONST ProcessIdle=-15
$IFNDEF __WIN32API
DECLARE FUNCTION CreateProcess LIB "kernel32" ALIAS "CreateThread" (lpThreadAttributes AS LONG, BYVAL dwStackSize AS LONG, lpStartAddress AS LONG, lpParameter AS LONG, BYVAL dwCreationFlags AS LONG, lpThreadId AS LONG) AS LONG
DECLARE FUNCTION TerminateProcess LIB "kernel32" ALIAS "TerminateThread" (BYVAL hThread AS LONG, BYVAL dwExitCode AS LONG) AS LONG
DECLARE FUNCTION GetProcessPriority LIB "kernel32" ALIAS "GetThreadPriority" (hThread AS LONG) AS LONG
DECLARE FUNCTION SetProcessPriority LIB "kernel32" ALIAS "SetThreadPriority" (hThread AS LONG,nPriority AS LONG) AS LONG
$ENDIF
DECLARE SUB OnProcess_event
TYPE QProcess EXTENDS QOBJECT
Private:
IdProcess AS LONG
hProcess AS LONG
Public:
OnProcess AS EVENT(OnProcess_event)
Priority AS LONG PROPERTY SET SetPriority
PROPERTY SET SetPriority(priority AS LONG)
this.priority=priority
END PROPERTY
Private:
SUB Process
IF This.OnProcess<>0 THEN CALLFUNC this.OnProcess
END SUB
Public:
SUB OPEN
DIM PtVar AS LONG
DIM PtSub AS LONG
IF this.hProcess<>0 THEN TerminateProcess(this.hProcess,0)
PtVar=VARPTR(this.IdProcess)
PtSub=CODEPTR(this.Process)
this.hProcess=CreateProcess(0,0,PtSub,0,0,PtVar)
SetProcessPriority(this.hProcess,this.Priority)
END SUB
SUB CLOSE
IF this.hProcess<>0 THEN TerminateProcess(this.hProcess,0)
END SUB
CONSTRUCTOR
priority=0
IdProcess=0
hProcess=0
END CONSTRUCTOR
END TYPE
|