i have this sample code i want to use. I’m not sure where to place it. I’m using Visual studio 2008 , windows mobile 6 sdk. I wish to test the accelerometer but i’m not sure where i should code it. The start is e.g. form1. Do i create new existing item > new program.cs a new C# file and do this(as of below)?
#include "smiAccelerometer.h"
SmiAccelerometerVector accel;
// get the acceleration vector containing X, Y, Z components
if (SmiAccelerometerGetVector(&accel) == SMI_SUCCESS)
{
// Successfully got acceleration.
// Use accel.x, accel.y and accel.z in your application
}
else
{
// failed to get the acceleration
}
That code snippet is C++ not C#.
In order to use this from C# you have a few options, you could create a managed C++ wrapper class and call that from C# (IMO best option). Compilet the C++ into a dll and use p/invoke and call the code directly, or you could create a COM wrapper around it and use COM interop from C#.