[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

PC to phone via Bluetooth

Asked by wisemanxxx in Visual Basic Programming, Winsock

Tags: bluetooth

want to use vb6 for discovering bluetooth devices (cellular phones) in area and then sending vnotes to them. I use winsock and ws2 .. Please tell me how can I discover phones and send a message to them shortly. thanks by now. Please send me a short vb example for this.. or tell me a book name or site address please. I really need it.

I use wsalookupservicestart but vb6 is crashing when I try to use this function. My source code is :
 Private Const ERROR_SUCCESS = 0
Private Const INVALID_SOCKET = 0
Private Const MIN_SOCKETS_REQD As Long = 1
Private Const WS_VERSION_REQD As Long = &H202
Private Const WS_VERSION_MAJOR As Long = WS_VERSION_REQD \ &H100 And &HFF&
Private Const WS_VERSION_MINOR As Long = WS_VERSION_REQD And &HFF&

Private Const AF_BTH = 32
Private Const PF_BTH = 32
Private Const NS_BTH = 16
Private Const BTHPROTO_RFCOMM = 3



Private Function HiByte(ByVal wParam As Integer)
    HiByte = wParam \ &H100 And &HFF&
End Function
Private Function LoByte(ByVal wParam As Integer)
    LoByte = wParam And &HFF&
End Function
Private Sub SocketsCleanup()
    If WSACleanup() <> ERROR_SUCCESS Then
        MsgBox "Socket error occurred in Cleanup."
    End If
End Sub
Private Function SocketsInitialize() As Boolean
    Dim WSAD As WSADATA
    Dim sLoByte As String
    Dim sHiByte As String
    If WSAStartup(WS_VERSION_REQD, WSAD) <> ERROR_SUCCESS Then
        MsgBox "The 32-bit Windows Socket is not responding."
        SocketsInitialize = False
        Exit Function
    End If
    If LoByte(WS_VERSION_REQD) < 2 Then
        If WSAD.iMaxSockets < MIN_SOCKETS_REQD Then
            MsgBox "This application requires a minimum of " & CStr(MIN_SOCKETS_REQD) & " supported sockets."
            SocketsInitialize = False
            Exit Function
        End If
    End If
    If LoByte(WSAD.wVersion) < WS_VERSION_MAJOR Or (LoByte(WSAD.wVersion) = WS_VERSION_MAJOR And HiByte(WSAD.wVersion) < WS_VERSION_MINOR) Then
        sHiByte = CStr(HiByte(WSAD.wVersion))
        sLoByte = CStr(LoByte(WSAD.wVersion))
        MsgBox "Sockets version " & sLoByte & "." & sHiByte & " is not supported by 32-bit Windows Sockets."
        SocketsInitialize = False
        Exit Function
    End If
    'must be OK, so lets do it
    MsgBox "Sozkets Initialized"
    SocketsInitialize = True
End Function


Public Function Find_First_BT() As Boolean
    Dim BTH_Query As WSAQUERYSET
    Dim Next_Handle As Long
    Dim BTH_Lookup_Flags As Long
    Dim Bth_Socket_Num As Long

    If SocketsInitialize = False Then
        SocketsCleanup
        MsgBox "Error Opening Socket for Bluetooth"
        Find_First_BT = False
        Exit Function
    End If
   
    Bth_Socket_Num = socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM)
    If Bth_Socket_Num = INVALID_SOCKET Then
        SocketsCleanup
        MsgBox "Error :INVALID_SOCKET on opening a Socket for Bluetooth"
        Find_First_BT = False
        Exit Function
    End If

   ' WSACleanup

    'BTH_Query.dwNameSpace = 0
   
    BTH_Query.dwNameSpace = NS_BTH
    BTH_Query.dwSize = Len(BTH_Query)
 BTH_Query.dwNumberOfCsAddrs = 0
 BTH_Query.lpafpProtocols.iAddressFamily = AF_BTH
  BTH_Query.lpafpProtocols.iProtocol = BTHPROTO_RFCOMM
'GoTo ATLA
BTH_Query.lpServiceClassId.Data1 = &H1105
BTH_Query.lpServiceClassId.Data2 = &H0
BTH_Query.lpServiceClassId.Data3 = &H1000
BTH_Query.lpServiceClassId.Data4(0) = &H80
BTH_Query.lpServiceClassId.Data4(1) = &H0
BTH_Query.lpServiceClassId.Data4(2) = &H0
BTH_Query.lpServiceClassId.Data4(3) = &H80
BTH_Query.lpServiceClassId.Data4(4) = &H5F
BTH_Query.lpServiceClassId.Data4(5) = &H9B
BTH_Query.lpServiceClassId.Data4(6) = &H34
BTH_Query.lpServiceClassId.Data4(7) = &HFB
ATLA:

    BTH_Lookup_Flags = LUP_CONTAINERS Or LUP_RETURN_ADDR Or LUP_RETURN_NAME Or LUP_FLUSHCACHE

    MsgBox "About to scan for BT devices"
   
    result = WSALookupServiceBegin(BTH_Query, BTH_Lookup_Flags, Next_Handle)
   
    MsgBox "Done first step in scan for BT devices"
       
    If result = SOCKET_ERROR Then
        SocketsCleanup
        result = closesocket(Bth_Socket_Num)
        MsgBox "Error calling WSALookupServiceBegin"
        Find_First_BT = False
        Exit Function
    End If
   
   
    result = closesocket(Bth_Socket_Num)
    SocketsCleanup

End Function

Private Sub Command1_Click()
Find_First_BT
End Sub
' --------------------------
I use a winsock module for functions and other types and stuff.
[+][-]07/21/05 06:22 AM, ID: 14493152Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/29/05 12:32 AM, ID: 14552579Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/29/05 05:34 AM, ID: 14553971Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/16/05 11:38 PM, ID: 14689363Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/18/05 12:31 PM, ID: 15507825Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]12/22/05 11:34 AM, ID: 15536766Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Visual Basic Programming, Winsock
Tags: bluetooth
Sign Up Now!
Solution Provided By: DarthMod
Participating Experts: 2
Solution Grade: A
 
 
Loading Advertisement...
20091021-EE-VQP-81