[3/3] msi: Set the ComputerName property.

Hans Leidekker hans at codeweavers.com
Tue Nov 1 05:07:45 CDT 2011


See http://bugs.winehq.org/show_bug.cgi?id=9444
---
 dlls/msi/package.c       |   18 ++++++++++++++----
 dlls/msi/tests/package.c |    5 +++++
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index 8ec6889..c265cca 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -751,14 +751,13 @@ static VOID set_installer_properties(MSIPACKAGE *package)
     static const WCHAR szNetHoodFolder[] = {'N','e','t','H','o','o','d','F','o','l','d','e','r',0};
     static const WCHAR szPrintHoodFolder[] = {'P','r','i','n','t','H','o','o','d','F','o','l','d','e','r',0};
     static const WCHAR szRecentFolder[] = {'R','e','c','e','n','t','F','o','l','d','e','r',0};
+    static const WCHAR szComputerName[] = {'C','o','m','p','u','t','e','r','N','a','m','e',0};
 
     /*
      * Other things that probably should be set:
      *
-     * ComputerName VirtualMemory
-     * ShellAdvSupport DefaultUIFont PackagecodeChanging
-     * CaptionHeight BorderTop BorderSide TextHeight
-     * RedirectedDllSupport
+     * VirtualMemory ShellAdvSupport DefaultUIFont PackagecodeChanging
+     * CaptionHeight BorderTop BorderSide TextHeight RedirectedDllSupport
      */
 
     SHGetFolderPathW(NULL, CSIDL_COMMON_APPDATA, NULL, 0, pth);
@@ -1014,6 +1013,17 @@ static VOID set_installer_properties(MSIPACKAGE *package)
             msi_free( username );
         }
     }
+    len = 0;
+    if (!GetComputerNameW( NULL, &len ) && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
+    {
+        WCHAR *computername;
+        if ((computername = msi_alloc( len * sizeof(WCHAR) )))
+        {
+            if (GetComputerNameW( computername, &len ))
+                msi_set_property( package->db, szComputerName, computername );
+            msi_free( computername );
+        }
+    }
 }
 
 static UINT msi_load_summary_properties( MSIPACKAGE *package )
diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c
index 04c3fe7..9fae1d9 100644
--- a/dlls/msi/tests/package.c
+++ b/dlls/msi/tests/package.c
@@ -10103,6 +10103,11 @@ static void test_installprops(void)
     ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
     trace("PackageCode = %s\n", buf);
 
+    size = MAX_PATH;
+    r = MsiGetProperty(hpkg, "ComputerName", buf, &size);
+    ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
+    trace("ComputerName = %s\n", buf);
+
     langid = GetUserDefaultLangID();
     sprintf(path, "%d", langid);
 
-- 
1.7.5.4






More information about the wine-patches mailing list