主题:高手帮忙看一下这段代码。
#COMPILE EXE
TYPE PROCESSENTRY32
dwSize AS LONG
cntUsage AS LONG
th32ProcessID AS LONG
th32DefaultHeapID AS LONG
th32ModuleID AS LONG
cntThreads AS LONG
th32ParentProcessID AS LONG
pcPriClassBase AS LONG
dwFlags AS LONG
szExeFile AS STRING*260
END TYPE
GLOBAL a() AS STRING
DECLARE FUNCTION CreateToolhelpSnapshot LIB "kernel32" ALIAS "CreateToolhelp32Snapshot" (BYVAL dwFlags AS LONG, BYVAL th32ProcessID AS LONG) AS LONG
DECLARE FUNCTION Process32First LIB "kernel32" ALIAS "Process32First" (BYVAL hSnapshot AS LONG, lppe AS PROCESSENTRY32) AS LONG
DECLARE FUNCTION Process32Next LIB "kernel32" ALIAS "Process32Next" (BYVAL hSnapshot AS LONG, lppe AS PROCESSENTRY32) AS LONG
DECLARE FUNCTION CloseHandle LIB "KERNEL32.DLL" ALIAS "CloseHandle" (BYVAL hObject AS DWORD) AS LONG
DECLARE FUNCTION TerminateProcess LIB "KERNEL32.DLL" ALIAS "TerminateProcess" (BYVAL hProcess AS DWORD, BYVAL uExitCode AS DWORD) AS LONG
DECLARE FUNCTION OpenProcess LIB "KERNEL32.DLL" ALIAS "OpenProcess" (BYVAL dwDesiredAccess AS DWORD, BYVAL bInheritHandle AS LONG, BYVAL dwProcessId AS DWORD) AS DWORD
FUNCTION Write_File(BYVAL SaveFile AS STRING ,BYVAL Str AS STRING) AS LONG
OPEN SaveFile FOR APPEND AS #1
PRINT #1,TIME$ & " " & str
CLOSE #1
END FUNCTION
FUNCTION GetRowCount(BYVAL FileName AS STRING,n AS LONG) AS STRING
LOCAL i AS LONG
DIM TempStr AS STRING, FileNumber AS LONG
FileNumber = FREEFILE
OPEN FileName FOR INPUT AS #FileNumber
WHILE NOT EOF(FileNumber)
LINE INPUT #FileNumber, TempStr
i=i + 1
IF i=n THEN FUNCTION= Tempstr:GOTO ex:
WEND
ex:
CLOSE #FileNumber
'GetRowCount = i
END FUNCTION
FUNCTION KillProcess ALIAS "KillprocessA" () EXPORT AS LONG
DIM Proc AS PROCESSENTRY32
DIM Snap AS LONG
DIM ExeName AS STRING
DIM Theloop AS LONG
DIM j AS LONG
DIM str AS STRING
Snap = CreateToolhelpSnapshot(&H1+&H2+&H4+&H8, 0)
Proc.dwSize = LEN(Proc)
Theloop = Process32First(Snap,Proc)
WHILE Theloop <> 0
ExeName = Proc.szExeFile
LOCAL i AS INTEGER
FOR i = 1 TO UBOUND(a, 1)
IF LCASE$(LEFT$(ExeName,INSTR(ExeName, CHR$(0))-1)) = LCASE$(a(i)) THEN
FUNCTION = Proc.th32ProcessID
DIM hProcess AS DWORD
hProcess=OpenProcess(1, 0, Proc.th32ProcessID)
TerminateProcess hProcess,1
Write_File "xbs.log","成功结束进程 " & a(i) & " PID为:" & STR$(Proc.th32ProcessID)
END IF
NEXT
Theloop = Process32Next(BYVAL Snap, Proc)
WEND
FUNCTION = -1
END FUNCTION
FUNCTION PBMAIN() AS LONG
LOCAL s AS STRING
s= GetRowCount("xbs.ini",1)
s=REMOVE$(s,"查杀=")
DIM a(1 TO PARSECOUNT(s,"|"))
PARSE s, a(),"|"
ARRAY SORT a()
IF PARSECOUNT(s,"|")>1 THEN
DO
KillProcess
SLEEP 10
LOOP
END IF
END FUNCTION
[size=6]
[b]麻烦高手来帮我注释一下,感激不尽![/b][/size]
TYPE PROCESSENTRY32
dwSize AS LONG
cntUsage AS LONG
th32ProcessID AS LONG
th32DefaultHeapID AS LONG
th32ModuleID AS LONG
cntThreads AS LONG
th32ParentProcessID AS LONG
pcPriClassBase AS LONG
dwFlags AS LONG
szExeFile AS STRING*260
END TYPE
GLOBAL a() AS STRING
DECLARE FUNCTION CreateToolhelpSnapshot LIB "kernel32" ALIAS "CreateToolhelp32Snapshot" (BYVAL dwFlags AS LONG, BYVAL th32ProcessID AS LONG) AS LONG
DECLARE FUNCTION Process32First LIB "kernel32" ALIAS "Process32First" (BYVAL hSnapshot AS LONG, lppe AS PROCESSENTRY32) AS LONG
DECLARE FUNCTION Process32Next LIB "kernel32" ALIAS "Process32Next" (BYVAL hSnapshot AS LONG, lppe AS PROCESSENTRY32) AS LONG
DECLARE FUNCTION CloseHandle LIB "KERNEL32.DLL" ALIAS "CloseHandle" (BYVAL hObject AS DWORD) AS LONG
DECLARE FUNCTION TerminateProcess LIB "KERNEL32.DLL" ALIAS "TerminateProcess" (BYVAL hProcess AS DWORD, BYVAL uExitCode AS DWORD) AS LONG
DECLARE FUNCTION OpenProcess LIB "KERNEL32.DLL" ALIAS "OpenProcess" (BYVAL dwDesiredAccess AS DWORD, BYVAL bInheritHandle AS LONG, BYVAL dwProcessId AS DWORD) AS DWORD
FUNCTION Write_File(BYVAL SaveFile AS STRING ,BYVAL Str AS STRING) AS LONG
OPEN SaveFile FOR APPEND AS #1
PRINT #1,TIME$ & " " & str
CLOSE #1
END FUNCTION
FUNCTION GetRowCount(BYVAL FileName AS STRING,n AS LONG) AS STRING
LOCAL i AS LONG
DIM TempStr AS STRING, FileNumber AS LONG
FileNumber = FREEFILE
OPEN FileName FOR INPUT AS #FileNumber
WHILE NOT EOF(FileNumber)
LINE INPUT #FileNumber, TempStr
i=i + 1
IF i=n THEN FUNCTION= Tempstr:GOTO ex:
WEND
ex:
CLOSE #FileNumber
'GetRowCount = i
END FUNCTION
FUNCTION KillProcess ALIAS "KillprocessA" () EXPORT AS LONG
DIM Proc AS PROCESSENTRY32
DIM Snap AS LONG
DIM ExeName AS STRING
DIM Theloop AS LONG
DIM j AS LONG
DIM str AS STRING
Snap = CreateToolhelpSnapshot(&H1+&H2+&H4+&H8, 0)
Proc.dwSize = LEN(Proc)
Theloop = Process32First(Snap,Proc)
WHILE Theloop <> 0
ExeName = Proc.szExeFile
LOCAL i AS INTEGER
FOR i = 1 TO UBOUND(a, 1)
IF LCASE$(LEFT$(ExeName,INSTR(ExeName, CHR$(0))-1)) = LCASE$(a(i)) THEN
FUNCTION = Proc.th32ProcessID
DIM hProcess AS DWORD
hProcess=OpenProcess(1, 0, Proc.th32ProcessID)
TerminateProcess hProcess,1
Write_File "xbs.log","成功结束进程 " & a(i) & " PID为:" & STR$(Proc.th32ProcessID)
END IF
NEXT
Theloop = Process32Next(BYVAL Snap, Proc)
WEND
FUNCTION = -1
END FUNCTION
FUNCTION PBMAIN() AS LONG
LOCAL s AS STRING
s= GetRowCount("xbs.ini",1)
s=REMOVE$(s,"查杀=")
DIM a(1 TO PARSECOUNT(s,"|"))
PARSE s, a(),"|"
ARRAY SORT a()
IF PARSECOUNT(s,"|")>1 THEN
DO
KillProcess
SLEEP 10
LOOP
END IF
END FUNCTION
[size=6]
[b]麻烦高手来帮我注释一下,感激不尽![/b][/size]