【C#】使用user32.dll的MessageBox弹窗消息
要使用user32.dll的MessageBox弹窗消息,自然需要引入user32.dll到项目中。
一个最简单的实例如下:
using System;
using System.Runtime.InteropServices; class Example
{
// Use DllImport to import the Win32 MessageBox function.
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern int MessageBox(IntPtr hWnd, String text, String caption, uint type); static void Main()
{
// Call the MessageBox function using platform invoke.
MessageBox(new IntPtr(), "Hello World!", "Hello Dialog", );
}
}
运行项目后,直接弹出弹窗消息。
这是C#使用外部DLL中的方法,项目的引用中并没有显示该user32.dll。
【C#】使用user32.dll的MessageBox弹窗消息的更多相关文章
- 对类HelloWorld程序中添加一个MessageBox弹窗
对类HelloWorld程序中添加一个MessageBox弹窗 分析: 任一程序运行的时候都会加载kernel32.dll的,但MessageBoxA()这个API却是在user32.dll中的.所以 ...
- 控制台——对WIN32 API的使用(user32.dll)
Win32 API概念:即为Microsoft 32位平台的应用程序编程接口(Application Programming Interface).所有在Win32平台上运行的应用程序都可以调用这些函 ...
- C#中可直接调用WIN32的API函数--USER32.DLL
Win32的API函数可以直接在C#中直接调用,在做WinForm时还是很有帮助的.有时候直接调用Win32的API,可以很高效的实现想要的效果. using System; 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 ...
- user32.dll
user32.dll中的所有函数 using System; using System.Collections.Generic; using System.Linq; using System.Tex ...
- 【WinAPI】User32.dll注释
#region User32.dll 函数 /// <summary> /// 该函数检索一指定窗口的客户区域或整个屏幕的显示设备上下文环境的句柄,以后可以在GDI函数中使用该句柄来在设备 ...
- 【整理】c# 调用windows API(user32.dll)
User32.dll提供了很多可供调用的接口,大致如下(转自http://blog.csdn.net/zhang399401/article/details/6978803) using System ...
- C# user32.dll
#region User32.dll 函数 /// <summary> /// 该函数检索一指定窗口的客户区域或整个屏幕的显示设备上下文环境的句柄,以后可以在GDI函数中使用该句柄来在设备 ...
随机推荐
- Java/Android倒计时(开始,暂停,恢复,停止)
由于要做暂停和恢复,这里我就没有使用Android的CountDownTimer,而是用了Java的Timer.所以,这个方法在java肯定是通用.我也外加了Android独有的Service,有些计 ...
- Redis 的安装与使用(单节点)
Redis 的安装与使用(单节点) 环境:CentOS 6.5 Redis 版本:redis-3.0 (考虑到Redis3.0 在集群和性能提升方面的特性,rc 版为正式版的候选版,而且 很快就出 ...
- php file_get_contents读取大容量文件方法
当我们遇到文本文件体积很大时,比如超过几十M甚至几百M几G的大文件,用记事本或者其它编辑器打开往往不能成功,因为他们都需要把文件内容全部放到内存里面,这时就会发生内存溢出而打开错误,遇到这种情况我 ...
- 《自己动手写框架2》:用200行的DBF解析器来展示良好架构设计
因为工作关系.须要工作其中,须要读取DBF文件.找了一些DBF读取开源软件,要么是太过庞大,动不动就上万行.要么是功能有问题,编码,长度,总之是没有找到一个很爽的. 在万般无奈之下,我老人家怒从心头起 ...
- Java 8 – Period and Duration examples
Few examples to show you how to use Java 8 Duration, Period and ChronoUnit objects to find out the d ...
- hibernate显示完整的sql(转)
不完整的SQL Hibernate: /* insert com.test.bean.User */ insert into user (username, password, email, sex) ...
- 腾讯云服务器 - 安装redis3.2.9以及集群
redis大家都知道,服务器上必不可少的,那么在生产环境下安装的步骤和虚拟机里也是差不多的 官网上最新稳定版是3.2.9,而4.0的更新比较大,但是比几个还是beta版嘛 下载并且上传压缩包至云服务器 ...
- [svc][jk]磁盘的iops和吞吐量(Throught)指标
参考 另参考 IOPS (Input/Output Per Second)即每秒的输入输出量(或读写次数),是衡量磁盘性能的主要指标之一.IOPS是指单位时间内系统能处理的I/O请求数量,一般以每秒处 ...
- Project Euler:Problem 32 Pandigital products
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly o ...
- UML的通用机制(三)
Common Divisions In modeling object-oriented systems, the world often gets divided in several way ...