Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2003-11-13
12
Medium Priority
?
775 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
Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

 
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Progress means simplifying, not complicating. Bruno Munari Preface How to detect the name of the internal storage or an SD-card on Windows Mobile device from the desktop application? I got this question, when I was working on a PC applicati…
If you are anything like me, you install many apps on your phone and have your life on it, sometimes literally.  When I bought my current phone, a Samsung Galaxy S5 from Verizon, they were only selling the versions with 16 GB internal.  I didn't rea…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

927 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