بعد ان تضع زر على الفورم و Label
ضع use ShlObj, ActiveX
[l]
procedure TForm1.Button1Click(Sender: TObject);
var
IResult:boolean;
BrowseInfo: TBrowseInfo;
ItemIDList: PItemIDList;
ComputerName: array[0..MAX_PATH] of Char;
CompName, Title: string;
WindowList: Pointer;
ShellMalloc: IMalloc;
begin
if Failed(SHGetSpecialFolderLocation(Application.Handle, CSIDL_NETWORK, ItemIDList)) then
raise Exception.Create('Unable open browse computer dialog');
try
FillChar(BrowseInfo, SizeOf(BrowseInfo), 0);
BrowseInfo.hwndOwner := Application.Handle;
BrowseInfo.pidlRoot := ItemIDList;
BrowseInfo.pszDisplayName := ComputerName;
Title := 'l';
BrowseInfo.lpszTitle := PChar(Pointer(Title));
BrowseInfo.ulFlags := BIF_BROWSEFORCOMPUTER;
WindowList := DisableTaskWindows(0);
try
IResult := SHBrowseForFolder(BrowseInfo) <> nil;
finally
EnableTaskWindows(WindowList);
end;
if IResult then CompName := ComputerName;
finally
Label1.caption:= CompName;
if Succeeded(SHGetMalloc(ShellMalloc)) then
ShellMalloc.Free(ItemIDList);
end;
end;
[/l]
وشكرا(*)