要使用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. Android如何实现点击一次返回键返回桌面而不是退出应用

    具体代码如下所示: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent. ...

  2. 【转】给Java说句公道话

    有些人问我,在现有的语言里面,有什么好的推荐?我说:“Java.” 他们很惊讶:“什么?Java!” 所以我现在来解释一下. Java超越了所有咒骂它的“动态语言” 也许是因为年轻人的逆反心理,人们都 ...

  3. linux文件系统 - 初始化(二)

    加载initrd(上) 一.目的 本文主要讲述linux3.10文件系统初始化过程的第二阶段:加载initrd. initrd是一个临时文件系统,由bootload负责加载到内存中,里面包含了基本的可 ...

  4. Cross compiling coreutils and generate the manpages

    When we cross compiling coreutils, there is an problem of generating man pages, because the source s ...

  5. eclipse热部署配置

    1. 方法一 打开server.xml,找到 比对下:改成下面这样: <Context docBase="dreamlive" path="/ROOT"  ...

  6. android开发之interpolator的使用

    android:interpolator Interpolator 被用来修饰动画效果,定义动画的变化率,可以使存在的动画效果accelerated(加速),decelerated(减速),repea ...

  7. JavaScript 循环:如何处理 async/await

    如何串行或者并行运行异步循环? 在使用循环处理异步的魔法之前,我们先来看下我们是怎么处理同步循环的. 同步循环 很久以前我写的循环是这样的: for (var i = 0; i < array. ...

  8. 如何使用 t-sql 更新数据库中日期字段的部分数据(年?月?日?时?分?秒?)

    嗯,从网上找到了一些内容,综合利用了sql server的一些内置方法 首先是 convert 方法:https://msdn.microsoft.com/zh-cn/library/ms187928 ...

  9. 如何在Windows环境下安装JDK

    原文链接:http://android.eoe.cn/topic/android_sdk 1. JDK 的下载 JDK有好几个类型版本,我们只需要选择Java SE类型的版本就行了. 进入网页:htt ...

  10. 浅析Java中的final关键字--转

    转载自:http://www.importnew.com/18586.html#comment-581628 谈到final关键字,想必很多人都不陌生,在使用匿名内部类的时候可能会经常用到final关 ...