IsRunning – System Function






IsRunning Function


Usage

The IsRunning function indicates whether a program is loaded in memory or not. Depending on whether a process is running or not, you can take the appropriate action, for example, kill it.

Syntax

a = IsRunning(<module_name>)

Parameters

  • <module_name>: string which defines the name of the program. If an extension is not included, .EXE is assumed. It can be a constant or a variable; a path can be included in <module_name>, which can be in upper/lower case.

Return Value

a = 1 if the program is loaded, 0 otherwise.

Examples

'Check if Wordpad.exe is running
a = IsRunning("Wordpad") ' Returns 1 if Wordpad.exe is loaded.

'Check if Comdlg32.dll is running
a = IsRunning("Comdlg32.dll") ' Returns 1 if Comdlg32.dll is loaded.

'Check if mfc42.dll in a specific directory is running
prog$ = "c:\taskware\mfc42.dll"
a = IsRunning(prog$) ' Returns 1 if mfc42.dll is loaded (the one in c:\taskware)

'Example of killing Notepad if it is running
Shell("notepad", 1)
If IsRunning("notepad") Then
    KillApp("notepad", 1)
End If