msi: iterate SelfRegModules

Aric Stewart aric at codeweavers.com
Thu Jun 23 08:33:53 CDT 2005


rework SelfRegModules to use MSI_IterateRecords
-------------- next part --------------
Index: dlls/msi/action.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/action.c,v
retrieving revision 1.160
diff -u -r1.160 action.c
--- dlls/msi/action.c	23 Jun 2005 11:04:09 -0000	1.160
+++ dlls/msi/action.c	23 Jun 2005 13:29:56 -0000
@@ -3312,15 +3246,13 @@
     return rc;
 }
 
-static UINT ACTION_SelfRegModules(MSIPACKAGE *package)
+static UINT ITERATE_SelfRegModules(MSIRECORD *row, LPVOID param)
 {
-    UINT rc;
-    MSIQUERY * view;
-    MSIRECORD * row = 0;
-    static const WCHAR ExecSeqQuery[] = 
-        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
-         '`','S','e','l','f','R','e','g','`',0};
-
+    MSIPACKAGE *package = (MSIPACKAGE*)param;
+    LPCWSTR filename;
+    LPWSTR FullName;
+    INT index;
+    DWORD len;
     static const WCHAR ExeStr[] =
         {'r','e','g','s','v','r','3','2','.','e','x','e',' ','\"',0};
     static const WCHAR close[] =  {'\"',0};
@@ -3330,67 +3262,54 @@
 
     memset(&si,0,sizeof(STARTUPINFOW));
 
-    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
-    if (rc != ERROR_SUCCESS)
-    {
-        TRACE("no SelfReg table\n");
-        return ERROR_SUCCESS;
-    }
+    filename = MSI_RecordGetString(row,1);
+    index = get_loaded_file(package,filename);
 
-    rc = MSI_ViewExecute(view, 0);
-    if (rc != ERROR_SUCCESS)
+    if (index < 0)
     {
-        MSI_ViewClose(view);
-        msiobj_release(&view->hdr);
-        return rc;
+        ERR("Unable to find file id %s\n",debugstr_w(filename));
+        return ERROR_SUCCESS;
     }
 
-    while (1)
-    {
-        LPCWSTR filename;
-        LPWSTR FullName;
-        INT index;
-        DWORD len;
-
-        rc = MSI_ViewFetch(view,&row);
-        if (rc != ERROR_SUCCESS)
-        {
-            rc = ERROR_SUCCESS;
-            break;
-        }
+    len = strlenW(ExeStr);
+    len += strlenW(package->files[index].TargetPath);
+    len +=2;
+
+    FullName = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR));
+    strcpyW(FullName,ExeStr);
+    strcatW(FullName,package->files[index].TargetPath);
+    strcatW(FullName,close);
+
+    TRACE("Registering %s\n",debugstr_w(FullName));
+    brc = CreateProcessW(NULL, FullName, NULL, NULL, FALSE, 0, NULL, c_colon,
+                    &si, &info);
 
-        filename = MSI_RecordGetString(row,1);
-        index = get_loaded_file(package,filename);
+    if (brc)
+        msi_dialog_check_messages(info.hProcess);
 
-        if (index < 0)
-        {
-            ERR("Unable to find file id %s\n",debugstr_w(filename));
-            msiobj_release(&row->hdr);
-            continue;
-        }
+    HeapFree(GetProcessHeap(),0,FullName);
+    return ERROR_SUCCESS;
+}
 
-        len = strlenW(ExeStr);
-        len += strlenW(package->files[index].TargetPath);
-        len +=2;
-
-        FullName = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR));
-        strcpyW(FullName,ExeStr);
-        strcatW(FullName,package->files[index].TargetPath);
-        strcatW(FullName,close);
-
-        TRACE("Registering %s\n",debugstr_w(FullName));
-        brc = CreateProcessW(NULL, FullName, NULL, NULL, FALSE, 0, NULL,
-                  c_colon, &si, &info);
+static UINT ACTION_SelfRegModules(MSIPACKAGE *package)
+{
+    UINT rc;
+    MSIQUERY * view;
+    static const WCHAR ExecSeqQuery[] = 
+        {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
+         '`','S','e','l','f','R','e','g','`',0};
 
-        if (brc)
-            msi_dialog_check_messages(info.hProcess);
- 
-        HeapFree(GetProcessHeap(),0,FullName);
-        msiobj_release(&row->hdr);
+    rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
+    if (rc != ERROR_SUCCESS)
+    {
+        TRACE("no SelfReg table\n");
+        return ERROR_SUCCESS;
     }
-    MSI_ViewClose(view);
+
+    MSI_IterateRecords(view, NULL, ITERATE_SelfRegModules, package);
     msiobj_release(&view->hdr);
-    return rc;
+
+    return ERROR_SUCCESS;
 }
 
 static UINT ACTION_PublishFeatures(MSIPACKAGE *package)


More information about the wine-patches mailing list