Prakash,
Sorry, I should have added those earlier.
public const uint E_FAIL = 0x80004005;
public const uint WAIT_FAILED = 0xffffffff;
public const uint WAIT_TIMEOUT = 0x00000102;
[StructLayout(LayoutKind.Sequential)]
public struct RAPIINIT
{
public uint cbSize;
public uint heRapiInit;
public uint hrRapiInit;
}
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
public static extern uint CeRapiInitEx([MarshalAs(UnmanagedType.Struct)] ref
RAPIINIT pRapiInit);
[DllImport("kernel32.dll", SetLastError=true)]
public static extern uint WaitForSingleObject(uint hHandle, int
milliseconds);
Regards,
Neville Lang
"prakash" <(E-Mail Removed)> wrote in message
news:A30CB0FC-E9E2-4444-BEF1-(E-Mail Removed)...
> Thank you very much Neville
>
> can you give the declaration of RAPIINIT,CeRapiInitEx , constant values
>
> regards
> prakash
>
> "Neville Lang" wrote:
>
> > Prakash,
> >
> > I am using ordinary RAPI and not the one from OpenNETCF though I susepct
> > these would be the same.
> >
> > The clue is that CeRapiInit() simply waits for a connection, effectively
> > "hanging" the program. I have found the best choice is to use the
> > CeRapiInitEx(). Here is a method that might be useful in that it informs
the
> > user if there is no connection:
> >
> > public static bool IsDeviceConnected(int MillisecondsToWait)
> > {
> > RAPIINIT rapiStructure = new RAPIINIT();
> > rapiStructure.cbSize = 12;
> > uint hResult = CeRapiInitEx(ref rapiStructure);
> > if (hResult == E_FAIL)
> > {
> > MessageBox.Show("Unable to initialize connection to device !!");
> > return false;
> > }
> > uint hWait = WaitForSingleObject(rapiStructure.heRapiInit,
> > MillisecondsToWait);
> > if (hWait == WAIT_FAILED)
> > {
> > MessageBox.Show("Unable to wait for device: " +
> > Marshal.GetLastWin32Error().ToString());
> > return false;
> > }
> > if (hWait == WAIT_TIMEOUT)
> > {
> > MessageBox.Show("Timed out waiting for device !!");
> > return false;
> > }
> > if (rapiStructure.hrRapiInit == E_FAIL)
> > {
> > MessageBox.Show("Failed to connect to device !!");
> > return false;
> > }
> > return true;
> > }
> >
> >
> > I pass a value of 5000 to this method, allowing 5 seconds to wait if the
PPC
> > is not in the cradle.
> >
> > Regards,
> > Neville Lang
|