[SHELL32]

- Remove unused/empty files
- Improve directory layout

svn path=/trunk/; revision=54683
This commit is contained in:
Rafal Harabien 2011-12-18 15:47:41 +00:00
parent af11491f7c
commit a5ec468fe0
49 changed files with 113 additions and 2329 deletions

View file

@ -43,16 +43,16 @@ list(APPEND SOURCE
shellpath.cpp
shellreg.cpp
shellstring.cpp
shfldr_desktop.cpp
shfldr_fs.cpp
shfldr_mycomp.cpp
shfldr_mydocuments.cpp
shfldr_printers.cpp
shfldr_admintools.cpp
shfldr_netplaces.cpp
shfldr_fonts.cpp
shfldr_cpanel.cpp
shfldr_recyclebin.cpp
folders/desktop.cpp
folders/fs.cpp
folders/mycomp.cpp
folders/mydocuments.cpp
folders/printers.cpp
folders/admintools.cpp
folders/netplaces.cpp
folders/fonts.cpp
folders/cpanel.cpp
folders/recyclebin.cpp
shlexec.cpp
shlfileop.cpp
shlfolder.cpp
@ -60,16 +60,15 @@ list(APPEND SOURCE
shlmenu.cpp
shlview.cpp
shpolicy.cpp
shv_def_cmenu.cpp
startmenu.cpp
stubs.cpp
ros-systray.cpp
systray.cpp
fprop.cpp
drive.cpp
she_ocmenu.cpp
shv_item_new.cpp
defcontextmenu.cpp
openwithmenu.cpp
newmenu.cpp
startmenu.cpp
folder_options.cpp
regsvr.c
shell32.rc
${CMAKE_CURRENT_BINARY_DIR}/shell32_stubs.c
${CMAKE_CURRENT_BINARY_DIR}/shell32.def)

View file

@ -1,336 +0,0 @@
LONG WINAPI RegCopyTreeX(HKEY, LPCWSTR, HKEY)
{
DebugBreak();
return 0;
}
static int load_string(HINSTANCE hModule, UINT resId, LPWSTR pwszBuffer, INT cMaxChars)
{
HGLOBAL hMemory;
HRSRC hResource;
WCHAR *pString;
int idxString;
/* Negative values have to be inverted. */
if (HIWORD(resId) == 0xffff)
resId = (UINT)(-((INT)resId));
/* Load the resource into memory and get a pointer to it. */
hResource = FindResourceW(hModule, MAKEINTRESOURCEW(LOWORD(resId >> 4) + 1), (LPWSTR)RT_STRING);
if (!hResource) return 0;
hMemory = LoadResource(hModule, hResource);
if (!hMemory) return 0;
pString = (WCHAR *)LockResource(hMemory);
/* Strings are length-prefixed. Lowest nibble of resId is an index. */
idxString = resId & 0xf;
while (idxString--) pString += *pString + 1;
/* If no buffer is given, return length of the string. */
if (!pwszBuffer) return *pString;
/* Else copy over the string, respecting the buffer size. */
cMaxChars = (*pString < cMaxChars) ? *pString : (cMaxChars - 1);
if (cMaxChars >= 0)
{
memcpy(pwszBuffer, pString+1, cMaxChars * sizeof(WCHAR));
pwszBuffer[cMaxChars] = L'\0';
}
return cMaxChars;
}
LONG WINAPI
RegLoadMUIStringWX(IN HKEY hKey,
IN LPCWSTR pszValue OPTIONAL,
OUT LPWSTR pszOutBuf,
IN DWORD cbOutBuf,
OUT LPDWORD pcbData OPTIONAL,
IN DWORD Flags,
IN LPCWSTR pszDirectory OPTIONAL)
{
DWORD dwValueType, cbData;
LPWSTR pwszTempBuffer = NULL, pwszExpandedBuffer = NULL;
LONG result;
/* Parameter sanity checks. */
if (!hKey || !pszOutBuf)
return ERROR_INVALID_PARAMETER;
if (pszDirectory && *pszDirectory)
{
return ERROR_INVALID_PARAMETER;
}
/* Check for value existence and correctness of it's type, allocate a buffer and load it. */
result = RegQueryValueExW(hKey, pszValue, NULL, &dwValueType, NULL, &cbData);
if (result != ERROR_SUCCESS) goto cleanup;
if (!(dwValueType == REG_SZ || dwValueType == REG_EXPAND_SZ) || !cbData)
{
result = ERROR_FILE_NOT_FOUND;
goto cleanup;
}
pwszTempBuffer = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, cbData);
if (!pwszTempBuffer)
{
result = ERROR_NOT_ENOUGH_MEMORY;
goto cleanup;
}
result = RegQueryValueExW(hKey, pszValue, NULL, &dwValueType, (LPBYTE)pwszTempBuffer, &cbData);
if (result != ERROR_SUCCESS) goto cleanup;
/* Expand environment variables, if appropriate, or copy the original string over. */
if (dwValueType == REG_EXPAND_SZ)
{
cbData = ExpandEnvironmentStringsW(pwszTempBuffer, NULL, 0) * sizeof(WCHAR);
if (!cbData) goto cleanup;
pwszExpandedBuffer = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, cbData);
if (!pwszExpandedBuffer)
{
result = ERROR_NOT_ENOUGH_MEMORY;
goto cleanup;
}
ExpandEnvironmentStringsW(pwszTempBuffer, pwszExpandedBuffer, cbData);
}
else
{
pwszExpandedBuffer = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, cbData);
memcpy(pwszExpandedBuffer, pwszTempBuffer, cbData);
}
/* If the value references a resource based string, parse the value and load the string.
* Else just copy over the original value. */
result = ERROR_SUCCESS;
if (*pwszExpandedBuffer != L'@') /* '@' is the prefix for resource based string entries. */
{
lstrcpynW(pszOutBuf, pwszExpandedBuffer, cbOutBuf / sizeof(WCHAR));
}
else
{
WCHAR *pComma = wcsrchr(pwszExpandedBuffer, L',');
UINT uiStringId;
HMODULE hModule;
/* Format of the expanded value is 'path_to_dll,-resId' */
if (!pComma || pComma[1] != L'-')
{
result = ERROR_BADKEY;
goto cleanup;
}
uiStringId = _wtoi(pComma+2);
*pComma = L'\0';
hModule = LoadLibraryExW(pwszExpandedBuffer + 1, NULL, LOAD_LIBRARY_AS_DATAFILE);
if (!hModule || !load_string(hModule, uiStringId, pszOutBuf, cbOutBuf / sizeof(WCHAR)))
result = ERROR_BADKEY;
FreeLibrary(hModule);
}
cleanup:
HeapFree(GetProcessHeap(), 0, pwszTempBuffer);
HeapFree(GetProcessHeap(), 0, pwszExpandedBuffer);
return result;
}
#if 0
VOID WINAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString);
#else
typedef VOID (WINAPI *PRtlFreeUnicodeString)(PUNICODE_STRING UnicodeString);
static VOID WINAPI
RtlFreeUnicodeStringx(PUNICODE_STRING UnicodeString)
{
static PRtlFreeUnicodeString Func = NULL;
if (Func == NULL)
{
HMODULE hShlwapi;
hShlwapi = LoadLibrary(TEXT("ntdll.DLL"));
if (hShlwapi != NULL)
{
Func = (PRtlFreeUnicodeString)GetProcAddress(hShlwapi, "RtlFreeUnicodeString");
}
}
if (Func != NULL)
{
Func(UnicodeString);
return;
}
MessageBox(NULL, TEXT("RtlFreeUnicodeString not available"), NULL, 0);
}
#endif
LONG WINAPI
RegLoadMUIStringAX(IN HKEY hKey,
IN LPCSTR pszValue OPTIONAL,
OUT LPSTR pszOutBuf,
IN DWORD cbOutBuf,
OUT LPDWORD pcbData OPTIONAL,
IN DWORD Flags,
IN LPCSTR pszDirectory OPTIONAL)
{
UNICODE_STRING valueW, baseDirW;
WCHAR *pwszBuffer;
DWORD cbData = cbOutBuf * sizeof(WCHAR);
LONG result;
valueW.Buffer = baseDirW.Buffer = pwszBuffer = NULL;
if (!RtlCreateUnicodeStringFromAsciiz(&valueW, pszValue) ||
!RtlCreateUnicodeStringFromAsciiz(&baseDirW, pszDirectory) ||
!(pwszBuffer = (WCHAR *)HeapAlloc(GetProcessHeap(), 0, cbData)))
{
result = ERROR_NOT_ENOUGH_MEMORY;
goto cleanup;
}
result = RegLoadMUIStringWX(hKey, valueW.Buffer, pwszBuffer, cbData, NULL, Flags,
baseDirW.Buffer);
if (result == ERROR_SUCCESS)
{
cbData = WideCharToMultiByte(CP_ACP, 0, pwszBuffer, -1, pszOutBuf, cbOutBuf, NULL, NULL);
if (pcbData)
*pcbData = cbData;
}
cleanup:
HeapFree(GetProcessHeap(), 0, pwszBuffer);
RtlFreeUnicodeStringx(&baseDirW);
RtlFreeUnicodeStringx(&valueW);
return result;
}
static VOID
RegpApplyRestrictions(DWORD dwFlags,
DWORD dwType,
DWORD cbData,
PLONG ret)
{
/* Check if the type is restricted by the passed flags */
if (*ret == ERROR_SUCCESS || *ret == ERROR_MORE_DATA)
{
DWORD dwMask = 0;
switch (dwType)
{
case REG_NONE: dwMask = RRF_RT_REG_NONE; break;
case REG_SZ: dwMask = RRF_RT_REG_SZ; break;
case REG_EXPAND_SZ: dwMask = RRF_RT_REG_EXPAND_SZ; break;
case REG_MULTI_SZ: dwMask = RRF_RT_REG_MULTI_SZ; break;
case REG_BINARY: dwMask = RRF_RT_REG_BINARY; break;
case REG_DWORD: dwMask = RRF_RT_REG_DWORD; break;
case REG_QWORD: dwMask = RRF_RT_REG_QWORD; break;
}
if (dwFlags & dwMask)
{
/* Type is not restricted, check for size mismatch */
if (dwType == REG_BINARY)
{
DWORD cbExpect = 0;
if ((dwFlags & RRF_RT_DWORD) == RRF_RT_DWORD)
cbExpect = 4;
else if ((dwFlags & RRF_RT_QWORD) == RRF_RT_QWORD)
cbExpect = 8;
if (cbExpect && cbData != cbExpect)
*ret = ERROR_DATATYPE_MISMATCH;
}
}
else *ret = ERROR_UNSUPPORTED_TYPE;
}
}
LONG WINAPI RegGetValueX(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
{
DWORD dwType, cbData = pcbData ? *pcbData : 0;
PVOID pvBuf = NULL;
LONG ret;
if (pvData && !pcbData)
return ERROR_INVALID_PARAMETER;
if ((dwFlags & RRF_RT_REG_EXPAND_SZ) && !(dwFlags & RRF_NOEXPAND) &&
((dwFlags & RRF_RT_ANY) != RRF_RT_ANY))
return ERROR_INVALID_PARAMETER;
if (pszSubKey && pszSubKey[0])
{
ret = RegOpenKeyExW(hKey, pszSubKey, 0, KEY_QUERY_VALUE, &hKey);
if (ret != ERROR_SUCCESS) return ret;
}
ret = RegQueryValueExW(hKey, pszValue, NULL, &dwType, (LPBYTE)pvData, &cbData);
/* If we are going to expand we need to read in the whole the value even
* if the passed buffer was too small as the expanded string might be
* smaller than the unexpanded one and could fit into cbData bytes. */
if ((ret == ERROR_SUCCESS || ret == ERROR_MORE_DATA) &&
dwType == REG_EXPAND_SZ && !(dwFlags & RRF_NOEXPAND))
{
do
{
HeapFree(GetProcessHeap(), 0, pvBuf);
pvBuf = HeapAlloc(GetProcessHeap(), 0, cbData);
if (!pvBuf)
{
ret = ERROR_NOT_ENOUGH_MEMORY;
break;
}
if (ret == ERROR_MORE_DATA || !pvData)
ret = RegQueryValueExW(hKey, pszValue, NULL,
&dwType, (LPBYTE)pvBuf, &cbData);
else
{
/* Even if cbData was large enough we have to copy the
* string since ExpandEnvironmentStrings can't handle
* overlapping buffers. */
CopyMemory(pvBuf, pvData, cbData);
}
/* Both the type or the value itself could have been modified in
* between so we have to keep retrying until the buffer is large
* enough or we no longer have to expand the value. */
}
while (dwType == REG_EXPAND_SZ && ret == ERROR_MORE_DATA);
if (ret == ERROR_SUCCESS)
{
/* Recheck dwType in case it changed since the first call */
if (dwType == REG_EXPAND_SZ)
{
cbData = ExpandEnvironmentStringsW((LPCWSTR)pvBuf, (LPWSTR)pvData,
pcbData ? *pcbData : 0) * sizeof(WCHAR);
dwType = REG_SZ;
if (pvData && pcbData && cbData > *pcbData)
ret = ERROR_MORE_DATA;
}
else if (pvData)
CopyMemory(pvData, pvBuf, *pcbData);
}
HeapFree(GetProcessHeap(), 0, pvBuf);
}
if (pszSubKey && pszSubKey[0])
RegCloseKey(hKey);
RegpApplyRestrictions(dwFlags, dwType, cbData, &ret);
if (pvData && ret != ERROR_SUCCESS && (dwFlags & RRF_ZEROONFAILURE))
ZeroMemory(pvData, *pcbData);
if (pdwType)
*pdwType = dwType;
if (pcbData)
*pcbData = cbData;
return ret;
}

View file

@ -1,11 +0,0 @@
#ifndef _GLUE_CODE_H_
#define _GLUE_CODE_H_
LONG WINAPI RegCopyTreeX(HKEY, LPCWSTR, HKEY);
LONG WINAPI RegGetValueX(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData);
LONG WINAPI RegLoadMUIStringWX(IN HKEY hKey, IN LPCWSTR pszValue OPTIONAL, OUT LPWSTR pszOutBuf, IN DWORD cbOutBuf, OUT LPDWORD pcbData OPTIONAL, IN DWORD Flags, IN LPCWSTR pszDirectory OPTIONAL);
LONG WINAPI RegLoadMUIStringAX(IN HKEY hKey, IN LPCSTR pszValue OPTIONAL, OUT LPSTR pszOutBuf, IN DWORD cbOutBuf, OUT LPDWORD pcbData OPTIONAL, IN DWORD Flags, IN LPCSTR pszDirectory OPTIONAL);
#endif

View file

@ -0,0 +1,5 @@
toolband
basebar
menuband
menubandsite
menudeskbar

View file

@ -350,7 +350,7 @@ static void Control_DoWindow(CPanel* panel, HWND hWnd, HINSTANCE hInst)
Control_DoInterface(panel, hWnd, hInst);
}
static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd)
static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd)
/* forms to parse:
* foo.cpl,@sp,str
* foo.cpl,@sp

View file

@ -22,26 +22,28 @@
#include "cpl.h"
typedef struct CPlApplet {
struct CPlApplet* next; /* linked list */
HWND hWnd;
unsigned count; /* number of subprograms */
HMODULE hModule; /* module of loaded applet */
APPLET_PROC proc; /* entry point address */
NEWCPLINFOW info[1]; /* array of count information.
* dwSize field is 0 if entry is invalid */
typedef struct CPlApplet
{
struct CPlApplet *next; /* linked list */
HWND hWnd;
unsigned count; /* number of subprograms */
HMODULE hModule; /* module of loaded applet */
APPLET_PROC proc; /* entry point address */
NEWCPLINFOW info[1]; /* array of count information.
* dwSize field is 0 if entry is invalid */
} CPlApplet;
typedef struct CPanel {
CPlApplet* first; /* linked list */
HWND hWnd;
unsigned status;
CPlApplet* clkApplet;
unsigned clkSP;
typedef struct CPanel
{
CPlApplet *first; /* linked list */
HWND hWnd;
unsigned status;
CPlApplet *clkApplet;
unsigned clkSP;
} CPanel;
CPlApplet* Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel);
CPlApplet* Control_UnloadApplet(CPlApplet* applet);
CPlApplet *Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel);
CPlApplet *Control_UnloadApplet(CPlApplet* applet);
#endif /* __WINE_SHELL_CPANEL_H */

View file

@ -65,22 +65,22 @@
#include "xdg.h"
#include "shellapi.h"
#include "shfldr_fs.h"
#include "shfldr_mycomp.h"
#include "shfldr_desktop.h"
#include "shellitem.h"
#include "shelllink.h"
#include "dragdrophelper.h"
#include "shfldr_cpanel.h"
#include "autocomplete.h"
#include "shfldr_mydocuments.h"
#include "shfldr_netplaces.h"
#include "shfldr_fonts.h"
#include "shfldr_printers.h"
#include "shfldr_admintools.h"
#include "shfldr_recyclebin.h"
#include "she_ocmenu.h"
#include "shv_item_new.h"
#include "folders/fs.h"
#include "folders/mycomp.h"
#include "folders/desktop.h"
#include "folders/cpanel.h"
#include "folders/mydocuments.h"
#include "folders/netplaces.h"
#include "folders/fonts.h"
#include "folders/printers.h"
#include "folders/admintools.h"
#include "folders/recyclebin.h"
#include "openwithmenu.h"
#include "newmenu.h"
#include "startmenu.h"
#include "wine/debug.h"

View file

@ -1,847 +0,0 @@
/*
* self-registerable dll functions for shell32.dll
*
* Copyright (C) 2003 John K. Hohm
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdio.h>
#include <shlobj.h>
#include <shlobj_undoc.h>
#include "shresdef.h"
#include "wine/debug.h"
#define CHARS_IN_GUID 39
extern HRESULT SHELL_RegisterShellFolders(void);
extern const GUID CLSID_AdminFolderShortcut;
extern const GUID CLSID_StartMenu;
extern const GUID CLSID_MenuBandSite;
extern const GUID CLSID_OpenWith;
extern const GUID CLSID_UnixFolder;
extern const GUID CLSID_UnixDosFolder;
extern const GUID CLSID_FontsFolderShortcut;
extern const GUID SHELL32_AdvtShortcutProduct;
extern const GUID SHELL32_AdvtShortcutComponent;
extern const GUID CLSID_ShellFolderViewOC;
WINE_DEFAULT_DEBUG_CHANNEL(shell);
/*
* Near the bottom of this file are the exported DllRegisterServer and
* DllUnregisterServer, which make all this worthwhile.
*/
/***********************************************************************
* interface for self-registering
*/
struct regsvr_interface
{
IID const *iid; /* NULL for end of list */
LPCSTR name; /* can be NULL to omit */
IID const *base_iid; /* can be NULL to omit */
int num_methods; /* can be <0 to omit */
CLSID const *ps_clsid; /* can be NULL to omit */
CLSID const *ps_clsid32; /* can be NULL to omit */
};
static HRESULT register_interfaces(struct regsvr_interface const *list);
static HRESULT unregister_interfaces(struct regsvr_interface const *list);
struct regsvr_coclass
{
CLSID const *clsid; /* NULL for end of list */
LPCSTR name; /* can be NULL to omit */
UINT idName; /* can be 0 to omit */
LPCSTR ips; /* can be NULL to omit */
LPCSTR ips32; /* can be NULL to omit */
LPCSTR ips32_tmodel; /* can be NULL to omit */
DWORD flags;
DWORD dwAttributes;
DWORD dwCallForAttributes;
LPCSTR clsid_str; /* can be NULL to omit */
LPCSTR progid; /* can be NULL to omit */
UINT idDefaultIcon; /* can be 0 to omit */
// CLSID const *clsid_menu; /* can be NULL to omit */
};
/* flags for regsvr_coclass.flags */
#define SHELLEX_MAYCHANGEDEFAULTMENU 0x00000001
#define SHELLFOLDER_WANTSFORPARSING 0x00000002
#define SHELLFOLDER_ATTRIBUTES 0x00000004
#define SHELLFOLDER_CALLFORATTRIBUTES 0x00000008
#define SHELLFOLDER_WANTSFORDISPLAY 0x00000010
#define SHELLFOLDER_HIDEASDELETEPERUSER 0x00000020
static HRESULT register_coclasses(struct regsvr_coclass const *list);
static HRESULT unregister_coclasses(struct regsvr_coclass const *list);
struct regsvr_namespace
{
CLSID const *clsid; /* CLSID of the namespace extension. NULL for end of list */
LPCWSTR parent; /* Mount point (MyComputer, Desktop, ..). */
LPCWSTR value; /* Display name of the extension. */
};
static HRESULT register_namespace_extensions(struct regsvr_namespace const *list);
static HRESULT unregister_namespace_extensions(struct regsvr_namespace const *list);
/***********************************************************************
* static string constants
*/
static WCHAR const interface_keyname[10] = {
'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e', 0 };
static WCHAR const base_ifa_keyname[14] = {
'B', 'a', 's', 'e', 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c',
'e', 0 };
static WCHAR const num_methods_keyname[11] = {
'N', 'u', 'm', 'M', 'e', 't', 'h', 'o', 'd', 's', 0 };
static WCHAR const ps_clsid_keyname[15] = {
'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
'i', 'd', 0 };
static WCHAR const ps_clsid32_keyname[17] = {
'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
'i', 'd', '3', '2', 0 };
static WCHAR const clsid_keyname[6] = {
'C', 'L', 'S', 'I', 'D', 0 };
static WCHAR const ips_keyname[13] = {
'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
0 };
static WCHAR const ips32_keyname[15] = {
'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
'3', '2', 0 };
static WCHAR const progid_keyname[7] = {
'P', 'r', 'o', 'g', 'I', 'D', 0 };
static WCHAR const shellex_keyname[8] = {
's', 'h', 'e', 'l', 'l', 'e', 'x', 0 };
static WCHAR const shellfolder_keyname[12] = {
'S', 'h', 'e', 'l', 'l', 'F', 'o', 'l', 'd', 'e', 'r', 0 };
static WCHAR const mcdm_keyname[21] = {
'M', 'a', 'y', 'C', 'h', 'a', 'n', 'g', 'e', 'D', 'e', 'f',
'a', 'u', 'l', 't', 'M', 'e', 'n', 'u', 0 };
static WCHAR const defaulticon_keyname[] = {
'D','e','f','a','u','l','t','I','c','o','n',0};
static WCHAR const contextmenu_keyname[] = { 'C', 'o', 'n', 't', 'e', 'x', 't', 'M', 'e', 'n', 'u', 'H', 'a', 'n', 'd', 'l', 'e', 'r', 's', 0 };
static char const tmodel_valuename[] = "ThreadingModel";
static char const wfparsing_valuename[] = "WantsFORPARSING";
static char const wfdisplay_valuename[] = "WantsFORDISPLAY";
static char const hideasdeleteperuser_valuename[] = "HideAsDeletePerUser";
static char const attributes_valuename[] = "Attributes";
static char const cfattributes_valuename[] = "CallForAttributes";
static char const localized_valuename[] = "LocalizedString";
/***********************************************************************
* static helper functions
*/
static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid);
static LONG register_key_defvalueW(HKEY base, WCHAR const *name,
WCHAR const *value);
static LONG register_key_defvalueA(HKEY base, WCHAR const *name,
char const *value);
/***********************************************************************
* register_interfaces
*/
static HRESULT register_interfaces(struct regsvr_interface const *list)
{
LONG res = ERROR_SUCCESS;
HKEY interface_key;
res = RegCreateKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &interface_key, NULL);
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->iid; ++list) {
WCHAR buf[39];
HKEY iid_key;
StringFromGUID2(list->iid, buf, 39);
res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &iid_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_interface_key;
if (list->name) {
res = RegSetValueExA(iid_key, NULL, 0, REG_SZ,
(CONST BYTE*)(list->name),
strlen(list->name) + 1);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (list->base_iid) {
res = register_key_guid(iid_key, base_ifa_keyname, list->base_iid);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (0 <= list->num_methods) {
static WCHAR const fmt[3] = { '%', 'd', 0 };
HKEY key;
res = RegCreateKeyExW(iid_key, num_methods_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &key, NULL);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
swprintf(buf, fmt, list->num_methods);
res = RegSetValueExW(key, NULL, 0, REG_SZ,
(CONST BYTE*)buf,
(wcslen(buf) + 1) * sizeof(WCHAR));
RegCloseKey(key);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (list->ps_clsid) {
res = register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (list->ps_clsid32) {
res = register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
error_close_iid_key:
RegCloseKey(iid_key);
}
error_close_interface_key:
RegCloseKey(interface_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* unregister_interfaces
*/
static HRESULT unregister_interfaces(struct regsvr_interface const *list)
{
LONG res = ERROR_SUCCESS;
HKEY interface_key;
res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0,
KEY_READ | KEY_WRITE, &interface_key);
if (res == ERROR_FILE_NOT_FOUND) return S_OK;
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->iid; ++list) {
WCHAR buf[39];
StringFromGUID2(list->iid, buf, 39);
res = RegDeleteTreeW(interface_key, buf);
if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
}
RegCloseKey(interface_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* register_coclasses
*/
static HRESULT register_coclasses(struct regsvr_coclass const *list)
{
LONG res = ERROR_SUCCESS;
HKEY coclass_key;
res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL);
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->clsid; ++list) {
WCHAR buf[39];
HKEY clsid_key;
StringFromGUID2(list->clsid, buf, 39);
res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
if (list->name) {
res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ,
(CONST BYTE*)(list->name),
strlen(list->name) + 1);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->idName) {
char buffer[64];
sprintf(buffer, "@shell32.dll,-%u", list->idName);
res = RegSetValueExA(clsid_key, localized_valuename, 0, REG_SZ,
(CONST BYTE*)(buffer), strlen(buffer)+1);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->idDefaultIcon) {
HKEY icon_key;
char buffer[64];
res = RegCreateKeyExW(clsid_key, defaulticon_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &icon_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
sprintf(buffer, "shell32.dll,-%u", list->idDefaultIcon);
res = RegSetValueExA(icon_key, NULL, 0, REG_SZ,
(CONST BYTE*)(buffer), strlen(buffer)+1);
RegCloseKey(icon_key);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->ips) {
res = register_key_defvalueA(clsid_key, ips_keyname, list->ips);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->ips32) {
HKEY ips32_key;
res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL,
&ips32_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ,
(CONST BYTE*)list->ips32,
lstrlenA(list->ips32) + 1);
if (res == ERROR_SUCCESS && list->ips32_tmodel)
res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ,
(CONST BYTE*)list->ips32_tmodel,
strlen(list->ips32_tmodel) + 1);
RegCloseKey(ips32_key);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->flags & SHELLEX_MAYCHANGEDEFAULTMENU) {
HKEY shellex_key, mcdm_key;
res = RegCreateKeyExW(clsid_key, shellex_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL,
&shellex_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = RegCreateKeyExW(shellex_key, mcdm_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL,
&mcdm_key, NULL);
RegCloseKey(shellex_key);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
RegCloseKey(mcdm_key);
}
if (list->flags &
(SHELLFOLDER_WANTSFORPARSING|SHELLFOLDER_ATTRIBUTES|SHELLFOLDER_CALLFORATTRIBUTES|SHELLFOLDER_WANTSFORDISPLAY|SHELLFOLDER_HIDEASDELETEPERUSER))
{
HKEY shellfolder_key;
res = RegCreateKeyExW(clsid_key, shellfolder_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL,
&shellfolder_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
if (list->flags & SHELLFOLDER_WANTSFORPARSING)
res = RegSetValueExA(shellfolder_key, wfparsing_valuename, 0, REG_SZ, (const BYTE *)"", 1);
if (list->flags & SHELLFOLDER_ATTRIBUTES)
res = RegSetValueExA(shellfolder_key, attributes_valuename, 0, REG_DWORD,
(const BYTE *)&list->dwAttributes, sizeof(DWORD));
if (list->flags & SHELLFOLDER_CALLFORATTRIBUTES)
res = RegSetValueExA(shellfolder_key, cfattributes_valuename, 0, REG_DWORD,
(const BYTE *)&list->dwCallForAttributes, sizeof(DWORD));
if (list->flags & SHELLFOLDER_WANTSFORDISPLAY)
res = RegSetValueExA(shellfolder_key, wfdisplay_valuename, 0, REG_SZ, (const BYTE *)"", 1);
if (list->flags & SHELLFOLDER_HIDEASDELETEPERUSER)
res = RegSetValueExA(shellfolder_key, hideasdeleteperuser_valuename, 0, REG_SZ, (const BYTE *)"", 1);
RegCloseKey(shellfolder_key);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->clsid_str) {
res = register_key_defvalueA(clsid_key, clsid_keyname,
list->clsid_str);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->progid) {
HKEY progid_key;
res = register_key_defvalueA(clsid_key, progid_keyname,
list->progid);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = RegCreateKeyExA(HKEY_CLASSES_ROOT, list->progid, 0,
NULL, 0, KEY_READ | KEY_WRITE, NULL,
&progid_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = register_key_defvalueW(progid_key, clsid_keyname, buf);
RegCloseKey(progid_key);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (IsEqualIID(list->clsid, &CLSID_RecycleBin)) {//if (list->clsid_menu) {
HKEY shellex_key, cmenu_key, menuhandler_key;
res = RegCreateKeyExW(clsid_key, shellex_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL,
&shellex_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = RegCreateKeyExW(shellex_key, contextmenu_keyname, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL,
&cmenu_key, NULL);
if (res != ERROR_SUCCESS) {
RegCloseKey(shellex_key);
goto error_close_clsid_key;
}
StringFromGUID2(list->clsid, buf, 39); //clsid_menu
res = RegCreateKeyExW(cmenu_key, buf, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL,
&menuhandler_key, NULL);
RegCloseKey(menuhandler_key);
RegCloseKey(cmenu_key);
RegCloseKey(shellex_key);
}
error_close_clsid_key:
RegCloseKey(clsid_key);
}
error_close_coclass_key:
RegCloseKey(coclass_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* unregister_coclasses
*/
static HRESULT unregister_coclasses(struct regsvr_coclass const *list)
{
LONG res = ERROR_SUCCESS;
HKEY coclass_key;
res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0,
KEY_READ | KEY_WRITE, &coclass_key);
if (res == ERROR_FILE_NOT_FOUND) return S_OK;
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->clsid; ++list) {
WCHAR buf[39];
StringFromGUID2(list->clsid, buf, 39);
res = RegDeleteTreeW(coclass_key, buf);
if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
if (list->progid) {
res = RegDeleteTreeA(HKEY_CLASSES_ROOT, list->progid);
if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
}
}
error_close_coclass_key:
RegCloseKey(coclass_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/**********************************************************************
* register_namespace_extensions
*/
static WCHAR *get_namespace_key(struct regsvr_namespace const *list) {
static const WCHAR wszExplorerKey[] = {
'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'E','x','p','l','o','r','e','r','\\',0 };
static const WCHAR wszNamespace[] = { '\\','N','a','m','e','s','p','a','c','e','\\',0 };
WCHAR *pwszKey, *pwszCLSID;
pwszKey = HeapAlloc(GetProcessHeap(), 0, sizeof(wszExplorerKey)+sizeof(wszNamespace)+
sizeof(WCHAR)*(wcslen(list->parent)+CHARS_IN_GUID));
if (!pwszKey)
return NULL;
wcscpy(pwszKey, wszExplorerKey);
wcscat(pwszKey, list->parent);
wcscat(pwszKey, wszNamespace);
if (FAILED(StringFromCLSID(list->clsid, &pwszCLSID))) {
HeapFree(GetProcessHeap(), 0, pwszKey);
return NULL;
}
wcscat(pwszKey, pwszCLSID);
CoTaskMemFree(pwszCLSID);
return pwszKey;
}
static HRESULT register_namespace_extensions(struct regsvr_namespace const *list) {
WCHAR *pwszKey;
HKEY hKey;
for (; list->clsid; list++) {
pwszKey = get_namespace_key(list);
/* Create the key and set the value. */
if (pwszKey && ERROR_SUCCESS ==
RegCreateKeyExW(HKEY_LOCAL_MACHINE, pwszKey, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL))
{
RegSetValueExW(hKey, NULL, 0, REG_SZ, (const BYTE *)list->value, sizeof(WCHAR)*(wcslen(list->value)+1));
RegCloseKey(hKey);
}
HeapFree(GetProcessHeap(), 0, pwszKey);
}
return S_OK;
}
static HRESULT unregister_namespace_extensions(struct regsvr_namespace const *list) {
WCHAR *pwszKey;
for (; list->clsid; list++) {
pwszKey = get_namespace_key(list);
RegDeleteKeyW(HKEY_LOCAL_MACHINE, pwszKey);
HeapFree(GetProcessHeap(), 0, pwszKey);
}
return S_OK;
}
/***********************************************************************
* regsvr_key_guid
*/
static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid)
{
WCHAR buf[39];
StringFromGUID2(guid, buf, 39);
return register_key_defvalueW(base, name, buf);
}
/***********************************************************************
* regsvr_key_defvalueW
*/
static LONG register_key_defvalueW(
HKEY base,
WCHAR const *name,
WCHAR const *value)
{
LONG res;
HKEY key;
res = RegCreateKeyExW(base, name, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &key, NULL);
if (res != ERROR_SUCCESS) return res;
res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
(wcslen(value) + 1) * sizeof(WCHAR));
RegCloseKey(key);
return res;
}
/***********************************************************************
* regsvr_key_defvalueA
*/
static LONG register_key_defvalueA(
HKEY base,
WCHAR const *name,
char const *value)
{
LONG res;
HKEY key;
res = RegCreateKeyExW(base, name, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &key, NULL);
if (res != ERROR_SUCCESS) return res;
res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
lstrlenA(value) + 1);
RegCloseKey(key);
return res;
}
/***********************************************************************
* coclass list
*/
static GUID const CLSID_Desktop = {
0x00021400, 0x0000, 0x0000, {0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46} };
static GUID const CLSID_Shortcut = {
0x00021401, 0x0000, 0x0000, {0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46} };
static struct regsvr_coclass const coclass_list[] = {
/*{ &CLSID_Desktop,
"Desktop",
IDS_DESKTOP,
NULL,
"shell32.dll",
"Apartment"
},
{ &CLSID_ControlPanel,
"Shell Control Panel Folder",
IDS_CONTROLPANEL,
NULL,
"shell32.dll",
"Apartment",
SHELLFOLDER_WANTSFORDISPLAY|SHELLFOLDER_ATTRIBUTES|SHELLFOLDER_HIDEASDELETEPERUSER,
SFGAO_FOLDER|SFGAO_HASSUBFOLDER,
0,
NULL,
NULL,
IDI_SHELL_CONTROL_PANEL1
},
{ &CLSID_DragDropHelper,
"Shell Drag and Drop Helper",
0,
NULL,
"shell32.dll",
"Apartment"
},
{ &CLSID_Printers,
"Printers & Fax",
IDS_PRINTERS,
NULL,
"shell32.dll",
"Apartment",
SHELLFOLDER_ATTRIBUTES,
SFGAO_FOLDER,
0,
NULL,
NULL,
IDI_SHELL_PRINTERS_FOLDER
},
{ &CLSID_MyComputer,
"My Computer",
IDS_MYCOMPUTER,
NULL,
"shell32.dll",
"Apartment"
},
{ &CLSID_NetworkPlaces,
"My Network Places",
IDS_NETWORKPLACE,
NULL,
"shell32.dll",
"Apartment",
SHELLFOLDER_ATTRIBUTES|SHELLFOLDER_CALLFORATTRIBUTES,
SFGAO_FOLDER|SFGAO_HASPROPSHEET,
0,
NULL,
NULL,
IDI_SHELL_MY_NETWORK_PLACES
},*/
{ &CLSID_FontsFolderShortcut,
"Fonts",
IDS_FONTS,
NULL,
"shell32.dll",
"Apartment",
SHELLFOLDER_ATTRIBUTES,
SFGAO_FOLDER,
0,
NULL,
NULL,
IDI_SHELL_FONTS_FOLDER
},
/*{ &CLSID_AdminFolderShortcut,
"Administrative Tools",
IDS_ADMINISTRATIVETOOLS,
NULL,
"shell32.dll",
"Apartment",
SHELLFOLDER_ATTRIBUTES,
SFGAO_FOLDER,
0,
NULL,
NULL,
IDI_SHELL_ADMINTOOLS //FIXME
},*/
/*{ &CLSID_Shortcut,
"Shortcut",
0,
NULL,
"shell32.dll",
"Apartment",
SHELLEX_MAYCHANGEDEFAULTMENU
},
{ &CLSID_AutoComplete,
"AutoComplete",
0,
NULL,
"shell32.dll",
"Apartment",
},
{ &CLSID_FolderShortcut,
"Foldershortcut",
0,
NULL,
"shell32.dll",
"Apartment",
SHELLFOLDER_ATTRIBUTES|SHELLFOLDER_CALLFORATTRIBUTES,
SFGAO_FILESYSTEM|SFGAO_FOLDER|SFGAO_LINK,
SFGAO_HASSUBFOLDER|SFGAO_FILESYSTEM|SFGAO_FOLDER|SFGAO_FILESYSANCESTOR
},
{ &CLSID_MyDocuments,
"My Documents",
IDS_PERSONAL,
NULL,
"shell32.dll",
"Apartment",
SHELLFOLDER_WANTSFORPARSING|SHELLFOLDER_ATTRIBUTES|SHELLFOLDER_CALLFORATTRIBUTES,
SFGAO_FILESYSANCESTOR|SFGAO_FOLDER|SFGAO_HASSUBFOLDER,
SFGAO_FILESYSTEM
},
{ &CLSID_RecycleBin,
"Trash",
IDS_RECYCLEBIN_FOLDER_NAME,
NULL,
"shell32.dll",
"Apartment",
SHELLFOLDER_ATTRIBUTES|SHELLFOLDER_CALLFORATTRIBUTES,
SFGAO_FOLDER|SFGAO_DROPTARGET|SFGAO_HASPROPSHEET,
0,
NULL,
NULL,
IDI_SHELL_FULL_RECYCLE_BIN
// &CLSID_RecycleBin
},
{ &CLSID_ShellFSFolder,
"Shell File System Folder",
0,
NULL,
"shell32.dll",
"Apartment"
},
{ &CLSID_ShellFolderViewOC,
"Microsoft Shell Folder View Router",
0,
NULL,
"shell32.dll",
"Apartment"
},
{ &CLSID_StartMenu,
"Start Menu",
0,
NULL,
"shell32.dll",
"Apartment"
},
{ &CLSID_MenuBandSite,
"Menu Site",
0,
NULL,
"shell32.dll",
"Apartment"
},*/
{ NULL } /* list terminator */
};
/***********************************************************************
* interface list
*/
static struct regsvr_interface const interface_list[] = {
{ NULL } /* list terminator */
};
/***********************************************************************
* namespace extensions list
*/
static const WCHAR wszDesktop[] = { 'D','e','s','k','t','o','p',0 };
static const WCHAR wszSlash[] = { '/', 0 };
static const WCHAR wszMyDocuments[] = { 'M','y',' ','D','o','c','u','m','e','n','t','s', 0 };
static const WCHAR wszRecycleBin[] = { 'T','r','a','s','h', 0 };
static const WCHAR wszMyComputer[] = { 'M','y','C','o','m','p','u','t','e','r',0 };
static const WCHAR wszControlPanel[] = { 'C','o','n','t','r','o','l','P','a','n','e','l',0 };
static const WCHAR wszFolderOptions[] = { 'F','o','l','d','e','r',' ','O','p','t','i','o','n','s',0 };
static const WCHAR wszNethoodFolder[] = { 'N','e','t','h','o','o','d',' ','f','o','l','d','e','r',0};
static const WCHAR wszPrinters[] = { 'P','r','i','n','t','e','r','s',0 };
static const WCHAR wszFonts[] = { 'F','o','n','t','s',0 };
static const WCHAR wszAdminTools[] = { 'A','d','m','i','n','T','o','o','l','s',0 };
extern const GUID CLSID_FolderOptions;
static struct regsvr_namespace const namespace_extensions_list[] = {
#if 0
{
&CLSID_UnixDosFolder,
wszDesktop,
wszSlash
},
#endif
{
&CLSID_MyDocuments,
wszDesktop,
wszMyDocuments
},
{
&CLSID_NetworkPlaces,
wszDesktop,
wszNethoodFolder
},
{
&CLSID_RecycleBin,
wszDesktop,
wszRecycleBin
},
{
&CLSID_ControlPanel,
wszMyComputer,
wszControlPanel
},
{
&CLSID_FolderOptions,
wszControlPanel,
wszFolderOptions
},
{
&CLSID_FontsFolderShortcut,
wszControlPanel,
wszFonts
},
{
&CLSID_Printers,
wszControlPanel,
wszPrinters
},
{
&CLSID_AdminFolderShortcut,
wszControlPanel,
wszAdminTools
},
{ NULL }
};
HRESULT WINAPI DoRegisterServer(void)
{
HRESULT hr = S_OK;
TRACE("\n");
//hr = register_coclasses(coclass_list);
//if (SUCCEEDED(hr))
// hr = register_interfaces(interface_list);
//if (SUCCEEDED(hr))
// hr = SHELL_RegisterShellFolders();
//if (SUCCEEDED(hr))
// hr = register_namespace_extensions(namespace_extensions_list);
return hr;
}
HRESULT WINAPI DoUnregisterServer(void)
{
HRESULT hr;
TRACE("\n");
hr = unregister_coclasses(coclass_list);
if (SUCCEEDED(hr))
hr = unregister_interfaces(interface_list);
if (SUCCEEDED(hr))
hr = unregister_namespace_extensions(namespace_extensions_list);
return hr;
}

View file

@ -1,798 +0,0 @@
/*
* self-registerable dll functions for shell32.dll
*
* Copyright (C) 2003 John K. Hohm
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <precomp.h>
WINE_DEFAULT_DEBUG_CHANNEL(shell);
/*
* Near the bottom of this file are the exported DllRegisterServer and
* DllUnregisterServer, which make all this worthwhile.
*/
/***********************************************************************
* interface for self-registering
*/
struct regsvr_interface
{
IID const *iid; /* NULL for end of list */
LPCSTR name; /* can be NULL to omit */
IID const *base_iid; /* can be NULL to omit */
int num_methods; /* can be <0 to omit */
CLSID const *ps_clsid; /* can be NULL to omit */
CLSID const *ps_clsid32; /* can be NULL to omit */
};
static HRESULT register_interfaces(struct regsvr_interface const *list);
static HRESULT unregister_interfaces(struct regsvr_interface const *list);
struct regsvr_coclass
{
CLSID const *clsid; /* NULL for end of list */
LPCSTR name; /* can be NULL to omit */
UINT idName; /* can be 0 to omit */
LPCSTR ips; /* can be NULL to omit */
LPCSTR ips32; /* can be NULL to omit */
LPCSTR ips32_tmodel; /* can be NULL to omit */
DWORD flags;
DWORD dwAttributes;
DWORD dwCallForAttributes;
LPCSTR clsid_str; /* can be NULL to omit */
LPCSTR progid; /* can be NULL to omit */
UINT idDefaultIcon; /* can be 0 to omit */
// CLSID const *clsid_menu; /* can be NULL to omit */
};
/* flags for regsvr_coclass.flags */
#define SHELLEX_MAYCHANGEDEFAULTMENU 0x00000001
#define SHELLFOLDER_WANTSFORPARSING 0x00000002
#define SHELLFOLDER_ATTRIBUTES 0x00000004
#define SHELLFOLDER_CALLFORATTRIBUTES 0x00000008
#define SHELLFOLDER_WANTSFORDISPLAY 0x00000010
#define SHELLFOLDER_HIDEASDELETEPERUSER 0x00000020
static HRESULT register_coclasses(struct regsvr_coclass const *list);
static HRESULT unregister_coclasses(struct regsvr_coclass const *list);
struct regsvr_namespace
{
CLSID const *clsid; /* CLSID of the namespace extension. NULL for end of list */
LPCWSTR parent; /* Mount point (MyComputer, Desktop, ..). */
LPCWSTR value; /* Display name of the extension. */
};
static HRESULT register_namespace_extensions(struct regsvr_namespace const *list);
static HRESULT unregister_namespace_extensions(struct regsvr_namespace const *list);
/***********************************************************************
* static helper functions
*/
static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid);
static LONG register_key_defvalueW(HKEY base, WCHAR const *name,
WCHAR const *value);
static LONG register_key_defvalueA(HKEY base, WCHAR const *name,
char const *value);
/***********************************************************************
* register_interfaces
*/
static HRESULT register_interfaces(struct regsvr_interface const *list)
{
LONG res = ERROR_SUCCESS;
HKEY interface_key;
res = RegCreateKeyExW(HKEY_CLASSES_ROOT, L"Interface", 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &interface_key, NULL);
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->iid; ++list) {
WCHAR buf[39];
HKEY iid_key;
StringFromGUID2(*list->iid, buf, 39);
res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &iid_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_interface_key;
if (list->name) {
res = RegSetValueExA(iid_key, NULL, 0, REG_SZ,
(CONST BYTE*)(list->name),
strlen(list->name) + 1);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (list->base_iid) {
res = register_key_guid(iid_key, L"BaseInterface", list->base_iid);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (0 <= list->num_methods) {
static WCHAR const fmt[3] = { '%', 'd', 0 };
HKEY key;
res = RegCreateKeyExW(iid_key, L"NumMethods", 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &key, NULL);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
swprintf(buf, fmt, list->num_methods);
res = RegSetValueExW(key, NULL, 0, REG_SZ,
(CONST BYTE*)buf,
(wcslen(buf) + 1) * sizeof(WCHAR));
RegCloseKey(key);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (list->ps_clsid) {
res = register_key_guid(iid_key, L"ProxyStubClsid", list->ps_clsid);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
if (list->ps_clsid32) {
res = register_key_guid(iid_key, L"ProxyStubClsid32", list->ps_clsid32);
if (res != ERROR_SUCCESS) goto error_close_iid_key;
}
error_close_iid_key:
RegCloseKey(iid_key);
}
error_close_interface_key:
RegCloseKey(interface_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* unregister_interfaces
*/
static HRESULT unregister_interfaces(struct regsvr_interface const *list)
{
LONG res = ERROR_SUCCESS;
HKEY interface_key;
res = RegOpenKeyExW(HKEY_CLASSES_ROOT, L"Interface", 0,
KEY_READ | KEY_WRITE, &interface_key);
if (res == ERROR_FILE_NOT_FOUND) return S_OK;
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->iid; ++list) {
WCHAR buf[39];
StringFromGUID2(*list->iid, buf, 39);
res = RegDeleteTreeW(interface_key, buf);
if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
}
RegCloseKey(interface_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* register_coclasses
*/
static HRESULT register_coclasses(struct regsvr_coclass const *list)
{
LONG res = ERROR_SUCCESS;
HKEY coclass_key;
res = RegCreateKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL);
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->clsid; ++list) {
WCHAR buf[39];
HKEY clsid_key;
StringFromGUID2(*list->clsid, buf, 39);
res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
if (list->name) {
res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ,
(CONST BYTE*)(list->name),
strlen(list->name) + 1);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->idName) {
char buffer[64];
sprintf(buffer, "@shell32.dll,-%u", list->idName);
res = RegSetValueExA(clsid_key, "LocalizedString", 0, REG_SZ,
(CONST BYTE*)(buffer), strlen(buffer)+1);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->idDefaultIcon) {
HKEY icon_key;
char buffer[64];
res = RegCreateKeyExW(clsid_key, L"DefaultIcon", 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &icon_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
sprintf(buffer, "shell32.dll,-%u", list->idDefaultIcon);
res = RegSetValueExA(icon_key, NULL, 0, REG_SZ,
(CONST BYTE*)(buffer), strlen(buffer)+1);
RegCloseKey(icon_key);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->ips) {
res = register_key_defvalueA(clsid_key, L"InProcServer", list->ips);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->ips32) {
HKEY ips32_key;
res = RegCreateKeyExW(clsid_key, L"InProcServer32", 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL,
&ips32_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ,
(CONST BYTE*)list->ips32,
lstrlenA(list->ips32) + 1);
if (res == ERROR_SUCCESS && list->ips32_tmodel)
res = RegSetValueExA(ips32_key, "ThreadingModel", 0, REG_SZ,
(CONST BYTE*)list->ips32_tmodel,
strlen(list->ips32_tmodel) + 1);
RegCloseKey(ips32_key);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->flags & SHELLEX_MAYCHANGEDEFAULTMENU) {
HKEY shellex_key, mcdm_key;
res = RegCreateKeyExW(clsid_key, L"shellex", 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL,
&shellex_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = RegCreateKeyExW(shellex_key, L"MayChangeDefaultMenu", 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL,
&mcdm_key, NULL);
RegCloseKey(shellex_key);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
RegCloseKey(mcdm_key);
}
if (list->flags &
(SHELLFOLDER_WANTSFORPARSING|SHELLFOLDER_ATTRIBUTES|SHELLFOLDER_CALLFORATTRIBUTES|SHELLFOLDER_WANTSFORDISPLAY|SHELLFOLDER_HIDEASDELETEPERUSER))
{
HKEY shellfolder_key;
res = RegCreateKeyExW(clsid_key, L"ShellFolder", 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL,
&shellfolder_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
if (list->flags & SHELLFOLDER_WANTSFORPARSING)
res = RegSetValueExA(shellfolder_key, "WantsFORPARSING", 0, REG_SZ, (const BYTE *)"", 1);
if (list->flags & SHELLFOLDER_ATTRIBUTES)
res = RegSetValueExA(shellfolder_key, "Attributes", 0, REG_DWORD,
(const BYTE *)&list->dwAttributes, sizeof(DWORD));
if (list->flags & SHELLFOLDER_CALLFORATTRIBUTES)
res = RegSetValueExA(shellfolder_key, "CallForAttributes", 0, REG_DWORD,
(const BYTE *)&list->dwCallForAttributes, sizeof(DWORD));
if (list->flags & SHELLFOLDER_WANTSFORDISPLAY)
res = RegSetValueExA(shellfolder_key, "WantsFORDISPLAY", 0, REG_SZ, (const BYTE *)"", 1);
if (list->flags & SHELLFOLDER_HIDEASDELETEPERUSER)
res = RegSetValueExA(shellfolder_key, "HideAsDeletePerUser", 0, REG_SZ, (const BYTE *)"", 1);
RegCloseKey(shellfolder_key);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->clsid_str) {
res = register_key_defvalueA(clsid_key, L"CLSID",
list->clsid_str);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (list->progid) {
HKEY progid_key;
res = register_key_defvalueA(clsid_key, L"ProgID",
list->progid);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = RegCreateKeyExA(HKEY_CLASSES_ROOT, list->progid, 0,
NULL, 0, KEY_READ | KEY_WRITE, NULL,
&progid_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = register_key_defvalueW(progid_key, L"CLSID", buf);
RegCloseKey(progid_key);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
}
if (IsEqualIID(list->clsid, CLSID_RecycleBin)) {//if (list->clsid_menu) {
HKEY shellex_key, cmenu_key, menuhandler_key;
res = RegCreateKeyExW(clsid_key, L"shellex", 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL,
&shellex_key, NULL);
if (res != ERROR_SUCCESS) goto error_close_clsid_key;
res = RegCreateKeyExW(shellex_key, L"ContextMenuHandlers", 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL,
&cmenu_key, NULL);
if (res != ERROR_SUCCESS) {
RegCloseKey(shellex_key);
goto error_close_clsid_key;
}
StringFromGUID2(*list->clsid, buf, 39); //clsid_menu
res = RegCreateKeyExW(cmenu_key, buf, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL,
&menuhandler_key, NULL);
RegCloseKey(menuhandler_key);
RegCloseKey(cmenu_key);
RegCloseKey(shellex_key);
}
error_close_clsid_key:
RegCloseKey(clsid_key);
}
error_close_coclass_key:
RegCloseKey(coclass_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/***********************************************************************
* unregister_coclasses
*/
static HRESULT unregister_coclasses(struct regsvr_coclass const *list)
{
LONG res = ERROR_SUCCESS;
HKEY coclass_key;
res = RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0,
KEY_READ | KEY_WRITE, &coclass_key);
if (res == ERROR_FILE_NOT_FOUND) return S_OK;
if (res != ERROR_SUCCESS) goto error_return;
for (; res == ERROR_SUCCESS && list->clsid; ++list) {
WCHAR buf[39];
StringFromGUID2(*list->clsid, buf, 39);
res = RegDeleteTreeW(coclass_key, buf);
if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
if (list->progid) {
res = RegDeleteTreeA(HKEY_CLASSES_ROOT, list->progid);
if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
if (res != ERROR_SUCCESS) goto error_close_coclass_key;
}
}
error_close_coclass_key:
RegCloseKey(coclass_key);
error_return:
return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
}
/**********************************************************************
* register_namespace_extensions
*/
static WCHAR *get_namespace_key(struct regsvr_namespace const *list) {
static const WCHAR wszExplorerKey[] = {
'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'E','x','p','l','o','r','e','r','\\',0 };
static const WCHAR wszNamespace[] = { '\\','N','a','m','e','s','p','a','c','e','\\',0 };
WCHAR *pwszKey, *pwszCLSID;
pwszKey = (WCHAR *)HeapAlloc(GetProcessHeap(), 0, sizeof(wszExplorerKey)+sizeof(wszNamespace)+
sizeof(WCHAR)*(wcslen(list->parent)+CHARS_IN_GUID));
if (!pwszKey)
return NULL;
wcscpy(pwszKey, wszExplorerKey);
wcscat(pwszKey, list->parent);
wcscat(pwszKey, wszNamespace);
if (FAILED(StringFromCLSID(*list->clsid, &pwszCLSID))) {
HeapFree(GetProcessHeap(), 0, pwszKey);
return NULL;
}
wcscat(pwszKey, pwszCLSID);
CoTaskMemFree(pwszCLSID);
return pwszKey;
}
static HRESULT register_namespace_extensions(struct regsvr_namespace const *list) {
WCHAR *pwszKey;
HKEY hKey;
for (; list->clsid; list++) {
pwszKey = get_namespace_key(list);
/* Create the key and set the value. */
if (pwszKey && ERROR_SUCCESS ==
RegCreateKeyExW(HKEY_LOCAL_MACHINE, pwszKey, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL))
{
RegSetValueExW(hKey, NULL, 0, REG_SZ, (const BYTE *)list->value, sizeof(WCHAR)*(wcslen(list->value)+1));
RegCloseKey(hKey);
}
HeapFree(GetProcessHeap(), 0, pwszKey);
}
return S_OK;
}
static HRESULT unregister_namespace_extensions(struct regsvr_namespace const *list) {
WCHAR *pwszKey;
for (; list->clsid; list++) {
pwszKey = get_namespace_key(list);
RegDeleteKeyW(HKEY_LOCAL_MACHINE, pwszKey);
HeapFree(GetProcessHeap(), 0, pwszKey);
}
return S_OK;
}
/***********************************************************************
* regsvr_key_guid
*/
static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid)
{
WCHAR buf[39];
StringFromGUID2(*guid, buf, 39);
return register_key_defvalueW(base, name, buf);
}
/***********************************************************************
* regsvr_key_defvalueW
*/
static LONG register_key_defvalueW(
HKEY base,
WCHAR const *name,
WCHAR const *value)
{
LONG res;
HKEY key;
res = RegCreateKeyExW(base, name, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &key, NULL);
if (res != ERROR_SUCCESS) return res;
res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
(wcslen(value) + 1) * sizeof(WCHAR));
RegCloseKey(key);
return res;
}
/***********************************************************************
* regsvr_key_defvalueA
*/
static LONG register_key_defvalueA(
HKEY base,
WCHAR const *name,
char const *value)
{
LONG res;
HKEY key;
res = RegCreateKeyExW(base, name, 0, NULL, 0,
KEY_READ | KEY_WRITE, NULL, &key, NULL);
if (res != ERROR_SUCCESS) return res;
res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
lstrlenA(value) + 1);
RegCloseKey(key);
return res;
}
/***********************************************************************
* coclass list
*/
static GUID const CLSID_Desktop = {
0x00021400, 0x0000, 0x0000, {0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46} };
static GUID const CLSID_Shortcut = {
0x00021401, 0x0000, 0x0000, {0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46} };
static struct regsvr_coclass const coclass_list[] = {
{
&CLSID_Desktop,
"Desktop",
IDS_DESKTOP,
NULL,
"shell32.dll",
"Apartment"
},
{
&CLSID_ControlPanel,
"Shell Control Panel Folder",
IDS_CONTROLPANEL,
NULL,
"shell32.dll",
"Apartment",
SHELLFOLDER_WANTSFORDISPLAY|SHELLFOLDER_ATTRIBUTES|SHELLFOLDER_HIDEASDELETEPERUSER,
SFGAO_FOLDER|SFGAO_HASSUBFOLDER,
0,
NULL,
NULL,
IDI_SHELL_CONTROL_PANEL1
},
{
&CLSID_DragDropHelper,
"Shell Drag and Drop Helper",
0,
NULL,
"shell32.dll",
"Apartment"
},
{
&CLSID_Printers,
"Printers & Fax",
IDS_PRINTERS,
NULL,
"shell32.dll",
"Apartment",
SHELLFOLDER_ATTRIBUTES,
SFGAO_FOLDER,
0,
NULL,
NULL,
IDI_SHELL_PRINTERS_FOLDER
},
{
&CLSID_MyComputer,
"My Computer",
IDS_MYCOMPUTER,
NULL,
"shell32.dll",
"Apartment"
},
{
&CLSID_NetworkPlaces,
"My Network Places",
IDS_NETWORKPLACE,
NULL,
"shell32.dll",
"Apartment",
SHELLFOLDER_ATTRIBUTES|SHELLFOLDER_CALLFORATTRIBUTES,
SFGAO_FOLDER|SFGAO_HASPROPSHEET,
0,
NULL,
NULL,
IDI_SHELL_MY_NETWORK_PLACES
},
{
&CLSID_FontsFolderShortcut,
"Fonts",
IDS_FONTS,
NULL,
"shell32.dll",
"Apartment",
SHELLFOLDER_ATTRIBUTES,
SFGAO_FOLDER,
0,
NULL,
NULL,
IDI_SHELL_FONTS_FOLDER
},
{
&CLSID_AdminFolderShortcut,
"Administrative Tools",
IDS_ADMINISTRATIVETOOLS,
NULL,
"shell32.dll",
"Apartment",
SHELLFOLDER_ATTRIBUTES,
SFGAO_FOLDER,
0,
NULL,
NULL,
IDI_SHELL_ADMINTOOLS //FIXME
},
{
&CLSID_Shortcut,
"Shortcut",
0,
NULL,
"shell32.dll",
"Apartment",
SHELLEX_MAYCHANGEDEFAULTMENU
},
{
&CLSID_AutoComplete,
"AutoComplete",
0,
NULL,
"shell32.dll",
"Apartment",
},
{
&CLSID_FolderShortcut,
"Foldershortcut",
0,
NULL,
"shell32.dll",
"Apartment",
SHELLFOLDER_ATTRIBUTES|SHELLFOLDER_CALLFORATTRIBUTES,
SFGAO_FILESYSTEM|SFGAO_FOLDER|SFGAO_LINK,
SFGAO_HASSUBFOLDER|SFGAO_FILESYSTEM|SFGAO_FOLDER|SFGAO_FILESYSANCESTOR
},
{
&CLSID_MyDocuments,
"My Documents",
IDS_PERSONAL,
NULL,
"shell32.dll",
"Apartment",
SHELLFOLDER_WANTSFORPARSING|SHELLFOLDER_ATTRIBUTES|SHELLFOLDER_CALLFORATTRIBUTES,
SFGAO_FILESYSANCESTOR|SFGAO_FOLDER|SFGAO_HASSUBFOLDER,
SFGAO_FILESYSTEM
},
{
&CLSID_RecycleBin,
"Trash",
IDS_RECYCLEBIN_FOLDER_NAME,
NULL,
"shell32.dll",
"Apartment",
SHELLFOLDER_ATTRIBUTES|SHELLFOLDER_CALLFORATTRIBUTES,
SFGAO_FOLDER|SFGAO_DROPTARGET|SFGAO_HASPROPSHEET,
0,
NULL,
NULL,
IDI_SHELL_FULL_RECYCLE_BIN
// &CLSID_RecycleBin
},
{
&CLSID_ShellFSFolder,
"Shell File System Folder",
0,
NULL,
"shell32.dll",
"Apartment"
},
{
&CLSID_ShellFolderViewOC,
"Microsoft Shell Folder View Router",
0,
NULL,
"shell32.dll",
"Apartment"
},
{
&CLSID_StartMenu,
"Start Menu",
0,
NULL,
"shell32.dll",
"Apartment"
},
{
&CLSID_MenuBandSite,
"Menu Site",
0,
NULL,
"shell32.dll",
"Apartment"
},
{ NULL } /* list terminator */
};
/***********************************************************************
* interface list
*/
static struct regsvr_interface const interface_list[] = {
{ NULL } /* list terminator */
};
/***********************************************************************
* namespace extensions list
*/
static const WCHAR wszDesktop[] = { 'D','e','s','k','t','o','p',0 };
static const WCHAR wszSlash[] = { '/', 0 };
static const WCHAR wszMyDocuments[] = { 'M','y',' ','D','o','c','u','m','e','n','t','s', 0 };
static const WCHAR wszRecycleBin[] = { 'T','r','a','s','h', 0 };
static const WCHAR wszMyComputer[] = { 'M','y','C','o','m','p','u','t','e','r',0 };
static const WCHAR wszControlPanel[] = { 'C','o','n','t','r','o','l','P','a','n','e','l',0 };
static const WCHAR wszFolderOptions[] = { 'F','o','l','d','e','r',' ','O','p','t','i','o','n','s',0 };
static const WCHAR wszNethoodFolder[] = { 'N','e','t','h','o','o','d',' ','f','o','l','d','e','r',0};
static const WCHAR wszPrinters[] = { 'P','r','i','n','t','e','r','s',0 };
static const WCHAR wszFonts[] = { 'F','o','n','t','s',0 };
static const WCHAR wszAdminTools[] = { 'A','d','m','i','n','T','o','o','l','s',0 };
static struct regsvr_namespace const namespace_extensions_list[] = {
{
&CLSID_MyDocuments,
L"Desktop",
L"My Documents"
},
{
&CLSID_NetworkPlaces,
L"Desktop",
L"Nethood folder"
},
{
&CLSID_RecycleBin,
L"Desktop",
L"Trash"
},
{
&CLSID_ControlPanel,
L"MyComputer",
L"ControlPanel"
},
{
&CLSID_FolderOptions,
L"ControlPanel"
L"Folder Options"
},
{
&CLSID_FontsFolderShortcut,
L"ControlPanel"
L"Fonts"
},
{
&CLSID_Printers,
L"ControlPanel"
L"Printers"
},
{
&CLSID_AdminFolderShortcut,
L"ControlPanel"
L"AdminTools"
},
{ NULL }
};
/***********************************************************************
* DllRegisterServer (SHELL32.@)
*/
EXTERN_C HRESULT WINAPI DllRegisterServer(void)
{
HRESULT hr;
TRACE("\n");
hr = register_coclasses(coclass_list);
if (SUCCEEDED(hr))
hr = register_interfaces(interface_list);
if (SUCCEEDED(hr))
hr = SHELL_RegisterShellFolders();
if (SUCCEEDED(hr))
hr = register_namespace_extensions(namespace_extensions_list);
return hr;
}
/***********************************************************************
* DllUnregisterServer (SHELL32.@)
*/
EXTERN_C HRESULT WINAPI DllUnregisterServer(void)
{
HRESULT hr;
TRACE("\n");
hr = unregister_coclasses(coclass_list);
if (SUCCEEDED(hr))
hr = unregister_interfaces(interface_list);
if (SUCCEEDED(hr))
hr = unregister_namespace_extensions(namespace_extensions_list);
return hr;
}

View file

@ -1,73 +0,0 @@
/*
* Copyright 2004 Martin Fuchs
*
* Pass on icon notification messages to the systray implementation
* in the currently running shell.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <precomp.h>
/* copy data structure for tray notifications */
typedef struct TrayNotifyCDS_Dummy {
DWORD cookie;
DWORD notify_code;
DWORD nicon_data[1]; // placeholder for NOTIFYICONDATA structure
} TrayNotifyCDS_Dummy;
/* The only difference between Shell_NotifyIconA and Shell_NotifyIconW is the call to SendMessageA/W. */
static BOOL SHELL_NotifyIcon(DWORD dwMessage, void* pnid, HWND nid_hwnd, int nid_size, BOOL unicode)
{
HWND hwnd;
COPYDATASTRUCT data;
BOOL ret = FALSE;
int len = sizeof(TrayNotifyCDS_Dummy) - sizeof(DWORD) + nid_size;
TrayNotifyCDS_Dummy* pnotify_data = (TrayNotifyCDS_Dummy*) alloca(len);
pnotify_data->cookie = 1;
pnotify_data->notify_code = dwMessage;
memcpy(&pnotify_data->nicon_data, pnid, nid_size);
data.dwData = 1;
data.cbData = len;
data.lpData = pnotify_data;
for(hwnd = 0; (hwnd = FindWindowExW(0, hwnd, L"Shell_TrayWnd", NULL)); )
if ((unicode ? SendMessageW : SendMessageA)(hwnd, WM_COPYDATA, (WPARAM)nid_hwnd, (LPARAM)&data))
ret = TRUE;
return ret;
}
/*************************************************************************
* Shell_NotifyIcon [SHELL32.296]
* Shell_NotifyIconA [SHELL32.297]
*/
BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA pnid)
{
return SHELL_NotifyIcon(dwMessage, pnid, pnid->hWnd, pnid->cbSize, FALSE);
}
/*************************************************************************
* Shell_NotifyIconW [SHELL32.298]
*/
BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW pnid)
{
return SHELL_NotifyIcon(dwMessage, pnid, pnid->hWnd, pnid->cbSize, TRUE);
}

View file

@ -1,21 +0,0 @@
/*
* Shell Library Functions
*
* Copyright 1998 Marcus Meissner
* Copyright 2000 Juergen Schmied
* Copyright 2002 Eric Pouech
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/

View file

@ -56,16 +56,18 @@
<file>shellpath.cpp</file>
<file>shellreg.cpp</file>
<file>shellstring.cpp</file>
<file>shfldr_desktop.cpp</file>
<file>shfldr_fs.cpp</file>
<file>shfldr_mycomp.cpp</file>
<file>shfldr_mydocuments.cpp</file>
<file>shfldr_printers.cpp</file>
<file>shfldr_admintools.cpp</file>
<file>shfldr_netplaces.cpp</file>
<file>shfldr_fonts.cpp</file>
<file>shfldr_cpanel.cpp</file>
<file>shfldr_recyclebin.cpp</file>
<directory name="folders">
<file>desktop.cpp</file>
<file>fs.cpp</file>
<file>mycomp.cpp</file>
<file>mydocuments.cpp</file>
<file>printers.cpp</file>
<file>admintools.cpp</file>
<file>netplaces.cpp</file>
<file>fonts.cpp</file>
<file>cpanel.cpp</file>
<file>recyclebin.cpp</file>
</directory>
<file>shlexec.cpp</file>
<file>shlfileop.cpp</file>
<file>shlfolder.cpp</file>
@ -73,15 +75,14 @@
<file>shlmenu.cpp</file>
<file>shlview.cpp</file>
<file>shpolicy.cpp</file>
<file>shv_def_cmenu.cpp</file>
<file>startmenu.cpp</file>
<file>stubs.cpp</file>
<file>ros-systray.cpp</file>
<file>regsvr.c</file>
<file>systray.cpp</file>
<file>fprop.cpp</file>
<file>drive.cpp</file>
<file>she_ocmenu.cpp</file>
<file>shv_item_new.cpp</file>
<file>defcontextmenu.cpp</file>
<file>startmenu.cpp</file>
<file>openwithmenu.cpp</file>
<file>newmenu.cpp</file>
<file>folder_options.cpp</file>
<file>shell32.rc</file>
</module>

View file

@ -1258,7 +1258,7 @@ EXTERN_C void WINAPI FreeIconList( DWORD dw )
/*************************************************************************
* SHLoadNonloadedIconOverlayIdentifiers (SHELL32.@)
*/
EXTERN_C HRESULT WINAPI SHLoadNonloadedIconOverlayIdentifiers( VOID )
EXTERN_C HRESULT WINAPI SHLoadNonloadedIconOverlayIdentifiers(VOID)
{
FIXME("stub\n");
return S_OK;
@ -1294,32 +1294,6 @@ END_OBJECT_MAP()
CShell32Module gModule;
/*
static const struct {
REFIID riid;
LPFNCREATEINSTANCE lpfnCI;
} InterfaceTable[] = {
{CLSID_ShellFSFolder, &IFSFolder_Constructor},
{CLSID_MyComputer, &ISF_MyComputer_Constructor},
{CLSID_ShellDesktop, &ISF_Desktop_Constructor},
{CLSID_ShellItem, &IShellItem_Constructor},
{CLSID_ShellLink, &IShellLink_Constructor},
{CLSID_DragDropHelper, &IDropTargetHelper_Constructor},
{CLSID_ControlPanel, &IControlPanel_Constructor},
{CLSID_AutoComplete, &IAutoComplete_Constructor},
{CLSID_MyDocuments, &ISF_MyDocuments_Constructor},
{CLSID_NetworkPlaces, &ISF_NetworkPlaces_Constructor},
{CLSID_FontsFolderShortcut, &ISF_Fonts_Constructor},
{CLSID_Printers, &ISF_Printers_Constructor},
{CLSID_AdminFolderShortcut, &ISF_AdminTools_Constructor},
{CLSID_RecycleBin, &RecycleBin_Constructor},
{CLSID_OpenWithMenu, &SHEOW_Constructor},
{CLSID_NewMenu, &INewItem_Constructor},
{CLSID_StartMenu, &StartMenu_Constructor},
{CLSID_MenuBandSite, &MenuBandSite_Constructor},
};
*/
/***********************************************************************
* DllGetVersion [SHELL32.@]
*

View file

@ -1,9 +1,8 @@
/*
* Systray handling
* Copyright 2004 Martin Fuchs
*
* Copyright 1999 Kai Morich <kai.morich@bigfoot.de>
* Copyright 2004 Mike Hearn, for CodeWeavers
* Copyright 2005 Robert Shearman
* Pass on icon notification messages to the systray implementation
* in the currently running shell.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -17,168 +16,58 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <precomp.h>
WINE_DEFAULT_DEBUG_CHANNEL(systray);
/* copy data structure for tray notifications */
typedef struct TrayNotifyCDS_Dummy {
DWORD cookie;
DWORD notify_code;
DWORD nicon_data[1]; // placeholder for NOTIFYICONDATA structure
} TrayNotifyCDS_Dummy;
static const WCHAR classname[] = /* Shell_TrayWnd */ {'S','h','e','l','l','_','T','r','a','y','W','n','d','\0'};
/*************************************************************************
* Shell_NotifyIcon [SHELL32.296]
* Shell_NotifyIconA [SHELL32.297]
*/
BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA pnid)
/* The only difference between Shell_NotifyIconA and Shell_NotifyIconW is the call to SendMessageA/W. */
static BOOL SHELL_NotifyIcon(DWORD dwMessage, void* pnid, HWND nid_hwnd, int nid_size, BOOL unicode)
{
NOTIFYICONDATAW nidW;
INT cbSize;
HWND hwnd;
COPYDATASTRUCT data;
/* Validate the cbSize as Windows XP does */
if (pnid->cbSize != NOTIFYICONDATAA_V1_SIZE &&
pnid->cbSize != NOTIFYICONDATAA_V2_SIZE &&
pnid->cbSize != NOTIFYICONDATAA_V3_SIZE &&
pnid->cbSize != sizeof(NOTIFYICONDATAA))
{
WARN("Invalid cbSize (%d) - using only Win95 fields (size=%d)\n",
pnid->cbSize, NOTIFYICONDATAA_V1_SIZE);
cbSize = NOTIFYICONDATAA_V1_SIZE;
}
else
cbSize = pnid->cbSize;
BOOL ret = FALSE;
int len = sizeof(TrayNotifyCDS_Dummy) - sizeof(DWORD) + nid_size;
ZeroMemory(&nidW, sizeof(nidW));
nidW.cbSize = sizeof(nidW);
nidW.hWnd = pnid->hWnd;
nidW.uID = pnid->uID;
nidW.uFlags = pnid->uFlags;
nidW.uCallbackMessage = pnid->uCallbackMessage;
nidW.hIcon = pnid->hIcon;
TrayNotifyCDS_Dummy* pnotify_data = (TrayNotifyCDS_Dummy*) alloca(len);
/* szTip */
if (pnid->uFlags & NIF_TIP)
MultiByteToWideChar(CP_ACP, 0, pnid->szTip, -1, nidW.szTip, sizeof(nidW.szTip)/sizeof(WCHAR));
pnotify_data->cookie = 1;
pnotify_data->notify_code = dwMessage;
memcpy(&pnotify_data->nicon_data, pnid, nid_size);
if (cbSize >= NOTIFYICONDATAA_V2_SIZE)
{
nidW.dwState = pnid->dwState;
nidW.dwStateMask = pnid->dwStateMask;
data.dwData = 1;
data.cbData = len;
data.lpData = pnotify_data;
/* szInfo, szInfoTitle */
if (pnid->uFlags & NIF_INFO)
{
MultiByteToWideChar(CP_ACP, 0, pnid->szInfo, -1, nidW.szInfo, sizeof(nidW.szInfo)/sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, pnid->szInfoTitle, -1, nidW.szInfoTitle, sizeof(nidW.szInfoTitle)/sizeof(WCHAR));
}
nidW.u.uTimeout = pnid->u.uTimeout;
nidW.dwInfoFlags = pnid->dwInfoFlags;
}
if (cbSize >= NOTIFYICONDATAA_V3_SIZE)
nidW.guidItem = pnid->guidItem;
if (cbSize >= sizeof(NOTIFYICONDATAA))
nidW.hBalloonIcon = pnid->hBalloonIcon;
return Shell_NotifyIconW(dwMessage, &nidW);
}
/*************************************************************************
* Shell_NotifyIconW [SHELL32.298]
*/
BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW nid)
{
HWND tray;
COPYDATASTRUCT cds;
char *buffer = NULL;
BOOL ret;
TRACE("dwMessage = %d, nid->cbSize=%d\n", dwMessage, nid->cbSize);
/* Validate the cbSize so that WM_COPYDATA doesn't crash the application */
if (nid->cbSize != NOTIFYICONDATAW_V1_SIZE &&
nid->cbSize != NOTIFYICONDATAW_V2_SIZE &&
nid->cbSize != NOTIFYICONDATAW_V3_SIZE &&
nid->cbSize != sizeof(NOTIFYICONDATAW))
{
NOTIFYICONDATAW newNid;
WARN("Invalid cbSize (%d) - using only Win95 fields (size=%d)\n",
nid->cbSize, NOTIFYICONDATAW_V1_SIZE);
CopyMemory(&newNid, nid, NOTIFYICONDATAW_V1_SIZE);
newNid.cbSize = NOTIFYICONDATAW_V1_SIZE;
return Shell_NotifyIconW(dwMessage, &newNid);
}
tray = FindWindowExW(0, NULL, classname, NULL);
if (!tray) return FALSE;
cds.dwData = dwMessage;
/* FIXME: if statement only needed because we don't support interprocess
* icon handles */
if (nid->uFlags & NIF_ICON)
{
ICONINFO iconinfo;
BITMAP bmMask;
BITMAP bmColour;
LONG cbMaskBits;
LONG cbColourBits;
if (!GetIconInfo(nid->hIcon, &iconinfo))
goto noicon;
if (!GetObjectW(iconinfo.hbmMask, sizeof(bmMask), &bmMask) ||
!GetObjectW(iconinfo.hbmColor, sizeof(bmColour), &bmColour))
{
DeleteObject(iconinfo.hbmMask);
DeleteObject(iconinfo.hbmColor);
goto noicon;
}
cbMaskBits = (bmMask.bmPlanes * bmMask.bmWidth * bmMask.bmHeight * bmMask.bmBitsPixel) / 8;
cbColourBits = (bmColour.bmPlanes * bmColour.bmWidth * bmColour.bmHeight * bmColour.bmBitsPixel) / 8;
cds.cbData = nid->cbSize + 2*sizeof(BITMAP) + cbMaskBits + cbColourBits;
buffer = HeapAlloc(GetProcessHeap(), 0, cds.cbData);
if (!buffer)
{
DeleteObject(iconinfo.hbmMask);
DeleteObject(iconinfo.hbmColor);
return FALSE;
}
cds.lpData = buffer;
memcpy(buffer, nid, nid->cbSize);
buffer += nid->cbSize;
memcpy(buffer, &bmMask, sizeof(bmMask));
buffer += sizeof(bmMask);
memcpy(buffer, &bmColour, sizeof(bmColour));
buffer += sizeof(bmColour);
GetBitmapBits(iconinfo.hbmMask, cbMaskBits, buffer);
buffer += cbMaskBits;
GetBitmapBits(iconinfo.hbmColor, cbColourBits, buffer);
/* Reset pointer to allocated block so it can be freed later.
* Note that cds.lpData cannot be passed to HeapFree since it
* points to nid when no icon info is found. */
buffer = cds.lpData;
DeleteObject(iconinfo.hbmMask);
DeleteObject(iconinfo.hbmColor);
}
else
{
noicon:
cds.cbData = nid->cbSize;
cds.lpData = nid;
}
ret = SendMessageW(tray, WM_COPYDATA, (WPARAM)nid->hWnd, (LPARAM)&cds);
/* FIXME: if statement only needed because we don't support interprocess
* icon handles */
HeapFree(GetProcessHeap(), 0, buffer);
for(hwnd = 0; (hwnd = FindWindowExW(0, hwnd, L"Shell_TrayWnd", NULL)); )
if ((unicode ? SendMessageW : SendMessageA)(hwnd, WM_COPYDATA, (WPARAM)nid_hwnd, (LPARAM)&data))
ret = TRUE;
return ret;
}
/*************************************************************************
* Shell_NotifyIcon [SHELL32.296]
* Shell_NotifyIconA [SHELL32.297]
*/
BOOL WINAPI Shell_NotifyIconA(DWORD dwMessage, PNOTIFYICONDATAA pnid)
{
return SHELL_NotifyIcon(dwMessage, pnid, pnid->hWnd, pnid->cbSize, FALSE);
}
/*************************************************************************
* Shell_NotifyIconW [SHELL32.298]
*/
BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW pnid)
{
return SHELL_NotifyIcon(dwMessage, pnid, pnid->hWnd, pnid->cbSize, TRUE);
}