Created
February 3, 2017 03:16
-
-
Save drewchapin/bec133b678822212891f2b2fd167be3c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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