2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2005 Aric Stewart for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #define NONAMELESSUNION
32 #include "wine/debug.h"
36 #include "wine/unicode.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(msi);
45 * This module will be all the helper functions for registry access by the
48 static const WCHAR szUserFeatures_fmt[] = {
49 'S','o','f','t','w','a','r','e','\\',
50 'M','i','c','r','o','s','o','f','t','\\',
51 'I','n','s','t','a','l','l','e','r','\\',
52 'F','e','a','t','u','r','e','s','\\',
55 static const WCHAR szInstaller_Features[] = {
56 'S','o','f','t','w','a','r','e','\\',
57 'M','i','c','r','o','s','o','f','t','\\',
58 'W','i','n','d','o','w','s','\\',
59 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
60 'I','n','s','t','a','l','l','e','r','\\',
61 'F','e','a','t','u','r','e','s',0 };
63 static const WCHAR szUserDataFeatures_fmt[] = {
64 'S','o','f','t','w','a','r','e','\\',
65 'M','i','c','r','o','s','o','f','t','\\',
66 'W','i','n','d','o','w','s','\\',
67 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
68 'I','n','s','t','a','l','l','e','r','\\',
69 'U','s','e','r','D','a','t','a','\\',
70 '%','s','\\','P','r','o','d','u','c','t','s','\\',
71 '%','s','\\','F','e','a','t','u','r','e','s',0};
73 static const WCHAR szInstaller_Features_fmt[] = {
74 'S','o','f','t','w','a','r','e','\\',
75 'M','i','c','r','o','s','o','f','t','\\',
76 'W','i','n','d','o','w','s','\\',
77 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
78 'I','n','s','t','a','l','l','e','r','\\',
79 'F','e','a','t','u','r','e','s','\\',
82 static const WCHAR szInstaller_Components[] = {
83 'S','o','f','t','w','a','r','e','\\',
84 'M','i','c','r','o','s','o','f','t','\\',
85 'W','i','n','d','o','w','s','\\',
86 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
87 'I','n','s','t','a','l','l','e','r','\\',
88 'C','o','m','p','o','n','e','n','t','s',0 };
90 static const WCHAR szInstaller_Components_fmt[] = {
91 'S','o','f','t','w','a','r','e','\\',
92 'M','i','c','r','o','s','o','f','t','\\',
93 'W','i','n','d','o','w','s','\\',
94 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
95 'I','n','s','t','a','l','l','e','r','\\',
96 'C','o','m','p','o','n','e','n','t','s','\\',
99 static const WCHAR szUser_Components_fmt[] = {
100 'S','o','f','t','w','a','r','e','\\',
101 'M','i','c','r','o','s','o','f','t','\\',
102 'I','n','s','t','a','l','l','e','r','\\',
103 'C','o','m','p','o','n','e','n','t','s','\\',
106 static const WCHAR szUserDataComp_fmt[] = {
107 'S','o','f','t','w','a','r','e','\\',
108 'M','i','c','r','o','s','o','f','t','\\',
109 'W','i','n','d','o','w','s','\\',
110 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
111 'I','n','s','t','a','l','l','e','r','\\',
112 'U','s','e','r','D','a','t','a','\\',
113 '%','s','\\','C','o','m','p','o','n','e','n','t','s','\\','%','s',0};
115 static const WCHAR szUninstall_fmt[] = {
116 'S','o','f','t','w','a','r','e','\\',
117 'M','i','c','r','o','s','o','f','t','\\',
118 'W','i','n','d','o','w','s','\\',
119 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
120 'U','n','i','n','s','t','a','l','l','\\',
123 static const WCHAR szUserProduct_fmt[] = {
124 'S','o','f','t','w','a','r','e','\\',
125 'M','i','c','r','o','s','o','f','t','\\',
126 'I','n','s','t','a','l','l','e','r','\\',
127 'P','r','o','d','u','c','t','s','\\',
130 static const WCHAR szUserPatch_fmt[] = {
131 'S','o','f','t','w','a','r','e','\\',
132 'M','i','c','r','o','s','o','f','t','\\',
133 'I','n','s','t','a','l','l','e','r','\\',
134 'P','a','t','c','h','e','s','\\',
137 static const WCHAR szInstaller_Products[] = {
138 'S','o','f','t','w','a','r','e','\\',
139 'M','i','c','r','o','s','o','f','t','\\',
140 'W','i','n','d','o','w','s','\\',
141 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
142 'I','n','s','t','a','l','l','e','r','\\',
143 'P','r','o','d','u','c','t','s',0};
145 static const WCHAR szInstaller_Products_fmt[] = {
146 'S','o','f','t','w','a','r','e','\\',
147 'M','i','c','r','o','s','o','f','t','\\',
148 'W','i','n','d','o','w','s','\\',
149 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
150 'I','n','s','t','a','l','l','e','r','\\',
151 'P','r','o','d','u','c','t','s','\\',
154 static const WCHAR szInstaller_Patches_fmt[] = {
155 'S','o','f','t','w','a','r','e','\\',
156 'M','i','c','r','o','s','o','f','t','\\',
157 'W','i','n','d','o','w','s','\\',
158 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
159 'I','n','s','t','a','l','l','e','r','\\',
160 'P','a','t','c','h','e','s','\\',
163 static const WCHAR szInstaller_UpgradeCodes_fmt[] = {
164 'S','o','f','t','w','a','r','e','\\',
165 'M','i','c','r','o','s','o','f','t','\\',
166 'W','i','n','d','o','w','s','\\',
167 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
168 'I','n','s','t','a','l','l','e','r','\\',
169 'U','p','g','r','a','d','e','C','o','d','e','s','\\',
172 static const WCHAR szInstaller_UserUpgradeCodes_fmt[] = {
173 'S','o','f','t','w','a','r','e','\\',
174 'M','i','c','r','o','s','o','f','t','\\',
175 'I','n','s','t','a','l','l','e','r','\\',
176 'U','p','g','r','a','d','e','C','o','d','e','s','\\',
179 static const WCHAR szUserDataProd_fmt[] = {
180 'S','o','f','t','w','a','r','e','\\',
181 'M','i','c','r','o','s','o','f','t','\\',
182 'W','i','n','d','o','w','s','\\',
183 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
184 'I','n','s','t','a','l','l','e','r','\\',
185 'U','s','e','r','D','a','t','a','\\',
186 '%','s','\\','P','r','o','d','u','c','t','s','\\','%','s',0};
188 static const WCHAR szInstallProperties_fmt[] = {
189 'S','o','f','t','w','a','r','e','\\',
190 'M','i','c','r','o','s','o','f','t','\\',
191 'W','i','n','d','o','w','s','\\',
192 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
193 'I','n','s','t','a','l','l','e','r','\\',
194 'U','s','e','r','D','a','t','a','\\',
195 '%','s','\\','P','r','o','d','u','c','t','s','\\','%','s','\\',
196 'I','n','s','t','a','l','l','P','r','o','p','e','r','t','i','e','s',0};
198 static const WCHAR szInstaller_LocalSystemProductCodes_fmt[] = {
199 'S','o','f','t','w','a','r','e','\\',
200 'M','i','c','r','o','s','o','f','t','\\',
201 'W','i','n','d','o','w','s','\\',
202 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
203 'I','n','s','t','a','l','l','e','r','\\',
204 'U','s','e','r','D','a','t','a','\\',
205 'S','-','1','-','5','-','1','8','\\','P','r','o','d','u','c','t','s','\\',
206 '%','s','\\','I','n','s','t','a','l','l','P','r','o','p','e','r','t','i','e','s',0};
208 static const WCHAR szInstaller_LocalSystemComponent_fmt[] = {
209 'S','o','f','t','w','a','r','e','\\',
210 'M','i','c','r','o','s','o','f','t','\\',
211 'W','i','n','d','o','w','s','\\',
212 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
213 'I','n','s','t','a','l','l','e','r','\\',
214 'U','s','e','r','D','a','t','a','\\',
215 'S','-','1','-','5','-','1','8','\\',
216 'C','o','m','p','o','n','e','n','t','s','\\','%','s',0};
218 static const WCHAR szInstaller_LocalClassesProd_fmt[] = {
219 'S','o','f','t','w','a','r','e','\\',
220 'C','l','a','s','s','e','s','\\',
221 'I','n','s','t','a','l','l','e','r','\\',
222 'P','r','o','d','u','c','t','s','\\','%','s',0};
224 static const WCHAR szInstaller_LocalManagedProd_fmt[] = {
225 'S','o','f','t','w','a','r','e','\\',
226 'M','i','c','r','o','s','o','f','t','\\',
227 'W','i','n','d','o','w','s','\\',
228 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
229 'I','n','s','t','a','l','l','e','r','\\',
230 'M','a','n','a','g','e','d','\\','%','s','\\',
231 'I','n','s','t','a','l','l','e','r','\\',
232 'P','r','o','d','u','c','t','s','\\','%','s',0};
234 #define SQUISH_GUID_SIZE 33
236 BOOL unsquash_guid(LPCWSTR in, LPWSTR out)
252 out[n++] = in[17+i*2];
253 out[n++] = in[16+i*2];
258 out[n++] = in[17+i*2];
259 out[n++] = in[16+i*2];
266 BOOL squash_guid(LPCWSTR in, LPWSTR out)
273 if (FAILED(CLSIDFromString((LPOLESTR)in, &guid)))
287 out[17+i*2] = in[n++];
288 out[16+i*2] = in[n++];
293 out[17+i*2] = in[n++];
294 out[16+i*2] = in[n++];
301 /* tables for encoding and decoding base85 */
302 static const unsigned char table_dec85[0x80] = {
303 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
304 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
305 0xff,0x00,0xff,0xff,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0xff,
306 0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0xff,0xff,0xff,0x16,0xff,0x17,
307 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,
308 0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,0xff,0x34,0x35,0x36,
309 0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,0x40,0x41,0x42,0x43,0x44,0x45,0x46,
310 0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0xff,0x53,0x54,0xff,
313 static const char table_enc85[] =
314 "!$%&'()*+,-.0123456789=?@ABCDEFGHIJKLMNO"
315 "PQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwx"
319 * Converts a base85 encoded guid into a GUID pointer
320 * Base85 encoded GUIDs should be 20 characters long.
322 * returns TRUE if successful, FALSE if not
324 BOOL decode_base85_guid( LPCWSTR str, GUID *guid )
326 DWORD i, val = 0, base = 1, *p;
332 for( i=0; i<20; i++ )
339 val += table_dec85[str[i]] * base;
342 if( table_dec85[str[i]] == 0xff )
352 * Encodes a base85 guid given a GUID pointer
353 * Caller should provide a 21 character buffer for the encoded string.
355 * returns TRUE if successful, FALSE if not
357 BOOL encode_base85_guid( GUID *guid, LPWSTR str )
359 unsigned int x, *p, i;
361 p = (unsigned int*) guid;
365 *str++ = table_enc85[x%85];
367 *str++ = table_enc85[x%85];
369 *str++ = table_enc85[x%85];
371 *str++ = table_enc85[x%85];
373 *str++ = table_enc85[x%85];
380 DWORD msi_version_str_to_dword(LPCWSTR p)
382 DWORD major, minor = 0, build = 0, version = 0;
393 p = strchrW(p+1, '.');
398 return MAKELONG(build, MAKEWORD(minor, major));
401 LPWSTR msi_version_dword_to_str(DWORD version)
403 const WCHAR fmt[] = { '%','u','.','%','u','.','%','u',0 };
404 LPWSTR str = msi_alloc(20);
406 (version&0xff000000)>>24,
407 (version&0x00ff0000)>>16,
412 LONG msi_reg_set_val_str( HKEY hkey, LPCWSTR name, LPCWSTR value )
414 DWORD len = value ? (lstrlenW(value) + 1) * sizeof (WCHAR) : 0;
415 return RegSetValueExW( hkey, name, 0, REG_SZ, (const BYTE *)value, len );
418 LONG msi_reg_set_val_multi_str( HKEY hkey, LPCWSTR name, LPCWSTR value )
421 while (*p) p += lstrlenW(p) + 1;
422 return RegSetValueExW( hkey, name, 0, REG_MULTI_SZ,
423 (const BYTE *)value, (p + 1 - value) * sizeof(WCHAR) );
426 LONG msi_reg_set_val_dword( HKEY hkey, LPCWSTR name, DWORD val )
428 return RegSetValueExW( hkey, name, 0, REG_DWORD, (LPBYTE)&val, sizeof (DWORD) );
431 LONG msi_reg_set_subkey_val( HKEY hkey, LPCWSTR path, LPCWSTR name, LPCWSTR val )
436 r = RegCreateKeyW( hkey, path, &hsubkey );
437 if (r != ERROR_SUCCESS)
439 r = msi_reg_set_val_str( hsubkey, name, val );
440 RegCloseKey( hsubkey );
444 LPWSTR msi_reg_get_val_str( HKEY hkey, LPCWSTR name )
450 r = RegQueryValueExW(hkey, name, NULL, NULL, NULL, &len);
451 if (r != ERROR_SUCCESS)
454 len += sizeof (WCHAR);
455 val = msi_alloc( len );
459 RegQueryValueExW(hkey, name, NULL, NULL, (LPBYTE) val, &len);
463 BOOL msi_reg_get_val_dword( HKEY hkey, LPCWSTR name, DWORD *val)
465 DWORD type, len = sizeof (DWORD);
466 LONG r = RegQueryValueExW(hkey, name, NULL, &type, (LPBYTE) val, &len);
467 return r == ERROR_SUCCESS && type == REG_DWORD;
470 static UINT get_user_sid(LPWSTR *usersid)
477 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
478 return ERROR_FUNCTION_FAILED;
481 if (!GetTokenInformation(token, TokenUser, (void *)buf, size, &size))
482 return ERROR_FUNCTION_FAILED;
484 user = (PTOKEN_USER)buf;
485 if (!ConvertSidToStringSidW(user->User.Sid, usersid))
486 return ERROR_FUNCTION_FAILED;
488 return ERROR_SUCCESS;
491 UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create)
494 WCHAR keypath[0x200];
495 TRACE("%s\n",debugstr_w(szProduct));
497 sprintfW(keypath,szUninstall_fmt,szProduct);
500 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
502 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
507 UINT MSIREG_DeleteUninstallKey(LPCWSTR szProduct)
509 WCHAR keypath[0x200];
510 TRACE("%s\n",debugstr_w(szProduct));
512 sprintfW(keypath,szUninstall_fmt,szProduct);
514 return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
517 UINT MSIREG_OpenUserProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create)
520 WCHAR squished_pc[GUID_SIZE];
521 WCHAR keypath[0x200];
523 TRACE("%s\n",debugstr_w(szProduct));
524 if (!squash_guid(szProduct,squished_pc))
525 return ERROR_FUNCTION_FAILED;
526 TRACE("squished (%s)\n", debugstr_w(squished_pc));
528 sprintfW(keypath,szUserProduct_fmt,squished_pc);
531 rc = RegCreateKeyW(HKEY_CURRENT_USER,keypath,key);
533 rc = RegOpenKeyW(HKEY_CURRENT_USER,keypath,key);
538 UINT MSIREG_DeleteUserProductKey(LPCWSTR szProduct)
540 WCHAR squished_pc[GUID_SIZE];
541 WCHAR keypath[0x200];
543 TRACE("%s\n",debugstr_w(szProduct));
544 if (!squash_guid(szProduct,squished_pc))
545 return ERROR_FUNCTION_FAILED;
546 TRACE("squished (%s)\n", debugstr_w(squished_pc));
548 sprintfW(keypath,szUserProduct_fmt,squished_pc);
550 return RegDeleteTreeW(HKEY_CURRENT_USER, keypath);
553 UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create)
556 WCHAR squished_pc[GUID_SIZE];
557 WCHAR keypath[0x200];
559 TRACE("%s\n",debugstr_w(szPatch));
560 if (!squash_guid(szPatch,squished_pc))
561 return ERROR_FUNCTION_FAILED;
562 TRACE("squished (%s)\n", debugstr_w(squished_pc));
564 sprintfW(keypath,szUserPatch_fmt,squished_pc);
567 rc = RegCreateKeyW(HKEY_CURRENT_USER,keypath,key);
569 rc = RegOpenKeyW(HKEY_CURRENT_USER,keypath,key);
574 UINT MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create)
577 WCHAR squished_pc[GUID_SIZE];
578 WCHAR keypath[0x200];
580 TRACE("%s\n",debugstr_w(szProduct));
581 if (!squash_guid(szProduct,squished_pc))
582 return ERROR_FUNCTION_FAILED;
583 TRACE("squished (%s)\n", debugstr_w(squished_pc));
585 sprintfW(keypath,szUserFeatures_fmt,squished_pc);
588 rc = RegCreateKeyW(HKEY_CURRENT_USER,keypath,key);
590 rc = RegOpenKeyW(HKEY_CURRENT_USER,keypath,key);
595 UINT MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct)
597 WCHAR squished_pc[GUID_SIZE];
598 WCHAR keypath[0x200];
600 TRACE("%s\n",debugstr_w(szProduct));
601 if (!squash_guid(szProduct,squished_pc))
602 return ERROR_FUNCTION_FAILED;
603 TRACE("squished (%s)\n", debugstr_w(squished_pc));
605 sprintfW(keypath,szUserFeatures_fmt,squished_pc);
606 return RegDeleteTreeW(HKEY_CURRENT_USER, keypath);
609 UINT MSIREG_OpenFeatures(HKEY* key)
611 return RegCreateKeyW(HKEY_LOCAL_MACHINE,szInstaller_Features,key);
614 UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create)
617 WCHAR squished_pc[GUID_SIZE];
618 WCHAR keypath[0x200];
620 TRACE("%s\n",debugstr_w(szProduct));
621 if (!squash_guid(szProduct,squished_pc))
622 return ERROR_FUNCTION_FAILED;
623 TRACE("squished (%s)\n", debugstr_w(squished_pc));
625 sprintfW(keypath,szInstaller_Features_fmt,squished_pc);
628 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE,keypath,key);
630 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,keypath,key);
635 UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create)
638 WCHAR squished_pc[GUID_SIZE];
639 WCHAR keypath[0x200];
642 TRACE("%s\n", debugstr_w(szProduct));
643 if (!squash_guid(szProduct, squished_pc))
644 return ERROR_FUNCTION_FAILED;
645 TRACE("squished (%s)\n", debugstr_w(squished_pc));
647 rc = get_user_sid(&usersid);
648 if (rc != ERROR_SUCCESS || !usersid)
650 ERR("Failed to retrieve user SID: %d\n", rc);
654 sprintfW(keypath, szUserDataFeatures_fmt, usersid, squished_pc);
657 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
659 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
665 UINT MSIREG_OpenComponents(HKEY* key)
667 return RegCreateKeyW(HKEY_LOCAL_MACHINE,szInstaller_Components,key);
670 UINT MSIREG_OpenComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create)
673 WCHAR squished_cc[GUID_SIZE];
674 WCHAR keypath[0x200];
676 TRACE("%s\n",debugstr_w(szComponent));
677 if (!squash_guid(szComponent,squished_cc))
678 return ERROR_FUNCTION_FAILED;
679 TRACE("squished (%s)\n", debugstr_w(squished_cc));
681 sprintfW(keypath,szInstaller_Components_fmt,squished_cc);
684 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE,keypath,key);
686 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,keypath,key);
691 UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create)
694 WCHAR squished_cc[GUID_SIZE];
695 WCHAR keypath[0x200];
697 TRACE("%s\n",debugstr_w(szComponent));
698 if (!squash_guid(szComponent,squished_cc))
699 return ERROR_FUNCTION_FAILED;
700 TRACE("squished (%s)\n", debugstr_w(squished_cc));
702 sprintfW(keypath,szUser_Components_fmt,squished_cc);
705 rc = RegCreateKeyW(HKEY_CURRENT_USER,keypath,key);
707 rc = RegOpenKeyW(HKEY_CURRENT_USER,keypath,key);
712 UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create)
715 WCHAR comp[GUID_SIZE];
716 WCHAR keypath[0x200];
719 TRACE("%s\n", debugstr_w(szComponent));
720 if (!squash_guid(szComponent, comp))
721 return ERROR_FUNCTION_FAILED;
722 TRACE("squished (%s)\n", debugstr_w(comp));
724 rc = get_user_sid(&usersid);
725 if (rc != ERROR_SUCCESS || !usersid)
727 ERR("Failed to retrieve user SID: %d\n", rc);
731 sprintfW(keypath, szUserDataComp_fmt, usersid, comp);
734 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
736 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
742 UINT MSIREG_DeleteUserDataComponentKey(LPCWSTR szComponent)
745 WCHAR comp[GUID_SIZE];
746 WCHAR keypath[0x200];
749 TRACE("%s\n", debugstr_w(szComponent));
750 if (!squash_guid(szComponent, comp))
751 return ERROR_FUNCTION_FAILED;
752 TRACE("squished (%s)\n", debugstr_w(comp));
754 rc = get_user_sid(&usersid);
755 if (rc != ERROR_SUCCESS || !usersid)
757 ERR("Failed to retrieve user SID: %d\n", rc);
761 sprintfW(keypath, szUserDataComp_fmt, usersid, comp);
763 return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
766 UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, HKEY *key, BOOL create)
769 WCHAR squished_pc[GUID_SIZE];
770 WCHAR keypath[0x200];
773 TRACE("%s\n", debugstr_w(szProduct));
774 if (!squash_guid(szProduct, squished_pc))
775 return ERROR_FUNCTION_FAILED;
776 TRACE("squished (%s)\n", debugstr_w(squished_pc));
778 rc = get_user_sid(&usersid);
779 if (rc != ERROR_SUCCESS || !usersid)
781 ERR("Failed to retrieve user SID: %d\n", rc);
785 sprintfW(keypath, szUserDataProd_fmt, usersid, squished_pc);
788 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
790 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
796 UINT MSIREG_OpenInstallPropertiesKey(LPCWSTR szProduct, HKEY *key, BOOL create)
799 WCHAR squished_pc[GUID_SIZE];
800 WCHAR keypath[0x200];
803 TRACE("%s\n", debugstr_w(szProduct));
804 if (!squash_guid(szProduct, squished_pc))
805 return ERROR_FUNCTION_FAILED;
806 TRACE("squished (%s)\n", debugstr_w(squished_pc));
808 rc = get_user_sid(&usersid);
809 if (rc != ERROR_SUCCESS || !usersid)
811 ERR("Failed to retrieve user SID: %d\n", rc);
815 sprintfW(keypath, szInstallProperties_fmt, usersid, squished_pc);
818 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
820 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
826 UINT MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct)
829 WCHAR squished_pc[GUID_SIZE];
830 WCHAR keypath[0x200];
833 TRACE("%s\n", debugstr_w(szProduct));
834 if (!squash_guid(szProduct, squished_pc))
835 return ERROR_FUNCTION_FAILED;
836 TRACE("squished (%s)\n", debugstr_w(squished_pc));
838 rc = get_user_sid(&usersid);
839 if (rc != ERROR_SUCCESS || !usersid)
841 ERR("Failed to retrieve user SID: %d\n", rc);
845 sprintfW(keypath, szUserDataProd_fmt, usersid, squished_pc);
848 return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
851 UINT MSIREG_OpenProducts(HKEY* key)
853 return RegCreateKeyW(HKEY_LOCAL_MACHINE,szInstaller_Products,key);
856 UINT MSIREG_OpenProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create)
859 WCHAR squished_pc[GUID_SIZE];
860 WCHAR keypath[0x200];
862 TRACE("%s\n",debugstr_w(szProduct));
863 if (!squash_guid(szProduct,squished_pc))
864 return ERROR_FUNCTION_FAILED;
865 TRACE("squished (%s)\n", debugstr_w(squished_pc));
867 sprintfW(keypath,szInstaller_Products_fmt,squished_pc);
870 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE,keypath,key);
872 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,keypath,key);
877 UINT MSIREG_DeleteProductKey(LPCWSTR szProduct)
879 WCHAR squished_pc[GUID_SIZE];
880 WCHAR keypath[0x200];
882 TRACE("%s\n", debugstr_w(szProduct));
883 if (!squash_guid(szProduct, squished_pc))
884 return ERROR_FUNCTION_FAILED;
885 TRACE("squished (%s)\n", debugstr_w(squished_pc));
887 sprintfW(keypath, szInstaller_Products_fmt, squished_pc);
889 return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
892 UINT MSIREG_OpenPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create)
895 WCHAR squished_pc[GUID_SIZE];
896 WCHAR keypath[0x200];
898 TRACE("%s\n",debugstr_w(szPatch));
899 if (!squash_guid(szPatch,squished_pc))
900 return ERROR_FUNCTION_FAILED;
901 TRACE("squished (%s)\n", debugstr_w(squished_pc));
903 sprintfW(keypath,szInstaller_Patches_fmt,squished_pc);
906 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE,keypath,key);
908 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,keypath,key);
913 UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY* key, BOOL create)
916 WCHAR squished_pc[GUID_SIZE];
917 WCHAR keypath[0x200];
919 TRACE("%s\n",debugstr_w(szUpgradeCode));
920 if (!squash_guid(szUpgradeCode,squished_pc))
921 return ERROR_FUNCTION_FAILED;
922 TRACE("squished (%s)\n", debugstr_w(squished_pc));
924 sprintfW(keypath,szInstaller_UpgradeCodes_fmt,squished_pc);
927 rc = RegCreateKeyW(HKEY_LOCAL_MACHINE,keypath,key);
929 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,keypath,key);
934 UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY* key, BOOL create)
937 WCHAR squished_pc[GUID_SIZE];
938 WCHAR keypath[0x200];
940 TRACE("%s\n",debugstr_w(szUpgradeCode));
941 if (!squash_guid(szUpgradeCode,squished_pc))
942 return ERROR_FUNCTION_FAILED;
943 TRACE("squished (%s)\n", debugstr_w(squished_pc));
945 sprintfW(keypath,szInstaller_UserUpgradeCodes_fmt,squished_pc);
948 rc = RegCreateKeyW(HKEY_CURRENT_USER,keypath,key);
950 rc = RegOpenKeyW(HKEY_CURRENT_USER,keypath,key);
955 UINT MSIREG_OpenLocalSystemProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create)
957 WCHAR squished_pc[GUID_SIZE];
958 WCHAR keypath[0x200];
960 TRACE("%s\n", debugstr_w(szProductCode));
962 if (!squash_guid(szProductCode, squished_pc))
963 return ERROR_FUNCTION_FAILED;
965 TRACE("squished (%s)\n", debugstr_w(squished_pc));
967 sprintfW(keypath, szInstaller_LocalSystemProductCodes_fmt, squished_pc);
970 return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
972 return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
975 UINT MSIREG_OpenLocalSystemComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create)
977 WCHAR squished_pc[GUID_SIZE];
978 WCHAR keypath[0x200];
980 TRACE("%s\n", debugstr_w(szComponent));
982 if (!squash_guid(szComponent, squished_pc))
983 return ERROR_FUNCTION_FAILED;
985 TRACE("squished (%s)\n", debugstr_w(squished_pc));
987 sprintfW(keypath, szInstaller_LocalSystemComponent_fmt, squished_pc);
990 return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
992 return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
995 UINT MSIREG_OpenLocalClassesProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create)
997 WCHAR squished_pc[GUID_SIZE];
998 WCHAR keypath[0x200];
1000 TRACE("%s\n", debugstr_w(szProductCode));
1002 if (!squash_guid(szProductCode, squished_pc))
1003 return ERROR_FUNCTION_FAILED;
1005 TRACE("squished (%s)\n", debugstr_w(squished_pc));
1007 sprintfW(keypath, szInstaller_LocalClassesProd_fmt, squished_pc);
1010 return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
1012 return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
1015 UINT MSIREG_OpenLocalManagedProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create)
1017 WCHAR squished_pc[GUID_SIZE];
1018 WCHAR keypath[0x200];
1022 TRACE("%s\n", debugstr_w(szProductCode));
1024 if (!squash_guid(szProductCode, squished_pc))
1025 return ERROR_FUNCTION_FAILED;
1027 TRACE("squished (%s)\n", debugstr_w(squished_pc));
1029 r = get_user_sid(&usersid);
1030 if (r != ERROR_SUCCESS || !usersid)
1032 ERR("Failed to retrieve user SID: %d\n", r);
1036 sprintfW(keypath, szInstaller_LocalManagedProd_fmt, usersid, squished_pc);
1040 return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
1042 return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
1045 /*************************************************************************
1046 * MsiDecomposeDescriptorW [MSI.@]
1048 * Decomposes an MSI descriptor into product, feature and component parts.
1049 * An MSI descriptor is a string of the form:
1050 * [base 85 guid] [feature code] '>' [base 85 guid]
1053 * szDescriptor [I] the descriptor to decompose
1054 * szProduct [O] buffer of MAX_FEATURE_CHARS+1 for the product guid
1055 * szFeature [O] buffer of MAX_FEATURE_CHARS+1 for the feature code
1056 * szComponent [O] buffer of MAX_FEATURE_CHARS+1 for the component guid
1057 * pUsed [O] the length of the descriptor
1060 * ERROR_SUCCESS if everything worked correctly
1061 * ERROR_INVALID_PARAMETER if the descriptor was invalid
1064 UINT WINAPI MsiDecomposeDescriptorW( LPCWSTR szDescriptor, LPWSTR szProduct,
1065 LPWSTR szFeature, LPWSTR szComponent, LPDWORD pUsed )
1069 GUID product, component;
1071 TRACE("%s %p %p %p %p\n", debugstr_w(szDescriptor), szProduct,
1072 szFeature, szComponent, pUsed);
1074 r = decode_base85_guid( szDescriptor, &product );
1076 return ERROR_INVALID_PARAMETER;
1078 TRACE("product %s\n", debugstr_guid( &product ));
1080 p = strchrW(&szDescriptor[20],'>');
1082 return ERROR_INVALID_PARAMETER;
1084 len = (p - &szDescriptor[20]);
1085 if( len > MAX_FEATURE_CHARS )
1086 return ERROR_INVALID_PARAMETER;
1088 TRACE("feature %s\n", debugstr_wn( &szDescriptor[20], len ));
1090 r = decode_base85_guid( p+1, &component );
1092 return ERROR_INVALID_PARAMETER;
1094 TRACE("component %s\n", debugstr_guid( &component ));
1097 StringFromGUID2( &product, szProduct, MAX_FEATURE_CHARS+1 );
1099 StringFromGUID2( &component, szComponent, MAX_FEATURE_CHARS+1 );
1102 memcpy( szFeature, &szDescriptor[20], len*sizeof(WCHAR) );
1105 len = ( &p[21] - szDescriptor );
1107 TRACE("length = %d\n", len);
1110 return ERROR_SUCCESS;
1113 UINT WINAPI MsiDecomposeDescriptorA( LPCSTR szDescriptor, LPSTR szProduct,
1114 LPSTR szFeature, LPSTR szComponent, LPDWORD pUsed )
1116 WCHAR product[MAX_FEATURE_CHARS+1];
1117 WCHAR feature[MAX_FEATURE_CHARS+1];
1118 WCHAR component[MAX_FEATURE_CHARS+1];
1119 LPWSTR str = NULL, p = NULL, f = NULL, c = NULL;
1122 TRACE("%s %p %p %p %p\n", debugstr_a(szDescriptor), szProduct,
1123 szFeature, szComponent, pUsed);
1125 str = strdupAtoW( szDescriptor );
1126 if( szDescriptor && !str )
1127 return ERROR_OUTOFMEMORY;
1136 r = MsiDecomposeDescriptorW( str, p, f, c, pUsed );
1138 if (r == ERROR_SUCCESS)
1140 WideCharToMultiByte( CP_ACP, 0, p, -1,
1141 szProduct, MAX_FEATURE_CHARS+1, NULL, NULL );
1142 WideCharToMultiByte( CP_ACP, 0, f, -1,
1143 szFeature, MAX_FEATURE_CHARS+1, NULL, NULL );
1144 WideCharToMultiByte( CP_ACP, 0, c, -1,
1145 szComponent, MAX_FEATURE_CHARS+1, NULL, NULL );
1153 UINT WINAPI MsiEnumProductsA(DWORD index, LPSTR lpguid)
1156 WCHAR szwGuid[GUID_SIZE];
1158 TRACE("%d %p\n", index, lpguid);
1161 return ERROR_INVALID_PARAMETER;
1162 r = MsiEnumProductsW(index, szwGuid);
1163 if( r == ERROR_SUCCESS )
1164 WideCharToMultiByte(CP_ACP, 0, szwGuid, -1, lpguid, GUID_SIZE, NULL, NULL);
1169 UINT WINAPI MsiEnumProductsW(DWORD index, LPWSTR lpguid)
1171 HKEY hkeyProducts = 0;
1173 WCHAR szKeyName[SQUISH_GUID_SIZE];
1175 TRACE("%d %p\n", index, lpguid);
1178 return ERROR_INVALID_PARAMETER;
1180 r = MSIREG_OpenProducts(&hkeyProducts);
1181 if( r != ERROR_SUCCESS )
1182 return ERROR_NO_MORE_ITEMS;
1184 r = RegEnumKeyW(hkeyProducts, index, szKeyName, SQUISH_GUID_SIZE);
1185 if( r == ERROR_SUCCESS )
1186 unsquash_guid(szKeyName, lpguid);
1187 RegCloseKey(hkeyProducts);
1192 UINT WINAPI MsiEnumFeaturesA(LPCSTR szProduct, DWORD index,
1193 LPSTR szFeature, LPSTR szParent)
1196 WCHAR szwFeature[GUID_SIZE], szwParent[GUID_SIZE];
1197 LPWSTR szwProduct = NULL;
1199 TRACE("%s %d %p %p\n", debugstr_a(szProduct), index, szFeature, szParent);
1203 szwProduct = strdupAtoW( szProduct );
1205 return ERROR_OUTOFMEMORY;
1208 r = MsiEnumFeaturesW(szwProduct, index, szwFeature, szwParent);
1209 if( r == ERROR_SUCCESS )
1211 WideCharToMultiByte(CP_ACP, 0, szwFeature, -1,
1212 szFeature, GUID_SIZE, NULL, NULL);
1213 WideCharToMultiByte(CP_ACP, 0, szwParent, -1,
1214 szParent, GUID_SIZE, NULL, NULL);
1217 msi_free( szwProduct);
1222 UINT WINAPI MsiEnumFeaturesW(LPCWSTR szProduct, DWORD index,
1223 LPWSTR szFeature, LPWSTR szParent)
1225 HKEY hkeyProduct = 0;
1228 TRACE("%s %d %p %p\n", debugstr_w(szProduct), index, szFeature, szParent);
1231 return ERROR_INVALID_PARAMETER;
1233 r = MSIREG_OpenFeaturesKey(szProduct,&hkeyProduct,FALSE);
1234 if( r != ERROR_SUCCESS )
1235 return ERROR_NO_MORE_ITEMS;
1238 r = RegEnumValueW(hkeyProduct, index, szFeature, &sz, NULL, NULL, NULL, NULL);
1239 RegCloseKey(hkeyProduct);
1244 UINT WINAPI MsiEnumComponentsA(DWORD index, LPSTR lpguid)
1247 WCHAR szwGuid[GUID_SIZE];
1249 TRACE("%d %p\n", index, lpguid);
1251 r = MsiEnumComponentsW(index, szwGuid);
1252 if( r == ERROR_SUCCESS )
1253 WideCharToMultiByte(CP_ACP, 0, szwGuid, -1, lpguid, GUID_SIZE, NULL, NULL);
1258 UINT WINAPI MsiEnumComponentsW(DWORD index, LPWSTR lpguid)
1260 HKEY hkeyComponents = 0;
1262 WCHAR szKeyName[SQUISH_GUID_SIZE];
1264 TRACE("%d %p\n", index, lpguid);
1266 r = MSIREG_OpenComponents(&hkeyComponents);
1267 if( r != ERROR_SUCCESS )
1268 return ERROR_NO_MORE_ITEMS;
1270 r = RegEnumKeyW(hkeyComponents, index, szKeyName, SQUISH_GUID_SIZE);
1271 if( r == ERROR_SUCCESS )
1272 unsquash_guid(szKeyName, lpguid);
1273 RegCloseKey(hkeyComponents);
1278 UINT WINAPI MsiEnumClientsA(LPCSTR szComponent, DWORD index, LPSTR szProduct)
1281 WCHAR szwProduct[GUID_SIZE];
1282 LPWSTR szwComponent = NULL;
1284 TRACE("%s %d %p\n", debugstr_a(szComponent), index, szProduct);
1288 szwComponent = strdupAtoW( szComponent );
1290 return ERROR_OUTOFMEMORY;
1293 r = MsiEnumClientsW(szComponent?szwComponent:NULL, index, szwProduct);
1294 if( r == ERROR_SUCCESS )
1296 WideCharToMultiByte(CP_ACP, 0, szwProduct, -1,
1297 szProduct, GUID_SIZE, NULL, NULL);
1300 msi_free( szwComponent);
1305 UINT WINAPI MsiEnumClientsW(LPCWSTR szComponent, DWORD index, LPWSTR szProduct)
1309 WCHAR szValName[SQUISH_GUID_SIZE];
1311 TRACE("%s %d %p\n", debugstr_w(szComponent), index, szProduct);
1313 r = MSIREG_OpenComponentsKey(szComponent,&hkeyComp,FALSE);
1314 if( r != ERROR_SUCCESS )
1315 return ERROR_NO_MORE_ITEMS;
1317 sz = SQUISH_GUID_SIZE;
1318 r = RegEnumValueW(hkeyComp, index, szValName, &sz, NULL, NULL, NULL, NULL);
1319 if( r == ERROR_SUCCESS )
1320 unsquash_guid(szValName, szProduct);
1322 RegCloseKey(hkeyComp);
1327 static UINT WINAPI MSI_EnumComponentQualifiers( LPCWSTR szComponent, DWORD iIndex,
1328 awstring *lpQualBuf, LPDWORD pcchQual,
1329 awstring *lpAppBuf, LPDWORD pcchAppBuf )
1331 DWORD name_sz, val_sz, name_max, val_max, type, ofs;
1332 LPWSTR name = NULL, val = NULL;
1336 TRACE("%s %08x %p %p %p %p\n", debugstr_w(szComponent), iIndex,
1337 lpQualBuf, pcchQual, lpAppBuf, pcchAppBuf);
1340 return ERROR_INVALID_PARAMETER;
1342 r = MSIREG_OpenUserComponentsKey( szComponent, &key, FALSE );
1343 if (r != ERROR_SUCCESS)
1344 return ERROR_UNKNOWN_COMPONENT;
1346 /* figure out how big the name is we want to return */
1348 r = ERROR_OUTOFMEMORY;
1349 name = msi_alloc( name_max * sizeof(WCHAR) );
1354 r = ERROR_OUTOFMEMORY;
1355 val = msi_alloc( val_max );
1359 /* loop until we allocate enough memory */
1364 r = RegEnumValueW( key, iIndex, name, &name_sz,
1365 NULL, &type, (LPBYTE)val, &val_sz );
1366 if (r == ERROR_SUCCESS)
1368 if (r != ERROR_MORE_DATA)
1371 if (type != REG_MULTI_SZ)
1373 ERR("component data has wrong type (%d)\n", type);
1377 r = ERROR_OUTOFMEMORY;
1378 if ((name_sz+1) >= name_max)
1382 name = msi_alloc( name_max * sizeof (WCHAR) );
1387 if (val_sz > val_max)
1389 val_max = val_sz + sizeof (WCHAR);
1391 val = msi_alloc( val_max * sizeof (WCHAR) );
1396 ERR("should be enough data, but isn't %d %d\n", name_sz, val_sz );
1401 r = MsiDecomposeDescriptorW( val, NULL, NULL, NULL, &ofs );
1402 if (r != ERROR_SUCCESS)
1405 TRACE("Providing %s and %s\n", debugstr_w(name), debugstr_w(val+ofs));
1407 r = msi_strcpy_to_awstring( name, lpQualBuf, pcchQual );
1408 r2 = msi_strcpy_to_awstring( val+ofs, lpAppBuf, pcchAppBuf );
1410 if (r2 != ERROR_SUCCESS)
1421 /*************************************************************************
1422 * MsiEnumComponentQualifiersA [MSI.@]
1424 UINT WINAPI MsiEnumComponentQualifiersA( LPCSTR szComponent, DWORD iIndex,
1425 LPSTR lpQualifierBuf, LPDWORD pcchQualifierBuf,
1426 LPSTR lpApplicationDataBuf, LPDWORD pcchApplicationDataBuf )
1428 awstring qual, appdata;
1432 TRACE("%s %08x %p %p %p %p\n", debugstr_a(szComponent), iIndex,
1433 lpQualifierBuf, pcchQualifierBuf, lpApplicationDataBuf,
1434 pcchApplicationDataBuf);
1436 comp = strdupAtoW( szComponent );
1437 if (szComponent && !comp)
1438 return ERROR_OUTOFMEMORY;
1440 qual.unicode = FALSE;
1441 qual.str.a = lpQualifierBuf;
1443 appdata.unicode = FALSE;
1444 appdata.str.a = lpApplicationDataBuf;
1446 r = MSI_EnumComponentQualifiers( comp, iIndex,
1447 &qual, pcchQualifierBuf, &appdata, pcchApplicationDataBuf );
1452 /*************************************************************************
1453 * MsiEnumComponentQualifiersW [MSI.@]
1455 UINT WINAPI MsiEnumComponentQualifiersW( LPCWSTR szComponent, DWORD iIndex,
1456 LPWSTR lpQualifierBuf, LPDWORD pcchQualifierBuf,
1457 LPWSTR lpApplicationDataBuf, LPDWORD pcchApplicationDataBuf )
1459 awstring qual, appdata;
1461 TRACE("%s %08x %p %p %p %p\n", debugstr_w(szComponent), iIndex,
1462 lpQualifierBuf, pcchQualifierBuf, lpApplicationDataBuf,
1463 pcchApplicationDataBuf);
1465 qual.unicode = TRUE;
1466 qual.str.w = lpQualifierBuf;
1468 appdata.unicode = TRUE;
1469 appdata.str.w = lpApplicationDataBuf;
1471 return MSI_EnumComponentQualifiers( szComponent, iIndex,
1472 &qual, pcchQualifierBuf, &appdata, pcchApplicationDataBuf );
1475 /*************************************************************************
1476 * MsiEnumRelatedProductsW [MSI.@]
1479 UINT WINAPI MsiEnumRelatedProductsW(LPCWSTR szUpgradeCode, DWORD dwReserved,
1480 DWORD iProductIndex, LPWSTR lpProductBuf)
1484 DWORD dwSize = SQUISH_GUID_SIZE;
1485 WCHAR szKeyName[SQUISH_GUID_SIZE];
1487 TRACE("%s %u %u %p\n", debugstr_w(szUpgradeCode), dwReserved,
1488 iProductIndex, lpProductBuf);
1490 if (NULL == szUpgradeCode)
1491 return ERROR_INVALID_PARAMETER;
1492 if (NULL == lpProductBuf)
1493 return ERROR_INVALID_PARAMETER;
1495 r = MSIREG_OpenUpgradeCodesKey(szUpgradeCode, &hkey, FALSE);
1496 if (r != ERROR_SUCCESS)
1497 return ERROR_NO_MORE_ITEMS;
1499 r = RegEnumValueW(hkey, iProductIndex, szKeyName, &dwSize, NULL, NULL, NULL, NULL);
1500 if( r == ERROR_SUCCESS )
1501 unsquash_guid(szKeyName, lpProductBuf);
1507 /*************************************************************************
1508 * MsiEnumRelatedProductsA [MSI.@]
1511 UINT WINAPI MsiEnumRelatedProductsA(LPCSTR szUpgradeCode, DWORD dwReserved,
1512 DWORD iProductIndex, LPSTR lpProductBuf)
1514 LPWSTR szwUpgradeCode = NULL;
1515 WCHAR productW[GUID_SIZE];
1518 TRACE("%s %u %u %p\n", debugstr_a(szUpgradeCode), dwReserved,
1519 iProductIndex, lpProductBuf);
1523 szwUpgradeCode = strdupAtoW( szUpgradeCode );
1524 if( !szwUpgradeCode )
1525 return ERROR_OUTOFMEMORY;
1528 r = MsiEnumRelatedProductsW( szwUpgradeCode, dwReserved,
1529 iProductIndex, productW );
1530 if (r == ERROR_SUCCESS)
1532 WideCharToMultiByte( CP_ACP, 0, productW, GUID_SIZE,
1533 lpProductBuf, GUID_SIZE, NULL, NULL );
1535 msi_free( szwUpgradeCode);
1539 /***********************************************************************
1540 * MsiEnumPatchesA [MSI.@]
1542 UINT WINAPI MsiEnumPatchesA( LPCSTR szProduct, DWORD iPatchIndex,
1543 LPSTR lpPatchBuf, LPSTR lpTransformsBuf, LPDWORD pcchTransformsBuf)
1545 FIXME("%s %d %p %p %p\n", debugstr_a(szProduct),
1546 iPatchIndex, lpPatchBuf, lpTransformsBuf, pcchTransformsBuf);
1547 return ERROR_NO_MORE_ITEMS;
1550 /***********************************************************************
1551 * MsiEnumPatchesW [MSI.@]
1553 UINT WINAPI MsiEnumPatchesW( LPCWSTR szProduct, DWORD iPatchIndex,
1554 LPWSTR lpPatchBuf, LPWSTR lpTransformsBuf, LPDWORD pcchTransformsBuf)
1556 FIXME("%s %d %p %p %p\n", debugstr_w(szProduct),
1557 iPatchIndex, lpPatchBuf, lpTransformsBuf, pcchTransformsBuf);
1558 return ERROR_NO_MORE_ITEMS;
1561 UINT WINAPI MsiEnumProductsExA( LPCSTR szProductCode, LPCSTR szUserSid,
1562 DWORD dwContext, DWORD dwIndex, CHAR szInstalledProductCode[39],
1563 MSIINSTALLCONTEXT* pdwInstalledContext, LPSTR szSid, LPDWORD pcchSid)
1565 FIXME("%s %s %d %d %p %p %p %p\n", debugstr_a(szProductCode), debugstr_a(szUserSid),
1566 dwContext, dwIndex, szInstalledProductCode, pdwInstalledContext,
1568 return ERROR_NO_MORE_ITEMS;
1571 UINT WINAPI MsiEnumProductsExW( LPCWSTR szProductCode, LPCWSTR szUserSid,
1572 DWORD dwContext, DWORD dwIndex, WCHAR szInstalledProductCode[39],
1573 MSIINSTALLCONTEXT* pdwInstalledContext, LPWSTR szSid, LPDWORD pcchSid)
1575 FIXME("%s %s %d %d %p %p %p %p\n", debugstr_w(szProductCode), debugstr_w(szUserSid),
1576 dwContext, dwIndex, szInstalledProductCode, pdwInstalledContext,
1578 return ERROR_NO_MORE_ITEMS;