Skip to content

Instantly share code, notes, and snippets.

@drewchapin
Created February 3, 2017 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drewchapin/bec133b678822212891f2b2fd167be3c to your computer and use it in GitHub Desktop.
Save drewchapin/bec133b678822212891f2b2fd167be3c to your computer and use it in GitHub Desktop.
#include <Windows.h>
#include <ShObjIdl.h>
#include <iostream>
int main(int argc, char* argv[])
{
HRESULT hResult = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
if( SUCCEEDED(hResult) )
{
IShellItem* pItem;
hResult = SHCreateItemFromParsingName(TEXT("C:\\Users\\glsp168\\AppData\\Roaming\\Microsoft\\Internet Explorer\\Quick Launch\\User Pinned\\TaskBar\\Notepad.lnk"),
NULL, IID_PPV_ARGS(&pItem));
DWORD dwError = GetLastError();
if( SUCCEEDED(hResult) )
{
IStartMenuPinnedList* pPinnedList;
hResult = CoCreateInstance(CLSID_StartMenuPin, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pPinnedList));
if( SUCCEEDED(hResult) )
{
if( SUCCEEDED(pPinnedList->RemoveFromList(pItem)) )
std::cout << "RemoveFromList() succeeded!\n";
else
std::cerr << "RemoveFromList() failed\n";
pPinnedList->Release();
}
else
std::cerr << "CoCreateInstance() failed\n";
pItem->Release();
}
else
std::cerr << "SHCreateItemFromParsingName() failed\nError: " << dwError << std::endl;;
CoUninitialize();
}
else
std::cerr << "CoInitializeEx() failed" << std::endl;
std::getchar();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment