using CInternetSession to get length of a file

I use CInternetSession to get length of a file ,the code is like this:
CInternetSession sess(_T("httpdownfile"));
CHttpFile* phttpfile=NULL;
DWORD dwFlag = INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD ;
DWORD dwFileLength;
phttpfile=(CHttpFile*)sess.OpenURL(fileOnURL, 1, dwFlag);
try
{
if (phttpfile!=NULL)
{
if (phttpfile->SendRequest())
{
phttpfile->QueryInfo(HTTP_QUERY_CONTENT_LENGTH,dwFileLength);
//here the dwFileLength is not right ,
}
}
}
catch (CInternetException* pEx){//other code }

the code is not work to open some URL,why?Is it different between web site?
or I use this function wrong?

I am waiting on line.
thanks for your attention.
Topic archived. No new replies allowed.