要使用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弹窗消息的更多相关文章

  1. 对类HelloWorld程序中添加一个MessageBox弹窗

    对类HelloWorld程序中添加一个MessageBox弹窗 分析: 任一程序运行的时候都会加载kernel32.dll的,但MessageBoxA()这个API却是在user32.dll中的.所以 ...

  2. 控制台——对WIN32 API的使用(user32.dll)

    Win32 API概念:即为Microsoft 32位平台的应用程序编程接口(Application Programming Interface).所有在Win32平台上运行的应用程序都可以调用这些函 ...

  3. C#中可直接调用WIN32的API函数--USER32.DLL

    Win32的API函数可以直接在C#中直接调用,在做WinForm时还是很有帮助的.有时候直接调用Win32的API,可以很高效的实现想要的效果. using System; using System ...

  4. Winform API "user32.dll"中的函数

    命名空间:System.Runtime.InteropServices /// <summary> /// 该函数检索一指定窗口的客户区域或整个屏幕的显示设备上下文环境的句柄,以后可以在G ...

  5. 【转】c# 调用windows API(user32.dll)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.R ...

  6. user32.dll

    user32.dll中的所有函数 using System; using System.Collections.Generic; using System.Linq; using System.Tex ...

  7. 【WinAPI】User32.dll注释

    #region User32.dll 函数 /// <summary> /// 该函数检索一指定窗口的客户区域或整个屏幕的显示设备上下文环境的句柄,以后可以在GDI函数中使用该句柄来在设备 ...

  8. 【整理】c# 调用windows API(user32.dll)

    User32.dll提供了很多可供调用的接口,大致如下(转自http://blog.csdn.net/zhang399401/article/details/6978803) using System ...

  9. C# user32.dll

    #region User32.dll 函数 /// <summary> /// 该函数检索一指定窗口的客户区域或整个屏幕的显示设备上下文环境的句柄,以后可以在GDI函数中使用该句柄来在设备 ...

随机推荐

  1. 【转载】Chrome插件开发 尝试

    本来来自 http://www.cnblogs.com/rufus-hua/ 1.新建文件夹 如图:整个项目的结构 2.新建一个名为manifest.json的文件,编码模式为utf-8,(可以先建好 ...

  2. Easyui 中 Tabsr的常用方法

    注:index必须为变量 tab页从0开始 //新增一个tab页var index = 0;$('#tt').tabs('add',{ title: 'Tab'+index, content: '&l ...

  3. Android自己定义view之measure、layout、draw三大流程

    自己定义view之measure.layout.draw三大流程 一个view要显示出来.须要经过測量.布局和绘制这三个过程,本章就这三个流程具体探讨一下.View的三大流程具体分析起来比較复杂,本文 ...

  4. centos 安装pecl

    一.更新yum源,安装php7 CentOS/RHEL 7.x: 1 rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-lates ...

  5. MySQL创建用户与授权方法实例精讲

    MySQL中创建用户与授权的实现方法. 运行环境:widnows xp professional + MySQL5.0 一, 创建用户: 命令:CREATE USER 'username'@'host ...

  6. ssm redis 数据字典在J2EE中的多种应用与实现

    数据字典在项目中是不可缺少的“基础设施”,关于数据字典如何设计如何实现,今天抽空讲一下吧 先看一下表设计: 通过自定义标签来实现页面的渲染: public class DataDictValueTag ...

  7. tips: javascript 参数传递含有空格怎么办?

    js 方法传参有时候会遇到空格,空格会报错,因为它会默认空格后是元素 解决方法就是使用 escape 和 unescape html: var title = escape(rowObject.tit ...

  8. android应用开发-从设计到实现 3-3 Sketch静态原型设计

    Sketch静态原型设计 对于静态原型的设计,我们使用Sketch. 启动Sketch后,我们将看到相似例如以下的界面, 工具栏 它的顶部是工具栏, 能够通过菜单条View -> Customi ...

  9. 每日英语:Proactive Advice for Dealing With Grief: Seek Out New Experiences

    When her husband died of cancer 10 years ago, Becky Aikman says she experienced grief and adapted to ...

  10. Erlang中一些错误或者异常的标识

    erlang中错误大体分为四种: 1. 编译错误    2. 逻辑错误    3. 运行时错误    4. 用户代码生成的错误 编译错误,主要是编译器检测出的代码语法错误 逻辑错误,是指程序没有完成预 ...