Dear all,
I am doing an Windows CE 5.0 application project, which requires
vibrating function. I have tried three ways to implement it, but all
fails.
impl
Here is the summary of my trials.
Project Background
OS: Windows CE 5.0
Framework version: .NET Compact Framework 2.0 SP2
Trial 1:
Using OpenNetCF community version 2.3
I refereneced OpenNETCF.WindowsMobile to my project, and try calling
Vibrate method.
However, it failed woth the following exception message:
Can't find an Entry Point 'VibrateGetDeviceCaps' in a PInvoke DLL
'aygshell.dll'.
Here is the core code used for the trial:
using System;
...
using OpenNETCF.WindowsMobile;
...
private void btnTestVibration_Click(object sender, EventArgs e) {
MessageBox.Show("Supported Amplitude Level(s) " +
Vibrate.GetDeviceCaps(Vibrate.VibrationCapabilities.Amplitude).ToString
());
}
Trial 2:
P/Invoke Vibrate(), VibrateGetDeviceCaps() and VibrateStop() from
aygshell.lib
Referring to the article in MSDN (http://msdn.microsoft.com/en-us/
library/ms836136.aspx), I invoked those three methods to my project.
However, it also didn't work with the following exception returned:
Can't find PInvoke DLL 'aygshell.lib'.
Ironically, the bottom part of the article stated device running
Windows CE 3.0 or above would support those functions.
[...
Requirements
Smartphone Platforms: Smartphone 2002 and later
OS Versions: Windows CE 3.0 and later
Header: Declared in vibrate.h
Library: Use aygshell.lib
...
]
Here is the core code used for this trial:
using System;
...
["using OpenNETCF.WindowsMobile" is removed]
...
public class Vibrator
{
[DllImport("aygshell.lib", EntryPoint = "Vibrate",
SetLastError = true)]
public static extern VibrateReturnValue Vibrate(uint
numOfElements, VibrateNote[] noteArray, bool isRepeat, uint timeout);
[DllImport("aygshell.lib", EntryPoint =
"VibrateGetDeviceCaps", SetLastError = true)]
public static extern int GetDeviceCaps(VibrateDeviceCaps
caps);
[DllImport("aygshell.lib", EntryPoint = "VibrateStop",
SetLastError = true)]
public static extern int Stop();
}
[Flags, UnmanagedName("VIBRATEDEVICECAPS")]
public enum VibrateDeviceCaps
{
/// <summary>
/// Query the amplitude that the device supports
/// </summary>
VDC_AMPLITUDE,
/// <summary>
/// Query the frequency that the device supports.
/// </summary>
VDC_FREQUENCY,
/// <summary>
/// A placeholder to indicate the last value in the list
/// </summary>
VDC_LAST
}
...
public partial class Form1 : Form
{
private void btnTestVibration_Click(object sender, EventArgs e) {
MessageBox.Show("Supported Amplitude Level(s) " +
Vibrator.GetDeviceCaps(VibrateDeviceCaps.VDC_AMPLITUDE).ToString());
}
Trial 3:
Similar to Trial 2, but I tried to invoke those from "aygshell.dll"
instead.
Still, I got the same message as the trial 1 did:
Can't find an Entry Point 'VibrateGetDeviceCaps' in a PInvoke DLL
'aygshell.dll'.
After all, I searched MSDN for "aygshell" again, and these seems no
any vibration-related functions.
(http://msdn.microsoft.com/en-us/library/ms927275.aspx).
To conclude, vibration support may not to able to be implemented from
'aygshell' library. Therefore, I came here and posted question, in
hope of getting an solution to achieve the goal.
I am glad to provide more information if needed. Many thanks.
Alexander Man