//////////////////////////////////////////////////// // return the color bits content of specific bitmap. // pBuf Need height*wid*4 // wupeng BOOL GetBMPBinaryDataEx(PBITMAPINFO pbi, HBITMAP hBMP, HDC hDC, char* pBuf) { ASSERT_NOTNULLRET(pbi, FALSE); ASSERT_NOTNULLRET(pBuf, FALSE); int res = GetDIBits(hDC, hBMP, 0, (WORD)pbi->bmiHeader.biHeight, pBuf, pbi, DIB_RGB_COLORS); ASSERT_NOTZERORET(res, FALSE); return TRUE; }
BOOL DisplayAllPrivileges(HANDLE hToken) { BOOL bResult = FALSE; DWORD dwSize = 0; TOKEN_PRIVILEGES* pTokenPrivilegesInfo = NULL; pTokenPrivilegesInfo = (TOKEN_PRIVILEGES*)RetrieveTokenInformation(hToken, TokenPrivileges, dwSize); ASSERT_NOTNULLRET(pTokenPrivilegesInfo, FALSE); CHAR lpwNameBuf[MAX_PATH] = { 0 }; DWORD bufSize = 0; LUID_AND_ATTRIBUTES *pPrivilegeAttr = NULL; for (UINT i = 0; i < pTokenPrivilegesInfo->PrivilegeCount; ++i) { pPrivilegeAttr = &(pTokenPrivilegesInfo->Privileges[i]); bufSize = MAX_PATH - 1; if (FALSE == LookupPrivilegeNameA("", &(pTokenPrivilegesInfo->Privileges[i].Luid), lpwNameBuf, &bufSize)) { DOLOG("LookupPrivilegeNameW failed ErrorCocde: " + GetLastError()); bResult = FALSE; break; } DOLOG("Privilege Name:" + lpwNameBuf + " , Enable: " + (pPrivilegeAttr->Attributes == SE_PRIVILEGE_ENABLED) + ", Default Enable: " + (pPrivilegeAttr->Attributes == SE_PRIVILEGE_ENABLED_BY_DEFAULT) + ", Remove : " + (pPrivilegeAttr->Attributes == SE_PRIVILEGE_REMOVED) + ", Access: " + (pPrivilegeAttr->Attributes == SE_PRIVILEGE_USED_FOR_ACCESS)); bResult = TRUE; } free(pTokenPrivilegesInfo); return bResult ; }
TypeContainer* C2DimensionFile::GetTypeContaner(const WCHAR* lpwTypeName) { ASSERT_NOTNULLRET(lpwTypeName, NULL); for (int i = 0; i < s_TypeBufferCount; ++i) { if (0 == lstrcmpiW(lpwTypeName, s_TypeBufferString[i].pTypeName)) { return &(s_TypeBufferString[i]); } } return NULL; }
/////////////////////////////////////////////// // pBuf size need to be width*height*4 // wupeng BOOL GetCaptureScreenDCRGBAbitsEx(int& rWidth, int& rHeight, int& rPixelBitSize, char* pBuf) { ASSERT_NOTNULLRET(pBuf, FALSE); HDC compatibleHDC = NULL; HBITMAP compatibleHbitmap = NULL; compatibleHDC = NULL; compatibleHbitmap = NULL; GetCurDisplay(compatibleHDC, compatibleHbitmap); ASSERT_NOTNULLRET(compatibleHDC, FALSE); ASSERT_NOTNULLRET(compatibleHbitmap, FALSE); BITMAPINFO rBmpinfo = { 0 }; GetBitmapInfo(rBmpinfo, compatibleHbitmap); rWidth = rBmpinfo.bmiHeader.biWidth; rHeight = rBmpinfo.bmiHeader.biHeight; rPixelBitSize = rBmpinfo.bmiHeader.biBitCount; BOOL bRes = FALSE; bRes = GetBMPBinaryDataEx(&rBmpinfo, compatibleHbitmap, compatibleHDC, pBuf); ASSERT_NOTFALSERET(bRes, FALSE); DeleteDC(compatibleHDC); DeleteObject(compatibleHbitmap); return true; }