vs2017 调用动态库

c# 版本 使用比较方便

[DllImport("D:/code/removal/x64/Release/removal.dll")]
 public static extern void removal_far_point(string filein, string fileout, float leaf , int k_point, float r);

        public Form1()
        {
            string filein = "C:/Users/12875/Desktop/数据/点云/1.pcd";
            string fileout= "C:/Users/12875/Desktop/数据/点云/1_new.pcd";

            removal_far_point(filein, fileout,1.0f,50,1.2f);
        }

import 里面放动态库的地址,函数名要与动态库中函数名一致就可以使用

C++版本 调用麻烦一点,有两种版本,这里只有其一(定义和调用比较麻烦)

定义 myDLL.cpp 

#include"myDLL.h"
#include <Windows.h>
HINSTANCE g_hCtrlInstance = NULL;
removal_point remval_point_fun = NULL;

bool LoadCtrl(char* strPath)
{
	g_hCtrlInstance = LoadLibrary(strPath);
	if (!g_hCtrlInstance)
	{
		return false;
	}

	remval_point_fun = (removal_point)GetProcAddress(g_hCtrlInstance, "removal_far_point");
	return true;
}

myDLL.h

#pragma once
#include <iostream>
using namespace std;
typedef void(*removal_point)(char*,char*,float,int,float);
extern removal_point remval_point_fun ;
bool LoadCtrl(char* strPath);

使用 Main.cpp

#include "myDLL.h"
int main()
{
	clock_t start = clock();

	char filepcd[50] = "1.pcd";
	char filepcd2[50] ="1_22.pcd";
	char str[50] = "removal.dll";
	if (LoadCtrl(str)) {
		cout << "are you ok?" << endl;
	}
	remval_point_fun(filepcd, filepcd2,0.3,50,0.6);
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值