Home » U++ Library support » U++ Core » Symlink/Shortcut support
Re: Symlink/Shortcut support [message #24860 is a reply to message #24830] |
Mon, 01 February 2010 21:40   |
 |
fudadmin
Messages: 1321 Registered: November 2005 Location: Kaunas, Lithuania
|
Ultimate Contributor Administrator |
|
|
Hi guys, sorry for big breaks but life sometimes make crude corrections... But I've never stopped working on u++. Hopefully I'll to start posting my contributions if... ok, we will see. And, sorry, I've had symlink in my u++ version for windows for some time.
Some of my code if that helps:
bool FindFile::IsShellLinkDir() const //aris002 wrong name? tmp
{
if (!GetName().EndsWith(".lnk")) //aris002 shell we check ext somewhere outside?
return false;
// char linkpath[MAX_PATH];
LPCSTR linkpath=~path;
LLOG("IsShellLinkDir getname="<<GetName());
char szGotPath[MAX_PATH];
char szDescription[MAX_PATH];
// WIN32_FIND_DATA wfd;
HRESULT hres;
IShellLink* psl;
CoInitialize(NULL);
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, (LPVOID *) &psl);
if(SUCCEEDED(hres)) {
IPersistFile* ppf;
psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
if(SUCCEEDED(hres)) {
WCHAR szPath[_MAX_PATH] = { 0 };
MultiByteToWideChar(CP_ACP, 0, linkpath, (int)strlen(linkpath), szPath, _MAX_PATH);
//not correct? - might be links with diffrerent extensions
//get shortcuts extension from registry? how?
hres = ppf->Load(szPath, STGM_READ); //Load the shortcut.
if (SUCCEEDED(hres)) {
// LLOG("ppf->Load ok!! "<<linkpath);
hres = psl->GetPath((LPSTR)szGotPath, MAX_PATH,
NULL, SLGP_UNCPRIORITY );
LLOG("name "<<GetName()<<" target "<<szGotPath);
// if(SUCCEEDED(hres))
// LLOG("SUCCEEDED link ");
ppf->Release();
}
psl->Release();
}
}
CoUninitialize();
if(SUCCEEDED(hres)) {
LLOG("SUCCEEDED2 link ");
return true;
}
else
return false;
//return SUCCEEDED(hres);
}
bool ResolveShellLink(const String& path, String& linked) //aris002
{
// char linkpath[MAX_PATH];
LPCSTR linkpath=path;
LLOG("IsShellLinkDir getname="<<path);
char szGotPath[MAX_PATH];
HRESULT hres;
IShellLink* psl;
CoInitialize(NULL);
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, (LPVOID *) &psl);
if(SUCCEEDED(hres)) {
IPersistFile* ppf;
psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
if(SUCCEEDED(hres)) {
WCHAR szPath[_MAX_PATH] = { 0 };
MultiByteToWideChar(CP_ACP, 0, linkpath, (int)strlen(linkpath), szPath, _MAX_PATH);
//not correct? - might be links with diffrerent extensions
//get shortcuts extension from registry? how?
hres = ppf->Load(szPath, STGM_READ); //Load the shortcut.
if (SUCCEEDED(hres)) {
// LLOG("ppf->Load ok!! "<<linkpath);
hres = psl->GetPath((LPSTR)szGotPath, MAX_PATH,
NULL, SLGP_UNCPRIORITY );
LLOG("name "<<linkpath<<" target "<<szGotPath);
linked=szGotPath;
// if(SUCCEEDED(hres))
// LLOG("SUCCEEDED link ");
ppf->Release();
}
psl->Release();
}
}
CoUninitialize();
if(SUCCEEDED(hres)) {
LLOG("SUCCEEDED2 RESOLVED link ");
return true;
}
else
return false;
//return SUCCEEDED(hres);
}
they are not optimal and might need above or somewhere else switching off the check of target existance if I can remember.
Below the whole files attached.
P.S I've got also adapted for older version of FileSel for those with icon overlays. And, sorry i don't use svn because because that's too dificult for me, esp, merging.
Huge thanks to all of you!
-
Attachment: Path.h
(Size: 8.85KB, Downloaded 354 times)
-
Attachment: Path.cpp
(Size: 29.86KB, Downloaded 292 times)
|
|
|
 |
|
Symlink/Shortcut support
By: koldo on Mon, 01 February 2010 08:02
|
 |
|
Re: Symlink/Shortcut support
By: mirek on Mon, 01 February 2010 14:42
|
 |
|
Re: Symlink/Shortcut support
By: koldo on Mon, 01 February 2010 15:49
|
 |
|
Re: Symlink/Shortcut support
|
 |
|
Re: Symlink/Shortcut support
By: koldo on Mon, 01 February 2010 16:24
|
 |
|
Re: Symlink/Shortcut support
By: fudadmin on Mon, 01 February 2010 21:40
|
 |
|
Re: Symlink/Shortcut support
By: mirek on Mon, 01 February 2010 22:29
|
 |
|
Re: Symlink/Shortcut support
By: mirek on Fri, 05 February 2010 10:22
|
 |
|
Re: Symlink/Shortcut support
By: mirek on Fri, 05 February 2010 10:25
|
 |
|
Re: Symlink/Shortcut support
By: koldo on Fri, 05 February 2010 11:42
|
 |
|
Re: Symlink/Shortcut support
By: mirek on Sat, 06 February 2010 12:49
|
 |
|
Re: Symlink/Shortcut support
By: mirek on Sat, 06 February 2010 13:20
|
 |
|
Re: Symlink/Shortcut support
By: koldo on Sat, 06 February 2010 14:30
|
 |
|
Re: Symlink/Shortcut support
By: mirek on Sat, 06 February 2010 19:40
|
 |
|
Re: Symlink/Shortcut support
By: koldo on Sat, 06 February 2010 23:13
|
 |
|
Re: Symlink/Shortcut support
By: mirek on Sat, 06 February 2010 23:19
|
 |
|
Re: Symlink/Shortcut support
By: mirek on Sat, 06 February 2010 23:26
|
Goto Forum:
Current Time: Sat May 03 15:10:31 CEST 2025
Total time taken to generate the page: 0.00348 seconds
|