c#做Active并调用DLL二次开发

c#做Active园中很多了,但是做好Active后调用外部Dll如何使用?在做一个读卡功能需要调用第三方dll时候查了很多资料后可以正常调用打开读卡设备。

 

系统平台:win 2003 sp2

1、建立好Active控件(不多说了,我是看红马的文章)

2、添加外部DLL引用,和winform程序使用一样。

/// <summary>

        /// 打开读卡器 0:成功
        /// </summary>
        /// <param name="op">com端口号</param>
        /// <returns></returns>
        [DllImport("YLE280_API.dll", EntryPoint = "YLE280_Open")]
        public static extern int YLE280_Open(int op);
 
        /// <summary>
        /// 关闭读卡器
        /// </summary>
        /// <param name="op"></param>
        /// <returns></returns>
        [DllImport("YLE280_API.dll", EntryPoint = "YLE280_Close")]
        public static extern int YLE280_Close();

 3、把使用的dll copy到 “C:\WINDOWS\system32”下。

4、直接运行active控件的窗口就可调用。

 

posted @ 2013-06-08 12:21  冰封的心  阅读(213)  评论(0)    收藏  举报