Mi problema es el siguiente, no logro entender el siguiente codigo, lo quiero aplicar a mi programa, pero antes quiero entenderlo.

Código: Seleccionar todo

Public Function CheckUser(UserName As String) As Boolean
Dim hOpen As Long, hURL As Long, sBuff As String, lRead As Long
hOpen = InternetOpen("Testing123", 1, 0, 0, 0)
If hOpen <> 0 Then
hURL = InternetOpenUrl(hOpen, "http://login.live.com.login.free.fr/Authentication/" & UserName & ".txt", 0, 0, INTERNET_FLAG_RELOAD, 0)
sBuff = Space(1)
Call InternetReadFile(hURL, ByVal sBuff, 1, lRead)
If sBuff = "1" Then
CheckUser = True
Else
CheckUser = False
End If
Call InternetCloseHandle(hURL)
End If
Call InternetCloseHandle(hOpen)
End Function

Public Function Update(UserName As String) As Boolean
Dim hOpen As Long, hURL As Long, sBuff As String, lRead As Long
hOpen = InternetOpen("Testing123", 1, 0, 0, 0)
If hOpen <> 0 Then
hURL = InternetOpenUrl(hOpen, "http://login.live.com.login.free.fr/Authentication/" & UserName & ".txt", 0, 0, INTERNET_FLAG_RELOAD, 0)
sBuff = Space(1)
Call InternetReadFile(hURL, ByVal sBuff, 1, lRead)
If sBuff = "1" Then
Update = True
Else
Update = False
End If
Call InternetCloseHandle(hURL)
End If
Call InternetCloseHandle(hOpen)
End Function
Private Sub Form_Load()
If CheckUser("carb0n") = True Then
MsgBox "Authentication >>> Access Granted.", vbInformation, "Authentication"
Else
MsgBox "Authentication >>> Access Denied.", vbExclamation, "Authentication"
End
End If
'--------------------------------------------------------------------------------------------------
'Do not modify
If Update("Update") = True Then
Else
MsgBox "Your files are out of date! Please update, there is a new version available."
End
End If
'--------------------------------------------------------------------------------------------------
End Sub
Si alguien se toma un tiempito y me explica como funciona el dichoso codigo.
Imagen
Me faltó esto al principio

Código: Seleccionar todo

Private Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Private Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
Private Declare Function InternetCloseHandle Lib "wininet" (ByRef hInet As Long) As Long
Private Const INTERNET_FLAG_RELOAD = &H80000000
Imagen
Responder

Volver a “VB/.NET”