You'll have to create the "one button" GUI to execute the Shortcut function. Also, you'll have to verify that the network path to the executable, JPGopener.exe is available. Finally, Creating File Associations
Creating desktop shortcut sample:
Code:
// Compile as follows:
// CL /MT MyCode.cpp ole32.lib
#include <afxole.h>
#include <shlobj.h>
HRESULT Shortcut(const CString ExecutableName, const CString ExecutableArguments, const CString
LinkName)
{
HRESULT hres;
CString Desktop=getenv("USERPROFILE"); //Get the path to the desktop
Desktop += "\\Desktop\\";
CString Link = Desktop + LinkName;
IShellLink* pIShellLnk;
hres = CoInitialize(NULL);
hres = CoCreateInstance(CLSID_ShellLink,
NULL,
CLSCTX_INPROC_SERVER,
IID_IShellLink,
(LPVOID*) &pIShellLnk);
IPersistFile* pIPersist;
pIShellLnk->SetPath(ExecutableName);
pIShellLnk->SetArguments(ExecutableArguments);
hres = pIShellLnk->QueryInterface( IID_IPersistFile,
(LPVOID *) &pIPersist);
if (SUCCEEDED(hres))
{
CString Temp = Link;
Temp.MakeLower();
if (Temp.Find(".lnk")==-1)
Link += ".lnk";
WORD wString[MAX_PATH];
MultiByteToWideChar(CP_ACP,
MB_PRECOMPOSED,
Link,
-1,
wString,
MAX_PATH);
hres = pIPersist->Save(wString, TRUE);
pIPersist->Release();
}
else
pIShellLnk->Release();
return hres;
}
int main(void)
{
Shortcut("notepad.exe", "", "My Notepad");
return 0;
}