Sunday, April 25, 2010

Calling Native Code from C#. (.Net CF in WM)

One of My Colleague was trying to configure a GPIO pin from a C# Application. To call the native code we have P- Invoke in C#. But sometimes it confuses,what data types to use while declaring the function in C# and whether that type is compatible in C/C++.

Another Colleague suggested a smart way of handling these type of issues.

If you are not passing any input to the Native code from C#(or if it is not required to pass), then simply define a a function with no input and do all the processing in the native code itself. In Native code you can call any system APIs like DeviceIoctl or MmMapIoSpace and have any data types you need to.

This may help the beginners to catch up !!

No comments:

Post a Comment