Discussion:
Using wininet in windows CE 6.0 with VB 2005
(too old to reply)
lsimoni
2008-12-02 16:30:14 UTC
Permalink
am trying to download a file from an FTP site to my device in a VB
application. When I get to the InternetOpen command, I get a
"NotSupportedException" and don't know what the problem is. wininet.dll is
present in the \windows directory, so it should be available.

Here's my code:

Imports System.Net.sockets
Imports System.Net
...

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 MAX_PATH = 260

Private Structure FILETIME
Dim dwLowDateTime As Long
Dim dwHighDateTime As Long
End Structure

Private Structure WIN32_FIND_DATA
Dim dwFileAttributes As Long
Dim ftCreationTime As FILETIME
Dim ftLastAccessTime As FILETIME
Dim ftLastWriteTime As FILETIME
Dim nFileSizeHigh As Long
Dim nFileSizeLow As Long
Dim dwReserved0 As Long
Dim dwReserved1 As Long
Dim cFileName As String
Dim cAlternate As String
End Structure
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByRef
hInet As Long) As Long
Public 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 FtpGetCurrentDirectory Lib "wininet.dll" Alias
"FtpGetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal
lpszCurrentDirectory As String, ByVal lpdwCurrentDirectory As Long) As Long
Private Declare Function FtpCreateDirectory Lib "wininet.dll" Alias
"FtpCreateDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As
String) As Boolean
Private Declare Function FtpRemoveDirectory Lib "wininet.dll" Alias
"FtpRemoveDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As
String) As Boolean
Private Declare Function FtpDeleteFile Lib "wininet.dll" Alias
"FtpDeleteFileA" (ByVal hFtpSession As Long, ByVal lpszFileName As String) As
Boolean
Private Declare Function FtpRenameFile Lib "wininet.dll" Alias
"FtpRenameFileA" (ByVal hFtpSession As Long, ByVal lpszExisting As String,
ByVal lpszNew 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
Private Declare Function InternetGetLastResponseInfo Lib "wininet.dll"
Alias "InternetGetLastResponseInfoA" (ByVal lpdwError As Long, ByVal
lpszBuffer As String, ByVal lpdwBufferLength As Long) As Boolean
Private Declare Function FtpFindFirstFile Lib "wininet.dll" Alias
"FtpFindFirstFileA" (ByVal hFtpSession As Long, ByVal lpszSearchFile As
String, ByVal lpFindFileData As WIN32_FIND_DATA, ByVal dwFlags As Long, ByVal
dwContent As Long) As Long
Private Declare Function InternetFindNextFile Lib "wininet.dll" Alias
"InternetFindNextFileA" (ByVal hFind As Long, ByVal lpvFindData As
WIN32_FIND_DATA) As Long



Const PassiveConnection As Boolean = True
...
Dim i As Long
Dim iCount As Long
Dim iK As Boolean
Dim scUserAgent As String = "VB OpenUrl"


i = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT,
vbNullString, vbNullString, 0)
iCount = InternetConnect(i,
"ftp.jpccontrols.com/Flash_Programming/Flash_Programs/BC_Group/",
INTERNET_DEFAULT_FTP_PORT, "Anonymous", "Guest", INTERNET_SERVICE_FTP, 0, 0)
iK = FtpGetFile(iCount, "ESU-2400.exe", "\Hard
Disk\ESU-2400\ESU-2400_FTP.exe", True, 1, 0, 0)
Paul G. Tobey [eMVP]
2008-12-02 16:44:08 UTC
Permalink
Please don't separately post the same message to multiple groups in this
way. I've replied to your original post to platbuilder.

Paul T.
Post by lsimoni
am trying to download a file from an FTP site to my device in a VB
application. When I get to the InternetOpen command, I get a
"NotSupportedException" and don't know what the problem is. wininet.dll is
present in the \windows directory, so it should be available.
Imports System.Net.sockets
Imports System.Net
...
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 MAX_PATH = 260
Private Structure FILETIME
Dim dwLowDateTime As Long
Dim dwHighDateTime As Long
End Structure
Private Structure WIN32_FIND_DATA
Dim dwFileAttributes As Long
Dim ftCreationTime As FILETIME
Dim ftLastAccessTime As FILETIME
Dim ftLastWriteTime As FILETIME
Dim nFileSizeHigh As Long
Dim nFileSizeLow As Long
Dim dwReserved0 As Long
Dim dwReserved1 As Long
Dim cFileName As String
Dim cAlternate As String
End Structure
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByRef
hInet As Long) As Long
Public 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 FtpGetCurrentDirectory Lib "wininet.dll" Alias
"FtpGetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal
lpszCurrentDirectory As String, ByVal lpdwCurrentDirectory As Long) As Long
Private Declare Function FtpCreateDirectory Lib "wininet.dll" Alias
"FtpCreateDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As
String) As Boolean
Private Declare Function FtpRemoveDirectory Lib "wininet.dll" Alias
"FtpRemoveDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As
String) As Boolean
Private Declare Function FtpDeleteFile Lib "wininet.dll" Alias
"FtpDeleteFileA" (ByVal hFtpSession As Long, ByVal lpszFileName As String) As
Boolean
Private Declare Function FtpRenameFile Lib "wininet.dll" Alias
"FtpRenameFileA" (ByVal hFtpSession As Long, ByVal lpszExisting As String,
ByVal lpszNew 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
Private Declare Function InternetGetLastResponseInfo Lib "wininet.dll"
Alias "InternetGetLastResponseInfoA" (ByVal lpdwError As Long, ByVal
lpszBuffer As String, ByVal lpdwBufferLength As Long) As Boolean
Private Declare Function FtpFindFirstFile Lib "wininet.dll" Alias
"FtpFindFirstFileA" (ByVal hFtpSession As Long, ByVal lpszSearchFile As
String, ByVal lpFindFileData As WIN32_FIND_DATA, ByVal dwFlags As Long, ByVal
dwContent As Long) As Long
Private Declare Function InternetFindNextFile Lib "wininet.dll" Alias
"InternetFindNextFileA" (ByVal hFind As Long, ByVal lpvFindData As
WIN32_FIND_DATA) As Long
Const PassiveConnection As Boolean = True
...
Dim i As Long
Dim iCount As Long
Dim iK As Boolean
Dim scUserAgent As String = "VB OpenUrl"
i = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT,
vbNullString, vbNullString, 0)
iCount = InternetConnect(i,
"ftp.jpccontrols.com/Flash_Programming/Flash_Programs/BC_Group/",
INTERNET_DEFAULT_FTP_PORT, "Anonymous", "Guest", INTERNET_SERVICE_FTP, 0, 0)
iK = FtpGetFile(iCount, "ESU-2400.exe", "\Hard
Disk\ESU-2400\ESU-2400_FTP.exe", True, 1, 0, 0)
lsimoni
2008-12-02 16:58:04 UTC
Permalink
Sorry, Chis said that it didn't belong in platbuilder, I assumed that meant
that I should move it elsewhere. I greatly appreciate your time and input.
Post by Paul G. Tobey [eMVP]
Please don't separately post the same message to multiple groups in this
way. I've replied to your original post to platbuilder.
Paul T.
Post by lsimoni
am trying to download a file from an FTP site to my device in a VB
application. When I get to the InternetOpen command, I get a
"NotSupportedException" and don't know what the problem is. wininet.dll is
present in the \windows directory, so it should be available.
Imports System.Net.sockets
Imports System.Net
...
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 MAX_PATH = 260
Private Structure FILETIME
Dim dwLowDateTime As Long
Dim dwHighDateTime As Long
End Structure
Private Structure WIN32_FIND_DATA
Dim dwFileAttributes As Long
Dim ftCreationTime As FILETIME
Dim ftLastAccessTime As FILETIME
Dim ftLastWriteTime As FILETIME
Dim nFileSizeHigh As Long
Dim nFileSizeLow As Long
Dim dwReserved0 As Long
Dim dwReserved1 As Long
Dim cFileName As String
Dim cAlternate As String
End Structure
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByRef
hInet As Long) As Long
Public 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 FtpGetCurrentDirectory Lib "wininet.dll" Alias
"FtpGetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal
lpszCurrentDirectory As String, ByVal lpdwCurrentDirectory As Long) As Long
Private Declare Function FtpCreateDirectory Lib "wininet.dll" Alias
"FtpCreateDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As
String) As Boolean
Private Declare Function FtpRemoveDirectory Lib "wininet.dll" Alias
"FtpRemoveDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As
String) As Boolean
Private Declare Function FtpDeleteFile Lib "wininet.dll" Alias
"FtpDeleteFileA" (ByVal hFtpSession As Long, ByVal lpszFileName As String) As
Boolean
Private Declare Function FtpRenameFile Lib "wininet.dll" Alias
"FtpRenameFileA" (ByVal hFtpSession As Long, ByVal lpszExisting As String,
ByVal lpszNew 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
Private Declare Function InternetGetLastResponseInfo Lib "wininet.dll"
Alias "InternetGetLastResponseInfoA" (ByVal lpdwError As Long, ByVal
lpszBuffer As String, ByVal lpdwBufferLength As Long) As Boolean
Private Declare Function FtpFindFirstFile Lib "wininet.dll" Alias
"FtpFindFirstFileA" (ByVal hFtpSession As Long, ByVal lpszSearchFile As
String, ByVal lpFindFileData As WIN32_FIND_DATA, ByVal dwFlags As Long, ByVal
dwContent As Long) As Long
Private Declare Function InternetFindNextFile Lib "wininet.dll" Alias
"InternetFindNextFileA" (ByVal hFind As Long, ByVal lpvFindData As
WIN32_FIND_DATA) As Long
Const PassiveConnection As Boolean = True
...
Dim i As Long
Dim iCount As Long
Dim iK As Boolean
Dim scUserAgent As String = "VB OpenUrl"
i = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT,
vbNullString, vbNullString, 0)
iCount = InternetConnect(i,
"ftp.jpccontrols.com/Flash_Programming/Flash_Programs/BC_Group/",
INTERNET_DEFAULT_FTP_PORT, "Anonymous", "Guest", INTERNET_SERVICE_FTP, 0, 0)
iK = FtpGetFile(iCount, "ESU-2400.exe", "\Hard
Disk\ESU-2400\ESU-2400_FTP.exe", True, 1, 0, 0)
Loading...