Step 4: Compile the project
It's time to compile the project. From the file menu, select the "Make HTTP.dll". The component is automatically registered on the computer where it is compiled but to register it on other computers, you will have to register it manually. Use regsvr32.exe to register the component manually.
Step 5: Testing the component
Lets test the component in VB first. It is always good practice to test the component in VB before taking it to the ASP. If you find an error while using the component in ASP then it will be quite laborious to recompile the component with new changes added to it. If such a situation occurs, then stop the IIS services and always unregister the component before deleting it, if you decide to do so. To unregister the component, use the following command:
Regsvr32.exe /u component.dll
Recompile the component and start the IIS services. To test the component in VB, add a standard EXE project to the current project. Add two command buttons on the form, change the caption of one button to "Test Dload Component" and change the caption of the other button to "Exit"
Private Sub Test_Click()
Dim objHTTP As New HTTP.DLoad
Dim strURL As String
objHTTP.Protocol1 = icHTTP
objHTTP.ProxyAddress = ""
objHTTP.RemotePort1 = 80
strURL = "http://server/application/images/image1.gif"
objHTTP.DLoad strURL, "c:\test.gif"
MsgBox objHTTP.Status
Set objHTTP = Nothing
End Sub
The test code is pretty simple. Set the property values and provide the name of the file to be download.
Use the code below to test the component in ASP:
<%
Dim objHTTP
Set objHTTP = server.createobject("HTTP.Dload")
Dim strURL
objHTTP.Protocol1 = icHTTP
objHTTP.ProxyAddress = ""
objHTTP.RemotePort1 = 80
strURL = "http://server/application/images/image1.gif"
objHTTP.DLoad (strURL, "c:\test.gif")
response.write objHTTP.Status
Set objHTTP = Nothing
%>
You will find the string (string containing the name of the file to be downloaded)
parsing code in the ASP file provided with this article.
ASP and VB code is provided with this article. ASP code contains two asp pages,
form1.asp is the initial form and the results from form1.asp are passed to the
form2.asp. In form2.asp, object is created and the values from form1.asp are
passed to the object.
VB code contains a form and values that are to be passed to the object are hard coded in the form, you can change the values to test the functionality.
Comments