Link to home
Start Free TrialLog in
Avatar of kfrick
kfrick

asked on

MSInet Control on DHTML Page doesn't load.....

I have a DHTML project that includes the MSInet control. When I run the project on either of 2 development systems (Win2K, WinXP), it works fine. When I create an Install Set and install it on another PC, the MSINet control just appears as an empty box. In the design environment, the MSINet control is not even visible on the page, but at run time there is an empty box.

Any idea as to what I'm doing wrong?


-konfused karl

ASKER CERTIFIED SOLUTION
Avatar of Richie_Simonetti
Richie_Simonetti
Flag of Argentina image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kfrick
kfrick

ASKER

Perhaps this is the problem all along......maybe I'm juts going about this wrong!

Here's the scoop: An industrial scale indicator exposes an FTP area on our network. The scale can read and write files in this area. A group of files define the scale's setup.

A browser-based way of administering thee files is desired.

I am attempting to use the INet control to read the files from the scale to local files. I then use VB code populate the text input boxes on my DHTML page with the contents of the various files. The user can edit data, click SUBMIT, and VB code will move the data from the text input boxes to the files, and FTP the files to the scale.

Now, all this works on the 2 development machines. But the INet control never appears on other machines on which I have tested the installation.

Maybe I should NOT be trying to use the MSINet control on the page? How else might you go about this? I'm open for suggestions....

-karl
Well, since it works on other machines, please verify is msinet.ocx is installed on those machines that fails.
Avatar of kfrick

ASKER

Well, the PDW includes MSINET.OCX for distribution in the install set.......I have a feeling it's something to do with starting an instance of MSINet at run-time, rather than installing it on the DHTML page......Hmmmmmm......

-karl
some background:
from devx.site (link no longer available)

WinInet API Programming
By Matthew Arnheiter

Visual Basic applications are becoming more connected, and developers are trying to Web-enable their applications by supporting HTTP or FTP. Often this requires using the Microsoft Internet Transfer control or a third party control, but all of the functionality can be achieved through the use of the WinInet API without the need of a form to host the control.


This solution will present the FTP functionality of the WinInet API and provide a wrapper to this API so that you can easily add FTP support to your applications.

Built into Windows are several APIs that allow you to develop rich networking applications. Two that are available to Visual Basic developers are the Win32 Internet API (WinInet) and the WinSock API. These two APIs are encapsulated in the Microsoft Internet Transfer control and the Winsock control, but they do not offer all of the flexibility that working with the API does.

The WinInet API was designed to abstract three Internet protocols, HTTP, FTP, and Gopher; making it easier for developers to build Internet-enabled applications. WinInet exposes many functions for Web-enabling your applications. Some of the functions that exist in the API are:


InternetConnect - Opens a FTP, Gopher, or HTTP session to a given site.
InternetReadFile - Reads data from a handle on a site.
InternetWriteFile - Writes data to an open Internet file.
FTPGetFile - Retrieves a file from a FTP site and saves it locally.
FTPRenameFile - Renames a file on a FTP site.

Now let's go into detail on the FTP functions that the WinInet API exposes and create a wrapper class to allow you to easily add FTP support without the use of ActiveX controls.
FTP API Functions
The WinInet API exposes 12 functions that allow developers to manipulate and navigate files and directories on a FTP site. In addition there are several functions that provide session management for opening and closing handles to a site. When working with the WinInet API, there is a sequence of events that occur over an over. This sequence is:

1. Initialize the WinInet API by calling the InternetOpen function
2. Connect to a site and retrieve a handle to the open connection by using the InternetConnect function
3. Navigate through the site and manipulate files and directories
4. Close the connection

To make this more concrete, let's download a file from Microsoft's FTP site using the WinInet API. The code for downloading ls-lr.zip from the root directory would be:


    hInternet = InternetOpen("DevX Sample", _
INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, _
INTERNET_FLAG_NO_CACHE_WRITE)
    hConnect = InternetConnect(hInternet, "ftp.Microsoft.com", _
INTERNET_DEFAULT_FTP_PORT, _
            "", "", INTERNET_SERVICE_FTP, _
            INTERNET_FLAG_EXISTING_CONNECT Or INTERNET_FLAG_PASSIVE, _
&H0)
    lRes = FtpGetFile(hConnect, "ls-lr.zip", "c:\ls-lr.zip", _
False, FILE_ATTRIBUTE_ARCHIVE, _
            FTP_TRANSFER_TYPE_UNKNOWN, 0&)
    lRes = InternetCloseHandle(hConnect)
    lRes = InternetCloseHandle(hInternet)

To get a better understanding of what is happening, let's take a closer look at each function.

InternetOpen
The first function to be called is the InternetOpen function. This initializes the internal state of the WinInet API. The declaration of the InternetOpen method is:
Public Declare Function InternetOpen Lib "wininet.dll" _


 
   Alias "InternetOpenA" _
  (ByVal lpszAgent As String, _
   ByVal dwAccessType As Long, _
   ByVal lpszProxyName As String, _
   ByVal lpszProxyBypass As String, _
   ByVal dwFlags As Long) As Long

The following table describes each of the parameters.

Parameter Description
lpszAgent Sets the user agent string that is passed to the server during each call.
dwAccessType Determines what access will be used, either direct connection or through a proxy.
lpszProxyName Lists the names of the proxy servers to use.
lpszProxyBypass Lists the names of clients that should not use a proxy server.
dwFlags Flags for setting asynchronous requests and caching support.
Table 1: Parameters for the InternetOpen function

InternetOpen returns a handle that is used in subsequent calls into the WinInet API. You will only have to call this function once and store the handle in a variable.

InternetConnect
After initializing the WinInet DLL, you must retrieve a handle to an FTP session. This is accomplished using the InternetConnect function. The handle that you receive will be used in all of the subsequent calls to manipulate files and directories and navigate through the FTP site. The InternetConnect function is passed connection information like the site you are connecting to and the user's name and password. In addition, the type of connection is specified. In the following case we are opening a FTP session:


 
  hConnect = InternetConnect(hInternet,
      "ftp.Microsoft.com", INTERNET_DEFAULT_FTP_PORT, _
            sUserName, sPassword, INTERNET_SERVICE_FTP, _
            INTERNET_FLAG_EXISTING_CONNECT Or INTERNET_FLAG_PASSIVE, &H0)

With the connection handle you can start manipulating file and directories on the FTP site.


FTP Functions
The WinInet API exposes several functions that allow you to manipulate files and directories and to navigate through a FTP site. The following table lists all of the functions.

Function Description
FtpCreateDirectory Creates a new directory on the FTP site
FtpGetCurrentDirectory Retrieves the current directory
FtpRemoveDirectory Deletes a directory and all sub items from the FTP site
FtpSetCurrentDirectory Changes the current directory  
FtpDeleteFile Deletes a file from the FTP site
FtpFindFirstFile Searches the current directory of a FTP site for files and subdirectories
FtpGetFile Downloads a file from a FTP site to the local machine
FtpGetFileSize Retrieves the size of a file from the FTP site
FtpOpenFile Opens a handle to a file on the FTP for reading and writing
FtpPutFile Uploads a file to the FTP site
FtpRenameFile Renames a file on the FTP site
FtpCommand Provides an interface for sending FTP commands to the FTP server
Table 2: FTP functions within the WinInet API

All of these functions take a handle to an Internet connection and specific information on the file or directory to manipulate. All of the declarations for these functions can be found in the WinInetAPI.bas file in the source code.

WinInet FTP Class
As with most APIs it is often easier to think about and work with the API if it is wrapped in a class module. The accompanying source code contains one class module that exposes the FTP functionality of the WinInet API. By encapsulating the functionality within a class module, most of the details of the underlying API can be removed from client application. To demonstrate this, we will download the same ls-lr.zip from Microsoft's FTP site:


 
    Dim oFTP As New clsFTP
   
    oFTP.OpenConnection "ftp.Microsoft.com", "", "", ""
    oFTP.DownloadFile "ls-lr.zip", "C:\"
    oFTP.CloseConnection
   
    Set oFTP = Nothing

The class can be used to perform most interactions with an FTP site such as navigating through the directory structure, enumerating files and directories, and manipulating the file and directories. You can download the code by clicking here.

Limitations of WinInet
The WinInet API was not designed to scale for high-stress, high-volume server environments. It was designed to provide FTP, HTTP, and Gopher functionality for Internet Explorer. Because it was designed as a client application, the uses registry values contained in the HKEY_CURRENT_USER hive are not available if you are running the WinInet API from NT services such as IIS. In addition, the WinInet API limits the number of concurrent connections to a single server to just two connections. This is in agreement with the HTTP specification. To accomplish networking tasks on a server you will need to use the WinSock API or third party components that were designed for this task.

try updating the ie to the same version in the machine it was created and then ... check that msinet.ocx is correctly registered and working... do some tests... with a small app with only the msinet and a messagebox...

good luck
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
No response from kfrick from 10/21/2003 comment
Award points to Richie_Simonetti is recommend.
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

planocz
EE Cleanup Volunteer