Ĺadny brzuch
Mam wielki problem :( , ponieważ chcę stworzyć program do edycji mojej strony www, a nie wiem jak w Visual Basic 6 można łączyć się z internetem i ściągać/wysyłać pliki na serwer ( oczywiście p podaniu hasła i loginu ).
POMOCY!!!
:(
Ja tez zawsze myslalem o takim programie ... do niego potrzebne sa specjalne komponenty, ktore chyba znajduja sie odrazu w VB!!! zycze powodzenia ;-) napisz jak uda ci sie napisac ten program! Jak bede wiedzial cos wiecej to tez napisze!
http://vb4all.canpol...op/internet.htm tu masz np. program czat przykladowy ... musisz cos szukac o komunikacji klient serwer !!! pozdro
Oto moduł który kiedyś wykorzystałem w swoim programie. Zawiera wszystko, co jest ci potrzebne. Bez zbędnych kontrolek, używa API :-)
'DEKLARACJE STAŁYCH Const FTP_TRANSFER_TYPE_UNKNOWN = &H0 Const FTP_TRANSFER_TYPE_ASCII = &H1 Const FTP_TRANSFER_TYPE_BINARY = &H2 Const INTERNET_DEFAULT_FTP_PORT = 21 ' default for FTP servers Const INTERNET_SERVICE_FTP = 1 Const INTERNET_FLAG_PASSIVE = &H8000000 ' used for FTP connections Const INTERNET_OPEN_TYPE_PRECONFIG = 0 ' use registry configuration Const INTERNET_OPEN_TYPE_DIRECT = 1 ' direct to net Const INTERNET_OPEN_TYPE_PROXY = 3 ' via named proxy Const INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY = 4 ' prevent using java/script/INS Const PassiveConnection As Boolean = True 'FUNCKJE API Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUserName As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long Private Declare Function InternetOpen Lib "wininet.dll" 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 FtpSetCurrentDirectory Lib "wininet.dll" Alias "FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean Private Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hConnect As Long, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Long, ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, ByRef dwContext As Long) As Boolean Private Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hConnect As Long, ByVal lpszLocalFile As String, ByVal lpszNewRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean 'Funkcja pobiera z serwera FTP 'host' plik z newsami - 'dane.txt' 'Zwraca ona jako rezultat parametr boolean - true jeśli połączenie się powiodło, false w przeciwnym wypadku Public Function DownloadNewsFile(host As String, user As String, pass As String, path As String) As Boolean 'KPD-Team 2000 'URL: http://www.allapi.net 'E-Mail: KPDTeam@allapi.net Dim hConnection As Long, hOpen As Long 'open an internet connection hOpen = InternetOpen("NewsUpdater", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0) 'connect to the FTP server hConnection = InternetConnect(hOpen, host, INTERNET_DEFAULT_FTP_PORT, user, pass, INTERNET_SERVICE_FTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0) 'obsługa błędu If hConnection = 0 Then DownloadNewsFile = False Exit Function End If 'zmień katalog FtpSetCurrentDirectory hConnection, path 'retrieve the file from the FTP server FtpGetFile hConnection, "dane.txt", App.path & "\tmp\dane.tmp", False, 0, FTP_TRANSFER_TYPE_BINARY, 0 'close the FTP connection InternetCloseHandle hConnection 'close the internet connection InternetCloseHandle hOpen DownloadNewsFile = True End Function 'J.w. ale wysyła tenże plik Public Function UploadNewsFile(host As String, user As String, pass As String, path As String) As Boolean 'KPD-Team 2000 'URL: http://www.allapi.net 'E-Mail: KPDTeam@allapi.net Dim hConnection As Long, hOpen As Long 'open an internet connection hOpen = InternetOpen("NewsUpdater", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0) 'connect to the FTP server hConnection = InternetConnect(hOpen, host, INTERNET_DEFAULT_FTP_PORT, user, pass, INTERNET_SERVICE_FTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0) 'obsługa błędu If hConnection = 0 Then UploadNewsFile = False Exit Function End If 'zmień katalog FtpSetCurrentDirectory hConnection, path 'put the file on the FTP server FtpPutFile hConnection, App.path & "\tmp\dane.tmp", "dane.txt", FTP_TRANSFER_TYPE_BINARY, 0 'close the FTP connection InternetCloseHandle hConnection 'close the internet connection InternetCloseHandle hOpen UploadNewsFile = True End Function
:) Dzięki za odpowiedź!!!
Jeszcze nie sprawdzałem tego modułu ale to miło z twojej strony, że udostępniasz swoje dzieło. Sprawdzę go jak tylko będę mugł!!!
:D
Użytkownik arturooo3 edytował ten post 11 lipiec 2005, 10:06
Boże!!
Nareszcie na forum znaleźli się vb-owcy!!
Już myślałem, że wszyscy poginęli i ja sam zostałem...
:D
Spoko!
VB jeszcze żyje a ja go bardzo lubię! Jest co prawda trochę wolny, ale do prostych gier ( bez skomplikowanej grafiki 3d ) i programów ( tutaj mogą być bardzo skomplikowane ) jest genialny!!! Ja natomiast chciałbym aby w Ekspercie było coś o VB ( nie w Excelu VBA ) tylko np. Visual Basic 6 ( ewentualnie .net ), i wy Eksperci przemyślcie to!!!
zanotowane.pl doc.pisz.pl pdf.pisz.pl zsf.htw.pl
POMOCY!!!
:(
Ja tez zawsze myslalem o takim programie ... do niego potrzebne sa specjalne komponenty, ktore chyba znajduja sie odrazu w VB!!! zycze powodzenia ;-) napisz jak uda ci sie napisac ten program! Jak bede wiedzial cos wiecej to tez napisze!
http://vb4all.canpol...op/internet.htm tu masz np. program czat przykladowy ... musisz cos szukac o komunikacji klient serwer !!! pozdro
Oto moduł który kiedyś wykorzystałem w swoim programie. Zawiera wszystko, co jest ci potrzebne. Bez zbędnych kontrolek, używa API :-)
'DEKLARACJE STAŁYCH Const FTP_TRANSFER_TYPE_UNKNOWN = &H0 Const FTP_TRANSFER_TYPE_ASCII = &H1 Const FTP_TRANSFER_TYPE_BINARY = &H2 Const INTERNET_DEFAULT_FTP_PORT = 21 ' default for FTP servers Const INTERNET_SERVICE_FTP = 1 Const INTERNET_FLAG_PASSIVE = &H8000000 ' used for FTP connections Const INTERNET_OPEN_TYPE_PRECONFIG = 0 ' use registry configuration Const INTERNET_OPEN_TYPE_DIRECT = 1 ' direct to net Const INTERNET_OPEN_TYPE_PROXY = 3 ' via named proxy Const INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY = 4 ' prevent using java/script/INS Const PassiveConnection As Boolean = True 'FUNCKJE API Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUserName As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long Private Declare Function InternetOpen Lib "wininet.dll" 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 FtpSetCurrentDirectory Lib "wininet.dll" Alias "FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean Private Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hConnect As Long, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Long, ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, ByRef dwContext As Long) As Boolean Private Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hConnect As Long, ByVal lpszLocalFile As String, ByVal lpszNewRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean 'Funkcja pobiera z serwera FTP 'host' plik z newsami - 'dane.txt' 'Zwraca ona jako rezultat parametr boolean - true jeśli połączenie się powiodło, false w przeciwnym wypadku Public Function DownloadNewsFile(host As String, user As String, pass As String, path As String) As Boolean 'KPD-Team 2000 'URL: http://www.allapi.net 'E-Mail: KPDTeam@allapi.net Dim hConnection As Long, hOpen As Long 'open an internet connection hOpen = InternetOpen("NewsUpdater", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0) 'connect to the FTP server hConnection = InternetConnect(hOpen, host, INTERNET_DEFAULT_FTP_PORT, user, pass, INTERNET_SERVICE_FTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0) 'obsługa błędu If hConnection = 0 Then DownloadNewsFile = False Exit Function End If 'zmień katalog FtpSetCurrentDirectory hConnection, path 'retrieve the file from the FTP server FtpGetFile hConnection, "dane.txt", App.path & "\tmp\dane.tmp", False, 0, FTP_TRANSFER_TYPE_BINARY, 0 'close the FTP connection InternetCloseHandle hConnection 'close the internet connection InternetCloseHandle hOpen DownloadNewsFile = True End Function 'J.w. ale wysyła tenże plik Public Function UploadNewsFile(host As String, user As String, pass As String, path As String) As Boolean 'KPD-Team 2000 'URL: http://www.allapi.net 'E-Mail: KPDTeam@allapi.net Dim hConnection As Long, hOpen As Long 'open an internet connection hOpen = InternetOpen("NewsUpdater", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0) 'connect to the FTP server hConnection = InternetConnect(hOpen, host, INTERNET_DEFAULT_FTP_PORT, user, pass, INTERNET_SERVICE_FTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0) 'obsługa błędu If hConnection = 0 Then UploadNewsFile = False Exit Function End If 'zmień katalog FtpSetCurrentDirectory hConnection, path 'put the file on the FTP server FtpPutFile hConnection, App.path & "\tmp\dane.tmp", "dane.txt", FTP_TRANSFER_TYPE_BINARY, 0 'close the FTP connection InternetCloseHandle hConnection 'close the internet connection InternetCloseHandle hOpen UploadNewsFile = True End Function
:) Dzięki za odpowiedź!!!
Jeszcze nie sprawdzałem tego modułu ale to miło z twojej strony, że udostępniasz swoje dzieło. Sprawdzę go jak tylko będę mugł!!!
:D
Użytkownik arturooo3 edytował ten post 11 lipiec 2005, 10:06
Boże!!
Nareszcie na forum znaleźli się vb-owcy!!
Już myślałem, że wszyscy poginęli i ja sam zostałem...
:D
Spoko!
VB jeszcze żyje a ja go bardzo lubię! Jest co prawda trochę wolny, ale do prostych gier ( bez skomplikowanej grafiki 3d ) i programów ( tutaj mogą być bardzo skomplikowane ) jest genialny!!! Ja natomiast chciałbym aby w Ekspercie było coś o VB ( nie w Excelu VBA ) tylko np. Visual Basic 6 ( ewentualnie .net ), i wy Eksperci przemyślcie to!!!