Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How i find a process by the name program in a list of task
Message
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
How i find a process by the name program in a list of task
Divers
Thread ID:
00769530
Message ID:
00769530
Vues:
52
Hi!!!
I need find a process by name in a program of the visual fox pro 7.0, I get a list of the process Id using the external function EnumProcess, in a example of MSDN library i see that can use OpenProcess, enumprocessModules and getModuleBaseName to get a list of process, but this not work correctily, enumprocessmodules return a value equal to 0, this is the code that i use for get a list of process running in the pc.
#include "psapi.h"
DECLARE INTEGER EnumProcesses IN psapi STRING @ lpidProcess, INTEGER cb, INTEGER @ cbNeeded
declare integer OpenProcess in kernel32 integer dwDesiredAccessas, integer bInheritHandle, integer dwProcId
declare integer EnumProcessModules in psapi integer hProcess, string @ lphModule, integer cb, integer @ cbNeeded
declare integer GetModuleBasename in psapi integer hprocess, hModule, string @ lpBaseName, integer nSize

superstring = space(4096)
nb = 4096
enteros = 0
resultado = 0

resultado = EnumProcesses ( @superstring, nb, @enteros )
*? resultado
*? enteros
*? superstring
if resultado != 0
local i, maxpid, car, pos
maxpid = (enteros / 4)
?"Numero maximo de pids", maxpid
dimension car [maxpid]
pos = 1
i = 1
do while (pos <= enteros)
car [i] = substr (superstring, pos, 4)
pos = pos + 4
i = i + 1
enddo
i = 3
local pids, h1, l1, h2, l2
dimension pids [maxpid]
for i = 1 to maxpid
h1 = asc (substr (car [i], 1, 1))
l1 = asc (substr (car [i], 2, 1)) * 256
h2 = asc (substr (car [i], 3, 1)) *512
l2 = asc (substr (car [i], 4, 1)) * 1024
pids [i] = h1+l1 +h2+l2
endfor
local handle
local hmod, bytes, res, namep
*for i= 1 to maxpid
* ? "Pid",pids[i]
*endfor
*wait "espero"
for i= 1 to maxpid
*? "Pid antes ",pids[i]
handle = OpenProcess (1028,0, pids [i])
hmod = space (4096)
if (handle!=0)
? "Pid",pids[i], "Proceso", handle
if EnumProcessModules (handle, @hmod, 4096, @bytes) != 0
namep = space (256)
?GetModuleBasename(handle, hmod, namep, 256)
endif
endif
*wait "espero"
endfor
endif

please anybody can help me!!!
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform