mirror of
https://github.com/reactos/reactos.git
synced 2025-05-01 11:39:58 +00:00
[SHELL32] Read the label for a CD from autorun.inf (#4945)
Some CDs may set a custom label using autorun.inf. Read the label from the file, and if it succeeds, show it to the user. CORE-18567
This commit is contained in:
parent
ba03ffd645
commit
d1718366de
1 changed files with 57 additions and 27 deletions
|
@ -463,6 +463,28 @@ getIconLocationForDrive(IShellFolder *psf, PCITEMID_CHILD pidl, UINT uFlags,
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HRESULT
|
||||||
|
getLabelForDrive(LPWSTR wszPath, LPWSTR wszLabel)
|
||||||
|
{
|
||||||
|
WCHAR wszAutoRunInfPath[MAX_PATH];
|
||||||
|
WCHAR wszTemp[MAX_PATH];
|
||||||
|
|
||||||
|
if (!PathIsDirectoryW(wszPath))
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
StringCchCopyW(wszAutoRunInfPath, _countof(wszAutoRunInfPath), wszPath);
|
||||||
|
PathAppendW(wszAutoRunInfPath, L"autorun.inf");
|
||||||
|
|
||||||
|
if (GetPrivateProfileStringW(L"autorun", L"label", NULL, wszTemp, _countof(wszTemp),
|
||||||
|
wszAutoRunInfPath) && wszTemp[0] != 0)
|
||||||
|
{
|
||||||
|
StringCchCopyW(wszLabel, _countof(wszTemp), wszTemp);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
BOOL IsDriveFloppyA(LPCSTR pszDriveRoot);
|
BOOL IsDriveFloppyA(LPCSTR pszDriveRoot);
|
||||||
|
|
||||||
HRESULT CDrivesExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID riid, LPVOID * ppvOut)
|
HRESULT CDrivesExtractIcon_CreateInstance(IShellFolder * psf, LPCITEMIDLIST pidl, REFIID riid, LPVOID * ppvOut)
|
||||||
|
@ -979,19 +1001,25 @@ HRESULT WINAPI CDrivesFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFla
|
||||||
if (!(dwFlags & SHGDN_FORPARSING))
|
if (!(dwFlags & SHGDN_FORPARSING))
|
||||||
{
|
{
|
||||||
WCHAR wszDrive[18] = {0};
|
WCHAR wszDrive[18] = {0};
|
||||||
DWORD dwVolumeSerialNumber, dwMaximumComponentLength, dwFileSystemFlags;
|
|
||||||
|
|
||||||
lstrcpynW(wszDrive, pszPath, 4);
|
lstrcpynW(wszDrive, pszPath, 4);
|
||||||
pszPath[0] = L'\0';
|
pszPath[0] = L'\0';
|
||||||
|
|
||||||
|
if (!SUCCEEDED(getLabelForDrive(wszDrive, pszPath)))
|
||||||
|
{
|
||||||
|
DWORD dwVolumeSerialNumber, dwMaximumComponentLength, dwFileSystemFlags;
|
||||||
|
|
||||||
GetVolumeInformationW(wszDrive, pszPath,
|
GetVolumeInformationW(wszDrive, pszPath,
|
||||||
MAX_PATH - 7,
|
MAX_PATH - 7,
|
||||||
&dwVolumeSerialNumber,
|
&dwVolumeSerialNumber,
|
||||||
&dwMaximumComponentLength, &dwFileSystemFlags, NULL, 0);
|
&dwMaximumComponentLength, &dwFileSystemFlags, NULL, 0);
|
||||||
pszPath[MAX_PATH-1] = L'\0';
|
pszPath[MAX_PATH-1] = L'\0';
|
||||||
|
|
||||||
if (!wcslen(pszPath))
|
if (!wcslen(pszPath))
|
||||||
{
|
{
|
||||||
UINT DriveType, ResourceId;
|
UINT DriveType, ResourceId;
|
||||||
DriveType = GetDriveTypeW(wszDrive);
|
DriveType = GetDriveTypeW(wszDrive);
|
||||||
|
|
||||||
switch (DriveType)
|
switch (DriveType)
|
||||||
{
|
{
|
||||||
case DRIVE_FIXED:
|
case DRIVE_FIXED:
|
||||||
|
@ -1006,6 +1034,7 @@ HRESULT WINAPI CDrivesFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFla
|
||||||
default:
|
default:
|
||||||
ResourceId = 0;
|
ResourceId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ResourceId)
|
if (ResourceId)
|
||||||
{
|
{
|
||||||
dwFileSystemFlags = LoadStringW(shell32_hInstance, ResourceId, pszPath, MAX_PATH);
|
dwFileSystemFlags = LoadStringW(shell32_hInstance, ResourceId, pszPath, MAX_PATH);
|
||||||
|
@ -1013,6 +1042,7 @@ HRESULT WINAPI CDrivesFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFla
|
||||||
pszPath[MAX_PATH-7] = L'\0';
|
pszPath[MAX_PATH-7] = L'\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
wcscat (pszPath, L" (");
|
wcscat (pszPath, L" (");
|
||||||
wszDrive[2] = L'\0';
|
wszDrive[2] = L'\0';
|
||||||
wcscat (pszPath, wszDrive);
|
wcscat (pszPath, wszDrive);
|
||||||
|
|
Loading…
Reference in a new issue