dobra, więc mam kodzik, który z założenia powinien działać, ale nie działa! co jest z nim nie tak?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, CommCtrl;
type
PInfo = ^TInfo;
TInfo = packed record
InfoPoint: TPoint;
InfoText: array[0..255] of Char;
InfoItem: TLVItem;
InfoFindInfo: TLVFindInfo;
end;
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Info: PInfo;
Desktop: THandle;
Count, I: Integer;
function GetDesktopListViewHandle: THandle;
var
S: String;
begin
Result := FindWindow('ProgMan', nil);
Result := GetWindow(Result, GW_CHILD);
Result := GetWindow(Result, GW_CHILD);
SetLength(S, 40);
GetClassName(Result, PChar(S), 39);
if PChar(S) 'SysListView32' then Result := 0;
end;
begin
Desktop:=GetDesktopListViewHandle;
If Desktop=0 then
Exit;
Count:=ListView_GetItemCount(Desktop);
GetMem(Info, SizeOf(TInfo));
try
ZeroMemory(Info, SizeOf(TInfo));
with Info^ do
begin
InfoItem.pszText:=InfoText;
InfoItem.cchTextMax := 255;
InfoItem.mask := LVIF_TEXT;
try
for I:=0 to Count-1 do
begin
InfoItem.iItem:=I;
try
ListView_GetItem(Desktop, InfoItem);
ListView_GetItemPosition(Desktop, I, InfoPoint);
except
Application.MessageBox('Something is wrong!', 'Exception!', MB_OK);
end;
end;
except
Application.MessageBox('Something is wrong!', 'Exception!', MB_OK);
end;
end;
finally
FreeMem(Info);
end;
end;
Gdy nacise na buttona od razu Explorer pada na nieprawidłwym wywołaniu funkcji z commctrl.dll a następnie (po zresetowaniu explorer.exe) wali sie o nieprawidłowe dojście do okna, co w tym jest źle?