Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to call C++ dynamic library interface function and callback function by C #

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

In this article, the editor introduces in detail "C# how to call C++ dynamic library interface functions and callback functions" with detailed content, clear steps and proper handling of details. I hope this article "how to call C++ dynamic library interface functions and callback functions" can help you solve your doubts.

1. Preface

Requirements: at present, C has written a dynamic library and completed the product development requirements. C # needs to call the DLL interface of the dynamic library written by C to develop a complete software. DLL dynamic library contains common interface functions and callback functions.

Development environment: win10 64-bit, VS2017

two。 Common API function call example 2.1 C++ end authoring API

(1) declare the interface to be provided in the header file and export the interface to facilitate the call by C#

/ / invisible reference example EXTERN_C TOOLLIBRARY_API char* Version (void) with return value; / / no return value with pointer reference example EXTERN_C TOOLLIBRARY_API void SetApplicationDirPath (char* buff)

(2) Source code

Char* Version (void) {return version_str;} void SetApplicationDirPath (char* buff) {std::string str = buff; printf ("incoming parameters:% s\ n", buff); std::cout

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report