| 1 | /* $Id: classes.cpp,v 1.3 2000-03-26 16:34:39 cbratschi Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Win32 SHELL32 for OS/2
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright 1997 Marcus Meissner
|
|---|
| 7 | * Copyright 1999 Patrick Haller (haller@zebra.fh-weingarten.de)
|
|---|
| 8 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 9 | *
|
|---|
| 10 | * Corel WINE 20000324 level
|
|---|
| 11 | */
|
|---|
| 12 |
|
|---|
| 13 | /*
|
|---|
| 14 | * file type mapping
|
|---|
| 15 | * (HKEY_CLASSES_ROOT - Stuff)
|
|---|
| 16 | */
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 | /*****************************************************************************
|
|---|
| 20 | * Includes *
|
|---|
| 21 | *****************************************************************************/
|
|---|
| 22 |
|
|---|
| 23 | #include <stdlib.h>
|
|---|
| 24 | #include <string.h>
|
|---|
| 25 | #include <odin.h>
|
|---|
| 26 | #include <odinwrap.h>
|
|---|
| 27 | #include <os2sel.h>
|
|---|
| 28 |
|
|---|
| 29 | #define ICOM_CINTERFACE 1
|
|---|
| 30 | #define CINTERFACE 1
|
|---|
| 31 |
|
|---|
| 32 | #include "debugtools.h"
|
|---|
| 33 | #include "winerror.h"
|
|---|
| 34 | #include "winreg.h"
|
|---|
| 35 |
|
|---|
| 36 | #include "shlobj.h"
|
|---|
| 37 | #include "shell32_main.h"
|
|---|
| 38 | #include "shlguid.h"
|
|---|
| 39 | #include "shresdef.h"
|
|---|
| 40 |
|
|---|
| 41 | #include <misc.h>
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 | /*****************************************************************************
|
|---|
| 45 | * Local Variables *
|
|---|
| 46 | *****************************************************************************/
|
|---|
| 47 |
|
|---|
| 48 | ODINDEBUGCHANNEL(shell32-classes)
|
|---|
| 49 |
|
|---|
| 50 | #define MAX_EXTENSION_LENGTH 20
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 | /*****************************************************************************
|
|---|
| 54 | * Implementation *
|
|---|
| 55 | *****************************************************************************/
|
|---|
| 56 |
|
|---|
| 57 | BOOL HCR_MapTypeToValue ( LPCSTR szExtension, LPSTR szFileType, DWORD len, BOOL bPrependDot)
|
|---|
| 58 | {
|
|---|
| 59 | HKEY hkey;
|
|---|
| 60 | char szTemp[MAX_EXTENSION_LENGTH + 2];
|
|---|
| 61 |
|
|---|
| 62 | dprintf(("SHELL32:classes:HCR_MapTypeToValue(%s,%08xh,%08xh,%08xh)\n",
|
|---|
| 63 | szExtension,
|
|---|
| 64 | szFileType,
|
|---|
| 65 | len,
|
|---|
| 66 | bPrependDot));
|
|---|
| 67 |
|
|---|
| 68 | if (bPrependDot)
|
|---|
| 69 | strcpy(szTemp, ".");
|
|---|
| 70 |
|
|---|
| 71 | lstrcpynA(szTemp+((bPrependDot)?1:0), szExtension, MAX_EXTENSION_LENGTH);
|
|---|
| 72 |
|
|---|
| 73 | if (RegOpenKeyExA(HKEY_CLASSES_ROOT,szTemp,0,0x02000000,&hkey))
|
|---|
| 74 | { return FALSE;
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | if (RegQueryValueA(hkey,NULL,szFileType,(LPLONG)&len))
|
|---|
| 78 | { RegCloseKey(hkey);
|
|---|
| 79 | return FALSE;
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | RegCloseKey(hkey);
|
|---|
| 83 |
|
|---|
| 84 | TRACE("-- %s\n", szFileType );
|
|---|
| 85 |
|
|---|
| 86 | return TRUE;
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | BOOL HCR_GetExecuteCommand ( LPCSTR szClass, LPCSTR szVerb, LPSTR szDest, DWORD len )
|
|---|
| 90 | {
|
|---|
| 91 | HKEY hkey;
|
|---|
| 92 | char sTemp[256];
|
|---|
| 93 |
|
|---|
| 94 | dprintf(("SHELL32:classes:HCR_GetExecuteCommand(%s,%s,%08xh,%08xh)\n",
|
|---|
| 95 | szClass,
|
|---|
| 96 | szVerb,
|
|---|
| 97 | szDest,
|
|---|
| 98 | len));
|
|---|
| 99 |
|
|---|
| 100 | sprintf(sTemp, "%s\\shell\\%s\\command",szClass, szVerb);
|
|---|
| 101 |
|
|---|
| 102 | if (RegOpenKeyExA(HKEY_CLASSES_ROOT,sTemp,0,0x02000000,&hkey))
|
|---|
| 103 | { return FALSE;
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | if (RegQueryValueA(hkey,NULL,szDest,(LPLONG)&len))
|
|---|
| 107 | { RegCloseKey(hkey);
|
|---|
| 108 | return FALSE;
|
|---|
| 109 | }
|
|---|
| 110 | RegCloseKey(hkey);
|
|---|
| 111 |
|
|---|
| 112 | TRACE("-- %s\n", szDest );
|
|---|
| 113 |
|
|---|
| 114 | return TRUE;
|
|---|
| 115 |
|
|---|
| 116 | }
|
|---|
| 117 | /***************************************************************************************
|
|---|
| 118 | * HCR_GetDefaultIcon [internal]
|
|---|
| 119 | *
|
|---|
| 120 | * Gets the icon for a filetype
|
|---|
| 121 | */
|
|---|
| 122 | BOOL HCR_GetDefaultIcon (LPCSTR szClass, LPSTR szDest, DWORD len, LPDWORD dwNr)
|
|---|
| 123 | {
|
|---|
| 124 | HKEY hkey;
|
|---|
| 125 | char sTemp[256];
|
|---|
| 126 | char sNum[5];
|
|---|
| 127 |
|
|---|
| 128 | dprintf(("SHELL32:classes:HCR_GetDefaultIcon(%s,%08xh,%08xh,%08xh)\n",
|
|---|
| 129 | szClass,
|
|---|
| 130 | szDest,
|
|---|
| 131 | len,
|
|---|
| 132 | dwNr));
|
|---|
| 133 |
|
|---|
| 134 | sprintf(sTemp, "%s\\DefaultIcon",szClass);
|
|---|
| 135 |
|
|---|
| 136 | if (RegOpenKeyExA(HKEY_CLASSES_ROOT,sTemp,0,0x02000000,&hkey))
|
|---|
| 137 | { return FALSE;
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | if (RegQueryValueA(hkey,NULL,szDest,(LPLONG)&len))
|
|---|
| 141 | { RegCloseKey(hkey);
|
|---|
| 142 | return FALSE;
|
|---|
| 143 | }
|
|---|
| 144 |
|
|---|
| 145 | RegCloseKey(hkey);
|
|---|
| 146 |
|
|---|
| 147 | if (ParseFieldA (szDest, 2, sNum, 5))
|
|---|
| 148 | { *dwNr=atoi(sNum);
|
|---|
| 149 | }
|
|---|
| 150 |
|
|---|
| 151 | ParseFieldA (szDest, 1, szDest, len);
|
|---|
| 152 |
|
|---|
| 153 | TRACE("-- %s %li\n", szDest, *dwNr );
|
|---|
| 154 |
|
|---|
| 155 | return TRUE;
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | /***************************************************************************************
|
|---|
| 159 | * HCR_GetClassName [internal]
|
|---|
| 160 | *
|
|---|
| 161 | * Gets the name of a registred class
|
|---|
| 162 | */
|
|---|
| 163 | BOOL HCR_GetClassName (REFIID riid, LPSTR szDest, DWORD len)
|
|---|
| 164 | {
|
|---|
| 165 | HKEY hkey;
|
|---|
| 166 | char xriid[50];
|
|---|
| 167 | BOOL ret = FALSE;
|
|---|
| 168 | DWORD buflen = len;
|
|---|
| 169 |
|
|---|
| 170 | dprintf(("SHELL32:classes:HCR_GetClassName(%08xh,%08xh,%08xh)\n",
|
|---|
| 171 | riid,
|
|---|
| 172 | szDest,
|
|---|
| 173 | len));
|
|---|
| 174 |
|
|---|
| 175 | strcpy(xriid,"CLSID\\");
|
|---|
| 176 | WINE_StringFromCLSID(riid,&xriid[strlen(xriid)]);
|
|---|
| 177 |
|
|---|
| 178 | TRACE("%s\n",xriid );
|
|---|
| 179 |
|
|---|
| 180 | if (!RegOpenKeyExA(HKEY_CLASSES_ROOT,xriid,0,KEY_READ,&hkey))
|
|---|
| 181 | {
|
|---|
| 182 | if (!RegQueryValueExA(hkey,"",0,NULL,(LPBYTE)szDest,&len))
|
|---|
| 183 | {
|
|---|
| 184 | ret = TRUE;
|
|---|
| 185 | }
|
|---|
| 186 | RegCloseKey(hkey);
|
|---|
| 187 | }
|
|---|
| 188 |
|
|---|
| 189 | if (!ret || !szDest[0])
|
|---|
| 190 | {
|
|---|
| 191 | if(IsEqualIID(riid, &CLSID_ShellDesktop))
|
|---|
| 192 | {
|
|---|
| 193 | LoadStringA(shell32_hInstance, IDS_DESKTOP, szDest, buflen);
|
|---|
| 194 | ret = TRUE;
|
|---|
| 195 | }
|
|---|
| 196 | else if (IsEqualIID(riid, &CLSID_MyComputer))
|
|---|
| 197 | {
|
|---|
| 198 | LoadStringA(shell32_hInstance, IDS_MYCOMPUTER, szDest, buflen);
|
|---|
| 199 | ret = TRUE;
|
|---|
| 200 | }
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | TRACE("-- %s\n", szDest);
|
|---|
| 204 |
|
|---|
| 205 | return ret;
|
|---|
| 206 | }
|
|---|
| 207 |
|
|---|
| 208 | /***************************************************************************************
|
|---|
| 209 | * HCR_GetFolderAttributes [internal]
|
|---|
| 210 | *
|
|---|
| 211 | * gets the folder attributes of a class
|
|---|
| 212 | *
|
|---|
| 213 | * FIXME
|
|---|
| 214 | * verify the defaultvalue for *szDest
|
|---|
| 215 | */
|
|---|
| 216 | BOOL HCR_GetFolderAttributes (REFIID riid, LPDWORD szDest)
|
|---|
| 217 | {
|
|---|
| 218 | HKEY hkey;
|
|---|
| 219 | char xriid[60];
|
|---|
| 220 | DWORD attributes;
|
|---|
| 221 | DWORD len = 4;
|
|---|
| 222 |
|
|---|
| 223 | dprintf(("SHELL32:classes:HCR_GetFolderAttributes(%08xh,%08xh)\n",
|
|---|
| 224 | riid,
|
|---|
| 225 | szDest));
|
|---|
| 226 |
|
|---|
| 227 | strcpy(xriid,"CLSID\\");
|
|---|
| 228 | WINE_StringFromCLSID(riid,&xriid[strlen(xriid)]);
|
|---|
| 229 | TRACE("%s\n",xriid );
|
|---|
| 230 |
|
|---|
| 231 | if (!szDest) return FALSE;
|
|---|
| 232 | *szDest = SFGAO_FOLDER|SFGAO_FILESYSTEM;
|
|---|
| 233 |
|
|---|
| 234 | strcat (xriid, "\\ShellFolder");
|
|---|
| 235 |
|
|---|
| 236 | if (RegOpenKeyExA(HKEY_CLASSES_ROOT,xriid,0,KEY_READ,&hkey))
|
|---|
| 237 | {
|
|---|
| 238 | return FALSE;
|
|---|
| 239 | }
|
|---|
| 240 |
|
|---|
| 241 | if (RegQueryValueExA(hkey,"Attributes",0,NULL,(LPBYTE)&attributes,&len))
|
|---|
| 242 | {
|
|---|
| 243 | RegCloseKey(hkey);
|
|---|
| 244 | return FALSE;
|
|---|
| 245 | }
|
|---|
| 246 |
|
|---|
| 247 | RegCloseKey(hkey);
|
|---|
| 248 |
|
|---|
| 249 | TRACE("-- 0x%08lx\n", attributes);
|
|---|
| 250 |
|
|---|
| 251 | *szDest = attributes;
|
|---|
| 252 |
|
|---|
| 253 | return TRUE;
|
|---|
| 254 | }
|
|---|
| 255 |
|
|---|