Results 1 to 14 of 14
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Transfer Control (VB6)

    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?

  2. #2
    2 Star Lounger
    Join Date
    Nov 2001
    Location
    London, UK, England
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Internet Transfer Control (VB6)

    Check out http://www.planet-source-code.com which has some excellent examples of this type of code. Do a search on 'wininet' or something similar & you're bound to find something...

  3. #3
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Internet Transfer Control (VB6)

    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!

  4. #4
    2 Star Lounger
    Join Date
    Nov 2001
    Location
    London, UK, England
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Internet Transfer Control (VB6)

    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

  5. #5
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Internet Transfer Control (VB6)

    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....

  6. #6
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Internet Transfer Control (VB6)

    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!).

  7. #7
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Internet Transfer Control (VB6)

    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

  8. #8
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Internet Transfer Control (VB6)

    > 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"

  9. #9
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Internet Transfer Control (VB6)

    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:

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

    To test code using CreateObject instead of New, replace:

    <code> Dim ITC As Inet</code>
    <code> Set ITC = New Inet</code>

    with:

    <code> Dim ITC As Object</code>
    <code> Set ITC = CreateObject("InetCtls.Inet")</code> ' Version independent ProgID

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

    <code>Sub TestDownloadFileHTTP()</code>

    <code> Dim strURL As String</code>
    <code> Dim strLocalFile As String</code>

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

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

    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

  10. #10
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Internet Transfer Control (VB6)

    > 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.

  11. #11
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Internet Transfer Control (VB6)

    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. <img src=/S/sad.gif border=0 alt=sad width=15 height=15> Although you didn't get that message, I think that might be an additional possibility, depending on where it came from.

  12. #12
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Internet Transfer Control (VB6)

    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

  13. #13
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Internet Transfer Control (VB6)

    > 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)

  14. #14
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Internet Transfer Control (VB6)

    > See MSKB 194751:

    Mark, thanks for this

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •