MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / PathGetLnkPath

Function PathGetLnkPath

src/Helpers.c:1009–1041  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// Name: PathGetLnkPath() Purpose: Try to get the path to which a lnk-file is linked Manipulates: pszResPath

Source from the content-addressed store, hash-verified

1007// Manipulates: pszResPath
1008//
1009BOOL PathGetLnkPath ( LPCWSTR pszLnkFile, LPWSTR pszResPath, int cchResPath )
1010{
1011 IShellLink *psl;
1012 WIN32_FIND_DATA fd;
1013 BOOL bSucceeded = FALSE;
1014 if ( SUCCEEDED ( CoCreateInstance ( &CLSID_ShellLink, NULL,
1015 CLSCTX_INPROC_SERVER,
1016 &IID_IShellLink, &psl ) ) ) {
1017 IPersistFile *ppf;
1018 if ( SUCCEEDED ( psl->lpVtbl->QueryInterface ( psl, &IID_IPersistFile, &ppf ) ) ) {
1019 WORD wsz[MAX_PATH];
1020 /*MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,
1021 pszLnkFile,-1,wsz,MAX_PATH);*/
1022 lstrcpy ( wsz, pszLnkFile );
1023 if ( SUCCEEDED ( ppf->lpVtbl->Load ( ppf, wsz, STGM_READ ) ) ) {
1024 if ( NOERROR == psl->lpVtbl->GetPath ( psl, pszResPath, cchResPath, &fd, 0 ) ) {
1025 bSucceeded = TRUE;
1026 }
1027 }
1028 ppf->lpVtbl->Release ( ppf );
1029 }
1030 psl->lpVtbl->Release ( psl );
1031 }
1032 // This additional check seems reasonable
1033 if ( !lstrlen ( pszResPath ) ) {
1034 bSucceeded = FALSE;
1035 }
1036 if ( bSucceeded ) {
1037 ExpandEnvironmentStringsEx ( pszResPath, cchResPath );
1038 PathCanonicalizeEx ( pszResPath );
1039 }
1040 return ( bSucceeded );
1041}
1042
1043
1044///////////////////////////////////////////////////////////////////////////////

Callers 5

PathIsLnkFileFunction · 0.85
PathIsLnkToDirectoryFunction · 0.85
OpenWithDlgFunction · 0.85
MsgCommandFunction · 0.85
_FileLoadFunction · 0.85

Calls 5

PathCanonicalizeExFunction · 0.85
QueryInterfaceMethod · 0.80
LoadMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected