HRESULT hr = S_OK; ULONG celtFetched; LPITEMIDLIST pidlItems = NULL; LPITEMIDLIST netItemIdLst = NULL; IShellFolder* pPrinterFolder = NULL; IEnumIDList* pEnumIds = NULL; IMalloc* pMalloc = NULL; IShellFolder* pDesktopFolder = NULL; CoInitializeEx( NULL, 0 ); hr = SHGetMalloc( &pMalloc ); hr = SHGetDesktopFolder( &pDesktopFolder ); hr = SHGetSpecialFolderLocation( NULL, CSIDL_PRINTERS, &netItemIdLst ); hr = pDesktopFolder->BindToObject( netItemIdLst, NULL, IID_IShellFolder, (void **)&pPrinterFolder ); if ( SUCCEEDED( hr ) ) { hr = pPrinterFolder->EnumObjects( NULL, SHCONTF_NONFOLDERS, &pEnumIds ); if ( SUCCEEDED( hr ) ) { STRRET strDisplayName; while ( ( hr = pEnumIds->Next( 1, &pidlItems, &celtFetched ) ) == S_OK && celtFetched > 0 ) { hr = pPrinterFolder->GetDisplayNameOf( pidlItems, SHGDN_NORMAL, &strDisplayName ); if ( SUCCEEDED( hr ) ) { // used pidlItems for the IShellLink::SetIDList } } } }
netItemIdLst
pidlItems
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)