|
-
Feb 24th, 2006, 01:38 AM
#1
Thread Starter
Member
Enable or disable internet connection of remote computers
Halo i'm looking for ways to enable or disable internet connection of remote computers, like everythings are controlled by the server computer. Can anyone give me some advise on this matter... A sampel would be nice.. Thanks alot..
-
Feb 24th, 2006, 11:10 AM
#2
Re: Enable or disable internet connection of remote computers
When you want to disconnect the internet of the client you can do it by having your server send some data which tells it to d/c, when the clients receives this, it calls the disconnect internet API which can be found on this forum if you search.
client data arrival sub:
VB Code:
Dim strBuffer as String
Winsock1.GetData strBuffer
If strBuffer = "[DISCONNECT]" & vbcrlf Then
'Call disconnect internet API here
End if
In the server command button which DC's the client
VB Code:
Winsock1(2).SendData "[DISCONNECT]" & vbCrLf
'This will tell client 2 to d/c
-
Feb 24th, 2006, 10:46 PM
#3
Thread Starter
Member
Thanks alot the182guy
Thank you so much. I will try it and tell you all what are the results. Have a nice day....
-
Mar 8th, 2006, 04:37 AM
#4
New Member
Re: Enable or disable internet connection of remote computers
 Originally Posted by the182guy
When you want to disconnect the internet of the client
client data arrival sub:
VB Code:
Dim strBuffer as String
Winsock1.GetData strBuffer
If strBuffer = "[DISCONNECT]" & vbcrlf Then
'Call disconnect internet API here
End if
In the server command button which DC's the client
VB Code:
Winsock1(2).SendData "[DISCONNECT]" & vbCrLf
'This will tell client 2 to d/c
just wanna ask where i can see internet API.
thanks in advance.
-
Mar 8th, 2006, 10:07 AM
#5
Thread Starter
Member
Where to find disconnect internet API ??
I have tried to find the disconnect internet API but i can't seem to find it anywhere. Can someone please show us where to find it.
Thanks alot..
-
Mar 9th, 2006, 02:36 AM
#6
Re: Enable or disable internet connection of remote computers
-
Mar 12th, 2006, 11:41 AM
#7
Thread Starter
Member
Re: Enable or disable internet connection of remote computers
Hai the182guy,
Thanks for your API site. But i still have one small question. Can the coding work if the computer is connected to the internet though LAN. We are using broadband with router and switch to connect to each of the computers to the internet.
Thanks alot in advanced
-
Mar 12th, 2006, 05:56 PM
#8
Re: Enable or disable internet connection of remote computers
if your using a router, you can d/c the network conection using the WNNetCancel API, here it is:
http://www.mentalis.org/apilist/WNet...nnection.shtml
-
Mar 13th, 2006, 11:40 AM
#9
Thread Starter
Member
Need help with this coding!!!
VB Code:
Client
Case "Connect"
AddConnection
Case "Disconnect"
CancelConnection
Module
Public Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" (ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) As Long
Public Declare Function WNetCancelConnection Lib "mpr.dll" Alias "WNetCancelConnectionA" (ByVal lpszName As String, ByVal bForce As Long) As Long
Public Const WN_SUCCESS = 0 ' The function was successful.
Public Const WN_NET_ERROR = 2 ' An error occurred on the network.
Public Const WN_BAD_PASSWORD = 6 ' The password was invalid.
Public Sub AddConnection()
Dim AddConnection As Integer
Dim MyShareName As String
Dim MyPWD As String
Dim UseLetter As String
On Local Error GoTo AddConnection_Err
AddConnection = WNetAddConnection(MyShareName, MyPWD, UseLetter)
AddConnection_End:
Exit Sub
AddConnection_Err:
AddConnection = Err
MsgBox Error$
Resume AddConnection_End
End Sub
Public Sub CancelConnection()
Dim CancelConnection As Integer
Dim DriveLetter As String
Dim Force As Integer
On Local Error GoTo CancelConnection_Err
CancelConnection = WNetCancelConnection(DriveLetter, Force)
CancelConnection_End:
Exit Sub
CancelConnection_Err:
CancelConnection = Err
MsgBox Error$
Resume CancelConnection_End
End Sub
VB Code:
Server
Private Sub Command1_Click()
sckControlPanel.SendData "Connect#"
End Sub
Private Sub Command2_Click()
sckControlPanel.SendData "Disconnect#"
End Sub
PS:sckControlPanel = Winsock
Guys the above are the two of the coding which i obtain from http://www.mentalis.org/apilist/WNet...nnection.shtml
The first part is for the client side and the second one is for the server side. Now i wonder what did i do wrong because when i execute the disconnect command from the server side to the client, nothing is happening. Can somebody tell me what is wrong please....
Thanks alot in advanced
-
Mar 13th, 2006, 11:44 AM
#10
Re: Enable or disable internet connection of remote computers
do you have any code so that the client can receive the data?
-
Mar 13th, 2006, 12:07 PM
#11
Thread Starter
Member
Re: Enable or disable internet connection of remote computers
VB Code:
Client
Private Sub sckControlPanel_DataArrival(ByVal bytesTotal As Long)
Dim Command As String, txtData As String
Dim Position As Integer
On Error Resume Next
sckControlPanel.GetData txtData
Position = InStr(1, txtData, "#")
Command = Left(txtData, Position - 1)
txtData = Mid(txtData, Position + 1)
Select Case Command
Case "ScreenSaver"
RunScreenSaver
Case "CDDoor"
If txtData = "Open" Then
OpenCDDoor
Else
CloseCDDoor
End If
Case "LockSystem"
SystemParametersInfo SPI_SCREENSAVERRUNNING, _
1&, Null, SPIF_UPDATEINIFILE
LockForm.Show
Case "UnLockSystem"
Unload LockForm
UnlockForm.Show
Case "Logoff"
ExitWindowsEx (EWX_LOGOFF Or EWX_FORCE), &HFFFF
Case "Reboot"
AdjustToken
ExitWindowsEx (EWX_SHUTDOWN Or EWX_FORCE Or EWX_REBOOT), &HFFFF
Case "Shutdown"
AdjustToken
ExitWindowsEx (EWX_SHUTDOWN Or EWX_FORCE), &HFFFF
Case "GetUserName"
txtData = GetUser()
sckControlPanel.SendData "GetUserName#" & txtData
Case "GetTickCount"
txtData = GetLoginTime
sckControlPanel.SendData "GetTickCount#" & txtData
Case "SystemInfo"
txtData = "SystemInfo#" & SystemInfo()
sckControlPanel.SendData txtData
Case "Connect"
AddConnection
Case "Disconnect"
CancelConnection
Case "Message"
MsgBox txtData, vbExclamation, "Windows Message"
Case "Date&Time"
Case "Mouse"
End Select
End Sub
I put this part at the client side. so when i execude this
VB Code:
Server
Private Sub Command1_Click()
sckControlPanel.SendData "Connect#"
End Sub
Private Sub Command2_Click()
sckControlPanel.SendData "Disconnect#"
End Sub
It should have call for the disconnect to function. But nothing seem to be happening. I wonder why??
-
Mar 13th, 2006, 12:26 PM
#12
Re: Enable or disable internet connection of remote computers
in the Case "Disconnect" part put a msgbox and try it, this will tell you if its a problem with the connection/data arrival or a problem with the CancelConnectionAPI
also make s small app that just uses the CancelConnection API and try it, to see if the API actually works
-
Mar 13th, 2006, 12:55 PM
#13
Thread Starter
Member
Re: Enable or disable internet connection of remote computers
I have tried with the msgbox and the connection part is ok so i have also tried with this
VB Code:
Private Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" (ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) As Long
Private Declare Function WNetCancelConnection Lib "mpr.dll" Alias "WNetCancelConnectionA" (ByVal lpszName As String, ByVal bForce As Long) As Long
Const WN_SUCCESS = 0 ' The function was successful.
Const WN_NET_ERROR = 2 ' An error occurred on the network.
Const WN_BAD_PASSWORD = 6 ' The password was invalid.
Private Sub Form_Load()
Dim CancelConnection As Integer
Dim DriveLetter As String
Dim Force As Integer
On Local Error GoTo CancelConnection_Err
CancelConnection = WNetCancelConnection(DriveLetter, Force)
CancelConnection_End:
Exit Sub
CancelConnection_Err:
CancelConnection = Err
MsgBox Error$
Resume CancelConnection_End
End Sub
On a single form and when i excecute it also nothing is happening. Can someone tell me why???
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|