Вниз
Скачать: CL | DM;

AV в API callback   Найти похожие ветки 

← →
RWolf ©   (2011-02-16 12:08) [0]

Что не так в нижеприведённом коде?

procedure EnumerateWindows(const sl: TStrings);
 function EnumWindowProc(Handle: THandle; lParam: integer): BOOL; stdcall;
 var
   nread: DWORD;
   buf: array[1..256] of Char;
   wt: string;
 begin
   result := True;
   nread := GetWindowText(Handle, @buf, 256);
   if nread <> 0 then begin
     SetLength(wt, nread);
     move(buf[1], wt[1], nread);
     sl.Add(wt);
   end;
 end;
begin
 sl.Clear;
 EnumWindows(@EnumWindowProc, 0);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 EnumerateWindows(memo1.Lines);
end;


---------------------------
"Access violation at address 004504CE in module "Project1.exe". Read of address 000000A0".
---------------------------


← →
clickmaker ©   (2011-02-16 12:14) [1]

nread := GetWindowTextLength(Handle);
SetLength(wt, nread);
GetWindowText(Handle, PChar(wt), nread);


← →
DiamondShark ©   (2011-02-16 12:52) [2]

Вложенную функцию как колбэк передавать?
Свежо.


← →
RWolf ©   (2011-02-16 12:55) [3]


> DiamondShark ©   (16.02.11 12:52) [2]

нормально; это я не подумал, что стек сдвинется.
Передача контекста (т.е. sl) через параметр EnumWindows"а помогла.



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.005 c
6-1237314496
ID_23587A5E
2009-03-17 21:28
2011.05.22
Unit WinInet , проблема с InternetCloseHandle


2-1297232556
SKIPtr
2011-02-09 09:22
2011.05.22
переключение между TEdit


2-1297437090
NieL
2011-02-11 18:11
2011.05.22
Out of memory while expanding memory stream


1-1245744723
dmitry_12_08_73
2009-06-23 12:12
2011.05.22
Как выделить нужный файл в открываемой папке?


15-1297231514
Volodq
2011-02-09 09:05
2011.05.22
Возмещение морального вреда!




   Наверх