2007-03-27 17:47:10 +00:00
|
|
|
/*
|
|
|
|
* CiderPress
|
|
|
|
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
|
|
|
|
* See the file LICENSE for distribution terms.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* PIDL utility functions.
|
|
|
|
*/
|
|
|
|
#include "StdAfx.h"
|
|
|
|
#include "Pidl.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ==========================================================================
|
2014-11-04 00:26:53 +00:00
|
|
|
* PIDL functions
|
2007-03-27 17:47:10 +00:00
|
|
|
* ==========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the next item in the PIDL.
|
|
|
|
*
|
|
|
|
* "pidl->mkid.cb" will be zero at the end of the list.
|
|
|
|
*/
|
|
|
|
LPITEMIDLIST
|
|
|
|
Pidl::Next(LPCITEMIDLIST pidl)
|
|
|
|
{
|
|
|
|
LPSTR lpMem = (LPSTR)pidl;
|
|
|
|
|
|
|
|
lpMem += pidl->mkid.cb;
|
|
|
|
|
|
|
|
return (LPITEMIDLIST)lpMem;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compute the size in bytes of a PIDL.
|
|
|
|
*/
|
|
|
|
UINT
|
|
|
|
Pidl::GetSize(LPCITEMIDLIST pidl)
|
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
UINT cbTotal = 0;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
if (pidl) {
|
|
|
|
cbTotal += sizeof(pidl->mkid.cb); // Null terminator
|
|
|
|
while (pidl->mkid.cb) {
|
|
|
|
cbTotal += pidl->mkid.cb;
|
|
|
|
pidl = Next(pidl);
|
|
|
|
}
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return cbTotal;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate a PIDL of the specified size.
|
|
|
|
*/
|
|
|
|
LPITEMIDLIST
|
|
|
|
Pidl::CreatePidl(UINT cbSize)
|
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
LPMALLOC lpMalloc;
|
|
|
|
HRESULT hr;
|
|
|
|
LPITEMIDLIST pidl = NULL;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
hr=SHGetMalloc(&lpMalloc);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
if (FAILED(hr))
|
|
|
|
return 0;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
pidl = (LPITEMIDLIST)lpMalloc->Alloc(cbSize);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
if (pidl)
|
|
|
|
memset(pidl, 0, cbSize); // zero-init for external task alloc
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
if (lpMalloc) lpMalloc->Release();
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return pidl;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Concatenates two PIDLs. The PIDL returned is newly-allocated storage.
|
|
|
|
*
|
|
|
|
* "pidl1" may be NULL.
|
|
|
|
*/
|
|
|
|
LPITEMIDLIST
|
|
|
|
Pidl::ConcatPidls(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
|
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
LPITEMIDLIST pidlNew;
|
|
|
|
UINT cb1;
|
|
|
|
UINT cb2;
|
|
|
|
|
|
|
|
if (pidl1)
|
|
|
|
cb1 = GetSize(pidl1) - sizeof(pidl1->mkid.cb);
|
|
|
|
else
|
|
|
|
cb1 = 0;
|
|
|
|
|
|
|
|
cb2 = GetSize(pidl2);
|
|
|
|
|
|
|
|
pidlNew = CreatePidl(cb1 + cb2);
|
|
|
|
if (pidlNew) {
|
|
|
|
if (pidl1)
|
|
|
|
memcpy(pidlNew, pidl1, cb1);
|
|
|
|
memcpy(((LPSTR)pidlNew) + cb1, pidl2, cb2);
|
|
|
|
}
|
|
|
|
return pidlNew;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make a copy of a PIDL.
|
|
|
|
*
|
|
|
|
* The PIDL returned is newly-allocated storage.
|
|
|
|
*/
|
|
|
|
LPITEMIDLIST
|
|
|
|
Pidl::CopyITEMID(LPMALLOC lpMalloc, LPITEMIDLIST lpi)
|
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
LPITEMIDLIST lpiTemp;
|
|
|
|
|
|
|
|
lpiTemp = (LPITEMIDLIST)lpMalloc->Alloc(lpi->mkid.cb + sizeof(lpi->mkid.cb));
|
|
|
|
CopyMemory((PVOID)lpiTemp, (CONST VOID *)lpi,
|
|
|
|
lpi->mkid.cb + sizeof(lpi->mkid.cb));
|
|
|
|
|
|
|
|
return lpiTemp;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the display name of a file in a ShellFolder.
|
|
|
|
*
|
|
|
|
* "lpsf" is the ShellFolder that contains the file, "lpi" is the PIDL for
|
|
|
|
* the file, "dwFlags" is passed to GetDisplayNameOf and affects which
|
|
|
|
* name is returned, and "lpFriendlyName" is a buffer of at least MAX_PATH
|
|
|
|
* bytes.
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
Pidl::GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, DWORD dwFlags,
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
CString* pFriendlyName)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
BOOL bSuccess=TRUE;
|
|
|
|
STRRET str;
|
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (NOERROR == lpsf->GetDisplayNameOf(lpi, dwFlags, &str)) {
|
2014-11-04 00:26:53 +00:00
|
|
|
switch (str.uType) {
|
|
|
|
case STRRET_WSTR:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
//WideCharToMultiByte(CP_ACP, // CodePage
|
|
|
|
// 0, // dwFlags
|
|
|
|
// str.pOleStr, // lpWideCharStr
|
|
|
|
// -1, // cchWideChar
|
|
|
|
// lpFriendlyName, // lpMultiByteStr
|
|
|
|
// MAX_PATH, // cchMultiByte
|
|
|
|
// NULL, // lpDefaultChar,
|
|
|
|
// NULL); // lpUsedDefaultChar
|
|
|
|
|
|
|
|
////Once the the function returns, the wide string
|
|
|
|
////should be freed. CoTaskMemFree(str.pOleStr) seems
|
|
|
|
////to do the job as well.
|
|
|
|
//LPMALLOC pMalloc;
|
|
|
|
//SHGetMalloc(&pMalloc);
|
|
|
|
//pMalloc->Free (str.pOleStr);
|
|
|
|
//pMalloc->Release();
|
|
|
|
*pFriendlyName = str.pOleStr;
|
|
|
|
CoTaskMemFree(str.pOleStr);
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case STRRET_OFFSET:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
*pFriendlyName = (LPSTR)lpi+str.uOffset;
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case STRRET_CSTR:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
*pFriendlyName = (LPSTR)str.cStr;
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
bSuccess = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
} else {
|
|
|
|
bSuccess = FALSE;
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return bSuccess;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get a fully qualified PIDL for a ShellFolder.
|
|
|
|
*
|
|
|
|
* This is a rather roundabout way of doing things (converting to a full
|
|
|
|
* display name and then converting that to a PIDL). However, there doesn't
|
|
|
|
* seem to be a way to just ask a ShellFolder for its fully qualified PIDL.
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
* TODO: see if there's a better way now.
|
2007-03-27 17:47:10 +00:00
|
|
|
*
|
|
|
|
* Pass in the parent ShellFolder and the item's partial PIDL.
|
|
|
|
*/
|
|
|
|
LPITEMIDLIST
|
|
|
|
Pidl::GetFullyQualPidl(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi)
|
|
|
|
{
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
//char szBuff[MAX_PATH];
|
|
|
|
//OLECHAR szOleChar[MAX_PATH];
|
|
|
|
CString name;
|
|
|
|
WCHAR pathBuf[MAX_PATH];
|
2014-11-04 00:26:53 +00:00
|
|
|
LPSHELLFOLDER lpsfDeskTop;
|
|
|
|
LPITEMIDLIST lpifq;
|
|
|
|
ULONG ulEaten, ulAttribs;
|
|
|
|
HRESULT hr;
|
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (!GetName(lpsf, lpi, SHGDN_FORPARSING, &name))
|
2014-11-04 00:26:53 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
hr = SHGetDesktopFolder(&lpsfDeskTop);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
return NULL;
|
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
//MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szBuff, -1,
|
|
|
|
// (USHORT *)szOleChar, sizeof(szOleChar));
|
|
|
|
wcscpy_s(pathBuf, name);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
hr = lpsfDeskTop->ParseDisplayName(NULL, NULL, pathBuf,
|
2014-11-04 00:26:53 +00:00
|
|
|
&ulEaten, &lpifq, &ulAttribs);
|
|
|
|
|
|
|
|
lpsfDeskTop->Release();
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return lpifq;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert a PIDL to a filesystem path.
|
|
|
|
*
|
|
|
|
* Returns TRUE on success, FALSE on failure.
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
Pidl::GetPath(LPCITEMIDLIST pidl, CString* pPath)
|
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
BOOL result;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
WCHAR buf[MAX_PATH];
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
result = SHGetPathFromIDList(pidl, buf);
|
|
|
|
if (result)
|
|
|
|
*pPath = buf;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return result;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: DoTheMenuThing(HWND hwnd,
|
2014-11-04 00:26:53 +00:00
|
|
|
* LPSHELLFOLDER lpsfParent,
|
|
|
|
* LPITEMIDLIST lpi,
|
|
|
|
* LPPOINT lppt)
|
2007-03-27 17:47:10 +00:00
|
|
|
*
|
|
|
|
* PURPOSE: Displays a popup context menu, given a parent shell folder,
|
2014-11-04 00:26:53 +00:00
|
|
|
* relative item id and screen location.
|
2007-03-27 17:47:10 +00:00
|
|
|
*
|
|
|
|
* PARAMETERS:
|
2014-11-04 00:26:53 +00:00
|
|
|
* hwnd - Parent window handle
|
|
|
|
* lpsfParent - Pointer to parent shell folder.
|
|
|
|
* lpi - Pointer to item id that is relative to lpsfParent
|
|
|
|
* lppt - Screen location of where to popup the menu.
|
2007-03-27 17:47:10 +00:00
|
|
|
*
|
|
|
|
* RETURN VALUE:
|
2014-11-04 00:26:53 +00:00
|
|
|
* Returns TRUE on success, FALSE on failure
|
2007-03-27 17:47:10 +00:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
BOOL
|
|
|
|
Pidl::DoTheMenuThing(HWND hwnd, LPSHELLFOLDER lpsfParent,
|
2014-11-04 00:26:53 +00:00
|
|
|
LPITEMIDLIST lpi, LPPOINT lppt)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
LPCONTEXTMENU lpcm;
|
|
|
|
HRESULT hr;
|
|
|
|
char szTemp[64];
|
|
|
|
CMINVOKECOMMANDINFO cmi;
|
|
|
|
// DWORD dwAttribs=0;
|
|
|
|
int idCmd;
|
|
|
|
HMENU hMenu;
|
|
|
|
BOOL bSuccess=TRUE;
|
|
|
|
|
|
|
|
hr=lpsfParent->GetUIObjectOf(hwnd,
|
|
|
|
1, //Number of objects to get attributes of
|
|
|
|
(const struct _ITEMIDLIST **)&lpi,
|
|
|
|
IID_IContextMenu,
|
|
|
|
0,
|
|
|
|
(LPVOID *)&lpcm);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hMenu = CreatePopupMenu();
|
|
|
|
|
|
|
|
if (hMenu)
|
|
|
|
{
|
|
|
|
hr=lpcm->QueryContextMenu(hMenu, 0, 1, 0x7fff, CMF_EXPLORE);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
idCmd=TrackPopupMenu(hMenu,
|
|
|
|
TPM_LEFTALIGN | TPM_RETURNCMD | TPM_RIGHTBUTTON,
|
|
|
|
lppt->x, lppt->y, 0, hwnd, NULL);
|
|
|
|
|
|
|
|
if (idCmd)
|
|
|
|
{
|
|
|
|
cmi.cbSize = sizeof(CMINVOKECOMMANDINFO);
|
|
|
|
cmi.fMask = 0;
|
|
|
|
cmi.hwnd = hwnd;
|
|
|
|
cmi.lpVerb = MAKEINTRESOURCE(idCmd-1);
|
|
|
|
cmi.lpParameters = NULL;
|
|
|
|
cmi.lpDirectory = NULL;
|
|
|
|
cmi.nShow = SW_SHOWNORMAL;
|
|
|
|
cmi.dwHotKey = 0;
|
|
|
|
cmi.hIcon = NULL;
|
|
|
|
hr=lpcm->InvokeCommand(&cmi);
|
|
|
|
if (!SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
wsprintf(szTemp, "InvokeCommand failed. hr=%lx", hr);
|
|
|
|
AfxMessageBox(szTemp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bSuccess = FALSE;
|
|
|
|
|
|
|
|
DestroyMenu(hMenu);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bSuccess = FALSE;
|
|
|
|
|
|
|
|
lpcm->Release();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wsprintf(szTemp, "GetUIObjectOf failed! hr=%lx", hr);
|
|
|
|
AfxMessageBox(szTemp );
|
|
|
|
bSuccess = FALSE;
|
|
|
|
}
|
|
|
|
return bSuccess;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the index for an icon for a ShellFolder object.
|
|
|
|
*
|
|
|
|
* "lpi" is the fully-qualified PIDL for the object in question. "uFlags"
|
|
|
|
* specifies which of the object's icons to retrieve.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
Pidl::GetItemIcon(LPITEMIDLIST lpi, UINT uFlags)
|
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
SHFILEINFO sfi;
|
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
uFlags |= SHGFI_PIDL; // we're passing a PIDL, not a pathname, in 1st arg
|
|
|
|
SHGetFileInfo((LPCWSTR)lpi, 0, &sfi, sizeof(SHFILEINFO), uFlags);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
return sfi.iIcon;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|