C # Call the Win32 API function-User32.dll

Source: Internet
Author: User

Win32 API functions are something of Microsoft. They can be called directly in C #, which is helpful in WinForm. Sometimes we can directly call the Win32 API to achieve the desired effect efficiently.
 

Code Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
Using System. Runtime. InteropServices;

Namespace WindowsAPI
{
Class CSharp_Win32Api
{
# Region User32.dll Function
/// <Summary>
/// This function retrieves the handle of the client area of a specified window or the display context of the entire screen. This handle can be used in the GDI function to draw in the context of the device. HWnd: handle of the window retrieved in the device context
/// </Summary>
[DllImport ("user32.dll", CharSet = CharSet. Auto)]
Public static extern IntPtr GetDC (IntPtr hWnd );
/// <Summary>
/// Function to release the device context (DC) for use by other applications.
/// </Summary>
Public static extern int ReleaseDC (IntPtr hWnd, IntPtr hDC );
/// <Summary>
/// This function returns the handle of the desktop window. The desktop window overwrites the entire screen.
/// </Summary>
Static public extern IntPtr getasktopwindow ();
/// <Summary>
/// This function sets the display status of the specified window.
/// </Summary>
Static public extern bool ShowWindow (IntPtr hWnd, short State );
/// <Summary>
/// Send the re-painting message WM_PAINT to the target form to update the invalid region of the target form customer area.
/// </Summary>
Static public extern bool UpdateWindow (IntPtr hWnd );
&

Related Article

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.