weixin_42616351 2020-07-17 12:38 采纳率: 0%
浏览 155

用c#给c语言程序做界面的相关问题 求赐教!qwq(动态链接库)

有一个底层的c语言代码封装的dll文件
c语言程序调用这个dll文件实现了功能

现在需要用c#给这个c语言程序做一个界面 涉及到几个问题

1.这个c语言程序包含了多个头文件,怎么把头文件放到c#程序里调用

2.怎么调用动态链接库,在项目里添加不进去尝试了如下代码

//fcApi.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;


namespace fc
{
    unsafe class fcApi 
    {
        [DllImport("BQFIC_ASM_DLL.dll", EntryPoint = "FIC_DIV_Found")]
        public extern static int FIC_DEV_Found(uint* Devnum);
    }
}


这个是老师给的方法

3.我在主框体里放了个按钮,在点击事件里调用dll中的函数

unsafe private void button1_Click(object sender, EventArgs e)
{

BQFIC_ASM_DLL_API int FIC_DEV_Found(int* Devnum);
int dev_count = 0;
int x = FIC_DEV_Found((int *) & dev_count); 

}

说“上下文中不存在名称”BQFIC_ASM_DLL_API

  • 写回答

1条回答 默认 最新

  • threenewbee 2020-07-17 16:22
    关注

    BQFIC_ASM_DLL_API
    这个本来就没有定义

    BQFIC_ASM_DLL_API int FIC_DEV_Found(int* Devnum);
    这个去掉


    int x = fcApi.FIC_DEV_Found((int *) & dev_count);

    评论

报告相同问题?

悬赏问题

  • ¥20 怎么在stm32门禁成品上增加记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面
  • ¥50 NT4.0系统 STOP:0X0000007B
  • ¥15 想问一下stata17中这段代码哪里有问题呀
  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 解riccati方程组