Windows API URLdl2file...
Results 1 to 4 of 4

Thread: Windows API URLdl2file...

  1. #1
    Junior Member
    Join Date
    Jul 2005

    Windows API URLdl2file...

    Please excuse if this isnot the right forum to post this...Here is something that works on vb but doesnot seem to be working with C++
    PHP Code:
    bool DownloadFile(charremotechar*local){
        return (

    its being used like this:
    PHP Code:
    LPSTR listAddr "";
    LPSTR srvFullRaw "C:\\srvList.raw";
    which doesnot seem to be working...On the other hand the same thing in vb works quite fine...
    Public Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
    Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
        Dim lngRetVal As Long
        lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
        If lngRetVal = 0 Then DownloadFile = True
    End Function
    Sub Main()
        DownloadFile "", "C:\srvList.raw"
    End Sub
    Just wondering what was wrong with the C++ code and how I might go around fixing it.


  2. #2
    Join Date
    Jul 2005
    (Wonders if the LPSTR type is equal to char*)

    What about:

    char* listAddr = "";
    char* srvFullRaw = "C:\srvList.raw";


  3. #3
    Just Another Geek
    Join Date
    Jul 2002
    Rotterdam, Netherlands
    The definition here uses LPCTSTR instead of LPSTR.. If I read this correctly it's a difference in Unicode/ANSI style strings.. You probably need to use the Unicode version..

    Another thing I remember (it's been a while) is that NULL!=0..
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  4. #4
    Join Date
    Jul 2005
    SirDice, Quick check... He calls URLDownloadToFileA and the A at the end suggests this is the ASCII-version of this functioncall. If he had used URLDownloadToFileW then I would agree with you that he needs WideChar (Unicode) strings here.

    However, the C code that's posted here doesn't tell us which version of this procedure is actually loaded here. You could be right that this function in C++ links to the Unicode version while the version in VB is linked to the ASCII version.

Posting Permissions

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