在C#中调用C语言写的动态链接库 DLL
来源:互联网 发布:流行的网络dj歌曲大全 编辑:程序博客网 时间:2024/05/12 07:33
1.首先将相关的C语言接口的DLL文件复制到bin\Debug
2.添加 using System.Windows.Shapes;
3. 在类中用一下方式添加接口函数
[DllImport("TFFT.dll", EntryPoint = "TtfTest_InitTestEvn")]
public static extern int TtfTest_InitTestEvn();
[DllImport("TFFT.dll", EntryPoint = "TtfTest_Test")]
public static extern int TtfTest_Test();
2.添加 using System.Windows.Shapes;
3. 在类中用一下方式添加接口函数
[DllImport("TFFT.dll", EntryPoint = "TtfTest_InitTestEvn")]
public static extern int TtfTest_InitTestEvn();
[DllImport("TFFT.dll", EntryPoint = "TtfTest_Test")]
public static extern int TtfTest_Test();
4.在相应的地方引用相关的函数TtfTest_InitTestEvn(),TtfTest_Test()。
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes; using System.Windows.Shapes; using System.Runtime.InteropServices;namespace One{ /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> /// public partial class MainWindow : Window { [DllImport("TFFT.dll", EntryPoint = "TtfTest_InitTestEvn")] public static extern int TtfTest_InitTestEvn(); [DllImport("TFFT.dll", EntryPoint = "TtfTest_Test")] public static extern int TtfTest_Test(); public MainWindow() { InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { string strDiffTime; DateTime dtStart, dtEnd; dtStart = DateTime.Now; for (int i = 0; i < 10; ++i ) { MainWindow.TtfTest_InitTestEvn(); MainWindow.TtfTest_Test(); } dtEnd = DateTime.Now;//获得当前时间 double dStartTime = dtStart.TimeOfDay.TotalSeconds; double dEndTime = dtEnd.TimeOfDay.TotalSeconds; strDiffTime = (dEndTime - dStartTime).ToString() + ":s"; MessageBox.Show(strDiffTime); } }}
0 0
- 在C#中调用C语言写的动态链接库 DLL
- C#调用matlab写的动态链接库(dll)
- C#调用matlab写的动态链接库(dll)
- C#中调用C++ 动态链接库 dll 的方…
- C#中调用C++ 动态链接库 dll 的方…
- 在PB中调用其它语言开发的DLL动态链接库
- c#中如何调用vc++写的动态链接库
- c/c++动态库(DLL)调用,c#等其他语言调用c/c++的DLL
- C语言调用DLL动态链接库出错
- C#调用C/C++ 动态链接库DLL(一)
- C#调用C/C++ 动态链接库DLL(二)
- C#调用C/C++ 动态链接库DLL(三)
- C#调用C/C++动态链接库(.dll)详解
- C#调用C/C++动态链接库(.dll)详解
- 在C#中调用C语言标准动态库方法
- C#中如何调用动态链接库DLL(转)
- C#中如何调用动态链接库DLL
- C#中如何调用动态链接库DLL(转)
- Extjs Grid当中Toolbar上面按时间段查询2
- ubuntu下hello驱动模块问题补充
- Android 4.0 Camera架构分析之Camera初始化
- 理解Scroll View
- uitextfield placeholder字体颜色和垂直居中
- 在C#中调用C语言写的动态链接库 DLL
- ORA-12154: TNS:could not resolve the connect identifier specified
- 嵌入式基础知识编程
- iOS NSTimer invalidate 和 release 释放问题
- java起步
- 自考毕业设计有感
- C++ cout格式化输出
- 自定义 Collection View 布局
- android编写访问http的源代码