GetTasks() Function
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Fri Oct 16, 2015 2:55 pm
by Maurizio
Antonio
I have to close a program (that is in Try Icon Bar )
I tryed with
GetTasks() but the program is not in the list , but if I open task manger insted it is.
Thank in anticipation
Maurizio
www.nipesetvice.com
Re: GetTasks() Function
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Fri Oct 16, 2015 4:15 pm
by Antonio Linares
Maurizio,
You could try with the old FWH function
GetTasks():
- Code: Select all Expand view
#include "FiveWin.ch"
#define GHW_HWNDFIRST 0
#define GHW_HWNDNEXT 2
#define GWW_HINSTANCE -6
//----------------------------------------------------------------------------//
function GetTasks()
local hWnd := GetWindow( GetActiveWindow(), GHW_HWNDFIRST )
local aTasks := {}
local cTask
while hWnd != 0
#ifdef __CLIPPER__
cTask = GetModuleFileName( GetWindowWord( hWnd, GWW_HINSTANCE ) )
#else
// cTask = GetModuleFileName( GetWindowLong( hWnd, GWW_HINSTANCE ) )
cTask = GetWindowText( hWnd ) // The above does now work :-(
#endif
if AScan( aTasks, cTask ) == 0
AAdd( aTasks, cTask )
endif
hWnd = GetWindow( hWnd, GHW_HWNDNEXT )
end
return aTasks
//----------------------------------------------------------------------------//
#define HKEY_CURRENT_USER 2147483649
#define REG_DWORD 4
function SetTaskManager( lOnOff ) // Enables/Disables Ctrl+Alt+Del
local hKey := 0
if lOnOff
RegCreateKey( HKEY_CURRENT_USER,;
"Software\Microsoft\Windows\CurrentVersion\Policies\System", @hKey )
RegSetValue( hKey, "DisableTaskMgr", 0, REG_DWORD, L2BIN( 0 ), 4 )
RegCloseKey( hKey )
else
RegCreateKey( HKEY_CURRENT_USER,;
"Software\Microsoft\Windows\CurrentVersion\Policies\System", @hKey )
RegSetValue( hKey, "DisableTaskMgr", 0, REG_DWORD, L2BIN( 1 ), 4 )
RegCloseKey( hKey )
endif
return nil
DLL32 static FUNCTION REGCREATEKEY( hKey AS LONG, cSubKey AS LPSTR, @nHandle AS ;
PTR ) AS LONG PASCAL FROM "RegCreateKeyA" LIB "advapi32.dll"
DLL32 static FUNCTION REGSETVALUE( hKey AS LONG, cValueName AS LPSTR, nReserved AS ;
LONG, nType AS DWORD, cData AS LPSTR, nData AS DWORD ) AS LONG ;
PASCAL FROM "RegSetValueExA" LIB "advapi32.dll"
DLL32 static FUNCTION REGCLOSEKEY( hKey AS LONG ) AS LONG ;
PASCAL FROM "RegCloseKey" LIB "advapi32.dll"
Re: GetTasks() Function
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Fri Oct 16, 2015 6:39 pm
by stefano
Non ricordo dove l'ho trovato ...
KillProcess("menu.exe")
FUNCTION KillProcess( cExe )
local oWmi, oList, oProc
oWmi := WmiService()
oList := oWmi:ExecQuery( "select * from Win32_Process where Name = '" + cExe + "'" )
for each oProc in oList
oProc:Terminate()
next
return nil
FUNCTION WMIService()
// It would be useful to keep this function in the library
static oWMI
local oLocator
if oWMI == nil
oLocator := CREATEOBJECT( "wbemScripting.SwbemLocator" )
oWMI := oLocator:ConnectServer()
endif
return oWMI
Stefano
Re: GetTasks() Function
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Mon Oct 19, 2015 9:43 am
by Maurizio
Thank Antonio and Stefano
they both work
Maurizio
www.nipeservice.com