|
-
Dec 27th, 2001, 11:08 PM
#1
Thread Starter
Frenzied Member
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?
-
Dec 28th, 2001, 08:07 AM
#2
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.
-
Dec 28th, 2001, 09:12 AM
#3
Monday Morning Lunatic
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
-
Dec 28th, 2001, 10:29 AM
#4
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.
-
Dec 28th, 2001, 11:41 AM
#5
So you'd have to do:
PHP Code:
typedef long (WINAPI* L_CASTR)(LPCSTR);
HMODULE hMyDll = LoadLibrary(TEXT("shdocvw.dll"));
if(hMyDll == NULL) {} // error
L_CASTR pDoFileDownload = (L_CASTR)GetProcAddress(hMyDll, TEXT("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.
-
Dec 28th, 2001, 12:25 PM
#6
Thread Starter
Frenzied Member
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 )
-
Dec 28th, 2001, 03:46 PM
#7
It has to be unicode text. My protoype is wrong.
Sorry.
-
Dec 28th, 2001, 03:48 PM
#8
Monday Morning Lunatic
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
-
Dec 29th, 2001, 02:36 PM
#9
Thread Starter
Frenzied Member
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
-
Dec 29th, 2001, 03:27 PM
#10
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.
-
Dec 29th, 2001, 11:37 PM
#11
Thread Starter
Frenzied Member
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
-
Jan 6th, 2002, 08:26 AM
#12
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.
-
Jan 6th, 2002, 08:32 AM
#13
Monday Morning Lunatic
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
-
Jan 6th, 2002, 09:24 AM
#14
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.
-
Jan 6th, 2002, 09:45 AM
#15
Monday Morning Lunatic
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|