|
Very nice. A small suggestion that might double the ability of the method: The return type may be unsigned __int64 rather than being signed (the default size can be 0)
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
I know, I know. I used the signed __int64 because I convert the return value somewhere to double and VC6 doesn't support the conversion from unsigned __int64 to double ;-(
|
|
|
|
|
This works on VC6:
typedef unsigned __int64 UI64;
UI64 GetSize(CString cs_file)
{
WIN32_FIND_DATA fd;
UI64 iSize = 0;
HANDLE hFind = FindFirstFile((LPCTSTR)cs_file, &fd);
if (hFind != INVALID_HANDLE_VALUE)
iSize = (((UI64)fd.nFileSizeHigh) << 32) + fd.nFileSizeLow;
FindClose(hFind);
return iSize;
}
void CCPDlgDlg::OnButton3()
{
UI64 isize = GetSize(_T("D:\\Rajesh\\Cheers.htm"));
}
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Did you try to cast the return value to double?
|
|
|
|
|
If you hear a loud noise, it is me banging head against the table.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
|
Rajesh R Subramanian wrote: the default size can be 0
Actually, 0 bytes is still a valid length for a file. It would be better to use 0xFFFFFFFFFFFFFFFF as the default value in case the function fails (it's rather unlikely that a file would have that size )
|
|
|
|
|
Michael Schubert wrote: 0xFFFFFFFFFFFFFFFF ... (it's rather unlikely that a file would have that size)
Yes, but only until the next version of acrobat reader is released.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Dang, you might be right. I heard that they will release their next wave of crap products on Blue Ray discs because they don't fit on DVDs any more
|
|
|
|
|
Michael Schubert wrote: I heard that they will release their next wave of crap products on Blue Ray discs because they don't fit on DVDs any more
Yes, but the installer will be incredibly compressed so that it fits in just 2 such discs.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Michael Schubert wrote: Other option:
Use CFile::GetStatus if you are using MFC. Does the same work inside. Gives plenty more information.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
In the MFC version that ships with VC6, the m_size field in the CFileStatus structure is only LONG which limits the file size to 4 GB.
|
|
|
|
|
I already suggested that to the OP (my second reply to the OP). Michael Schubert was providing even more options than that.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Rajesh R Subramanian wrote: I already suggested that to the OP (my second reply to the OP). Michael Schubert was providing even more options than that. Smile
Sorry, repost.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Attending the South Asia summit BTW? I'm planning to be there. We will sit down for a tea.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Rajesh R Subramanian wrote: Attending the South Asia summit BTW? I'm planning to be there. We will sit down for a tea.
Will be in Belgium then sadly! Would love sit down with you for tea though!
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Belgium? Drop an email to Cedric Moonen then.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Rajesh R Subramanian wrote: Drop an email to Cedric Moonen then
Hmm, I will.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
There is solution I got the size of a existing file before,and it's capable to calculate the size of a file of Big-size bigger that 2GB,I hope it will help.
CString filename="c:\\file.avi"; // bigger that 2GB supposed
HANDLE handle=CreateFile(filename,
GENERIC_READ,
FILE_SHARE_READ,
NULL,OPEN_EXISTING,
FILE_ATTIBUTE_NORMAL,
NULL);
__int64 iSize=0;
DWORD dwSizeHigh=0;
iSize=GetFileSize(handle,&dwSizeHigh);
iSize|=(((__int64)dwSizeHigh)<<32);
//here iSize is the size of file named "c:\\file.avi".
CloseHandle(handle);
//convert it to a string buffer for printing
char buff[64]={'\0'};
_i64toa(iSize,buff,10);
//display
pStatic->SetWindowText(buff);
|
|
|
|
|
Hi All
How can convert a dialog base app to a service?Plz help me
|
|
|
|
|
there are plenty of articles about "how to make a service" or "how to convert an application into a service" in here.
have you bothered search codeproject before asking ?
|
|
|
|
|
sorry sir no result found..
|
|
|
|
|
|
Thx's for link but all are showing for consol and i need example for dailog..So plz help me
|
|
|
|
|
Since a service rarely, if ever, has a user interface, the fact that it is a console application is irrelevant.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|