C 可以直接调用的Win32API

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.youkuaiyun.com/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

http://www.cnblogs.com/jxsoft/archive/2012/06/29/2569876.html

 

整理的Win32 API,可以直接在C#中直接调用,在做WinForm时还是很有帮助的。

源码包含三个文件

Win32API.cs,

using System;using System.Drawing;using System.Runtime.InteropServices;using Lordal.Window.Form.Lib.General;using Lordal.Window.Form.Lib.Win32;namespace Lordeo.Framework/// <summary> /// Windows API Functions /// </summary> public class Win32API {  #region .ctor()  // No need to construct this object  private Win32API()  {  }  #endregion    #region Constans values  public const string TOOLBARCLASSNAME = "ToolbarWindow32";  public const string REBARCLASSNAME = "ReBarWindow32";  public const string PROGRESSBARCLASSNAME = "msctls_progress32";  public const string SCROLLBAR = "SCROLLBAR";  #endregion  #region CallBacks  public delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam);  #endregion  #region Kernel32.dll functions  [DllImport("kernel32.dll", ExactSpelling=true, CharSet=CharSet.Auto)]   public static extern int GetCurrentThreadId();  #endregion   #region Gdi32.dll functions  [DllImport("gdi32.dll")]   static public extern bool StretchBlt(IntPtr hDCDest, int XOriginDest, int YOriginDest, int WidthDest, int HeightDest,   IntPtr hDCSrc,  int XOriginScr, int YOriginSrc, int WidthScr, int HeightScr, uint Rop);  [DllImport("gdi32.dll")]   static public extern IntPtr CreateCompatibleDC(IntPtr hDC);  [DllImport("gdi32.dll")]   static public extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int Width, int Heigth);  [DllImport("gdi32.dll")]   static public extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject);  [DllImport("gdi32.dll")]   static public extern bool BitBlt(IntPtr hDCDest, int XOriginDest, int YOriginDest, int WidthDest, int HeightDest,   IntPtr hDCSrc,  int XOriginScr, int YOriginSrc, uint Rop);  [DllImport("gdi32.dll")]   static public extern IntPtr DeleteDC(IntPtr hDC);  [DllImport("gdi32.dll")]   static public extern bool PatBlt(IntPtr hDC, int XLeft, int YLeft, int Width, int Height, uint Rop);  [DllImport("gdi32.dll")]   static public extern bool DeleteObject(IntPtr hObject);  [DllImport("gdi32.dll")]   static public extern uint GetPixel(IntPtr hDC, int XPos, int YPos);  [DllImport("gdi32.dll")]   static public extern int SetMapMode(IntPtr hDC, int fnMapMode);  [DllImport("gdi32.dll")]   static public extern int GetObjectType(IntPtr handle);  [DllImport("gdi32")]   public static extern IntPtr CreateDIBSection(IntPtr hdc, ref BITMAPINFO_FLAT bmi,    int iUsage, ref int ppvBits, IntPtr hSection, int dwOffset);  [DllImport("gdi32")]   public static extern int GetDIBits(IntPtr hDC, IntPtr hbm, int StartScan, int ScanLines, int lpBits, BITMAPINFOHEADER bmi, int usage);  [DllImport("gdi32")]   public static extern int GetDIBits(IntPtr hdc, IntPtr hbm, int StartScan, int ScanLines, int lpBits, ref BITMAPINFO_FLAT bmi, int usage);  [DllImport("gdi32")]   public static extern IntPtr GetPaletteEntries(IntPtr hpal, int iStartIndex, int nEntries, byte[] lppe);  [DllImport("gdi32")]   public static extern IntPtr GetSystemPaletteEntries(IntPtr hdc, int iStartIndex, int nEntries, byte[] lppe);  [DllImport("gdi32")]   public static extern uint SetDCBrushColor(IntPtr hdc,  uint crColor);  [DllImport("gdi32")]   public static extern IntPtr CreateSolidBrush(uint crColor);  [DllImport("gdi32")]   public static extern int SetBkMode(IntPtr hDC, BackgroundMode mode);  [DllImport("gdi32")]   public static extern int SetViewportOrgEx(IntPtr hdc,  int x, int y,  int param);  [DllImport("gdi32")]   public static extern uint SetTextColor(IntPtr hDC, uint colorRef);  [DllImport("gdi32")]   public static extern int SetStretchBltMode(IntPtr hDC, int StrechMode);  #endregion  #region Uxtheme.dll functions  [DllImport("uxtheme.dll")]  static public extern int SetWindowTheme(IntPtr hWnd, string AppID, string ClassID);  #endregion   #region User32.dll functions  [DllImport("user32.dll", CharSet=CharSet.Auto)]   public static extern IntPtr GetDC(IntPtr hWnd);  [DllImport("user32.dll", CharSet=CharSet.Auto)]   public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);  [DllImport("user32.dll", CharSet=CharSet.Auto)]   static public extern IntPtr GetDesktopWindow();  [DllImport("user32.dll", CharSet=CharSet.Auto)]   static public extern bool ShowWindow(IntPtr hWnd, short State);  [DllImport("user32.dll", CharSet=CharSet.Auto)]   static public extern bool UpdateWindow(IntPtr hWnd);  [DllImport("user32.dll", CharSet=CharSet.Auto)]   static public extern bool SetForegroundWindow(IntPtr hWnd);  [DllImport("user32.dll", CharSet=CharSet.Auto)]   static public extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int Width, int Height, uint flags);  [DllImport("user32.dll", CharSet=CharSet.Auto)]   static public extern bool OpenClipboard(IntPtr hWndNewOwner);  [DllImport("user32.dll", CharSet=CharSet.Auto)]   static public extern bool CloseClipboard();  [DllImport("user32.dll", CharSet=CharSet.Auto)]   static public extern bool EmptyClipboard();  [DllImport("user32.dll", CharSet=CharSet.Auto)]   static public extern IntPtr SetClipboardData( uint Format, IntPtr hData);  [DllImport("user32.dll", CharSet=CharSet.Auto)]   static public extern bool GetMenuItemRect(IntPtr hWnd, IntPtr hMenu, uint Item, ref RECT rc);  [DllImport("user32.dll", ExactSpelling=true, CharSet=CharSet.Auto)]   public static extern IntPtr GetParent(IntPtr hWnd);  [DllImport("user32.dll", CharSet=CharSet.Auto)]   public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);  [DllImport("user32.dll", CharSet=CharSet.Auto)]   public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, IntPtr lParam);  [DllImport("user32.dll", CharSet=CharSet.Auto)]   public static extern void SendMessage(IntPtr hWnd, int msg, int wParam, ref RECT lParam);  [DllImport("user32.dll", CharSet=CharSet.Auto)]   public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, ref POINT lParam);  [DllImport("user32.dll", CharSet=CharSet.Auto)]   public static extern void SendMessage(IntPtr hWnd, int msg, int wParam, ref TBBUTTON lParam);  [DllImport("user32.dll", CharSet=CharSet.Auto)]   public static extern void SendMessage(IntPtr hWnd, int msg, int wParam, ref TBBUTTONINFO lPar
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值