最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

extern外部方法使用C#的實現(xiàn)方法

 更新時間:2014年12月24日 15:02:25   投稿:shichen2014  
這篇文章主要介紹了extern外部方法使用C#的實現(xiàn)方法,較為詳細(xì)的分析了外部方法使用C#的具體步驟與實現(xiàn)技巧,具有一定的參考借鑒價值,需要的朋友可以參考下

本文實例講述了extern外部方法使用C#的方法。分享給大家供大家參考。具體分析如下:

外部方法使用C#步驟如下:

1、增加引用using System.Runtime.InteropServices;

2、聲明和實現(xiàn)的連接[DllImport("kernel32", SetLastError = true)]

3、聲明外部方法public static extern int GetCurrentDirectory(int a, StringBuilder b);

4、對外部方法操作 GetCurrentDirectory(300, pathstring);

具體實現(xiàn)代碼如下:

復(fù)制代碼 代碼如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;//引用外部
 
namespace extern
{
    public partial class DllImportForm : Form
    {
        public DllImportForm()
        {
            InitializeComponent();
        }
 
        [DllImport("kernel32", SetLastError = true)]//聲明和實現(xiàn)的連接
        public static extern int GetCurrentDirectory(int a, StringBuilder b);//外部方法
       
        private void btnDisplay_Click(object sender, EventArgs e)
        {
            StringBuilder pathstring=new StringBuilder ();//返回路徑
            GetCurrentDirectory(300, pathstring);
           this.listBox1.Items.Add (pathstring );
 
        }
    }
}

希望本文所述對大家的C#程序設(shè)計有所幫助。

相關(guān)文章

最新評論

太谷县| 肥西县| 乌拉特后旗| 宝坻区| 赤水市| 武邑县| 藁城市| 文登市| 砀山县| 瑞金市| 济宁市| 香格里拉县| 玉田县| 兴仁县| 蒙山县| 孝义市| 松潘县| 黄陵县| 陇西县| 田阳县| 无极县| 桓台县| 沁源县| 襄城县| 长沙县| 龙泉市| 榆中县| 咸阳市| 武胜县| 正镶白旗| 丰顺县| 凤冈县| 丰都县| 栾城县| 文水县| 石台县| 仁化县| 咸阳市| 湖口县| 屯昌县| 中江县|