Results 1 to 15 of 15

Thread: downloading

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800

    downloading

    is there a way to initiate a download? like make the download window pop up? I know I could open an IE window to the file but I want to be able to save it to a location...so how could I do that?

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You could create your own download window...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    I think it's URLDownloadToFile or something similar.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4
    jim mcnamara
    Guest
    Call LoadLibrary -- use shdocvw.dll. Call is: DoFileDownload.

    long DoFileDownload(LPCSTR url);

    MSDN doesn't document this call, but it's part of IE 5 & 6. It brings up the cute dialog boxes.

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    So you'd have to do:
    PHP Code:
    typedef long (WINAPIL_CASTR)(LPCSTR);

    HMODULE hMyDll LoadLibrary(TEXT("shdocvw.dll"));
    if(
    hMyDll == NULL) {} // error

    L_CASTR pDoFileDownload = (L_CASTR)GetProcAddress(hMyDllTEXT("DoFileDownload")); // DoFileDownloadA?

    // call
    pDoFileDownload("http://www...."); 
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    Parksie...URLDownloadToFile gets the html not the file

    okay I tried the code cornedbee gave...but a messagebox popped up giving a wierd error (I don't have any message boxes in my program...its not my custom error)



    as a test Im downloading this file: http://www.terminalstudio.com/files/instlawnm.exe
    (first one i saw on download.com )

  7. #7
    jim mcnamara
    Guest
    It has to be unicode text. My protoype is wrong.

    Sorry.

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    So you want LPCWSTR (or for the non-masochists, const wchar_t*).
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    so
    Code:
    ypedef long (WINAPI* L_CASTR)(LPCSTR(const wchar_t*));
    
    					HMODULE hMyDll = LoadLibrary(TEXT("shdocvw.dll"));
    					if(hMyDll == NULL) {} // error
    					
    					L_CASTR pDoFileDownload = (L_CASTR)GetProcAddress(hMyDll, TEXT("DoFileDownload")); // DoFileDownloadA?
    					
    					// call
    					pDoFileDownload("http://wwwterminalstudio.com/files/instlawnn.exe");
    ? 5 errors

  10. #10
    Zaei
    Guest
    URLDownloadToFile() certainly downloads files. It gets raw data from the server, and saves it to a file. Ive used it before to download files.

    Z.

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    Oh im such an idiot! It gets the html of a web page...but if you go to an exe, it gets the info on the exe When I was using that before I couldn't figure out how to get the % done....can you show me? (msdn's example confused the hell out of me)

    thanks

  12. #12
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    One more thing:
    pDoFileDownload(L"URL");
    because when you're using UNICODE, you're using UNICODE.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  13. #13
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    If you're reading the URL from user input, or something else that isn't known at compile time, you'll need the MultiByteToWideChar function:
    Code:
    string WideToANSI(const wstring &sIn) {
    	int iReq = WideCharToMultiByte(CP_ACP, 0, sIn.c_str(), -1, NULL, 0, NULL, NULL);
    	char *pcBuf = new char[iReq];
    	WideCharToMultiByte(CP_ACP, 0, sIn.c_str(), -1, pcBuf, iReq, NULL, NULL);
    	string sTemp = pcBuf;
    	delete[] pcBuf;
    	return sTemp;
    }
    
    wstring ANSIToWide(const string &sIn) {
    	int iReq = MultiByteToWideChar(CP_ACP, 0, sIn.c_str(), -1, NULL, 0);
    	wchar_t *pcBuf = new wchar_t[iReq];
    	MultiByteToWideChar(CP_ACP, 0, sIn.c_str(), -1, pcBuf, iReq);
    	wstring sTemp = pcBuf;
    	delete[] pcBuf;
    	return sTemp;
    }
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  14. #14
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    The stream classes do know wchar_t, so when you're using cin, you don't need to convert, cin does that for you.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  15. #15
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    It never seemed to do that properly before - probably a buggy implementation *looks daggers at microsoft*



    What if you're looking it up from the Registry then, or from user input in a text box...

    PS: Most of this stuff will be transparent when you stick to C++, but the Windows API isn't template-based (yet ) so you have to mess around sometimes.

    PPS: I wonder if that transparent conversion extends to stringstreams...
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

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



Click Here to Expand Forum to Full Width