码迷,mamicode.com
首页 > Windows程序 > 详细

C#调用win32 api程序实例

时间:2015-10-25 16:25:32      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:

1、声明static extern 方法,使用DllImport特性

   class MyClass
    {
        [DllImport("kernel32", SetLastError = true)]
        public static extern int GetCurrentDirectory(int a, StringBuilder b);
    }

2、调用

StringBuilder sb=new StringBuilder {Length = 250};
MyClass.GetCurrentDirectory(250, sb);
Console.WriteLine(sb);
Console.Read();

C#调用win32 api程序实例

标签:

原文地址:http://www.cnblogs.com/Benjamin/p/4908775.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!