Export (0) Print
Expand All

Calling a DLL Function

Updated: February 2010

Although calling unmanaged DLL functions is nearly identical to calling other managed code, there are differences that can make DLL functions seem confusing at first. This section describes some of the unusual calling-related issues.

Structures that are returned from platform invoke calls must be data types that have the same representation in managed and unmanaged code. Such structures are called blittable types because they do not require conversion (see Blittable and Non-Blittable Types). To call a function that has a non-blittable structure as its return type, you can define a blittable helper type of the same size as the non-blittable type and convert the data after the function returns.

Passing Structures

Identifies the issues of passing data structures with a predefined layout.

Callback Functions

Provides basic information about callback functions.

How to: Implement Callback Functions

Describes how to implement callback functions in managed code.

Consuming Unmanaged DLL Functions

Describes how to call unmanaged DLL functions using platform invoke.

Marshaling Data with Platform Invoke

Describes how to declare method parameters and pass arguments to functions exported by unmanaged libraries.

Date

History

Reason

February 2010

Clarified that return types must be blittable.

Customer feedback.

Community Additions

ADD
Show:
© 2014 Microsoft