msi: Set the MsiNetAssemblySupport property

James Hawkins truiken at gmail.com
Tue Jun 12 18:33:52 CDT 2007


Hi,

This fixes the msi part of bug 8603.
http://bugs.winehq.org/show_bug.cgi?id=8603 .  This property will only
be set if fusion.dll is copied to
c:\windows\windows.net\framework\[insert_version] and the proper reg
keys are set.

Changelog:
* Set the MsiNetAssemblySupport property.

 dlls/msi/package.c |  120 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 120 insertions(+), 0 deletions(-)

-- 
James Hawkins
-------------- next part --------------
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index 5a78cb8..28b0df3 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -36,6 +36,7 @@ #include "objidl.h"
 #include "wincrypt.h"
 #include "winuser.h"
 #include "wininet.h"
+#include "winver.h"
 #include "urlmon.h"
 #include "shlobj.h"
 #include "wine/unicode.h"
@@ -207,6 +208,123 @@ done:
     return r;
 }
 
+static LPWSTR get_fusion_filename(MSIPACKAGE *package)
+{
+    HKEY netsetup;
+    LONG res;
+    LPWSTR file;
+    DWORD index = 0, size;
+    WCHAR ver[MAX_PATH];
+    WCHAR name[MAX_PATH];
+    WCHAR windir[MAX_PATH];
+
+    static const WCHAR backslash[] = {'\\',0};
+    static const WCHAR fusion[] = {'f','u','s','i','o','n','.','d','l','l',0};
+    static const WCHAR sub[] = {
+        'S','o','f','t','w','a','r','e','\\',
+        'M','i','c','r','o','s','o','f','t','\\',
+        'N','E','T',' ','F','r','a','m','e','w','o','r','k',' ','S','e','t','u','p','\\',
+        'N','D','P',0
+    };
+    static const WCHAR subdir[] = {
+        'M','i','c','r','o','s','o','f','t','.','N','E','T','\\',
+        'F','r','a','m','e','w','o','r','k','\\',0
+    };
+
+    res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, sub, 0, KEY_ENUMERATE_SUB_KEYS, &netsetup);
+    if (res != ERROR_SUCCESS)
+        return NULL;
+
+    ver[0] = '\0';
+    size = MAX_PATH;
+    while (RegEnumKeyExW(netsetup, index, name, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
+    {
+        index++;
+        if (lstrcmpW(ver, name) < 0)
+            lstrcpyW(ver, name);
+    }
+
+    RegCloseKey(netsetup);
+
+    if (!index)
+        return NULL;
+
+    GetWindowsDirectoryW(windir, MAX_PATH);
+
+    size = lstrlenW(windir) + lstrlenW(subdir) + lstrlenW(ver) +lstrlenW(fusion) + 3;
+    file = msi_alloc(size * sizeof(WCHAR));
+    if (!file)
+        return NULL;
+
+    lstrcpyW(file, windir);
+    lstrcatW(file, backslash);
+    lstrcatW(file, subdir);
+    lstrcatW(file, ver);
+    lstrcatW(file, backslash);
+    lstrcatW(file, fusion); 
+
+    return file;
+}
+
+typedef struct tagLANGANDCODEPAGE
+{
+  WORD wLanguage;
+  WORD wCodePage;
+} LANGANDCODEPAGE;
+
+static void set_msi_assembly_prop(MSIPACKAGE *package)
+{
+    UINT val_len;
+    DWORD size, handle;
+    LPVOID version = NULL;
+    WCHAR buf[MAX_PATH];
+    LPWSTR fusion, verstr;
+    LANGANDCODEPAGE *translate;
+
+    static const WCHAR netasm[] = {
+        'M','s','i','N','e','t','A','s','s','e','m','b','l','y','S','u','p','p','o','r','t',0
+    };
+    static const WCHAR translation[] = {
+        '\\','V','a','r','F','i','l','e','I','n','f','o',
+        '\\','T','r','a','n','s','l','a','t','i','o','n',0
+    };
+    static const WCHAR verfmt[] = {
+        '\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
+        '\\','%','0','4','x','%','0','4','x',
+        '\\','P','r','o','d','u','c','t','V','e','r','s','i','o','n',0
+    };
+
+    fusion = get_fusion_filename(package);
+    if (!fusion)
+        return;
+
+    size = GetFileVersionInfoSizeW(fusion, &handle);
+    if (!size) return;
+
+    version = msi_alloc(size);
+    if (!version) return;
+
+    if (!GetFileVersionInfoW(fusion, handle, size, version))
+        goto done;
+
+    if (!VerQueryValueW(version, translation, (LPVOID *)&translate, &val_len))
+        goto done;
+
+    sprintfW(buf, verfmt, translate[0].wLanguage, translate[0].wCodePage);
+
+    if (!VerQueryValueW(version, buf, (LPVOID *)&verstr, &val_len))
+        goto done;
+
+    if (!val_len || !verstr)
+        goto done;
+
+    MSI_SetPropertyW(package, netasm, verstr);
+
+done:
+    msi_free(fusion);
+    msi_free(version);
+}
+
 /*
  * There are a whole slew of these we need to set
  *
@@ -501,6 +619,8 @@ static VOID set_installer_properties(MSI
     else
         ERR("Couldn't set Time property: GetTimeFormat failed with error %d\n", GetLastError());
 
+    set_msi_assembly_prop( package );
+
     msi_free( check );
     CloseHandle( hkey );
 }
-- 
1.4.1


More information about the wine-patches mailing list