Solved

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

Posted on 2003-11-13
12
757 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
 
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Preface: This article is part of a series focused on cross platform mobile app development (specifically Android and iOS) using the Alloy framework and Titanium Studio made by Appcelerator (https://www.appcelerator.com/). This article presumes a wor…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now