C#中调用一些API函数
来源:互联网 发布:中国银行mac企业网银 编辑:程序博客网 时间:2024/05/01 19:54
在类中写入:
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hwnd, int nindex, int newlong);
[DllImport("user32.dll")]
private static extern int GetWindowLong(IntPtr hwnd, int newlong);
[DllImportAttribute("gdi32.dll")]
public static extern IntPtr CreateRoundRectRgn(int nLeftRect, int nTopRect, int
nRightRect, int nBottomRect, int nWidthEllipse, int nHeightEllipse);
[DllImportAttribute("user32.dll")]
public static extern int SetWindowRgn(IntPtr hWnd, IntPtr hRgn, bool bRedraw);
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int
lParam);
[DllImport("user32")]
public static extern int GetKeyState(int nVirtKey); //得到键盘上的键状态
一些消息参数数值:
const int WM_SYSCOMMAND = 0x0112;
const int SC_MOVE = 0xF010;
const int HTCAPTION = 0x0002;
const int WS_CAPTION = 0x00C00000;
const int GWL_EXSTYLE = -20;
const int GWL_STYLE = -16;
const int WS_EX_TOOLWINDOW = 0x0080000;
const int WS_EX_APPWINDOW = 0x0040000;
const int WM_LBUTTONDOWN = 0x0201;
const int WM_RBUTTONDOWN = 0x0204;
API调用:
SetWindowLong((IntPtr)f.Handle, GWL_STYLE,GetWindowLong((IntPtr)
f.Handle,GWL_STYLE) & ~WS_CAPTION );
// 去掉窗体标题栏
IntPtr rgnHwnd = CreateRoundRectRgn(0,0, f.Width, f.Height, 5, 5);
SetWindowRgn((IntPtr)f.Handle, rgnHwnd, true);
//给窗体切圆角
SendMessage((IntPtr)control.Handle,WM_LBUTTONDOWN,0,0);
SendMessage((IntPtr)control.Handle,WM_LBUTTONUP,0,0);
//模拟一次鼠标单击
label1.Text = (GetKeyState(20) & -1) > 0 ? "CapsLock:开" : "CapsLock:关";
//取得CapsLock灯的状态赋值LABEL的TEXT属性
- C#中调用一些API函数
- 在C#中调用windows API函数
- 在C#中调用windows API函数
- C#中动态调用API函数
- 在C#中调用windows API函数
- 在C#中调用windows API函数
- C# 中 调用 Win API 函数
- 在C#中调用windows API函数
- 在C#中调用windows API函数
- 在C#中调用windows API函数
- 在C#中调用windows API函数
- 在C#中调用windows API函数
- 在C#中调用windows API函数
- c# 中调用win32的api函数
- C#调用API函数
- C#调用API函数
- C#调用API函数
- C#调用API函数
- SQL Union和SQL Union All用法
- 有关字节对齐的介绍
- VS2008快捷键大全
- 什么是事务
- 2009年6月29日星期一
- C#中调用一些API函数
- SQL语句教训总结
- 变长结构体
- 糟糕的面试
- CListCtrl使用技巧
- 一个简单的Win32 SDK窗口程序
- delphi 的类型转换函数
- 第三章作业
- 视图的要求