在第一次启动时调用下面的函数由用户输入,输入完后可以保存到注册
表或者INI文件中以便下次启动时直接使用
uses
ShlObj;
function GetNetComputerName : string;
var
BrowseInfo: TBrowseInfo;
IDRoot
ItemIDList;
Path: array[0..MAX_PATH] of Char;
begin
// Get the Item ID for Network Neighborhood
SHGetSpecialFolderLocation(Application.Handle,CSIDL_NETWORK,IDRoot);
ZeroMemory(@BrowseInfo,SizeOf(TBrowseInfo));
ZeroMemory(@path, MAX_PATH);
BrowseInfo.hwndOwner := Application.Handle;
BrowseInfo.pidlRoot := IDRoot;
//BrowseInfo.lpszTitle := '';
BrowseInfo.pszDisplayName := @path;
// Include this flag to show computer only
BrowseInfo.ulFlags := BIF_BROWSEFORCOMPUTER;// or BIF_RETURNONLYFSDIRS ;
// Show the browse dialog, get the Item ID for the selected item and convert it to a path
SHBrowseForFolder(BrowseInfo);
// SHGetPathFromIDList(IDList, Path);
result := Path;
end;