Mega Code Archive
Sürükle bırak metodu ile bilgi göndermek
//Sürükle bırak metodu ile başka programlara bilgi göndermek...
//...::::::( KORSAN )::::::...\\
uses
ShellAPI;
function MakeDrop(const FileNames: array of string): THandle;
var
I, Size: Integer;
Data: PDragInfoA;
P: PChar;
begin
Size := SizeOf(TDragInfoA) + 1;
for I := 0 to High(FileNames) do
Inc(Size, Length(FileNames[I]) + 1);
Result := GlobalAlloc(GHND or GMEM_SHARE, Size);
if Result <> 0 then
begin
Data := GlobalLock(Result);
if Data <> nil then
try
Data.uSize := SizeOf(TDragInfoA);
P := PChar(@Data.grfKeyState) + 4;
Data.lpFileList := P;
for I := 0 to High(FileNames) do
begin
Size := Length(FileNames[I]);
Move(Pointer(FileNames[I])^, P^, Size);
Inc(P, Size + 1);
end;
finally
GlobalUnlock(Result);
end
else
begin
GlobalFree(Result);
Result := 0;
end;
end;
end;
function MyEnum(Wnd: hWnd; Res: PInteger): Bool; stdcall;
var
N: string;
begin
SetLength(N, MAX_PATH);
SetLength(N, GetClassName(Wnd, Pointer(N), Length(N)));
Result := AnsiCompareText('TEditControl', N) <> 0;
if not Result then Res^ := Wnd;
end;
// Örnek :
procedure TForm1.Button1Click(Sender: TObject);
var
Wnd: HWnd;
Drop: hDrop;
begin
EnumChildWindows(FindWindow('TEditWindow', nil), @MyEnum, Integer(@Wnd));
wnd := FindWindow('notepad', nil);
if IsWindow(Wnd) then
begin
Drop := MakeDrop(['c:\msdos.sys']);
if Drop <> 0 then PostMessage(Wnd, wm_DropFiles, Drop, 0);
GlobalFree(Drop);
end;
end;