Important alert: (current site time 7/16/2013 2:09:26 AM EDT)
 

VB icon

_____________________...:::SIJO Soft Net Checker:::...___

Email
Submitted on: 3/13/2003 11:38:58 PM
By: SIJO Soft Corp  
Level: Beginner
User Rating: By 3 Users
Compatibility: VB 6.0
Views: 11272
author picture
(About the author)
 
     PC is connected to Net even through Lan?

 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :_____________________...:::SIJO Soft Net Checker:::...___
'**************************************
Private Const WS_VERSION_REQD = &H101
Private Const WS_VERSION_MAJOR = WS_VERSION_REQD \ &H100 And &HFF&
Private Const WS_VERSION_MINOR = WS_VERSION_REQD And &HFF&
Private Const MIN_SOCKETS_REQD = 1
Private Const SOCKET_ERROR = -1
Private Const WSADescription_Len = 256
Private Const WSASYS_Status_Len = 128
Private Type HOSTENT
hName As Long
hAliases As Long
hAddrType As Integer
hLength As Integer
hAddrList As Long
End Type
Private Type WSADATA
wversion As Integer
wHighVersion As Integer
szDescription(0 To WSADescription_Len) As Byte
szSystemStatus(0 To WSASYS_Status_Len) As Byte
iMaxSockets As Integer
iMaxUdpDg As Integer
lpszVendorInfo As Long
End Type
Private Declare Function WSAGetLastError Lib "WSOCK32.DLL" () As Long
Private Declare Function WSAStartup Lib "WSOCK32.DLL" (ByVal wVersionRequired&, lpWSAData As WSADATA) As Long
Private Declare Function WSACleanup Lib "WSOCK32.DLL" () As Long
Private Declare Function gethostbyname Lib "WSOCK32.DLL" (ByVal hostname$) As Long
Private Declare Sub RtlMoveMemory Lib "KERNEL32" (hpvDest As Any, ByVal hpvSource&, ByVal cbCopy&)
' add a command button command1
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: _____________________...:::SIJO Soft Net Checker:::...___
' Description:PC is connected to Net even through Lan?
' By: SIJO Soft Corp
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=43989&lngWId=1'for details.'**************************************

'I have just used a simple concept , I have resolved the IP address of www.yahoo.com and if I get a numeric value
'then It means that you are connected
Function hibyte(ByVal wParam As Integer)
hibyte = wParam \ &H100 And &HFF&
End Function
Function lobyte(ByVal wParam As Integer)
lobyte = wParam And &HFF&
End Function
Sub SocketsInitialize()
Dim WSAD As WSADATA
Dim iReturn As Integer
Dim sLowByte As String, sHighByte As String, sMsg As String
iReturn = WSAStartup(WS_VERSION_REQD, WSAD)
If iReturn <> 0 Then
 MsgBox "Winsock.dll is not responding."
 End
End If
If lobyte(WSAD.wversion) < WS_VERSION_MAJOR Or (lobyte(WSAD.wversion) = WS_VERSION_MAJOR And hibyte(WSAD.wversion) < WS_VERSION_MINOR) Then
 sHighByte = Trim$(Str$(hibyte(WSAD.wversion)))
 sLowByte = Trim$(Str$(lobyte(WSAD.wversion)))
 sMsg = "Windows Sockets version " & sLowByte & "." & sHighByte
 sMsg = sMsg & " is not supported by winsock.dll "
 MsgBox sMsg
 End
End If
If WSAD.iMaxSockets < MIN_SOCKETS_REQD Then
 sMsg = "This application requires a minimum of "
 sMsg = sMsg & Trim$(Str$(MIN_SOCKETS_REQD)) & " supported sockets."
 MsgBox sMsg
 End
End If
End Sub
Sub SocketsCleanup()
Dim lReturn As Long
lReturn = WSACleanup()
If lReturn <> 0 Then
 MsgBox "Socket error " & Trim$(Str$(lReturn)) & " occurred in Cleanup "
 End
End If
End Sub
Private Sub Command1_Click()
If isConnected = True Then
MsgBox "connected"
Else
MsgBox "not connected"
End If
End Sub
Sub Form_Load()
SocketsInitialize
End Sub
Private Sub Form_Unload(Cancel As Integer)
SocketsCleanup
End Sub
Private Function isConnected() As Boolean
Dim hostent_addr As Long
Dim host As HOSTENT
Dim hostip_addr As Long
Dim temp_ip_address() As Byte
Dim i As Integer
Dim ip_address As String
hostent_addr = gethostbyname("www.yahoo.com")
If hostent_addr = 0 Then
 isConnected = False
 Exit Function
End If
RtlMoveMemory host, hostent_addr, LenB(host)
RtlMoveMemory hostip_addr, host.hAddrList, 4
ReDim temp_ip_address(1 To host.hLength)
RtlMoveMemory temp_ip_address(1), hostip_addr, host.hLength
For i = 1 To host.hLength
 ip_address = ip_address & temp_ip_address(i) & "."
Next
ip_address = Mid$(ip_address, 1, Len(ip_address) - 1)
If IsNumeric(Mid$(ip_address, 1, 1)) Then
isConnected = True
Else
isConnected = False
End If
 
End Function


Other 13 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
3/13/2003 11:42:57 PMSIJO Soft Corp

If you feel it is good for you please leave a vote for me.
(If this comment was disrespectful, please report it.)

 
3/13/2003 11:55:40 PM

Poor code. I will give it to my child
(If this comment was disrespectful, please report it.)

 
3/14/2003 5:59:08 AMShadowDragon Systems

Do you want to validate that comment Mr Anonymous? Why is it poor code? Looks ok to me and does what its suposed to do. I suspect you wont as you don't even have the common decency to sign your posts...
(If this comment was disrespectful, please report it.)

 
3/14/2003 9:19:20 AMPFCGentry

The reason every one is calling this poor code is he claims code as his own that belongs to other people..

ShadowDragon Systems

you can find this code in allmost any VB book, along with every other post he has!!!!!

and yet I left my name how about that!

(If this comment was disrespectful, please report it.)

 
3/14/2003 11:44:31 AMCoding Genius

He deletes d@mning comments too so I'll say again:
1) Your screenshot is invalid. It's of no use. If you don't have a proper screenshot don't put a f'm orange.
2) The names of your submissions are incredibly annoying. We hate seeing a code ticker full of ''_____________________...:::SIJO Soft Stolen Code:::...''
3) Yes, most of the code is stolen from other sources, or even PSC, and resubmitted.
5) You insist on posting at least 10 submissions at a time, completely wiping everybody elses submissions off the code ticker and spamming PSC with your oranges.
6) After all this, you ask for votes!
All I can say is get to f**k
(If this comment was disrespectful, please report it.)

 
3/14/2003 6:05:53 PMWet_Keyboard

Coding Genius......well said
(If this comment was disrespectful, please report it.)

 
3/15/2003 3:40:14 AMShadowDragon Systems

Thanks for the info Coding. I probably could have phrased my question better but it was well meant. It's next to useless berating someones code with giving a reason.
(If this comment was disrespectful, please report it.)

 
6/29/2003 12:58:10 AM

i agree with coding genius, lol stop posting pictures of fruit. they have nothing to do with anything.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.