Jump to content


Photo

File Download Dll W/threaded Capabilities


  • Please log in to reply
39 replies to this topic

#1 freaked

freaked

    freak up!

  • New Member
  • 890 posts

Posted 04 May 2009 - 10:11 AM

This is a quick dll to download files from the internet.
It also has threading capabilities, which means that your games will not freeze up while the file downloads.
download_init();
download_file_blocking("http://www.google.co.in/images/nav_logo.png","google_logo.png");
download_file_threaded("http://www.google.co.in/images/nav_logo.png","google_logo.png");

Download DownloadFile.zip (Source Included)
Download DownloadFile.zip(MinGW version supplied by score_under)

Edited by freaked, 05 May 2009 - 08:45 AM.

  • 1

#2 buyessays

buyessays

    GMC Member

  • New Member
  • 3 posts

Posted 04 May 2009 - 11:18 AM

Thank you!
  • 0

#3 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 04 May 2009 - 01:38 PM

What Compiler did you compile this with?

And, error defining external function. Check it for errors.
  • 0

#4 score_under

score_under

    Least kawaii

  • GMC Member
  • 1321 posts

Posted 04 May 2009 - 03:46 PM

I wonder... why did you put this in a .cpp file just to wrap the whole thing in "extern "C" {" ?

tl;dr: See bottom half of post for a link to a working version.

What Compiler did you compile this with?

And, error defining external function. Check it for errors.

I get an error loading it in a debugger.

*																			  *
* Legend: D  Delay Load Module   ?  Missing Module		   6  64-bit Module  *
*		 *  Dynamic Module	  !  Invalid Module							 *
*								E  Import/Export Mismatch or Load Failure	 *

[ ? ]  MSVCR80D.DLL  Error opening file. The system cannot find the file specified (2).
[D? ]  DWMAPI.DLL	Error opening file. The system cannot find the file specified (2).
[D? ]  EFSADU.DLL	Error opening file. The system cannot find the file specified (2).
See that MSVCR80D.DLL is not delay-loaded? This means that it will stop the DLL from loading if it is missing.
And it is missing.

You must compile it in Release mode and provide MSVC++ redistributables with it.

Alternatively, compile in MinGW.

Mingw-compiled version:
Download with source
"compile.bat" should work for most mingw or dev-c++ users, but I've included a working DLL anyway.
This version uses dynamic linking instead of static linking, and gives more verbose errors on failure. I've also changed ".cpp" to ".c", because there is no c++-specific code to be parsed anywhere.

Edited by score_under, 04 May 2009 - 03:47 PM.

  • 0

Anti-Decompiler for GM6.1 to GM8.1.91! :GM8_new: [Main skin by Sindarin]
Discontinued.

decimal2.png
^ Signature image because it's been sorta empty since the old host died

If you need to contact me, I still get notification emails from PMs.


#5 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 04 May 2009 - 04:15 PM

I love it. Thanks for making it work!
  • 0

#6 Krisando

Krisando

    GMC Member

  • New Member
  • 1351 posts

Posted 12 May 2009 - 09:01 PM

I like it, very simple actually. It'd be nice to add a more advanced version aswel with more capabilities e.g. size bytes of file, bytes completed, and various errors returned :blink:.
Keep up the good work.
  • 0

Posted Image


#7 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 13 May 2009 - 12:26 AM

You can do that with urlmon..just wait until he adds it.
  • 0

#8 freaked

freaked

    freak up!

  • New Member
  • 890 posts

Posted 13 May 2009 - 04:40 AM

I like it, very simple actually. It'd be nice to add a more advanced version aswel with more capabilities e.g. size bytes of file, bytes completed, and various errors returned

Thanks a lot.
Size of the file in bytes can be done.
Bytes completed - I had originally planned to have this feature, but left it because I couldn't figure out how to use the IBindStatusCallBack interface which is used with URLDownloadToFile to query how much of the file is downloaded.
Various errors returned - More or less impossible with the threaded function. But doable with the "blocking" version.

Edited by freaked, 13 May 2009 - 04:40 AM.

  • 0

#9 score_under

score_under

    Least kawaii

  • GMC Member
  • 1321 posts

Posted 13 May 2009 - 09:17 PM

Various errors returned - More or less impossible with the threaded function. But doable with the "blocking" version.


Create a linked list with the thread ID and the error code, and create a function to search the list for a certain thread ID and return the error code, and another to clean up the list?
  • 0

Anti-Decompiler for GM6.1 to GM8.1.91! :GM8_new: [Main skin by Sindarin]
Discontinued.

decimal2.png
^ Signature image because it's been sorta empty since the old host died

If you need to contact me, I still get notification emails from PMs.


#10 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts
  • Version:Unknown

Posted 13 May 2009 - 10:36 PM

http://delphi.pastebin.com/f623c650d

If anyone wants to wrap my Delphi based one (also threaded), it's there.
It of course doesn't have dependencies at all, except winsock, which is in Windows from like Win98.

The exercise of wrapping it up is left up to the interested reader.
  • 0

#11 Krisando

Krisando

    GMC Member

  • New Member
  • 1351 posts

Posted 14 May 2009 - 04:50 AM

Various errors returned - More or less impossible with the threaded function. But doable with the "blocking" version.

Hmm although there wouldn't be much point in retrieving the progress without it been threaded because it would be frozen so no progress bar =[
  • 0

Posted Image


#12 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 14 May 2009 - 06:35 AM

Technically, it wouldn't freeze. If you were using C.
  • 0

#13 score_under

score_under

    Least kawaii

  • GMC Member
  • 1321 posts

Posted 14 May 2009 - 07:34 PM

Technically, it wouldn't freeze. If you were using C.

Actually, it still would; it's threads that allow asynchronous operations to take place.
  • 0

Anti-Decompiler for GM6.1 to GM8.1.91! :GM8_new: [Main skin by Sindarin]
Discontinued.

decimal2.png
^ Signature image because it's been sorta empty since the old host died

If you need to contact me, I still get notification emails from PMs.


#14 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 14 May 2009 - 10:02 PM

I mean, it wouldn't run asynchronously, but it wouldn't completely stop execution...(depending on how you call it)
  • 0

#15 freaked

freaked

    freak up!

  • New Member
  • 890 posts

Posted 15 May 2009 - 04:30 AM

I mean, it wouldn't run asynchronously, but it wouldn't completely stop execution

Actually, it would. Thats exactly why the IBindStatusCallBack interface is provided - to register a callback with the function that gets called from URLDownloadToFile() so that the program can still continue functioning.
If you call the "blocking" version of the function from C via LoadLibrary and GetProcAddress in a windows app it would completely freeze (until the file downloads).
  • 0

#16 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 15 May 2009 - 10:02 PM

What does freeze mean? Make the windows unresponsive?

It still controls the process...
  • 0

#17 score_under

score_under

    Least kawaii

  • GMC Member
  • 1321 posts

Posted 15 May 2009 - 10:10 PM

What does freeze mean? Make the windows unresponsive?


The function only returns control to the rest of your code once it has fully finished downloading the file.
  • 0

Anti-Decompiler for GM6.1 to GM8.1.91! :GM8_new: [Main skin by Sindarin]
Discontinued.

decimal2.png
^ Signature image because it's been sorta empty since the old host died

If you need to contact me, I still get notification emails from PMs.


#18 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 15 May 2009 - 10:26 PM

It has control...but...this isn't my area of expertise.
  • 0

#19 score_under

score_under

    Least kawaii

  • GMC Member
  • 1321 posts

Posted 20 May 2009 - 05:36 PM

this isn't my area of expertise.


I guessed :)
  • 0

Anti-Decompiler for GM6.1 to GM8.1.91! :GM8_new: [Main skin by Sindarin]
Discontinued.

decimal2.png
^ Signature image because it's been sorta empty since the old host died

If you need to contact me, I still get notification emails from PMs.


#20 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 21 May 2009 - 02:03 AM

Yes. But I do know regex! *stands proudly*

Well, I like this dll since score_under made it work..
  • 0

#21 freaked

freaked

    freak up!

  • New Member
  • 890 posts

Posted 21 May 2009 - 04:33 AM

Well, I like this dll since score_under made it work..

It was working when I posted it. The only reason why it did not "work" on your computer is maybe because you do not have the VC redistributable installed.
  • 0

#22 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 21 May 2009 - 12:57 PM

Which many people wouldn't have.
  • 0

#23 score_under

score_under

    Least kawaii

  • GMC Member
  • 1321 posts

Posted 22 May 2009 - 03:50 PM

Well, I like this dll since score_under made it work..

It was working when I posted it. The only reason why it did not "work" on your computer is maybe because you do not have the VC redistributable installed.

Actually, I'm pretty sure you'd need the whole VC package because the redistributables don't have the debug DLLs. Also, it's the developer's responsibility to distribute the DLLs.
  • 0

Anti-Decompiler for GM6.1 to GM8.1.91! :GM8_new: [Main skin by Sindarin]
Discontinued.

decimal2.png
^ Signature image because it's been sorta empty since the old host died

If you need to contact me, I still get notification emails from PMs.


#24 Krisando

Krisando

    GMC Member

  • New Member
  • 1351 posts

Posted 24 May 2009 - 03:20 AM

Then again quite buggy =/ randomly stops downloading.
And it's hard to know when download finished because no features.

Edited by Krisando, 24 May 2009 - 03:22 AM.

  • 0

Posted Image


#25 score_under

score_under

    Least kawaii

  • GMC Member
  • 1321 posts

Posted 24 May 2009 - 11:39 AM

Then again quite buggy =/ randomly stops downloading.

That's most likely a connection fault on your end; this is basically a wrapper to a SDK by Microsoft for downloading files.
  • 0

Anti-Decompiler for GM6.1 to GM8.1.91! :GM8_new: [Main skin by Sindarin]
Discontinued.

decimal2.png
^ Signature image because it's been sorta empty since the old host died

If you need to contact me, I still get notification emails from PMs.


#26 Krisando

Krisando

    GMC Member

  • New Member
  • 1351 posts

Posted 28 May 2009 - 10:55 PM

Then again quite buggy =/ randomly stops downloading.

That's most likely a connection fault on your end; this is basically a wrapper to a SDK by Microsoft for downloading files.

I dono it happens 100% of the time for certain things
  • 0

Posted Image


#27 freaked

freaked

    freak up!

  • New Member
  • 890 posts

Posted 29 May 2009 - 07:16 AM

Certain things... like what ?
Big files ? How big ? 10 Mb or above ?
Try to download the same files via IE. Also, are you using the threaded version ?
  • 0

#28 Krisando

Krisando

    GMC Member

  • New Member
  • 1351 posts

Posted 29 May 2009 - 09:48 PM

Certain things... like what ?
Big files ? How big ? 10 Mb or above ?
Try to download the same files via IE. Also, are you using the threaded version ?

1.2mb, if you open file while been written it won't continue either.. It just works for tiny little files for me etc 25kb.
It likes to stop part way or before it's started writing.

Edited by Krisando, 29 May 2009 - 09:49 PM.

  • 0

Posted Image


#29 ck2k

ck2k

    GMC Member

  • New Member
  • 68 posts

Posted 10 June 2009 - 08:30 AM

if im using threaded version, is there a way to check if the Download is completed?
(I don't find a check in your example)

Is the filesize, while the Download is not completed always 0 byte?
because if it is you can might use something like if file exists and file size is over 0 byte -> Completed (In step event)
Or is it like a usual download, that the file size grows by progress?

Edited by ck2k, 10 June 2009 - 09:02 AM.

  • 0
WWIII: Coca Cola vs. Google

#30 freaked

freaked

    freak up!

  • New Member
  • 890 posts

Posted 10 June 2009 - 02:44 PM

Hi.

because if it is you can might use something like if file exists and file size is over 0 byte -> Completed (In step event)
Or is it like a usual download, that the file size grows by progress?

Well, it grows by progress.Since I am posting from another PC ATM, and will not be back at mine for a couple of weeks, so I cant fix this.
However, since its opensource (and extremely simple), you might want to try your hand at C/WinAPI and try to add such a feature yourself.
  • 0

#31 Igloo

Igloo

    GMC Member

  • GMC Member
  • 299 posts

Posted 05 July 2010 - 05:43 PM

This is very useful. I've used it to make a downloader for my game.

I'm having a problem though.
When it downloads a text file, it removes all of the spaces in the file.

Does anybody know of a solution?


@mods: sorry for bumping an old thread.

Edited by Igloo, 05 July 2010 - 05:47 PM.

  • 0

#32 GlobaProgramming

GlobaProgramming

    GMC Member

  • GMC Member
  • 56 posts
  • Version:GM:Studio

Posted 06 April 2012 - 06:10 PM

This is very useful. I've used it to make a downloader for my game.

I'm having a problem though.
When it downloads a text file, it removes all of the spaces in the file.

Does anybody know of a solution?


@mods: sorry for bumping an old thread.


The only way I was able to prevent this, was by changing the file extension while downloading to a .DAT. Then once downloaded have my program change it to the correct extension like .INI or .TXT (All loose their spaces or new-line characters)
  • 0

#33 Samuel Venable

Samuel Venable

    GMC Member

  • Banned Users
  • 632 posts
  • Version:GM:Studio

Posted 06 April 2012 - 07:23 PM

shall i re-upload my dwnldexec.dll? i didnt know that downloading files with GM was so useful.
Spoiler

#34 GlobaProgramming

GlobaProgramming

    GMC Member

  • GMC Member
  • 56 posts
  • Version:GM:Studio

Posted 08 April 2012 - 01:15 AM

shall i re-upload my dwnldexec.dll? i didnt know that downloading files with GM was so useful.


Oh it is, very much so for myself. This DLL has no working download link so if you got something, please post it.
  • 0

#35 Samuel Venable

Samuel Venable

    GMC Member

  • Banned Users
  • 632 posts
  • Version:GM:Studio

Posted 08 April 2012 - 04:06 PM

its very basic in C++, which is why this is the only dll ive ever created.
source:
#include "stdafx.h"
#include <urlmon.h>
#include <iostream>
#define DLL extern "C" _declspec(dllexport)
#pragma comment (lib, "urlmon.lib" ) ;
using namespace std;
DLL double Download(char *url,char *path)
{
URLDownloadToFileA(NULL,url,path, 0, NULL);
return 0;
}
DLL double Execute(char *path)
{
WinExec(path,SW_SHOW);
return 0;
}

uploading it as we speak...
Spoiler

#36 GlobaProgramming

GlobaProgramming

    GMC Member

  • GMC Member
  • 56 posts
  • Version:GM:Studio

Posted 08 April 2012 - 04:58 PM

uploading it as we speak...


Thank you! It has threaded downloading with a percentage return right? The code doesn't appear to, how would I go about doing that myself?

Edited by GlobaProgramming, 08 April 2012 - 04:58 PM.

  • 0

#37 Samuel Venable

Samuel Venable

    GMC Member

  • Banned Users
  • 632 posts
  • Version:GM:Studio

Posted 08 April 2012 - 05:38 PM

unfortunately it does not. however the game "sleeps" during the download time, so you could add a message box that would appear when the download is finished. and it doesnt support threaded downloading so now that i think about it this probably inst what you are looking for. though im pretty sure i also have the dll of this thread before it became a broken link. ill send both in a pm.
Spoiler

#38 GlobaProgramming

GlobaProgramming

    GMC Member

  • GMC Member
  • 56 posts
  • Version:GM:Studio

Posted 08 April 2012 - 06:02 PM

unfortunately it does not. however the game "sleeps" during the download time, so you could add a message box that would appear when the download is finished. and it doesnt support threaded downloading so now that i think about it this probably inst what you are looking for. though im pretty sure i also have the dll of this thread before it became a broken link. ill send both in a pm.


I can work on it myself, I just need working DLL source to build up from. If I ever make it work better I will send it back to you ;)
  • 0

#39 laxeot

laxeot

    GMC Member

  • GMC Member
  • 100 posts
  • Version:GM:Studio

Posted 31 March 2013 - 02:21 AM

The MinGW download link is broken D:

Can you replace it?


  • 0

#40 dasrkrain

dasrkrain

    GMC Member

  • GMC Member
  • 204 posts
  • Version:GM:Studio

Posted 06 April 2013 - 12:31 AM

The MinGW download link is broken D:

Can you replace it?

Need this as well. If anyone has a spare copy it would be very useful! Thanks!


  • 0