Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

TCP Communication

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • TCP Communication

    ' TCP Communication - TelegramTcp.bas
    ' Based on PowerBASIC sample files "\Internet\TCP\EchoServ.bas" and "EClient.bas"

    ' TCP transmit and receive via ip, chat demo network communication
    ' See next post for WSAGetLastErrorMsg.inc, TelegramTcp.rc and TelegramTCP.exe.ManifestRc

    ' Playing with IP, port and hostname etc.
    ' One instance of this app can speak to itself,
    ' you can also run 2 instance on the same PC
    ' and of course for real fun, run it on 2 different PC,
    ' you may have to disable firewall.

    ' Pierre

    ' Updated 2005-12-25

    Code:
     
    #COMPILE EXE '# Win 8.01 # Compatible PBWin 7.xx, 8.00 and 8.01
    #DIM ALL
    #INCLUDE "Win32Api.inc"           'Last Update: 2005-01-27 (January  27, 2005)
    #INCLUDE "CommCtrl.inc"           'Last updated 2003-10-27 (October 27, 2003)
    #INCLUDE "WS2_32.inc"             'Last Update: 2003-03-18 (March 18, 2003)
    #INCLUDE "WSAGetLastErrorMsg.inc" 'See next post
    #RESOURCE "TelegramTcp.PBR"       'Rem line if themed Manifest not needed
     
    $AppName              = "Telegram TCP"
     
    %LabelMyPC            = 101
    %LabelMyip            = 102
    %LabelMyPort          = 103
    %LabelPacketRcv       = 104
    %LabelPacketSnd       = 105
     
    %ButtonSetMyPort      = 201
    %ButtonIncrMyPort     = 202
    %ButtonDecrMyPort     = 203
    %ButtonSetRemoteIp    = 204
    %ButtonSetRemoteName  = 205
    %ButtonSetRemotePort  = 206
    %ButtonIncrRemotePort = 207
    %ButtonDecrRemotePort = 208
    %ButtonCls            = 209
    %ButtonSend           = 210
     
    %TextboxMyPort        = 301
    %TextboxRemoteName    = 302
    %TexboxRemotePort     = 303
    %TextBoxToSend        = 304
     
    %Listbox              = 401
    %SysIpAddr            = 501
    %OptionIp             = 601
    %OptionHostName       = 602
    %CheckFilterInfo      = 701
    %TIMEOUT              = 5000 'Five second, increase if necessary
     
    %WhiteIntro           = &hFFFFFF
    %GrayInfo             = &hF0F0F0 
    %YellowSnd            = &hF0FFFF 
    %RedError             = &hF0F0FF 
    %GreenRcv             = &hF0FFF0
    %BlueUnused           = &hFFF7F0 
    %Black                = 0
     
    %TCP_ACCEPT           = %WM_USER + 500
    %TCP_RECV             = %WM_USER + 501
     
    GLOBAL hDlg            AS DWORD
    GLOBAL hList           AS DWORD
    GLOBAL FilterInfoCheck AS DWORD
    '______________________________________________________________________________
     
    FUNCTION Say(sAddToList AS STRING, dwColor AS DWORD) AS LONG
     LOCAL  hDC       AS DWORD
     LOCAL  Si        AS ApiSize
     LOCAL  hFont     AS DWORD
     LOCAL  ListCount AS LONG
     STATIC ListWidth AS LONG
     
     IF ISFALSE((dwColor = %GrayInfo) AND FilterInfoCheck )THEN 'Do unless gray-info and filter is on
       ListCount = SendMessage(hList, %LB_ADDSTRING, 0, STRPTR(sAddToList))
       'Hi Gösta, this is where I store the item color...
       SendMessage hList, %LB_SETITEMDATA, ListCount, dwColor
       SendMessage hList, %LB_SETCURSEL, ListCount, 0
     
       'Horizontal bar stuff...
       IF ListCount = 1 THEN ListWidth = 0 'List is new or resetted
       hFont = SendMessage(hList, %WM_GETFONT, 0, 0)
       hDC = GetDC(hList)
       hFont = SelectObject(hDC, hFont)
       GetTextExtentPoint32 hDC, BYCOPY sAddToList + "W", LEN(sAddToList) + 1, Si
       ListWidth = MAX(ListWidth, Si.cx) 'Remenber the largest line
       SendMessage hList, %LB_SETHORIZONTALEXTENT, ListWidth, 0 'Set horizontal bar according to ListWidth
       SelectObject hDC, hFont
       ReleaseDC hList, hDC
     END IF
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION ipHostNameToDottedIp(sHostName AS STRING) AS STRING
     LOCAL HostentPtr AS HostEntStru PTR 
     LOCAL zPtr       AS ASCIIZ PTR
     LOCAL iaAddr     AS In_Addr
     LOCAL wdData     AS WSAData 
     LOCAL Retval     AS LONG
     
     Retval = WSAStartup(&H101, wdData)
     HostentPtr = GetHostByName(BYVAL STRPTR(sHostName)) 
     IF HostentPtr = 0 THEN
       Retval = WSAGetLastError
       Say "Error A:" & STR$(Retval)& ", " & WSAGetLastErrorMsg(Retval), %RedError
       FUNCTION =  ""
     ELSE
       iaAddr.s_Addr = @[email protected]@h_addr_list
       zPtr = inet_ntoa(iaAddr.s_addr)
       WSACleanup
       FUNCTION = @zPtr
     END IF
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION ipDottedIpToHostName(sIP AS STRING) AS STRING
     LOCAL HostentPtr AS HostEntStru PTR
     LOCAL iaAddr     AS In_Addr
     LOCAL wdData     AS WSAData 
     LOCAL Retval     AS LONG 
     
     Retval = WSAStartup(&H101, wdData)
     iaAddr.s_Addr = Inet_Addr(BYVAL STRPTR(sIP))
     HostentPtr = GetHostByAddr(iaAddr.s_Addr, 4, %PF_INET)
     IF HostentPtr = 0 THEN
       Retval = WSAGetLastError
       Say "Error B:" & STR$(Retval)& ", " & WSAGetLastErrorMsg(Retval), %RedError
     ELSE
       FUNCTION = @[email protected]_name
       WSACleanup
     END IF
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION ipDottedIpToDwordIP(BYVAL IpString AS STRING) AS DWORD
     LOCAL BytePtr AS BYTE PTR
     LOCAL IP      AS DWORD
     LOCAL Counter AS LONG
     
     BytePtr = VARPTR(IP)
     FOR Counter = 0 TO PARSECOUNT(IpString, ".") - 1
       @BytePtr[Counter] = VAL(PARSE$(IpString, ".", Counter + 1))
     NEXT Counter
     FUNCTION = IP
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION ipDwordIPToDottedIp(BYVAL IP AS DWORD) AS STRING
     LOCAL BytePtr AS BYTE PTR
     
     BytePtr = VARPTR(IP)
     FUNCTION = FORMAT$(@BytePtr[0]) & "." & FORMAT$(@BytePtr[1]) & "." & _
                FORMAT$(@BytePtr[2]) & "." & FORMAT$(@BytePtr[3])
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION GetRemotePort(BYVAL fFileNumber AS DWORD) AS DWORD
     LOCAL WinsockSocketHandle AS DWORD 
     LOCAL SocketAddress       AS SockAddr_in
     
     WinsockSocketHandle = FILEATTR(fFileNumber, 2) 
     'Use GetSockName() for local and GetPeerName() for remote
     IF GetPeerName(WinsockSocketHandle, BYVAL VARPTR(SocketAddress), SIZEOF(SocketAddress)) = 0 THEN
       FUNCTION = HTONS(SocketAddress.sin_port)
     END IF  
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION ipGetRemoteDwordIP(BYVAL fFileNumber AS DWORD) AS DWORD
     LOCAL WinsockSocketHandle AS DWORD 
     LOCAL SocketAddress       AS SockAddr_in
     
     WinsockSocketHandle = FILEATTR(fFileNumber, 2) 
     'Use GetSockName() for local and GetPeerName() for remote
     IF GetPeerName(WinsockSocketHandle, BYVAL VARPTR(SocketAddress), SIZEOF(SocketAddress)) = 0 THEN
       FUNCTION = SocketAddress.sin_addr.s_addr 
     END IF  
     
    END FUNCTION
    '______________________________________________________________________________
     
    SUB FocusRectangle() 'Thank to Börje Hagsten
     LOCAL  hDC       AS DWORD
     LOCAL  hBrush    AS DWORD
     LOCAL  hPen      AS DWORD
     LOCAL  rc        AS RECT
     LOCAL  Clr       AS DWORD
     STATIC hCtrl     AS DWORD
     
     IF hCtrl THEN 'Erase previous rectangle
       Clr = GetSysColor(%COLOR_3DFACE)  
       GOSUB DrawRectangle
     END IF
     
     IF GetForegroundWindow = hDlg THEN
       hCtrl = GetFocus() 
       IF GetDlgCtrlId(GetFocus()) = %SysIpAddr THEN hCtrl = GetParent(hCtrl)
       Clr = &H0000FF
       GOSUB DrawRectangle   
     END IF  
     
     EXIT SUB '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
     
     DrawRectangle:
       GetWindowRect hCtrl, rc        'Get control's pos and size
       MapWindowPoints 0, hDlg, rc, 2 'Map rect to dialog
       InflateRect rc, 2, 2           'Increase slightly to draw around control
     
       hDC = GetDc(hDlg)                   'Use dialog's DC since we want to paint on it
       hPen = CreatePen(%PS_SOLID, 1, Clr) 'Create a pen for given color
       hPen = SelectObject(hDC, hPen)      'Select the new pen into the DC
       hBrush = SelectObject(hDC, GetStockObject(%NULL_BRUSH)) 'Use stock null brush for hollow rect
     
       Rectangle hDC, rc.nLeft, rc.nTop, rc.nRight, rc.nBottom 'draw the rectangle
     
       SelectObject hDC, hBrush 'return original pen and brush, then release DC
       DeleteObject SelectObject(hDC, hPen)
       ReleaseDc hDlg, hDC
     
     RETURN
     
    END SUB
    '______________________________________________________________________________
     
    CALLBACK FUNCTION DlgProc() AS LONG
     LOCAL  sBuffer     AS STRING
     LOCAL  sBigBuffer  AS STRING
     STATIC fRecv       AS DWORD
     STATIC fMyPort     AS DWORD
     STATIC MyIp        AS DWORD
     STATIC dwIpRemote  AS DWORD 
     STATIC MyPort      AS DWORD
     STATIC RemotePort  AS DWORD
     STATIC fRemotePort AS DWORD
     STATIC PacketSnd   AS DWORD 
     STATIC PacketAck   AS DWORD 
     STATIC Hourglass   AS LONG
     STATIC hFocus      AS DWORD
     LOCAL  hPen        AS DWORD
     LOCAL  hBrush      AS DWORD
     LOCAL  dwColor     AS DWORD 
     LOCAL  CtrlId      AS DWORD
     LOCAL  DiSPtr      AS DRAWITEMSTRUCT PTR
     LOCAL  zItem       AS ASCIIZ * 1024
     
     SELECT CASE CBMSG
     
       CASE %WM_INITDIALOG ' - - - - - - - - - - - - - - - - - - - - - - - - - - - 
         CONTROL HANDLE CBHNDL, %Listbox TO hList
         Say "How to play...", %WhiteIntro
         Say "", %WhiteIntro
         Say "Set a port number and click <Set local port> button.", %WhiteIntro
         Say "Choose <Remote ip> or <Remote name>,", %WhiteIntro
         Say "give valid ip or name and click coresponding button.", %WhiteIntro
         Say "Note that local setting are preset for auto test.", %WhiteIntro
         Say "Set a remote port number and click <Set remote port> button.", %WhiteIntro
         Say "Fill the <Text to send...> textbox", %WhiteIntro
         Say "Click the <Send> button.", %WhiteIntro
         Say "Use the <Clear> button to clear this listbox.", %WhiteIntro
         Say "", %WhiteIntro
         Say "To use 2 instance of the program on the same computer,", %WhiteIntro
         Say "Try to set the first dialog with local port = 18000", %WhiteIntro
         Say "and remote port to 18001,", %WhiteIntro
         Say "then the second dialog with local port = 18001", %WhiteIntro
         Say "and remote port to 18000", %WhiteIntro
         Say "Click both <Set local port> button first, then other buttons.", %WhiteIntro
         Say "", %WhiteIntro
         Say "Of course, real fun is with 2 different computers...", %WhiteIntro
         Say "Click both <Set local port> button first, then other button.", %WhiteIntro
         Say "", %WhiteIntro
         Say "Messages are showed on gray line", %GrayInfo
         Say "Sent data is shown on a yellow line", %YellowSnd
         Say "Received data is shown on a green line", %GreenRcv
         Say "Errors are shown on a red line", %RedError         
         Say "", %WhiteIntro
         Say "Have fun", %WhiteIntro
         Say "", %WhiteIntro
         Say "Pierre", %WhiteIntro
         LISTBOX SELECT CBHNDL, %Listbox, 1  
     
         fRecv       = %INVALID_SOCKET  
         fMyPort     = %INVALID_SOCKET
         fRemotePort = %INVALID_SOCKET
         MyPort      = 18000 'Registered ports 1024-49151
         RemotePort  = 18000 'Registered ports 1024-49151
         CONTROL SET TEXT CBHNDL, %TextboxMyPort, FORMAT$(MyPort)
         CONTROL SET TEXT CBHNDL, %TexboxRemotePort, FORMAT$(RemotePort)
     
         HOST ADDR TO MyIp
         HOST NAME MyIp TO sBuffer
         CONTROL SET TEXT CBHNDL, %LabelMyPC, sBuffer 
         CONTROL SET TEXT CBHNDL, %LabelMyip, ipDwordIPToDottedIp(MyIp)
         CONTROL SET TEXT CBHNDL, %SysIpAddr, ipDwordIPToDottedIp(MyIp)
         CONTROL SET TEXT CBHNDL, %TextboxRemoteName, sBuffer
         CONTROL SET FOCUS CBHNDL, %ButtonSetMyPort  
         'CONTROL SEND CBHNDL, %ButtonSetMyPort, %WM_UPDATEUISTATE, MAKLNG(%UIS_CLEAR, %UISF_HIDEFOCUS), 0
     
       CASE %WM_COMMAND ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     
         IF CBCTLMSG = %BN_SETFOCUS OR _ 'Button
            CBCTLMSG = %EN_SETFOCUS OR _ 'Edit
            CBCTLMSG = %LBN_SETFOCUS   _ 'Listbox
         THEN FocusRectangle   'CBCTLMSG = %CBN_SETFOCUS 'Combo
     
         SELECT CASE CBCTL
     
           CASE %ButtonSetMyPort
             IF CBCTLMSG = %BN_CLICKED THEN   
               GOSUB ResetPacket
               HourGlass = 1 : MOUSEPTR 11 'Hourglass
               IF fMyPort <> %INVALID_SOCKET THEN
                 TCP CLOSE fMyPort
                 fMyPort = %INVALID_SOCKET 
                 Say "Port" & STR$(MyPort) & " is closed", %GrayInfo            
               END IF
               CONTROL GET TEXT CBHNDL, %TextboxMyPort TO sBuffer
               MyPort = VAL(sBuffer)
               fMyPort = FREEFILE
               ERRCLEAR
               TCP OPEN SERVER PORT MyPort AS fMyPort TIMEOUT %TIMEOUT
               HourGlass = 0 : MOUSEPTR 1 'Arrow
               IF ERR THEN
                 Say "Error D: Choose another local port, " & ERROR$(ERR) & " on" & STR$(MyPort), %RedError
                 TCP CLOSE fMyPort
                 fMyPort = %INVALID_SOCKET
               ELSE
                 Say "Port" & STR$(MyPort) & " is open", %GrayInfo
                 TCP NOTIFY fMyPort, ACCEPT TO CBHNDL AS %TCP_ACCEPT
                 Say "Notification will be send to <TCP_ACCEPT>", %GrayInfo
               END IF
             END IF
     
           CASE %ButtonIncrMyPort
             IF CBCTLMSG = %BN_CLICKED THEN          
               CONTROL GET TEXT CBHNDL, %TextboxMyPort TO sBuffer
               sBuffer = FORMAT$(VAL(sBuffer) + 1)
               CONTROL SET TEXT CBHNDL, %TextboxMyPort, sBuffer           
             END IF
     
           CASE %ButtonDecrMyPort
             IF CBCTLMSG = %BN_CLICKED THEN          
               CONTROL GET TEXT CBHNDL, %TextboxMyPort TO sBuffer
               sBuffer = FORMAT$(VAL(sBuffer) - 1)
               CONTROL SET TEXT CBHNDL, %TextboxMyPort, sBuffer           
             END IF
     
           CASE %ButtonSetRemoteIp
             IF CBCTLMSG = %BN_CLICKED THEN   
               GOSUB ResetPacket
               CONTROL GET TEXT CBHNDL, %SysIpAddr TO sBuffer
               dwIpRemote = ipDottedIpToDwordIP(sBuffer)
               IF dwIpRemote = 0 THEN
                 'MesgBox("Invalid IP", "Error E")
                 Say "Error E: Invalid IP", %RedError
               ELSE
                 Say "Setting ip to " & sBuffer, %GrayInfo
                 HourGlass = 1 : MOUSEPTR 11 'Hourglass
                 sBuffer = ipDottedIpToHostName(sBuffer)
                 HourGlass = 0 : MOUSEPTR 1 'Arrow
                 IF LEN(sBuffer) THEN
                   CONTROL SET TEXT CBHNDL, %TextboxRemoteName, sBuffer
                 END IF
               END IF
             END IF
     
           CASE %ButtonSetRemoteName
             IF CBCTLMSG = %BN_CLICKED THEN
               GOSUB ResetPacket
               CONTROL GET TEXT CBHNDL, %TextboxRemoteName TO sBuffer
               IF LEN(sBuffer) = 0 THEN
                 Say "Error F: Invalid HostName", %Red
               ELSE
                 Say "Setting computername to " & sBuffer, %GrayInfo
                 HourGlass = 1 : MOUSEPTR 11 'Hourglass
                 sBuffer = ipHostNameToDottedIp(sBuffer)
                 dwIpRemote = ipDottedIpToDwordIP(sBuffer)
                 HourGlass = 0 : MOUSEPTR 1 'Arrow
                 IF dwIpRemote THEN CONTROL SET TEXT CBHNDL, %SysIpAddr, sBuffer
               END IF
             END IF
     
           CASE %ButtonSetRemotePort  
             IF CBCTLMSG = %BN_CLICKED THEN
               GOSUB ResetPacket
               IF fRemotePort <> %INVALID_SOCKET THEN
                 TCP CLOSE fRemotePort
                 fRemotePort = %INVALID_SOCKET
                 Say "Port" & STR$(RemotePort) & " is closed", %GrayInfo
               END IF  
               CONTROL GET TEXT CBHNDL, %TexboxRemotePort TO sBuffer
               RemotePort = VAL(sBuffer)
               CONTROL SET TEXT CBHNDL, %TexboxRemotePort, LTRIM$(STR$(RemotePort))
               CONTROL GET TEXT CBHNDL, %TextboxRemoteName TO sBuffer  
               fRemotePort = FREEFILE
               ERRCLEAR
               HourGlass = 1 : MOUSEPTR 11 'Hourglass
               TCP OPEN PORT RemotePort AT sBuffer AS fRemotePort TIMEOUT %TIMEOUT
               HourGlass = 0 : MOUSEPTR 1 'Arrow
               IF ERR THEN 
                 Say "Error G: " & ERROR$(ERR) & ", " & WSAGetLastErrorMsg(ERR), %RedError
               ELSE
                 Say "Port" & STR$(RemotePort) & " is open", %GrayInfo
               END IF  
             END IF         
     
           CASE %ButtonIncrRemotePort
             IF CBCTLMSG = %BN_CLICKED THEN          
               CONTROL GET TEXT CBHNDL, %TexboxRemotePort TO sBuffer
               sBuffer = FORMAT$(VAL(sBuffer) + 1)
               CONTROL SET TEXT CBHNDL, %TexboxRemotePort, sBuffer           
             END IF
     
           CASE %ButtonDecrRemotePort
             IF CBCTLMSG = %BN_CLICKED THEN          
               CONTROL GET TEXT CBHNDL, %TexboxRemotePort TO sBuffer
               sBuffer = FORMAT$(VAL(sBuffer) - 1)
               CONTROL SET TEXT CBHNDL, %TexboxRemotePort, sBuffer           
             END IF
     
           CASE %ButtonCls
             IF CBCTLMSG = %BN_CLICKED THEN
               GOSUB ResetPacket
               LISTBOX RESET CBHNDL, %Listbox
             END IF         
     
           CASE %ButtonSend
             IF CBCTLMSG = %BN_CLICKED THEN
               CONTROL GET TEXT CBHNDL, %TextBoxToSend TO sBuffer
               IF LEN(RTRIM$(sBuffer)) = 0 THEN 
                 sBuffer = "Time is " & TIME$ 
                 CONTROL SET TEXT CBHNDL, %TextBoxToSend, sBuffer
               END IF  
               IF LEN(sBuffer) = 16 AND LEFT$(sBuffer, 8) = "Time is " THEN 
                 sBuffer = "Time is " & TIME$ 'Refresh time
                 CONTROL SET TEXT CBHNDL, %TextBoxToSend, sBuffer
               END IF  
               IF fRemotePort <> %INVALID_SOCKET THEN 
                 HourGlass = 1 : MOUSEPTR 11 'Hourglass
                 Say sBuffer, %YellowSnd 
                 ERRCLEAR
                 TCP SEND fRemotePort, HEX$(PacketSnd + 1, 8) & sBuffer  
                 HourGlass = 0 : MOUSEPTR 1 'Arrow
                 IF ERR THEN 
                   Say "Error H: " & ERROR$(ERR) & ", " & WSAGetLastErrorMsg(ERR), %RedError
                 ELSE 
                   INCR PacketSnd 
                   CONTROL SET TEXT CBHNDL, %LabelPacketSnd, "Snd packet id:" & $TAB & HEX$(PacketSnd, 8)             
                 END IF
               ELSE
                 Say "Error I: fRemotePort = INVALID_SOCKET", %RedError     
               END IF  
             END IF
     
           CASE %OptionHostName
             IF CBCTLMSG = %BN_CLICKED THEN
               CONTROL ENABLE CBHNDL, %ButtonSetRemoteName
               CONTROL ENABLE CBHNDL, %TextboxRemoteName
               CONTROL DISABLE CBHNDL, %ButtonSetRemoteIp       
               CONTROL DISABLE CBHNDL, %SysIpAddr      
             END IF
     
           CASE %OptionIp
             IF CBCTLMSG = %BN_CLICKED THEN
               CONTROL ENABLE CBHNDL, %ButtonSetRemoteIp
               CONTROL ENABLE CBHNDL, %SysIpAddr       
               CONTROL DISABLE CBHNDL, %ButtonSetRemoteName 
               CONTROL DISABLE CBHNDL, %TextboxRemoteName
             END IF
     
           CASE %CheckFilterInfo
             IF CBCTLMSG = %BN_CLICKED THEN
               CONTROL GET CHECK CBHNDL, %CheckFilterInfo TO FilterInfoCheck
             END IF         
     
           CASE %IDCANCEL 'Escape key was pressed
             IF CBCTLMSG = %BN_CLICKED THEN
               DIALOG END CBHNDL
             END IF         
     
           CASE %IDOK 'Enter key was pressed
             IF CBCTLMSG = %BN_CLICKED THEN
               CtrlId = GetDlgCtrlId(GetFocus()) 'Get Control that has focus
     
               SELECT CASE CtrlId
     
                 CASE %ButtonSetMyPort
                   CONTROL SEND CBHNDL, %ButtonSetMyPort, %BM_CLICK, 0, 0                 
     
                 CASE %TextboxMyPort
                   CONTROL SEND CBHNDL, %ButtonSetMyPort, %BM_CLICK, 0, 0  
                   CONTROL SET FOCUS CBHNDL, %TextboxMyPort
     
                 CASE %SysIpAddr         
                   CONTROL SEND CBHNDL, %ButtonSetRemoteIp, %BM_CLICK, 0, 0  
                   CONTROL SET FOCUS CBHNDL, %SysIpAddr
     
                 CASE %TextboxRemoteName         
                   CONTROL SEND CBHNDL, %ButtonSetRemoteName, %BM_CLICK, 0, 0  
                   CONTROL SET FOCUS CBHNDL, %TextboxRemoteName
     
                 CASE %TexboxRemotePort
                   CONTROL SEND CBHNDL, %ButtonSetRemotePort, %BM_CLICK, 0, 0                 
                   CONTROL SET FOCUS CBHNDL, %TexboxRemotePort
     
                 CASE %TextBoxToSend
                   CONTROL SEND CBHNDL, %ButtonSend, %BM_CLICK, 0, 0
                   CONTROL SET FOCUS CBHNDL, %TextBoxToSend                        
     
                 CASE %CheckFilterInfo
                   CONTROL SEND CBHNDL, %CheckFilterInfo, %BM_CLICK, 0, 0
     
               END SELECT
             END IF
     
         END SELECT
     
       CASE %TCP_ACCEPT ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
         SELECT CASE LOWRD(CBLPARAM) 'or LO(WORD, CBLPARAM)
     
           CASE %FD_ACCEPT
             Say "<TCP_ACCEPT/FD_ACCEPT> notification received", %GrayInfo
             IF fRecv <> %INVALID_SOCKET THEN
               TCP CLOSE fRecv
               fRecv = %INVALID_SOCKET 
               Say "<TCP_ACCEPT/FD_ACCEPT> closing fRecv", %GrayInfo           
             END IF
             fRecv = FREEFILE
             TCP ACCEPT fMyPort AS fRecv
             TCP NOTIFY fRecv, RECV CLOSE TO CBHNDL AS %TCP_RECV
             Say "<TCP_ACCEPT/FD_ACCEPT> accept fRecv", %GrayInfo           
             Say "<TCP_ACCEPT/FD_ACCEPT> notify <TCP_RECV>", %GrayInfo               
         END SELECT
         FUNCTION = 1
     
       'CBWPARAM        = (FreeFile)
       'HIWRD(CBLPARAM) = Error code
       'LOWRD(CBLPARAM) = Event code
       '  1 = %FD_READ    Data is available to be read from the socket.
       '  2 = %FD_WRITE   The socket is ready for data to be written.
       '  8 = %FD_ACCEPT  The socket is able to accept a new connection.
       ' 16 = %FD_CONNECT The connection has been established.
       ' 32 = %FD_CLOSE   The socket has been closed.
     
       CASE %TCP_RECV ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
         Say "<TCP_RECV> message received", %GrayInfo
         SELECT CASE LOWRD(CBLPARAM) 'or LO(WORD, CBLPARAM)
     
           CASE %FD_READ ' 1 - Data is available to be read from the socket.
             IF fRecv <> %INVALID_SOCKET THEN
               Say "<TCP_RECV/FD_READ> message received", %GrayInfo
               sBuffer = ""
               sBigBuffer = ""
               HourGlass = 1 : MOUSEPTR 11 'Hourglass
               DO
                 TCP RECV fRecv, 1024, sBuffer
                 sBigBuffer = sBigBuffer & sBuffer
               LOOP UNTIL sBuffer = "" OR ISTRUE EOF(fRecv) OR ISTRUE ERR
               HourGlass = 0 : MOUSEPTR 1 'Arrow
     
               IF LEN(sBigBuffer) = 8 THEN 'This is an acknoledgement
                 PacketAck = VAL("&H" & sBigBuffer) 
                 IF PacketAck <> PacketSnd THEN
                   Say "Error J: PacketAck <> PacketSnd", %RedError
                 ELSE
                   Say "ACK from " & ipDwordIPToDottedIp(ipGetRemoteDwordIP(fRecv)) & ":" & _
                      FORMAT$(GetRemotePort(fRecv)) & " for packet id " & HEX$(PacketAck, 8), %GrayInfo
                 END IF
               ELSE
                 Say "From " & ipDwordIPToDottedIp(ipGetRemoteDwordIP(fRecv)) & ":" & _
                     FORMAT$(GetRemotePort(fRecv)), %GrayInfo
                 Say MID$(sBigBuffer, 9), %GreenRcv 'Remove PacketSnd   
                 HourGlass = 1 : MOUSEPTR 11 'Hourglass
                 TCP SEND fRemotePort, LEFT$(sBigBuffer, 8) 'Send acknoledgement  
                 Say "Sending ACK " & LEFT$(sBigBuffer, 8), %GrayInfo
                 HourGlass = 0 : MOUSEPTR 1 'Arrow
                 CONTROL SET TEXT CBHNDL, %LabelPacketRcv, "Rcv packet id:" & $TAB & LEFT$(sBigBuffer, 8)
               END IF
             ELSE
               Say "Error K: fRecv = %INVALID_SOCKET" , %RedError
             END IF
     
           CASE %FD_WRITE   ' 2 - The socket is ready for data to be written.
             Say "<FD_WRITE> notification received", %GrayInfo
     
           CASE %FD_CONNECT '16 - The connection has been established.
             Say "<FD_CONNECT> notification received", %GrayInfo
     
           CASE %FD_CLOSE   '32 - The socket has been closed.
             Say "<FD_CLOSE> notification received", %GrayInfo
             TCP CLOSE fRecv
             fRecv = %INVALID_SOCKET
             Say "fRecv is close", %GrayInfo
     
         END SELECT
         FUNCTION = 1
     
       CASE %WM_DESTROY ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
         IF fRecv       <> %INVALID_SOCKET THEN TCP CLOSE fRecv 
         IF fMyPort     <> %INVALID_SOCKET THEN TCP CLOSE fMyPort
         IF fRemotePort <> %INVALID_SOCKET THEN TCP CLOSE fRemotePort           
     
       CASE %WM_SETCURSOR  ' - - - - - - - - - - - - - - - - - - - - - - - - - - - 
         'This message is received on mouse move.
         IF Hourglass THEN
           MOUSEPTR 11  'Hourglass
           FUNCTION = 1 'Will prevent window to reset cursor to default arrow
         END IF
     
       CASE %WM_NCACTIVATE
         IF CBWPARAM THEN 'Application is now foreground
           SetFocus hFocus 'Set focus as it was
         ELSE 'Application is not foreground anymore
           hFocus = GetFocus 'Remenber focus 
           FocusRectangle
         END IF
     
       CASE %WM_PAINT 'Repaint rectangle if dialog has been covered and uncovered
         FocusRectangle
     
       CASE %WM_DRAWITEM 'Thank to Börje Hagsten
         IF CBWPARAM = %Listbox THEN 'CBWPARAM holds control's ID
           DiSPtr = CBLPARAM         'CBLPARAM points to a DRAWITEMSTRUCT structure
           IF @DiSPtr.itemID = &HFFFFFFFF THEN EXIT FUNCTION 'If list is empty
     
           SELECT CASE @DiSPtr.itemAction
             CASE %ODA_DRAWENTIRE, %ODA_SELECT
     
               CONTROL SEND CBHNDL, %Listbox, %LB_GETTEXT, @DiSPtr.itemID, VARPTR(zItem)
     
               'IF (@DiSPtr.itemState AND %ODS_SELECTED) = 0 THEN                'Item is not selected
                 dwColor = SendMessage(hList, %LB_GETITEMDATA, @DiSPtr.itemID, 0) 'Get color from ItemData
                 hBrush = CreateSolidBrush(dwColor)
                 FillRect @DiSPtr.hDC, @DiSPtr.rcItem, hBrush                     'Cls
                 SetBkColor @DiSPtr.hDC, dwColor                                  'Text background
                 SetTextColor @DiSPtr.hDC, GetSysColor(%COLOR_WINDOWTEXT)         'Text color
                 DeleteObject hBrush
               'ELSE                                                              'Item is Selected
                 'hBrush = GetSysColorBrush(%COLOR_HIGHLIGHT)
                 'FillRect @DiSPtr.hDC, @DiSPtr.rcItem, GetSysColorBrush(%COLOR_HIGHLIGHT) 'Cls
                 'SetBkColor @DiSPtr.hDC, GetSysColor(%COLOR_HIGHLIGHT)           'Text background
                 'SetTextColor @DiSPtr.hDC, GetSysColor(%COLOR_HIGHLIGHTTEXT)     'Text color
               'END IF
     
               'Get/Draw current item's text
               CALL DrawText(@DiSPtr.hDC, zItem, LEN(zItem), @DiSPtr.rcItem, _ 
                             %DT_SINGLELINE OR %DT_LEFT OR %DT_VCENTER)
     
               'Draw grid lines
               'hPen = CreatePen(%PS_SOLID, 1, GetSysColor(%COLOR_3DFACE))
               hPen = CreatePen(%PS_SOLID, 1, RGB(200, 200, 200)) 
               hPen = SelectObject(@DiSPtr.hDC, hPen)
               MoveToEx @DiSPtr.hDC, 0, @DiSPtr.rcItem.nBottom - 1, BYVAL %NULL
               LineTo @DiSPtr.hDC, @DiSPtr.rcItem.nRight, @DiSPtr.rcItem.nBottom - 1
               DeleteObject SelectObject(@DiSPtr.hDC, hPen)
     
               FUNCTION = %TRUE
               EXIT FUNCTION
           END SELECT
         END IF
     
     END SELECT
     
     EXIT FUNCTION '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     
     ResetPacket:
       PacketSnd = 0
       CONTROL SET TEXT CBHNDL, %LabelPacketRcv, "Rcv packet id:"
       CONTROL SET TEXT CBHNDL, %LabelPacketSnd, "Snd packet id:"
     RETURN
     
    END FUNCTION
    '______________________________________________________________________________
     
    FUNCTION PBMAIN() AS LONG
     LOCAL ICC           AS INIT_COMMON_CONTROLSEX
     LOCAL ButtonStyle   AS DWORD
     LOCAL ButtonStyleEx AS DWORD
     
     ICC.dwSize = SIZEOF(ICC)
     ICC.dwICC = %ICC_INTERNET_CLASSES
     CALL InitCommonControlsEx(ICC)
     
     ButtonStyle = %BS_CENTER OR %BS_VCENTER OR %WS_TABSTOP OR %BS_NOTIFY
     ButtonStyleEx = %WS_EX_LEFT
     
     DIALOG NEW %HWND_DESKTOP, $AppName, , , 245, 320, %WS_CAPTION OR %WS_SYSMENU OR %WS_MINIMIZEBOX , 0 TO hDlg
     SetClassLong hDlg, %GCL_HICON, LoadIcon(BYVAL %NULL, BYVAL %IDI_INFORMATION)
     
     CONTROL ADD LABEL,   hDlg, -1, "Local name:", 10, 5, 55, 10
     CONTROL ADD LABEL,   hDlg, %LabelMyPC, "", 70, 5, 170, 10
     CONTROL ADD LABEL,   hDlg, -1, "Local ip:", 10, 17, 55, 10
     CONTROL ADD LABEL,   hDlg, %LabelMyip, "", 70, 17, 170, 10
     
     CONTROL ADD LABEL,   hDlg, %LabelMyPort, "Local port", 10, 32, 57, 10
     CONTROL ADD TEXTBOX, hDlg, %TextboxMyPort, "MyPort", 70, 30, 55, 12, %ES_AUTOHSCROLL OR _
                          %ES_RIGHT OR %WS_BORDER OR %WS_TABSTOP, %WS_EX_RIGHT 
     CONTROL ADD BUTTON,  hDlg, %ButtonIncrMyPort, "+", 132, 30, 14, 14, ButtonStyle, ButtonStyleEx
     CONTROL ADD BUTTON,  hDlg, %ButtonDecrMyPort, "-", 152, 30, 14, 14, ButtonStyle, ButtonStyleEx
     CONTROL ADD BUTTON,  hDlg, %ButtonSetMyPort, "Set local &port", 175, 30, 60, 14, ButtonStyle, ButtonStyleEx
     '-----------------------------------------------------------------------------
     CONTROL ADD LINE,    hDlg, -1, "", 5, 52, 230, 3
     '-----------------------------------------------------------------------------
     CONTROL ADD OPTION,  hDlg, %OptionIp, "&Remote IP", 7, 60, 58, 14, %BS_LEFT OR %BS_LEFTTEXT OR %BS_NOTIFY OR %BS_VCENTER OR %WS_TABSTOP OR %WS_GROUP, %WS_EX_LEFT    
     CONTROL ADD OPTION,  hDlg, %OptionHostName, "Remote &Name", 7, 77, 58, 14, %BS_LEFT OR %BS_LEFTTEXT OR %BS_NOTIFY OR %BS_VCENTER OR %WS_TABSTOP, %WS_EX_LEFT    
     CONTROL SET OPTION   hDlg, %OptionIp, %OptionIp, %OptionHostName
     CONTROL ADD LABEL,   hDlg, -1, "Remote Port", 10, 99, 45, 10
     CONTROL ADD "SysIPAddress32", hDlg, %SysIpAddr, "", 70, 60, 95, 12, _
                                   %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, %WS_EX_LEFT OR _
                                   %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
     CONTROL ADD BUTTON,  hDlg, %ButtonSetRemoteIp, "Set remote &ip", 175, 60,  60, 14, ButtonStyle, ButtonStyleEx
     CONTROL ADD TEXTBOX, hDlg, %TextboxRemoteName, "", 70, 77, 95, 12
     CONTROL DISABLE      hDlg, %TextboxRemoteName
     CONTROL ADD BUTTON,  hDlg, %ButtonSetRemoteName, "Set remote &name", 175, 77,  60, 14, ButtonStyle, ButtonStyleEx
     CONTROL DISABLE      hDlg, %ButtonSetRemoteName
     CONTROL ADD TEXTBOX, hDlg, %TexboxRemotePort, "", 70, 95, 55, 12, %ES_AUTOHSCROLL OR _
                                %ES_RIGHT OR %WS_BORDER OR %WS_TABSTOP, %WS_EX_RIGHT
     CONTROL ADD BUTTON,  hDlg, %ButtonIncrRemotePort, "+", 132, 95, 14, 14, ButtonStyle, ButtonStyleEx
     CONTROL ADD BUTTON,  hDlg, %ButtonDecrRemotePort, "-", 152, 95, 14, 14, ButtonStyle, ButtonStyleEx
     CONTROL ADD BUTTON,  hDlg, %ButtonSetRemotePort, "Set remote por&t", 175, 95, 60, 14, ButtonStyle, ButtonStyleEx
     '-----------------------------------------------------------------------------
     CONTROL ADD LINE,    hDlg, -1, "", 5, 115, 230, 3
     '-----------------------------------------------------------------------------
     CONTROL ADD LABEL,   hDlg, %LabelPacketSnd, "Snd packet id: <Nil>", 10, 120, 100, 10
     CONTROL ADD LABEL,   hDlg, %LabelPacketRcv, "Rcv packet id: <Nil>", 10, 130, 100, 10
     CONTROL ADD BUTTON,  hDlg, %ButtonCls, "&Clear", 125, 123, 50, 14, ButtonStyle, ButtonStyleEx
     CONTROL ADD BUTTON,  hDlg, %ButtonSend, "&Send", 185, 123, 50, 14, ButtonStyle, ButtonStyleEx
     CONTROL ADD LABEL,   hDlg, -1, "Text to send...", 10, 143, 100, 10
     CONTROL ADD CHECKBOX,hDlg, %CheckFilterInfo, "Filter information message", 135, 140, 100, 10, %BS_LEFT OR %BS_NOTIFY OR %BS_VCENTER OR %WS_TABSTOP, %WS_EX_LEFT
     CONTROL ADD TEXTBOX, hDlg, %TextBoxToSend, "Hello [STOP] I'm coming back home...[STOP]", 10, 155, 225, 11 
     CONTROL SET COLOR    hDlg, %TextBoxToSend, %Black, %YellowSnd 
     CONTROL ADD LISTBOX, hDlg, %Listbox, , 10, 175, 225, 130, %LBS_NOINTEGRALHEIGHT OR _ 
                          %WS_CHILD OR %WS_VISIBLE OR %LBS_OWNERDRAWFIXED OR %LBS_HASSTRINGS OR _
                          %LBS_NOTIFY OR %WS_TABSTOP OR %WS_VSCROLL OR %WS_HSCROLL, %WS_EX_CLIENTEDGE
     
     DIALOG SHOW MODAL hDlg, CALL DlgProc
     
    END FUNCTION
    '______________________________________________________________________________


    [This message has been edited by Pierre Bellisle (edited December 25, 2005).]

  • #2
    'Save as "WSAGetLastError.inc"

    Code:
    'WSAGetLastError.inc, return WSAGetLastError string message, thanks to Ralph Berger 
    'version 2002-07-11
    '______________________________________________________________________________
     
    FUNCTION WSAGetLastErrorMsg(WSAError AS LONG) AS STRING
     
     SELECT CASE WSAError
     
       ' Windows Sockets definitions of regular Microsoft C error constants
       CASE %WSAEINTR               : FUNCTION = "Interrupted system call."
       CASE %WSAEBADF               : FUNCTION = "Bad file number."
       CASE %WSAEACCES              : FUNCTION = "Permission Denied."
       CASE %WSAEFAULT              : FUNCTION = "Bad Address."
       CASE %WSAEINVAL              : FUNCTION = "Invalid Argument."
       CASE %WSAEMFILE              : FUNCTION = "Too many open files."
     
       ' Windows Sockets definitions of regular Berkeley error constants
       CASE %WSAEWOULDBLOCK         : FUNCTION = "Operation would block."
       CASE %WSAEINPROGRESS         : FUNCTION = "Operation now in progress."
       CASE %WSAEALREADY            : FUNCTION = "Operation already in progress."
       CASE %WSAENOTSOCK            : FUNCTION = "Socket operation on nonsocket."
       CASE %WSAEDESTADDRREQ        : FUNCTION = "Destination address required."
       CASE %WSAEMSGSIZE            : FUNCTION = "Message too long."
       CASE %WSAEPROTOTYPE          : FUNCTION = "Protocol wrong type for socket."
       CASE %WSAENOPROTOOPT         : FUNCTION = "Protocol not available."
       CASE %WSAEPROTONOSUPPORT     : FUNCTION = "Protocol not supported."
       CASE %WSAESOCKTNOSUPPORT     : FUNCTION = "Socket type not supported."
       CASE %WSAEOPNOTSUPP          : FUNCTION = "Operation not supported on socket."
       CASE %WSAEPFNOSUPPORT        : FUNCTION = "Protocol family not supported."
       CASE %WSAEAFNOSUPPORT        : FUNCTION = "Address family not supported by protocol family."
       CASE %WSAEADDRINUSE          : FUNCTION = "Address already in use."
       CASE %WSAEADDRNOTAVAIL       : FUNCTION = "Can't assign requested address."
       CASE %WSAENETDOWN            : FUNCTION = "Network is down."
       CASE %WSAENETUNREACH         : FUNCTION = "Network is unreachable."
       CASE %WSAENETRESET           : FUNCTION = "Network dropped connection."
       CASE %WSAECONNABORTED        : FUNCTION = "Software caused connection abort."
       CASE %WSAECONNRESET          : FUNCTION = "Connection reset by peer."
       CASE %WSAENOBUFS             : FUNCTION = "No buffer space available."
       CASE %WSAEISCONN             : FUNCTION = "Socket is already connected."
       CASE %WSAENOTCONN            : FUNCTION = "Socket is not connected."
       CASE %WSAESHUTDOWN           : FUNCTION = "Can't send after socket shutdown."
       CASE %WSAETOOMANYREFS        : FUNCTION = "Too many references: can't splice."
       CASE %WSAETIMEDOUT           : FUNCTION = "Connection timed out."
       CASE %WSAECONNREFUSED        : FUNCTION = "Connection refused."
       CASE %WSAELOOP               : FUNCTION = "Too many levels of symbolic links."
       CASE %WSAENAMETOOLONG        : FUNCTION = "File name too long."
       CASE %WSAEHOSTDOWN           : FUNCTION = "Host is down."
       CASE %WSAEHOSTUNREACH        : FUNCTION = "No route to host."
       CASE %WSAENOTEMPTY           : FUNCTION = "Directory not empty."
       CASE %WSAEPROCLIM            : FUNCTION = "Too many processes."
       CASE %WSAEUSERS              : FUNCTION = "Too many users."
       CASE %WSAEDQUOT              : FUNCTION = "Disk quota exceeded."
       CASE %WSAESTALE              : FUNCTION = "Stale NFS file handle."
       CASE %WSAEREMOTE             : FUNCTION = "Too many levels of remote in path."
     
       ' Extended Windows Sockets errors
       CASE %WSASYSNOTREADY         : FUNCTION = "Network subsystem is unusable."
       CASE %WSAVERNOTSUPPORTED     : FUNCTION = "Winsock DLL cannot support this application."
       CASE %WSANOTINITIALISED      : FUNCTION = "Winsock not initialized."
       CASE %WSAEDISCON             : FUNCTION = "Disconnect."
       CASE %WSAENOMORE             : FUNCTION = "Nonrecoverable error."
       CASE %WSAECANCELLED          : FUNCTION = "Valid name, no data record of requested type."
       CASE %WSAEINVALIDPROCTABLE   : FUNCTION = "Invalid proc table."
       CASE %WSAEINVALIDPROVIDER    : FUNCTION = "Invalid provider."
       CASE %WSAEPROVIDERFAILEDINIT : FUNCTION = "Provider failed init."
       CASE %WSASYSCALLFAILURE      : FUNCTION = "Sys call failure."
       CASE %WSASERVICE_NOT_FOUND   : FUNCTION = "Service not found."
       CASE %WSATYPE_NOT_FOUND      : FUNCTION = "Type not found."
       CASE %WSA_E_NO_MORE          : FUNCTION = "E no more."
       CASE %WSA_E_CANCELLED        : FUNCTION = "Error cancelled."
       CASE %WSAEREFUSED            : FUNCTION = "Error refused."
     
       ' Error return codes from gethostbyname() and gethostbyaddr()
       CASE %WSAHOST_NOT_FOUND      : FUNCTION = "Host not found."
       CASE %WSATRY_AGAIN           : FUNCTION = "Nonauthoritative host not found or serverfail"
       CASE %WSANO_RECOVERY         : FUNCTION = "Non-recoverable errors, formerr, refused, notimp."
       CASE %WSANO_DATA             : FUNCTION = "Valid name, no data record of requested type."
     
       CASE ELSE                    : FUNCTION = "Error:" & STR$(WSAError) & "."
     
     END SELECT
     
    END FUNCTION
    '______________________________________________________________________________

    Comment


    • #3
      'Save as "TelegramTcp.rc"
      Code:
      #include "resource.h"
       
      // Next line is needed for theme
      1 24 "TelegramTCP.exe.ManifestRc"
       
      VS_VERSION_INFO VERSIONINFO
      FILEVERSION 1, 0, 0, 0
      PRODUCTVERSION 1, 0, 0, 0
      FILEOS VOS_WINDOWS32
      FILETYPE VFT_APP
      BEGIN
        BLOCK "StringFileInfo"
        BEGIN
          BLOCK "040904E4"
          BEGIN
            VALUE "CompanyName",      "Pierre Bellisle\000"
            VALUE "FileDescription",  "TCP Chat demo\000"
            VALUE "FileVersion",      "1.00.00.00\000"
            VALUE "InternalName",     "TelegramTCP.Exe\000"
            VALUE "OriginalFilename", "TelegramTCP.Exe\000"
            VALUE "LegalCopyright",   "Copyright (c) 2006 Pierre Bellisle\000"
            VALUE "LegalTrademarks",  "Copyright (c) 2006 Pierre Bellisle\000"
            VALUE "ProductName",      "TelegramTCP\000"
            VALUE "ProductVersion",   "1.00.000\000"
            VALUE "Comments",         "TCP Chat demo\000"
          END
        END
      END

      Comment


      • #4
        'Save as "TelegramTCP.exe.ManifestRc"

        Code:
        <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
        <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
            <assemblyIdentity
                version="1.0.0.0"
                processorArchitecture="X86"
                name="TelegramTcp.exe"
                type="win32" />
            <description>TCP chat demo</description>
            <dependency>
                <dependentAssembly>
                    <assemblyIdentity
                        type="win32"
                        name="Microsoft.Windows.Common-Controls"
                        version="6.0.0.0"
                        processorArchitecture="X86"
                        publicKeyToken="6595b64144ccf1df"
                        language="*" />
                </dependentAssembly>
            </dependency>
        </assembly>

        Comment

        Working...
        X