/** * Determines if the the system's elevation type allows * unprmopted elevation. * * @param isUnpromptedElevation Out parameter which specifies if unprompted * elevation is allowed. * @return TRUE if the user can actually elevate and the value was obtained * successfully. */ BOOL IsUnpromptedElevation(BOOL &isUnpromptedElevation) { if (!UACHelper::CanUserElevate()) { return FALSE; } LPCWSTR UACBaseRegKey = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"; HKEY baseKey; LONG retCode = RegOpenKeyExW(HKEY_LOCAL_MACHINE, UACBaseRegKey, 0, KEY_READ, &baseKey); if (retCode != ERROR_SUCCESS) { return FALSE; } DWORD consent, secureDesktop; BOOL success = GetDWORDValue(baseKey, L"ConsentPromptBehaviorAdmin", consent); success = success && GetDWORDValue(baseKey, L"PromptOnSecureDesktop", secureDesktop); isUnpromptedElevation = !consent && !secureDesktop; RegCloseKey(baseKey); return success; }
CStdString OfflineDocIDResolver::ResolveToOnlineDocID(const CStdString &sOfflineDocID, const CStdString &sCurrentUserName) const { CStdString sOfflineDocNum = GetDocNum( sOfflineDocID ); CStdString sVersion = GetVersion( sOfflineDocID ); CStdString sOfflineLibrary = sCurrentUserName; CStdString sOnlineLibrary = GetOnlineLibrary( sOfflineDocID, sOfflineLibrary ); CStdString sKey = GetAttacheLocation() + _T("\\") + sOnlineLibrary + _T("\\") + sOfflineLibrary + _T("\\") + sOfflineDocNum; DWORD dwOnlineDocNumber = GetDWORDValue(sKey, _T("DocNumber")); if(dwOnlineDocNumber == -1) { CStdString sErr = _T("Could not ResolveToOnlineDocID : ") + sOfflineDocID + _T("for user : "******"%d"), dwOnlineDocNumber ); CStdString sNewDocID(_T("powerdocs://")); sNewDocID += sOnlineLibrary; sNewDocID += _T("/") + sOnlineDocNumber; sNewDocID += _T("/") + sVersion; OfflineDataStore ods; if(!ods.IsDocOffline(sNewDocID)) return _T("offline://") + sOfflineDocID; return _T("offline://") + sNewDocID; }
bool OfflineDocIDResolver::SearchOfflineLibrary(const CStdString& sLibraryToSearch, const CStdString& sDocNum, CStdString& sOfflineDocKey ) const { CRegKey key; if( key.Open(HKEY_CURRENT_USER, sLibraryToSearch) != ERROR_SUCCESS ) { CStdString sErr = _T("Failed to Open Key : HKCU\\") + sLibraryToSearch; LOG_WS_ERROR(sErr.c_str()); return false; } DWORD dwIndex = 0; long lResult = ERROR_SUCCESS; while((lResult == ERROR_SUCCESS || lResult == ERROR_MORE_DATA)) { DWORD dwLength =MAX_PATH; lResult = key.EnumKey(dwIndex , sOfflineDocKey.GetBuffer(MAX_PATH), &dwLength , NULL); sOfflineDocKey.ReleaseBuffer(); if(lResult == ERROR_NO_MORE_ITEMS) return false; DWORD dw = GetDWORDValue(sLibraryToSearch + _T("\\") + sOfflineDocKey, _T("DocNumber")); CStdString str; str.Format( _T("%d"), dw ); if( str == sDocNum ) return true; dwIndex++; } return false; }
int IsRegisterDxva() { DWORD noDxvaDecoder = GetDWORDValue( HKEY_LOCAL_MACHINE, FFDSHOW_REG_PARENT _l("\\") FFDSHOW, _l("noDxvaDecoder"), 0); return !noDxvaDecoder; }