MSICALib/MSITSCA.h

115 lines
3.3 KiB
C++

#ifndef __MSITSCA_H__
#define __MSITSCA_H__
////////////////////////////////////////////////////////////////////////////
// Konstante
////////////////////////////////////////////////////////////////////////////
#define MSITSCA_VERSION 0x01000000
#define MSITSCA_VERSION_MAJ 1
#define MSITSCA_VERSION_MIN 0
#define MSITSCA_VERSION_REV 0
#define MSITSCA_VERSION_STR "1.0"
#define MSITSCA_VERSION_INST "1.0.0.0"
////////////////////////////////////////////////////////////////////
// Kode virov
////////////////////////////////////////////////////////////////////
#define IDR_MAINFRAME 1
// TODO: Dodaj definicije konstant virov tukaj.
#if !defined(RC_INVOKED) && !defined(MIDL_PASS)
#include <msi.h>
////////////////////////////////////////////////////////////////////
// Naèin klicanja funkcij
////////////////////////////////////////////////////////////////////
#if defined(MSITSCA_DLL)
#define MSITSCA_API __declspec(dllexport)
#elif defined(MSITSCA_DLLIMP)
#define MSITSCA_API __declspec(dllimport)
#else
#define MSITSCA_API
#endif
////////////////////////////////////////////////////////////////////
// Javne funkcije
////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
extern "C" {
#endif
UINT MSITSCA_API EvaluateScheduledTasks(MSIHANDLE hInstall);
UINT MSITSCA_API InstallScheduledTasks(MSIHANDLE hInstall);
UINT MSITSCA_API CommitScheduledTasks(MSIHANDLE hInstall);
UINT MSITSCA_API RollbackScheduledTasks(MSIHANDLE hInstall);
#ifdef __cplusplus
}
#endif
////////////////////////////////////////////////////////////////////
// Globalne funkcije in spremenljivke
////////////////////////////////////////////////////////////////////
namespace MSITSCA {
extern HINSTANCE hInstance; // roèica modula
}
////////////////////////////////////////////////////////////////////
// Lokalni include
////////////////////////////////////////////////////////////////////
#include <msiquery.h>
////////////////////////////////////////////////////////////////////
// Funkcije inline
////////////////////////////////////////////////////////////////////
inline UINT MsiRecordGetString(MSIHANDLE hRecord, unsigned int iField, CString &sValue)
{
DWORD dwSize = 0;
UINT uiResult;
// Query the actual string length first.
uiResult = ::MsiRecordGetString(hRecord, iField, _T(""), &dwSize);
if (uiResult == ERROR_MORE_DATA) {
// Prepare the buffer to read the string data into and read it.
LPTSTR szBuffer = sValue.GetBuffer(dwSize++);
uiResult = ::MsiRecordGetString(hRecord, iField, szBuffer, &dwSize);
if (uiResult == ERROR_SUCCESS) {
// Read succeeded.
sValue.ReleaseBuffer(dwSize);
return ERROR_SUCCESS;
} else {
// Read failed. Empty the string and return error code.
sValue.ReleaseBuffer(0);
return uiResult;
}
} else if (uiResult == ERROR_SUCCESS) {
// The string in database is empty.
sValue.Empty();
return ERROR_SUCCESS;
} else {
// Return error code.
return uiResult;
}
}
#endif // !defined(RC_INVOKED) && !defined(MIDL_PASS)
#endif // __MSITSCA_H__