Visual Basic 6 Black Book:Visual Basic And The Internet: Web Browsing, Email, HTTP, FTP, And DHTML
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
var end = document.cookie.indexOf (";", j);
if (end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(j, end));
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
var m1='';
var gifstr=GetCookie("UsrType");
if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; }
document.write(m1+m2+m3);
Keyword
Title
Author
ISBN
Publisher
Imprint
Brief
Full
Advanced Search
Search Tips
Please Select
-----------
Components
Content Mgt
Certification
Databases
Enterprise Mgt
Fun/Games
Groupware
Hardware
IBM Redbooks
Intranet Dev
Middleware
Multimedia
Networks
OS
Prod Apps
Programming
Security
UI
Web Services
Webmaster
Y2K
-----------
New Titles
-----------
Free Archive
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
(Publisher: The Coriolis Group)
Author(s): Steven Holzner
ISBN: 1576102831
Publication Date: 08/01/98
function isIE4()
{
return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') );
}
function bookMarkit()
{
var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0";
parent.location.href=url;
//var win = window.open(url,"myitk");
//if(!isIE4())
// win.focus();
}
Search this book:
Previous
Table of Contents
Next
Using The Internet Transfer Control For FTP And HTTP Operations
You use the Microsoft Internet transfer control to handle FTP and HTTP operations in Visual Basic. Using the HTTP protocol, you can connect to World Wide Web servers to retrieve HTML documents. With the FTP protocol, you can log on to FTP servers to download and upload files.
The UserName and Password properties allow you to log on to private servers that require authentication. Otherwise, you can connect to public FTP servers and download files. The common FTP commands, such as CD and GET, are supported through the Execute method. You can keep track of the Internet transfer controls operations with the StillExecuting property. If this property is True, the control is working on a transfer and will not respond to other actions.
The Internet transfer control performs asynchronous Internet transfers, so besides the StillExecuting property, Microsoft has given the control a StateChanged event. In this events handler procedure, you are kept up-to-date on whats going on with the Internet transfer control:
Private Sub object_StateChanged(ByVal State As Integer)
End Sub
The State argument can take these values:
icNone0; no state to report.
icHostResolvingHost1; the control is looking up the IP address of the specified host computer.
icHostResolved2; the control successfully found the IP address of the specified host computer.
icConnecting3; the control is connecting to the host computer.
icConnected4; the control successfully connected to the host computer.
icRequesting5; the control is sending a request to the host computer.
icRequestSent6; the control successfully sent the request.
icReceivingResponse7; the control is receiving a response from the host computer.
icResponseReceived8; the control successfully received a response from the host computer.
icDisconnecting9; the control is disconnecting from the host computer.
icDisconnected10; the control successfully disconnected from the host computer.
icError11; an error occurred in communicating with the host computer.
icResponseCompleted12; the request has completed and all data has been received.
Note that when a request is finished, the State argument in the StateChanged event will be set to icResponseCompleted, and its safe to execute another command with the Internet transfer control.
To add an Internet transfer control to a program, follow these steps:
1. Select the Project|Components menu item.
2. Click the Controls tab in the Components dialog box that opens.
3. Select the entry labeled Microsoft Internet Transfer Control.
4. Click on OK to close the Components dialog box to add the Microsoft Internet Transfer Control tool to the toolbox.
5. Double-click the Microsoft Internet Transfer Control tool to the toolbox and add that control to your form. This control is invisible at runtime, so its size and location are not important.
6. Add the code you want to use with the control to your program.
When you start an FTP or HTTP operation with the Internet transfer control, the control will connect to the Internet (using the users system defaults) if the computer is not already connected.
TIP: For a complete FTP file upload example, including using the StateChanged event, see our online application registration example in Chapter 30.
Now that weve added an Internet transfer control to a program, well put that control to work in the next few topics.
Handling FTP Operations In Visual Basic
There are two ways of handling FTP operations with the Microsoft Internet transfer control: using the OpenUrl method and using the Execute method. The OpenUrl method lets you download files and uses the FTP protocol if the URL you specify begins with ftp:// (for example, ftp://ftp.microsoft.com/file.txt); heres how you use OpenUrl:
InetControl.OpenUrl url [, datatype]
The datatype argument can either be icString (the default) for text data or icByteArray for binary data. If you use icString, OpenUrl returns a string; if you use icByteArray, OpenUrl returns a byte array.
The Execute method can execute FTP commands. Heres how you use Execute:
InetControl.Execute url, operation, data, requestHeaders
Heres what the arguments to Execute mean:
urlString that specifies the URL to which the control should connect. If no URL is specified here, the URL specified in the URL property will be used.
operationString that specifies the type of operation to be executed.
dataString that specifies the data for operations.
requestHeadersString that specifies additional headers to be sent from the remote server. The format for these is header name: header value vbCrLf.
The FTP commands that you can use with the Internet transfer control and what they do appear in Table 21.3.
Previous
Table of Contents
Next
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.
Wyszukiwarka
Podobne podstrony:
729 a727 (2)demo cgi 727723 727729 732727 731729,17,artykulReadMe (727)mbdch20 727ReadMe (729)więcej podobnych podstron