2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2005 Aric Stewart for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Here are helper functions formally in action.c that are used by a variaty of
23 * actions and functions.
31 #include "wine/debug.h"
34 #include "wine/unicode.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
39 static const WCHAR cszTargetDir
[] = {'T','A','R','G','E','T','D','I','R',0};
40 static const WCHAR cszDatabase
[]={'D','A','T','A','B','A','S','E',0};
42 const WCHAR cszSourceDir
[] = {'S','o','u','r','c','e','D','i','r',0};
43 const WCHAR cszRootDrive
[] = {'R','O','O','T','D','R','I','V','E',0};
44 const WCHAR cszbs
[]={'\\',0};
46 DWORD
build_version_dword(LPCWSTR version_string
)
50 DWORD rc
= 0x00000000;
53 ptr1
= version_string
;
62 ptr1
= strchrW(ptr1
,'.');
72 ptr1
= strchrW(ptr1
,'.');
82 rc
= MAKELONG(build
,MAKEWORD(minor
,major
));
83 TRACE("%s -> 0x%lx\n",debugstr_w(version_string
),rc
);
87 LPWSTR
build_icon_path(MSIPACKAGE
*package
, LPCWSTR icon_name
)
89 LPWSTR SystemFolder
, dest
, FilePath
;
91 static const WCHAR szInstaller
[] =
92 {'M','i','c','r','o','s','o','f','t','\\',
93 'I','n','s','t','a','l','l','e','r','\\',0};
94 static const WCHAR szFolder
[] =
95 {'A','p','p','D','a','t','a','F','o','l','d','e','r',0};
97 SystemFolder
= msi_dup_property( package
, szFolder
);
99 dest
= build_directory_name(3, SystemFolder
, szInstaller
, package
->ProductCode
);
101 create_full_pathW(dest
);
103 FilePath
= build_directory_name(2, dest
, icon_name
);
105 msi_free(SystemFolder
);
110 LPWSTR
msi_dup_record_field( MSIRECORD
*row
, INT index
)
112 return strdupW( MSI_RecordGetString(row
,index
) );
115 LPWSTR
msi_dup_property(MSIPACKAGE
*package
, LPCWSTR prop
)
121 r
= MSI_GetPropertyW(package
, prop
, NULL
, &sz
);
122 if (r
!= ERROR_SUCCESS
&& r
!= ERROR_MORE_DATA
)
126 str
= msi_alloc(sz
*sizeof(WCHAR
));
127 r
= MSI_GetPropertyW(package
, prop
, str
, &sz
);
128 if (r
!= ERROR_SUCCESS
)
136 MSICOMPONENT
* get_loaded_component( MSIPACKAGE
* package
, LPCWSTR Component
)
140 LIST_FOR_EACH_ENTRY( comp
, &package
->components
, MSICOMPONENT
, entry
)
142 if (lstrcmpW(Component
,comp
->Component
)==0)
148 MSIFEATURE
* get_loaded_feature(MSIPACKAGE
* package
, LPCWSTR Feature
)
152 LIST_FOR_EACH_ENTRY( feature
, &package
->features
, MSIFEATURE
, entry
)
154 if (lstrcmpW( Feature
, feature
->Feature
)==0)
160 MSIFILE
* get_loaded_file( MSIPACKAGE
* package
, LPCWSTR key
)
164 LIST_FOR_EACH_ENTRY( file
, &package
->files
, MSIFILE
, entry
)
166 if (lstrcmpW( key
, file
->File
)==0)
172 int track_tempfile( MSIPACKAGE
*package
, LPCWSTR name
, LPCWSTR path
)
176 LIST_FOR_EACH_ENTRY( temp
, &package
->tempfiles
, MSITEMPFILE
, entry
)
178 if (lstrcmpW( name
, temp
->File
)==0)
180 TRACE("tempfile %s already exists with path %s\n",
181 debugstr_w(temp
->File
), debugstr_w(temp
->Path
));
186 temp
= msi_alloc_zero( sizeof (MSITEMPFILE
) );
190 list_add_head( &package
->tempfiles
, &temp
->entry
);
192 temp
->File
= strdupW( name
);
193 temp
->Path
= strdupW( path
);
195 TRACE("adding tempfile %s with path %s\n",
196 debugstr_w(temp
->File
), debugstr_w(temp
->Path
));
201 MSIFOLDER
*get_loaded_folder( MSIPACKAGE
*package
, LPCWSTR dir
)
205 LIST_FOR_EACH_ENTRY( folder
, &package
->folders
, MSIFOLDER
, entry
)
207 if (lstrcmpW( dir
, folder
->Directory
)==0)
213 static LPWSTR
get_source_root( MSIPACKAGE
*package
)
217 path
= msi_dup_property( package
, cszSourceDir
);
221 path
= msi_dup_property( package
, cszDatabase
);
224 p
= strrchrW(path
,'\\');
231 LPWSTR
resolve_folder(MSIPACKAGE
*package
, LPCWSTR name
, BOOL source
,
232 BOOL set_prop
, MSIFOLDER
**folder
)
235 LPWSTR p
, path
= NULL
;
237 TRACE("Working to resolve %s\n",debugstr_w(name
));
242 /* special resolving for Target and Source root dir */
243 if (strcmpW(name
,cszTargetDir
)==0 || strcmpW(name
,cszSourceDir
)==0)
248 check_path
= msi_dup_property( package
, cszTargetDir
);
251 check_path
= msi_dup_property( package
, cszRootDrive
);
253 MSI_SetPropertyW(package
,cszTargetDir
,check_path
);
256 /* correct misbuilt target dir */
257 path
= build_directory_name(2, check_path
, NULL
);
258 if (strcmpiW(path
,check_path
)!=0)
259 MSI_SetPropertyW(package
,cszTargetDir
,path
);
260 msi_free(check_path
);
263 path
= get_source_root( package
);
265 *folder
= get_loaded_folder( package
, name
);
269 f
= get_loaded_folder( package
, name
);
276 if (!source
&& f
->ResolvedTarget
)
278 path
= strdupW( f
->ResolvedTarget
);
279 TRACE(" already resolved to %s\n",debugstr_w(path
));
282 else if (source
&& f
->ResolvedSource
)
284 path
= strdupW( f
->ResolvedSource
);
285 TRACE(" (source)already resolved to %s\n",debugstr_w(path
));
288 else if (!source
&& f
->Property
)
290 path
= build_directory_name( 2, f
->Property
, NULL
);
292 TRACE(" internally set to %s\n",debugstr_w(path
));
294 MSI_SetPropertyW( package
, name
, path
);
300 LPWSTR parent
= f
->Parent
->Directory
;
302 TRACE(" ! Parent is %s\n", debugstr_w(parent
));
304 p
= resolve_folder(package
, parent
, source
, set_prop
, NULL
);
307 TRACE(" TargetDefault = %s\n", debugstr_w(f
->TargetDefault
));
309 path
= build_directory_name( 3, p
, f
->TargetDefault
, NULL
);
310 f
->ResolvedTarget
= strdupW( path
);
311 TRACE("target -> %s\n", debugstr_w(path
));
313 MSI_SetPropertyW(package
,name
,path
);
317 if (f
->SourceDefault
&& f
->SourceDefault
[0]!='.')
318 path
= build_directory_name( 3, p
, f
->SourceDefault
, NULL
);
321 TRACE("source -> %s\n", debugstr_w(path
));
323 /* if the directory doesn't exist, use the root */
324 if (INVALID_FILE_ATTRIBUTES
== GetFileAttributesW( path
))
327 path
= get_source_root( package
);
328 TRACE("defaulting to %s\n", debugstr_w(path
));
331 f
->ResolvedSource
= strdupW( path
);
338 /* wrapper to resist a need for a full rewrite right now */
339 DWORD
deformat_string(MSIPACKAGE
*package
, LPCWSTR ptr
, WCHAR
** data
)
343 MSIRECORD
*rec
= MSI_CreateRecord(1);
346 MSI_RecordSetStringW(rec
,0,ptr
);
347 MSI_FormatRecordW(package
,rec
,NULL
,&size
);
351 *data
= msi_alloc(size
*sizeof(WCHAR
));
353 MSI_FormatRecordW(package
,rec
,*data
,&size
);
356 msiobj_release( &rec
->hdr
);
357 return sizeof(WCHAR
)*size
;
359 msiobj_release( &rec
->hdr
);
366 UINT
schedule_action(MSIPACKAGE
*package
, UINT script
, LPCWSTR action
)
369 LPWSTR
*newbuf
= NULL
;
370 if (script
>= TOTAL_SCRIPTS
)
372 FIXME("Unknown script requested %i\n",script
);
373 return ERROR_FUNCTION_FAILED
;
375 TRACE("Scheduling Action %s in script %i\n",debugstr_w(action
), script
);
377 count
= package
->script
->ActionCount
[script
];
378 package
->script
->ActionCount
[script
]++;
380 newbuf
= msi_realloc( package
->script
->Actions
[script
],
381 package
->script
->ActionCount
[script
]* sizeof(LPWSTR
));
383 newbuf
= msi_alloc( sizeof(LPWSTR
));
385 newbuf
[count
] = strdupW(action
);
386 package
->script
->Actions
[script
] = newbuf
;
388 return ERROR_SUCCESS
;
391 static void remove_tracked_tempfiles(MSIPACKAGE
* package
)
393 struct list
*item
, *cursor
;
395 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->tempfiles
)
397 MSITEMPFILE
*temp
= LIST_ENTRY( item
, MSITEMPFILE
, entry
);
399 list_remove( &temp
->entry
);
400 TRACE("deleting temp file %s\n", debugstr_w( temp
->Path
));
401 DeleteFileW( temp
->Path
);
402 msi_free( temp
->File
);
403 msi_free( temp
->Path
);
408 static void free_feature( MSIFEATURE
*feature
)
410 struct list
*item
, *cursor
;
412 LIST_FOR_EACH_SAFE( item
, cursor
, &feature
->Components
)
414 ComponentList
*cl
= LIST_ENTRY( item
, ComponentList
, entry
);
415 list_remove( &cl
->entry
);
418 msi_free( feature
->Feature
);
419 msi_free( feature
->Feature_Parent
);
420 msi_free( feature
->Directory
);
421 msi_free( feature
->Description
);
422 msi_free( feature
->Title
);
426 void free_extension( MSIEXTENSION
*ext
)
428 struct list
*item
, *cursor
;
430 LIST_FOR_EACH_SAFE( item
, cursor
, &ext
->verbs
)
432 MSIVERB
*verb
= LIST_ENTRY( item
, MSIVERB
, entry
);
434 list_remove( &verb
->entry
);
435 msi_free( verb
->Verb
);
436 msi_free( verb
->Command
);
437 msi_free( verb
->Argument
);
441 msi_free( ext
->Extension
);
442 msi_free( ext
->ProgIDText
);
446 /* Called when the package is being closed */
447 void ACTION_free_package_structures( MSIPACKAGE
* package
)
450 struct list
*item
, *cursor
;
452 TRACE("Freeing package action data\n");
454 remove_tracked_tempfiles(package
);
456 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->features
)
458 MSIFEATURE
*feature
= LIST_ENTRY( item
, MSIFEATURE
, entry
);
459 list_remove( &feature
->entry
);
460 free_feature( feature
);
463 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->folders
)
465 MSIFOLDER
*folder
= LIST_ENTRY( item
, MSIFOLDER
, entry
);
467 list_remove( &folder
->entry
);
468 msi_free( folder
->Directory
);
469 msi_free( folder
->TargetDefault
);
470 msi_free( folder
->SourceDefault
);
471 msi_free( folder
->ResolvedTarget
);
472 msi_free( folder
->ResolvedSource
);
473 msi_free( folder
->Property
);
477 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->components
)
479 MSICOMPONENT
*comp
= LIST_ENTRY( item
, MSICOMPONENT
, entry
);
481 list_remove( &comp
->entry
);
482 msi_free( comp
->Component
);
483 msi_free( comp
->ComponentId
);
484 msi_free( comp
->Directory
);
485 msi_free( comp
->Condition
);
486 msi_free( comp
->KeyPath
);
487 msi_free( comp
->FullKeypath
);
491 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->files
)
493 MSIFILE
*file
= LIST_ENTRY( item
, MSIFILE
, entry
);
495 list_remove( &file
->entry
);
496 msi_free( file
->File
);
497 msi_free( file
->FileName
);
498 msi_free( file
->ShortName
);
499 msi_free( file
->Version
);
500 msi_free( file
->Language
);
501 msi_free( file
->SourcePath
);
502 msi_free( file
->TargetPath
);
506 /* clean up extension, progid, class and verb structures */
507 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->classes
)
509 MSICLASS
*cls
= LIST_ENTRY( item
, MSICLASS
, entry
);
511 list_remove( &cls
->entry
);
512 msi_free( cls
->clsid
);
513 msi_free( cls
->Context
);
514 msi_free( cls
->Description
);
515 msi_free( cls
->FileTypeMask
);
516 msi_free( cls
->IconPath
);
517 msi_free( cls
->DefInprocHandler
);
518 msi_free( cls
->DefInprocHandler32
);
519 msi_free( cls
->Argument
);
520 msi_free( cls
->ProgIDText
);
524 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->extensions
)
526 MSIEXTENSION
*ext
= LIST_ENTRY( item
, MSIEXTENSION
, entry
);
528 list_remove( &ext
->entry
);
529 free_extension( ext
);
532 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->progids
)
534 MSIPROGID
*progid
= LIST_ENTRY( item
, MSIPROGID
, entry
);
536 list_remove( &progid
->entry
);
537 msi_free( progid
->ProgID
);
538 msi_free( progid
->Description
);
539 msi_free( progid
->IconPath
);
543 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->mimes
)
545 MSIMIME
*mt
= LIST_ENTRY( item
, MSIMIME
, entry
);
547 list_remove( &mt
->entry
);
548 msi_free( mt
->clsid
);
549 msi_free( mt
->ContentType
);
553 LIST_FOR_EACH_SAFE( item
, cursor
, &package
->appids
)
555 MSIAPPID
*appid
= LIST_ENTRY( item
, MSIAPPID
, entry
);
557 list_remove( &appid
->entry
);
558 msi_free( appid
->AppID
);
559 msi_free( appid
->RemoteServerName
);
560 msi_free( appid
->LocalServer
);
561 msi_free( appid
->ServiceParameters
);
562 msi_free( appid
->DllSurrogate
);
568 for (i
= 0; i
< TOTAL_SCRIPTS
; i
++)
571 for (j
= 0; j
< package
->script
->ActionCount
[i
]; j
++)
572 msi_free(package
->script
->Actions
[i
][j
]);
574 msi_free(package
->script
->Actions
[i
]);
577 for (i
= 0; i
< package
->script
->UniqueActionsCount
; i
++)
578 msi_free(package
->script
->UniqueActions
[i
]);
580 msi_free(package
->script
->UniqueActions
);
581 msi_free(package
->script
);
584 msi_free(package
->PackagePath
);
585 msi_free(package
->ProductCode
);
586 msi_free(package
->ActionFormat
);
587 msi_free(package
->LastAction
);
589 /* cleanup control event subscriptions */
590 ControlEvent_CleanupSubscriptions(package
);
594 * build_directory_name()
596 * This function is to save messing round with directory names
597 * It handles adding backslashes between path segments,
598 * and can add \ at the end of the directory name if told to.
600 * It takes a variable number of arguments.
601 * It always allocates a new string for the result, so make sure
602 * to free the return value when finished with it.
604 * The first arg is the number of path segments that follow.
605 * The arguments following count are a list of path segments.
606 * A path segment may be NULL.
608 * Path segments will be added with a \ separating them.
609 * A \ will not be added after the last segment, however if the
610 * last segment is NULL, then the last character will be a \
613 LPWSTR
build_directory_name(DWORD count
, ...)
620 for(i
=0; i
<count
; i
++)
622 LPCWSTR str
= va_arg(va
,LPCWSTR
);
624 sz
+= strlenW(str
) + 1;
628 dir
= msi_alloc(sz
*sizeof(WCHAR
));
632 for(i
=0; i
<count
; i
++)
634 LPCWSTR str
= va_arg(va
,LPCWSTR
);
638 if( ((i
+1)!=count
) && dir
[strlenW(dir
)-1]!='\\')
644 /***********************************************************************
647 * Recursively create all directories in the path.
649 * shamelessly stolen from setupapi/queue.c
651 BOOL
create_full_pathW(const WCHAR
*path
)
657 new_path
= msi_alloc( (strlenW(path
) + 1) * sizeof(WCHAR
));
659 strcpyW(new_path
, path
);
661 while((len
= strlenW(new_path
)) && new_path
[len
- 1] == '\\')
662 new_path
[len
- 1] = 0;
664 while(!CreateDirectoryW(new_path
, NULL
))
667 DWORD last_error
= GetLastError();
668 if(last_error
== ERROR_ALREADY_EXISTS
)
671 if(last_error
!= ERROR_PATH_NOT_FOUND
)
677 if(!(slash
= strrchrW(new_path
, '\\')))
683 len
= slash
- new_path
;
685 if(!create_full_pathW(new_path
))
690 new_path
[len
] = '\\';
697 void ui_progress(MSIPACKAGE
*package
, int a
, int b
, int c
, int d
)
701 row
= MSI_CreateRecord(4);
702 MSI_RecordSetInteger(row
,1,a
);
703 MSI_RecordSetInteger(row
,2,b
);
704 MSI_RecordSetInteger(row
,3,c
);
705 MSI_RecordSetInteger(row
,4,d
);
706 MSI_ProcessMessage(package
, INSTALLMESSAGE_PROGRESS
, row
);
707 msiobj_release(&row
->hdr
);
709 msi_dialog_check_messages(NULL
);
712 void ui_actiondata(MSIPACKAGE
*package
, LPCWSTR action
, MSIRECORD
* record
)
714 static const WCHAR Query_t
[] =
715 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
716 '`','A','c','t','i','o', 'n','T','e','x','t','`',' ',
717 'W','H','E','R','E',' ', '`','A','c','t','i','o','n','`',' ','=',
718 ' ','\'','%','s','\'',0};
722 static const WCHAR szActionData
[] =
723 {'A','c','t','i','o','n','D','a','t','a',0};
725 if (!package
->LastAction
|| strcmpW(package
->LastAction
,action
))
727 row
= MSI_QueryGetRecord(package
->db
, Query_t
, action
);
731 if (MSI_RecordIsNull(row
,3))
733 msiobj_release(&row
->hdr
);
737 /* update the cached actionformat */
738 msi_free(package
->ActionFormat
);
739 package
->ActionFormat
= msi_dup_record_field(row
,3);
741 msi_free(package
->LastAction
);
742 package
->LastAction
= strdupW(action
);
744 msiobj_release(&row
->hdr
);
747 MSI_RecordSetStringW(record
,0,package
->ActionFormat
);
749 MSI_FormatRecordW(package
,record
,message
,&size
);
751 row
= MSI_CreateRecord(1);
752 MSI_RecordSetStringW(row
,1,message
);
754 MSI_ProcessMessage(package
, INSTALLMESSAGE_ACTIONDATA
, row
);
756 ControlEvent_FireSubscribedEvent(package
,szActionData
, row
);
758 msiobj_release(&row
->hdr
);
761 BOOL
ACTION_VerifyComponentForAction( MSICOMPONENT
* comp
, INSTALLSTATE check
)
766 if (comp
->Installed
== check
)
769 if (comp
->ActionRequest
== check
)
775 BOOL
ACTION_VerifyFeatureForAction( MSIFEATURE
* feature
, INSTALLSTATE check
)
780 if (feature
->Installed
== check
)
783 if (feature
->ActionRequest
== check
)
789 void reduce_to_longfilename(WCHAR
* filename
)
791 LPWSTR p
= strchrW(filename
,'|');
793 memmove(filename
, p
+1, (strlenW(p
+1)+1)*sizeof(WCHAR
));
796 void reduce_to_shortfilename(WCHAR
* filename
)
798 LPWSTR p
= strchrW(filename
,'|');
803 LPWSTR
create_component_advertise_string(MSIPACKAGE
* package
,
804 MSICOMPONENT
* component
, LPCWSTR feature
)
807 WCHAR productid_85
[21];
808 WCHAR component_85
[21];
810 * I have a fair bit of confusion as to when a < is used and when a > is
811 * used. I do not think i have it right...
813 * Ok it appears that the > is used if there is a guid for the compoenent
814 * and the < is used if not.
816 static WCHAR fmt1
[] = {'%','s','%','s','<',0,0};
817 static WCHAR fmt2
[] = {'%','s','%','s','>','%','s',0,0};
818 LPWSTR output
= NULL
;
821 memset(productid_85
,0,sizeof(productid_85
));
822 memset(component_85
,0,sizeof(component_85
));
824 CLSIDFromString(package
->ProductCode
, &clsid
);
826 encode_base85_guid(&clsid
,productid_85
);
828 CLSIDFromString(component
->ComponentId
, &clsid
);
829 encode_base85_guid(&clsid
,component_85
);
831 TRACE("Doing something with this... %s %s %s\n",
832 debugstr_w(productid_85
), debugstr_w(feature
),
833 debugstr_w(component_85
));
835 sz
= lstrlenW(productid_85
) + lstrlenW(feature
);
837 sz
+= lstrlenW(component_85
);
842 output
= msi_alloc(sz
);
846 sprintfW(output
,fmt2
,productid_85
,feature
,component_85
);
848 sprintfW(output
,fmt1
,productid_85
,feature
);
853 /* update compoennt state based on a feature change */
854 void ACTION_UpdateComponentStates(MSIPACKAGE
*package
, LPCWSTR szFeature
)
856 INSTALLSTATE newstate
;
860 feature
= get_loaded_feature(package
,szFeature
);
864 newstate
= feature
->ActionRequest
;
866 LIST_FOR_EACH_ENTRY( cl
, &feature
->Components
, ComponentList
, entry
)
868 MSICOMPONENT
* component
= cl
->component
;
870 TRACE("MODIFYING(%i): Component %s (Installed %i, Action %i, Request %i)\n",
871 newstate
, debugstr_w(component
->Component
), component
->Installed
,
872 component
->Action
, component
->ActionRequest
);
874 if (!component
->Enabled
)
877 if (newstate
== INSTALLSTATE_LOCAL
)
879 component
->ActionRequest
= INSTALLSTATE_LOCAL
;
880 component
->Action
= INSTALLSTATE_LOCAL
;
884 ComponentList
*clist
;
887 component
->ActionRequest
= newstate
;
888 component
->Action
= newstate
;
890 /*if any other feature wants is local we need to set it local*/
891 LIST_FOR_EACH_ENTRY( f
, &package
->features
, MSIFEATURE
, entry
)
893 if ( component
->ActionRequest
!= INSTALLSTATE_LOCAL
)
896 LIST_FOR_EACH_ENTRY( clist
, &f
->Components
, ComponentList
, entry
)
898 if ( clist
->component
== component
)
900 if (f
->ActionRequest
== INSTALLSTATE_LOCAL
)
902 TRACE("Saved by %s\n", debugstr_w(f
->Feature
));
903 component
->ActionRequest
= INSTALLSTATE_LOCAL
;
904 component
->Action
= INSTALLSTATE_LOCAL
;
911 TRACE("Result (%i): Component %s (Installed %i, Action %i, Request %i)\n",
912 newstate
, debugstr_w(component
->Component
), component
->Installed
,
913 component
->Action
, component
->ActionRequest
);
917 UINT
register_unique_action(MSIPACKAGE
*package
, LPCWSTR action
)
920 LPWSTR
*newbuf
= NULL
;
922 if (!package
->script
)
925 TRACE("Registering Action %s as having fun\n",debugstr_w(action
));
927 count
= package
->script
->UniqueActionsCount
;
928 package
->script
->UniqueActionsCount
++;
930 newbuf
= msi_realloc( package
->script
->UniqueActions
,
931 package
->script
->UniqueActionsCount
* sizeof(LPWSTR
));
933 newbuf
= msi_alloc( sizeof(LPWSTR
));
935 newbuf
[count
] = strdupW(action
);
936 package
->script
->UniqueActions
= newbuf
;
938 return ERROR_SUCCESS
;
941 BOOL
check_unique_action(MSIPACKAGE
*package
, LPCWSTR action
)
945 if (!package
->script
)
948 for (i
= 0; i
< package
->script
->UniqueActionsCount
; i
++)
949 if (!strcmpW(package
->script
->UniqueActions
[i
],action
))
955 WCHAR
* generate_error_string(MSIPACKAGE
*package
, UINT error
, DWORD count
, ... )
957 static const WCHAR query
[] = {'S','E','L','E','C','T',' ','`','M','e','s','s','a','g','e','`',' ','F','R','O','M',' ','`','E','r','r','o','r','`',' ','W','H','E','R','E',' ','`','E','r','r','o','r','`',' ','=',' ','%','i',0};
967 row
= MSI_QueryGetRecord(package
->db
, query
, error
);
971 rec
= MSI_CreateRecord(count
+2);
973 str
= MSI_RecordGetString(row
,1);
974 MSI_RecordSetStringW(rec
,0,str
);
975 msiobj_release( &row
->hdr
);
976 MSI_RecordSetInteger(rec
,1,error
);
979 for (i
= 0; i
< count
; i
++)
981 str
= va_arg(va
,LPCWSTR
);
982 MSI_RecordSetStringW(rec
,(i
+2),str
);
986 MSI_FormatRecordW(package
,rec
,NULL
,&size
);
990 data
= msi_alloc(size
*sizeof(WCHAR
));
992 MSI_FormatRecordW(package
,rec
,data
,&size
);
995 msiobj_release( &rec
->hdr
);
999 msiobj_release( &rec
->hdr
);