Gerenciador de Tarefas do Windows - Kill Exe, List Exe, Priority Exe
// Summary: Fills the treeview table of processes
// Syntax:
//Table_Fill ()
//
// Parameters:
// None
// Return value:
// None
//
PROCEDURE Table_Fill()
sListProcesses is string
sAProcess is string
nTableSubscript is int
// Clears the table
TableDeleteAll(TH_List)
// Modifies the image
TH_List..CollapsedImage = IMG_Process
TH_List..ExpandedImage = IMG_Process
// Retrieves the list of processes
sListProcesses = ExeListProcess(exePID, exeShortName, exeLongName, exeCommandLine, exeMemory, exeMaxMemory)
// Browses the lists of processes
FOR EACH STRING sAProcess OF sListProcesses SÉPARÉE BY CR
// Each process contains the following information
// ID <TAB> NAME <TAB> EXECUTABLE PATH <TAB> COMMAND LINE <TAB> MEMORY <TAB> MAX MEMORY
// Adds the process to the table
nTableSubscript = TableAddLine(TH_List, ExtractString(sAProcess, 2, TAB),
ExtractString(sAProcess, 1, TAB),
ExeInfo(exeVersion,ExtractString(sAProcess, 3, TAB)),
fExtractPath(ExtractString(sAProcess, 3, TAB), fDrive+fDirectory),
ExtractString(sAProcess, 4, TAB),
ExtractString(sAProcess, 5, TAB),
ExtractString(sAProcess, 6, TAB))
// Defines a procedure that will be called when expanding the node to display the dependencies
TH_List[nTableSubscript]..AddChildDelayed = Table_FillDelayedChild
END
// Collapses the rows
TableCollapseAll(TH_List)
// Sorts the table by name of process
TableSort(TH_List, TH_List.SET_NAME..Name)
//--------------------------------------------------------------------------------------------------
// Summary: Displays information about the selected process
// Syntax:
//Process_Info ()
//
// Parameters:
// None
// Return value:
// None
//
PROCEDURE Process_Info()
nProcessSubscript is int
sProcessPath is string
// Checks whether a process is selected
IF TH_List = -1 THEN
// Error message
Error("No process was selected.")
RETURN
END
// Retrieves the subscript of the process
nProcessSubscript = Process_GiveSubscript()
sProcessPath = TH_List[nProcessSubscript].SET_DIRECTORY+["\"]+TH_List[nProcessSubscript].SET_NAME
sModel is string = [
Copyright: %1
Description: %2
Mode: %3
Name: %4
Directory: %5
Version : %6
Version (standard Windows format): %7
Company: %8
]
InfoBuild(sModel,
ExeInfo(exeCopyright, sProcessPath),
ExeInfo(exeDescription, sProcessPath),
ExeInfo(exeMode, sProcessPath),
ExeInfo(exeName, sProcessPath),
ExeInfo(exeDirectory, sProcessPath),
ExeInfo(exeVersion, sProcessPath),
ExeInfo(exeVersionWindowsFormat, sProcessPath),
ExeInfo(exeCompany, sProcessPath))
//----------------------------------------------------------------------------------
// Summary: Ends a process
// Syntax:
//Process_End ()
//
// Parameters:
// None
// Return value:
// None
//
PROCEDURE Process_End()
nProcessSubscript is int
// Checks whether a process is selected
IF TH_List = -1 THEN
// Error message
Error("No process was selected.")
RETURN
END
// Retrieves the subscript of the process
nProcessSubscript = Process_GiveSubscript()
// Ends the application
IF ExeTerminate(COL_ID[nProcessSubscript]) THEN
ToastDisplay("Application ended", toastShort, vaMiddle, haCenter)
// If the application was successfully ended, deletes the corresponding row
TableDelete(TH_List, nProcessSubscript)
ELSE
// Unable to stop the process.
Error("Unable to end this process", ErrorInfo(errMessage))
END
//-------------------------------------------------------------------------------------------------------
// Summary: Modifies the priority of a process
// Syntax:
//Process_ChangePriority (<nPriority> is int)
//
// Parameters:
// nPriority (integer): Priority to apply
// Return value:
// None
//
PROCEDURE Process_ChangePriority(LOCAL nPriority is int)
nProcessSubscript is int
// Retrieves the subscript of the process
nProcessSubscript = Process_GiveSubscript()
// Changes the priority of the process
ExePriority(TH_List[nProcessSubscript], nPriority)
// Update the information
ExecuteProcess(TH_List, trtSelection)
//------------------------------------------------------------------------------------------
// Summary: Returns information about the current executable
// Syntax:
//Process_GetPID ()
//
// Parameters:
// None
// Return value:
// None
//
PROCEDURE Process_GetPID()
sModel is string = [
Information about the current process:
PID: %1
Parent PID: %2
TID: %3
]
// Displays information about the current process
InfoBuild(sModel, ExeGetPID(exePID), ExeGetPID(exeParentPID), ExeGetPID(exeTID))
//------------------------------------------------------------------------------------------------------------------------------
// Summary: Displays the number of process occurrences
// Syntax:
//Process_Run ()
//
// Parameters:
// None
// Return value:
// None
//
PROCEDURE Process_Run()
nProcessSubscript is int
sMessage is string
// Retrieves the subscript of the process
nProcessSubscript = Process_GiveSubscript()
// Returns the number of process occurrences according to its PID, name and full path
sMessage = StringBuild("Is the application with ""%1"" PID in execution: %2", TH_List.COL_ID[nProcessSubscript], ExeRunning(TH_List.COL_ID[nProcessSubscript]) ? "YES" ELSE "NO")
sMessage += CR + StringBuild("Is the ""%1"" executable in execution: %2 execution(s).", TH_List.SET_NAME[nProcessSubscript], ExeRunning(TH_List.SET_NAME[nProcessSubscript]))
sMessage += CR + StringBuild("Is the ""%1"" executable in execution: %2 execution(s).", TH_List.SET_DIRECTORY[nProcessSubscript]+TH_List.SET_NAME[nProcessSubscript], ExeRunning(TH_List.SET_DIRECTORY[nProcessSubscript]+TH_List.SET_NAME[nProcessSubscript]))
// Update the information
Info(sMessage)