|
First:
Thanks for that gread add-on. It really makes the explorer more useable.
I suggest changing the text alignment to right-aligned - this improves legibility.
|
|
|
|
|
Very cool add-on, something MS should've added to Explorer a long time ago...
I'll admit I haven't looked at the source yet, nor do I know anything about what's involved in creating such an extension, but...
Since Explorer already has a "Size" column, is it possible at all to use it to display the folder size, instead of having a separate column for this? Right now we end up with this:
<br />
Name Size FolderSize [Type] [OtherColumns]<br />
[foldername] [empty] [size] File Folder<br />
[foldername] [empty] [size] File Folder<br />
[foldername] [empty] [size] File Folder<br />
[filename] [size] [empty] File Type<br />
[filename] [size] [empty] File Type<br />
[filename] [size] [empty] File Type<br />
(damn the formatting...i dunno how to do this) :-p View it using a fixed-size font
|
|
|
|
|
I save a column by reporting files size and folders size in the same one when i got this codes. but for the sake of speed, some rules should be made.
One is 'the limits of Max recusive number of files and/or folders'. If a folder has too many files or subfolders, the answer can just be "too many..." or other flag like ">Max". this limit can be calculated according to CPU's type.
anyway, it's a good stuff, i give my thanks to the coder!
|
|
|
|
|
i make many changes:
-1)add a GetFileSize() function;
-2)give a number gap of 1000, like 3,234,122;
-3)use 2 kinds of unit to make difference, K" for folders, KB for files;
-4)use "files + folders <200" as recusive limit, and add '~' just for large scale folders, it gets much faster;
-5)text fmt is now set to "right" side;
....so "size" column now looks like:
```````````````````~21,813 K"| folder
`````````````````````1,332 KB| file
I put the whole file of "colhandler.cpp", header file is easy to edit.
==========================================================
<small>
#include "stdafx.h"<br />
#include "DirSize.h"<br />
#include "ColHandler.h"<br />
<br />
<br />
STDMETHODIMP CColHandler::Initialize(LPCSHCOLUMNINIT psci)<br />
{<br />
return S_OK;<br />
}<br />
<br />
STDMETHODIMP CColHandler::GetColumnInfo(DWORD dwIndex, SHCOLUMNINFO *psci)<br />
{<br />
TCHAR szText[] = "size";<br />
<br />
psci->scid.fmtid.Data1 = 0x28636AA6L;<br />
psci->scid.fmtid.Data2 = 0x953D;<br />
psci->scid.fmtid.Data3 = 0x11D2;<br />
strcpy((char *)psci->scid.fmtid.Data4,"B5D600C04FD918D0");<br />
<br />
psci->scid.pid = 12;<br />
psci->vt = VT_BSTR;<br />
psci->fmt = LVCFMT_RIGHT; psci->cChars = 35;<br />
psci->csFlags = SHCOLSTATE_TYPE_STR|SHCOLSTATE_SLOW;<br />
<br />
<br />
MultiByteToWideChar( CP_ACP, 0, szText,<br />
strlen(szText)+1, psci->wszTitle, <br />
sizeof(psci->wszTitle)/sizeof(psci->wszTitle[0]) );<br />
<br />
MultiByteToWideChar( CP_ACP, 0, szText,<br />
strlen(szText)+1, psci->wszDescription, <br />
sizeof(psci->wszDescription)/sizeof(psci->wszDescription[0]) );<br />
<br />
if(dwIndex == 0)<br />
{<br />
return S_OK;<br />
}<br />
else<br />
{<br />
return S_FALSE;<br />
}<br />
}<br />
<br />
STDMETHODIMP CColHandler::GetItemData(LPCSHCOLUMNID pscid, LPCSHCOLUMNDATA pscd, VARIANT *pvarData)<br />
{<br />
USES_CONVERSION;<br />
V_VT(pvarData) = VT_BSTR;<br />
DWORD dwSize = 0;<br />
char szTmp[200],sz_[200];<br />
DWORD dwFiles = 0, dwFolders = 0;<br />
BOOL bLimit=false;<br />
<br />
DWORD64 size = 0;<br />
if( pscd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )<br />
dwSize = GetFolderSize(OLE2T(pscd->wszFile),&dwFiles,&dwFolders,&bLimit);<br />
else<br />
{<br />
dwSize = GetFileSize(OLE2T(pscd->wszFile),&dwFiles,&dwFolders);<br />
}<br />
<br />
{<br />
size = dwSize/1024;<br />
if(dwSize%1024)<br />
size++;<br />
_i64toa(size,szTmp,10);<br />
<br />
int len=strlen(szTmp);<br />
int index=0;<br />
memset(sz_,0,200);<br />
if(bLimit)<br />
{<br />
strcat(sz_,"~"); index+=1;<br />
}<br />
<br />
int iTmp=len%3;<br />
if(iTmp!=0)<br />
{<br />
memcpy(sz_+index,szTmp,iTmp);<br />
index+=iTmp;<br />
len-=iTmp;<br />
<br />
if(len>0)<br />
{<br />
strcat(sz_,",");<br />
++index;<br />
}<br />
}<br />
<br />
while(len>0)<br />
{<br />
memcpy(sz_+index,szTmp+iTmp,3);<br />
index+=3;iTmp+=3;len-=3;<br />
if(len>0)<br />
{<br />
strcat(sz_,",");<br />
++index;<br />
}<br />
}<br />
if( pscd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )<br />
strcat(sz_," K\"");<br />
else strcat(sz_," KB");<br />
}<br />
<br />
V_BSTR(pvarData) = SysAllocString(T2OLE(sz_));<br />
<br />
return S_OK;<br />
}<br />
<br />
<br />
DWORD CColHandler::GetFolderSize(LPCTSTR szPath, DWORD *dwFiles, DWORD *dwFolders,BOOL *bLimit)<br />
{<br />
TCHAR szFileFilter[512];<br />
TCHAR szFilePath[512];<br />
HANDLE hFind = NULL;<br />
WIN32_FIND_DATA fileinfo;<br />
DWORD dwSize = 0;<br />
<br />
strcpy(szFilePath,szPath);<br />
strcat(szFilePath,"\\");<br />
strcpy(szFileFilter,szFilePath);<br />
strcat(szFileFilter,"*.*");<br />
<br />
<br />
hFind = FindFirstFile(szFileFilter,&fileinfo);<br />
do<br />
{<br />
if(fileinfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )<br />
{<br />
if (!strcmp(fileinfo.cFileName,".") || !strcmp(fileinfo.cFileName,".."))<br />
{<br />
}<br />
else<br />
{<br />
TCHAR sztmp[512];<br />
strcpy(sztmp,szFilePath);<br />
strcat(sztmp,fileinfo.cFileName);<br />
dwSize = dwSize + GetFolderSize(sztmp,dwFiles,dwFolders,bLimit);<br />
if(dwFolders != NULL)<br />
++(*dwFolders);<br />
}<br />
}<br />
else<br />
{<br />
if(dwFiles != NULL)<br />
++(*dwFiles);<br />
}<br />
<br />
dwSize += fileinfo.nFileSizeLow;<br />
if(dwFolders && dwFiles && bLimit)<br />
{<br />
if(*dwFolders+*dwFiles>200)<br />
*bLimit=true;<br />
}<br />
}while(FindNextFile(hFind,&fileinfo)&& ((bLimit!=NULL && !(*bLimit))||!bLimit) );<br />
<br />
FindClose(hFind);<br />
return dwSize;<br />
<br />
}<br />
<br />
DWORD CColHandler::GetFileSize(LPCTSTR szPath, DWORD *dwFiles, DWORD *dwFolders)<br />
{<br />
WIN32_FIND_DATA fileinfo;<br />
HANDLE hFind = FindFirstFile(szPath,&fileinfo);<br />
FindClose(hFind);<br />
return fileinfo.nFileSizeHigh * (MAXDWORD+1) + fileinfo.nFileSizeLow;<br />
}</small>
=====================================================
|
|
|
|
|
Great addition to this.
Did you guys notice that the sorting doesn't work properly now though? it sorts it as if it is a character field, not a numeric field...
Any suggestions on how to fix?
-Matt
|
|
|
|
|
Hello,
i registered the DirSize.dll, but I didn't found any new column named "Folder Size" or something to add to. I have got a german Version of Windows.. may be, thats the "failure"...?
Greetings
Sven
|
|
|
|
|
Sorry, to much details in the list.. I found it between 240 others...
|
|
|
|
|
i register dll. cmd gave me full registered msg but No extra Column after registering dll even checking with sort. can you help?
Abdullah GD (Mr.Green)
Focus Media Vision
|
|
|
|
|
Newbie in over his head, don't know anything about programming and shouldn't have installed the DirSize.dll but i did. Now Windows Explorer runs slowwwwwwww and i would like to remove said item but i'm sure its not as simple as deleting the file from my hard drive.
thank you
|
|
|
|
|
Go to Start/Run and type:
regsvr32 /u DirSize.DLL
If you put the .dll file in a folder somewhere then insert the folder name BEFORE the dirsize.dll.
Example: regsvr32 /u c:\dllfiles\DirSize.DLL
Pooja
|
|
|
|
|
|
Did u search in registry and deleted it?
|
|
|
|
|
How about adding the this folder size information, to
the Search (For Files or Folder) function of explorer?
IT would be much more useful, as you could spam multiple hard drives
|
|
|
|
|
Hello,
The dll does not work in Windows 98 although I
could register the dll successfully.
I am using VC++ 6.0 + SP5 but I can not rebuild
the DLL (more then 200 errors).
Cn anyone help me?
|
|
|
|
|
Dear John,
You need to have Windows 2000 and above to use this component. Win98 does not support column providers.
Cheers!
-Sharan
|
|
|
|
|
Dear Sharan
This is off topic, but I have a problem you may be able to advise me on. I have lost all the columns in Win98 explorer details view, and cannot find how to recover them.
Is it possible you can give me a clue on how to fix this.
Thanks
- Roger -
|
|
|
|
|
Hi i tried to install the dll with regsvr32 and it failed.
This error code was returned: 0x8007007e
Why doesnt it work? Im using WinXP Pro SWE. It that the problem?
That im using a swedish version of WinXP.
Any help would be appraciated.
|
|
|
|
|
Hi Basappa,
I have downloaded the zip file Dirsize.zip but I could not find any application file in that.
Pl. let me know how to install it in my PC?
I am not a guy from programming side. In my computer, there is no application like c, C++, VC, VC++, VB, etc...
Thanks and Regds...
Rajparikh.
|
|
|
|
|
To install it, unzip the DirSize.zip and at the command prompt type
"regsvr32 yourdrive:\path of the dll\dirsize.dll".
Eg. if you unzip the file in C:\Windows then type "regsvr32 c:\windows\dirsize.dll" to register it.
Then in the explorer, change the view to "Details", right click on the column's title bar, then select "Folder size" from the dropdown.
|
|
|
|
|
been looking for this a long time. great extension to explorer!!!
Thanx!
|
|
|
|
|
I was looking for this for a long time too, but from time to time it makes wrong calculations. I hope a new update come up soon.
|
|
|
|
|
How can we sort folders according to their size ?
Now clicking the column header sorts according to string.
Orcun Colak
|
|
|
|
|
Replace the GetItemData with this one:
STDMETHODIMP CColHandler::GetItemData(LPCSHCOLUMNID pscid, LPCSHCOLUMNDATA pscd, VARIANT *pvarData)
{
USES_CONVERSION;
V_VT(pvarData) = VT_BSTR; //VT_UI8;
DWORD64 dwSize = 0;
TCHAR szTmp[50];
DWORD dwFiles = 0, dwFolders = 0;
DWORD64 size = 0;
if(pscd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
dwSize = GetFolderSize(OLE2T(pscd->wszFile),&dwFiles,&dwFolders);
// size = dwSize/(1024*1024);
// if(size == 0)
// {
size = dwSize/1024;
if(size == 0)
{
_i64toa(dwSize,szTmp,10);
strcat(szTmp," Bytes");
}
else
{
_i64toa(size,szTmp,10);
strcat(szTmp," KB");
}
// }
// else
// {
// _i64toa(size,szTmp,10);
// strcat(szTmp," MB");
// }
V_BSTR(pvarData) = SysAllocString(T2OLE(szTmp));
}
else
{
V_BSTR(pvarData) = SysAllocString(T2OLE(""));
}
return S_OK;
}
Now the size is shown only in 'Bytes' or 'Kilo Bytes (KB)'.
If the size is to be sorted according to numbers then the units 'Bytes' or 'KB' cannot be displayed. Even the Microsoft displays only in KB and not in MB or GB. Only in property page shows in KB,MB or GB.
Cheers!
-Sharan
|
|
|
|
|
excuse me:
` The way u give may not work correctly. i found that, when using addin dll, explorer sorts files just according to the str_cmp function, but not the size value. so the 1st character has big weight on arranging items. then, 1 K may be the 1st one in the column, but not 9 K or 9,xxx,xxx KB.
~ but ms explorer does work in the order of size value. i need the reason.
regards!
|
|
|
|
|
I would appreciate if you could incorporate this change into the dll version rather than just giving source. I don't know how to build the dll from source
|
|
|
|
|