Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#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();
}
}
}
}