Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
connecting to the internet in free basic
#1
Hi there,
I've made it my next project to learn how to get a free basic program to access files on the internet. I was just wondering if anyone could give me a little guidance on this and/or a pointer to a good tutorial if one does exist.

Thanks in advance,

Jack
Reply
#2
Downloading a file chart.gif from internet to c:\chart.gif


Option Explicit
Option Private

'$include once:'win\kernel32.bi'
'$include once:'win\user32.bi'
'$include once:'win\gdi32.bi'

Declare Sub DownloadFile(sUrl As String, sFile As String)

Declare Function WinMain(ByVal hInstance As Long, ByVal hPrevInstance As Long, _
szCmdLine As String, ByVal iCmdShow As Integer ) As Integer ' Entry point!
End WinMain( GetModuleHandle( NULL ), NULL, Command$, SW_NORMAL )
'
Function WinMain ( ByVal hInstance As Long, ByVal hPrevInstance As Long, _
szCmdLine As String, ByVal iCmdShow As Integer ) As Integer

DownloadFile("http://www.daxa-chart.de/chart.gif", "C:\chart.gif")

WinMain = 0

End Function
'
Sub DownloadFile(sUrl As String, sFile As String)
Dim addr As Long, hUrlmonDll As Long, back As Long

Dim Download As Function(ByVal pCaller As Long, _
ByVal szURL As String, ByVal szFileName As String, _
ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long

hUrlmonDll = LoadLibraryEx("URLMON.DLL", 0, 0)
Download = GetProcAddress(hUrlmonDll,"URLDownloadToFileA")
If Download<>0 Then
back = Download(0, sUrl, sFile, 0, 0)
If back<>0 Then
MessageBox(0, "Download Error Number "+Str$(back), "Error", 0)
End If
Else
MessageBox(0, "Urlmon.dll-Initialisation-Error", "Error", 0)
End If
FreeLibrary(hUrlmonDll)

End Sub
Reply
#3
Thanks, that's exactly what I wanted.

Jack Big Grin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)