Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create shortcut link on the Quick Launch bar? 1

Status
Not open for further replies.

dc2000

Programmer
Jun 7, 2005
48
US
Hello everybody:

Does anyone know how to create a shortcut link on the Windows Quick Launch bar? (That is the one next to Start button)

I found lots of documentation about Desktop, Start Menu, but nothing about Quick Launch. Any ideas will be greatly appreciated!
 
Hello dc2000. I am sure you would want the simpiliest way to do this so here it goes...

Make a shortcut of the application that you want to show in your quick launch bar on your desktop. Now drag that shortcut icon over the quick launch toolbar. That is all.
 
hooka, i think he means programmatically.

anyway, the quick launch feature is just a folder in the users area, so create a shortcut in that folder.

C:\Documents and Settings\username\Application Data\Microsoft\Internet Explorer\Quick Launch\


If somethings hard to do, its not worth doing - Homer Simpson
 
Yes, definitely programmatically :) So what you say is to simply create a link in that folder? Without use of any function like SHGetSpecialFolderLocation? Will it be portable to other versions of Windows?
 
ok, here is some very rough and ready code.

if you use it make sure you add some error handling

Code:
#include <stdio.h>
#include <shlobj.h>

void main(void)
{
	LPITEMIDLIST pidl;
	HRESULT hr = SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl);

	if (SUCCEEDED(hr))
	{
		// Convert the item ID list's binary
		// representation into a file system path
		char szPath[_MAX_PATH];

		if (SHGetPathFromIDList(pidl, szPath))
		{
			//must call CoInitialise
			HRESULT hrcI = CoInitialize(NULL);
			if (SUCCEEDED(hrcI))
			{
				IShellLink* psl;
				sprintf(szPath,"%s\\Microsoft\\Internet Explorer\\Quick Launch\\calc.lnk",szPath);

				// Get a pointer to the IShellLink interface. 
				HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, 
									IID_IShellLink, (PVOID *) &psl); 
	
				if (SUCCEEDED(hres)) 
				{ 
					IPersistFile* ppf; 
		
					// Set the path to the shortcut target and add the 
					// description. 
					psl->SetPath("C:\\WINDOWS\\system32\\Calc.exe"); 
					psl->SetWorkingDirectory("C:\\WINDOWS\\system32");
					psl->SetDescription("Calculator"); 
				
					// Query IShellLink for the IPersistFile interface for saving the 
					// shortcut in persistent storage. 
					hres = psl->QueryInterface(IID_IPersistFile, (PVOID *) &ppf); 
				
					if (SUCCEEDED(hres)) 
					{ 
						WORD wsz[MAX_PATH]; 
					
						// Ensure that the string is ANSI. 
						MultiByteToWideChar(CP_ACP, 0, (LPCSTR) szPath, -1, wsz, MAX_PATH); 
					
						// Save the link by calling IPersistFile::Save. 
						hres = ppf->Save(wsz, TRUE); 
						ppf->Release(); 
					} 
					psl->Release(); 
				} 
				//if we initialised it, we gotta CoUninitialise it
				CoUninitialize();
			}
		}
	}
}

this will add a shortcut for the windows calculator to your quicklaunch bar.

it assumes the quicklaunch bar is active for the particular user, a few moifications will be needed to make it work with 9x machines.

THIS IS DEMO CODE ONLY, USE AT OWN RISK!

If somethings hard to do, its not worth doing - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top