| 1 | /* $Id: classes.cpp,v 1.1 1999-10-09 11:13:18 sandervl 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 | */
|
|---|
| 11 |
|
|---|
| 12 | /*
|
|---|
| 13 | * file type mapping
|
|---|
| 14 | * (HKEY_CLASSES_ROOT - Stuff)
|
|---|
| 15 | */
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 | /*****************************************************************************
|
|---|
| 19 | * Includes *
|
|---|
| 20 | *****************************************************************************/
|
|---|
| 21 |
|
|---|
| 22 | #include <stdlib.h>
|
|---|
| 23 | #include <string.h>
|
|---|
| 24 | #include <odin.h>
|
|---|
| 25 | #include <odinwrap.h>
|
|---|
| 26 | #include <os2sel.h>
|
|---|
| 27 |
|
|---|
| 28 | #define ICOM_CINTERFACE 1
|
|---|
| 29 | #define CINTERFACE 1
|
|---|
| 30 |
|
|---|
| 31 | #include "debugtools.h"
|
|---|
| 32 | #include "winerror.h"
|
|---|
| 33 | #include "winreg.h"
|
|---|
| 34 |
|
|---|
| 35 | #include "shlobj.h"
|
|---|
| 36 | #include "shell32_main.h"
|
|---|
| 37 | #include "shlguid.h"
|
|---|
| 38 | #include "shresdef.h"
|
|---|
| 39 |
|
|---|
| 40 | #include <misc.h>
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 | /*****************************************************************************
|
|---|
| 44 | * Local Variables *
|
|---|
| 45 | *****************************************************************************/
|
|---|
| 46 |
|
|---|
| 47 | ODINDEBUGCHANNEL(shell32-classes)
|
|---|
| 48 |
|
|---|
| 49 | #define MAX_EXTENSION_LENGTH 20
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 | /*****************************************************************************
|
|---|
| 53 | * Implementation *
|
|---|
| 54 | *****************************************************************************/
|
|---|
| 55 |
|
|---|
| 56 | BOOL HCR_MapTypeToValue ( LPCSTR szExtension, LPSTR szFileType, LONG len, BOOL bPrependDot)
|
|---|
| 57 | {
|
|---|
| 58 | HKEY hkey;
|
|---|
| 59 | char szTemp[MAX_EXTENSION_LENGTH + 2];
|
|---|
| 60 |
|
|---|
| 61 | dprintf(("SHELL32:classes:HCR_MapTypeToValue(%s,%08xh,%08xh,%08xh)\n",
|
|---|
| 62 | szExtension,
|
|---|
| 63 | szFileType,
|
|---|
| 64 | len,
|
|---|
| 65 | bPrependDot));
|
|---|
| 66 |
|
|---|
| 67 | if (bPrependDot)
|
|---|
| 68 | strcpy(szTemp, ".");
|
|---|
| 69 |
|
|---|
| 70 | lstrcpynA(szTemp+((bPrependDot)?1:0), szExtension, MAX_EXTENSION_LENGTH);
|
|---|
| 71 |
|
|---|
| 72 | if (RegOpenKeyExA(HKEY_CLASSES_ROOT,szTemp,0,0x02000000,&hkey))
|
|---|
| 73 | { return FALSE;
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | if (RegQueryValueA(hkey,NULL,szFileType,&len))
|
|---|
| 77 | { RegCloseKey(hkey);
|
|---|
| 78 | return FALSE;
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | RegCloseKey(hkey);
|
|---|
| 82 |
|
|---|
| 83 | TRACE("-- %s\n", szFileType );
|
|---|
| 84 |
|
|---|
| 85 | return TRUE;
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 | BOOL HCR_GetExecuteCommand ( LPCSTR szClass, LPCSTR szVerb, LPSTR szDest, LONG 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,&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, LONG 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,&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, &IID_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 | BOOL HCR_GetFolderAttributes (REFIID riid, LPDWORD szDest)
|
|---|
| 214 | {
|
|---|
| 215 | HKEY hkey;
|
|---|
| 216 | char xriid[60];
|
|---|
| 217 | DWORD attributes;
|
|---|
| 218 | DWORD len = 4;
|
|---|
| 219 |
|
|---|
| 220 | dprintf(("SHELL32:classes:HCR_GetFolderAttributes(%08xh,%08xh)\n",
|
|---|
| 221 | riid,
|
|---|
| 222 | szDest));
|
|---|
| 223 |
|
|---|
| 224 | strcpy(xriid,"CLSID\\");
|
|---|
| 225 | WINE_StringFromCLSID(riid,&xriid[strlen(xriid)]);
|
|---|
| 226 | TRACE("%s\n",xriid );
|
|---|
| 227 |
|
|---|
| 228 | strcat (xriid, "\\ShellFolder");
|
|---|
| 229 |
|
|---|
| 230 | if (RegOpenKeyExA(HKEY_CLASSES_ROOT,xriid,0,KEY_READ,&hkey))
|
|---|
| 231 | {
|
|---|
| 232 | return FALSE;
|
|---|
| 233 | }
|
|---|
| 234 |
|
|---|
| 235 | if (RegQueryValueExA(hkey,"Attributes",0,NULL,(LPBYTE)&attributes,&len))
|
|---|
| 236 | {
|
|---|
| 237 | RegCloseKey(hkey);
|
|---|
| 238 | return FALSE;
|
|---|
| 239 | }
|
|---|
| 240 |
|
|---|
| 241 | RegCloseKey(hkey);
|
|---|
| 242 |
|
|---|
| 243 | TRACE("-- 0x%08lx\n", attributes);
|
|---|
| 244 |
|
|---|
| 245 | *szDest = attributes;
|
|---|
| 246 |
|
|---|
| 247 | return TRUE;
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|