• Internet Transfer Control (VB6)

    Author
    Topic
    #389358

    Hi,
    Would anyone happen to know if there is a variable to replace the internet transfer control on a form?
    (in the same way Dim mMessage As New MAPIMessages, mSession As New MAPISession replace the MAPI controls).

    Any help or links would be much appreciated as the only solutions i’ve found have been for vb.net!

    p.s. After a while longer trawling the web I noticed alot of references to the API wininet. Would anyone happen to have a good example of downloading a file using this API?

    Viewing 0 reply threads
    Author
    Replies
    • #688119

      Check out http://www.planet-source-code.com[/url%5D which has some excellent examples of this type of code. Do a search on ‘wininet’ or something similar & you’re bound to find something…

      • #688410

        Thanks for the tip about planet source – however, the search engine one I usually do before making a post. And in this case, I found how to do it in vb .net, c and foxpro – but no luck finding it in good old visual basic.
        I thought about trying to convert one of the ones I found but decided it would probably take just as long as finding the original answer. In the mean time, i’ve been stuck doing a different task which is a bit unfortunate!
        Thanks again for your help, ill have a look through planet source when i’ve finished with my new nightmare!

        • #688413

          Check out this particular submission which seems to be fairly complete…should demonstrate all the different Wininet APIs and how to use them…

          http://www.planet-source-code.com/vb/scrip…=21186&lngWId=1%5B/url%5D

        • #688423

          You might take a look at MSKB Article 175179 – SAMPLE: VBFTP.EXE: Implementing FTP Using WinInet API from VB. Article provides a sample VB (not .NET!) project you can download that demonstrates use of the WinInet API’s. After looking at some of the API calls involved you may want to go back to using the ITC – using the control is definitely simpler….

          • #688426

            Thanks for your links, ill look into them both.

            The only reason I was going to look into the APIs is because i’d prefer not to have a form to have the control on, and so far i’ve been unable to find a replacement variable for the internet transfer control (haven’t looked since friday though).

            So far, using the control, my program works fine in that it opens a form, the user clicks a button and the process runs, but ideally i’d like to remove the form so only code remains and try and set it up as a service that runs once a week or something.
            I could use the task scheduler thing in Windows but I thought this would be a good opportunity to learn how to get a program running as a service and have a go at making a stand alone .exe with no forms (haven’t done that since Pascal at college!).

            • #688429

              You can use ITC for file transfer w/o having to place control on form. Here is simple example of sub in a standard code module that downloads a file to local PC using HTTP:

              Sub httpDownloadFile(ByVal strURL As String, _
              ByVal strLocalFile As String)

              Dim itc As Inet
              Dim FileContents() As Byte
              Dim lngFileSize As Long
              Dim strMsg As String

              Set itc = New Inet

              With itc
              .Protocol = icHTTP
              .URL = strURL
              FileContents() = .OpenURL(.URL, icByteArray)
              End With

              lngFileSize = UBound(FileContents)

              Open strLocalFile For Binary Access Write As #1
              Put #1, , FileContents()
              Close #1

              ‘ Test msg:

              strMsg = “File transfer complete. File downloaded to:” & vbCrLf & _
              strLocalFile & vbCrLf & vbCrLf & _
              “File Size in Bytes: ” & lngFileSize

              MsgBox strMsg, vbInformation, “FILE TRANSFER COMPLETE”

              Set itc = Nothing

              End Sub

              For 1st arg provide URL for file being downloaded, for 2nd arg the full path of location to save file. Similar code can be used for FTP transfers. You need to set a reference to “MIcrosoft Internet Transfer Control 6.0” (MSINET.OCX) (or whatever version you are using).

              HTH

            • #876433

              > Set itc = New Inet

              I’m getting an error ‘429’ “ActiveX component can’t create Object”. The control is registered (via regSvr) and I rebooted to make sure the updated registry was loaded.

              I’d appreciate any clues as to what I’ve done “wrong”

            • #876751

              According to MS, this error could have any possible number of causes. For example, see MSKB 244264 (re Office but same concepts apply to any component):

              INFO: Troubleshooting Error 429 When Automating Office Applications

              “Unlike some errors in Visual Basic, there is no one cause to an error 429. The problem happens because of an error in the application or system configuration, or a missing or damaged component. Finding the exact cause is a matter of eliminating possibilities. If you encounter this error on a client computer, there are a number of things you will need to check to isolate and resolve the error.” One suggestion is to use CreateObject instead of New: “CreateObject more closely maps to the creation process used by most Visual C++ clients, and allows for possible changes in the server’s CLSID between versions. CreateObject can be used with both early-bound and late-bound objects.” And: “Verify that the ProgID string passed to CreateObject is correct and that it is version independent.”

              CreateObject uses a different mechanism than the New operator to activate a component. When using “New”, the VB runtime calls CoCreateInstanceEx, which requires the compiler to know the CLSID of the class to be created at compile time. When using CreateObject, VB calls CLSIDFromProgIDEx to get the CLSID (at runtime) from the ProgID string you pass to CreateObject. Once the CLSID is obtained, CreateObject calls CoCreateInstance (CoCreateInstanceEx can query more than one interface at a time so can be quicker). The CLSID, ProgID, etc are stored in Registry (assuming component has been registered properly). For example, the ITC on my system is registered as:

              ' [HKEY_CLASSES_ROOTInetCtls.Inet]
              ' @="Microsoft Internet Transfer Control 6.0 (SP6)"
              ' [HKEY_CLASSES_ROOTInetCtls.InetCLSID]
              ' @="{48E59293-9880-11CF-9754-00AA00C00908}"
              ' [HKEY_CLASSES_ROOTCLSID{48E59293-9880-11CF-9754-00AA00C00908}InprocServer32]
              ' @="C:WINDOWSSystem32MSINET.OCX"
              ' [HKEY_CLASSES_ROOTCLSID{48E59293-9880-11CF-9754-00AA00C00908}ProgID]
              ' @="InetCtls.Inet.1"

              To test code using CreateObject instead of New, replace:

              Dim ITC As Inet
              Set ITC = New Inet

              with:

              Dim ITC As Object
              Set ITC = CreateObject("InetCtls.Inet") ‘ Version independent ProgID

              Rest of sample code posted previously remains the same. Tested downloading an .EXE using both methods with test sub:

              Sub TestDownloadFileHTTP()

              Dim strURL As String
              Dim strLocalFile As String

              ' see MSKB 195653, SAMPLE: Using FTP WinInet APIs in Visual Basic with SimpleFtp
              ' http://support.microsoft.com/default.aspx?...653&Product=vbb

              strURL = "http://download.microsoft.com/download/ie4095/vbsmpftp/1/w9xnt4/en-us/VBSMPFTP.exe"
              strLocalFile = "C:AccessVBSmpFtp.exe"
              DownloadFileHTTP strURL, strLocalFile
              End Sub

              This successfully downloaded file to disk using either method. I don’t know if using CreateObject instead of New will make any difference in your case – could be some other totally unrelated issue – but would try it to see if works. Otherwise, I have no brainstorms, since Error 429 may have any number of mysterious causes, other than check Registry entries, or to use WinInet API directly instead of the flaky control (do a MSKB search on “Internet Transfer Control error” to see what I mean by “flaky”).

              HTH

            • #876901

              > using CreateObject instead of New

              Mark, thanks for the comprehensive reply. I read the links, and noted too that I don’t have a C:WINDOWSSystem32MSINET.OCX, and had hooked up to one as C:ApplInstalledAct6!SUPPORTMSINET.OCX. The different version may be a problem, I guess. Mine is dated 6/24/98 which doesn’t sound like the latest!

              I followed the registry classes and I seem to have evrything in line there.

              And I used your suggestion for CreateObject. Still getting the ‘429’, so perhaps it’s in the “something else” category.

              Now this is a “would be nice to have” for me, so it’s not worth spending extra time on for now.

              Nonetheless I appreciate your help, and the gains I’ve made in my understanding of Objects.

            • #877269

              I recently found an expensive third party OCX on my computer, installed as part of WordPerfect. I was excited until I tried to add it to my Word 2002 project and got an error that it was not licensed for development use. sad Although you didn’t get that message, I think that might be an additional possibility, depending on where it came from.

            • #877319

              It’s possible a “license” issue could cause problem. See MSKB 194751:

              FILE: VB6Cli.exe Fixes License Problems with Visual Basic 6.0

              Quote: “VB6Cli.exe is a utility that is designed to fix design-time license problems with ActiveX Controls that ship with Microsoft Visual Basic 6.0.” Error 429 is listed among several possible errors due to license issue. Article has a list of ActiveX controls that VB6Cli.exe can fix, that includes the Internet Transfer Control 6.0 (MSINET.OCX). The article provides further details. May be worth a look for anyone with this problem.

              HTH

            • #877409

              > See MSKB 194751:

              Mark, thanks for this

            • #877410

              > See MSKB 194751:

              Mark, thanks for this

            • #877320

              It’s possible a “license” issue could cause problem. See MSKB 194751:

              FILE: VB6Cli.exe Fixes License Problems with Visual Basic 6.0

              Quote: “VB6Cli.exe is a utility that is designed to fix design-time license problems with ActiveX Controls that ship with Microsoft Visual Basic 6.0.” Error 429 is listed among several possible errors due to license issue. Article has a list of ActiveX controls that VB6Cli.exe can fix, that includes the Internet Transfer Control 6.0 (MSINET.OCX). The article provides further details. May be worth a look for anyone with this problem.

              HTH

            • #877407

              > depending on where it came from.

              I agree. And in this case we can see where it’s from. I think I’m perplexed by the amount of library code that gets installed on this machine whenever a client asks that some software be installed. No matter how I try to reduce installation problems, I soon seem to have three copies of any DLL or OCX or whatever being quoted, and not one of “mine” wll work in the examples!

              I am in the habit of doing a quick re-install every 6 to 12 months (as in delete C:Windows and C:Program Files and then re-install Windows and Office)

            • #877408

              > depending on where it came from.

              I agree. And in this case we can see where it’s from. I think I’m perplexed by the amount of library code that gets installed on this machine whenever a client asks that some software be installed. No matter how I try to reduce installation problems, I soon seem to have three copies of any DLL or OCX or whatever being quoted, and not one of “mine” wll work in the examples!

              I am in the habit of doing a quick re-install every 6 to 12 months (as in delete C:Windows and C:Program Files and then re-install Windows and Office)

            • #877270

              I recently found an expensive third party OCX on my computer, installed as part of WordPerfect. I was excited until I tried to add it to my Word 2002 project and got an error that it was not licensed for development use. sad Although you didn’t get that message, I think that might be an additional possibility, depending on where it came from.

            • #876902

              > using CreateObject instead of New

              Mark, thanks for the comprehensive reply. I read the links, and noted too that I don’t have a C:WINDOWSSystem32MSINET.OCX, and had hooked up to one as C:ApplInstalledAct6!SUPPORTMSINET.OCX. The different version may be a problem, I guess. Mine is dated 6/24/98 which doesn’t sound like the latest!

              I followed the registry classes and I seem to have evrything in line there.

              And I used your suggestion for CreateObject. Still getting the ‘429’, so perhaps it’s in the “something else” category.

              Now this is a “would be nice to have” for me, so it’s not worth spending extra time on for now.

              Nonetheless I appreciate your help, and the gains I’ve made in my understanding of Objects.

            • #876752

              According to MS, this error could have any possible number of causes. For example, see MSKB 244264 (re Office but same concepts apply to any component):

              INFO: Troubleshooting Error 429 When Automating Office Applications

              “Unlike some errors in Visual Basic, there is no one cause to an error 429. The problem happens because of an error in the application or system configuration, or a missing or damaged component. Finding the exact cause is a matter of eliminating possibilities. If you encounter this error on a client computer, there are a number of things you will need to check to isolate and resolve the error.” One suggestion is to use CreateObject instead of New: “CreateObject more closely maps to the creation process used by most Visual C++ clients, and allows for possible changes in the server’s CLSID between versions. CreateObject can be used with both early-bound and late-bound objects.” And: “Verify that the ProgID string passed to CreateObject is correct and that it is version independent.”

              CreateObject uses a different mechanism than the New operator to activate a component. When using “New”, the VB runtime calls CoCreateInstanceEx, which requires the compiler to know the CLSID of the class to be created at compile time. When using CreateObject, VB calls CLSIDFromProgIDEx to get the CLSID (at runtime) from the ProgID string you pass to CreateObject. Once the CLSID is obtained, CreateObject calls CoCreateInstance (CoCreateInstanceEx can query more than one interface at a time so can be quicker). The CLSID, ProgID, etc are stored in Registry (assuming component has been registered properly). For example, the ITC on my system is registered as:

              ' [HKEY_CLASSES_ROOTInetCtls.Inet]
              ' @="Microsoft Internet Transfer Control 6.0 (SP6)"
              ' [HKEY_CLASSES_ROOTInetCtls.InetCLSID]
              ' @="{48E59293-9880-11CF-9754-00AA00C00908}"
              ' [HKEY_CLASSES_ROOTCLSID{48E59293-9880-11CF-9754-00AA00C00908}InprocServer32]
              ' @="C:WINDOWSSystem32MSINET.OCX"
              ' [HKEY_CLASSES_ROOTCLSID{48E59293-9880-11CF-9754-00AA00C00908}ProgID]
              ' @="InetCtls.Inet.1"

              To test code using CreateObject instead of New, replace:

              Dim ITC As Inet
              Set ITC = New Inet

              with:

              Dim ITC As Object
              Set ITC = CreateObject("InetCtls.Inet") ‘ Version independent ProgID

              Rest of sample code posted previously remains the same. Tested downloading an .EXE using both methods with test sub:

              Sub TestDownloadFileHTTP()

              Dim strURL As String
              Dim strLocalFile As String

              ' see MSKB 195653, SAMPLE: Using FTP WinInet APIs in Visual Basic with SimpleFtp
              ' http://support.microsoft.com/default.aspx?...653&Product=vbb

              strURL = "http://download.microsoft.com/download/ie4095/vbsmpftp/1/w9xnt4/en-us/VBSMPFTP.exe"
              strLocalFile = "C:AccessVBSmpFtp.exe"
              DownloadFileHTTP strURL, strLocalFile
              End Sub

              This successfully downloaded file to disk using either method. I don’t know if using CreateObject instead of New will make any difference in your case – could be some other totally unrelated issue – but would try it to see if works. Otherwise, I have no brainstorms, since Error 429 may have any number of mysterious causes, other than check Registry entries, or to use WinInet API directly instead of the flaky control (do a MSKB search on “Internet Transfer Control error” to see what I mean by “flaky”).

              HTH

            • #876434

              > Set itc = New Inet

              I’m getting an error ‘429’ “ActiveX component can’t create Object”. The control is registered (via regSvr) and I rebooted to make sure the updated registry was loaded.

              I’d appreciate any clues as to what I’ve done “wrong”

    Viewing 0 reply threads
    Reply To: Reply #688410 in Internet Transfer Control (VB6)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel