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 UINT build_icon_path(MSIPACKAGE *package, LPCWSTR icon_name,
93 static const WCHAR szInstaller[] =
94 {'M','i','c','r','o','s','o','f','t','\\',
95 'I','n','s','t','a','l','l','e','r','\\',0};
96 static const WCHAR szFolder[] =
97 {'A','p','p','D','a','t','a','F','o','l','d','e','r',0};
99 SystemFolder = load_dynamic_property(package,szFolder,NULL);
101 dest = build_directory_name(3, SystemFolder, szInstaller, package->ProductCode);
103 create_full_pathW(dest);
105 *FilePath = build_directory_name(2, dest, icon_name);
107 HeapFree(GetProcessHeap(),0,SystemFolder);
108 HeapFree(GetProcessHeap(),0,dest);
109 return ERROR_SUCCESS;
112 WCHAR *load_dynamic_stringW(MSIRECORD *row, INT index)
119 if (MSI_RecordIsNull(row,index))
122 rc = MSI_RecordGetStringW(row,index,NULL,&sz);
124 /* having an empty string is different than NULL */
127 ret = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR));
133 ret = HeapAlloc(GetProcessHeap(),0,sz * sizeof (WCHAR));
134 rc = MSI_RecordGetStringW(row,index,ret,&sz);
135 if (rc!=ERROR_SUCCESS)
137 ERR("Unable to load dynamic string\n");
138 HeapFree(GetProcessHeap(), 0, ret);
144 LPWSTR load_dynamic_property(MSIPACKAGE *package, LPCWSTR prop, UINT* rc)
150 r = MSI_GetPropertyW(package, prop, NULL, &sz);
151 if (r != ERROR_SUCCESS && r != ERROR_MORE_DATA)
158 str = HeapAlloc(GetProcessHeap(),0,sz*sizeof(WCHAR));
159 r = MSI_GetPropertyW(package, prop, str, &sz);
160 if (r != ERROR_SUCCESS)
162 HeapFree(GetProcessHeap(),0,str);
170 MSICOMPONENT* get_loaded_component( MSIPACKAGE* package, LPCWSTR Component )
174 LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
176 if (lstrcmpW(Component,comp->Component)==0)
182 MSIFEATURE* get_loaded_feature(MSIPACKAGE* package, LPCWSTR Feature )
186 LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
188 if (lstrcmpW( Feature, feature->Feature )==0)
194 MSIFILE* get_loaded_file( MSIPACKAGE* package, LPCWSTR key )
198 LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
200 if (lstrcmpW( key, file->File )==0)
206 int track_tempfile( MSIPACKAGE *package, LPCWSTR name, LPCWSTR path )
213 LIST_FOR_EACH_ENTRY( temp, &package->tempfiles, MSITEMPFILE, entry )
215 if (lstrcmpW( name, temp->File )==0)
217 TRACE("tempfile %s already exists with path %s\n",
218 debugstr_w(temp->File), debugstr_w(temp->Path));
223 temp = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof (MSITEMPFILE) );
227 list_add_head( &package->tempfiles, &temp->entry );
229 temp->File = strdupW( name );
230 temp->Path = strdupW( path );
232 TRACE("adding tempfile %s with path %s\n",
233 debugstr_w(temp->File), debugstr_w(temp->Path));
238 MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir )
242 LIST_FOR_EACH_ENTRY( folder, &package->folders, MSIFOLDER, entry )
244 if (lstrcmpW( dir, folder->Directory )==0)
250 LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
251 BOOL set_prop, MSIFOLDER **folder)
254 LPWSTR p, path = NULL;
256 TRACE("Working to resolve %s\n",debugstr_w(name));
261 /* special resolving for Target and Source root dir */
262 if (strcmpW(name,cszTargetDir)==0 || strcmpW(name,cszSourceDir)==0)
267 check_path = load_dynamic_property(package,cszTargetDir,NULL);
270 check_path = load_dynamic_property(package,cszRootDrive,NULL);
272 MSI_SetPropertyW(package,cszTargetDir,check_path);
275 /* correct misbuilt target dir */
276 path = build_directory_name(2, check_path, NULL);
277 if (strcmpiW(path,check_path)!=0)
278 MSI_SetPropertyW(package,cszTargetDir,path);
282 path = load_dynamic_property(package,cszSourceDir,NULL);
285 path = load_dynamic_property(package,cszDatabase,NULL);
288 p = strrchrW(path,'\\');
295 *folder = get_loaded_folder( package, name );
299 f = get_loaded_folder( package, name );
306 if (!source && f->ResolvedTarget)
308 path = strdupW( f->ResolvedTarget );
309 TRACE(" already resolved to %s\n",debugstr_w(path));
312 else if (source && f->ResolvedSource)
314 path = strdupW( f->ResolvedSource );
315 TRACE(" (source)already resolved to %s\n",debugstr_w(path));
318 else if (!source && f->Property)
320 path = build_directory_name( 2, f->Property, NULL );
322 TRACE(" internally set to %s\n",debugstr_w(path));
324 MSI_SetPropertyW( package, name, path );
330 LPWSTR parent = f->Parent->Directory;
332 TRACE(" ! Parent is %s\n", debugstr_w(parent));
334 p = resolve_folder(package, parent, source, set_prop, NULL);
337 TRACE(" TargetDefault = %s\n", debugstr_w(f->TargetDefault));
339 path = build_directory_name( 3, p, f->TargetDefault, NULL );
340 f->ResolvedTarget = strdupW( path );
341 TRACE(" resolved into %s\n",debugstr_w(path));
343 MSI_SetPropertyW(package,name,path);
347 if (f->SourceDefault && f->SourceDefault[0]!='.')
348 path = build_directory_name( 3, p, f->SourceDefault, NULL );
351 TRACE(" (source)resolved into %s\n",debugstr_w(path));
352 f->ResolvedSource = strdupW( path );
354 HeapFree(GetProcessHeap(),0,p);
359 /* wrapper to resist a need for a full rewrite right now */
360 DWORD deformat_string(MSIPACKAGE *package, LPCWSTR ptr, WCHAR** data )
364 MSIRECORD *rec = MSI_CreateRecord(1);
367 MSI_RecordSetStringW(rec,0,ptr);
368 MSI_FormatRecordW(package,rec,NULL,&size);
372 *data = HeapAlloc(GetProcessHeap(),0,size*sizeof(WCHAR));
374 MSI_FormatRecordW(package,rec,*data,&size);
377 msiobj_release( &rec->hdr );
378 return sizeof(WCHAR)*size;
380 msiobj_release( &rec->hdr );
387 UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action)
390 LPWSTR *newbuf = NULL;
391 if (script >= TOTAL_SCRIPTS)
393 FIXME("Unknown script requested %i\n",script);
394 return ERROR_FUNCTION_FAILED;
396 TRACE("Scheduling Action %s in script %i\n",debugstr_w(action), script);
398 count = package->script->ActionCount[script];
399 package->script->ActionCount[script]++;
401 newbuf = HeapReAlloc(GetProcessHeap(),0,
402 package->script->Actions[script],
403 package->script->ActionCount[script]* sizeof(LPWSTR));
405 newbuf = HeapAlloc(GetProcessHeap(),0, sizeof(LPWSTR));
407 newbuf[count] = strdupW(action);
408 package->script->Actions[script] = newbuf;
410 return ERROR_SUCCESS;
413 static void remove_tracked_tempfiles(MSIPACKAGE* package)
415 struct list *item, *cursor;
417 LIST_FOR_EACH_SAFE( item, cursor, &package->tempfiles )
419 MSITEMPFILE *temp = LIST_ENTRY( item, MSITEMPFILE, entry );
421 list_remove( &temp->entry );
422 TRACE("deleting temp file %s\n", debugstr_w( temp->Path ));
423 DeleteFileW( temp->Path );
424 HeapFree( GetProcessHeap(), 0, temp->File );
425 HeapFree( GetProcessHeap(), 0, temp->Path );
426 HeapFree( GetProcessHeap(), 0, temp );
430 static void free_feature( MSIFEATURE *feature )
432 struct list *item, *cursor;
434 LIST_FOR_EACH_SAFE( item, cursor, &feature->Components )
436 ComponentList *cl = LIST_ENTRY( item, ComponentList, entry );
437 list_remove( &cl->entry );
438 HeapFree( GetProcessHeap(), 0, cl );
440 HeapFree( GetProcessHeap(), 0, feature );
443 void free_extension( MSIEXTENSION *ext )
445 struct list *item, *cursor;
447 LIST_FOR_EACH_SAFE( item, cursor, &ext->verbs )
449 MSIVERB *verb = LIST_ENTRY( item, MSIVERB, entry );
451 list_remove( &verb->entry );
452 HeapFree( GetProcessHeap(), 0, verb->Verb );
453 HeapFree( GetProcessHeap(), 0, verb->Command );
454 HeapFree( GetProcessHeap(), 0, verb->Argument );
455 HeapFree( GetProcessHeap(), 0, verb );
458 HeapFree( GetProcessHeap(), 0, ext->ProgIDText );
459 HeapFree( GetProcessHeap(), 0, ext );
463 /* Called when the package is being closed */
464 void ACTION_free_package_structures( MSIPACKAGE* package)
467 struct list *item, *cursor;
469 TRACE("Freeing package action data\n");
471 remove_tracked_tempfiles(package);
473 LIST_FOR_EACH_SAFE( item, cursor, &package->features )
475 MSIFEATURE *feature = LIST_ENTRY( item, MSIFEATURE, entry );
476 list_remove( &feature->entry );
477 free_feature( feature );
480 LIST_FOR_EACH_SAFE( item, cursor, &package->folders )
482 MSIFOLDER *folder = LIST_ENTRY( item, MSIFOLDER, entry );
484 list_remove( &folder->entry );
485 HeapFree( GetProcessHeap(), 0, folder->Directory );
486 HeapFree( GetProcessHeap(), 0, folder->TargetDefault );
487 HeapFree( GetProcessHeap(), 0, folder->SourceDefault );
488 HeapFree( GetProcessHeap(), 0, folder->ResolvedTarget );
489 HeapFree( GetProcessHeap(), 0, folder->ResolvedSource );
490 HeapFree( GetProcessHeap(), 0, folder->Property );
493 LIST_FOR_EACH_SAFE( item, cursor, &package->components )
495 MSICOMPONENT *comp = LIST_ENTRY( item, MSICOMPONENT, entry );
497 list_remove( &comp->entry );
498 HeapFree( GetProcessHeap(), 0, comp->Condition );
499 HeapFree( GetProcessHeap(), 0, comp->FullKeypath );
500 HeapFree( GetProcessHeap(), 0, comp );
503 LIST_FOR_EACH_SAFE( item, cursor, &package->files )
505 MSIFILE *file = LIST_ENTRY( item, MSIFILE, entry );
507 list_remove( &file->entry );
508 HeapFree( GetProcessHeap(), 0, file->File );
509 HeapFree( GetProcessHeap(), 0, file->FileName );
510 HeapFree( GetProcessHeap(), 0, file->ShortName );
511 HeapFree( GetProcessHeap(), 0, file->Version );
512 HeapFree( GetProcessHeap(), 0, file->Language );
513 HeapFree( GetProcessHeap(), 0, file->SourcePath );
514 HeapFree( GetProcessHeap(), 0, file->TargetPath );
515 HeapFree( GetProcessHeap(), 0, file );
518 /* clean up extension, progid, class and verb structures */
519 LIST_FOR_EACH_SAFE( item, cursor, &package->classes )
521 MSICLASS *cls = LIST_ENTRY( item, MSICLASS, entry );
523 list_remove( &cls->entry );
524 HeapFree( GetProcessHeap(), 0, cls->Description );
525 HeapFree( GetProcessHeap(), 0, cls->FileTypeMask );
526 HeapFree( GetProcessHeap(), 0, cls->IconPath );
527 HeapFree( GetProcessHeap(), 0, cls->DefInprocHandler );
528 HeapFree( GetProcessHeap(), 0, cls->DefInprocHandler32 );
529 HeapFree( GetProcessHeap(), 0, cls->Argument );
530 HeapFree( GetProcessHeap(), 0, cls->ProgIDText );
531 HeapFree( GetProcessHeap(), 0, cls );
534 LIST_FOR_EACH_SAFE( item, cursor, &package->extensions )
536 MSIEXTENSION *ext = LIST_ENTRY( item, MSIEXTENSION, entry );
538 list_remove( &ext->entry );
539 free_extension( ext );
542 LIST_FOR_EACH_SAFE( item, cursor, &package->progids )
544 MSIPROGID *progid = LIST_ENTRY( item, MSIPROGID, entry );
546 list_remove( &progid->entry );
547 HeapFree( GetProcessHeap(), 0, progid->ProgID );
548 HeapFree( GetProcessHeap(), 0, progid->Description );
549 HeapFree( GetProcessHeap(), 0, progid->IconPath );
550 HeapFree( GetProcessHeap(), 0, progid );
553 LIST_FOR_EACH_SAFE( item, cursor, &package->mimes )
555 MSIMIME *mt = LIST_ENTRY( item, MSIMIME, entry );
557 list_remove( &mt->entry );
558 HeapFree( GetProcessHeap(), 0, mt->ContentType );
559 HeapFree( GetProcessHeap(), 0, mt );
562 LIST_FOR_EACH_SAFE( item, cursor, &package->appids )
564 MSIAPPID *appid = LIST_ENTRY( item, MSIAPPID, entry );
566 list_remove( &appid->entry );
567 HeapFree( GetProcessHeap(), 0, appid->RemoteServerName );
568 HeapFree( GetProcessHeap(), 0, appid->LocalServer );
569 HeapFree( GetProcessHeap(), 0, appid->ServiceParameters );
570 HeapFree( GetProcessHeap(), 0, appid->DllSurrogate );
571 HeapFree( GetProcessHeap(), 0, appid );
576 for (i = 0; i < TOTAL_SCRIPTS; i++)
579 for (j = 0; j < package->script->ActionCount[i]; j++)
580 HeapFree(GetProcessHeap(),0,package->script->Actions[i][j]);
582 HeapFree(GetProcessHeap(),0,package->script->Actions[i]);
585 for (i = 0; i < package->script->UniqueActionsCount; i++)
586 HeapFree(GetProcessHeap(),0,package->script->UniqueActions[i]);
588 HeapFree(GetProcessHeap(),0,package->script->UniqueActions);
589 HeapFree(GetProcessHeap(),0,package->script);
592 HeapFree(GetProcessHeap(),0,package->PackagePath);
593 HeapFree(GetProcessHeap(),0,package->msiFilePath);
594 HeapFree(GetProcessHeap(),0,package->ProductCode);
596 /* cleanup control event subscriptions */
597 ControlEvent_CleanupSubscriptions(package);
601 * build_directory_name()
603 * This function is to save messing round with directory names
604 * It handles adding backslashes between path segments,
605 * and can add \ at the end of the directory name if told to.
607 * It takes a variable number of arguments.
608 * It always allocates a new string for the result, so make sure
609 * to free the return value when finished with it.
611 * The first arg is the number of path segments that follow.
612 * The arguments following count are a list of path segments.
613 * A path segment may be NULL.
615 * Path segments will be added with a \ separating them.
616 * A \ will not be added after the last segment, however if the
617 * last segment is NULL, then the last character will be a \
620 LPWSTR build_directory_name(DWORD count, ...)
627 for(i=0; i<count; i++)
629 LPCWSTR str = va_arg(va,LPCWSTR);
631 sz += strlenW(str) + 1;
635 dir = HeapAlloc(GetProcessHeap(), 0, sz*sizeof(WCHAR));
639 for(i=0; i<count; i++)
641 LPCWSTR str = va_arg(va,LPCWSTR);
645 if( ((i+1)!=count) && dir[strlenW(dir)-1]!='\\')
651 /***********************************************************************
654 * Recursively create all directories in the path.
656 * shamelessly stolen from setupapi/queue.c
658 BOOL create_full_pathW(const WCHAR *path)
664 new_path = HeapAlloc(GetProcessHeap(), 0, (strlenW(path) + 1) *
667 strcpyW(new_path, path);
669 while((len = strlenW(new_path)) && new_path[len - 1] == '\\')
670 new_path[len - 1] = 0;
672 while(!CreateDirectoryW(new_path, NULL))
675 DWORD last_error = GetLastError();
676 if(last_error == ERROR_ALREADY_EXISTS)
679 if(last_error != ERROR_PATH_NOT_FOUND)
685 if(!(slash = strrchrW(new_path, '\\')))
691 len = slash - new_path;
693 if(!create_full_pathW(new_path))
698 new_path[len] = '\\';
701 HeapFree(GetProcessHeap(), 0, new_path);
705 void ui_progress(MSIPACKAGE *package, int a, int b, int c, int d )
709 row = MSI_CreateRecord(4);
710 MSI_RecordSetInteger(row,1,a);
711 MSI_RecordSetInteger(row,2,b);
712 MSI_RecordSetInteger(row,3,c);
713 MSI_RecordSetInteger(row,4,d);
714 MSI_ProcessMessage(package, INSTALLMESSAGE_PROGRESS, row);
715 msiobj_release(&row->hdr);
717 msi_dialog_check_messages(NULL);
720 void ui_actiondata(MSIPACKAGE *package, LPCWSTR action, MSIRECORD * record)
722 static const WCHAR Query_t[] =
723 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
724 '`','A','c','t','i','o', 'n','T','e','x','t','`',' ',
725 'W','H','E','R','E',' ', '`','A','c','t','i','o','n','`',' ','=',
726 ' ','\'','%','s','\'',0};
730 static const WCHAR szActionData[] =
731 {'A','c','t','i','o','n','D','a','t','a',0};
733 if (!package->LastAction || strcmpW(package->LastAction,action))
735 row = MSI_QueryGetRecord(package->db, Query_t, action);
739 if (MSI_RecordIsNull(row,3))
741 msiobj_release(&row->hdr);
745 /* update the cached actionformat */
746 HeapFree(GetProcessHeap(),0,package->ActionFormat);
747 package->ActionFormat = load_dynamic_stringW(row,3);
749 HeapFree(GetProcessHeap(),0,package->LastAction);
750 package->LastAction = strdupW(action);
752 msiobj_release(&row->hdr);
755 MSI_RecordSetStringW(record,0,package->ActionFormat);
757 MSI_FormatRecordW(package,record,message,&size);
759 row = MSI_CreateRecord(1);
760 MSI_RecordSetStringW(row,1,message);
762 MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, row);
764 ControlEvent_FireSubscribedEvent(package,szActionData, row);
766 msiobj_release(&row->hdr);
769 BOOL ACTION_VerifyComponentForAction(MSIPACKAGE* package, MSICOMPONENT* comp,
772 if (comp->Installed == check)
775 if (comp->ActionRequest == check)
781 BOOL ACTION_VerifyFeatureForAction( MSIFEATURE* feature, INSTALLSTATE check )
783 if (feature->Installed == check)
786 if (feature->ActionRequest == check)
792 void reduce_to_longfilename(WCHAR* filename)
794 LPWSTR p = strchrW(filename,'|');
796 memmove(filename, p+1, (strlenW(p+1)+1)*sizeof(WCHAR));
799 void reduce_to_shortfilename(WCHAR* filename)
801 LPWSTR p = strchrW(filename,'|');
806 LPWSTR create_component_advertise_string(MSIPACKAGE* package,
807 MSICOMPONENT* component, LPCWSTR feature)
810 WCHAR productid_85[21];
811 WCHAR component_85[21];
813 * I have a fair bit of confusion as to when a < is used and when a > is
814 * used. I do not think i have it right...
816 * Ok it appears that the > is used if there is a guid for the compoenent
817 * and the < is used if not.
819 static WCHAR fmt1[] = {'%','s','%','s','<',0,0};
820 static WCHAR fmt2[] = {'%','s','%','s','>','%','s',0,0};
821 LPWSTR output = NULL;
824 memset(productid_85,0,sizeof(productid_85));
825 memset(component_85,0,sizeof(component_85));
827 CLSIDFromString(package->ProductCode, &clsid);
829 encode_base85_guid(&clsid,productid_85);
831 CLSIDFromString(component->ComponentId, &clsid);
832 encode_base85_guid(&clsid,component_85);
834 TRACE("Doing something with this... %s %s %s\n",
835 debugstr_w(productid_85), debugstr_w(feature),
836 debugstr_w(component_85));
838 sz = lstrlenW(productid_85) + lstrlenW(feature);
840 sz += lstrlenW(component_85);
845 output = HeapAlloc(GetProcessHeap(),0,sz);
849 sprintfW(output,fmt2,productid_85,feature,component_85);
851 sprintfW(output,fmt1,productid_85,feature);
856 /* update compoennt state based on a feature change */
857 void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature)
859 INSTALLSTATE newstate;
863 feature = get_loaded_feature(package,szFeature);
867 newstate = feature->ActionRequest;
869 LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
871 MSICOMPONENT* component = cl->component;
873 TRACE("MODIFYING(%i): Component %s (Installed %i, Action %i, Request %i)\n",
874 newstate, debugstr_w(component->Component), component->Installed,
875 component->Action, component->ActionRequest);
877 if (!component->Enabled)
880 if (newstate == INSTALLSTATE_LOCAL)
882 component->ActionRequest = INSTALLSTATE_LOCAL;
883 component->Action = INSTALLSTATE_LOCAL;
887 ComponentList *clist;
890 component->ActionRequest = newstate;
891 component->Action = newstate;
893 /*if any other feature wants is local we need to set it local*/
894 LIST_FOR_EACH_ENTRY( f, &package->features, MSIFEATURE, entry )
896 if ( component->ActionRequest != INSTALLSTATE_LOCAL )
899 LIST_FOR_EACH_ENTRY( clist, &f->Components, ComponentList, entry )
901 if ( clist->component == component )
903 if (f->ActionRequest == INSTALLSTATE_LOCAL)
905 TRACE("Saved by %s\n", debugstr_w(f->Feature));
906 component->ActionRequest = INSTALLSTATE_LOCAL;
907 component->Action = INSTALLSTATE_LOCAL;
914 TRACE("Result (%i): Component %s (Installed %i, Action %i, Request %i)\n",
915 newstate, debugstr_w(component->Component), component->Installed,
916 component->Action, component->ActionRequest);
920 UINT register_unique_action(MSIPACKAGE *package, LPCWSTR action)
923 LPWSTR *newbuf = NULL;
925 if (!package || !package->script)
928 TRACE("Registering Action %s as having fun\n",debugstr_w(action));
930 count = package->script->UniqueActionsCount;
931 package->script->UniqueActionsCount++;
933 newbuf = HeapReAlloc(GetProcessHeap(),0,
934 package->script->UniqueActions,
935 package->script->UniqueActionsCount* sizeof(LPWSTR));
937 newbuf = HeapAlloc(GetProcessHeap(),0, sizeof(LPWSTR));
939 newbuf[count] = strdupW(action);
940 package->script->UniqueActions = newbuf;
942 return ERROR_SUCCESS;
945 BOOL check_unique_action(MSIPACKAGE *package, LPCWSTR action)
949 if (!package || !package->script)
952 for (i = 0; i < package->script->UniqueActionsCount; i++)
953 if (!strcmpW(package->script->UniqueActions[i],action))
959 WCHAR* generate_error_string(MSIPACKAGE *package, UINT error, DWORD count, ... )
961 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};
971 row = MSI_QueryGetRecord(package->db, query, error);
975 rec = MSI_CreateRecord(count+2);
977 str = MSI_RecordGetString(row,1);
978 MSI_RecordSetStringW(rec,0,str);
979 msiobj_release( &row->hdr );
980 MSI_RecordSetInteger(rec,1,error);
983 for (i = 0; i < count; i++)
985 str = va_arg(va,LPCWSTR);
986 MSI_RecordSetStringW(rec,(i+2),str);
990 MSI_FormatRecordW(package,rec,NULL,&size);
994 data = HeapAlloc(GetProcessHeap(),0,size*sizeof(WCHAR));
996 MSI_FormatRecordW(package,rec,data,&size);
999 msiobj_release( &rec->hdr );
1003 msiobj_release( &rec->hdr );