Solved

This VB code works with Active Sync 3.5 and 3.6, but not 3.7

Posted on 2003-11-13
12
763 Views
Last Modified: 2013-12-27
I'm using the following VB 6.0 code to connect to my Pocket PC. RapiConnect() is successful with Active Sync 3.5 and 3.6, but not 3.7.1
I would think 3.7 would be backwards compatible, but it looks like rapi.dll has changed... Does anyone why it's not working? Thank you!
Option Explicit

Private Type CEOSVERSIONINFO
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
End Type

Private Type RAPIINIT
    cbSize As Long
    heRapiInit As Long
    hrRapiInit As Long
End Type

Private Declare Function CeRapiInitEx Lib "rapi.dll" ( _
    pRapiInit As RAPIINIT) As Long

Private Declare Function CeGetVersionEx Lib "rapi.dll" ( _
    lpVersionInformation As CEOSVERSIONINFO) As Boolean
   

Public Function RapiConnect() As Boolean
    ' Initiates a connection and returns True if it connected, False if it did not
   
    Dim pRapiInit As RAPIINIT
   
    On Error GoTo RapiConnect_Err

    With pRapiInit
        .cbSize = Len(pRapiInit)
    End With
    Call CeRapiInitEx(pRapiInit)
    RapiConnect = RapiGetCEOSVersionString <> ""
    Exit Function
   
RapiConnect_Err:
    RapiConnect = False
End Function


Public Function RapiGetCEOSVersionString() As String
    ' Returns the Major, Minor, and Build number of the OS In a string
    Dim ceosver As CEOSVERSIONINFO
   
    ceosver.dwOSVersionInfoSize = Len(ceosver)
   
    If CeGetVersionEx(ceosver) Then
        RapiGetCEOSVersionString = ceosver.dwMajorVersion & "." & _
            ceosver.dwMinorVersion & "." & _
            ceosver.dwBuildNumber & " " & _
            Left$(ceosver.szCSDVersion, _
            InStr(ceosver.szCSDVersion, Chr$(0)) - 1)
    Else
        RapiGetCEOSVersionString = ""
    End If
End Function


0
Comment
Question by:EwS
  • 5
  • 2
  • 2
  • +1
12 Comments
 
LVL 48

Expert Comment

by:Mikal613
ID: 9742688
Microsft ActiveSync was made for Windows CE 4.2

The only languages that can be used for 4.2 (that are supported) are eMbedded Visual C++ 4.2 and Visual Studio.NET

I would suggest Upgrading your project to One of these 2

http://support.microsoft.com/default.aspx?scid=kb;en-us;307256
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 9742723
try this

http://www.aximsite.com/boards/showthread/t-21809.html

Uninstall ActiveSync 3.7 Startover and follow those directions on the Link.
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 9742728
Give attention to Step 5

5th step
Copy rapi.dll and ceutil.dll from Program Files\Microsoft ActiveSync to Windows\System32

0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 48

Expert Comment

by:Mikal613
ID: 9742737
Also

C:\WINDOWS\SYSTEM32\rapi.dll
Old date: 5/28/2002 3:54 PM
New date: 3/26/2003 6:28 PM
Old size: 73,809 bytes
New size: 73,803 bytes
It did change
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 9742747
There is a problem with 3.7.1 and until Microsoft fix it you will need to install 3.7 or earlier.
This should still work on almost all devices.
0
 

Author Comment

by:EwS
ID: 9749184
Thanks for all the help and quick responses!
Actually, it seems that Microsoft introduced changes in the timing with ActiveSync 3.7 and it takes a bit longer to establish a connection with the device. My solution: I used MsgWaitForMultipleObjects function with a timeout value of 5 seconds and it worked!
0
 

Expert Comment

by:jason_cartwright
ID: 10552147
I'm having this same issue. Can you post the modified code that solved the issue?
0
 

Accepted Solution

by:
EwS earned 0 total points
ID: 10552776
Here it is:

Option Explicit

Private Type RAPIINIT
    cbSize As Long
    heRapiInit As Long
    hrRapiInit As Long
End Type

Private Declare Function CeRapiInitEx Lib "rapi.dll" ( _
    pRapiInit As RAPIINIT) As Long

Private Declare Function MsgWaitForMultipleObjects Lib "user32" ( _
    ByVal nCount As Long, _
    ByRef pHandles As Long, _
    ByVal fWaitAll As Long, _
    ByVal dwMilliseconds As Long, _
    ByVal dwWakeMask As Long) As Long
   
' GetQueueStatus flags
Private Const QS_KEY = &H1
Private Const QS_MOUSEMOVE = &H2
Private Const QS_MOUSEBUTTON = &H4
Private Const QS_POSTMESSAGE = &H8
Private Const QS_TIMER = &H10
Private Const QS_PAINT = &H20
Private Const QS_SENDMESSAGE = &H40
Private Const QS_HOTKEY = &H80

Private Const QS_MOUSE = (QS_MOUSEMOVE Or QS_MOUSEBUTTON)
Private Const QS_INPUT = (QS_MOUSE Or QS_KEY)
Private Const QS_ALLEVENTS = (QS_INPUT Or QS_POSTMESSAGE Or QS_TIMER Or QS_PAINT Or QS_HOTKEY)
Private Const QS_ALLINPUT = (QS_SENDMESSAGE Or QS_PAINT Or QS_TIMER Or QS_POSTMESSAGE Or QS_MOUSEBUTTON Or QS_MOUSEMOVE Or QS_HOTKEY Or QS_KEY)

' Possible returns from MsgWaitForMultipleObjects
Private Const WAIT_OBJECT_0 = 0&
Private Const WAIT_TIMEOUT = &H102&
Private Const WAIT_ABANDONED_0 = &H80&
   
Private Const INFINITE = -1&
   

Public Function RapiConnect() As Boolean
    ' Initiates a connection and returns True if it connected, False if it did not
   
    On Error GoTo RapiConnect_Err

    Dim pRapiInit As RAPIINIT
   
    With pRapiInit
        .cbSize = Len(pRapiInit)
    End With
    Call CeRapiInitEx(pRapiInit)
   
    Dim retval As Long
    retval = 1
   
    Do
        ' Try to connect to the device until a connection is established or a timeout (5 seconds) occurs
        retval = MsgWaitForMultipleObjects(1&, pRapiInit.heRapiInit, False, 5000, _
            (QS_POSTMESSAGE Or QS_SENDMESSAGE))
        DoEvents
    Loop Until retval = WAIT_OBJECT_0 Or retval = WAIT_TIMEOUT
   
    If retval = 0 Then
        RapiConnect = True
    Else
        RapiConnect = False
    End If
       
    Exit Function
   
RapiConnect_Err:
    RapiConnect = False

End Function


0
 

Expert Comment

by:jason_cartwright
ID: 10553366
Great, that will be a big help. Also, it seems that the adofltr.dll methods DEVICETODESKTOP and DESKTOPTODEVICE have been affected. Has anyone encountered this with ActiveSync 3.7 and found a resolution?

Looks like it's about time to convert these "legacy" VB apps up to .NET.
0
 

Expert Comment

by:zippy6000
ID: 10861887
I am having the same problem as above.  I have added the example code to my project and still receive an error using ActiveSync 3.7.1  It actually closes VB during the sync so there is no way to debug the code.  Does anyone else have a solution for this problem?
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When I was a beginner in Windows Mobile programming, even for small test I used to create a single MFC dialog-based application with one button, and put my test code in the OnLButtonDown method. For Pocket PC it worked fine, on some Windows CE d…
A short article about problems I had with the new location API and permissions in Marshmallow
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question