 |
|
 |
Hello,
New to OLE COM development, i've noticed that your shell extension menu appears only when right clicking on a folder.
I don't find in your source code the line(s) that make sure we have right-clicked on a folder.
Thanks for your help.
Olivier
|
|
|
|
 |
|
 |
I finally decided to do it myself, replace the
void CDirCleanShlExt::AddDirsToFileOp ( CShellFileOp* pOp, CString sDir )
{ ... }
with this code and build:
void CDirCleanShlExt::AddDirsToFileOp ( CShellFileOp* pOp, CString sDir )
{
CString sNextPattern;
CString sNextSearchSpec;
CString sFileExt;
CString sFullFileName;
CFileFind find;
BOOL bWorking;
POSITION pos;
ASSERT ( sDir.Right(1) == _T("\\") );
// Search the current dir for files matching each pattern.
for ( pos = m_lsPatternsToDelete.GetHeadPosition(); NULL != pos; )
{
sNextPattern = m_lsPatternsToDelete.GetNext ( pos );
sNextSearchSpec = sDir + sNextPattern;
sFileExt = PathFindExtension(sNextPattern);
size_t extLength = sFileExt.GetLength();
if ( find.FindFile ( sNextSearchSpec ))
{
do
{
bWorking = find.FindNextFile();
sFullFileName = find.GetFilePath();
if(0 == sFileExt.CompareNoCase(PathFindExtension(sFullFileName)))
{
m_bFoundFilesToDelete = TRUE;
pOp->AddSourceFile ( sFullFileName);
}
} while ( bWorking );
find.Close();
}
}
// Now recurse into subdirectories and continue searching.
if ( find.FindFile ( sDir + _T("*.*") ))
{
do
{
bWorking = find.FindNextFile();
if ( !find.IsDirectory() || find.IsDots() )
continue;
AddDirsToFileOp ( pOp, find.GetFilePath() + '\\' );
} while ( bWorking );
}
}
You also need to #include <shlwapi.h> and link to "shlwspi.lib" because a shell api PathFindExtension() is used.
The rationale is simple, for any matches with the original criteria, I check that the extension must be an exact match.
By doing this way, wildcard characters in the extension is not supported any more. But I feel it's better than deleting *.resx file accidentally.
|
|
|
|
 |
|
 |
Hi Michael,
DirClean whacked *.resx files. I suspect that the utility is determining a *.res == *.resx, which is not the case. I also verified that *.resx was not included in the deleted file list.
Jeff
|
|
|
|
 |
|
 |
It seems I can't make it work on 64 bit versions of Windows. Right now, I'm using the 64 bit version of windows and i also have 64 bit Windows Vista on which I haven't tried it.
|
|
|
|
 |
|
 |
Just love this utility but like everything in my life at the moment it suffers some problems re-compiling. Fixes below...
File: DirClean.def
EXPORTS
DllCanUnloadNow @1 PRIVATE
DllGetClassObject @2 PRIVATE
DllRegisterServer @3 PRIVATE
DllUnregisterServer @4 PRIVATE
Change to.....
EXPORTS
DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
(Remove the ordinal number)
File: DirCleanShlExt.h
Add
struct __declspec(uuid("000214e4-0000-0000-c000-000000000046")) IContextMenu;
Before the class declaration.
File: CShellFileOp.cpp
BOOL CShellFileOp::Go ( BOOL* lpbOperationStarted,
int* lpnAPIReturn /*=NULL*/,
BOOL* lpbAnyOperationsAborted /*=NULL*/ )
{
......
FillSzzBuffer ( szzSourceFiles, m_lcstrSourceFiles );
if ( m_rFOS.wFunc != FO_DELETE )
{
FillSzzBuffer ( szzDestFiles, m_lcstrDestFiles );
}
......
}
Change to.....
BOOL CShellFileOp::Go ( BOOL* lpbOperationStarted,
int* lpnAPIReturn /*=NULL*/,
BOOL* lpbAnyOperationsAborted /*=NULL*/ )
{
......
FillSzzBuffer ( szzSourceFiles, dwSourceBufferSize, m_lcstrSourceFiles );
if ( m_rFOS.wFunc != FO_DELETE )
{
FillSzzBuffer ( szzDestFiles, dwDestBufferSize, m_lcstrDestFiles );
}
......
}
void CShellFileOp::FillSzzBuffer ( TCHAR* pBuffer, const CStringList& list )
{
......
_tcscpy ( pCurrPos, (LPCTSTR) cstr );
......
}
Change to.....
void CShellFileOp::FillSzzBuffer( TCHAR* pBuffer, size_t stDstSize, const CStringList& list )
{
......
strcpy_s( pCurrPos, (stDstSize - 1), (LPCTSTR)cstr );
......
}
Also change the function declaration in CShellFileOp.h
File: DirClean.cpp
STDAPI DllRegisterServer(void)
{
......
lRet = reg.SetValue ( _T("DirClean Shell Extension"),
_T("{BA06A5A0-BDE3-11D3-BE82-0050DA63C294}") );
......
}
Change to.....
STDAPI DllRegisterServer(void)
{
......
lRet = reg.SetStringValue ( _T("DirClean Shell Extension"),
_T("{BA06A5A0-BDE3-11D3-BE82-0050DA63C294}") );
......
}
Seems to be working a treat!
Regards,
Kevin.
|
|
|
|
 |
|
 |
Hi Michael,
I thoroughly enjoy this utility. It prepares my files before zipping for CodeProject articles.
A small suggestion. When (if) revised, add "*.suo" to the list of cleaned files.
Jeff
|
|
|
|
 |
|
 |
Thanks Jeffrey I should probably remove *.res while I'm at it.
|
|
|
|
 |
|
 |
Hi Mike,
The registry fix:
"or go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem, and set the DWORD value Win95TruncatedExtensions to 0, then restart your computer"
doesn't work on my system (WinXP pro).
Any hint?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
 |
|
 |
Just remove .res from the extension list, that's easier than mucking with this whacky truncated extensions "feature".
|
|
|
|
 |
|
 |
First of all, great tool!
On the other hand, I think you should give more emphasis to the .RESX issue.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
 |
|
|
 |
|
 |
i don't know how to do this.
Murtaza Tahir ALi Dhari
|
|
|
|
 |
|
 |
Run regsvr32 and pass the full path to the DLL on the command line.
Example: regsvr32 C:\test\dirclean.dll
If system32 isn't in your path, you can use
%systemroot%\system32\regsvr32
|
|
|
|
 |
|
 |
If you ever upgrade this software, add the ability to add projects in a listbox so that users will clean files based on the last selected project type. For example, you can create projects for Visual C++, Borland C++, JBuilder, and each one will have its own list of files to delete. Great job.
"For that one fraction of a second, you were open to options you would never have considered. That is the exploration that awaits you. Not mapping stars and studying nebula, but charting the unknown possibilities of existence." - Q (Star Trek: The Next Generation) Web - Blog
|
|
|
|
 |
|
 |
Hi Bassam, could you explain a bit more what you're thinking? The idea I get from your description is like a list of "presets", where you can go to the config dialog and change the whole list of extensions to match one of your presets. Is that what you had in mind?
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
 |
|
 |
Excatly. It just occured to me, that you can list those presets as submenus in the context-menu so that not just the last one is available. If you want, you could make it sort by most frequently used.
"For that one fraction of a second, you were open to options you would never have considered. That is the exploration that awaits you. Not mapping stars and studying nebula, but charting the unknown possibilities of existence." - Q (Star Trek: The Next Generation) Web - Blog
|
|
|
|
 |
|
 |
Sounds good to me.
I plan on going through my articles and fixing them up for VC7 (since a lot of ATL3.1 code doesn't compile in VC7 *sigh*) so I'll keep that feature in mind when I update this article.
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
 |
|
 |
Cool. I'll keep my eye out for it then. Getting a larger hard-drive at work is not possible right now and I'm running out of space due to software builds (both work and CP-related).
"For that one fraction of a second, you were open to options you would never have considered. That is the exploration that awaits you. Not mapping stars and studying nebula, but charting the unknown possibilities of existence." - Q (Star Trek: The Next Generation) Web - Blog
|
|
|
|
 |
|
 |
One last thing, I personally don't like the "Clean up temp files" menu with the "DirClean Options" under it. It would be nice to have only one menu (like WinZip) called DirClean and add all the menus under it.
DirClean
|
- Clean (Reorder based on last or frequently used)
|
- Visual C++
- Borland C++
- Borland JBuilder
|
- Options
"For that one fraction of a second, you were open to options you would never have considered. That is the exploration that awaits you. Not mapping stars and studying nebula, but charting the unknown possibilities of existence." - Q (Star Trek: The Next Generation) Web - Blog
|
|
|
|
 |
|
 |
MSDN Q164351: .... This behavior only affects file management commands such as dir, del, move, and copy that are executed at a command prompt. File management operations performed by Find, File Manager, or Windows NT Explorer do not perform in this manner.
So I suggest to find all file yourself by FindFile and delete those;)
Thanks to your NICE and USEFUL article.
My vote is 5
|
|
|
|
 |
|
 |
I've tried to copy recursively files from a floppy,CD-Rom or IOMEGA ZIP with shFileOperation. Although it works with a subdirectory, the function fails if I declare the pFrom flag with the name of the drive (ex : "A:\\").
Does anybody know the origin of this problem?
|
|
|
|
 |
|
|
 |
|
 |
Good morning,
How do you compile this with MS Visual C++ 5.0?
This would be a great GUI for deleting temp files for my FEA program.
Cheers,
Harry
Basic Standard ANSI C user
|
|
|
|
 |
|
 |
It would help if you listed what compiler errors you're getting.
--Mike--
"So where does that leave us? Well, it leaves us right back where we started, only more confused than before." -- Matt Gullett
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
 |
|
 |
I get this error.
Cannot open include file: 'DirClean.h':
File was not in the Zip File
Regards,
Harry
|
|
|
|
 |