以编程方式访问摩托罗拉MC9500运动传感器

本文关键字:MC9500 运动 传感器 摩托罗拉 访问 编程 方式 | 更新日期: 2023-09-27 18:18:18

我目前正在为具有Windows Mobile 6.5Motorola MC9500的windows移动应用程序工作。我已经尝试了符号的EMDK库访问内置的运动传感器的设备没有任何运气。

. net v2.7的EMDK有Symbol.Sensor类库在它应该访问所有内置传感器,但我不知道如何使用它。

Symbol.Sensor.SensorManager manager = new Symbol.Sensor.SensorManager();

我在这里得到一个MissingMethodException异常,说…"Can't find PInvoke DLL SensorsAPI.dll ."

如何使用c#访问运动传感器?

以编程方式访问摩托罗拉MC9500运动传感器

我将发布一个dllImport示例作为@HemendraSharma评论的继续。以上代码是为移动设备编写的,用于更改系统小时。

using System;
using System.Runtime.InteropServices;
namespace changeHour
{   
public class cDateTime  
{       
    [StructLayout(LayoutKind.Sequential)]       
    private struct SystemTime
    {           
        public ushort uYear;            
        public ushort uMonth;           
        public ushort uDayOfWeek;           
        public ushort uDay;         
        public ushort uHour;            
        public ushort uMinute;          
        public ushort uSecond;          
        public ushort uMilliseconds;            
        public SystemTime(
            ushort uYear, 
            ushort uMonth, 
            ushort uDay, 
            ushort uHour, 
            ushort uMinute, 
            ushort uSecond)
        {               
            this.uYear = uYear;             
            this.uMonth = uMonth;               
            this.uDayOfWeek = 0;                
            this.uDay = uDay;               
            this.uHour = uHour;             
            this.uMinute = uMinute;             
            this.uSecond = uSecond;             
            this.uMilliseconds = 0;         
        }       
    }       
    [DllImport("Coredll.dll")]          
    private static extern bool SetLocalTime(ref SystemTime st);
           [DllImport("Coredll.dll")]           
           private static extern uint SetSystemTime(ref SystemTime st);     

    public static bool SetDateTime(
        int iYear, 
        int iMonth, 
        int iDay, 
        int iHour, 
        int iMinute, 
        int iSecond)        
           {            
        SystemTime st = 
            new SystemTime
            (
            Convert.ToUInt16(iYear), 
            Convert.ToUInt16(iMonth), 
            Convert.ToUInt16(iDay), 
            Convert.ToUInt16(iHour), 
            Convert.ToUInt16(iMinute), 
            Convert.ToUInt16(iSecond)
            );          
        return SetLocalTime(ref st);        
    }
    public static uint SetDateTimeSystem(
        int iYear,
        int iMonth,
        int iDay,
        int iHour,
        int iMinute,
        int iSecond)
    {
        SystemTime st =
            new SystemTime
            (
            Convert.ToUInt16(iYear),
            Convert.ToUInt16(iMonth),
            Convert.ToUInt16(iDay),
            Convert.ToUInt16(iHour),
            Convert.ToUInt16(iMinute),
            Convert.ToUInt16(iSecond)
            );
        return SetSystemTime(ref st);
    }       

    public static bool SetDateTime(DateTime dt)     
    {           
        return SetDateTime
            (
            dt.Year, 
            dt.Month, 
            dt.Day, 
            dt.Hour, 
            dt.Minute, 
            dt.Second
            );      
    }       

    public static bool SetDate(int iYear, int iMonth, int iDay)
    {           
        DateTime dt = DateTime.Now;         
        return SetDateTime(
            iYear, 
            iMonth, 
            iDay, 
            dt.Hour, 
            dt.Minute, 
            dt.Second);     
    }       
    public static bool SetDate(DateTime date)       
    {           DateTime time = DateTime.Now;           
        return SetDateTime(
            date.Year, 
            date.Month, 
            date.Day, 
            time.Hour, 
            time.Minute, 
            time.Second);       
    }       
    public static bool SetTime(int iHour, int iMinute, int iSecond)
    {           
        DateTime dt = DateTime.Now;         
        return SetDateTime(
            dt.Year, 
            dt.Month, 
            dt.Day, 
            iHour, 
            iMinute, 
            iSecond);       
    }       

    public static bool SetTime(DateTime time)       
    {           
        DateTime date = DateTime.Now;           
        return SetDateTime(
            date.Year, 
            date.Month, 
            date.Day, 
            time.Hour, 
            time.Minute, 
            time.Second);       
    }       
}
 }

这是我目前得出的结论…摩托罗拉MC9500的传感器不能通过编程方式访问