Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FTP using wininet.dll

391 views
Skip to first unread message

Matthew L. Butcher

unread,
Jun 30, 2003, 11:59:03 AM6/30/03
to
I'm interested in transfering a file using FTP but would like to avoid using
the console app FTP.EXE. I've seen some VB code that makes use of the FTP
capabilities available in wininet.dll and I'm curious of anyone here has
made use of this dll in a VBScript.

Please advise!
Matthew


Han

unread,
Jul 1, 2003, 8:04:07 AM7/1/03
to
HI Matthew

No, it's not available because vbs doesn't allow "declare" statement. You
may want msinet.ocx(inetCtrl.inet) or VB wrapper of the wininet.dll. If
you're in network environment, the latter is recommanded but there is still
thread limitation.

"Matthew L. Butcher" <matthew...@vfc.com> wrote in message
news:OhUsXCyP...@tk2msftngp13.phx.gbl...

Matthew L. Butcher

unread,
Jun 30, 2003, 4:22:15 PM6/30/03
to
Han,

It appears that the "Microsoft Internet Transfer Control" API you mentioned
does not have a facility to upload or "put" a file using FTP.

Could you elaborate on "VB wrapper of the wininet.dll"?
Where you suggesting that a wrapper already exits or that I should write a
wrapper?

Matthew

"Han" <hp4...@kornet.net> wrote in message
news:#40UJL0P...@TK2MSFTNGP11.phx.gbl...

Matthew L. Butcher

unread,
Jun 30, 2003, 4:25:41 PM6/30/03
to
Han,

Looks like I spoke to soon about the ability to "put" or upload a file.

In addition to my previous questions, why do you recommend the "VB wrapper"
if in a network environment?

Matthew

"Han" <hp4...@kornet.net> wrote in message
news:#40UJL0P...@TK2MSFTNGP11.phx.gbl...

Han

unread,
Jul 1, 2003, 8:37:57 AM7/1/03
to
Matthew

The control has "execute" method which does all the ftp commands. You may
want also "getChunk" with that. Check them in MSDN.

For wininet.dll, there may already a wheel someone made. But I don't know
about that. I've earlier used the following VB wrapper in MTS+ASP
environment without problem.

Option Explicit
Private Declare Function InternetOpen Lib "wininet.dll" Alias
"InternetOpenA" _
(ByVal lpszCallerName As String, _
ByVal dwAccessType As Long, _
ByVal lpszProxyName As String, _
ByVal lpszProxyBypass As String, _
ByVal dwFlags As Long) As Long

Private Declare Function InternetConnect Lib "wininet.dll" Alias
"InternetConnectA" _
(ByVal hInternetSession As Long, _
ByVal lpszServerName As String, _
ByVal nProxyPort As Integer, _
ByVal lpszUsername As String, _
ByVal lpszPassword As String, _
ByVal dwService As Long, _
ByVal dwFlags As Long, _
ByVal dwContext As Long) As Long

Private Declare Function InternetCloseHandle Lib "wininet.dll" _
(ByVal hInternetHandle As Long) As Boolean

Private Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" _
(ByVal hFtpSession As Long, _
ByVal lpszLocalFile As String, _
ByVal lpszRemoteFile As String, _
ByVal dwFlags As Long, _
ByVal dwContext As Long) As Boolean

Private io, fo As Long

Public Function init1() As Boolean
io = InternetOpen("http generic", 0, vbNullString, vbNullString, 0)
If io <> 0 Then
fo = InternetConnect(io, "ftp.xxx.com", 21, "YOUR ID", "YOUR
PASSWORD", 1, 0, 0)
If fo <> 0 Then init1 = True
End If
End Function

Public Function put1(path1 as string) As Boolean
On Error GoTo exitPut
FtpPutFile fo, path1, mid(path1,instrRev(path1,"\")+1), &H1, 0
put1 = True
Exit Function
exitPut:
put1 = False
End Function

Public Sub close1()
If io <> 0 Then InternetCloseHandle io
If fo <> 0 Then InternetCloseHandle fo
End Sub

"Matthew L. Butcher" <matthew...@vfc.com> wrote in message

news:OuYwcV0P...@TK2MSFTNGP11.phx.gbl...

Matthew L. Butcher

unread,
Jun 30, 2003, 4:44:47 PM6/30/03
to
Han,

I attempted to create an object for "InetCtls.Inet" but I received an error
indicating that it was not licensed for use. I guess this means that your
first suggestion is a no go for VBScript.

Thanks for your input!

Matthew

"Han" <hp4...@kornet.net> wrote in message

news:O4oFDe0P...@TK2MSFTNGP11.phx.gbl...

Han

unread,
Jul 1, 2003, 10:08:51 AM7/1/03
to
Hi Matthew

Check this earlier thread.
http://groups.google.com/groups?as_q=license%20inetctl&safe=images&ie=UTF-8&
oe=UTF-8&lr=&hl=en

"Matthew L. Butcher" <matthew...@vfc.com> wrote in message

news:ednRCi0P...@TK2MSFTNGP10.phx.gbl...

Han

unread,
Jul 1, 2003, 11:08:22 AM7/1/03
to
Hi Matthew

You have not handle with the control while you have with the API.

"Matthew L. Butcher" <matthew...@vfc.com> wrote in message

news:uzcgXX0P...@TK2MSFTNGP11.phx.gbl...

0 new messages