uses shlobj, activex;
function NetComputer: string;
var
info: _browseinfoA;
pidl: PItemIDList;
im: IMalloc;
p: PChar;
begin
result := '';
if SHGetSpecialFolderLocation(Application.Handle, CSIDL_NETWORK, pidl) = 0
then begin
getmem(p, max_path);
zeromemory(@info, SizeOf(info));
try
with info do begin
hwndOwner := Application.Handle;
pidlRoot := pidl;
pszDisplayName := p;
lpszTitle := 'Netzwerkcomputer';
ulFlags := BIF_BROWSEFORCOMPUTER;
end;
if SHBrowseForFolder(info) <> nil
then result := '\\' + p;
except
end;
if Succeeded(SHGetMalloc(im)) then
im.Free(pidl);
freemem(p);
end;
end;
// Beispielaufruf
procedure TForm1.Button1Click(Sender: TObject);
var
computer: string;
begin
computer := NetComputer;
if computer <> '' then
showmessage(computer);
end;