zoukankan      html  css  js  c++  java
  • To consume exported DLL functions 之二 Create a class to hold DLL functions.

    Creating a Class to Hold DLL Functions

    Wrapping a frequently used DLL function in a managed class is an effective approach to encapsulate platform functionality. Although it is not mandatory to do so in every case, providing a class wrapper is convenient because defining DLL functions can be cumbersome and error-prone. If you are programming in Visual Basic or C#, you must declare DLL functions within a class or Visual Basic module.

    Within a class, you define a static method for each DLL function you want to call. The definition can include additional information, such as the character set or the calling convention used in passing method arguments; by omitting this information, you select the default settings. For a complete list of declaration options and their default settings, see Creating Prototypes in Managed Code.

    Once wrapped, you can call methods on the function as you call methods on any other static function. Platform invoke handles the underlying exported function automatically.

    When designing a managed class for platform invoke, consider the relationships between classes and DLL functions. For example, you can:

    • Declare DLL functions within an existing class.

    • Create an individual class for each DLL function, keeping functions isolated and easy to find.

    • Create one class for a set of related DLL functions to form logical groupings and reduce overhead.

    You can name the class and its methods as you please. For examples that demonstrate how to construct .NET-based declarations to be used with platform invoke, see Marshaling Data with Platform Invoke.

  • 相关阅读:
    解决jar包冲突
    postman使用记录
    get请求直接通过浏览器发请求传数组或者list到后台
    excel中ppmt/pmt/ipmt的计算方式
    unicode编码与解码
    spring参数拼装
    java内存模型(jmm)
    Mysql事务,并发问题,锁机制-- 幻读、不可重复读(转)
    星空雅梦
    星空雅梦
  • 原文地址:https://www.cnblogs.com/MayGarden/p/1642360.html
Copyright © 2011-2022 走看看