マイネットワーク内に登録されたWEBフォルダのリンク先を取得したいのですがどうしたら良いのでしょうか。
IShellLink.GetPathを使ってみたのですが、空の値が返ってきてしまいます。
どうぞよろしくお願いします。
参考
http://www12.plala.or.jp/srop/html/delphi/delphiutils.html
長らく放置してしまいまして申し訳ありません。
結局さっぱり分からなくて以下のようにして無理やり取得しています。
もっと良いやり方があれば教えてください。
procedure TForm1.Button1Click(Sender: TObject);
var
BrowseInfo: TBrowseInfo;
FolderName, FolderPath: array[0..MAX_PATH] of Char;
pidl: PItemIDList;
lpMalloc: IMalloc;
begin
if FAILED(SHGetMalloc(lpMalloc)) then Exit;
with BrowseInfo do
begin
hwndOwner := Handle;
pidlRoot := PItemIDList(CSIDL_NETWORK);
pszDisplayName := FolderName;
lpszTitle := 'WebDavを選択してください';
ulFlags := BIF_RETURNONLYFSDIRS;
lpfn := nil;
end;
pidl := SHBrowseForFolder(BrowseInfo);
if pidl = nil then exit;
SHGetPathFromIDList(pidl, FolderPath);
lpMalloc.Free(pidl);
Edit1.Text := ReadURLString(FolderPath);
end;
function TForm1.ReadURLString(Path: String): String;
var
fs: TFileStream;
wS: WideString;
i: Integer;
begin
Result := '';
Path := Path + '\target.lnk';
if not FileExists(Path) then Exit;
fs := TFileStream.Create(Path, fmOpenRead)
try
fs.Position := 0;
i := fs.Size;
wS := '';
SetLength(wS, i div 2);
fs.ReadBuffer(wS[1], i);
finally
fs.Free;
end;
i:= Pos('https://', wS);
if i=0 then Exit;
Result := Copy(wS, i, Length(wS)-i-1);
end;
ツイート | ![]() |