src/Helpers.c
bool PathCreateFavLnk(LPCWSTR pszName,LPCWSTR pszTarget,LPCWSTR pszDir)
{

  WCHAR tchLnkFileName[MAX_PATH] = { L'\0' };

  IShellLink *psl;
  bool bSucceeded = false;

  if (StrIsEmpty(pszName)) { return true; }

  StringCchCopy(tchLnkFileName,COUNTOF(tchLnkFileName),pszDir);
  PathCchAppend(tchLnkFileName,COUNTOF(tchLnkFileName),pszName);
  StringCchCat(tchLnkFileName,COUNTOF(tchLnkFileName),L".lnk");

  if (PathFileExists(tchLnkFileName))
    return false;

  if (SUCCEEDED(CoCreateInstance(&CLSID_ShellLink,NULL,
                                 CLSCTX_INPROC_SERVER,
                                 &IID_IShellLink,(void**)&psl)))
  {
    IPersistFile *ppf;

    if (SUCCEEDED(psl->lpVtbl->QueryInterface(psl,&IID_IPersistFile,(void**)&ppf)))
    {
      WORD wsz[MAX_PATH] = { L'\0' };

      /*MultiByteToWideCharEx(CP_ACP,MB_PRECOMPOSED,tchLnkFileName,-1,wsz,MAX_PATH);*/
      StringCchCopy(wsz,COUNTOF(wsz),tchLnkFileName);

      psl->lpVtbl->SetPath(psl,pszTarget);

      if (SUCCEEDED(ppf->lpVtbl->Save(ppf,wsz,true)))
        bSucceeded = true;

      ppf->lpVtbl->Release(ppf);
    }
    psl->lpVtbl->Release(psl);
  }

  return(bSucceeded);

}
///////////////////////////////////////////////////////////////////////////////
//
//
//  Name: PathCreateFavLnk()
//
//  Purpose: Modified to create a Notepad2 favorites link
//
//  Manipulates:
//
PathCreateFavLnk()
Purpose: Modified to create a Notepad2 favorites link


PathCreateFavLnk () Purpose : Modified to create a Notepad2 favorites link
bool PathCreateFavLnk(LPCWSTR pszName,LPCWSTR pszTarget,LPCWSTR pszDir)
{
  WCHAR tchLnkFileName[MAX_PATH] = { L'\0' };
  IShellLink *psl;
  bool bSucceeded = false;
  if (StrIsEmpty(pszName)) { return true; }
  StringCchCopy(tchLnkFileName,COUNTOF(tchLnkFileName),pszDir);
  PathCchAppend(tchLnkFileName,COUNTOF(tchLnkFileName),pszName);
  StringCchCat(tchLnkFileName,COUNTOF(tchLnkFileName),L".lnk");
  if (PathFileExists(tchLnkFileName))
    return false;
  if (SUCCEEDED(CoCreateInstance(&CLSID_ShellLink,NULL,
                                 CLSCTX_INPROC_SERVER,
                                 &IID_IShellLink,(void**)&psl)))
  {
    IPersistFile *ppf;
    if (SUCCEEDED(psl->lpVtbl->QueryInterface(psl,&IID_IPersistFile,(void**)&ppf)))
    {
      WORD wsz[MAX_PATH] = { L'\0' };
      StringCchCopy(wsz,COUNTOF(wsz),tchLnkFileName);
      psl->lpVtbl->SetPath(psl,pszTarget);
      if (SUCCEEDED(ppf->lpVtbl->Save(ppf,wsz,true)))
        bSucceeded = true;
      ppf->lpVtbl->Release(ppf);
    }
    psl->lpVtbl->Release(psl);
  }
  return(bSucceeded);
}
bool PathCreateFavLnk ( LPCWSTR pszName , LPCWSTR pszTarget , LPCWSTR pszDir ) { WCHAR tchLnkFileName [ MAX_PATH ] = { L' \0 ' } ; IShellLink * psl ; bool bSucceeded = false ; if ( StrIsEmpty ( pszName ) ) { return true ; } StringCchCopy ( tchLnkFileName , COUNTOF ( tchLnkFileName ) , pszDir ) ; PathCchAppend ( tchLnkFileName , COUNTOF ( tchLnkFileName ) , pszName ) ; StringCchCat ( tchLnkFileName , COUNTOF ( tchLnkFileName ) , L" " ) ; if ( PathFileExists ( tchLnkFileName ) ) return false ; if ( SUCCEEDED ( CoCreateInstance ( & CLSID_ShellLink , NULL , CLSCTX_INPROC_SERVER , & IID_IShellLink , ( void * * ) & psl ) ) ) { IPersistFile * ppf ; if ( SUCCEEDED ( psl -> lpVtbl -> QueryInterface ( psl , & IID_IPersistFile , ( void * * ) & ppf ) ) ) { WORD wsz [ MAX_PATH ] = { L' \0 ' } ; StringCchCopy ( wsz , COUNTOF ( wsz ) , tchLnkFileName ) ; psl -> lpVtbl -> SetPath ( psl , pszTarget ) ; if ( SUCCEEDED ( ppf -> lpVtbl -> Save ( ppf , wsz , true ) ) ) bSucceeded = true ; ppf -> lpVtbl -> Release ( ppf ) ; } psl -> lpVtbl -> Release ( psl ) ; } return ( bSucceeded ) ; }
Name: PathCreateFavLnk()
Purpose: Modified to create a Notepad2 favorites link
Name : PathCreateFavLnk () Purpose : Modified to create a Notepad2 favorites link
/*MultiByteToWideCharEx(CP_ACP,MB_PRECOMPOSED,tchLnkFileName,-1,wsz,MAX_PATH);*/