如何在程序中判断快捷方式指向那里

zhhbsan 2000-06-06 03:36:00
...全文
145 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Kingron 2001-05-01
  • 打赏
  • 举报
回复
解决问题要给分

附加功能:提前。
halfdream 2000-06-23
  • 打赏
  • 举报
回复
windoze 的方法是对的。
zyb 2000-06-23
  • 打赏
  • 举报
回复
可以编程查找c:\Windows\Desktop\*.lnk文件,浏览相应属性即可
windoze 2000-06-15
  • 打赏
  • 举报
回复
给你一个C++的例子,自己翻译成Delphi吧,说实在的,20分有点少:)

HRESULT ResolveIt(HWND hwnd, LPCSTR lpszLinkFile, LPSTR lpszPath)
{
HRESULT hres;
IShellLink* psl;
char szGotPath[MAX_PATH];
char szDescription[MAX_PATH];
WIN32_FIND_DATA wfd;

*lpszPath = 0; // assume failure

// Get a pointer to the IShellLink interface.
hres = CoCreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID *) &psl);
if (SUCCEEDED(hres)) {
IPersistFile* ppf;

// Get a pointer to the IPersistFile interface.
hres = psl->QueryInterface(&IID_IPersistFile,
&ppf);
if (SUCCEEDED(hres)) {
WCHAR wsz[MAX_PATH];

// Ensure that the string is Unicode.
MultiByteToWideChar(CP_ACP, 0, lpszLinkFile, -1, wsz,
MAX_PATH);

// Load the shortcut.
hres = ppf->Load(wsz, STGM_READ);
if (SUCCEEDED(hres)) {

// Resolve the link.
hres = psl->Resolve(hwnd, 0);
if (SUCCEEDED(hres)) {

// Get the path to the link target.
hres = psl->GetPath(szGotPath,
MAX_PATH, (WIN32_FIND_DATA *)&wfd,
SLGP_SHORTPATH );
if (FAILED(hres)
HandleErr(hres); // application-defined function

// Get the description of the target.
hres = psl->GetDescription(szDescription, MAX_PATH);
if (FAILED(hres))
HandleErr(hres);
lstrcpy(lpszPath, szGotPath);
}
}
// Release the pointer to the IPersistFile interface.
ppf->Release();
}
// Release the pointer to the IShellLink interface.
psl->Release();
}
return hres;
}

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧