mirror of
https://github.com/reactos/reactos.git
synced 2025-05-01 11:39:58 +00:00
[SHELL32] - Improve method names and simplify _ILCreateCPanelApplet
svn path=/trunk/; revision=54422
This commit is contained in:
parent
f7ea2bd8c6
commit
e56b1c65be
1 changed files with 37 additions and 39 deletions
|
@ -41,9 +41,9 @@ public:
|
||||||
CControlPanelEnum();
|
CControlPanelEnum();
|
||||||
~CControlPanelEnum();
|
~CControlPanelEnum();
|
||||||
HRESULT WINAPI Initialize(DWORD dwFlags);
|
HRESULT WINAPI Initialize(DWORD dwFlags);
|
||||||
BOOL SHELL_RegisterCPanelApp(LPCSTR path);
|
BOOL RegisterCPanelApp(LPCSTR path);
|
||||||
int SHELL_RegisterRegistryCPanelApps(HKEY hkey_root, LPCSTR szRepPath);
|
int RegisterRegistryCPanelApps(HKEY hkey_root, LPCSTR szRepPath);
|
||||||
int SHELL_RegisterCPanelFolders(HKEY hkey_root, LPCSTR szRepPath);
|
int RegisterCPanelFolders(HKEY hkey_root, LPCSTR szRepPath);
|
||||||
BOOL CreateCPanelEnumList(DWORD dwFlags);
|
BOOL CreateCPanelEnumList(DWORD dwFlags);
|
||||||
|
|
||||||
BEGIN_COM_MAP(CControlPanelEnum)
|
BEGIN_COM_MAP(CControlPanelEnum)
|
||||||
|
@ -77,43 +77,41 @@ HRESULT WINAPI CControlPanelEnum::Initialize(DWORD dwFlags)
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LPITEMIDLIST _ILCreateCPanelApplet(LPCSTR name, LPCSTR displayName, LPCSTR comment, int iconIdx)
|
static LPITEMIDLIST _ILCreateCPanelApplet(LPCSTR pszName, LPCSTR pszDisplayName, LPCSTR pszComment, int iIconIdx)
|
||||||
{
|
{
|
||||||
PIDLCPanelStruct *p;
|
PIDLCPanelStruct *pCP;
|
||||||
LPITEMIDLIST pidl;
|
LPITEMIDLIST pidl;
|
||||||
PIDLDATA tmp;
|
LPPIDLDATA pData;
|
||||||
int size0 = (char*)&tmp.u.cpanel.szName - (char*)&tmp.u.cpanel;
|
int cchName, cchDisplayName, cchComment, cbData;
|
||||||
int size = size0;
|
|
||||||
int l;
|
|
||||||
|
|
||||||
tmp.type = PT_CPLAPPLET;
|
/* Calculate lengths of given strings */
|
||||||
tmp.u.cpanel.dummy = 0;
|
cchName = strlen(pszName);
|
||||||
tmp.u.cpanel.iconIdx = iconIdx;
|
cchDisplayName = strlen(pszDisplayName);
|
||||||
|
cchComment = strlen(pszComment);
|
||||||
|
|
||||||
l = strlen(name);
|
/* Allocate PIDL */
|
||||||
size += l + 1;
|
cbData = sizeof(pidl->mkid.cb) + sizeof(pData->type) + sizeof(pData->u.cpanel) - sizeof(pData->u.cpanel.szName)
|
||||||
|
+ cchName + cchDisplayName + cchComment + 3;
|
||||||
tmp.u.cpanel.offsDispName = l+1;
|
pidl = (LPITEMIDLIST)SHAlloc(cbData + sizeof(WORD));
|
||||||
l = strlen(displayName);
|
|
||||||
size += l + 1;
|
|
||||||
|
|
||||||
tmp.u.cpanel.offsComment = tmp.u.cpanel.offsDispName + 1 + l;
|
|
||||||
l = strlen(comment);
|
|
||||||
size += l + 1;
|
|
||||||
|
|
||||||
pidl = (LPITEMIDLIST)SHAlloc(size + 4);
|
|
||||||
if (!pidl)
|
if (!pidl)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
pidl->mkid.cb = size + 2;
|
/* Copy data to allocated memory */
|
||||||
memcpy(pidl->mkid.abID, &tmp, 2 + size0);
|
pidl->mkid.cb = cbData;
|
||||||
|
pData = (PIDLDATA *)pidl->mkid.abID;
|
||||||
|
pData->type = PT_CPLAPPLET;
|
||||||
|
|
||||||
p = &((PIDLDATA *)pidl->mkid.abID)->u.cpanel;
|
pCP = &pData->u.cpanel;
|
||||||
strcpy(p->szName, name);
|
pCP->dummy = 0;
|
||||||
strcpy(p->szName+tmp.u.cpanel.offsDispName, displayName);
|
pCP->iconIdx = iIconIdx;
|
||||||
strcpy(p->szName+tmp.u.cpanel.offsComment, comment);
|
strcpy(pCP->szName, pszName);
|
||||||
|
pCP->offsDispName = cchName + 1;
|
||||||
|
strcpy(pCP->szName + pCP->offsDispName, pszDisplayName);
|
||||||
|
pCP->offsComment = pCP->offsDispName + cchDisplayName + 1;
|
||||||
|
strcpy(pCP->szName + pCP->offsComment, pszComment);
|
||||||
|
|
||||||
*(WORD*)((char*)pidl + (size + 2)) = 0;
|
/* Add PIDL NULL terminator */
|
||||||
|
*(WORD*)(pCP->szName + pCP->offsComment + cchComment + 1) = 0;
|
||||||
|
|
||||||
pcheck(pidl);
|
pcheck(pidl);
|
||||||
|
|
||||||
|
@ -134,7 +132,7 @@ static PIDLCPanelStruct *_ILGetCPanelPointer(LPCITEMIDLIST pidl)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CControlPanelEnum::SHELL_RegisterCPanelApp(LPCSTR path)
|
BOOL CControlPanelEnum::RegisterCPanelApp(LPCSTR path)
|
||||||
{
|
{
|
||||||
LPITEMIDLIST pidl;
|
LPITEMIDLIST pidl;
|
||||||
CPlApplet* applet;
|
CPlApplet* applet;
|
||||||
|
@ -177,7 +175,7 @@ BOOL CControlPanelEnum::SHELL_RegisterCPanelApp(LPCSTR path)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CControlPanelEnum::SHELL_RegisterRegistryCPanelApps(HKEY hkey_root, LPCSTR szRepPath)
|
int CControlPanelEnum::RegisterRegistryCPanelApps(HKEY hkey_root, LPCSTR szRepPath)
|
||||||
{
|
{
|
||||||
char name[MAX_PATH];
|
char name[MAX_PATH];
|
||||||
char value[MAX_PATH];
|
char value[MAX_PATH];
|
||||||
|
@ -197,7 +195,7 @@ int CControlPanelEnum::SHELL_RegisterRegistryCPanelApps(HKEY hkey_root, LPCSTR s
|
||||||
if (RegEnumValueA(hkey, idx, name, &nameLen, NULL, NULL, (LPBYTE)&value, &valueLen) != ERROR_SUCCESS)
|
if (RegEnumValueA(hkey, idx, name, &nameLen, NULL, NULL, (LPBYTE)&value, &valueLen) != ERROR_SUCCESS)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (SHELL_RegisterCPanelApp(value))
|
if (RegisterCPanelApp(value))
|
||||||
++cnt;
|
++cnt;
|
||||||
}
|
}
|
||||||
RegCloseKey(hkey);
|
RegCloseKey(hkey);
|
||||||
|
@ -206,7 +204,7 @@ int CControlPanelEnum::SHELL_RegisterRegistryCPanelApps(HKEY hkey_root, LPCSTR s
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CControlPanelEnum::SHELL_RegisterCPanelFolders(HKEY hkey_root, LPCSTR szRepPath)
|
int CControlPanelEnum::RegisterCPanelFolders(HKEY hkey_root, LPCSTR szRepPath)
|
||||||
{
|
{
|
||||||
char name[MAX_PATH];
|
char name[MAX_PATH];
|
||||||
HKEY hkey;
|
HKEY hkey;
|
||||||
|
@ -249,7 +247,7 @@ BOOL CControlPanelEnum::CreateCPanelEnumList(DWORD dwFlags)
|
||||||
|
|
||||||
/* enumerate control panel folders */
|
/* enumerate control panel folders */
|
||||||
if (dwFlags & SHCONTF_FOLDERS)
|
if (dwFlags & SHCONTF_FOLDERS)
|
||||||
SHELL_RegisterCPanelFolders(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace");
|
RegisterCPanelFolders(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace");
|
||||||
|
|
||||||
/* enumerate the control panel applets */
|
/* enumerate the control panel applets */
|
||||||
if (dwFlags & SHCONTF_NONFOLDERS)
|
if (dwFlags & SHCONTF_NONFOLDERS)
|
||||||
|
@ -273,14 +271,14 @@ BOOL CControlPanelEnum::CreateCPanelEnumList(DWORD dwFlags)
|
||||||
if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
|
if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||||
strcpy(p, wfd.cFileName);
|
strcpy(p, wfd.cFileName);
|
||||||
if (strcmp(wfd.cFileName, "ncpa.cpl"))
|
if (strcmp(wfd.cFileName, "ncpa.cpl"))
|
||||||
SHELL_RegisterCPanelApp(szPath);
|
RegisterCPanelApp(szPath);
|
||||||
}
|
}
|
||||||
} while(FindNextFileA(hFile, &wfd));
|
} while(FindNextFileA(hFile, &wfd));
|
||||||
FindClose(hFile);
|
FindClose(hFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
SHELL_RegisterRegistryCPanelApps(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
|
RegisterRegistryCPanelApps(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
|
||||||
SHELL_RegisterRegistryCPanelApps(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
|
RegisterRegistryCPanelApps(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue