VB example

 

Download

Download binaries here .

Download sources here .


Source Code

Module1.bas

Attribute VB_Name = "Module1"
Public Type POINTAPI
       x As Long
       y As Long
End Type

Public Type MSG
   hwnd As Long
   message As Long
   wParam As Long
   lParam As Long
   time As Long
   pt As POINTAPI
End Type

Public Const WM_USER = &H400

Public Declare Function GetLastError Lib "kernel32" () As Long
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Declare Function GetMessage Lib "user32" Alias "GetMessageA" (lpMsg As MSG, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long) As Long
Public Declare Function TranslateMessage Lib "user32" (lpMsg As MSG) As Long
Public Declare Function DispatchMessage Lib "user32" Alias "DispatchMessageA" (lpMsg As MSG) As Long


Form1.frm

VERSION 5.00
Begin VB.Form Form1
  Caption         =   "Form1"
  ClientHeight    =   6735
  ClientLeft      =   60
  ClientTop       =   360
  ClientWidth     =   7245
  LinkTopic       =   "Form1"
  ScaleHeight     =   6735
  ScaleWidth      =   7245
  StartUpPosition =   3  'Windows Default
  Begin VB.TextBox txtOut
     Height          =   5655
     Left            =   120
     MultiLine       =   -1  'True
     ScrollBars      =   3  'Both
     TabIndex        =   1
     Top             =   840
     Width           =   6975
  End
  Begin VB.CommandButton Command1
     Caption         =   "Start"
     Height          =   375
     Left            =   120
     TabIndex        =   0
     Top             =   120
     Width           =   6975
  End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click()
 Dim ISL_Light_Desk_path As String
 Dim ISL_Light_Client_path As String
 Dim res As Long
 Dim params As String
 Dim m As MSG
 Dim ISL_Light_Desk_Username As String
 Dim ISL_Light_Desk_Password As String
 ISL_Light_Desk_path = "ISLLightDesk.exe"
 ISL_Light_Client_path = "ISLLightClient.exe"
 ISL_Light_Desk_Username = "demo"
 ISL_Light_Desk_Password = "demo"
 params = params & " --get-code"
 params = params & " --username " & ISL_Light_Desk_Username
 params = params & " --password " & ISL_Light_Desk_Password
 params = params & " --notification-message " & WM_USER + 2
 params = params & " --notification-thread " & App.ThreadID
 params = params & " --auto-close"

 ShellExecute 0, "Open", ISL_Light_Desk_path, params, "", 0
 txtOut.Text = txtOut.Text & "Starting ISL Light Desk" & Chr(13) & Chr(10)
 While GetMessage(m, 0, 0, 0)
   If m.message = WM_USER + 2 Then
     t = "Desk notification message: "
     t = t & "wparam = " & m.wParam
     t = t & " lparam = " & m.lParam
     txtOut.Text = txtOut.Text & t & Chr(13) & Chr(10)
     If m.wParam = 1 Then
       params = " --connect " & m.lParam
       params = params & " --notification-message " & WM_USER + 1
       params = params & " --notification-thread " & App.ThreadID
       params = params & " --auto-close"
       ShellExecute 0, "Open", ISL_Light_Client_path, params, "", 0
       txtOut.Text = txtOut.Text & "Starting ISL Light Client" & Chr(13) & Chr(10)
     End If
   ElseIf m.message = WM_USER + 1 Then
     t = "Client notification message: "
     t = t & "wparam = " & m.wParam
     t = t & " lparam = " & m.lParam
     txtOut.Text = txtOut.Text & t & Chr(13) & Chr(10)
   Else
     TranslateMessage m
     DispatchMessage m
   End If
 Wend
 End

End Sub

Was this article helpful?