C++解析lnk
来源:互联网 发布:stc单片机串口程序 编辑:程序博客网 时间:2024/06/16 10:01
源代码:
#include <shobjidl.h>#include <shlguid.h>#include <stdio.h>#include <locale.h>static HRESULT ResolveIt(HWND hwnd, TCHAR *lpszLinkFile, TCHAR *lpszPath, int iPathBufferSize) { HRESULT hres; IShellLink* psl; WIN32_FIND_DATA wfd; *lpszPath = 0; // Assume failure // Get a pointer to the IShellLink interface. It is assumed that CoInitialize // has already been called. 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)) { // Add code here to check return value from MultiByteWideChar // for success. // Load the shortcut. hres = ppf->Load(lpszLinkFile, 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(lpszPath, MAX_PATH, (WIN32_FIND_DATA*)&wfd, SLGP_RAWPATH); } } // Release the pointer to the IPersistFile interface. ppf->Release(); } // Release the pointer to the IShellLink interface. psl->Release(); } return hres; }int main(){setlocale(LC_ALL, "chs");TCHAR szLinkFilePath[MAX_PATH] = L"C:\\Documents and Settings\\All Users\\桌面\\腾讯QQ.lnk";TCHAR szLinkFileExePath[MAX_PATH]={0};CoInitialize(NULL);ResolveIt(NULL, szLinkFilePath, szLinkFileExePath, MAX_PATH);wprintf(L"%s\n", szLinkFileExePath);CoUninitialize();return 0;}
- 【C++】关于error LNK 2019 无法解析的外部符号
- C++解析lnk
- 文件格式解析:快捷方式 (LNK文件)
- LNK 2019 LNK 2001 无法解析的外部符号9
- 通过LNK文件(快捷方式)解析出目标文件的路径
- Qt5 【LNK 2019无法解析的外部符号】
- c/c++出现:fatal error LNK 1120:1 unresolved externals
- "链接器工具错误 LNK 2001 无法解析外部符号 __security_cookie " 解决方法
- 关于vs2010 C++编译链接总是出现“LNK:2019 无法解析的外部符号”的问题
- 关于我遇到的“LNK 2019无法解析的外部符号”的链接错误
- C++LNK错误总结(摘抄别人的),留着自已用,哈哈。。。
- c/c++多文件相互调用,为解决ERROR LNK:2005
- VS 2013/08/12 上出现的ERROR LNK 2019 1120 无法解析外部符号的问题
- Error[e12]: Unable to open file 'C:\Program Files\IAR Systems\Embedded Workbench 5.3\8051\config\lnk
- 转 LNK 2005
- Microsoft Office.lnk
- ERROR LNK 2001||2019
- LNK 2001错误
- CRM上线之路 走上了CRM实施顾问-第30天上班 -第七周
- 结构体和类的区别
- VMware vSphere 5.5的12个更新亮点(1)
- 推荐一本编程进阶书籍- 重构:改善既有代码的设计
- 一个操作系统的实现(10):进程间通信
- C++解析lnk
- valgrind 的使用简介
- Android开发之旅:环境搭建及HelloWorld (AVD无法启动,出现Starting emulator for AVD '2.2' PANIC: Could not open: 错误提示)
- MySQL数据库程序设计--学习笔记
- C++中的对象数组
- 玩游戏代表了先进生产力的发展方向
- Proftpd INSTALL翻译(Troubleshoot和Help部分没有翻译)
- VMware vSphere 5.5的12个更新亮点(2)
- awk内置函数