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 )
172 MSICOMPONENT *comp = NULL;
174 LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
176 if (lstrcmpW(Component,comp->Component)==0)
182 int get_loaded_feature(MSIPACKAGE* package, LPCWSTR Feature )
187 for (i = 0; i < package->loaded_features; i++)
189 if (strcmpW(Feature,package->features[i].Feature)==0)
198 int get_loaded_file(MSIPACKAGE* package, LPCWSTR file)
203 for (i = 0; i < package->loaded_files; i++)
205 if (strcmpW(file,package->files[i].File)==0)
214 int track_tempfile(MSIPACKAGE *package, LPCWSTR name, LPCWSTR path)
222 for (i=0; i < package->loaded_files; i++)
223 if (strcmpW(package->files[i].File,name)==0)
226 index = package->loaded_files;
227 package->loaded_files++;
228 if (package->loaded_files== 1)
229 package->files = HeapAlloc(GetProcessHeap(),0,sizeof(MSIFILE));
231 package->files = HeapReAlloc(GetProcessHeap(),0,
232 package->files , package->loaded_files * sizeof(MSIFILE));
234 memset(&package->files[index],0,sizeof(MSIFILE));
236 package->files[index].File = strdupW(name);
237 package->files[index].TargetPath = strdupW(path);
238 package->files[index].Temporary = TRUE;
240 TRACE("Tracking tempfile (%s)\n",debugstr_w(package->files[index].File));
245 LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
246 BOOL set_prop, MSIFOLDER **folder)
249 LPWSTR p, path = NULL;
251 TRACE("Working to resolve %s\n",debugstr_w(name));
256 /* special resolving for Target and Source root dir */
257 if (strcmpW(name,cszTargetDir)==0 || strcmpW(name,cszSourceDir)==0)
262 check_path = load_dynamic_property(package,cszTargetDir,NULL);
265 check_path = load_dynamic_property(package,cszRootDrive,NULL);
267 MSI_SetPropertyW(package,cszTargetDir,check_path);
270 /* correct misbuilt target dir */
271 path = build_directory_name(2, check_path, NULL);
272 if (strcmpiW(path,check_path)!=0)
273 MSI_SetPropertyW(package,cszTargetDir,path);
277 for (i = 0; i < package->loaded_folders; i++)
279 if (strcmpW(package->folders[i].Directory,name)==0)
282 *folder = &(package->folders[i]);
288 path = load_dynamic_property(package,cszSourceDir,NULL);
291 path = load_dynamic_property(package,cszDatabase,NULL);
294 p = strrchrW(path,'\\');
301 for (i = 0; i < package->loaded_folders; i++)
303 if (strcmpW(package->folders[i].Directory,name)==0)
306 *folder = &(package->folders[i]);
312 for (i = 0; i < package->loaded_folders; i++)
314 if (strcmpW(package->folders[i].Directory,name)==0)
318 if (i >= package->loaded_folders)
322 *folder = &(package->folders[i]);
324 if (!source && package->folders[i].ResolvedTarget)
326 path = strdupW(package->folders[i].ResolvedTarget);
327 TRACE(" already resolved to %s\n",debugstr_w(path));
330 else if (source && package->folders[i].ResolvedSource)
332 path = strdupW(package->folders[i].ResolvedSource);
333 TRACE(" (source)already resolved to %s\n",debugstr_w(path));
336 else if (!source && package->folders[i].Property)
338 path = build_directory_name(2, package->folders[i].Property, NULL);
340 TRACE(" internally set to %s\n",debugstr_w(path));
342 MSI_SetPropertyW(package,name,path);
346 if (package->folders[i].ParentIndex >= 0)
348 LPWSTR parent = package->folders[package->folders[i].ParentIndex].Directory;
350 TRACE(" ! Parent is %s\n", debugstr_w(parent));
352 p = resolve_folder(package, parent, source, set_prop, NULL);
355 TRACE(" TargetDefault = %s\n",
356 debugstr_w(package->folders[i].TargetDefault));
358 path = build_directory_name(3, p,
359 package->folders[i].TargetDefault, NULL);
360 package->folders[i].ResolvedTarget = strdupW(path);
361 TRACE(" resolved into %s\n",debugstr_w(path));
363 MSI_SetPropertyW(package,name,path);
367 if (package->folders[i].SourceDefault &&
368 package->folders[i].SourceDefault[0]!='.')
369 path = build_directory_name(3, p, package->folders[i].SourceDefault, NULL);
372 TRACE(" (source)resolved into %s\n",debugstr_w(path));
373 package->folders[i].ResolvedSource = strdupW(path);
375 HeapFree(GetProcessHeap(),0,p);
380 /* wrapper to resist a need for a full rewrite right now */
381 DWORD deformat_string(MSIPACKAGE *package, LPCWSTR ptr, WCHAR** data )
385 MSIRECORD *rec = MSI_CreateRecord(1);
388 MSI_RecordSetStringW(rec,0,ptr);
389 MSI_FormatRecordW(package,rec,NULL,&size);
393 *data = HeapAlloc(GetProcessHeap(),0,size*sizeof(WCHAR));
395 MSI_FormatRecordW(package,rec,*data,&size);
398 msiobj_release( &rec->hdr );
399 return sizeof(WCHAR)*size;
401 msiobj_release( &rec->hdr );
408 UINT schedule_action(MSIPACKAGE *package, UINT script, LPCWSTR action)
411 LPWSTR *newbuf = NULL;
412 if (script >= TOTAL_SCRIPTS)
414 FIXME("Unknown script requested %i\n",script);
415 return ERROR_FUNCTION_FAILED;
417 TRACE("Scheduling Action %s in script %i\n",debugstr_w(action), script);
419 count = package->script->ActionCount[script];
420 package->script->ActionCount[script]++;
422 newbuf = HeapReAlloc(GetProcessHeap(),0,
423 package->script->Actions[script],
424 package->script->ActionCount[script]* sizeof(LPWSTR));
426 newbuf = HeapAlloc(GetProcessHeap(),0, sizeof(LPWSTR));
428 newbuf[count] = strdupW(action);
429 package->script->Actions[script] = newbuf;
431 return ERROR_SUCCESS;
434 static void remove_tracked_tempfiles(MSIPACKAGE* package)
441 for (i = 0; i < package->loaded_files; i++)
443 if (package->files[i].Temporary)
445 TRACE("Cleaning up %s\n",debugstr_w(package->files[i].TargetPath));
446 DeleteFileW(package->files[i].TargetPath);
452 /* Called when the package is being closed */
453 void ACTION_free_package_structures( MSIPACKAGE* package)
456 struct list *item, *cursor;
458 TRACE("Freeing package action data\n");
460 remove_tracked_tempfiles(package);
462 if (package->features)
464 LIST_FOR_EACH_SAFE( item, cursor, package->features->Components )
466 ComponentList *cl = LIST_ENTRY( item, ComponentList, entry );
467 list_remove( &cl->entry );
468 HeapFree(GetProcessHeap(), 0, cl);
470 HeapFree(GetProcessHeap(),0,package->features->Components);
471 HeapFree(GetProcessHeap(),0,package->features);
474 for (i = 0; i < package->loaded_folders; i++)
476 HeapFree(GetProcessHeap(),0,package->folders[i].Directory);
477 HeapFree(GetProcessHeap(),0,package->folders[i].TargetDefault);
478 HeapFree(GetProcessHeap(),0,package->folders[i].SourceDefault);
479 HeapFree(GetProcessHeap(),0,package->folders[i].ResolvedTarget);
480 HeapFree(GetProcessHeap(),0,package->folders[i].ResolvedSource);
481 HeapFree(GetProcessHeap(),0,package->folders[i].Property);
483 if (package->folders && package->loaded_folders > 0)
484 HeapFree(GetProcessHeap(),0,package->folders);
486 LIST_FOR_EACH_SAFE( item, cursor, &package->components )
488 MSICOMPONENT *comp = LIST_ENTRY( item, MSICOMPONENT, entry );
490 list_remove( &comp->entry );
491 HeapFree( GetProcessHeap(), 0, comp->FullKeypath );
492 HeapFree( GetProcessHeap(), 0, comp );
495 for (i = 0; i < package->loaded_files; i++)
497 HeapFree(GetProcessHeap(),0,package->files[i].File);
498 HeapFree(GetProcessHeap(),0,package->files[i].FileName);
499 HeapFree(GetProcessHeap(),0,package->files[i].ShortName);
500 HeapFree(GetProcessHeap(),0,package->files[i].Version);
501 HeapFree(GetProcessHeap(),0,package->files[i].Language);
502 HeapFree(GetProcessHeap(),0,package->files[i].SourcePath);
503 HeapFree(GetProcessHeap(),0,package->files[i].TargetPath);
506 if (package->files && package->loaded_files > 0)
507 HeapFree(GetProcessHeap(),0,package->files);
509 /* clean up extension, progid, class and verb structures */
510 for (i = 0; i < package->loaded_classes; i++)
512 HeapFree(GetProcessHeap(),0,package->classes[i].Description);
513 HeapFree(GetProcessHeap(),0,package->classes[i].FileTypeMask);
514 HeapFree(GetProcessHeap(),0,package->classes[i].IconPath);
515 HeapFree(GetProcessHeap(),0,package->classes[i].DefInprocHandler);
516 HeapFree(GetProcessHeap(),0,package->classes[i].DefInprocHandler32);
517 HeapFree(GetProcessHeap(),0,package->classes[i].Argument);
518 HeapFree(GetProcessHeap(),0,package->classes[i].ProgIDText);
521 if (package->classes && package->loaded_classes > 0)
522 HeapFree(GetProcessHeap(),0,package->classes);
524 for (i = 0; i < package->loaded_extensions; i++)
526 HeapFree(GetProcessHeap(),0,package->extensions[i].ProgIDText);
529 if (package->extensions && package->loaded_extensions > 0)
530 HeapFree(GetProcessHeap(),0,package->extensions);
532 for (i = 0; i < package->loaded_progids; i++)
534 HeapFree(GetProcessHeap(),0,package->progids[i].ProgID);
535 HeapFree(GetProcessHeap(),0,package->progids[i].Description);
536 HeapFree(GetProcessHeap(),0,package->progids[i].IconPath);
539 if (package->progids && package->loaded_progids > 0)
540 HeapFree(GetProcessHeap(),0,package->progids);
542 for (i = 0; i < package->loaded_verbs; i++)
544 HeapFree(GetProcessHeap(),0,package->verbs[i].Verb);
545 HeapFree(GetProcessHeap(),0,package->verbs[i].Command);
546 HeapFree(GetProcessHeap(),0,package->verbs[i].Argument);
549 if (package->verbs && package->loaded_verbs > 0)
550 HeapFree(GetProcessHeap(),0,package->verbs);
552 for (i = 0; i < package->loaded_mimes; i++)
553 HeapFree(GetProcessHeap(),0,package->mimes[i].ContentType);
555 if (package->mimes && package->loaded_mimes > 0)
556 HeapFree(GetProcessHeap(),0,package->mimes);
558 for (i = 0; i < package->loaded_appids; i++)
560 HeapFree(GetProcessHeap(),0,package->appids[i].RemoteServerName);
561 HeapFree(GetProcessHeap(),0,package->appids[i].LocalServer);
562 HeapFree(GetProcessHeap(),0,package->appids[i].ServiceParameters);
563 HeapFree(GetProcessHeap(),0,package->appids[i].DllSurrogate);
566 if (package->appids && package->loaded_appids > 0)
567 HeapFree(GetProcessHeap(),0,package->appids);
571 for (i = 0; i < TOTAL_SCRIPTS; i++)
574 for (j = 0; j < package->script->ActionCount[i]; j++)
575 HeapFree(GetProcessHeap(),0,package->script->Actions[i][j]);
577 HeapFree(GetProcessHeap(),0,package->script->Actions[i]);
580 for (i = 0; i < package->script->UniqueActionsCount; i++)
581 HeapFree(GetProcessHeap(),0,package->script->UniqueActions[i]);
583 HeapFree(GetProcessHeap(),0,package->script->UniqueActions);
584 HeapFree(GetProcessHeap(),0,package->script);
587 HeapFree(GetProcessHeap(),0,package->PackagePath);
588 HeapFree(GetProcessHeap(),0,package->msiFilePath);
589 HeapFree(GetProcessHeap(),0,package->ProductCode);
591 /* cleanup control event subscriptions */
592 ControlEvent_CleanupSubscriptions(package);
596 * build_directory_name()
598 * This function is to save messing round with directory names
599 * It handles adding backslashes between path segments,
600 * and can add \ at the end of the directory name if told to.
602 * It takes a variable number of arguments.
603 * It always allocates a new string for the result, so make sure
604 * to free the return value when finished with it.
606 * The first arg is the number of path segments that follow.
607 * The arguments following count are a list of path segments.
608 * A path segment may be NULL.
610 * Path segments will be added with a \ separating them.
611 * A \ will not be added after the last segment, however if the
612 * last segment is NULL, then the last character will be a \
615 LPWSTR build_directory_name(DWORD count, ...)
622 for(i=0; i<count; i++)
624 LPCWSTR str = va_arg(va,LPCWSTR);
626 sz += strlenW(str) + 1;
630 dir = HeapAlloc(GetProcessHeap(), 0, sz*sizeof(WCHAR));
634 for(i=0; i<count; i++)
636 LPCWSTR str = va_arg(va,LPCWSTR);
640 if( ((i+1)!=count) && dir[strlenW(dir)-1]!='\\')
646 /***********************************************************************
649 * Recursively create all directories in the path.
651 * shamelessly stolen from setupapi/queue.c
653 BOOL create_full_pathW(const WCHAR *path)
659 new_path = HeapAlloc(GetProcessHeap(), 0, (strlenW(path) + 1) *
662 strcpyW(new_path, path);
664 while((len = strlenW(new_path)) && new_path[len - 1] == '\\')
665 new_path[len - 1] = 0;
667 while(!CreateDirectoryW(new_path, NULL))
670 DWORD last_error = GetLastError();
671 if(last_error == ERROR_ALREADY_EXISTS)
674 if(last_error != ERROR_PATH_NOT_FOUND)
680 if(!(slash = strrchrW(new_path, '\\')))
686 len = slash - new_path;
688 if(!create_full_pathW(new_path))
693 new_path[len] = '\\';
696 HeapFree(GetProcessHeap(), 0, new_path);
700 void ui_progress(MSIPACKAGE *package, int a, int b, int c, int d )
704 row = MSI_CreateRecord(4);
705 MSI_RecordSetInteger(row,1,a);
706 MSI_RecordSetInteger(row,2,b);
707 MSI_RecordSetInteger(row,3,c);
708 MSI_RecordSetInteger(row,4,d);
709 MSI_ProcessMessage(package, INSTALLMESSAGE_PROGRESS, row);
710 msiobj_release(&row->hdr);
712 msi_dialog_check_messages(NULL);
715 void ui_actiondata(MSIPACKAGE *package, LPCWSTR action, MSIRECORD * record)
717 static const WCHAR Query_t[] =
718 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
719 '`','A','c','t','i','o', 'n','T','e','x','t','`',' ',
720 'W','H','E','R','E',' ', '`','A','c','t','i','o','n','`',' ','=',
721 ' ','\'','%','s','\'',0};
725 static const WCHAR szActionData[] =
726 {'A','c','t','i','o','n','D','a','t','a',0};
728 if (!package->LastAction || strcmpW(package->LastAction,action))
730 row = MSI_QueryGetRecord(package->db, Query_t, action);
734 if (MSI_RecordIsNull(row,3))
736 msiobj_release(&row->hdr);
740 /* update the cached actionformat */
741 HeapFree(GetProcessHeap(),0,package->ActionFormat);
742 package->ActionFormat = load_dynamic_stringW(row,3);
744 HeapFree(GetProcessHeap(),0,package->LastAction);
745 package->LastAction = strdupW(action);
747 msiobj_release(&row->hdr);
750 MSI_RecordSetStringW(record,0,package->ActionFormat);
752 MSI_FormatRecordW(package,record,message,&size);
754 row = MSI_CreateRecord(1);
755 MSI_RecordSetStringW(row,1,message);
757 MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, row);
759 ControlEvent_FireSubscribedEvent(package,szActionData, row);
761 msiobj_release(&row->hdr);
764 BOOL ACTION_VerifyComponentForAction(MSIPACKAGE* package, MSICOMPONENT* comp,
767 if (comp->Installed == check)
770 if (comp->ActionRequest == check)
776 BOOL ACTION_VerifyFeatureForAction(MSIPACKAGE* package, INT index,
779 if (package->features[index].Installed == check)
782 if (package->features[index].ActionRequest == check)
788 void reduce_to_longfilename(WCHAR* filename)
790 LPWSTR p = strchrW(filename,'|');
792 memmove(filename, p+1, (strlenW(p+1)+1)*sizeof(WCHAR));
795 void reduce_to_shortfilename(WCHAR* filename)
797 LPWSTR p = strchrW(filename,'|');
802 LPWSTR create_component_advertise_string(MSIPACKAGE* package,
803 MSICOMPONENT* component, LPCWSTR feature)
806 WCHAR productid_85[21];
807 WCHAR component_85[21];
809 * I have a fair bit of confusion as to when a < is used and when a > is
810 * used. I do not think i have it right...
812 * Ok it appears that the > is used if there is a guid for the compoenent
813 * and the < is used if not.
815 static WCHAR fmt1[] = {'%','s','%','s','<',0,0};
816 static WCHAR fmt2[] = {'%','s','%','s','>','%','s',0,0};
817 LPWSTR output = NULL;
820 memset(productid_85,0,sizeof(productid_85));
821 memset(component_85,0,sizeof(component_85));
823 CLSIDFromString(package->ProductCode, &clsid);
825 encode_base85_guid(&clsid,productid_85);
827 CLSIDFromString(component->ComponentId, &clsid);
828 encode_base85_guid(&clsid,component_85);
830 TRACE("Doing something with this... %s %s %s\n",
831 debugstr_w(productid_85), debugstr_w(feature),
832 debugstr_w(component_85));
834 sz = lstrlenW(productid_85) + lstrlenW(feature);
836 sz += lstrlenW(component_85);
841 output = HeapAlloc(GetProcessHeap(),0,sz);
845 sprintfW(output,fmt2,productid_85,feature,component_85);
847 sprintfW(output,fmt1,productid_85,feature);
852 /* update compoennt state based on a feature change */
853 void ACTION_UpdateComponentStates(MSIPACKAGE *package, LPCWSTR szFeature)
856 INSTALLSTATE newstate;
860 i = get_loaded_feature(package,szFeature);
864 feature = &package->features[i];
865 newstate = feature->ActionRequest;
867 LIST_FOR_EACH_ENTRY( cl, feature->Components, ComponentList, entry )
869 MSICOMPONENT* component = cl->component;
871 TRACE("MODIFYING(%i): Component %s (Installed %i, Action %i, Request %i)\n",
872 newstate, debugstr_w(component->Component), component->Installed,
873 component->Action, component->ActionRequest);
875 if (!component->Enabled)
879 if (newstate == INSTALLSTATE_LOCAL)
881 component->ActionRequest = INSTALLSTATE_LOCAL;
882 component->Action = INSTALLSTATE_LOCAL;
887 ComponentList *clist;
889 component->ActionRequest = newstate;
890 component->Action = newstate;
892 /*if any other feature wants is local we need to set it local*/
894 j < package->loaded_features &&
895 component->ActionRequest != INSTALLSTATE_LOCAL;
898 LIST_FOR_EACH_ENTRY( clist, package->features[j].Components,
899 ComponentList, entry )
901 if ( clist->component == cl->component )
903 if (package->features[j].ActionRequest ==
906 TRACE("Saved by %s\n", debugstr_w(package->features[j].Feature));
907 component->ActionRequest = INSTALLSTATE_LOCAL;
908 component->Action = INSTALLSTATE_LOCAL;
916 TRACE("Result (%i): Component %s (Installed %i, Action %i, Request %i)\n",
917 newstate, debugstr_w(component->Component), component->Installed,
918 component->Action, component->ActionRequest);
922 UINT register_unique_action(MSIPACKAGE *package, LPCWSTR action)
925 LPWSTR *newbuf = NULL;
927 if (!package || !package->script)
930 TRACE("Registering Action %s as having fun\n",debugstr_w(action));
932 count = package->script->UniqueActionsCount;
933 package->script->UniqueActionsCount++;
935 newbuf = HeapReAlloc(GetProcessHeap(),0,
936 package->script->UniqueActions,
937 package->script->UniqueActionsCount* sizeof(LPWSTR));
939 newbuf = HeapAlloc(GetProcessHeap(),0, sizeof(LPWSTR));
941 newbuf[count] = strdupW(action);
942 package->script->UniqueActions = newbuf;
944 return ERROR_SUCCESS;
947 BOOL check_unique_action(MSIPACKAGE *package, LPCWSTR action)
951 if (!package || !package->script)
954 for (i = 0; i < package->script->UniqueActionsCount; i++)
955 if (!strcmpW(package->script->UniqueActions[i],action))
961 WCHAR* generate_error_string(MSIPACKAGE *package, UINT error, DWORD count, ... )
963 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};
973 row = MSI_QueryGetRecord(package->db, query, error);
977 rec = MSI_CreateRecord(count+2);
979 str = MSI_RecordGetString(row,1);
980 MSI_RecordSetStringW(rec,0,str);
981 msiobj_release( &row->hdr );
982 MSI_RecordSetInteger(rec,1,error);
985 for (i = 0; i < count; i++)
987 str = va_arg(va,LPCWSTR);
988 MSI_RecordSetStringW(rec,(i+2),str);
992 MSI_FormatRecordW(package,rec,NULL,&size);
996 data = HeapAlloc(GetProcessHeap(),0,size*sizeof(WCHAR));
998 MSI_FormatRecordW(package,rec,data,&size);
1001 msiobj_release( &rec->hdr );
1005 msiobj_release( &rec->hdr );