프로그램에서 데이터베이스 함수 호출
사용자 지정 작업 또는 자동화 프로세스와 같은 프로그램에서 다음 데이터베이스 함수 호출하기 전에 설치 관리자는 먼저 CostInitialize 작업, fileCost 작업 및 CostFinalize 작업 실행해야 합니다.
다음은 Windows Installer에서 사용되는 데이터베이스 함수 목록입니다.
- MsiGetComponentState
- MsiGetFeatureCost
- MsiGetFeatureState
- MsiGetFeatureValidStates
- MsiGetSourcePath
- MsiGetTargetPath
- MsiSetComponentState
- msiSetFeatureState
- msiSetInstallLevel
- MsiSetTargetPath
- MsiVerifyDiskSpace
프로그램에서 MsiSetFeatureAttributes 호출하기 전에 설치 관리자는 먼저 CostInitialize 작업을 실행해야 합니다. 그런 다음 설치 관리자는 MsiSetFeatureAttributes 후 CostFinalize 작업을 실행합니다.
다음 예제에서는 프로그램에서 MsiGetTargetPath 사용할 때 함수 동작을 호출해야 하는 순서를 보여 줍니다.
#include <windows.h>
#include <Msiquery.h>
#include <tchar.h>
#pragma comment(lib, "msi.lib")
int main()
{
MSIHANDLE hInstall;
TCHAR *szBuf;
DWORD cch = 0 ;
if(MsiOpenPackage(_T("PathToPackage...."), &hInstall) == ERROR_SUCCESS)
{
if(MsiDoAction(hInstall, _T("CostInitialize"))==ERROR_SUCCESS
&& MsiDoAction(hInstall, _T("FileCost"))==ERROR_SUCCESS
&& MsiDoAction(hInstall, _T("CostFinalize"))==ERROR_SUCCESS)
{
if(MsiGetTargetPath(hInstall, _T("FolderName"), _T(""),&cch)==ERROR_MORE_DATA)
{
cch++; // add 1 to include null terminator since MsiGetTargetPath does not include it on return
szBuf = (TCHAR *) malloc(cch*sizeof(TCHAR));
if(szBuf)
{
if(MsiGetTargetPath(hInstall, _T("FolderName"), szBuf,&cch)==ERROR_SUCCESS)
{
// Add code to use szBuf here
}
free(szBuf);
}
}
}
MsiCloseHandle(hInstall);
}
return 0;
}