Click here to Skip to main content
15,911,141 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to change the Scrollbar's color and picture of CTreeCtrl control in VC++6.0? Pin
xqhrs23214-May-08 17:20
xqhrs23214-May-08 17:20 
QuestionThread Name Pin
ForNow8-May-08 15:47
ForNow8-May-08 15:47 
AnswerRe: Thread Name Pin
Rajkumar R8-May-08 20:18
Rajkumar R8-May-08 20:18 
GeneralRe: Thread Name Pin
ForNow8-May-08 20:46
ForNow8-May-08 20:46 
GeneralRe: Thread Name Pin
Rajkumar R8-May-08 22:07
Rajkumar R8-May-08 22:07 
GeneralRe: Thread Name Pin
ForNow9-May-08 0:52
ForNow9-May-08 0:52 
QuestionFtpCommand Function? Pin
monsieur_jj8-May-08 15:45
monsieur_jj8-May-08 15:45 
AnswerRe: FtpCommand Function? Pin
Randor 8-May-08 16:37
professional Randor 8-May-08 16:37 
Hello again monsieur_jj,

You can use the code I posted yesterday[^] to pause/resume your download. You can easily implement it yourself. First you need to acquire some knowledge about HTTP. The ability to pause/resume a file download is actually taking an advantage of a function of the HTTP 1.1 RFC[^] over at the world wide web consortium[^].

If you take a look at section 14[^] and scroll down to 14.16 Content-Range you will see the description of how to obtain a range of bytes from the requested file. For example:

1.) When the HTTP download begins you should store the content length.
DWORD dwFileSize;
pSession->QueryInfo(HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER,dwFileSize);


2.) Open the URL with the sample code I provided in my last post and begin writing the bytes.

3.) If the user pauses the download close the CInternetSession in the middle of writing to the file. Save the number of bytes written to a variable for later use.

4.) User resumes the download and you compare content-length with amount you previously wrote to disk. Re-open the file on disk and reopen the CInternetSession and URL.

But this time we add the Range header! For example:
"Range: bytes=1024-2048"
//This HTTP header will request bytes 1024 to 2048

"Range: bytes=1024-"
//This header will request all bytes starting at 1024 byte offset until the end of the file.

"Range: bytes=-1024"
//This one will request only the last 1024 bytes of the file.

Any library which allows to add HTTP headers can be made to pause/resume HTTP downloads by simply adding the correct headers. Hope this helps!

Best Wishes,
-David Delaune
GeneralRe: FtpCommand Function? Pin
ShilpiP8-May-08 19:30
ShilpiP8-May-08 19:30 
GeneralRe: FtpCommand Function? Pin
Randor 9-May-08 3:56
professional Randor 9-May-08 3:56 
GeneralRe: FtpCommand Function? Pin
ShilpiP11-May-08 19:24
ShilpiP11-May-08 19:24 
GeneralRe: FtpCommand Function? Pin
monsieur_jj8-May-08 21:58
monsieur_jj8-May-08 21:58 
GeneralRe: FtpCommand Function? Pin
monsieur_jj8-May-08 22:10
monsieur_jj8-May-08 22:10 
GeneralRe: FtpCommand Function? Pin
Randor 9-May-08 3:37
professional Randor 9-May-08 3:37 
GeneralRe: FtpCommand Function? Pin
monsieur_jj11-May-08 19:22
monsieur_jj11-May-08 19:22 
Questionwhy i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. Pin
xqhrs2328-May-08 15:42
xqhrs2328-May-08 15:42 
AnswerRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. Pin
David Crow8-May-08 16:21
David Crow8-May-08 16:21 
QuestionRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. Pin
Rajesh R Subramanian8-May-08 19:19
professionalRajesh R Subramanian8-May-08 19:19 
AnswerRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. Pin
Nitheesh George8-May-08 19:53
Nitheesh George8-May-08 19:53 
AnswerRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. Pin
Hamid_RT8-May-08 19:56
Hamid_RT8-May-08 19:56 
AnswerRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. Pin
Dan8-May-08 20:19
Dan8-May-08 20:19 
GeneralRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. Pin
xqhrs2328-May-08 21:12
xqhrs2328-May-08 21:12 
GeneralRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. Pin
Mark Salsbery9-May-08 6:51
Mark Salsbery9-May-08 6:51 
GeneralRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. Pin
xqhrs23210-May-08 16:12
xqhrs23210-May-08 16:12 
GeneralRe: why i cannot close a dialog? the close operation by a button which sendmessage the WM_CLOSE message. [modified] Pin
Mark Salsbery10-May-08 17:07
Mark Salsbery10-May-08 17:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.