本文整理汇总了C++中MsiCloseHandle函数的典型用法代码示例。如果您正苦于以下问题:C++ MsiCloseHandle函数的具体用法?C++ MsiCloseHandle怎么用?C++ MsiCloseHandle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MsiCloseHandle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetMsiProperty
void GetMsiProperty (MSIHANDLE hModule, char* propertyValue, char* propertyName) {
if(!propertyName)
return;
MSIHANDLE hRecord, hView, hDatabase;
// get hView & hDatabase
hDatabase = MsiGetActiveDatabase(hModule);
char pSelectSql[256] = {0};
sprintf(pSelectSql, "select * from Property where `Property`='%s'", propertyName);
MsiDatabaseOpenView(hDatabase, pSelectSql, &hView);
MsiViewExecute(hView, NULL);
DWORD dwLength = 256;
if (MsiViewFetch(hView, &hRecord) != ERROR_SUCCESS)
return;
MsiRecordGetString(hRecord, 2, propertyValue, &dwLength);
// close all handles
MsiCloseHandle(hRecord);
MsiViewClose(hView);
MsiCloseHandle(hView);
MsiCloseHandle(hDatabase);
}
示例2: MsiCloseHandle
/////////////////////////////////////////////////////////////////////
//
// Function: BOINCCABase::~BOINCCABase
//
// Description: Cleanup up allocation resources.
//
/////////////////////////////////////////////////////////////////////
BOINCCABase::~BOINCCABase()
{
if (m_phActionStartRec)
{
MsiCloseHandle(m_phActionStartRec);
m_phActionStartRec = NULL;
}
if (m_phActionDataRec)
{
MsiCloseHandle(m_phActionDataRec);
m_phActionDataRec = NULL;
}
if (m_phProgressRec)
{
MsiCloseHandle(m_phProgressRec);
m_phProgressRec = NULL;
}
if (m_phLogInfoRec)
{
MsiCloseHandle(m_phLogInfoRec);
m_phLogInfoRec = NULL;
}
m_strActionName.clear();
m_strProgressTitle.clear();
}
示例3: FillListbox
UINT __stdcall FillListbox(MSIHANDLE hInstall)
{
HRESULT hr = S_OK;
UINT er = ERROR_SUCCESS;
hr = WcaInitialize(hInstall, "FillListbox");
ExitOnFailure(hr, "Failed to initialize");
WcaLog(LOGMSG_STANDARD, "Initialized.");
// TODO: Add your custom action code here.
MSIHANDLE hTable = NULL;
MSIHANDLE hColumns = NULL;
MSIDBERROR dbErr = MSIDBERROR_NOERROR;
WcaLog(LOGMSG_STANDARD, "AddingTempRecord %d hTable = %x hColumns = %x dbErr = %d.", 0, hTable, hColumns, dbErr);
hr = WcaAddTempRecord (&hTable, &hColumns, L"ListBox", &dbErr, 0, 3, L"LISTBOXVALUES", 1, L"Item 1");
WcaLog(LOGMSG_STANDARD, "AddingTempRecord %d hTable = %x hColumns = %x dbErr = %d.", 1, hTable, hColumns, dbErr);
hr = WcaAddTempRecord (&hTable, &hColumns, L"ListBox", &dbErr, 0, 3, L"LISTBOXVALUES", 2, L"Item 2");
WcaLog(LOGMSG_STANDARD, "AddingTempRecord %d hTable = %x hColumns = %x dbErr = %d.", 2, hTable, hColumns, dbErr);
hr = WcaAddTempRecord (&hTable, &hColumns, L"ListBox", &dbErr, 0, 3, L"LISTBOXVALUES", 3, L"Item 3");
WcaLog(LOGMSG_STANDARD, "AddingTempRecord %d hTable = %x hColumns = %x dbErr = %d.", 3, hTable, hColumns, dbErr);
if (hTable)
MsiCloseHandle (hTable);
if (hColumns)
MsiCloseHandle (hColumns);
LExit:
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
return WcaFinalize(er);
}
示例4: msidbExportStream
/***********************************************************************
* msidbExportStream
*
* Exports a stream to a file with an .idb extension.
*
* Examples (note wildcard escape for *nix/bash):
* msidb -d <pathtomsi>.msi -f <workdir> -x <streamname>
* msidb -d <pathtomsi>.msi -f <workdir> -x data.cab
**********************************************************************/
static BOOL msidbExportStream(LPCWSTR dbfile, LPCWSTR wdir, LPCWSTR streamName)
{
static const char ext[] = {'.', 'i', 'd', 'b', 0};
UINT r, len;
MSIHANDLE dbhandle, streamListView, rec;
char queryBuffer[100];
FILE *fp = 0;
char *streamNameA = strdupWtoA(CP_ACP, streamName);
char *wdirA = strdupWtoA(CP_ACP, wdir);
char *streamFileA = 0;
char streamPath[MAX_PATH];
char *dataBuffer;
DWORD dataLen = 0;
r = MsiOpenDatabaseW(dbfile, (LPCWSTR) MSIDBOPEN_READONLY, &dbhandle);
if (r != ERROR_SUCCESS) return FALSE;
sprintf(queryBuffer, "SELECT * FROM _Streams WHERE Name = '%s'", streamNameA);
MsiDatabaseOpenView(dbhandle, queryBuffer, &streamListView);
MsiViewExecute(streamListView, 0);
r = MsiViewFetch(streamListView, &rec);
if (r != ERROR_SUCCESS) return FALSE;
if (MsiRecordReadStream(rec, 2, 0, &dataLen) != ERROR_SUCCESS)
return FALSE;
dataBuffer = malloc(dataLen);
if (!dataBuffer) return FALSE;
if (MsiRecordReadStream(rec, 2, dataBuffer, &dataLen) != ERROR_SUCCESS)
return FALSE;
len = strlen(streamNameA) + 5;
streamFileA = malloc(len);
if (streamFileA == NULL) return FALSE;
strcpy(streamFileA, streamNameA);
strcat(streamFileA, ext);
strcpy(streamPath, wdirA);
strcat(streamPath, PATH_DELIMITER);
strcat(streamPath, streamFileA);
fp = fopen(streamPath , "wb");
if (fp != NULL)
{
fwrite(dataBuffer, 1, dataLen, fp);
fclose(fp);
}
free(streamFileA);
MsiCloseHandle(rec);
MsiViewClose(streamListView);
MsiCloseHandle(streamListView);
MsiCloseHandle(dbhandle);
free(wdirA);
free(streamNameA);
return TRUE;
}
示例5: msierror
static PyObject*
msierror(int status)
{
int code;
char buf[2000];
char *res = buf;
DWORD size = sizeof(buf);
MSIHANDLE err = MsiGetLastErrorRecord();
if (err == 0) {
switch(status) {
case ERROR_ACCESS_DENIED:
PyErr_SetString(MSIError, "access denied");
return NULL;
case ERROR_FUNCTION_FAILED:
PyErr_SetString(MSIError, "function failed");
return NULL;
case ERROR_INVALID_DATA:
PyErr_SetString(MSIError, "invalid data");
return NULL;
case ERROR_INVALID_HANDLE:
PyErr_SetString(MSIError, "invalid handle");
return NULL;
case ERROR_INVALID_STATE:
PyErr_SetString(MSIError, "invalid state");
return NULL;
case ERROR_INVALID_PARAMETER:
PyErr_SetString(MSIError, "invalid parameter");
return NULL;
case ERROR_OPEN_FAILED:
PyErr_SetString(MSIError, "open failed");
return NULL;
case ERROR_CREATE_FAILED:
PyErr_SetString(MSIError, "create failed");
return NULL;
default:
PyErr_Format(MSIError, "unknown error %x", status);
return NULL;
}
}
code = MsiRecordGetInteger(err, 1); /* XXX code */
if (MsiFormatRecord(0, err, res, &size) == ERROR_MORE_DATA) {
res = malloc(size+1);
if (res == NULL) {
MsiCloseHandle(err);
return PyErr_NoMemory();
}
MsiFormatRecord(0, err, res, &size);
res[size]='\0';
}
MsiCloseHandle(err);
PyErr_SetString(MSIError, res);
if (res != buf)
free(res);
return NULL;
}
示例6: test_summary_binary
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 );
}
示例7: msidbExportStorage
static BOOL msidbExportStorage(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR storageName)
{
UINT r, len;
MSIHANDLE dbhandle, view, rec;
char queryBuffer[100];
char *storageNameA = strdupWtoA(CP_ACP, storageName);
char *wdirA = strdupWtoA(CP_ACP, wdir);
char *storagePath = NULL;
char *dataBuffer;
DWORD dataLen = 0;
FILE *fp = NULL;
sprintf(queryBuffer, "SELECT * FROM _Storages WHERE Name = '%s'", storageNameA);
r = MsiOpenDatabaseW(dbfile, (LPWSTR) MSIDBOPEN_READONLY, &dbhandle);
if (r != ERROR_SUCCESS) return FALSE;
MsiDatabaseOpenView(dbhandle, queryBuffer, &view);
MsiViewExecute(view, 0);
r = MsiViewFetch(view, &rec);
if (r != ERROR_SUCCESS) return FALSE;
if ((r = MsiRecordReadStream(rec, 2, 0, &dataLen)) != ERROR_SUCCESS)
{
return FALSE;
}
if ((dataBuffer = malloc(dataLen)) == NULL) return FALSE;
if (MsiRecordReadStream(rec, 2, dataBuffer, &dataLen) != ERROR_SUCCESS) return FALSE;
len = strlen(wdirA) + strlen(storageNameA) + 2;
storagePath = malloc(len * sizeof(WCHAR));
if (storagePath == NULL) return FALSE;
strcpy(storagePath, wdirA);
strcat(storagePath, "/");
strcat(storagePath, storageNameA);
fp = fopen(storagePath , "wb");
if (fp != NULL)
{
fwrite(dataBuffer, 1, dataLen, fp);
fclose(fp);
}
free(storagePath);
MsiCloseHandle(rec);
MsiViewClose(view);
MsiCloseHandle(view);
MsiCloseHandle(dbhandle);
free(storageNameA);
free(wdirA);
return TRUE;
}
示例8: msidbImportStorages
static BOOL msidbImportStorages(LPCWSTR dbfile, LPCWSTR wdir, LPWSTR storageNames[])
{
static const WCHAR delim[] = {'/', 0};
UINT r, len, i;
MSIHANDLE dbhandle, view, rec;
WCHAR *storagePath = 0;
char *query = "INSERT INTO _Storages (Name, Data) VALUES(?, ?)";
r = MsiOpenDatabaseW(dbfile, (LPWSTR) MSIDBOPEN_TRANSACT, &dbhandle);
if (r != ERROR_SUCCESS) return FALSE;
r = MsiDatabaseOpenView(dbhandle, query, &view);
if (r != ERROR_SUCCESS) return FALSE;
MsiViewExecute(view, 0);
r = MsiViewFetch(view, &rec);
if (r != ERROR_SUCCESS) return FALSE;
for (i = 0; i < MAX_STORAGES && storageNames[i] != 0; ++i)
{
len = lstrlenW(wdir) + lstrlenW(storageNames[i]) + 2;
storagePath = malloc(len * sizeof(WCHAR));
if (storagePath == NULL) return FALSE;
lstrcpyW(storagePath, wdir);
lstrcatW(storagePath, delim);
lstrcatW(storagePath, storageNames[i]);
rec = MsiCreateRecord(2);
MsiRecordSetStringW(rec, 1, storageNames[i]);
r = MsiRecordSetStreamW(rec, 2, storagePath);
if (r != ERROR_SUCCESS)
{
return FALSE;
}
r = MsiViewExecute(view, rec);
if (r != ERROR_SUCCESS)
{
return FALSE;
}
MsiCloseHandle(rec);
}
MsiViewClose(view);
MsiCloseHandle(view);
MsiDatabaseCommit(dbhandle);
MsiCloseHandle(dbhandle);
return TRUE;
}
示例9: msiobj_dealloc
static void
msiobj_dealloc(msiobj* msidb)
{
MsiCloseHandle(msidb->h);
msidb->h = 0;
PyObject_Del(msidb);
}
示例10: create_database
static void create_database(const CHAR *name, const msi_table *tables, int num_tables)
{
MSIHANDLE db;
UINT r;
int j;
r = MsiOpenDatabaseA(name, MSIDBOPEN_CREATE, &db);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
/* import the tables into the database */
for (j = 0; j < num_tables; j++)
{
const msi_table *table = &tables[j];
write_file(table->filename, table->data, (table->size - 1) * sizeof(char));
r = MsiDatabaseImportA(db, CURR_DIR, table->filename);
todo_wine
{
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
}
DeleteFileA(table->filename);
}
write_msi_summary_info(db);
r = MsiDatabaseCommit(db);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
MsiCloseHandle(db);
}
示例11: test_MsiSetComponentState
static void test_MsiSetComponentState(void)
{
MSIHANDLE package;
char path[MAX_PATH];
UINT r;
CoInitialize(NULL);
lstrcpy(path, CURR_DIR);
lstrcat(path, "\\");
lstrcat(path, msifile);
r = MsiOpenPackage(path, &package);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
r = MsiDoAction(package, "CostInitialize");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
r = MsiDoAction(package, "FileCost");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
r = MsiDoAction(package, "CostFinalize");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
r = MsiSetComponentState(package, "dangler", INSTALLSTATE_SOURCE);
todo_wine
{
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
}
MsiCloseHandle(package);
CoUninitialize();
}
示例12: test_MsiRecordGetString
static void test_MsiRecordGetString(void)
{
MSIHANDLE rec;
CHAR buf[MAX_PATH];
DWORD sz;
UINT r;
rec = MsiCreateRecord(2);
ok(rec != 0, "Expected a valid handle\n");
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, ""), "Expected \"\", got \"%s\"\n", buf);
ok(sz == 0, "Expected 0, got %d\n", sz);
sz = MAX_PATH;
lstrcpyA(buf, "apple");
r = MsiRecordGetString(rec, 10, buf, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
ok(sz == 0, "Expected 0, got %d\n", sz);
MsiCloseHandle(rec);
}
示例13: MsiCloseHandle
Record::~Record()
{
if ( _handle != 0 )
{
MsiCloseHandle( _handle ) ;
}
}
示例14: getMsiProductCode
String getMsiProductCode() {
String productGuid = kEmptyString;
// Copy msi file from resources to the temp folder
prepareMsiData(kEnglishLocalId);
MSIHANDLE msiHandle;
String path = getTmpPath() + kMsiFileName;
// Open msi file
UINT result = MsiOpenPackageEx(path.c_str(),
MSIOPENPACKAGEFLAGS_IGNOREMACHINESTATE, &msiHandle);
if (result != ERROR_SUCCESS) {
return productGuid;
}
// Get Product code property string length
DWORD length = 0;
result = MsiGetProperty(msiHandle, _T("ProductCode"), _T(""), &length);
if (ERROR_MORE_DATA != result) {
return productGuid;
}
// Get Product code property
// increment length for termination character
Char* productCode = new Char[++length];
MsiGetProperty(msiHandle, _T("ProductCode"), productCode, &length);
productGuid = productCode;
delete[] productCode;
// Delete msi file from temp folder, close handles
MsiCloseHandle(msiHandle);
DeleteFile(path.c_str());
return productGuid;
}
示例15: msiPack
msiPack(std::wstring file) : hProduct(NULL),m_msiFile(file) {
MsiOpenPackage(m_msiFile.c_str(),&hProduct);
DWORD sz = sizeof(prodCode);
MsiGetProductProperty(hProduct,L"ProductCode",prodCode,&sz);
MsiCloseHandle(hProduct);
hProduct = NULL;
}