用c++编写一个程序输出 hello world 运行截屏

用c++编写一个程序输出 hello world 运行截屏,第1张

我用VC++编一个吧,你可以试试

#include "stdafx.h"

#include <iostream>   //使用iostream库,这行必不可少瞎老睁。

#include <stdio.h>

using namespace std  //使用含禅标准名称空间std,这行必不可少,因为cout使用的是这个标准名称空间

void main()  //必须为main方法指定一个反回类型,否则会出错。

{

cout<<"磨岁hello world"<<endl  //使用cout流输出字符。

cin.ignore()   //使程序暂停,如果不要这一行,则输出的结果会在屏幕上闪一下就消失了。

}

诸位不要胡说,看我伍毁的腔局备代码

这是直接用CImage截屏,不需要CBitmap,也不用保存为BMP再转换

BOOL bFull=true//是否截全屏,false则只截取当前活动的窗体

CImage image

CWnd* pWnd

CRect rect

BOOL bStat

if(bFull)

pWnd = CWnd::GetDesktopWindow()

else

pWnd = CWnd::GetActiveWindow()

ASSERT(pWnd)

if(pWnd == NULL)

return FALSE

CWindowDC winDC(pWnd)

pWnd->GetWindowRect(&rect)

int nBPP = winDC.GetDeviceCaps(BITSPIXEL) * winDC.GetDeviceCaps(PLANES)

if(nBPP <24) nBPP = 24

bStat = image.Create(rect.Width(), rect.Height(), nBPP)

ASSERT(bStat)

if(!bStat)

return FALSE

CImageDC imageDC(image)

::BitBlt(imageDC, 0, 0, rect.Width(), rect.Height(), winDC, 0, 0, SRCCOPY)

SYSTEMTIME sys

GetLocalTime(&sys)

m_StaticTime.Format("%4d%02d%02d%02d%02d%02d",sys.wYear,sys.wMonth,sys.wDay,sys.wHour,sys.wMinute,sys.wSecond)

HRESULT hr = image.Save("img\\腊败" + m_StaticTime + ".jpg")


欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/yw/12401767.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-25
下一篇 2023-05-25

发表评论

登录后才能评论

评论列表(0条)

保存