Thread: WinINet Problems

  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    20

    WinINet Problems

    Hi i got a problem with following Function:

    Code:
    void GetFiles()
    {
       FILE* pFile;
       DWORD ReadFiles,dwSize;
       char buf[1025];
       HINTERNET hInternet, hFile;
       
       hInternet = InternetOpen("sCC Patcher", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
       hFile = InternetOpenUrl(
          hInternet,
          "someurl",
          NULL,
          0,
          INTERNET_FLAG_RELOAD,
          INTERNET_NO_CALLBACK
       );
         
       pFile = fopen("l2.exe", "w+");
       
       InternetReadFile(hFile, buf,  1024,  &ReadFiles);
       while(ReadFiles != 0)
       {
          fwrite ( buf, ReadFiles, 1, pFile );
          InternetReadFile(hFile, buf,  1024,  &ReadFiles);
       }
       fwrite ( buf, ReadFiles, 1, pFile );
       fclose(pFile);
    }
    The File gets downloaded, but its too big. When i compare original to downloaded file hexwise, i can see that some bytes are twice there in the downloaded file, and as far as i can judge, all the original stuff is there.
    If it help i can upload original and downloaded file.

    Thx

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    I think you need to open the file in binary mode:
    Code:
    fopen("l2.exe", "wb");
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    Registered User
    Join Date
    Dec 2004
    Posts
    20
    oh man thanks.... how stupid from me thats it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  2. C Pointers Problems
    By mhelal in forum C Programming
    Replies: 8
    Last Post: 01-10-2007, 06:35 AM
  3. String Manipulation problems -_-
    By Astra in forum C Programming
    Replies: 5
    Last Post: 12-13-2006, 05:48 PM
  4. Rendering problems (DirectX?)
    By OnionKnight in forum Tech Board
    Replies: 0
    Last Post: 08-17-2006, 12:17 PM
  5. contest problems on my site
    By DavidP in forum Contests Board
    Replies: 4
    Last Post: 01-10-2004, 09:19 PM