' api_wininet.sbp


#ifndef _INC_WININET
#define _INC_WININET

#ifdef UNICODE
Const _FuncName_InternetOpen = "InternetOpenW"
Const _FuncName_InternetConnect = "InternetConnectW"
Const _FuncName_FtpGetFile = "FtpGetFileW"
Const _FuncName_FtpGetCurrentDirectory = "FtpGetCurrentDirectoryW"
Const _FuncName_FtpSetCurrentDirectory = "FtpSetCurrentDirectoryW"
Const _FuncName_FtpFindFirstFile = "FtpFindFirstFileW"
Const _FuncName_InternetFindNextFile = "InternetFindNextFileW"
#else
Const _FuncName_InternetOpen = "InternetOpenA"
Const _FuncName_InternetConnect = "InternetConnectA"
Const _FuncName_FtpGetFile = "FtpGetFileA"
Const _FuncName_FtpGetCurrentDirectory = "FtpGetCurrentDirectoryA"
Const _FuncName_FtpSetCurrentDirectory = "FtpSetCurrentDirectoryA"
Const _FuncName_FtpFindFirstFile = "FtpFindFirstFileA"
Const _FuncName_InternetFindNextFile = "InternetFindNextFileA"
#endif

TypeDef HINTERNET = VoidPtr

TypeDef INTERNET_PORT = Word


Const INTERNET_FLAG_RELOAD = &H80000000  'retrieve the original item


Const FTP_TRANSFER_TYPE_UNKNOWN = &H00000000
Const FTP_TRANSFER_TYPE_ASCII   = &H00000001
Const FTP_TRANSFER_TYPE_BINARY  = &H00000002


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

Declare Function InternetOpen Lib "wininet.dll" Alias _FuncName_InternetOpen (
	lpszAgent As LPCTSTR,
	dwAccessType As DWord,
	lpszProxy As LPCTSTR,
	lpszProxyBypass As LPCTSTR,
	dwFlags As DWord) As HINTERNET

Const INTERNET_SERVICE_FTP    = 1
Const INTERNET_SERVICE_GOPHER = 2
Const INTERNET_SERVICE_HTTP   = 3

Const INTERNET_FLAG_PASSIVE   = &H08000000  'used for FTP connections

Const INTERNET_INVALID_PORT_NUMBER   = 0           'use the protocol-specific default
Const INTERNET_DEFAULT_FTP_PORT      = 21          'default for FTP servers
Const INTERNET_DEFAULT_GOPHER_PORT   = 70          '   "     "  gopher "
Const INTERNET_DEFAULT_HTTP_PORT     = 80          '   "     "  HTTP   "
Const INTERNET_DEFAULT_HTTPS_PORT    = 443         '   "     "  HTTPS  "
Const INTERNET_DEFAULT_SOCKS_PORT    = 1080        'default for SOCKS firewall servers.

Declare Function InternetConnect Lib "wininet.dll" Alias _FuncName_InternetConnect (
	hInternet As HINTERNET,
	lpszServerName As LPCTSTR,
	nServerPort As INTERNET_PORT,
	lpszUserName As LPCTSTR,
	lpszPassword As LPCTSTR,
	dwService As DWord,
	dwFlags As DWord,
	dwContext As DWORD_PTR) As HINTERNET

Declare Function InternetCloseHandle Lib "wininet.dll" (hInternet As HINTERNET) As BOOL



'----------------
' FTP
'----------------

Declare Function FtpGetFile Lib "wininet.dll" Alias _FuncName_FtpGetFile (
	hConnect As HINTERNET,
	lpszRemoteFile As LPCTSTR,
	lpszNewFile As LPCTSTR,
	fFailIfExists As BOOL,
	dwFlagsAndAttributes As DWord,
	dwFlags As DWord,
	dwContext As DWORD_PTR) As BOOL

Declare Function FtpGetCurrentDirectory Lib "wininet.dll" Alias _FuncName_FtpGetCurrentDirectory (
	hConnect As HINTERNET,
	lpszCurrentDirectory As LPTSTR,
	lpdwCurrentDirectory As DWord) As BOOL

Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias _FuncName_FtpSetCurrentDirectory (
	hConnect As HINTERNET,
	lpszDirectory As LPCTSTR) As BOOL

Declare Function FtpFindFirstFile Lib "wininet.dll" Alias _FuncName_FtpFindFirstFile (
	hConnect As HINTERNET,
	lpszSearchFile As LPCTSTR,
	ByRef FindFileData As WIN32_FIND_DATA,
	dwFlags As DWord,
	dwContext As DWORD_PTR) As HINTERNET

Declare Function InternetFindNextFile Lib "wininet.dll" Alias _FuncName_InternetFindNextFile (
	hFind As HINTERNET,
	ByREf vFindData As Any) As BOOL


#endif '_INC_WININET
