Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:39 pm
by allistar >> Tue, 10 Sep 2002 20:58:45 GMT
Hi there,
You can do this easily in C++ like this: (sorry about poor
formatting).
IShellLink* pLink;
IPersistFile* pPersistFile;
// First, we have to initialize the COM library
if(SUCCEEDED(CoInitialize(NULL)))
{
// If CoInitialize doesn't fail, then instantiate an
// IShellLink object by calling CoCreateInstance.
if(SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER,
IID_IShellLink, (void **)
&pLink)))
{
// if that succeeds, then fill in the shortcut attributes
pLink->SetPath(file.c_str());
pLink->SetDescription("Woo hoo, look at Homer's
shortcut");
pLink->SetShowCmd(SW_SHOW);
// Now we need to save the shortcut to the hard drive. The
// IShellLink object also implements the IPersistFile interface.
// Get the IPersistFile part of the object using QueryInterface.
if(SUCCEEDED(pLink->QueryInterface(IID_IPersistFile,
(void
**)&pPersistFile)))
{
// If that succeeds, then call the Save method of the
// IPersistFile object to write the shortcut to the desktop.
WideString strShortCutLocation("C:\\bcbshortcut.lnk");
pPersistFile->Save(strShortCutLocation.c_bstr(),
TRUE);
pPersistFile->Release();
}
pLink->Release();
}
// Calls to CoInitialize need a corresponding CoUninitialize
call
CoUninitialize();
}
It would very easy to put this into a .dll that you could then call
from Jade as an external function.
Regards,
Allistar.
------------------------------------------------------------------
Allistar Melville
Software Developer
Auckland, NEW ZEALAND
Greentree International,
Developer of Greentree Financial Software. ------------------------------------------------------------------