本文介绍了如何从C ++本机编译的Dll调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我一直在调查这个没有用。我尝试使用 ENTRYPOINT 从C ++ DLL(库)调用函数,但没有成功。它不是一个开源的.dll,但它们是一个.NET库。我目前正在尝试将调用C ++ .DLL函数的C#库转换为C ++ CLI。 (所以... C#库(使用dllimport)转换为C ++ CLI ) 当然DLLIMPORT不起作用,我查看了 __ declspec(dllexport)& __ declspec(dllimport)而且我无处可去。我已经阅读了这个以尝试获得一些清晰度,但丢失并仍在阅读。 这是一个有效的(C ++ CLI)示例,用于旧的.DLL之前已经更新了...但是它没有 ENTRYPOINT ,但是较新的那个,我不知道如何添加入口点。 这就是 C ++ CLI版本(没有入口点(旧版本的DLL))的样子: typedef int(__ cdecl * Connectf)(const char *); Connectf Connect =(Connectf)GetProcAddress(LoadLibrary(LCCAPI.DLL),connectConsole); 这就是LIB的 C#版本的样子: private static extern int connectConsole( string targetIP); [DllImport( CCAPI.dll,EntryPoint = _ ZN5CcApi17disconnectConsoleEi,CallingConvention = CallingConvention.Cdecl)] PS:这是我的其他程序员之一的C ++ CLI库,但收效甚微: http://pastebin.com/0PTw73WZ 和原始C#Library(更新版本): http://pastebin.com/ccATzTm8 感谢您的时间。 BaSs_HaXoR 解决方案 I've been looking into this with no avail. I've tried calling a function from a C++ dll (library) WITH an ENTRYPOINT, with no success. It's not an open source .dll, but their is a .NET library for it. I am currently trying to convert the C# library that calls the functions of the C++ .DLL into C++ CLI.(So... C# library (using dllimport) conversion to C++CLI)Of course DLLIMPORT doesn't work, and I've looked into __declspec(dllexport)& __declspec(dllimport) and I'm not getting anywhere. I have read on this to try and gain some clarity, but lost and still reading.This is a working (C++ CLI) example for the older .DLL before it was updated... but this doesn't have an ENTRYPOINT in it, but the newer one does and i don't know how to add the entrypoint.This is what the C++ CLI Version (without entrypoint (older version of DLL)) looks like:typedef int (__cdecl* Connectf)(const char*);Connectf Connect = (Connectf)GetProcAddress(LoadLibrary(L"CCAPI.DLL"),"connectConsole");This is what the C# version of the LIB looks like:private static extern int connectConsole(string targetIP); [DllImport("CCAPI.dll", EntryPoint = "_ZN5CcApi17disconnectConsoleEi", CallingConvention = CallingConvention.Cdecl)]P.S.: Here's the C++ CLI Library one of my fellow programmers worked on, with little success: http://pastebin.com/0PTw73WZand the original C# Library (updated version): http://pastebin.com/ccATzTm8Thanks for your time.BaSs_HaXoR 解决方案 这篇关于如何从C ++本机编译的Dll调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-24 18:22