控制台——对WIN32 API的使用(user32.dll)
Win32 API概念:即为Microsoft 32位平台的应用程序编程接口(Application Programming Interface)。所有在Win32平台上运行的应用程序都可以调用这些函数。
Win32 API作用:应用程序可以充分挖掘Windows的32位操作系统的潜力。 Mircrosoft的所有32位平台都支持统一的API,包括函数、结构、消息、宏及接口。使用 Win32 API不但可以开发出在各种平台上都能成功运行的应用程序,而且也可以充分利用每个平台特有的功能和属性。
using System.Windows.Forms;
using System.Runtime.InteropServices;
通过DllImport引入user32.dll,这是核心代码
[DllImport("User32.dll", EntryPoint = "FindWindow")]
private static extern int FindWindow(string lpClassName, string lpWindowName);
private static void CloseWin()
{
const int WM_CLOSE = 0x10; //关闭
const uint WM_DESTROY = 0x02;
const uint WM_QUIT = 0x12;
const int BM_CLICK = 0xF5; //单击
IntPtr Window_Handle = (IntPtr)FindWindow(null, "MyLove");//查找所有的窗体,看看想查找的句柄是否存在,Microsoft Word 句柄
if (Window_Handle == IntPtr.Zero) //如果没有查找到相应的句柄
{
MessageBox.Show("没有找到窗体");
}
else //查找到相应的句柄
{
SendMessage(Window_Handle, WM_CLOSE, , ); //关闭窗体
}
}
控制台住函数入口处进行调用
static void Main(string[] args)
{
Console.Title = "关闭其他窗体";
CloseWin();
}
控制台——对WIN32 API的使用(user32.dll)的更多相关文章
- Win32 API中的user32.dll中的ShowWindow方法参数整理
在使用ShowWindow方法来设置窗体的状态时,由于不知道参数值,用起来非常容易混乱,所以整理了以下其参数的枚举值,方便以后的的使用. public class User32API { #reg ...
- 【.Net】从.NET平台调用Win32 API
小序 Win32 API可以直接控制Microsoft Windows的核心,因为API(Application Programming Interface)本来就是微软留给我们直接控制 ...
- C#调用Win32 api学习总结
从.NET平台调用Win32 API Win32 API可以直接控制Microsoft Windows的核心,因为API(Application Programming Interface)本来就是微 ...
- 【C#】使用user32.dll的MessageBox弹窗消息
要使用user32.dll的MessageBox弹窗消息,自然需要引入user32.dll到项目中. 一个最简单的实例如下: using System; using System.Runtime.In ...
- C#中可直接调用WIN32的API函数--USER32.DLL
Win32的API函数可以直接在C#中直接调用,在做WinForm时还是很有帮助的.有时候直接调用Win32的API,可以很高效的实现想要的效果. using System; using System ...
- C#调用Win32 的API函数--User32.dll ----转载
Win32的API函数是微软自己的东西,可以直接在C#中直接调用,在做WinForm时还是很有帮助的.有时候我们之直接调用Win32 的API,可以很高效的实现想要的效果. using System; ...
- Winform API "user32.dll"中的函数
命名空间:System.Runtime.InteropServices /// <summary> /// 该函数检索一指定窗口的客户区域或整个屏幕的显示设备上下文环境的句柄,以后可以在G ...
- 【转】c# 调用windows API(user32.dll)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.R ...
- 【整理】c# 调用windows API(user32.dll)
User32.dll提供了很多可供调用的接口,大致如下(转自http://blog.csdn.net/zhang399401/article/details/6978803) using System ...
随机推荐
- 【BZOJ1014】火星人prefix(splay,Hash)
题意: . 思路: ; ..,..]of longint; sum,size,fa,a,b,id,mi:..]of longint; n,m,i,x,y,s,k,j,cnt,root:longint; ...
- D. Palindromic characteristics
time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standa ...
- [bzoj 1093][ZJOI2007]最大半联通子图(强联通缩点+DP)
题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1093 分析: 首先肯定是先把强联通全部缩成一个点,然后成了一个DAG 下面要知道一点: ...
- canvas裁剪之后的base64转换为上传文件blob对象
function convertBase64UrlToBlob(urlData){ var bytes=window.atob(urlData.split(',')[1]); //去掉url的头,并转 ...
- 关于static静态块的使用和static list的使用
public class CorsConfiguration { /** * Wildcard representing <em>all</em> origins, metho ...
- fastjson将java list转为json字符串
1.直接用fastjson的静态方法string JSON.toJSONString(list)方法就行,JSON.toJSONString(list)将java list转为json字符串. 2.t ...
- 1.4-动态路由协议OSPF⑤
OSPF的特殊区域(Stub/total Stub区域,无法引入外部路由): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 第一种 ...
- gem5: 使用ruby memory system中的mesh结构 出现AssertionError错误
问题:在使用ruby memory system中的mesh结构測试时,出现例如以下错误: Traceback (most recent call last): File "<stri ...
- (转)C++ CListCtrl使用技巧的摘抄
转:http://blog.csdn.net/sanshao27/article/details/1888315 1. CListCtrl 风格 LVS_ICON: 为每个item显示大图标 ...
- GPU 编程入门到精通(三)之 第一个 GPU 程序
博主因为工作其中的须要.開始学习 GPU 上面的编程,主要涉及到的是基于 GPU 的深度学习方面的知识,鉴于之前没有接触过 GPU 编程,因此在这里特地学习一下 GPU 上面的编程.有志同道合的小伙伴 ...