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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #define NONAMELESSUNION
32 #include "wine/debug.h"
36 #include "wine/unicode.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
44 * This module will be all the helper functions for registry access by the
47 static const WCHAR szUserFeatures_fmt
[] = {
48 'S','o','f','t','w','a','r','e','\\',
49 'M','i','c','r','o','s','o','f','t','\\',
50 'I','n','s','t','a','l','l','e','r','\\',
51 'F','e','a','t','u','r','e','s','\\',
54 static const WCHAR szInstaller_Features
[] = {
55 'S','o','f','t','w','a','r','e','\\',
56 'M','i','c','r','o','s','o','f','t','\\',
57 'W','i','n','d','o','w','s','\\',
58 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
59 'I','n','s','t','a','l','l','e','r','\\',
60 'F','e','a','t','u','r','e','s',0 };
62 static const WCHAR szInstaller_Features_fmt
[] = {
63 'S','o','f','t','w','a','r','e','\\',
64 'M','i','c','r','o','s','o','f','t','\\',
65 'W','i','n','d','o','w','s','\\',
66 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
67 'I','n','s','t','a','l','l','e','r','\\',
68 'F','e','a','t','u','r','e','s','\\',
71 static const WCHAR szInstaller_Components
[] = {
72 'S','o','f','t','w','a','r','e','\\',
73 'M','i','c','r','o','s','o','f','t','\\',
74 'W','i','n','d','o','w','s','\\',
75 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
76 'I','n','s','t','a','l','l','e','r','\\',
77 'C','o','m','p','o','n','e','n','t','s',0 };
79 static const WCHAR szInstaller_Components_fmt
[] = {
80 'S','o','f','t','w','a','r','e','\\',
81 'M','i','c','r','o','s','o','f','t','\\',
82 'W','i','n','d','o','w','s','\\',
83 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
84 'I','n','s','t','a','l','l','e','r','\\',
85 'C','o','m','p','o','n','e','n','t','s','\\',
88 static const WCHAR szUser_Components_fmt
[] = {
89 'S','o','f','t','w','a','r','e','\\',
90 'M','i','c','r','o','s','o','f','t','\\',
91 'I','n','s','t','a','l','l','e','r','\\',
92 'C','o','m','p','o','n','e','n','t','s','\\',
95 static const WCHAR szUninstall_fmt
[] = {
96 'S','o','f','t','w','a','r','e','\\',
97 'M','i','c','r','o','s','o','f','t','\\',
98 'W','i','n','d','o','w','s','\\',
99 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
100 'U','n','i','n','s','t','a','l','l','\\',
103 static const WCHAR szUserProduct_fmt
[] = {
104 'S','o','f','t','w','a','r','e','\\',
105 'M','i','c','r','o','s','o','f','t','\\',
106 'I','n','s','t','a','l','l','e','r','\\',
107 'P','r','o','d','u','c','t','s','\\',
110 static const WCHAR szInstaller_Products
[] = {
111 'S','o','f','t','w','a','r','e','\\',
112 'M','i','c','r','o','s','o','f','t','\\',
113 'W','i','n','d','o','w','s','\\',
114 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
115 'I','n','s','t','a','l','l','e','r','\\',
116 'P','r','o','d','u','c','t','s',0};
118 static const WCHAR szInstaller_Products_fmt
[] = {
119 'S','o','f','t','w','a','r','e','\\',
120 'M','i','c','r','o','s','o','f','t','\\',
121 'W','i','n','d','o','w','s','\\',
122 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
123 'I','n','s','t','a','l','l','e','r','\\',
124 'P','r','o','d','u','c','t','s','\\',
127 static const WCHAR szInstaller_UpgradeCodes
[] = {
128 'S','o','f','t','w','a','r','e','\\',
129 'M','i','c','r','o','s','o','f','t','\\',
130 'W','i','n','d','o','w','s','\\',
131 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
132 'I','n','s','t','a','l','l','e','r','\\',
133 'U','p','g','r','a','d','e','C','o','d','e','s',0};
135 static const WCHAR szInstaller_UpgradeCodes_fmt
[] = {
136 'S','o','f','t','w','a','r','e','\\',
137 'M','i','c','r','o','s','o','f','t','\\',
138 'W','i','n','d','o','w','s','\\',
139 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
140 'I','n','s','t','a','l','l','e','r','\\',
141 'U','p','g','r','a','d','e','C','o','d','e','s','\\',
144 static const WCHAR szInstaller_UserUpgradeCodes
[] = {
145 'S','o','f','t','w','a','r','e','\\',
146 'M','i','c','r','o','s','o','f','t','\\',
147 'I','n','s','t','a','l','l','e','r','\\',
148 'U','p','g','r','a','d','e','C','o','d','e','s',0};
150 static const WCHAR szInstaller_UserUpgradeCodes_fmt
[] = {
151 'S','o','f','t','w','a','r','e','\\',
152 'M','i','c','r','o','s','o','f','t','\\',
153 'I','n','s','t','a','l','l','e','r','\\',
154 'U','p','g','r','a','d','e','C','o','d','e','s','\\',
158 #define SQUISH_GUID_SIZE 33
160 BOOL
unsquash_guid(LPCWSTR in
, LPWSTR out
)
176 out
[n
++] = in
[17+i
*2];
177 out
[n
++] = in
[16+i
*2];
182 out
[n
++] = in
[17+i
*2];
183 out
[n
++] = in
[16+i
*2];
190 BOOL
squash_guid(LPCWSTR in
, LPWSTR out
)
210 out
[17+i
*2] = in
[n
++];
211 out
[16+i
*2] = in
[n
++];
217 out
[17+i
*2] = in
[n
++];
218 out
[16+i
*2] = in
[n
++];
229 /* tables for encoding and decoding base85 */
230 static const unsigned char table_dec85
[0x80] = {
231 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
232 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
233 0xff,0x00,0xff,0xff,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0xff,
234 0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0xff,0xff,0xff,0x16,0xff,0x17,
235 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,
236 0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x32,0x33,0xff,0x34,0x35,0x36,
237 0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,0x40,0x41,0x42,0x43,0x44,0x45,0x46,
238 0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0xff,0x53,0x54,0xff,
241 static const char table_enc85
[] =
242 "!$%&'()*+,-.0123456789=?@ABCDEFGHIJKLMNO"
243 "PQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwx"
247 * Converts a base85 encoded guid into a GUID pointer
248 * Base85 encoded GUIDs should be 20 characters long.
250 * returns TRUE if successful, FALSE if not
252 BOOL
decode_base85_guid( LPCWSTR str
, GUID
*guid
)
254 DWORD i
, val
= 0, base
= 1, *p
;
260 for( i
=0; i
<20; i
++ )
267 val
+= table_dec85
[str
[i
]] * base
;
270 if( table_dec85
[str
[i
]] == 0xff )
280 * Encodes a base85 guid given a GUID pointer
281 * Caller should provide a 21 character buffer for the encoded string.
283 * returns TRUE if successful, FALSE if not
285 BOOL
encode_base85_guid( GUID
*guid
, LPWSTR str
)
287 unsigned int x
, *p
, i
;
289 p
= (unsigned int*) guid
;
293 *str
++ = table_enc85
[x
%85];
295 *str
++ = table_enc85
[x
%85];
297 *str
++ = table_enc85
[x
%85];
299 *str
++ = table_enc85
[x
%85];
301 *str
++ = table_enc85
[x
%85];
309 UINT
MSIREG_OpenUninstallKey(LPCWSTR szProduct
, HKEY
* key
, BOOL create
)
312 WCHAR keypath
[0x200];
313 TRACE("%s\n",debugstr_w(szProduct
));
315 sprintfW(keypath
,szUninstall_fmt
,szProduct
);
318 rc
= RegCreateKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
320 rc
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, keypath
, key
);
325 UINT
MSIREG_OpenUserProductsKey(LPCWSTR szProduct
, HKEY
* key
, BOOL create
)
328 WCHAR squished_pc
[GUID_SIZE
];
329 WCHAR keypath
[0x200];
331 TRACE("%s\n",debugstr_w(szProduct
));
332 squash_guid(szProduct
,squished_pc
);
333 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
335 sprintfW(keypath
,szUserProduct_fmt
,squished_pc
);
338 rc
= RegCreateKeyW(HKEY_CURRENT_USER
,keypath
,key
);
340 rc
= RegOpenKeyW(HKEY_CURRENT_USER
,keypath
,key
);
345 UINT
MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct
, HKEY
* key
, BOOL create
)
348 WCHAR squished_pc
[GUID_SIZE
];
349 WCHAR keypath
[0x200];
351 TRACE("%s\n",debugstr_w(szProduct
));
352 squash_guid(szProduct
,squished_pc
);
353 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
355 sprintfW(keypath
,szUserFeatures_fmt
,squished_pc
);
358 rc
= RegCreateKeyW(HKEY_CURRENT_USER
,keypath
,key
);
360 rc
= RegOpenKeyW(HKEY_CURRENT_USER
,keypath
,key
);
365 UINT
MSIREG_OpenFeatures(HKEY
* key
)
367 return RegCreateKeyW(HKEY_LOCAL_MACHINE
,szInstaller_Features
,key
);
370 UINT
MSIREG_OpenFeaturesKey(LPCWSTR szProduct
, HKEY
* key
, BOOL create
)
373 WCHAR squished_pc
[GUID_SIZE
];
374 WCHAR keypath
[0x200];
376 TRACE("%s\n",debugstr_w(szProduct
));
377 squash_guid(szProduct
,squished_pc
);
378 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
380 sprintfW(keypath
,szInstaller_Features_fmt
,squished_pc
);
383 rc
= RegCreateKeyW(HKEY_LOCAL_MACHINE
,keypath
,key
);
385 rc
= RegOpenKeyW(HKEY_LOCAL_MACHINE
,keypath
,key
);
390 UINT
MSIREG_OpenComponents(HKEY
* key
)
392 return RegCreateKeyW(HKEY_LOCAL_MACHINE
,szInstaller_Components
,key
);
395 UINT
MSIREG_OpenComponentsKey(LPCWSTR szComponent
, HKEY
* key
, BOOL create
)
398 WCHAR squished_cc
[GUID_SIZE
];
399 WCHAR keypath
[0x200];
401 TRACE("%s\n",debugstr_w(szComponent
));
402 squash_guid(szComponent
,squished_cc
);
403 TRACE("squished (%s)\n", debugstr_w(squished_cc
));
405 sprintfW(keypath
,szInstaller_Components_fmt
,squished_cc
);
408 rc
= RegCreateKeyW(HKEY_LOCAL_MACHINE
,keypath
,key
);
410 rc
= RegOpenKeyW(HKEY_LOCAL_MACHINE
,keypath
,key
);
415 UINT
MSIREG_OpenUserComponentsKey(LPCWSTR szComponent
, HKEY
* key
, BOOL create
)
418 WCHAR squished_cc
[GUID_SIZE
];
419 WCHAR keypath
[0x200];
421 TRACE("%s\n",debugstr_w(szComponent
));
422 squash_guid(szComponent
,squished_cc
);
423 TRACE("squished (%s)\n", debugstr_w(squished_cc
));
425 sprintfW(keypath
,szUser_Components_fmt
,squished_cc
);
428 rc
= RegCreateKeyW(HKEY_CURRENT_USER
,keypath
,key
);
430 rc
= RegOpenKeyW(HKEY_CURRENT_USER
,keypath
,key
);
435 UINT
MSIREG_OpenProductsKey(LPCWSTR szProduct
, HKEY
* key
, BOOL create
)
438 WCHAR squished_pc
[GUID_SIZE
];
439 WCHAR keypath
[0x200];
441 TRACE("%s\n",debugstr_w(szProduct
));
442 squash_guid(szProduct
,squished_pc
);
443 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
445 sprintfW(keypath
,szInstaller_Products_fmt
,squished_pc
);
448 rc
= RegCreateKeyW(HKEY_LOCAL_MACHINE
,keypath
,key
);
450 rc
= RegOpenKeyW(HKEY_LOCAL_MACHINE
,keypath
,key
);
455 UINT
MSIREG_OpenUpgradeCodesKey(LPCWSTR szUpgradeCode
, HKEY
* key
, BOOL create
)
458 WCHAR squished_pc
[GUID_SIZE
];
459 WCHAR keypath
[0x200];
461 TRACE("%s\n",debugstr_w(szUpgradeCode
));
462 squash_guid(szUpgradeCode
,squished_pc
);
463 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
465 sprintfW(keypath
,szInstaller_UpgradeCodes_fmt
,squished_pc
);
468 rc
= RegCreateKeyW(HKEY_LOCAL_MACHINE
,keypath
,key
);
470 rc
= RegOpenKeyW(HKEY_LOCAL_MACHINE
,keypath
,key
);
475 UINT
MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szUpgradeCode
, HKEY
* key
, BOOL create
)
478 WCHAR squished_pc
[GUID_SIZE
];
479 WCHAR keypath
[0x200];
481 TRACE("%s\n",debugstr_w(szUpgradeCode
));
482 squash_guid(szUpgradeCode
,squished_pc
);
483 TRACE("squished (%s)\n", debugstr_w(squished_pc
));
485 sprintfW(keypath
,szInstaller_UserUpgradeCodes_fmt
,squished_pc
);
488 rc
= RegCreateKeyW(HKEY_CURRENT_USER
,keypath
,key
);
490 rc
= RegOpenKeyW(HKEY_CURRENT_USER
,keypath
,key
);
496 /*************************************************************************
497 * MsiDecomposeDescriptorW [MSI.@]
499 * Decomposes an MSI descriptor into product, feature and component parts.
500 * An MSI descriptor is a string of the form:
501 * [base 85 guid] [feature code] '>' [base 85 guid]
504 * szDescriptor [I] the descriptor to decompose
505 * szProduct [O] buffer of MAX_FEATURE_CHARS for the product guid
506 * szFeature [O] buffer of MAX_FEATURE_CHARS for the feature code
507 * szComponent [O] buffer of MAX_FEATURE_CHARS for the component guid
508 * pUsed [O] the length of the descriptor
511 * ERROR_SUCCESS if everything worked correctly
512 * ERROR_INVALID_PARAMETER if the descriptor was invalid
515 UINT WINAPI
MsiDecomposeDescriptorW( LPCWSTR szDescriptor
, LPWSTR szProduct
,
516 LPWSTR szFeature
, LPWSTR szComponent
, DWORD
*pUsed
)
520 GUID product
, component
;
522 TRACE("%s %p %p %p %p\n", debugstr_w(szDescriptor
), szProduct
,
523 szFeature
, szComponent
, pUsed
);
525 r
= decode_base85_guid( szDescriptor
, &product
);
527 return ERROR_INVALID_PARAMETER
;
529 TRACE("product %s\n", debugstr_guid( &product
));
531 p
= strchrW(&szDescriptor
[20],'>');
533 return ERROR_INVALID_PARAMETER
;
535 len
= (p
- &szDescriptor
[20]);
536 if( len
> MAX_FEATURE_CHARS
)
537 return ERROR_INVALID_PARAMETER
;
540 memcpy( szFeature
, &szDescriptor
[20], len
*sizeof(WCHAR
) );
544 TRACE("feature %s\n", debugstr_w( &szDescriptor
[20] ));
546 r
= decode_base85_guid( p
+1, &component
);
548 return ERROR_INVALID_PARAMETER
;
550 TRACE("component %s\n", debugstr_guid( &component
));
553 StringFromGUID2( &product
, szProduct
, MAX_FEATURE_CHARS
+1 );
555 StringFromGUID2( &component
, szComponent
, MAX_FEATURE_CHARS
+1 );
556 len
= ( &p
[21] - szDescriptor
);
558 TRACE("length = %d\n", len
);
561 return ERROR_SUCCESS
;
564 UINT WINAPI
MsiDecomposeDescriptorA( LPCSTR szDescriptor
, LPSTR szProduct
,
565 LPSTR szFeature
, LPSTR szComponent
, DWORD
*pUsed
)
567 WCHAR product
[MAX_FEATURE_CHARS
+1];
568 WCHAR feature
[MAX_FEATURE_CHARS
+1];
569 WCHAR component
[MAX_FEATURE_CHARS
+1];
570 LPWSTR str
= NULL
, p
= NULL
, f
= NULL
, c
= NULL
;
573 TRACE("%s %p %p %p %p\n", debugstr_a(szDescriptor
), szProduct
,
574 szFeature
, szComponent
, pUsed
);
576 str
= strdupAtoW( szDescriptor
);
577 if( szDescriptor
&& !str
)
578 return ERROR_OUTOFMEMORY
;
587 r
= MsiDecomposeDescriptorW( str
, p
, f
, c
, pUsed
);
589 WideCharToMultiByte( CP_ACP
, 0, p
, MAX_FEATURE_CHARS
+1,
590 szProduct
, MAX_FEATURE_CHARS
+1, NULL
, NULL
);
591 WideCharToMultiByte( CP_ACP
, 0, f
, MAX_FEATURE_CHARS
+1,
592 szFeature
, MAX_FEATURE_CHARS
+1, NULL
, NULL
);
593 WideCharToMultiByte( CP_ACP
, 0, c
, MAX_FEATURE_CHARS
+1,
594 szComponent
, MAX_FEATURE_CHARS
+1, NULL
, NULL
);
601 UINT WINAPI
MsiEnumProductsA(DWORD index
, LPSTR lpguid
)
604 WCHAR szwGuid
[GUID_SIZE
];
606 TRACE("%ld %p\n",index
,lpguid
);
609 return ERROR_INVALID_PARAMETER
;
610 r
= MsiEnumProductsW(index
, szwGuid
);
611 if( r
== ERROR_SUCCESS
)
612 WideCharToMultiByte(CP_ACP
, 0, szwGuid
, -1, lpguid
, GUID_SIZE
, NULL
, NULL
);
617 UINT WINAPI
MsiEnumProductsW(DWORD index
, LPWSTR lpguid
)
619 HKEY hkeyFeatures
= 0;
621 WCHAR szKeyName
[SQUISH_GUID_SIZE
];
623 TRACE("%ld %p\n",index
,lpguid
);
626 return ERROR_INVALID_PARAMETER
;
628 r
= MSIREG_OpenFeatures(&hkeyFeatures
);
629 if( r
!= ERROR_SUCCESS
)
630 return ERROR_NO_MORE_ITEMS
;
632 r
= RegEnumKeyW(hkeyFeatures
, index
, szKeyName
, SQUISH_GUID_SIZE
);
633 if( r
== ERROR_SUCCESS
)
634 unsquash_guid(szKeyName
, lpguid
);
635 RegCloseKey(hkeyFeatures
);
640 UINT WINAPI
MsiEnumFeaturesA(LPCSTR szProduct
, DWORD index
,
641 LPSTR szFeature
, LPSTR szParent
)
644 WCHAR szwFeature
[GUID_SIZE
], szwParent
[GUID_SIZE
];
645 LPWSTR szwProduct
= NULL
;
647 TRACE("%s %ld %p %p\n",debugstr_a(szProduct
),index
,szFeature
,szParent
);
651 szwProduct
= strdupAtoW( szProduct
);
653 return ERROR_OUTOFMEMORY
;
656 r
= MsiEnumFeaturesW(szwProduct
, index
, szwFeature
, szwParent
);
657 if( r
== ERROR_SUCCESS
)
659 WideCharToMultiByte(CP_ACP
, 0, szwFeature
, -1,
660 szFeature
, GUID_SIZE
, NULL
, NULL
);
661 WideCharToMultiByte(CP_ACP
, 0, szwParent
, -1,
662 szParent
, GUID_SIZE
, NULL
, NULL
);
665 msi_free( szwProduct
);
670 UINT WINAPI
MsiEnumFeaturesW(LPCWSTR szProduct
, DWORD index
,
671 LPWSTR szFeature
, LPWSTR szParent
)
673 HKEY hkeyProduct
= 0;
676 TRACE("%s %ld %p %p\n",debugstr_w(szProduct
),index
,szFeature
,szParent
);
678 r
= MSIREG_OpenFeaturesKey(szProduct
,&hkeyProduct
,FALSE
);
679 if( r
!= ERROR_SUCCESS
)
680 return ERROR_NO_MORE_ITEMS
;
683 r
= RegEnumValueW(hkeyProduct
, index
, szFeature
, &sz
, NULL
, NULL
, NULL
, NULL
);
684 RegCloseKey(hkeyProduct
);
689 UINT WINAPI
MsiEnumComponentsA(DWORD index
, LPSTR lpguid
)
692 WCHAR szwGuid
[GUID_SIZE
];
694 TRACE("%ld %p\n",index
,lpguid
);
696 r
= MsiEnumComponentsW(index
, szwGuid
);
697 if( r
== ERROR_SUCCESS
)
698 WideCharToMultiByte(CP_ACP
, 0, szwGuid
, -1, lpguid
, GUID_SIZE
, NULL
, NULL
);
703 UINT WINAPI
MsiEnumComponentsW(DWORD index
, LPWSTR lpguid
)
705 HKEY hkeyComponents
= 0;
707 WCHAR szKeyName
[SQUISH_GUID_SIZE
];
709 TRACE("%ld %p\n",index
,lpguid
);
711 r
= MSIREG_OpenComponents(&hkeyComponents
);
712 if( r
!= ERROR_SUCCESS
)
713 return ERROR_NO_MORE_ITEMS
;
715 r
= RegEnumKeyW(hkeyComponents
, index
, szKeyName
, SQUISH_GUID_SIZE
);
716 if( r
== ERROR_SUCCESS
)
717 unsquash_guid(szKeyName
, lpguid
);
718 RegCloseKey(hkeyComponents
);
723 UINT WINAPI
MsiEnumClientsA(LPCSTR szComponent
, DWORD index
, LPSTR szProduct
)
726 WCHAR szwProduct
[GUID_SIZE
];
727 LPWSTR szwComponent
= NULL
;
729 TRACE("%s %ld %p\n",debugstr_a(szComponent
),index
,szProduct
);
733 szwComponent
= strdupAtoW( szComponent
);
735 return ERROR_OUTOFMEMORY
;
738 r
= MsiEnumClientsW(szComponent
?szwComponent
:NULL
, index
, szwProduct
);
739 if( r
== ERROR_SUCCESS
)
741 WideCharToMultiByte(CP_ACP
, 0, szwProduct
, -1,
742 szProduct
, GUID_SIZE
, NULL
, NULL
);
745 msi_free( szwComponent
);
750 UINT WINAPI
MsiEnumClientsW(LPCWSTR szComponent
, DWORD index
, LPWSTR szProduct
)
754 WCHAR szValName
[SQUISH_GUID_SIZE
];
756 TRACE("%s %ld %p\n",debugstr_w(szComponent
),index
,szProduct
);
758 r
= MSIREG_OpenComponentsKey(szComponent
,&hkeyComp
,FALSE
);
759 if( r
!= ERROR_SUCCESS
)
760 return ERROR_NO_MORE_ITEMS
;
762 sz
= SQUISH_GUID_SIZE
;
763 r
= RegEnumValueW(hkeyComp
, index
, szValName
, &sz
, NULL
, NULL
, NULL
, NULL
);
764 if( r
== ERROR_SUCCESS
)
765 unsquash_guid(szValName
, szProduct
);
767 RegCloseKey(hkeyComp
);
772 UINT WINAPI
MSI_EnumComponentQualifiers( LPCWSTR szComponent
, DWORD iIndex
,
773 awstring
*lpQualBuf
, DWORD
* pcchQual
,
774 awstring
*lpAppBuf
, DWORD
* pcchAppBuf
)
776 DWORD name_sz
, val_sz
, type
, ofs
;
777 LPWSTR name
= NULL
, val
= NULL
;
781 TRACE("%s %08lx %p %p %p %p\n", debugstr_w(szComponent
), iIndex
,
782 lpQualBuf
, pcchQual
, lpAppBuf
, pcchAppBuf
);
785 return ERROR_INVALID_PARAMETER
;
787 r
= MSIREG_OpenUserComponentsKey( szComponent
, &key
, FALSE
);
788 if (r
!= ERROR_SUCCESS
)
789 return ERROR_UNKNOWN_COMPONENT
;
791 /* figure out how big the name is we want to return */
795 r
= ERROR_OUTOFMEMORY
;
796 name_sz
= *pcchQual
* 4;
797 name
= msi_alloc( name_sz
* sizeof(WCHAR
) );
802 /* figure out how big the value is */
805 r
= RegEnumValueW( key
, iIndex
, NULL
, NULL
,
806 NULL
, &type
, NULL
, &val_sz
);
807 if (r
!= ERROR_SUCCESS
)
810 if (type
!= REG_MULTI_SZ
)
812 ERR("component data has wrong type (%ld)\n", type
);
816 /* the value size is in bytes */
817 val_sz
+= sizeof(WCHAR
);
818 val
= msi_alloc( val_sz
);
822 r
= RegEnumValueW( key
, iIndex
, name
, &name_sz
,
823 NULL
, &type
, (LPBYTE
)val
, &val_sz
);
824 if (r
!= ERROR_SUCCESS
)
828 r
= MsiDecomposeDescriptorW( val
, NULL
, NULL
, NULL
, &ofs
);
829 if (r
!= ERROR_SUCCESS
)
832 TRACE("Providing %s and %s\n", debugstr_w(name
), debugstr_w(val
+ofs
));
834 r
= msi_strcpy_to_awstring( name
, lpQualBuf
, pcchQual
);
835 r2
= msi_strcpy_to_awstring( val
+ofs
, lpAppBuf
, pcchAppBuf
);
837 if (r2
!= ERROR_SUCCESS
)
848 /*************************************************************************
849 * MsiEnumComponentQualifiersA [MSI.@]
851 UINT WINAPI
MsiEnumComponentQualifiersA( LPCSTR szComponent
, DWORD iIndex
,
852 LPSTR lpQualifierBuf
, DWORD
* pcchQualifierBuf
,
853 LPSTR lpApplicationDataBuf
, DWORD
* pcchApplicationDataBuf
)
855 awstring qual
, appdata
;
859 TRACE("%s %08lx %p %p %p %p\n", debugstr_a(szComponent
), iIndex
,
860 lpQualifierBuf
, pcchQualifierBuf
, lpApplicationDataBuf
,
861 pcchApplicationDataBuf
);
863 comp
= strdupAtoW( szComponent
);
864 if (szComponent
&& !comp
)
865 return ERROR_OUTOFMEMORY
;
867 qual
.unicode
= FALSE
;
868 qual
.str
.a
= lpQualifierBuf
;
870 appdata
.unicode
= FALSE
;
871 appdata
.str
.a
= lpApplicationDataBuf
;
873 r
= MSI_EnumComponentQualifiers( comp
, iIndex
,
874 &qual
, pcchQualifierBuf
, &appdata
, pcchApplicationDataBuf
);
879 /*************************************************************************
880 * MsiEnumComponentQualifiersW [MSI.@]
882 UINT WINAPI
MsiEnumComponentQualifiersW( LPCWSTR szComponent
, DWORD iIndex
,
883 LPWSTR lpQualifierBuf
, DWORD
* pcchQualifierBuf
,
884 LPWSTR lpApplicationDataBuf
, DWORD
* pcchApplicationDataBuf
)
886 awstring qual
, appdata
;
888 TRACE("%s %08lx %p %p %p %p\n", debugstr_w(szComponent
), iIndex
,
889 lpQualifierBuf
, pcchQualifierBuf
, lpApplicationDataBuf
,
890 pcchApplicationDataBuf
);
893 qual
.str
.w
= lpQualifierBuf
;
895 appdata
.unicode
= TRUE
;
896 appdata
.str
.w
= lpApplicationDataBuf
;
898 return MSI_EnumComponentQualifiers( szComponent
, iIndex
,
899 &qual
, pcchQualifierBuf
, &appdata
, pcchApplicationDataBuf
);
902 /*************************************************************************
903 * MsiEnumRelatedProductsW [MSI.@]
906 UINT WINAPI
MsiEnumRelatedProductsW(LPCWSTR szUpgradeCode
, DWORD dwReserved
,
907 DWORD iProductIndex
, LPWSTR lpProductBuf
)
911 WCHAR szKeyName
[SQUISH_GUID_SIZE
];
913 TRACE("%s %lu %lu %p\n", debugstr_w(szUpgradeCode
), dwReserved
,
914 iProductIndex
, lpProductBuf
);
916 if (NULL
== szUpgradeCode
)
917 return ERROR_INVALID_PARAMETER
;
918 if (NULL
== lpProductBuf
)
919 return ERROR_INVALID_PARAMETER
;
921 r
= MSIREG_OpenUpgradeCodesKey(szUpgradeCode
, &hkey
, FALSE
);
922 if (r
!= ERROR_SUCCESS
)
923 return ERROR_NO_MORE_ITEMS
;
925 r
= RegEnumKeyW(hkey
, iProductIndex
, szKeyName
, SQUISH_GUID_SIZE
);
926 if( r
== ERROR_SUCCESS
)
927 unsquash_guid(szKeyName
, lpProductBuf
);
933 /*************************************************************************
934 * MsiEnumRelatedProductsA [MSI.@]
937 UINT WINAPI
MsiEnumRelatedProductsA(LPCSTR szUpgradeCode
, DWORD dwReserved
,
938 DWORD iProductIndex
, LPSTR lpProductBuf
)
940 LPWSTR szwUpgradeCode
= NULL
;
941 WCHAR productW
[GUID_SIZE
];
944 TRACE("%s %lu %lu %p\n", debugstr_a(szUpgradeCode
), dwReserved
,
945 iProductIndex
, lpProductBuf
);
949 szwUpgradeCode
= strdupAtoW( szUpgradeCode
);
950 if( !szwUpgradeCode
)
951 return ERROR_OUTOFMEMORY
;
954 r
= MsiEnumRelatedProductsW( szwUpgradeCode
, dwReserved
,
955 iProductIndex
, productW
);
956 if (r
== ERROR_SUCCESS
)
958 WideCharToMultiByte( CP_ACP
, 0, productW
, GUID_SIZE
,
959 lpProductBuf
, GUID_SIZE
, NULL
, NULL
);
961 msi_free( szwUpgradeCode
);