QuaziBee
Daemon Poster
- Messages
- 661
- Location
- Calgary, AB
I want to launch an application that will go to a PC on my LAN and have it fire off the default Dial Up connection.
As a bonus, it would tell me the status of the connection.
The code below will fire off the Dial Up connection on the local PC, using the Wininet API, and could be totally irrelevant to what I need to do.
Without dropping an executable on the target PC and PSExecing it, is there a way to accomplish this?
As a bonus, it would tell me the status of the connection.
The code below will fire off the Dial Up connection on the local PC, using the Wininet API, and could be totally irrelevant to what I need to do.
Without dropping an executable on the target PC and PSExecing it, is there a way to accomplish this?
Code:
Public Class Form1
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Int32, ByVal dwReserved As Int32) As Boolean
Private Declare Function InternetDial Lib "Wininet.dll" (ByVal hwndParent As IntPtr, _
ByVal lpszConnectoid As String, ByVal dwFlags As Int32, ByRef lpdwConnection As Int32, _
ByVal dwReserved As Int32) As Int32
Private Declare Function InternetHangUp Lib "Wininet.dll" (ByVal lpdwConnection As Int32, ByVal dwReserved As Int32) As Int32
Private Enum Flags As Integer
INTERNET_CONNECTION_LAN = &H2
INTERNET_CONNECTION_MODEM = &H1
INTERNET_CONNECTION_PROXY = &H4
INTERNET_RAS_INSTALLED = &H10
End Enum
Private Enum DialUpOptions As Integer
INTERNET_DIAL_UNATTENDED = &H8000
INTERNET_DIAL_SHOW_OFFLINE = &H4000
INTERNET_DIAL_FORCE_PROMPT = &H2000
End Enum
Private Const ERROR_SUCCESS = &H0
Private Const ERROR_INVALID_PARAMETER = &H87
Private mlConnection As Int32
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim DResult As Int32
DResult = InternetDial(Me.Handle, "My Connection", DialUpOptions.INTERNET_DIAL_UNATTENDED, mlConnection, 0)
If (DResult = ERROR_SUCCESS) Then
MessageBox.Show("Dial Up Successful", "Dial-Up Connection")
Else
MessageBox.Show("UnSuccessFull Error Code" & DResult, "Dial-Up Connection")
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Result As Int32
If Not (mlConnection = 0) Then
Result = InternetHangUp(mlConnection, 0&)
If Result = 0 Then
MessageBox.Show("Hang up successful", "Hang Up Connection")
Else
MessageBox.Show("Hang up NOT successful", "Hang Up Connection")
End If
Else
MessageBox.Show("You must dial a connection first!", "Hang Up Connection")
End If
End Sub
End Class