bool sh_get_uiobject( const _ITEMIDLIST * pidl, _ITEMIDLIST ** ppidlPath, _ITEMIDLIST ** ppidlItem, struct IShellFolder **ppsfFolder, const struct _GUID riid, void **pObject ) { *ppidlItem = NULL; *ppsfFolder = NULL; *pObject = NULL; LPITEMIDLIST p = *ppidlPath = duplicateIDlist(pidl); if (NULL == p) return false; //get last shit.emid - the file while (NextID(p)->mkid.cb) p = NextID(p); *ppidlItem = duplicateIDlist(p); p->mkid.cb=0; if (NULL == (*ppsfFolder = sh_get_folder_interface(*ppidlPath))) return false; //fake ITEMIDLIST - array for 1 file object HRESULT hr = (*ppsfFolder)->GetUIObjectOf((HWND)NULL, 1, (LPCITEMIDLIST*)ppidlItem, riid, NULL, pObject); return SUCCEEDED(hr) && NULL != *pObject; }
bool PAP::SendRequest() { TRACE("PAP: SendRequest() state=%d\n", State()); --fRequestCounter; fNextTimeout = system_time() + kPAPTimeout; net_buffer *packet = gBufferModule->create(256); if (!packet) return false; ppp_lcp_packet *request; gBufferModule->append_size(packet, 1492, (void **)&request); const char *username = Interface().Username(), *password = Interface().Password(); uint16 packcketLenth = 6 + strlen(username) + strlen(password); // 6 : lcp header 4 byte + username length 1 byte + password length 1 byte request->code = PPP_CONFIGURE_REQUEST; request->id = fRequestID = NextID(); request->length = htons(packcketLenth); uint8 *data = request->data; data[0] = strlen(username); memcpy(data + 1, username, strlen(username)); data[1 + data[0]] = strlen(password); memcpy(data + 2 + data[0], password, strlen(password)); gBufferModule->trim(packet, packcketLenth); return Interface().Send(packet, PAP_PROTOCOL) == B_OK; }
nsIContent* IDRefsIterator::NextElem() { while (true) { const nsDependentSubstring id = NextID(); if (id.IsEmpty()) break; nsIContent* refContent = GetElem(id); if (refContent) return refContent; } return nsnull; }
IShellFolder* sh_get_folder_interface(LPCITEMIDLIST pIDFolder) { IShellFolder* pShellFolder = NULL; IShellFolder* pThisFolder = NULL; HRESULT hr; hr = SHGetDesktopFolder(&pShellFolder); if (NOERROR != hr) return NULL; if (NextID(pIDFolder) == pIDFolder) return pShellFolder; hr = pShellFolder->BindToObject( pIDFolder, NULL, IID_IShellFolder, (LPVOID*)&pThisFolder); pShellFolder->Release(); if (NOERROR != hr) return NULL; return pThisFolder; }