 |
P/Invoke Wizard Home
|
The PInvoke Wizard |
| |
| PInvoke Wizard Examples |
| 1. Example: Constants |
|
Here is an example of a PInvoke conversion. In this example, symbolic constants are defined in an include file using the #define keyword:
// C/C++ input
#define PS_SOLID 0
#define PS_DASH 1
#define PS_NULL 5
|
Here are the C# declarations that are created for the three constants that appear above:
// C# Declarations
public const int PS_SOLID = 0;
public const int PS_DASH = 1;
public const int PS_NULL = 5;
|
The PInvoke Wizard converts these three definitions in an instant. It makes sense, of course, when you have many hundreds (or even thousands) of conversions to do. Do you want to spend your time on this kind of mechanical, boring work? No! Instead, save your time for more interesting work like redesigning a web page, optimizing a database, or implementing performance optimizations. That is the kind of task you should spend your time doing!
For the above C/C++ declaration, the PInvoke Wizard generates the VB.NET declarations are shown here:
' [VB] output: managed code declarations
public const PS_SOLID As Integer = 0
public const PS_DASH As Integer = 1
public const PS_NULL As Integer = 5
|
|
|
Last updated: October 25, 2023 By: Paul Yao The Paul Yao Company
|
|
|
|