To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
MSDN Subscribers: Download the VS 2010 Release Candidate
MSDN Subscribers: Download the VS 2010 Release Candidate
Sell Your Code and Make Money?
Creating your own Tetris game using VB.NET
Article :: Improving Software Economics, Part 4 of 7: Top 10 Principles of Iterative Software Management



Go Back   VBForums > Visual Basic > API

Reply Post New Thread
 
Thread Tools Search this Thread Display Modes
Old Feb 25th, 2006, 12:12 AM   #1
tauhu82
Member
 
Join Date: Feb 06
Posts: 61
tauhu82 is an unknown quantity at this point (<10)
Exclamation Enable or disable internet connection of remote computers. Urgent!!

Halo i'm looking for ways to enable or disable internet connection of remote computers, like everythings are controlled by the server computer. I was told that there is a disconnect internet API and also a connect internet API. I would like to connect and disconnect the internet connection of remote computer which are connected to the internet through LAN. Can anyone give me some advise on this matter... A sampel would be nice.. Thanks alot..
tauhu82 is offline   Reply With Quote
Old Mar 9th, 2006, 02:37 AM   #2
qhyzme
New Member
 
Join Date: Mar 06
Posts: 4
qhyzme is an unknown quantity at this point (<10)
Cool Re: Enable or disable internet connection of remote computers. Urgent!!

try this one. hope this will help to solve your problem.
i just barrowed this code.

Declarations

VB Code:
  1. Public Const RAS_MAXENTRYNAME As Integer = 256
  2. Public Const RAS_MAXDEVICETYPE As Integer = 16
  3. Public Const RAS_MAXDEVICENAME As Integer = 128
  4. Public Const RAS_RASCONNSIZE As Integer = 412
  5. Public Const ERROR_SUCCESS = 0&
  6. Public Type RasEntryName
  7.     dwSize As Long
  8.     szEntryName(RAS_MAXENTRYNAME) As Byte
  9. End Type
  10. Public Type RasConn
  11.     dwSize As Long
  12.     hRasConn As Long
  13.     szEntryName(RAS_MAXENTRYNAME) As Byte
  14.     szDeviceType(RAS_MAXDEVICETYPE) As Byte
  15.     szDeviceName(RAS_MAXDEVICENAME) As Byte
  16. End Type
  17. Public Declare Function RasEnumConnections Lib _
  18. "rasapi32.dll" Alias "RasEnumConnectionsA" (lpRasConn As _
  19. Any, lpcb As Long, lpcConnections As Long) As Long
  20. Public Declare Function RasHangUp Lib "rasapi32.dll" Alias _
  21. "RasHangUpA" (ByVal hRasConn As Long) As LongPublic gstrISPName As String
  22. Public ReturnCode As Long


Procedure

VB Code:
  1. Public Sub HangUp()
  2. Dim i As Long
  3. Dim lpRasConn(255) As RasConn
  4. Dim lpcb As Long
  5. Dim lpcConnections As Long
  6. Dim hRasConn As Long
  7. lpRasConn(0).dwSize = RAS_RASCONNSIZE
  8. lpcb = RAS_MAXENTRYNAME * lpRasConn(0).dwSize
  9. lpcConnections = 0
  10. ReturnCode = RasEnumConnections(lpRasConn(0), lpcb, _
  11. lpcConnections)
  12. If ReturnCode = ERROR_SUCCESS Then
  13.     For i = 0 To lpcConnections - 1
  14.         If Trim(ByteToString(lpRasConn(i).szEntryName)) _
  15.             = Trim(gstrISPName) Then
  16.             hRasConn = lpRasConn(i).hRasConn
  17.             ReturnCode = RasHangUp(ByVal hRasConn)
  18.         End If
  19.     Next i
  20. End If
  21. End Sub
  22. Public Function ByteToString(bytString() As Byte) As String
  23. Dim i As Integer
  24. ByteToString = ""
  25. i = 0
  26. While bytString(i) = 0&
  27. ByteToString = ByteToString & Chr(bytString(i))
  28. i = i + 1
  29. Wend
  30. End Function

Using the HangUp Procedure

Once you have copied all required code into your project, you can hang up all connections to the telephone network by calling the procudure HangUp:

VB Code:
  1. Call HangUp

cheers,
-qhyzme-
qhyzme is offline   Reply With Quote
Old Mar 14th, 2006, 09:00 AM   #3
tauhu82
Member
 
Join Date: Feb 06
Posts: 61
tauhu82 is an unknown quantity at this point (<10)
Exclamation Re: Enable or disable internet connection of remote computers. Urgent!!

Dear qhyzme

I have tried the way you suggested but nothing seem to be happening? Is it the coding is for dial up or broadband? The computers which i intend to disconnect its internet connection are using broadband. Need more help

Thanks alot
tauhu82 is offline   Reply With Quote
Old Mar 14th, 2006, 09:49 AM   #4
tauhu82
Member
 
Join Date: Feb 06
Posts: 61
tauhu82 is an unknown quantity at this point (<10)
Exclamation Re: Enable or disable internet connection of remote computers. Urgent!!

This line is having some problem

VB Code:
  1. Public Declare Function RasHangUp Lib "rasapi32.dll" Alias _
  2. "RasHangUpA" (ByVal hRasConn As Long) As LongPublic gstrISPName As String
  3. Public ReturnCode As Long

The error message is Compiler error Expected: end of statement

Please help
tauhu82 is offline   Reply With Quote
Old Mar 14th, 2006, 12:29 PM   #5
benmartin101
Fanatic Member
 
Join Date: Jul 05
Posts: 1,007
benmartin101  is on a distinguished road (40+)
Re: Enable or disable internet connection of remote computers. Urgent!!

Try doing this:

VB Code:
  1. Public Declare Function RasHangUp Lib "rasapi32.dll" Alias _
  2. "RasHangUpA" (ByVal hRasConn As Long) As Long  'split them up
  3. Public gstrISPName As String
  4. Public ReturnCode As Long
benmartin101 is offline   Reply With Quote
Old Mar 15th, 2006, 12:34 AM   #6
tauhu82
Member
 
Join Date: Feb 06
Posts: 61
tauhu82 is an unknown quantity at this point (<10)
Talking Re: Enable or disable internet connection of remote computers. Urgent!!

Thanks alot benmartin101 yesterday i have just found the original site which this coding was in and i have split up the coding but it still can't work.

Did anyone tried this coding before?? Can it work on your computer which is to disconnect the internet connection on LAN? I have tried but still it can't work. Hope someone can tell me or show me some example on this.
tauhu82 is offline   Reply With Quote
Old Mar 15th, 2006, 12:42 AM   #7
tauhu82
Member
 
Join Date: Feb 06
Posts: 61
tauhu82 is an unknown quantity at this point (<10)
Exclamation Re: Enable or disable internet connection of remote computers. Urgent!!

Can you guys help me to check this site out and try the coding
http://www.developerfusion.co.uk/show/247/

Can anyone get the coding to work?? What do we need to get it to work??

Please help me...
tauhu82 is offline   Reply With Quote
Old Mar 16th, 2006, 01:27 PM   #8
tauhu82
Member
 
Join Date: Feb 06
Posts: 61
tauhu82 is an unknown quantity at this point (<10)
Talking Re: Enable or disable internet connection of remote computers. Urgent!!

You guys i have given up on this coding as i have find out that the code can only cater to dial up and not for LAN connection.

Its ok as i have found a new way to do this.
Thanks to all who have help me. I have start a new thread so please help me there ok. Thanks alot You guys are the best
tauhu82 is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > API


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 01:19 PM.




To view more projects, click here

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.