Exemple #1
0
static void test_summary_binary(void)
{
    const char *msifile = "winetest.msi";
    MSIHANDLE hdb = 0, hsuminfo = 0;
    UINT r, type, count;
    INT ival;
    DWORD sz;
    char sval[20];

    DeleteFile( msifile );

    test_create_database_binary();

    ok( INVALID_FILE_ATTRIBUTES != GetFileAttributes(msifile), "file doesn't exist!\n");

    /* just MsiOpenDatabase should not create a file */
    r = MsiOpenDatabase(msifile, MSIDBOPEN_READONLY, &hdb);
    ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");

    r = MsiGetSummaryInformation(hdb, NULL, 0, &hsuminfo);
    ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed\n");

    /*
     * Check what reading PID_LASTPRINTED does...
     * The string value is written to the msi file
     * but it appears that we're not allowed to read it back again.
     * We can still read its type though...?
     */
    sz = sizeof sval;
    sval[0] = 0;
    type = 0;
    r = MsiSummaryInfoGetProperty(hsuminfo, PID_LASTPRINTED, &type, NULL, NULL, sval, &sz);
    ok(r == ERROR_SUCCESS, "MsiSummaryInfoGetProperty failed\n");
    ok(!lstrcmpA(sval, "") || !lstrcmpA(sval, "7"),
        "Expected empty string or \"7\", got \"%s\"\n", sval);
    todo_wine {
    ok(type == VT_LPSTR, "Expected VT_LPSTR, got %d\n", type);
    ok(sz == 0 || sz == 1, "Expected 0 or 1, got %d\n", sz);
    }

    ival = -1;
    r = MsiSummaryInfoGetProperty(hsuminfo, PID_WORDCOUNT, &type, &ival, NULL, NULL, NULL);
    ok(r == ERROR_SUCCESS, "MsiSummaryInfoGetProperty failed\n");
    todo_wine ok( ival == 0, "value incorrect\n");

    /* looks like msi adds some of its own values in here */
    count = 0;
    r = MsiSummaryInfoGetPropertyCount( hsuminfo, &count );
    ok(r == ERROR_SUCCESS, "getpropcount failed\n");
    todo_wine ok(count == 10, "prop count incorrect\n");

    MsiCloseHandle( hsuminfo );
    MsiCloseHandle( hdb );

    DeleteFile( msifile );
}
Exemple #2
0
static void test_packagecoltypes(void)
{
    MSIHANDLE hdb, view, rec;
    char path[MAX_PATH];
    LPCSTR query;
    UINT r, count;

    CoInitialize(NULL);

    lstrcpy(path, CURR_DIR);
    lstrcat(path, "\\");
    lstrcat(path, msifile);

    r = MsiOpenDatabase(path, MSIDBOPEN_READONLY, &hdb);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);

    query = "SELECT * FROM `Media`";
    r = MsiDatabaseOpenView( hdb, query, &view );
    todo_wine
    {
        ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
    }

    r = MsiViewGetColumnInfo( view, MSICOLINFO_NAMES, &rec );
    count = MsiRecordGetFieldCount( rec );
    todo_wine
    {
        ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
        ok(count == 6, "Expected 6, got %d\n", count);
        ok(check_record(rec, 1, "DiskId"), "wrong column label\n");
        ok(check_record(rec, 2, "LastSequence"), "wrong column label\n");
        ok(check_record(rec, 3, "DiskPrompt"), "wrong column label\n");
        ok(check_record(rec, 4, "Cabinet"), "wrong column label\n");
        ok(check_record(rec, 5, "VolumeLabel"), "wrong column label\n");
        ok(check_record(rec, 6, "Source"), "wrong column label\n");
    }

    r = MsiViewGetColumnInfo( view, MSICOLINFO_TYPES, &rec );
    count = MsiRecordGetFieldCount( rec );
    todo_wine
    {
        ok(r == ERROR_SUCCESS, "MsiViewGetColumnInfo failed\n");
        ok(count == 6, "Expected 6, got %d\n", count);
        ok(check_record(rec, 1, "i2"), "wrong column label\n");
        ok(check_record(rec, 2, "i4"), "wrong column label\n");
        ok(check_record(rec, 3, "L64"), "wrong column label\n");
        ok(check_record(rec, 4, "S255"), "wrong column label\n");
        ok(check_record(rec, 5, "S32"), "wrong column label\n");
        ok(check_record(rec, 6, "S72"), "wrong column label\n");
    }

    MsiCloseHandle(hdb);
    DeleteFile(msifile);
}
Exemple #3
0
BOOL generateTransform(char * basedb, char * refdb, char * transFile, unsigned int err)
{
    MSIHANDLE dbHandle, refHandle;
    UINT r;
    r = MsiOpenDatabase(basedb, MSIDBOPEN_READONLY, &dbHandle);
    if (r != ERROR_SUCCESS) return FALSE;
    r = MsiOpenDatabase (refdb, MSIDBOPEN_READONLY, &refHandle);
    if (r != ERROR_SUCCESS) return FALSE;

    /* TODO: This isn't implemented in Wine */
    r = MsiDatabaseGenerateTransform(dbHandle, refHandle, transFile, 0, 0);
    if (r != ERROR_SUCCESS)
    {
        MsiCloseHandle(dbHandle);
        MsiCloseHandle(refHandle);
        return FALSE;
    }
    r = MsiCreateTransformSummaryInfo(dbHandle, refHandle, transFile, err, 0);
    MsiCloseHandle(dbHandle);
    MsiCloseHandle(refHandle);

    return TRUE;
}
Exemple #4
0
static void test_MsiOpenDatabase( void )
{
    UINT r;
    MSIHANDLE hdb;

    r = MsiOpenDatabase( mspfile, MSIDBOPEN_CREATE, &hdb );
    ok(r == ERROR_SUCCESS, "failed to open database %u\n", r);

    r = MsiDatabaseCommit( hdb );
    ok(r == ERROR_SUCCESS, "failed to commit database %u\n", r);
    MsiCloseHandle( hdb );

    r = MsiOpenDatabase( mspfile, MSIDBOPEN_READONLY + MSIDBOPEN_PATCHFILE, &hdb );
    ok(r == ERROR_OPEN_FAILED, "expected ERROR_OPEN_FAILED, got %u\n", r);
    DeleteFileA( mspfile );

    r = MsiOpenDatabase( mspfile, MSIDBOPEN_CREATE + MSIDBOPEN_PATCHFILE, &hdb );
    ok(r == ERROR_SUCCESS , "failed to open database %u\n", r);

    r = MsiDatabaseCommit( hdb );
    ok(r == ERROR_SUCCESS, "failed to commit database %u\n", r);
    MsiCloseHandle( hdb );

    r = MsiOpenDatabase( mspfile, MSIDBOPEN_READONLY + MSIDBOPEN_PATCHFILE, &hdb );
    ok(r == ERROR_SUCCESS, "failed to open database %u\n", r);
    MsiCloseHandle( hdb );
    DeleteFileA( mspfile );

    create_database( msifile, tables, sizeof(tables) / sizeof(struct msi_table) );
    create_patch( mspfile );

    r = MsiOpenDatabase( msifile, MSIDBOPEN_READONLY + MSIDBOPEN_PATCHFILE, &hdb );
    ok(r == ERROR_OPEN_FAILED, "failed to open database %u\n", r );

    r = MsiOpenDatabase( mspfile, MSIDBOPEN_READONLY + MSIDBOPEN_PATCHFILE, &hdb );
    ok(r == ERROR_SUCCESS, "failed to open database %u\n", r );
    MsiCloseHandle( hdb );

    DeleteFileA( msifile );
    DeleteFileA( mspfile );
}
Exemple #5
0
static void test_suminfo(void)
{
    const char *msifile = "winetest.msi";
    MSIHANDLE hdb = 0, hsuminfo;
    UINT r, count, type;
    DWORD sz;
    INT val;
    FILETIME ft;
    char buf[0x10];

    DeleteFile(msifile);

    /* just MsiOpenDatabase should not create a file */
    r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
    ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");

    r = MsiGetSummaryInformation(hdb, NULL, 0, NULL);
    ok(r == ERROR_INVALID_PARAMETER, "MsiGetSummaryInformation wrong error\n");

    r = MsiGetSummaryInformation(hdb, NULL, 0, &hsuminfo);
    ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed\n");

    r = MsiSummaryInfoGetPropertyCount(0, NULL);
    ok(r == ERROR_INVALID_HANDLE, "getpropcount failed\n");

    r = MsiSummaryInfoGetPropertyCount(hsuminfo, NULL);
    ok(r == ERROR_SUCCESS, "getpropcount failed\n");

    count = -1;
    r = MsiSummaryInfoGetPropertyCount(hsuminfo, &count);
    ok(r == ERROR_SUCCESS, "getpropcount failed\n");
    ok(count == 0, "count should be zero\n");

    r = MsiSummaryInfoGetProperty(hsuminfo, 0, NULL, NULL, NULL, 0, NULL);
    ok(r == ERROR_SUCCESS, "getpropcount failed\n");

    r = MsiSummaryInfoGetProperty(hsuminfo, -1, NULL, NULL, NULL, 0, NULL);
    ok(r == ERROR_UNKNOWN_PROPERTY, "MsiSummaryInfoGetProperty wrong error\n");

    r = MsiSummaryInfoGetProperty(hsuminfo, PID_SECURITY+1, NULL, NULL, NULL, 0, NULL);
    ok(r == ERROR_UNKNOWN_PROPERTY, "MsiSummaryInfoGetProperty wrong error\n");

    type = -1;
    r = MsiSummaryInfoGetProperty(hsuminfo, 0, &type, NULL, NULL, 0, NULL);
    ok(r == ERROR_SUCCESS, "getpropcount failed\n");
    ok(type == 0, "wrong type\n");

    type = -1;
    val = 1234;
    r = MsiSummaryInfoGetProperty(hsuminfo, 0, &type, &val, NULL, 0, NULL);
    ok(r == ERROR_SUCCESS, "getpropcount failed\n");
    ok(type == 0, "wrong type\n");
    ok(val == 1234, "wrong val\n");

    buf[0]='x';
    buf[1]=0;
    sz = 0x10;
    r = MsiSummaryInfoGetProperty(hsuminfo, PID_REVNUMBER, &type, &val, NULL, buf, &sz);
    ok(r == ERROR_SUCCESS, "getpropcount failed\n");
    ok(buf[0]=='x', "cleared buffer\n");
    ok(sz == 0x10, "count wasn't zero\n");
    ok(type == VT_EMPTY, "should be empty\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "Mike");
    ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 1, NULL, "JungAh");
    ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 1, &ft, "Mike");
    ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_CODEPAGE, VT_I2, 1, &ft, "JungAh");
    ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiCloseHandle(hsuminfo);
    ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");

    /* try again with the update count set */
    r = MsiGetSummaryInformation(hdb, NULL, 1, &hsuminfo);
    ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, 0, VT_LPSTR, 1, NULL, NULL);
    ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_CODEPAGE, VT_LPSTR, 1, NULL, NULL);
    ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_I4, 0, NULL, "Mike");
    ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_AUTHOR, VT_I4, 0, NULL, "JungAh");
    ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_KEYWORDS, VT_I2, 0, NULL, "Mike");
    ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_COMMENTS, VT_FILETIME, 0, NULL, "JungAh");
    ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_TEMPLATE, VT_I2, 0, NULL, "Mike");
    ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_LASTAUTHOR, VT_LPSTR, 0, NULL, NULL);
    ok(r == ERROR_INVALID_PARAMETER, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_LASTSAVE_DTM, VT_FILETIME, 0, NULL, NULL);
    ok(r == ERROR_INVALID_PARAMETER, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_LASTAUTHOR, VT_LPWSTR, 0, NULL, "h\0i\0\0");
    ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_REVNUMBER, VT_I4, 0, NULL, "Jungah");
    ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_PAGECOUNT, VT_LPSTR, 1, NULL, NULL);
    ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "Mike");
    ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty failed\n");

    sz = 2;
    strcpy(buf,"x");
    r = MsiSummaryInfoGetProperty(hsuminfo, PID_TITLE, &type, NULL, NULL, buf, &sz );
    ok(r == ERROR_MORE_DATA, "MsiSummaryInfoSetProperty failed\n");
    ok(sz == 4, "count was wrong\n");
    ok(type == VT_LPSTR, "type was wrong\n");
    ok(!strcmp(buf,"M"), "buffer was wrong\n");

    sz = 4;
    strcpy(buf,"x");
    r = MsiSummaryInfoGetProperty(hsuminfo, PID_TITLE, &type, NULL, NULL, buf, &sz );
    ok(r == ERROR_MORE_DATA, "MsiSummaryInfoSetProperty failed\n");
    ok(sz == 4, "count was wrong\n");
    ok(type == VT_LPSTR, "type was wrong\n");
    ok(!strcmp(buf,"Mik"), "buffer was wrong\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "JungAh");
    ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty failed\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_CODEPAGE, VT_I2, 1, &ft, "Mike");
    ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiCloseHandle(hsuminfo);
    ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");

    /* try again with a higher update count */
    r = MsiGetSummaryInformation(hdb, NULL, 10, &hsuminfo);
    ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "JungAh");
    ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty failed\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_CODEPAGE, VT_LPSTR, 1, NULL, NULL);
    ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_CODEPAGE, VT_I2, 1, NULL, NULL);
    ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_CODEPAGE, VT_I2, 1, &ft, "Mike");
    ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiSummaryInfoSetProperty(hsuminfo, PID_AUTHOR, VT_LPSTR, 1, &ft, "Mike");
    ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n");

    r = MsiSummaryInfoPersist(hsuminfo);
    ok(r == ERROR_SUCCESS, "MsiSummaryInfoPersist failed\n");

    MsiDatabaseCommit(hdb);

    r = MsiCloseHandle(hsuminfo);
    ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");

    r = MsiCloseHandle(hdb);
    ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");

    r = DeleteFile(msifile);
    ok(r, "DeleteFile failed\n");
}
Exemple #6
0
static void test_fieldzero(void)
{
    MSIHANDLE hdb, hview, rec;
    CHAR buf[MAX_PATH];
    LPCSTR query;
    DWORD sz;
    UINT r;

    rec = MsiCreateRecord(1);
    ok(rec != 0, "Expected a valid handle\n");

    r = MsiRecordGetInteger(rec, 0);
    ok(r == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %d\n", r);

    sz = MAX_PATH;
    lstrcpyA(buf, "apple");
    r = MsiRecordGetString(rec, 0, buf, &sz);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
    ok(sz == 0, "Expectd 0, got %d\n", sz);

    r = MsiRecordIsNull(rec, 0);
    ok(r == TRUE, "Expected TRUE, got %d\n", r);

    r = MsiRecordGetInteger(rec, 1);
    ok(r == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %d\n", r);

    r = MsiRecordSetInteger(rec, 1, 42);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);

    r = MsiRecordGetInteger(rec, 0);
    ok(r == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %d\n", r);

    sz = MAX_PATH;
    lstrcpyA(buf, "apple");
    r = MsiRecordGetString(rec, 0, buf, &sz);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
    ok(sz == 0, "Expectd 0, got %d\n", sz);

    r = MsiRecordIsNull(rec, 0);
    ok(r == TRUE, "Expected TRUE, got %d\n", r);

    r = MsiRecordGetInteger(rec, 1);
    ok(r == 42, "Expected 42, got %d\n", r);

    r = MsiRecordSetString(rec, 1, "bologna");
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);

    r = MsiRecordGetInteger(rec, 0);
    ok(r == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %d\n", r);

    sz = MAX_PATH;
    lstrcpyA(buf, "apple");
    r = MsiRecordGetString(rec, 0, buf, &sz);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
    ok(sz == 0, "Expectd 0, got %d\n", sz);

    r = MsiRecordIsNull(rec, 0);
    ok(r == TRUE, "Expected TRUE, got %d\n", r);

    sz = MAX_PATH;
    lstrcpyA(buf, "apple");
    r = MsiRecordGetString(rec, 1, buf, &sz);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!lstrcmpA(buf, "bologna"), "Expected \"bologna\", got \"%s\"\n", buf);
    ok(sz == 7, "Expectd 7, got %d\n", sz);

    MsiCloseHandle(rec);

    r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
    ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");

    query = "CREATE TABLE `drone` ( "
           "`id` INT, `name` CHAR(32), `number` CHAR(32) "
           "PRIMARY KEY `id`)";
    r = MsiDatabaseOpenView(hdb, query, &hview);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    r = MsiViewExecute(hview, 0);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    r = MsiViewClose(hview);
    ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
    r = MsiCloseHandle(hview);
    ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");

    query = "INSERT INTO `drone` ( `id`, `name`, `number` )"
           "VALUES('1', 'Abe', '8675309')";
    r = MsiDatabaseOpenView(hdb, query, &hview);
    ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
    r = MsiViewExecute(hview, 0);
    ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
    r = MsiViewClose(hview);
    ok(r == ERROR_SUCCESS, "MsiViewClose failed\n");
    r = MsiCloseHandle(hview);
    ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");

    r = MsiDatabaseGetPrimaryKeysA(hdb, "drone", &rec);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);

    r = MsiRecordGetInteger(rec, 0);
    ok(r == MSI_NULL_INTEGER, "Expected MSI_NULL_INTEGER, got %d\n", r);

    sz = MAX_PATH;
    lstrcpyA(buf, "apple");
    r = MsiRecordGetString(rec, 0, buf, &sz);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    ok(!lstrcmpA(buf, "drone"), "Expected \"drone\", got \"%s\"\n", buf);
    ok(sz == 5, "Expectd 5, got %d\n", sz);

    r = MsiRecordIsNull(rec, 0);
    ok(r == FALSE, "Expected FALSE, got %d\n", r);

    MsiCloseHandle(rec);

    r = MsiDatabaseGetPrimaryKeysA(hdb, "nosuchtable", &rec);
    ok(r == ERROR_INVALID_TABLE, "Expected ERROR_INVALID_TABLE, got %d\n", r);

    query = "SELECT * FROM `drone` WHERE `id` = 1";
    r = MsiDatabaseOpenView(hdb, query, &hview);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    r = MsiViewExecute(hview, 0);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
    r = MsiViewFetch(hview, &rec);
    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);

    r = MsiRecordGetInteger(rec, 0);
    ok(r != MSI_NULL_INTEGER && r != 0, "Expected non-NULL value, got %d\n", r);

    r = MsiRecordIsNull(rec, 0);
    ok(r == FALSE, "Expected FALSE, got %d\n", r);

    r = MsiCloseHandle(hview);
    ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
    MsiCloseHandle(rec);
    MsiCloseHandle(hdb);
    DeleteFileA(msifile);
}
Exemple #7
0
i4 
main(i4 argc, char* argv[])
{

    MSIHANDLE hDatabase;
    char view[1024];
    int Branding_Width, DlgLine_Width, DlgLine_X;
    char Branding_Text[64];

    if((argc < 2) || (GetFileAttributes(argv[1])==-1))
    {
	printf ("usage:\nmsiupd <full path to MSI file>\nmsiupd <full path to MSM file> <%II_INSTALLATION%>");
	return 1;
    }
	
    if(strstr(argv[1], "Ingres SDK") != NULL)
    {
	Branding_Width=40;
	DlgLine_X=45;
	DlgLine_Width=329;
	strcpy(Branding_Text, "Ingres SDK");
    }
    else
    {
	Branding_Width=30;
	DlgLine_X=35;
	DlgLine_Width=339;
	strcpy(Branding_Text, "Ingres");
    }

    MsiOpenDatabase(argv[1], MSIDBOPEN_DIRECT, &hDatabase);
    if (!hDatabase)
	return 1;

    if (argc==2 && strstr(argv[1], ".msi"))
    {
	/*
	** Change the brandings on each page from InstallShield to
	** Advantage Ingres.
	*/
	sprintf(view, "UPDATE Control SET Width = '%d' WHERE Control = 'Branding1'", Branding_Width);
	if(!ViewExecute(hDatabase, view))
	    return 1;
	sprintf(view, "UPDATE Control SET Width = '%d' WHERE Control = 'Branding2'", Branding_Width);
	if(!ViewExecute(hDatabase, view))
	    return 1;

	sprintf(view, "UPDATE Control SET X = '%d' WHERE Control = 'DlgLine'", DlgLine_X );
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET X = '0' WHERE Dialog_ = 'AdminWelcome' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET X = '0' WHERE Dialog_ = 'InstallWelcome' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET X = '0' WHERE Dialog_ = 'PatchWelcome' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET X = '0' WHERE Dialog_ = 'SetupCompleteError' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET X = '0' WHERE Dialog_ = 'SetupInterrupted' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET X = '0' WHERE Dialog_ = 'SetupCompleteSuccess' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET X = '0' WHERE Dialog_ = 'SetupInitialization' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET X = '0' WHERE Dialog_ = 'SetupResume' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET X = '0' WHERE Dialog_ = 'MaintenanceWelcome'AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;

	sprintf(view, "UPDATE Control SET Width = '%d' WHERE Control = 'DlgLine'", DlgLine_Width );
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Width = '374' WHERE Dialog_ = 'AdminWelcome' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Width = '374' WHERE Dialog_ = 'InstallWelcome' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Width = '374' WHERE Dialog_ = 'PatchWelcome' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Width = '374' WHERE Dialog_ = 'SetupCompleteError' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Width = '374' WHERE Dialog_ = 'SetupInterrupted' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Width = '374' WHERE Dialog_ = 'SetupCompleteSuccess' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Width = '374' WHERE Dialog_ = 'SetupInitialization' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Width = '374' WHERE Dialog_ = 'SetupResume' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Width = '374' WHERE Dialog_ = 'MaintenanceWelcome' AND Control = 'DlgLine'");
	if(!ViewExecute(hDatabase, view))
	    return 1;

	sprintf(view, "UPDATE Control SET Text = '{&MSSWhiteSerif8}%s' WHERE Control = 'Branding1'", Branding_Text);
	if(!ViewExecute(hDatabase, view))
		return 1;

	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'AdminWelcome' AND Control = 'Branding1'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'InstallWelcome' AND Control = 'Branding1'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'PatchWelcome' AND Control = 'Branding1'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupCompleteError' AND Control = 'Branding1'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupInterrupted' AND Control = 'Branding1'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupCompleteSuccess' AND Control = 'Branding1'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupInitialization' AND Control = 'Branding1'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupResume' AND Control = 'Branding1'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'MaintenanceWelcome'AND Control = 'Branding1'");
	if(!ViewExecute(hDatabase, view))
	    return 1;

	sprintf(view, "UPDATE Control SET Text = '{&Tahoma8}%s' WHERE Control = 'Branding2'", Branding_Text);
	if(!ViewExecute(hDatabase, view))
		return 1;

	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'AdminWelcome' AND Control = 'Branding2'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'InstallWelcome' AND Control = 'Branding2'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'PatchWelcome' AND Control = 'Branding2'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupCompleteError' AND Control = 'Branding2'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupInterrupted' AND Control = 'Branding2'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupCompleteSuccess' AND Control = 'Branding2'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupInitialization' AND Control = 'Branding2'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'SetupResume' AND Control = 'Branding2'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
	strcpy(view,  "UPDATE Control SET Text = '' WHERE Dialog_ = 'MaintenanceWelcome'AND Control = 'Branding2'");
	if(!ViewExecute(hDatabase, view))
	    return 1;
    }
    else if(argc==3 && strstr(argv[1], ".msm"))
    {
	/* Update Merge Module database with II_INSTALLATION. */
	MSIHANDLE hView, hRecord;
	int idx;
	char szID[3];

	strcpy(szID, _strupr(argv[2]));

	if (strlen(szID)!=2 || !isalpha(szID[0]) || !isalnum(szID[1]))
	{
	    printf ("Invalid installation identifier!");
	    return 1;
	}

	if (!strcmp(szID, "II"))
	{
	    if(MsiDatabaseCommit(hDatabase)!=ERROR_SUCCESS)
		return 1;
	    if(MsiCloseHandle(hDatabase)!=ERROR_SUCCESS)
		return 1;

	    return 0;
	}

	/* Update shortcut folders. */
	if (!MsiDatabaseOpenView
	(hDatabase, "SELECT Directory, DefaultDir FROM Directory", &hView))
	{
	    if (!MsiViewExecute(hView, 0))
	    {
		while (MsiViewFetch(hView, &hRecord)!=ERROR_NO_MORE_ITEMS)
		{
		    char szValue[80];
		    DWORD dwSize=sizeof(szValue);
			
		    MsiRecordGetString(hRecord, 2, szValue, &dwSize);
		    if (strstr(szValue, "Ingres II [ "))
			sprintf(szValue, "Ingres II [ %s ]", szID);
		    else if (strstr(szValue, "Ingres [ "))
			sprintf(szValue, "Ingres [ %s ]", szID);
		    MsiRecordSetString(hRecord, 2, szValue);
		    MsiViewModify(hView, MSIMODIFY_UPDATE, hRecord);
		    MsiCloseHandle(hRecord);
		}
	    }
	    MsiCloseHandle(hView);
	}
	
	/* Update IVM Startup shortcut. */
	if (!MsiDatabaseOpenView(hDatabase, "SELECT Name, Component_ FROM Shortcut", &hView))
	{
	    if(!MsiViewExecute(hView, 0))
	    {
		while (MsiViewFetch(hView, &hRecord)!=ERROR_NO_MORE_ITEMS)
		{
		    char szValue[80], szValue2[80];
		    DWORD dwSize, dwSize2;
			
		    dwSize=sizeof(szValue); 
		    dwSize2=sizeof(szValue2);
		    MsiRecordGetString(hRecord, 1, szValue, &dwSize);
		    MsiRecordGetString(hRecord, 2, szValue2, &dwSize2);
		    if (strstr(szValue, "Ingres Visual Manager [ ") 
		        && strstr(szValue2, "Shortcuts.") 
		        && !strstr(szValue2, "SDKShortcuts."))
			sprintf(szValue, "Ingres Visual Manager [ %s ]", szID);
		    MsiRecordSetString(hRecord, 1, szValue);
		    MsiViewModify(hView, MSIMODIFY_UPDATE, hRecord);
		    MsiCloseHandle(hRecord);
		}
	    }
	    MsiCloseHandle(hView);
	}

	/* Update Component GUIDs. */
	idx = (toupper(szID[0]) - 'A') * 26 + toupper(szID[1]) - 'A';
	if (idx <= 0)
	    idx = (toupper(szID[0]) - 'A') * 26 + toupper(szID[1]) - '0';

	UpdateComponentIds(hDatabase, idx);

    }
    else
    {
	printf ("usage:\nmsiupd <full path to MSI file>\nmsiupd <full path to MSM file> <%II_INSTALLATION%>");
	return 1;
    }

    if(MsiDatabaseCommit(hDatabase)!=ERROR_SUCCESS)
	return 1;
    if(MsiCloseHandle(hDatabase)!=ERROR_SUCCESS)
	return 1;
	
    return 0;
}