|
Hy everyone.
My purpose is to download a range of bytes (i.e. from the beggining up to a certain point) from a file located by a given URL. I am trying to determine the remote file size, but so far I didn't succeded. I am using WinInet, InternetReadFile function to actually read the file. I can read it, but I would like to determine it's size prior of downloading the whole file. If anyone could show me another way tp do that, more simple than this please do so.
THANKS.
|
|
|
|
|
Try:
HttpQueryInfo(hResource, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER,
&dwContentLength, &dwSize, NULL) where hResource is the one you use when calling InternetReadFile, dwContentLength is a DWORD to return the file-size into and dwSize = sizeof (DWORD).
"though nothing
will keep us together
we can beat them
for ever and ever"
rechi
|
|
|
|
|
Thanx Rechi One extra question ? R U from Romania ?
I tried that, but unfortunately i get:
ERROR_HTTP_HEADER_NOT_FOUND ... At first i had this in mind that is to play with such functions like Internetqueryoption and stuff, but no matter how much I dig up those flags I didn't find anyone related to the whole file size, just related to sections ...
THANKZ anyway :->
|
|
|
|
|
gecool wrote:
ERROR_HTTP_HEADER_NOT_FOUND
It's about the headers, take a look at this (old) fragment:
HINTERNET hResource=::HttpOpenRequest(hConnection, _T("GET"),
szRelativeFile, NULL, NULL, NULL,
INTERNET_FLAG_KEEP_CONNECTION, 0);
if (hResource)
{
LPTSTR szHeaders=_T("Accept: audio/x-aiff, application/octet-stream, "
"application/x-msdownload, audio/basic, "
"audio/midi, audio/mpeg, audio/wav, image/jpeg, image/gif, "
"image/jpg, image/png, image/mng, image/bmp, text/plain, "
"text/html, text/htm\r\n");
CString szAgentHeader;
szAgentHeader.Format(_T("User-Agent: %s/1.0\r\n"),
(LPCTSTR)m_szAppName);
HttpAddRequestHeaders(hResource, szHeaders, _tcslen(szHeaders),
HTTP_ADDREQ_FLAG_ADD_IF_NEW);
HttpAddRequestHeaders(hResource, (LPCTSTR)szAgentHeader,
szAgentHeader.GetLength(), HTTP_ADDREQ_FLAG_ADD_IF_NEW);
if (HttpSendRequest(hResource, NULL, 0, NULL, 0))
{
DWORD dw=0, dwOut=0, i=0, n=0, dwContentLength,
dwSize=sizeof(DWORD);
CString szFileFromPath=CUpgrader::GetFileFromPath(
szRelativeFile), filepath;
if (!::HttpQueryInfo(hResource, HTTP_QUERY_CONTENT_LENGTH |
HTTP_QUERY_FLAG_NUMBER, &dwContentLength, &dwSize, NULL))
dwContentLength=-1;
and check if something is missing in your code. It's from an update system i wrote a year ago, and it works like a dream :->
gecool wrote:
R U from Romania ?
Yeah!
"though nothing
will keep us together
we can beat them
for ever and ever"
rechi
|
|
|
|
|
Mersi mult
Tocmai asta asteptam sa gasesc un piece of code ....
Geo.
|
|
|
|
|
If you think you can help me to use the code that was published by Allan Nielsen in his article "SuperGrid",
please let me know!!!
thanks in advance,
sheli
|
|
|
|
|
That's why there's a space to post questions under the article
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I have to set an icon on a toolbar button - how do I do that????
I am programming in visual 6.0.
If you realy wona help me please detail all the steps.
thank you
|
|
|
|
|
At design time or run time?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Please Help.
How can i use the CListView (Add new Items, Columns, Sort, etc?
Thanks
|
|
|
|
|
First call GetListCtrl() to get a reference to the "underlying" list control. Then you can use that object's InsertColumn() and InsertItem() methods.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks but I don't find de GetListCtrl()
I Have a Dialog that i Have inserted a New ActiveX Control (MSCOMCTL.OCX V6). When starts a Class Wizard, it add some .cpp and .h files automatically and i have the same problem.
Do you have any example.
Thanks again
Xavier
|
|
|
|
|
ivax wrote:
Thanks but I don't find de GetListCtrl()
It is a member of the CListView class.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks, but something fail.
the compiler report an error: GetListCtrl() is not a member of CListView1.
I has find GetListCtrl in CListView.h and CListView1.h and don't find.
Please, can you give me more help?
|
|
|
|
|
Why are you using an ActiveX control rather than one that is already provided by MFC?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi David. This ActiveX is provided by Microsoft in VS 6. Is a Microsoft ListView Control Version 6. The OCX File Name is MSCOMCTL.OCX In VB, it provides more properties and functions and i try to use un VC++.
Many thanks again
Xavier
|
|
|
|
|
ivax wrote:
This ActiveX is provided by Microsoft in VS 6.
So is the other, plus it is easier to use (IMO). The thing about ActiveX controls is that they might not be registered, or even available, on the target machine. Some folks I know do not even allow ActiveX controls to run on their machines (for security reasons).
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
argv[0] only provides how the application has been invoked. How can an application obtain the full path and file name even when the system has found the application using the path environment variable?
|
|
|
|
|
See here.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
<br />
TCHAR lpszPath[MAX_PATH] = {0};<br />
DWORD dwResult = ::GetModuleFileName(AfxGetInstanceHandle(), lpszPath, MAX_PATH);<br />
That should do the trick
|
|
|
|
|
Try looking into GetModuleFileName(...) . Despite the name, it returns a fully qualified path.
Peace!
[EDIT] Hmmm... Guess I should refresh more often...! [/EDIT]
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites
|
|
|
|
|
Hello,
I have a problem with the combo box in the CGridCtrl. I set an options list and I don't get a default selection. Also when I do select an item, the selection goes away when I select an other cell or control...
Do I need to do something special to get a default selection or to get the new selection visible?
Thanks in advance,
Bob
|
|
|
|
|
Hi,
Can you please get me the answers for the following questions
1. VTABLE lies in what part of the memory? Isit in Stack, Heap or Datasegment?
Is VTABLE created at compile time or at runtime?
2. Whats the exact diff. between Abstraction and encapsulation?
3. There is base and derived class, Say there is a virtual fn Draw() in the Base class and its not overrided in the derived class. Now the object for the derived class is created and stored in the base class pointer. Now call the Draw() fn via the base class pointer. The base class Draw() is called as there is no implementation in the derived class.
Internally, two VTABLEs are created one for base and other for derived class. How internally the compiler calls the base class Draw() fn. How does this work wrt the VTABLE?
4. Where class member fn are stored in memory and how the compiler makes a call to these member fns?
5. What are the things the parent and child thread doesn't share?
6. Say, char* pstr = "Helloworld";
Now reverse the string pstr without using any temp variable? When we cout the pstr it should Helloworld should be reversed?
Thanks in advance.
sarathymail
|
|
|
|
|
psmail wrote:
Can you please get me the answers for the following questions
This smells of homework.
psmail wrote:
6. Say, char* pstr = "Helloworld";
Now reverse the string pstr without using any temp variable? When we cout the pstr it should Helloworld should be reversed?
Ue strrev() .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
DavidCrow wrote:
This smells of homework.
Hmmm... you're right, I didn't see that. Anyway, all the implementation of virtual functions stuff is compiler dependent IIRC, so it's only valid for VC++
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|