Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
fudadmin is currently offline  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 353 times)
  • Attachment: Path.cpp
    (Size: 29.86KB, Downloaded 291 times)
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: T* Detach() for ArrayMap
Next Topic: XmlParser patch
Goto Forum:
  


Current Time: Sat May 03 02:15:53 CEST 2025

Total time taken to generate the page: 0.00683 seconds