I'm trying to build a wrapper but the pointer gives me a hard time.
the C code:
typedef enum
{
MANYMOUSE_EVENT_ABSMOTION = 0,
MANYMOUSE_EVENT_RELMOTION,
MANYMOUSE_EVENT_BUTTON,
MANYMOUSE_EVENT_SCROLL,
MANYMOUSE_EVENT_DISCONNECT,
MANYMOUSE_EVENT_MAX
} ManyMouseEventType;
__declspec(dllexport) typedef struct
{
ManyMouseEventType type;
unsigned int device;
unsigned int item;
int value;
int minval;
int maxval;
} ManyMouseEvent;
__declspec(dllexport) int ManyMouse_PollEvent(ManyMouseEvent *event);
C# code:
[DllImport("ManyMouseDLL.dll")]
public static extern int ManyMouse_PollEvent( ); 3 1487
I think I've figured it to a certain degree but I still don't know how
to 'fix' the enumeration.
[DllImport("ManyMouseDLL.dll",CharSet = CharSet.Ansi)]
internal static extern int
ManyMouse_PollEvent([MarshalAs(UnmanagedType.LPStruct)] ManyMouseEvent
MouseEvent);
[StructLayout (LayoutKind.Sequential)]
internal struct ManyMouseEvent
{
public int device;
public int item;
public int value;
public int minval;
public int maxval;
};
Any help is appreciated
On Mar 29, 4:32 am, "Calin" <calinne...@gmail.comwrote:
I'm trying to build a wrapper but the pointer gives me a hard time.
the C code:
typedef enum
{
MANYMOUSE_EVENT_ABSMOTION = 0,
MANYMOUSE_EVENT_RELMOTION,
MANYMOUSE_EVENT_BUTTON,
MANYMOUSE_EVENT_SCROLL,
MANYMOUSE_EVENT_DISCONNECT,
MANYMOUSE_EVENT_MAX
} ManyMouseEventType;
__declspec(dllexport) typedef struct
{
ManyMouseEventType type;
unsigned int device;
unsigned int item;
int value;
int minval;
int maxval;
} ManyMouseEvent;
__declspec(dllexport) int ManyMouse_PollEvent(ManyMouseEvent *event);
C# code:
[DllImport("ManyMouseDLL.dll")]
public static extern int ManyMouse_PollEvent( );
>I think I've figured it to a certain degree but I still don't know how
>to 'fix' the enumeration.
What you have is almost valid C# code. Just strip off the typedef
stuff.
enum ManyMouseEventType
{
MANYMOUSE_EVENT_ABSMOTION = 0,
MANYMOUSE_EVENT_RELMOTION,
MANYMOUSE_EVENT_BUTTON,
MANYMOUSE_EVENT_SCROLL,
MANYMOUSE_EVENT_DISCONNECT,
MANYMOUSE_EVENT_MAX
}
>[DllImport("ManyMouseDLL.dll",CharSet = CharSet.Ansi)]
internal static extern int ManyMouse_PollEvent([MarshalAs(UnmanagedType.LPStruct)] ManyMouseEvent MouseEvent);
Make that
internal static extern int ManyMouse_PollEvent(ref ManyMouseEvent
MouseEvent);
Mattias
--
Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
On Mar 29, 10:02 pm, Mattias Sjögren <mattias.dont.want.s...@mvps.org>
wrote:
I think I've figured it to a certain degree but I still don't know how
to 'fix' the enumeration.
What you have is almost valid C# code. Just strip off the typedef
stuff.
enum ManyMouseEventType
{
MANYMOUSE_EVENT_ABSMOTION = 0,
MANYMOUSE_EVENT_RELMOTION,
MANYMOUSE_EVENT_BUTTON,
MANYMOUSE_EVENT_SCROLL,
MANYMOUSE_EVENT_DISCONNECT,
MANYMOUSE_EVENT_MAX
}
[DllImport("ManyMouseDLL.dll",CharSet = CharSet.Ansi)]
internal static extern int
ManyMouse_PollEvent([MarshalAs(UnmanagedType.LPStruct)] ManyMouseEvent
MouseEvent);
Make that
internal static extern int ManyMouse_PollEvent(ref ManyMouseEvent
MouseEvent);
Mattias
--
Mattias Sjögren [C# MVP] mattias @ mvps.orghttp://www.msjogren.net/dotnet/|http://www.dotnetinterop.com
Please reply only to the newsgroup.
Thanks that works fine. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: jarmopy |
last post by:
Hi,
I have made a service with C# and calling that service class from another C#
program with remoting.
(Referendes from the calling program)
That service class is configured so that garpage...
|
by: johny smith |
last post by:
I am trying to figure out a way to print the address of what called a
certain function once inside the function.
I am assuming that this information is on the stack somewhere. But can
someone...
|
by: William Payne |
last post by:
Hello, consider these following two classes. A base class, class
MDIChildWindow, and a class inherting from that base class, class Document.
In the static base member function callback() I obtain a...
|
by: Andreas Lagemann |
last post by:
Hi,
after browsing FAQ and archive for a while I decided that the following
is a legal question.
Consider this:
Class Base
{
public:
Base() {}
|
by: Francesco Bochicchio |
last post by:
Hi all,
anybody knows if there is a (standard, portable) way to dinamically build
a list of parameters to call a C function? Something like va_start & co,
but to be used on the calling side?
...
|
by: Ross A. Finlayson |
last post by:
Hi,
I hope you can help me understand the varargs facility.
Say I am programming in ISO C including stdarg.h and I declare a
function as so:
void log_printf(const char* logfilename, const...
|
by: I_have_nothing |
last post by:
Hi!
I am new in C. I try to use dynamical allocation fuction malloc( ) and
realloc( ).
I found something strange.
After several calling realloc( ), the malloc( ) will give me a
Segmentation...
|
by: Joakim Hove |
last post by:
Hello,
I have implemented a small library with a function a datatype to
manage temporary storage, and handle out correctly casted storage. The
function to get a double pointer is for instance:
...
|
by: santosh |
last post by:
Hi,
If I call free() with a uninitialised pointer, will the program
state become undefined, or will free() return harmlessly?
Incidentally, is there a way in Standard C to determine
weather a...
|
by: unauthorized |
last post by:
The short story:
I need to be able to cast a function pointer for any function and class to an intermediate type, so I could call it from any point of my program using the "__asm call" instruction....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |