能力值:
( LV13,RANK:370 )
|
-
-
2 楼
结帖,搞定了
|
能力值:
( LV2,RANK:10 )
|
-
-
3 楼
怎么搞定的?很想知道~~~
|
能力值:
( LV9,RANK:380 )
|
-
-
4 楼
我贴一个吧:
#include <Windows.h>
#include <objbase.h>
#include <stdio.h>
#include <shobjidl.h>
#include <guiddef.h>
#include <shlguid.h>
BOOL GetExePathFromLnk(LPCSTR lpLnkPath,LPSTR buf,int nSize)
{
if (FAILED(CoInitialize(NULL)))
{
return FALSE;
}
BOOL bret=FALSE;
WCHAR wsz[256] = {0};
IShellLink *ps1;
HRESULT hres;
WIN32_FIND_DATA fd;
if(SUCCEEDED(CoCreateInstance(CLSID_ShellLink,NULL,
CLSCTX_INPROC_SERVER,IID_IShellLink,(LPVOID*)&ps1)))
{
IPersistFile *ppf;
//ps1->SetPath(strPathObj);
if(SUCCEEDED(ps1->QueryInterface(IID_IPersistFile,(LPVOID *)&ppf)))
{
MultiByteToWideChar(CP_ACP,0,lpLnkPath,-1,wsz,MAX_PATH);
hres = ppf->Load(wsz,STGM_READ);
if(SUCCEEDED(hres))
hres = ps1->GetPath(buf,nSize,&fd,0);
ppf->Release();
}
ppf->Release();
}
CoUninitialize();
return bret;
}
int main()
{
char lpExePath[256] = {0};
GetExePathFromLnk("F:\\Windows Server 2003 Checked x86 Build Environment.lnk",lpExePath,sizeof(lpExePath));
printf("ExePath:%s\r\n",lpExePath);
return TRUE;
}
|
|
|