Api pour se servir du processus

sat2213 Messages postés 2 Date d'inscription mardi 2 novembre 2004 Statut Membre Dernière intervention 2 juillet 2006 - 2 juil. 2006 à 19:22
drikce06 Messages postés 2236 Date d'inscription lundi 29 mai 2006 Statut Membre Dernière intervention 29 mai 2008 - 6 juil. 2006 à 17:06
Bonjour

j'ai chercher sur plein de site comment me servir des api pour me servir de processus. mes je n'ai rien trouver enfin aucun tuto sur openprocess , terminateprocess ect... est ce que quelq'un pourrait me donner un site ou il y a des tuto sur c'est api car même en regardent les source de vbfrance je n'arrive pas a comprendre comment c'est api marche. merci d'avance

7 réponses

cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 27
2 juil. 2006 à 19:38
 Bonjour ,

Avec WMI,
ci-dessous 2 exemples:

dim strComputer,objWMIService,colProcesses,objProcess,ProcessTime,strCreationDate,user,Domain,strOwner,h,m,s,chaine
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery ("Select * from Win32_Process")        ' where Name='IEXPLORE.EXE'
Chaine="Process     |Creation Date Time |Handles|Threads|Owner              |Priority|MemoryUsage|MaxMemUsage|MemRequired|MaxMemRequi|       Swap|   Max Swap|CPU time|PID |PFaults|Path" & vbCrLf
For Each objProcess in colProcesses
        If objProcess.GetOwner ( User, Domain ) = 0 Then
                strOwner= Domain & "" & User
        Else
                strOwner="Unknown"
        End If
        ProcessTime=(CSng(objProcess.KernelModeTime) + CSng(objProcess.UserModeTime)) / 10000000
        h=right("0" & fix(ProcessTime/60/60),2)
        ProcessTime=ProcessTime-h*60*60
        m=right("0" & fix(ProcessTime/60),2)
        s=Right("0" & round(ProcessTime-m*60),2)
        strCreationDate=Mid(objProcess.CreationDate,7,2) & "/" & Mid(objProcess.CreationDate,5,2) & "/" & Left(objProcess.CreationDate,4) & " " & Mid(objProcess.CreationDate,9,2) & ":" & Mid(objProcess.CreationDate,11,2) & ":" & Mid(objProcess.CreationDate,13,2)
        If strCreationDate="// ::" Then strCreationDate=Space(19)
        Chaine=Chaine &  Left(objProcess.Name & space(8),12) & "|" _
                & strCreationDate & "|" & Right(Space(6) & objProcess.HandleCount,7) & "|" _
                & Right(Space(6) & objProcess.ThreadCount,7) & "|" _
                & Left(strOwner & space(14),19) & "|" _
                & Left(objProcess.Priority & Space(7),8) & "|" _
                & Right(Space(10) & objProcess.PageFileUsage ,11) & "|" _
                & Right(Space(10) & objProcess.PeakPageFileUsage ,11) & "|" _
                & Right(Space(8) & objProcess.WorkingSetSize ,11) & "|" _
                & Right(Space(8) & objProcess.PeakWorkingSetSize ,11) & "|" _
                & Right(Space(10) & objProcess.VirtualSize ,11) & "|" _
                & Right(Space(10) & objProcess.PeakVirtualSize ,11) & "|" _
                & h & ":" & m & ":" & s & "|" _
                & Left(objProcess.ProcessID & space(3),4) & "|"  _
                & Right(Space(6) & objProcess.PageFaults ,7) & "|" & objProcess.ExecutablePath
        Chaine=Chaine & vbCrLf
Next

'==================================================================
'Arrêt d'un Process
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\" _
    & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
    ("Select * from Win32_Process Where Name = 'excel.exe'")
For Each objProcess in colProcessList
    objProcess.Terminate()
Next


Set objWMIService = Nothing
Set colProcessList = Nothing


'WScript.Quit


Sub delayedSendKeys(str)
     WScript.Sleep 100
     WshShell.SendKeys str
End Sub




'Activer un Process
Dim WshShell, oCalc, oNotepad
Set WshShell = CreateObject("WScript.Shell")
Set oCalc = WshShell.Exec("calc")
Set oNotepad = WshShell.Exec("notepad")
WScript.Sleep 500


WshShell.AppActivate oCalc.ProcessID
delayedSendKeys "1{+}1~"
delayedSendKeys "^C"
delayedSendKeys "%{F4}"


WshShell.AppActivate oNotepad.ProcessID
delayedSendKeys "1 {+} 1 = ^V"

jean-marc
0
sat2213 Messages postés 2 Date d'inscription mardi 2 novembre 2004 Statut Membre Dernière intervention 2 juillet 2006
2 juil. 2006 à 21:19
ah oui mes la c'est du fso si je me trompe pas oui c'est vrai j'aver pas penser qu'on pouver utiliser du fso  merci bien. bon si vous aver quand meme des tuto sur les api que je cherche donne les moi svp .
0
cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 27
2 juil. 2006 à 21:25
 Bonsoir,

WSH vous permet de facilement utiliser WMI (Windows Management Instrumentation).
Remarque   Pour plus d'informations sur WMI, reportez-vous au SDK (kit de développement) de WMI qui se trouve à l'adresse http://www.microsoft.com/france/msdn.

jean-marc
0
mortalino Messages postés 6786 Date d'inscription vendredi 16 décembre 2005 Statut Membre Dernière intervention 21 décembre 2011 18
2 juil. 2006 à 23:36
Salut,

DarkSidious possède une source sur les principales APIs en français :

http://www.vbfrance.com/codes/AIDE-SUR-PRINCIPALES-API_4514.aspx

@++

--Mortalino--
Le Mystérieux Chevalier "Provençal, le Gaulois"
N'oubliez pas de lire le règlement !
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
zavier666 Messages postés 266 Date d'inscription mardi 7 septembre 2004 Statut Membre Dernière intervention 30 avril 2009 1
6 juil. 2006 à 16:54
tu peux essayer http://xav.prog.power.free.fr rubrique kernel32

slts!
0
drikce06 Messages postés 2236 Date d'inscription lundi 29 mai 2006 Statut Membre Dernière intervention 29 mai 2008 10
6 juil. 2006 à 17:01
Salut http://www.allapi.net/

 Drikce 06
0
drikce06 Messages postés 2236 Date d'inscription lundi 29 mai 2006 Statut Membre Dernière intervention 29 mai 2008 10
6 juil. 2006 à 17:06
sinon j'ai téléchargé un pti prog sur le net qui donne toutes les fonction api et des exemples mais je sais plus ou!
c'est API-Guide 3.7
http://www.devhood.com/Tools/tool_details.aspx?tool_id=563

 Drikce 06
0
Rejoignez-nous