Around 1997, I decided that I would learn how to use the Windows shell to do whatever I wanted it to do using C++, MFC, and my wits. The product of that effort is two articles that were published in Windows Developer Journal, this book, and a big set of libraries and wizards that make developing Control Panel applets, tray icons, screen savers, Namespace extensions, and other shell extensions very easy. All of the work is based on Visual Studio 6.0. This book is now out of print.
FAQ
My book, Windows Shell Programming, has been out since June 2000. Since then, helpful readers have pointed out a couple of problems with the book. Please check and see if yours is listed here before you submit it to me. Hopefully, everyone has been writing in and letting me know where I goofed.
-
-
-
- I bought your book used. Where can I get the contents of the CD-ROM?
Sorry about this one. First off, here's what is happening. The InstallShield scripts are looking for where the AWX files (Visual C++ Wizard files) are stored. For some reason, about 10% of all machines cannot find this path. When the scripts go to move the files to the right place, they cannot find it and error out. Instead of saying something nice like "Failed to move files", it tells you that you are out of disk space. Most people have more than 2 or 3 megabytes free on their drives, so they see things fail.
Apparently, this doesn't happen with SP5 of Visual C++ installed. SP4 must have done something odd. Still, if things don't work, are you stuck?
NO!!!
Here's what you can do to be happy and productive right away:
- Figure out where the AWX files are stored on your PC and copy the wizard files on the CD to that location.
- Copy the header files from the include directory to somewhere on your PC.
- Copy the lib files from the lib directory to somewhere on your PC.
- In VC++, add the shell include directory you just copied to the list of include paths.
- In VC++, add the shell lib directory you just copied to the list of library paths.
Where do you do steps 4 & 5?
- In VC++, navigate to Tools-->Options.
- Select the Directories Tab.
- Under "Show directories for:" select "Include files" for step4, "Library files" for step 5.
This bug was first reported by Gary Johnson.
Look at the top of the generated STDAFX.H file. There's a few lines indicating that they solve a problem with the January 2000 SDK. Delete those lines and rebuild. You should be just fine. Or, download this update of the wizard.
The namespace extension code generator will create a clone function that would create an unreferenced object if that code were ever called. It isn't, but better safe than sorry. The offending code currently looks like this:
STDMETHODIMP CSomeEnumIDList::Clone( IEnumIDList **ppEnum )
{
CComObject<CSomeEnumIDList> *pList =
new CComObject<CSomeEnumIDList>;
HRESULT hr = QueryInterface(IID_ISomeEnumIDLIST, (void**)ppEnum);
if ( pList == NULL )
{
return S_FALSE;
}
else
{
pList->SetShellFolder( m_pFolder, m_pFolderPidl );
pList->SetType( m_grfFlags );
}
return S_OK;
}
What happens is that the new pList pointer never goes out of scope and never does what we think it should. The code should really look like this:
STDMETHODIMP CSomeEnumIDList::Clone( IEnumIDList **ppEnum )
{
CComObject<CSomeEnumIDList> *pList =
new CComObject<CSomeEnumIDList>;
// Increment the interface pointer and assign it to ppEnum.
// (Now holds 2 references.)
HRESULT hr = pList->QueryInterface(IID_ISomeEnumIDLIST, (void**)
ppEnum);
if ( ppEnum == NULL )
{
return S_FALSE;
}
else
{
// pList and ppEnum reference the same object.
pList->SetShellFolder( m_pFolder, m_pFolderPidl );
pList->SetType( m_grfFlags );
}
return S_OK;
}
I'm still not 100% sure this fixes the problem correctly and I will be addressing it in the near future. As soon as I am confident that I have this fixed, I'll update the wizard to reflect the changes.
First reported by John McAuley
I bought your book used. Where can I get the contents of the CD-ROM?
I finally posted the contents of the CD. Total size is about 3158 KB. You can download it here (even if you didn't buy the book!).