BOOL WINAPI NLedGetDeviceInfo( UINT nInfoId, void *pOutput );
BOOL WINAPI NLedSetDevice( UINT nDeviceId, void *pInput );
NLedGetDeviceInfo是获得LED数量,NLedSetDevice是来设置LED状态的,我们只有通过它来启动或者关闭Pocket PC设备的震动与否。说明一下:一般PPC设备都有两个LED,一个就是扬声器0(Radio LED),另一个则是振动器1(Vibrator)了。在我的PPC设备上发现第二个是Vibrator,不知道是不是所有的PPC都是这样子的。后来查到“On the HTC Himalaya the vibration device is implemented at index 1。”也就是HTC内核的都是1.
在程序里调用
LED led=new LED();
led.SetLedStatus(LED.Status.ON,500);//震动500毫秒
以上就是自己通过P/Invoke来实现震动效果,还有一段文字值得注意的:
for example some devices contain a notification Led at position 0 and a vibration device at position 5. There is no way to programmatically determine the index of the vibration device, you can only determine the overall count of devices. Also the vibration device can only be turned on or off so the Blink setting behaves exactly as On would.
当然你可以直接使用OpenNETCF的类库,如下:
OpenNETCF.Notification.Led led = new OpenNETCF.Notification.Led();
//turn on vibration
led.SetLedStatus(1, OpenNETCF.Notification.Led.LedState.On);
//turn off vibration
led.SetLedStatus(1, OpenNETCF.Notification.Led.LedState.Off);