Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msi/database.c | 11 ++++++++--- dlls/msi/msiquery.c | 15 ++++++--------- dlls/msi/tests/custom.c | 22 ++++++++++++++++++++++ dlls/msi/winemsi.idl | 2 +- 4 files changed, 37 insertions(+), 13 deletions(-)
diff --git a/dlls/msi/database.c b/dlls/msi/database.c index c1cf493..7c0c4a9 100644 --- a/dlls/msi/database.c +++ b/dlls/msi/database.c @@ -1911,10 +1911,15 @@ MSICONDITION __cdecl remote_DatabaseIsTablePersistent(MSIHANDLE db, LPCWSTR tabl return MsiDatabaseIsTablePersistentW(db, table); }
-HRESULT __cdecl remote_DatabaseGetPrimaryKeys(MSIHANDLE db, LPCWSTR table, MSIHANDLE *keys) +UINT __cdecl remote_DatabaseGetPrimaryKeys(MSIHANDLE db, LPCWSTR table, struct wire_record **rec) { - UINT r = MsiDatabaseGetPrimaryKeysW(db, table, keys); - return HRESULT_FROM_WIN32(r); + MSIHANDLE handle; + UINT r = MsiDatabaseGetPrimaryKeysW(db, table, &handle); + *rec = NULL; + if (!r) + *rec = marshal_record(handle); + MsiCloseHandle(handle); + return r; }
HRESULT __cdecl remote_DatabaseGetSummaryInformation(MSIHANDLE db, UINT updatecount, MSIHANDLE *suminfo) diff --git a/dlls/msi/msiquery.c b/dlls/msi/msiquery.c index e3bcfd8..42ee8c7 100644 --- a/dlls/msi/msiquery.c +++ b/dlls/msi/msiquery.c @@ -998,23 +998,20 @@ UINT WINAPI MsiDatabaseGetPrimaryKeysW( MSIHANDLE hdb, db = msihandle2msiinfo( hdb, MSIHANDLETYPE_DATABASE ); if( !db ) { + struct wire_record *wire_rec = NULL; MSIHANDLE remote; - HRESULT hr;
if (!(remote = msi_get_remote(hdb))) return ERROR_INVALID_HANDLE;
- hr = remote_DatabaseGetPrimaryKeys(remote, table, phRec); - - if (FAILED(hr)) + r = remote_DatabaseGetPrimaryKeys(remote, table, &wire_rec); + if (!r) { - if (HRESULT_FACILITY(hr) == FACILITY_WIN32) - return HRESULT_CODE(hr); - - return ERROR_FUNCTION_FAILED; + r = unmarshal_record(wire_rec, phRec); + free_remote_record(wire_rec); }
- return ERROR_SUCCESS; + return r; }
r = MSI_DatabaseGetPrimaryKeys( db, table, &rec ); diff --git a/dlls/msi/tests/custom.c b/dlls/msi/tests/custom.c index 79d90f0..cdefefd 100644 --- a/dlls/msi/tests/custom.c +++ b/dlls/msi/tests/custom.c @@ -391,6 +391,28 @@ static void test_db(MSIHANDLE hinst) r = MsiCloseHandle(view); ok(hinst, !r, "got %u\n", r);
+ /* test MsiDatabaseGetPrimaryKeys() */ + r = MsiDatabaseGetPrimaryKeysA(hdb, "Test", &rec); + ok(hinst, !r, "got %u\n", r); + + r = MsiRecordGetFieldCount(rec); + ok(hinst, r == 1, "got %d\n", r); + + sz = sizeof(buffer); + r = MsiRecordGetStringA(rec, 0, buffer, &sz); + ok(hinst, !r, "got %u\n", r); + ok(hinst, sz == strlen(buffer), "got size %u\n", sz); + ok(hinst, !strcmp(buffer, "Test"), "got '%s'\n", buffer); + + sz = sizeof(buffer); + r = MsiRecordGetStringA(rec, 1, buffer, &sz); + ok(hinst, !r, "got %u\n", r); + ok(hinst, sz == strlen(buffer), "got size %u\n", sz); + ok(hinst, !strcmp(buffer, "Name"), "got '%s'\n", buffer); + + r = MsiCloseHandle(rec); + ok(hinst, !r, "got %u\n", r); + r = MsiCloseHandle(hdb); ok(hinst, !r, "got %u\n", r); } diff --git a/dlls/msi/winemsi.idl b/dlls/msi/winemsi.idl index 3fbd6d2..28c3ab1 100644 --- a/dlls/msi/winemsi.idl +++ b/dlls/msi/winemsi.idl @@ -66,7 +66,7 @@ interface IWineMsiRemote [in] struct wire_record *record, [out] struct wire_record **refreshed );
MSICONDITION remote_DatabaseIsTablePersistent( [in] MSIHANDLE db, [in] LPCWSTR table ); - HRESULT remote_DatabaseGetPrimaryKeys( [in] MSIHANDLE db, [in] LPCWSTR table, [out] MSIHANDLE *keys ); + UINT remote_DatabaseGetPrimaryKeys( [in] MSIHANDLE db, [in, string] LPCWSTR table, [out] struct wire_record **keys ); HRESULT remote_DatabaseGetSummaryInformation( [in] MSIHANDLE db, [in] UINT updatecount, [out] MSIHANDLE *suminfo ); UINT remote_DatabaseOpenView( [in] MSIHANDLE db, [in, string] LPCWSTR query, [out] MSIHANDLE *view );