#pragma once
//CRT headers.
#include <TCHAR.H>
//windows platform headers.
#include <WINDOWS.H>
//msi headers.
#pragma comment(lib,"msi.lib")
#include <MSI.H>
#include <MSIQUERY.H>
INT APIENTRY _tWinMain(
HINSTANCE,
HINSTANCE,
LPTSTR,
INT)
{
MSIHANDLE msiHandle=NULL;
//create msi database.
UINT openResult=MsiOpenDatabase(
_T("Setup.msi"),
MSIDBOPEN_CREATEDIRECT,
&msiHandle);
//create msil database failed.
if(openResult != ERROR_SUCCESS)
{
LPVOID formatMsg=NULL;
MSIHANDLE errorCode=MsiGetLastErrorRecord();
//format error code to string.
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
errorCode,
MAKELANGID(LANG_NEUTRAL,SUBLANG_SYS_DEFAULT),
(LPTSTR)&formatMsg,
0,
NULL);
//output error message.
MessageBoxEx(
NULL,
(LPTSTR)formatMsg,
_T("tip window"),
MB_OK,
MAKELANGID(LANG_NEUTRAL,SUBLANG_SYS_DEFAULT));
//free message buffer.
LocalFree(formatMsg);
formatMsg=NULL;
return -1;
}
//commit msi database.
UINT commitResult=MsiDatabaseCommit(msiHandle);
if(commitResult != ERROR_SUCCESS)
{
LPVOID formatMsg=NULL;
MSIHANDLE errorCode=MsiGetLastErrorRecord();
//format error code to string.
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
errorCode,
MAKELANGID(LANG_NEUTRAL,SUBLANG_SYS_DEFAULT),
(LPTSTR)&formatMsg,
0,
NULL);
//output error message.
MessageBoxEx(
NULL,
(LPTSTR)formatMsg,
_T("tip window"),
MB_OK,
MAKELANGID(LANG_NEUTRAL,SUBLANG_SYS_DEFAULT));
//free message buffer.
LocalFree(formatMsg);
formatMsg=NULL;
return -1;
}
//close msi database handle.
UINT closeResult=MsiCloseHandle(msiHandle);
if(closeResult != ERROR_SUCCESS)
{
LPVOID formatMsg=NULL;
MSIHANDLE errorCode=MsiGetLastErrorRecord();
//format error code to string.
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
errorCode,
MAKELANGID(LANG_NEUTRAL,SUBLANG_SYS_DEFAULT),
(LPTSTR)&formatMsg,
0,
NULL);
//output error message.
MessageBoxEx(
NULL,
(LPTSTR)formatMsg,
_T("tip window"),
MB_OK,
MAKELANGID(LANG_NEUTRAL,SUBLANG_SYS_DEFAULT));
//free message buffer.
LocalFree(formatMsg);
formatMsg=NULL;
return -1;
}
return 0;
}
</SPAN>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有