Espion Processus est un petit soft qui permet d'éspionner les processus qui s'ouvre et de les inscrire dans un fichier.
OS de Développement : Windows 7 intégrale
OS Compatible : Tous ceux sous windows avec le framework 4.
Lien de téléchargement : http://www.box.net/shared/4gk05llmtr
Et voici la source :
Code:
Imports System.Runtime.InteropServices.MarshalModule Module1
Sub Main()
Dim classINI As New ComINI
Dim myProcesses() As Process
Dim myProcess As Process
Dim j As Integer = 0
Dim i As Integer = 0
Dim k As Integer = 1
myProcesses = Process.GetProcesses()
Dim tableauProcess(100) As String
For Each myProcess In myProcesses
Dim Nom As String = myProcess.ProcessName
tableauProcess(j) = Nom
j = j + 1
classINI.SetCle(".\ProcessORIGINE.txt", "Process en cours", "Process" & j, Nom)
Next
tableauProcess(j + 1) = "dllhost"
Console.ForegroundColor = ConsoleColor.White
Console.WriteLine("Test en cours")
While 1
myProcesses = Process.GetProcesses
For Each myProcess In myProcesses
Dim Nom As String = myProcess.ProcessName
If Not tableauProcess.Contains(Nom) Then
i = i + 1
Console.ForegroundColor = ConsoleColor.Green
Console.WriteLine("Processus changé, nom inscrit dans le fichier Processus" & k & ".txt, ligne : " & Date.Now.ToLongTimeString & ", nom : " & Nom)
Console.ForegroundColor = ConsoleColor.White
Console.WriteLine("Recherche en cours...")
classINI.SetCle(".\Processus" & k & ".txt", "Processus ajoutés", Date.Now.ToLongTimeString, Nom)
If i > 49 Then
k = k + 1
i = 0
Console.ForegroundColor = ConsoleColor.Red
Console.WriteLine("Nouveau fichier créé (Processus" & k & ".txt).")
Console.ForegroundColor = ConsoleColor.White
Console.WriteLine("Recherche en cours...")
End If
End If
Next
j = 0
For Each myProcess In myProcesses
tableauProcess(j) = myProcess.ProcessName
j = j + 1
Next
tableauProcess(j + 1) = "dllhost"
End While
End Sub
End Module
Public Class ComINI
Private Declare Function GetPrivateProfileSection Lib "kernel32.dll" Alias "GetPrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedBuffer As IntPtr, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
Private Declare Function GetPrivateProfileSectionNames Lib "kernel32.dll" Alias "GetPrivateProfileSectionNamesA" (ByVal lpszReturnBuffer As IntPtr, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
Private Declare Function GetPrivateProfileString Lib "kernel32.dll" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedBuffer As IntPtr, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
Private Declare Function WritePrivateProfileSection Lib "kernel32.dll" Alias "WritePrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpString As String, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32.dll" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Long
'Retourne un booléen indiquant l'existance ou non d'une section
Public Function ExisteSection(ByVal File As String, ByVal Section As String) As Boolean
Dim PtrCh As IntPtr
Dim Lng As Integer
PtrCh = StringToHGlobalAnsi(New String(vbNullChar, 1024))
Lng = GetPrivateProfileSection(Section, PtrCh, 1024, File)
Return Lng
End Function
'Retourne une collection contenant l'ensemble des sections du fichier "File"
Public Function GetAllSections(ByVal File As String) As Collection
Dim PtrCh As IntPtr
Dim Sections As Collection
Dim I, Lng As Integer
Dim Chaine, SChaine As String
PtrCh = StringToHGlobalAnsi(New String(vbNullChar, 1024))
Lng = GetPrivateProfileSectionNames(PtrCh, 1024, File)
Chaine = PtrToStringAnsi(PtrCh, Lng)
FreeHGlobal(PtrCh)
Sections = New Collection
SChaine = ""
For I = 0 To Lng - 1
If Chaine.Chars(I) = vbNullChar Then
Sections.Add(SChaine)
SChaine = ""
Else
SChaine = SChaine & Chaine.Chars(I)
End If
Next
GetAllSections = Sections
Sections = Nothing
End Function
'Retourne une collection contenant l'ensemble des clés de la section "Section" du fichier "File"
Public Function GetSectionCles(ByVal File As String, ByVal Section As String) As Collection
Dim PtrCh As IntPtr
Dim Cles As Collection
Dim I, Lng As Integer
Dim Chaine, SChaine As String
PtrCh = StringToHGlobalAnsi(New String(vbNullChar, 1024))
Lng = GetPrivateProfileSection(Section, PtrCh, 1024, File)
Chaine = PtrToStringAnsi(PtrCh, Lng)
FreeHGlobal(PtrCh)
Cles = New Collection
SChaine = ""
For I = 0 To Lng - 1
If Chaine.Chars(I) = vbNullChar Then
Cles.Add(SChaine)
SChaine = ""
Else
SChaine = SChaine & Chaine.Chars(I)
End If
Next
GetSectionCles = Cles
Cles = Nothing
End Function
'Retourne la valeur de la clé "Cle" de la section "Section" du fichier "File"
Public Function GetCle(ByVal File As String, ByVal Section As String, ByVal Cle As String) As String
Dim PtrCh As IntPtr
Dim Lng As Integer
Dim Chaine As String
PtrCh = StringToHGlobalAnsi(New String(vbNullChar, 1024))
Lng = GetPrivateProfileString(Section, Cle, "", PtrCh, 255, File)
Chaine = PtrToStringAnsi(PtrCh, Lng)
FreeHGlobal(PtrCh)
GetCle = Chaine
End Function
'Insère une section dans le fichier "File"
Public Function SetSection(ByVal File As String, ByVal Section As String, ByVal Valeur As String) As Boolean
SetSection = WritePrivateProfileSection(Section, Valeur, File)
End Function
'Insère la clé "Cle" dans la section "Section" du fichier "File"
Public Function SetCle(ByVal File As String, ByVal Section As String, ByVal Cle As String, ByVal Valeur As String) As Boolean
SetCle = WritePrivateProfileString(Section, Cle, Valeur, File)
End Function
'Efface toute les clés de la section "Section"
Public Function DelSection(ByVal File As String, ByVal Section As String) As Boolean
DelSection = WritePrivateProfileSection(Section, "", File)
End Function
'Efface la valeur de la clé "Cle" de la section "Section"
Public Function DelCle(ByVal File As String, ByVal Section As String, ByVal Cle As String) As Boolean
DelCle = WritePrivateProfileString(Section, Cle, "", File)
End Function
End Class
Je n'ai pas créée la classe comINI, voici l'endroit ou je l'ai trouvé : http://www.vbfrance.com/codes/MANIPULATION-FICHIERS-INI-VB-NET_35975.aspx
Edit : Je trouve cette façon d'afficher les codes vraiment très moche
