M
Mark Jerde
I need to call a Win32 DLL. The API supports both Windows and Linux, but
I'm only concerned with Windows. I'd like advice whether I can use C# or
whether I'll have to dust off my old C++ books. I would prefer to learn C#
rather than go back to C++.
The API starts with
#ifdef (WIN32)
#define MyAPI __stdcall
#else
#define MyAPI
#endif
There are bitmap mask #define statements.
All integer values are little-endian.
There are many "typedef" and "typedef struct" statements with char, const,
void, sint8, uint8, uint16, uint32, and sint32 elements, arrays and
pointers.
There are "typedef struct" statements with union elements.
To ease cross-platform use, the API defines its own memory management. This
is one typedef:
typedef void * (MyAPI *MyAPI_REALLOC)
(void * Memblock,
uint32 Size,
void * Allocref);
And the part I'm the least sure can be done in C# is the asynchronous event
mechanism. Here is one of the typefefs.
typedef MyAPI_RETURN (MyAPI *MyAPI_ModuleEventHandler)
(const MyAPI_UUID *UUID,
void* AppNotifyCallbackCtx,
MyAPI_ID ID,
uint32 Reserved,
MyAPI_Event EventType);
Can C# easily work with this API? (*)
Thanks!
-- Mark
(*) Several years ago I wrote some ugly VB6 code to deal with a DLL that had
VB-unfriendly pointers and unicode strings. Therefore I assume it is
"possible" to use this DLL from C#. I guess I'm asking whether or not it is
"easy" or "reasonable" to call the DLL from C#.
I'm only concerned with Windows. I'd like advice whether I can use C# or
whether I'll have to dust off my old C++ books. I would prefer to learn C#
rather than go back to C++.
The API starts with
#ifdef (WIN32)
#define MyAPI __stdcall
#else
#define MyAPI
#endif
There are bitmap mask #define statements.
All integer values are little-endian.
There are many "typedef" and "typedef struct" statements with char, const,
void, sint8, uint8, uint16, uint32, and sint32 elements, arrays and
pointers.
There are "typedef struct" statements with union elements.
To ease cross-platform use, the API defines its own memory management. This
is one typedef:
typedef void * (MyAPI *MyAPI_REALLOC)
(void * Memblock,
uint32 Size,
void * Allocref);
And the part I'm the least sure can be done in C# is the asynchronous event
mechanism. Here is one of the typefefs.
typedef MyAPI_RETURN (MyAPI *MyAPI_ModuleEventHandler)
(const MyAPI_UUID *UUID,
void* AppNotifyCallbackCtx,
MyAPI_ID ID,
uint32 Reserved,
MyAPI_Event EventType);
Can C# easily work with this API? (*)
Thanks!
-- Mark
(*) Several years ago I wrote some ugly VB6 code to deal with a DLL that had
VB-unfriendly pointers and unicode strings. Therefore I assume it is
"possible" to use this DLL from C#. I guess I'm asking whether or not it is
"easy" or "reasonable" to call the DLL from C#.