由Ink文件怎样得到该Ink文件的实际Exe路径和名称?急.............有源码提供最好,在线等!!!
解决方案 »
- 类成员函数的问题。
- 预处理问题
- 非模式对话框的创建: 去掉_DEBUG的定义就出问题? AfxFindResourceHandle()函数修改this指针??
- 请高手帮助一下, 小小的问题!
- 如何用TCP方式穿透服务器防火墙
- ***一本书,Numerical Recipes in C++ The Art of Scientific Computing****
- 窗口拆分成了三个部分后,菜单只有在定义了这个菜单函数的View是激活的时候才有效,当另一个View是激活的时候,这个菜单就失效了,请问该
- 【MFC】访问其他类中的控件出错
- 请教串口通讯中接收数据前的延时设置
- 怪事,CreateProcess就是不能成功,大伙帮我看看。
- 加DBT.H头文件后,在其他cpp中使用变量DEV_BROADCAST_DEVICEINTERFACE居然提示未定义
- 在dll中使用MsFlexGrid控件
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, (void**)&ppf);
if (SUCCEEDED(hres))
{
WCHAR wsz[MAX_PATH];
// Ensure that the string is Unicode.
MultiByteToWideChar(CP_ACP, 0, lpszLinkFile, -1, wsz, MAX_PATH);
// TODO: Check return value from MultiByteWideChar to ensure
success.
// 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 (SUCCEEDED(hres))
{
// Get the description of the target.
hres = psl->GetDescription(szDescription, MAX_PATH); if (SUCCEEDED(hres))
{
hres = StringCbCopy(lpszPath, sizeof(lpszPath),
szGotPath);
if (SUCCEEDED(hres))
{
// Handle success
}
else
// application-defined function
HandleErr(hres);
}
}
}
} // Release the pointer to the IPersistFile interface.
ppf->Release();
} // Release the pointer to the IShellLink interface.
psl->Release();
}
return hres;
}记住要先初始化组建。CoInitialize
你的这种方式我试过,但有Bug,你试试看,如果你打开Word的快捷方式,你就发现你打开的不是真正的Word的路径,而只是一个Wrodicon.exe的路径,所以这种方式不行!
你的结果和idAnts(Coil & Nova Since 1985)的一样.有Bug,你试试看,如果你打开Word的快捷方式,你就发现你打开的不是真正的Word的路径,而只是一个Wrodicon.exe的路径,所以这种方式不行!