"C #" uses the User32.dll MessageBox popup message

Source: Internet
Author: User

To use User32.dll's MessageBox popup messages, you naturally need to introduce user32.dll into your project.

One of the simplest examples is as follows:

usingSystem;usingSystem.Runtime.InteropServices;classexample{//Use DllImport to import the Win32 MessageBox function.[DllImport ("user32.dll", CharSet =CharSet.Unicode)] Public Static extern intMessageBox (IntPtr hWnd, string text, string caption,UINTtype); Static voidMain () {//Call the MessageBox function using platform invoke.MessageBox (NewINTPTR (0),"Hello world!","Hello Dialog",0); }}

After the project is run, pop-up popup messages directly.

This is a method in C # that uses an external DLL, and the user32.dll is not shown in the project's reference.

"C #" uses the User32.dll MessageBox popup message

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.