Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 2011
- void* GetScreenShot(void){
- int width, height;
- HDC hdcScreen, hdcCom;
- HBITMAP hbmSnap;
- if((hdcScreen = CreateDC("DISPLAY", NULL, NULL, NULL))==NULL){
- return NULL;
- }
- if((hdcCom = CreateCompatibleDC(hdcScreen))==NULL){
- DeleteDC(hdcScreen);
- return NULL;
- }
- width = GetDeviceCaps(hdcScreen, HORZRES);
- height = GetDeviceCaps(hdcScreen, VERTRES);
- if((hbmSnap = CreateCompatibleBitmap(hdcScreen, width, height))==NULL){
- DeleteDC(hdcCom);
- DeleteDC(hdcScreen);
- return NULL;
- }
- if(SelectObject(hdcCom, hbmSnap)==NULL
- || !BitBlt(hdcCom, 0, 0, width, height, hdcScreen, 0, 0, SRCCOPY)){
- DeleteObject(hbmSnap);
- DeleteDC(hdcCom);
- DeleteDC(hdcScreen);
- return NULL;
- }
- DeleteDC(hdcCom);
- DeleteDC(hdcScreen);
- return hbmSnap;
- }
- // 2015
- HBITMAP __WDECL CaptureScreenBitmap(void)
- {
- bool bSuccess = false;
- HBITMAP hBmp;
- HDC hDC, hBmpDC;
- if((hDC = CreateDC("DISPLAY", NULL, NULL, NULL))!=NULL)
- {
- if((hBmpDC = CreateCompatibleDC(hDC))!=NULL)
- {
- SIZE Sz = { GetDeviceCaps(hDC, HORZRES), GetDeviceCaps(hDC, VERTRES) };
- if((hBmp = CreateCompatibleBitmap(hDC, Sz.cx, Sz.cy))!=NULL)
- {
- HGDIOBJ hPrevBmp = SelectObject(hBmpDC, hBmp);
- if(BitBlt(hBmpDC, 0, 0, Sz.cx, Sz.cy, hDC, 0, 0, SRCCOPY))
- {
- bSuccess = true;
- }
- SelectObject(hBmpDC, hPrevBmp);
- if(!bSuccess)
- {
- DeleteObject(hBmp);
- hBmp = NULL;
- }
- }
- DeleteDC(hBmpDC);
- }
- DeleteDC(hDC);
- }
- return hBmp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement