【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函数中使用该句柄来在设备 ...
随机推荐
- notepad++ 语法高亮
1. notepad++ 添加新语言语法高亮和加载插件 用notepad++已经很久了,很习惯用这个小东西做事情,简单方便,超实用的一款工具. 先说说在呢么添加对新的编程语言的支持吧, 添加新语言语法 ...
- JavaSE入门学习20:Java面向对象之接口(interface)(一)
一Java接口 接口(英文:interface)是抽象方法和常量值的集合,在Java编程语言中是一个抽象类型,接口通常以interface来声 明.类是一种详细实现体.而接口定义了某一批类所须要遵守的 ...
- logrotate日志管理工具
一.概述 logrotate是一个Linux系统默认安装了的日志文件管理工具,用来把旧文件轮转.压缩.删除,并且创建新的日志文件.我们可以根据日志文件的大小.天数等来转储,便于对日志文件管理. log ...
- bat 批处理脚本定时执行命令
有个需求,需要每天定时执行下某个任务,一天一次.由于工作机器环境问题,没有办法设置windows 定时任务.查找资料并完成如下脚本. 功能:每天定时执行一次任务. 复制如下脚本,到一个test.vbs ...
- Mac下 如何配置虚拟机软件Parallel Desktop--超详细
Mac下 如何配置虚拟机软件Pparallel Desktop--超详细 Mac 的双系统解决方案有两种,一种是使用Boot Camp分区安装独立的Windows,一种是通过安装Parallels D ...
- IOS7 新特性
相关ios7新特性 帖子.挺全的.一定要看看哪 http://www.devdiv.com/iOS_iPhone-ios_ui_uikit_text_kit_-thread-203631-1-1.ht ...
- [LeetCode] Read N Characters Given Read4 I & II
Read N Characters Given Read4 The API: int read4(char *buf) reads 4 characters at a time from a file ...
- Android-Cannot merge new index 66195 into a non-jumbo instruction的解决办法
转载请注明来源:http://blog.csdn.net/goldenfish1919/article/details/33729679 用eclispe打包的时候报错: [2014-06-23 13 ...
- js非常强大的日历控件fullcalendar.js, 日期时间库: moment.js
日历控件: https://fullcalendar.io/docs/ https://fullcalendar.io/docs/event_data/events_function/ https:/ ...
- 最新Windows下c++读写锁SRWLock介绍
https://blog.csdn.net/MoreWindows/article/details/7650574 https://blog.csdn.net/chenzhjlf/article/de ...