日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

一个抓取电脑屏幕的小控件台程序

發布時間:2025/3/20 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 一个抓取电脑屏幕的小控件台程序 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一個抓取電腦屏幕的小控件臺程序
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.Drawing;
using?System.Drawing.Imaging;

namespace?DeskRegistrar
{
????
class?Program
????{
????????
//聲明一個API函數
????????[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
????????
private?static?extern?bool?BitBlt(
?????????????IntPtr?hdcDest,?
//?目標?DC的句柄
?????????????int?nXDest,
?????????????
int?nYDest,
?????????????
int?nWidth,
?????????????
int?nHeight,
?????????????IntPtr?hdcSrc,??
//?源DC的句柄
?????????????int?nXSrc,
?????????????
int?nYSrc,
?????????????System.Int32?dwRop??
//?光柵的處理數值
?????????????);

????????[System.Runtime.InteropServices.DllImportAttribute(
"gdi32.dll")]
????????
private?static?extern?IntPtr?CreateDC(
????????????
string?lpszDriver,???//???驅動名稱???
????????????string?lpszDevice,???//???設備名稱???
????????????string?lpszOutput,???//???無用,可以設定位"NULL"???
????????????IntPtr?lpInitData????//???任意的打印機數據???
????????????);

????????
static?void?Main(string[]?args)
????????{

????????????System.Threading.Timer?timer?
=?new?System.Threading.Timer(delegate(Object?o)
????????????{
????????????????IntPtr?dc1?
=?CreateDC("DISPLAY",?null,?null,?(IntPtr)null);
????????????????
//創建顯示器的DC???
????????????????Graphics?g1?=?Graphics.FromHdc(dc1);
????????????????
//由一個指定設備的句柄創建一個新的Graphics對象???
????????????????Image?MyImage?=?new?Bitmap(Screen.PrimaryScreen.Bounds.Width,?Screen.PrimaryScreen.Bounds.Height,?g1);
????????????????
//根據屏幕大小創建一個與之相同大小的Bitmap對象???
????????????????Graphics?g2?=?Graphics.FromImage(MyImage);
????????????????
//獲得屏幕的句柄???
????????????????IntPtr?dc3?=?g1.GetHdc();
????????????????
//獲得位圖的句柄???
????????????????IntPtr?dc2?=?g2.GetHdc();
????????????????
//把當前屏幕捕獲到位圖對象中???
????????????????BitBlt(dc2,?0,?0,?Screen.PrimaryScreen.Bounds.Width,?Screen.PrimaryScreen.Bounds.Height,?dc3,?0,?0,?13369376);
????????????????
//把當前屏幕拷貝到位圖中???
????????????????g1.ReleaseHdc(dc3);
????????????????
//釋放屏幕句柄???
????????????????g2.ReleaseHdc(dc2);
????????????????
//釋放位圖句柄???
????????????????MyImage.Save(AppDomain.CurrentDomain.BaseDirectory?+?"\\"?+?DateTime.Now.ToString("yyyyMMddHHmmss")?+?".jpg",?ImageFormat.Jpeg);
????????????????
//MessageBox.Show("已經把當前屏幕保存到C:\\MyJpeg.jpg文件中!");?
????????????},?null,?0,?3000);

????????????Console.Read();
????????}
????}
}

轉載于:https://www.cnblogs.com/gleamy_ming/archive/2009/03/20/1418067.html

總結

以上是生活随笔為你收集整理的一个抓取电脑屏幕的小控件台程序的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。