保持带图标的桌面截图
来源:互联网 发布:手游服务端源码 编辑:程序博客网 时间:2024/05/01 16:23
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
private int _X, _Y;
[StructLayout(LayoutKind.Sequential)]
private struct ICONINFO
{
public bool fIcon;
public Int32 xHotspot;
public Int32 yHotspot;
public IntPtr hbmMask;
public IntPtr hbmColor;
}
[StructLayout(LayoutKind.Sequential)]
private struct CURSORINFO
{
public Int32 cbSize;
public Int32 flags;
public IntPtr hCursor;
public Point ptScreenPos;
}
[DllImport("user32.dll", EntryPoint = "GetSystemMetrics")]
private static extern int GetSystemMetrics(int mVal);
[DllImport("user32.dll", EntryPoint = "GetCursorInfo")]
private static extern bool GetCursorInfo(ref CURSORINFO cInfo);
[DllImport("user32.dll", EntryPoint = "CopyIcon")]
private static extern IntPtr CopyIcon(IntPtr hIcon);
[DllImport("user32.dll", EntryPoint = "GetIconInfo")]
private static extern bool GetIconInfo(IntPtr hIcon, out ICONINFO iInfo);
private Bitmap CaptureDesktop()//抓取带鼠标的桌面
{try
{
int _CX = 0, _CY = 0;
Bitmap _Source = new Bitmap(GetSystemMetrics(0), GetSystemMetrics(1));
using (Graphics g = Graphics.FromImage(_Source))
{
g.CopyFromScreen(0, 0, 0, 0, _Source.Size);
g.DrawImage(CaptureCursor(ref _CX, ref _CY), _CX, _CY);
g.Dispose();
}
_X = (800 - _Source.Width) / 2;
_Y = (600 - _Source.Height) / 2;
return _Source;
}
catch
{
return null;
}
}
private Bitmap CaptureCursor(ref int _CX, ref int _CY)
{
IntPtr _Icon;
CURSORINFO _CursorInfo = new CURSORINFO();
ICONINFO _IconInfo;
_CursorInfo.cbSize = Marshal.SizeOf(_CursorInfo);
if (GetCursorInfo(ref _CursorInfo))
{
if (_CursorInfo.flags == 0x00000001)
{
_Icon = CopyIcon(_CursorInfo.hCursor);
if (GetIconInfo(_Icon, out _IconInfo))
{
_CX = _CursorInfo.ptScreenPos.X - _IconInfo.xHotspot;
_CY = _CursorInfo.ptScreenPos.Y - _IconInfo.yHotspot;
return Icon.FromHandle(_Icon).ToBitmap();
}
}
}
return null;
}
- 保持带图标的桌面截图
- PHP设为桌面的代码 保存到桌面带图标的方法
- 保存到桌面、设为桌面且带图标的PHP代码
- 桌面应用图标带数目红点
- 带鼠标的屏幕截图
- 删除桌面的“回收站”图标
- 显示桌面的图标恢复
- 找回返回桌面的图标
- 桌面的快捷方式图标异常
- 带图标的button
- 带图标的ListView
- 带图标的input
- 任务栏图标保持一直闪烁的状态
- 调用android自带的截图工具进行截图
- 调用android自带的截图工具进行截图
- 桌面”显示桌面“图标
- 带icon图像的图标
- 带图标的list item
- typedef函数指针用法
- wordpress需要注意的问题
- Swarm程序分析StartHeatbugs程序
- 10秒内提交输入验证码
- c语言宏定义,可变参数的使用
- 保持带图标的桌面截图
- 最简单的电话拨打程序
- HDFS中的通信协议
- Google的十个核心技术
- Java性能的十一个用法
- ORACLE外连接小结~ http://blog.csdn.net/wh62592855/article/details/4852908
- ubuntu中eclipse中文乱码问题
- 第一个用GLSurfaceView画图形
- 使用MySQL数据库的23个注意事项