Commit 4d2e148f authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

msi: Use package_from_db instead of opening the package with MsiOpenPackage.

parent 1d9c680e
...@@ -2249,6 +2249,24 @@ static MSIHANDLE create_package_db(LPCSTR filename) ...@@ -2249,6 +2249,24 @@ static MSIHANDLE create_package_db(LPCSTR filename)
return hdb; return hdb;
} }
static MSIHANDLE package_from_db(MSIHANDLE hdb)
{
UINT res;
CHAR szPackage[10];
MSIHANDLE hPackage;
sprintf(szPackage,"#%li",hdb);
res = MsiOpenPackage(szPackage,&hPackage);
if (res != ERROR_SUCCESS)
return 0;
res = MsiCloseHandle(hdb);
if (res != ERROR_SUCCESS)
return 0;
return hPackage;
}
static void test_try_transform(void) static void test_try_transform(void)
{ {
MSIHANDLE hdb, hview, hrec, hpkg; MSIHANDLE hdb, hview, hrec, hpkg;
...@@ -2258,11 +2276,10 @@ static void test_try_transform(void) ...@@ -2258,11 +2276,10 @@ static void test_try_transform(void)
char buffer[MAX_PATH]; char buffer[MAX_PATH];
DeleteFile(msifile); DeleteFile(msifile);
DeleteFile(msifile2);
DeleteFile(mstfile); DeleteFile(mstfile);
/* create the database */ /* create the database */
hdb = create_package_db(msifile2); hdb = create_package_db(msifile);
ok(hdb, "Failed to create package db\n"); ok(hdb, "Failed to create package db\n");
query = "CREATE TABLE `MOO` ( `NOO` SHORT NOT NULL, `OOO` CHAR(255) PRIMARY KEY `NOO`)"; query = "CREATE TABLE `MOO` ( `NOO` SHORT NOT NULL, `OOO` CHAR(255) PRIMARY KEY `NOO`)";
...@@ -2315,7 +2332,7 @@ static void test_try_transform(void) ...@@ -2315,7 +2332,7 @@ static void test_try_transform(void)
else else
generate_transform_manual(); generate_transform_manual();
r = MsiOpenDatabase(msifile2, MSIDBOPEN_DIRECT, &hdb ); r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb );
ok( r == ERROR_SUCCESS , "Failed to create database\n" ); ok( r == ERROR_SUCCESS , "Failed to create database\n" );
r = MsiDatabaseApplyTransform( hdb, mstfile, 0 ); r = MsiDatabaseApplyTransform( hdb, mstfile, 0 );
...@@ -2423,11 +2440,10 @@ static void test_try_transform(void) ...@@ -2423,11 +2440,10 @@ static void test_try_transform(void)
MsiCloseHandle(hrec); MsiCloseHandle(hrec);
MsiCloseHandle(hview); MsiCloseHandle(hview);
MsiCloseHandle(hdb);
/* check that the property was added */ /* check that the property was added */
r = MsiOpenPackage(msifile2, &hpkg); hpkg = package_from_db(hdb);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(hpkg != 0, "Expected non-NULL hpkg\n");
sz = MAX_PATH; sz = MAX_PATH;
r = MsiGetProperty(hpkg, "prop", buffer, &sz); r = MsiGetProperty(hpkg, "prop", buffer, &sz);
...@@ -2435,9 +2451,9 @@ static void test_try_transform(void) ...@@ -2435,9 +2451,9 @@ static void test_try_transform(void)
ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer); ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer);
MsiCloseHandle(hpkg); MsiCloseHandle(hpkg);
MsiCloseHandle(hdb);
DeleteFile(msifile); DeleteFile(msifile);
DeleteFile(msifile2);
DeleteFile(mstfile); DeleteFile(mstfile);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment