星空网 > 软件开发 > ASP.net

C#调用windows api示例

这是运行结果:

C#调用windows api示例

 

Api函数是构筑Windws应用程序的基石,每一种Windows应用程序开发工具,它提 
供的底层函数都间接或直接地调用了Windows API函数,同时为了实现功能扩 
展,一般也都提供了调用WindowsAPI函数的接口, 也就是说具备调用动态连接 
库的能力。Visual C#和其它开发工具一样也能够调用动态链接库的API函 
数。.NET框架本身提供了这样一种服务,允许受管辖的代码调用动态链接库中实 
现的非受管辖函数,包括操作系统提供的Windows API函数。它能够定位和调用输 
出函数,根据需要,组织其各个参数(整型、字符串类型、数组、和结构等等)跨 
越互操作边界。 

参考:http://hovertree.com/h/bjaf/tc63n4t2.htm

using System;using System.Runtime.InteropServices;using System.Windows.Forms;namespace HoverTreeWinForm{  public partial class FormHewenqi : Form  {    /// <summary>    /// http://hovertree.com/h/bjaf/v4y0b2l6.htm    /// </summary>    /// <param name="h"></param>    /// <param name="m"></param>    /// <param name="c"></param>    /// <param name="type"></param>    /// <returns></returns>    [DllImport("User32.dll")]    public static extern int MessageBox(int h, string m, string c, int type);    public FormHewenqi()    {      InitializeComponent();    }    private void button_hewenqi_Click(object sender, EventArgs e)    {      MessageBox(0, "Hello Win32 API HoverTree", "何问起网", 4);    }    private void linkLabel_help_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)    {      System.Diagnostics.Process.Start("http://hovertree.com/h/bjaf/v4y0b2l6.htm");    }  }}

转载自:http://hovertree.com/h/bjaf/psjdasa2.htm

源码下载:http://pan.baidu.com/s/1bnPPgL5

http://roucheng.cnblogs.com/




原标题:C#调用windows api示例

关键词:C#

C#
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

海外客服:https://www.goluckyvip.com/tag/33357.html
海外跨境电商:https://www.goluckyvip.com/tag/33358.html
营销推广:https://www.goluckyvip.com/tag/3336.html
海外跨境电商推广:https://www.goluckyvip.com/tag/33360.html
海外跨境电商网站:https://www.goluckyvip.com/tag/33361.html
海外快递专线:https://www.goluckyvip.com/tag/33362.html
怎样做出一个有利可图的SaaS产品?:https://www.kjdsnews.com/a/1836639.html
【再放信号】美国Etsy即将放开中国卖家入驻,官方邮件你收到了吗?:https://www.kjdsnews.com/a/1836640.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流