Re: Can C# Call This DLL?
From: Nicholas Paldino [.NET/C# MVP] (mvp_at_spam.guard.caspershouse.com)
Date: 10/18/04
- Next message: Tomas Restrepo \(MVP\): "Re: managed string -> unmanaged string"
- Previous message: Dan Guzman: "Re: establishing cause of access violation?"
- In reply to: Mark Jerde: "Can C# Call This DLL?"
- Next in thread: Mark Jerde: "Re: Can C# Call This DLL?"
- Reply: Mark Jerde: "Re: Can C# Call This DLL?"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 18 Oct 2004 08:58:04 -0400
Mark,
While you are using the stdcall convention for the functions, it's not
possible to tell whether or not you are exploring the functions correctly.
My guess is that yes, the functions are exported correctly, so you should
have no problem using this.
However, the only thing that is of concern is the memory management
routine. It looks like there is a routine for allocating memory, but I
can't see anything for deallocating memory. If you have that defined, then
you should be alright.
Other than that, there is no reason why you shouldn't be able to use
this from .NET.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
"Mark Jerde" <mark.jerde@verizon.no.spam.net> wrote in message
news:%23UdwDBRtEHA.2956@TK2MSFTNGP12.phx.gbl...
>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#.
>
>
- Next message: Tomas Restrepo \(MVP\): "Re: managed string -> unmanaged string"
- Previous message: Dan Guzman: "Re: establishing cause of access violation?"
- In reply to: Mark Jerde: "Can C# Call This DLL?"
- Next in thread: Mark Jerde: "Re: Can C# Call This DLL?"
- Reply: Mark Jerde: "Re: Can C# Call This DLL?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|