MSI安装逻辑设置,安装模块逻辑设置等VC++源码
MSIFunction.cpp文件内容
// dll.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#define DLLINTERFACE __declspec(dllexport)
#include "msifunction.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
typedef set<_bstr_t> bstrSet;
map<_bstr_t, bstrSet> g_MsiFileMap;
const unsigned int BUFF_SIZE = 1024;
TCHAR buff[BUFF_SIZE] = {0};
#define LOGFILENAME _T("\\U8SetupError.log")
#define MAX_LENGTH 4096
//#define IDS_OnOpenWrite 136
#ifdef _DEBUG2
ofstream logf("c:\\debug.txt", ios::app);
#endif
#import "msxml3.dll" named_guids
using namespace MSXML2;
void ReadSetFromFile(bstrSet& theSet, LPCTSTR fileName, LPCTSTR targetDir);
void WriteSetToFile(bstrSet& theSet, LPCTSTR fileName, LPCTSTR targetDir);
CString GetInstallerPath(LPCTSTR targetDir);
void GetAbstractPathValue();
//CString targetDir;
CString g_WindowsDir;
CString g_WinSysDir;
bstrSet g_bsInstalledFile;
inline void DebugPrint (LPCTSTR lpszMessage,...)
{
#ifdef _DEBUG
va_list VAList;
static TCHAR szMsgBuf[1024];
va_start(VAList,lpszMessage);
wvsprintf(szMsgBuf,lpszMessage,VAList);
va_end(VAList);
OutputDebugString(szMsgBuf);
#endif
}
inline UINT WINAPI GetSystemWindows(LPTSTR lpBuffer,UINT uSize)
{
UINT uiRet = GetSystemDirectory(lpBuffer,uSize);
if(uiRet>0&&uiRet<=uSize)
{
_tcsupr(lpBuffer);
LPTSTR lpSys = _tcsstr(lpBuffer,_T("SYSTEM32"));
if(lpSys) *--lpSys = '\0';
}
return uiRet;
}
void GetError(LPTSTR lpSource);
void _stdcall WriteLog(LPCTSTR lpSource,LPCTSTR lpMsg);
int WriteText(LPCTSTR lpSrc,LPCTSTR lpMsg);
void GetError();
void _stdcall ParserConfigFile(LPCTSTR fileName);
void GetComErr(LPTSTR lpSource,_com_error& err);
void GetParseError(MSXML2::IXMLDOMDocumentPtr pXmlDoc);
void ParserMsi(MSXML2::IXMLDOMNodeListPtr msiPtr);
void GetComErr(_com_error& err);
/
void _stdcall AddConfigFile(LPCTSTR fileName, LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
bstrSet configSet;
ReadSetFromFile(configSet, _T("ConfigSet.log"), targetDir);
TCHAR * pName = _tcsdup(fileName);
configSet.insert(_tcslwr(pName));
free(pName);
WriteSetToFile(configSet, _T("ConfigSet.log"), targetDir);
}
void _stdcall AddReinstalledFile(LPCTSTR fileName)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
TCHAR * pName = _tcsdup(fileName);
g_bsInstalledFile.insert(_tcslwr(pName));
free(pName);
}
BOOL _stdcall IsReinstalledFile(LPCTSTR fileName)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
TCHAR * pName = _tcsdup(fileName);
set<_bstr_t>::iterator bsIterator =g_bsInstalledFile.find(_tcslwr(pName));
free(pName);
if(bsIterator!=g_bsInstalledFile.end())
return TRUE;
else
return FALSE;
}
void _stdcall WriteCACompareDateFile(LPCTSTR fileName,LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
bstrSet configSet;
ReadSetFromFile(configSet, _T("CACOMPAREDATE.log"), targetDir);
TCHAR * pName = _tcsdup(fileName);
configSet.insert(_tcslwr(pName));
free(pName);
WriteSetToFile(configSet, _T("CACOMPAREDATE.log"), targetDir);
}
BOOL _stdcall IsExistCACompareDateFile(LPCTSTR fileName,LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CString result;
result = CString(targetDir) + _T("\\Installer\\CACOMPAREDATE.log");
if (PathFileExists(result) == FALSE)
return FALSE;
bstrSet configSet;
ReadSetFromFile(configSet, _T("CACOMPAREDATE.log"), targetDir);
TCHAR * pName = _tcsdup(fileName);
set<_bstr_t>::iterator bsIterator =configSet.find(_tcslwr(pName));
free(pName);
if(bsIterator!=configSet.end())
return TRUE;
else
return FALSE;
}
void _stdcall AddInstalledMsi(LPCTSTR fileName, LPCTSTR targetDir)
{
WriteLog(_T("AddInstalledMsi "), fileName);
WriteLog(_T("AddInstalledMsi "), targetDir);
AFX_MANAGE_STATE(AfxGetStaticModuleState());
#ifdef _DEBUG2
logf << "AddInstalledMsi" << fileName <<endl;
#endif
bstrSet installedSet;
ReadSetFromFile(installedSet, _T("MsiSet.log"), targetDir);
TCHAR * pName = _tcsdup(fileName);
installedSet.insert(_tcslwr(pName));
free(pName);
WriteSetToFile(installedSet, _T("MsiSet.log"), targetDir);
}
void _stdcall WriteConfigFile_bak(LPTSTR str, LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
#ifdef _DEBUG2
logf << "WriteConfigFile" <<endl;
#endif
GetAbstractPathValue();
bstrSet installedSet;
ReadSetFromFile(installedSet, _T("MsiSet.log"), targetDir);
bstrSet configSet;
ReadSetFromFile(configSet, _T("ConfigSet.log"), targetDir);
bstrSet::iterator iter;
for(iter= configSet.begin(); iter != configSet.end(); iter++)
{
ParserConfigFile(*iter);
}
#ifdef _DEBUG2
int num = installedSet.size();
int num2 = g_MsiFileMap.size();
logf << "installedSet.size " << num << endl;
logf << "g_MsiFileMap.size " << num2 << endl;
#endif
bstrSet dependencisSet;
map<_bstr_t, bstrSet >::iterator it;
for (it = g_MsiFileMap.begin(); it != g_MsiFileMap.end(); it++)
{
if(installedSet.find(it->first) == installedSet.end())
{
CString msiName = (TCHAR*)it->first;
CString fileName = CString(targetDir) + _T("\\Installer\\") + msiName.Left(msiName.GetLength() - 4) + _T(".config");
ofstream of(fileName);
if (of)
{
bstrSet fileSet = it->second;
bstrSet::iterator it2;
for(it2 = fileSet.begin(); it2 != fileSet.end(); it2++)
{
CString path=(char*)*it2;
path.Replace(_T("%windir%"), g_WindowsDir);
path.Replace(_T("%sysdir%"), g_WinSysDir);
path.Replace(_T("%targetdir%"), targetDir);
of <<(LPCTSTR)(path)<<endl;
}
of.close();
}
else
{
// CString msg;
// msg.LoadString(IDS_OnOpenWrite);
// msg += _T(":");
// msg += fileName;
// AfxMessageBox(msg);
}
dependencisSet.insert(it->first);
_tcscat(str, (char*)(it->first));
_tcscat(str, _T(","));
}
}
WriteSetToFile(dependencisSet, _T("DependenceSet.log"), targetDir);
}
//忽略大小写比较
int CompareIgnoreCase(CString str1,CString str2)
{
wchar_t *str11=new wchar_t[255];
wchar_t *str12=new wchar_t[255];
for(int i=0;i<str1.GetLength();i++)
{
str11[i]=str1[i];
}
str11[i]='\0';
for(i=0;i<str2.GetLength();i++)
{
str12[i]=str2[i];
}
str12[i]='\0';
int result= wcscmp(_wcsupr((wchar_t *)str11),wcsupr((wchar_t *)str12));
delete str11;
delete str12;
return result;
}
//add by zhangxiong
DWORD _stdcall StopService(SC_HANDLE hSCM, SC_HANDLE hService, bool fStopDependencies, DWORD dwTimeout)
{
SERVICE_STATUS ss;
DWORD dwStartTime = GetTickCount();
if (!QueryServiceStatus( hService, &ss ))
return GetLastError();
if (ss.dwCurrentState == SERVICE_STOPPED)
return ERROR_SUCCESS;
while(ss.dwCurrentState == SERVICE_STOP_PENDING )
{
Sleep( ss.dwWaitHint );
if (!QueryServiceStatus( hService, &ss ))
return GetLastError();
if (ss.dwCurrentState == SERVICE_STOPPED)
return ERROR_SUCCESS;
if (GetTickCount() - dwStartTime > dwTimeout)
return ERROR_TIMEOUT;
}
if (fStopDependencies)
{
DWORD i;
DWORD dwBytesNeeded;
DWORD dwCount;
LPENUM_SERVICE_STATUS lpDependencies = NULL;
ENUM_SERVICE_STATUS ess;
SC_HANDLE hDepService;
if ( EnumDependentServices( hService, SERVICE_ACTIVE, lpDependencies, 0, &dwBytesNeeded, &dwCount ))
{
}
else
{
if(GetLastError() != ERROR_MORE_DATA)
return GetLastError();
lpDependencies = (LPENUM_SERVICE_STATUS) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwBytesNeeded);
if (!lpDependencies)
return GetLastError();
__try
{
if (!EnumDependentServices(hService, SERVICE_ACTIVE, lpDependencies, dwBytesNeeded, &dwBytesNeeded,&dwCount))
return GetLastError();
for (i = 0; i < dwCount; i++)
{
ess = *(lpDependencies + i);
hDepService = OpenService( hSCM, ess.lpServiceName, SERVICE_STOP | SERVICE_QUERY_STATUS );
if (!hDepService )
return GetLastError();
__try
{
if (!ControlService( hDepService, SERVICE_CONTROL_STOP,&ss))
return GetLastError();
while (ss.dwCurrentState != SERVICE_STOPPED)
{
Sleep(ss.dwWaitHint);
if (!QueryServiceStatus(hDepService, &ss))
return GetLastError();
if (ss.dwCurrentState == SERVICE_STOPPED)
break;
if (GetTickCount() - dwStartTime > dwTimeout)
return ERROR_TIMEOUT;
}
}
__finally {
CloseServiceHandle( hDepService );
}
}
}
__finally
{
HeapFree( GetProcessHeap(), 0, lpDependencies );
}
}
}
if (!ControlService(hService, SERVICE_CONTROL_STOP, &ss))
return GetLastError();
while (ss.dwCurrentState != SERVICE_STOPPED)
{
Sleep(ss.dwWaitHint);
if (!QueryServiceStatus(hService, &ss))
return GetLastError();
if (ss.dwCurrentState == SERVICE_STOPPED)
break;
if (GetTickCount() - dwStartTime > dwTimeout)
return ERROR_TIMEOUT;
}
return ERROR_SUCCESS;
}
//end by zhangxiong
//add by zhangxiong
bool _stdcall GetMemory()
{
MEMORYSTATUS memStatus;
memset(&memStatus,0x00,sizeof(MEMORYSTATUS));
memStatus.dwLength=sizeof(MEMORYSTATUS);
GlobalMemoryStatus(&memStatus);
SIZE_T zt=memStatus.dwAvailVirtual;
//zt+=memStatus.dwTotalPhys;
if((float)zt/(1024.0f*1024.0f*1024.0f)> 1.0)
return true;
return false;
}
//end by zhangxiong
void _stdcall WriteConfigFile(LPTSTR str,LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
#ifdef _DEBUG2
logf << "WriteConfigFile" <<endl;
#endif
GetAbstractPathValue();
bstrSet installedSet;
ReadSetFromFile(installedSet, _T("MsiSet.log"), targetDir);
bstrSet configSet;
ReadSetFromFile(configSet, _T("ConfigSet.log"), targetDir);
bstrSet::iterator iter;
for(iter= configSet.begin(); iter != configSet.end(); iter++)
{
ParserConfigFile(*iter);
}
//处理
const int strMSINumber=38;
const int strHRNumber=10;
const int strOthersNumber=8;
CString strMSI[strMSINumber]={"u8erp-public-au.msi","u8erp-public-eai.msi","u8erp-public-uap.msi",
"u8erp-cw-nb.msi","u8erp-cw-common.msi","u8erp-cw-ca.msi","u8erp-cw-casc.msi","u8erp-cw-pm.msi",
"u8erp-cw-fm.msi","u8erp-cw-cm.msi","u8erp-crm-cs.msi","u8erp-crm-sr.msi","u8erp-scm-pu.msi","u8erp-scm-hu.msi",
"u8erp-scm-common.msi","u8erp-scm-kc.msi","u8erp-scm-pa.msi","u8erp-scm-sa.msi","u8erp-scm-ex.msi","u8erp-scm-st.msi","u8erp-scm-ja.msi",
"u8erp-scm-qm.msi","u8erp-scm-ia.msi","u8erp-crm-sr.msi","u8erp-scm-im.msi","u8erp-scm-eb.msi","u8erp-scm-hy.msi","u8erp-scm-vm.msi","u8erp-u8m-common.msi",
"u8erp-u8m-pffc.msi","u8erp-u8m-eq.msi","u8erp-bpm-fd.msi","u8erp-bpm-common.msi",
"u8erp-bpm-gf.msi","u8erp-bi-bw.msi","u8erp-scm-ez.msi","u8erp-scm-om.msi","u8erp-scm-pdm.msi"};
//hr
CString strHR[strHRNumber]={"u8erp-hr-common.msi","u8erp-hr-hm.msi","u8erp-hr-wa.msi","u8erp-hr-tm.msi",
"u8erp-hr-rt.msi","u8erp-hr-ht.msi","u8erp-hr-wm.msi","u8erp-hr-tr.msi",
"u8erp-hr-pf.msi","u8erp-hr-pr.msi"
};
CString strOthers[strOthersNumber]={"u8erp-cw-gl.msi","u8erp-cw-mr.msi","u8erp-cw-fa.msi","u8erp-cw-ar.msi","u8erp-cw-ap.msi","u8erp-cw-sc.msi","u8erp-cw-fb.msi","u8erp-cw-ne.msi"};
bool isExistsMSI=false;
bool isExistsHR=false;
bool isExistsOthers=false;
int n=0;
CString strFind(str);
bstrSet::iterator it2;
bstrSet::iterator it3;
bstrSet::iterator it4;
//判断是否在strSCM
for(int i=0;i<strMSINumber;i++)
{
for (it2 = installedSet.begin(); it2 != installedSet.end(); it2++)
{
CString msiName((char*)(*it2));
if(CompareIgnoreCase(msiName,strMSI[i]) == 0)
{
isExistsMSI=true;
break;
}
}
}
//判断是否在strHR
for(i=0;i<strHRNumber;i++)
{
for (it3 = installedSet.begin(); it3 != installedSet.end(); it3++)
{
CString msiName((char*)(*it3));
if(CompareIgnoreCase(msiName,strHR[i]) == 0)
{
isExistsHR=true;
break;
}
}
}
//判断是否在其它七个中,添加EAI
for(i=0;i<strOthersNumber;i++)
{
for (it4 = installedSet.begin(); it4 != installedSet.end(); it4++)
{
CString msiName((char*)(*it4));
if(CompareIgnoreCase(msiName,strOthers[i]) == 0)
{
isExistsOthers=true;
break;
}
}
}
_bstr_t name(L"");
bstrSet fileSet;
//添加
if(isExistsMSI)
{
_bstr_t msi;
for(i=0;i<strMSINumber;i++)
{
fileSet.insert(name);
msi=_bstr_t(strMSI[i]);
g_MsiFileMap[msi]=fileSet;
}
//添加七项
//总账
fileSet.insert(name);
msi=_bstr_t(L"u8erp-cw-gl.msi");
g_MsiFileMap[msi]=fileSet;
//UFO
fileSet.insert(name);
msi=_bstr_t(L"u8erp-cw-mr.msi");
g_MsiFileMap[msi]=fileSet;
//固定资产
fileSet.insert(name);
msi=_bstr_t(L"u8erp-cw-fa.msi");
g_MsiFileMap[msi]=fileSet;
//应收
fileSet.insert(name);
msi=_bstr_t(L"u8erp-cw-ar.msi");
g_MsiFileMap[msi]=fileSet;
//应付
fileSet.insert(name);
msi=_bstr_t(L"u8erp-cw-ap.msi");
g_MsiFileMap[msi]=fileSet;
//应付
fileSet.insert(name);
msi=_bstr_t(L"u8erp-cw-sc.msi");
g_MsiFileMap[msi]=fileSet;
//费用预算
fileSet.insert(name);
msi=_bstr_t(L"u8erp-cw-fb.msi");
g_MsiFileMap[msi]=fileSet;
//预算。
fileSet.insert(name);
msi=_bstr_t(L"u8erp-cw-ne.msi");
g_MsiFileMap[msi]=fileSet;
}
if(isExistsHR)
{
_bstr_t hr;
_bstr_t msi;
for(i=0;i<strHRNumber;i++)
{
fileSet.insert(name);
hr=_bstr_t(strHR[i]);
g_MsiFileMap[hr]=fileSet;
}
//EAI
fileSet.insert(name);
msi=_bstr_t(L"u8erp-public-eai.msi");
g_MsiFileMap[msi]=fileSet;
}
if(isExistsOthers)
{
_bstr_t others;
_bstr_t msi;
for(i=0;i<strOthersNumber;i++)
{
fileSet.insert(name);
others=_bstr_t(strOthers[i]);
g_MsiFileMap[others]=fileSet;
}
//EAI
fileSet.insert(name);
msi=_bstr_t(L"u8erp-public-eai.msi");
g_MsiFileMap[msi]=fileSet;
}
#ifdef _DEBUG2
int num = installedSet.size();
int num2 = g_MsiFileMap.size();
logf << "installedSet.size " << num << endl;
logf << "g_MsiFileMap.size " << num2 << endl;
#endif
bstrSet dependencisSet;
map<_bstr_t, bstrSet >::iterator it;
for (it = g_MsiFileMap.begin(); it != g_MsiFileMap.end(); it++)
{
if(installedSet.find(it->first) == installedSet.end())
{
CString msiName = (TCHAR*)it->first;
CString fileName = CString(targetDir) + _T("\\Installer\\") + msiName.Left(msiName.GetLength() - 4) + _T(".config");
ofstream of(fileName);
if (of)
{
bstrSet fileSet = it->second;
bstrSet::iterator it2;
for(it2 = fileSet.begin(); it2 != fileSet.end(); it2++)
{
CString path=(char*)*it2;
path.Replace(_T("%windir%"), g_WindowsDir);
path.Replace(_T("%sysdir%"), g_WinSysDir);
path.Replace(_T("%targetdir%"), targetDir);
if(path!=_T(""))
of <<(LPCTSTR)(path)<<endl;
}
of.close();
}
else
{
/*CString msg;
msg.LoadString(IDS_OnOpenWrite);
msg += _T(":");
msg += fileName;
AfxMessageBox(msg);*/
}
//CString msiName1 = (TCHAR*)it->first;
dependencisSet.insert(it->first);
//调用的地方没有分配指针
//_tcscat(str, it->first);
//_tcscat(str, _T(","));
_tcscat(str, (char*)(it->first));
_tcscat(str, _T(","));
}
}
// WriteSetToFile(dependencisSet, _T("DependenceSet.log"));
WriteSetToFile(dependencisSet, _T("DependenceSet.log"), targetDir);
}
void _stdcall AppendInstalledMsi(LPCTSTR fileName, LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
}
void _stdcall RemoveInstalledMsi(LPCTSTR fileName, LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
WriteLog(_T("RemoveInstalledMsi "), fileName);
bstrSet installedSet;
ReadSetFromFile(installedSet, _T("MsiSet.log"), targetDir);
TCHAR * pName = _tcsdup(fileName);
installedSet.erase(_tcslwr(pName));
free(pName);
WriteSetToFile(installedSet, _T("MsiSet.log"), targetDir);
}
void _stdcall GetAllDenpendenceMsi(LPTSTR str, LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
bstrSet dependencisSet;
ReadSetFromFile(dependencisSet, _T("DependenceSet.log"), targetDir);
bstrSet::iterator it;
for (it = dependencisSet.begin(); it != dependencisSet.end(); it++)
{
_tcscat(str, (char*)(*it));
_tcscat(str, _T(","));
}
WriteLog(_T("GetAllDenpendenceMsi result is "), str);
}
void _stdcall RemoveConfigFile(LPCTSTR fileName, LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
WriteLog(_T("RemoveConfigFile "), fileName);
bstrSet configSet;
ReadSetFromFile(configSet, _T("ConfigSet.log"), targetDir);
TCHAR * pName = _tcsdup(fileName);
configSet.erase(_tcslwr(pName));
free(pName);
WriteSetToFile(configSet, _T("ConfigSet.log"), targetDir);
}
void _stdcall GetAllInstalledMsi(LPTSTR str, LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
bstrSet installedSet;
ReadSetFromFile(installedSet, _T("MsiSet.log"), targetDir);
bstrSet::iterator it;
for (it = installedSet.begin(); it != installedSet.end(); it++)
{
CString msiName((char*)(*it));
_tcscat(str, msiName.Mid(6,msiName.GetLength()-10));
_tcscat(str, _T(","));
}
WriteLog(_T("GetAllInstalledMsi result is "), str);
}
void _stdcall GetAllInstalledMsiFullName(LPTSTR str, LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
bstrSet installedSet;
ReadSetFromFile(installedSet, _T("MsiSet.log"), targetDir);
bstrSet::iterator it;
for (it = installedSet.begin(); it != installedSet.end(); it++)
{
CString msiName((char*)(*it));
//_tcscat(str, msiName.Mid(6,msiName.GetLength()-10));
_tcscat(str, _T(","));
}
WriteLog(_T("GetAllInstalledMsiFullName result is "), str);
}
UINT _stdcall GetAllInstalledMsiCount(LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
bstrSet installedSet;
ReadSetFromFile(installedSet, _T("MsiSet.log"), targetDir);
CString msiStr;
bstrSet::iterator it;
for (it = installedSet.begin(); it != installedSet.end(); it++)
{
msiStr +=CString((char*)(*it))+_T(",");
}
WriteLog(_T("GetAllInstalledMsiCount"),msiStr);
return installedSet.size();
}
UINT _stdcall GetAllDenpendenceMsiCount(LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
bstrSet dependencisSet;
ReadSetFromFile(dependencisSet, _T("DependenceSet.log"), targetDir);
CString dependStr;
bstrSet::iterator it;
for (it = dependencisSet.begin(); it != dependencisSet.end(); it++)
{
dependStr +=CString((char*)(*it))+_T(",");
}
WriteLog(_T("GetAllDenpendenceMsiCount"),dependStr);
CString str;
str.Format(_T("%d"), dependencisSet.size());
WriteLog(_T("dependencisSet size"),str );
return dependencisSet.size();
}
typedef BOOL (__stdcall *CHECKVERSION)(DWORD,DWORD,DWORD,DWORD,PDWORD);
BOOL _stdcall IsWindows2008()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
HINSTANCE hinstance = LoadLibrary(_T("Kernel32.dll"));
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
BOOL bIsWindows2008 = FALSE;
CHECKVERSION ProcAdd;
if (hinstance != NULL)
{
ProcAdd = (CHECKVERSION) GetProcAddress(hinstance, TEXT("GetProductInfo"));
int iVersion;
if (NULL != ProcAdd)
{
fRunTimeLinkSuccess = TRUE;
(ProcAdd) ( (DWORD)6,(DWORD)0,(DWORD)0,(DWORD)0,(PDWORD)&iVersion );
//the Vista ProductInfo Type Number
if(
iVersion == 1 || iVersion == 2 || iVersion == 3 || iVersion == 4 ||
iVersion == 5 || iVersion == 6 || iVersion == 11 || iVersion == 16
)
bIsWindows2008 = FALSE;
//the windows2008 ProductInfo Type Number
else if(
iVersion == 7 || iVersion == 13 || iVersion == 8 || iVersion == 12 ||
iVersion == 10 || iVersion == 14 || iVersion == 17 || iVersion == 15
)
bIsWindows2008 = TRUE;
else
bIsWindows2008 = FALSE;
}
fFreeResult = FreeLibrary(hinstance);
}
if (! fRunTimeLinkSuccess)
bIsWindows2008 = FALSE;
return bIsWindows2008;
}
//-----------------------辅助函数----------------
void ReadSetFromFile(bstrSet& theSet, LPCTSTR fileName, LPCTSTR targetDir)
{
ifstream infs(GetInstallerPath(targetDir) + fileName);
if(infs)
{
while(infs.getline(buff, BUFF_SIZE))
{
theSet.insert(buff);
}
}
infs.close();
}
void WriteSetToFile(bstrSet& theSet, LPCTSTR fileName, LPCTSTR targetDir)
{
ofstream ofs(GetInstallerPath(targetDir) + fileName);
if (ofs)
{
bstrSet::iterator it;
for(it= theSet.begin(); it != theSet.end(); it++)
{
ofs << (char*)(*it) <<endl;
}
}
ofs.close();
}
CString GetInstallerPath(LPCTSTR targetDir)
{
CString result;
//if(targetDir.IsEmpty())
//{
// GetAbstractPathValue();
if (PathFileExists(targetDir) == FALSE)
{
CreateDirectory(targetDir, NULL);
}
//}
result = CString(targetDir) + _T("\\Installer\\");
if (PathFileExists(result) == FALSE)
{
CreateDirectory(result, NULL);
}
return result;
}
void GetAbstractPathValue()
{
TCHAR path[MAX_PATH+1] = {0};
//GetWindowsDirectory(path,MAX_PATH);
//for terminal service issue
GetSystemWindows(path,MAX_PATH);
g_WindowsDir = path;
ZeroMemory(path,sizeof(path));
GetSystemDirectory(path,MAX_PATH);
g_WinSysDir = path;
}
void GetError()
{
LPVOID lpMsgBuf;
if (!FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL ))
{
return;
}
WriteLog(_T("GetError"), (LPTSTR)lpMsgBuf);
LocalFree(lpMsgBuf);
}
void GetError(LPTSTR lpSource)
{
LPVOID lpMsgBuf;
if (!FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL ))
{
return;
}
WriteLog(lpSource,(LPTSTR)lpMsgBuf);
LocalFree(lpMsgBuf);
}
void _stdcall WriteLog(LPCTSTR lpSource,LPCTSTR lpMsg)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
DWORD tid = GetCurrentThreadId();
CString cstr;
cstr.Format(_T("%s[%d] %s"),_T("Thread"),tid,lpSource);
LPTSTR lpsz = new TCHAR[cstr.GetLength()+1];
ZeroMemory(lpsz,cstr.GetLength()+1);
_tcscpy(lpsz,cstr);
WriteText(lpsz,lpMsg);
delete[] lpsz;
}
int WriteText(LPCTSTR lpSrc,LPCTSTR lpMsg)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CStdioFile inputFile;
TCHAR lpFile[MAX_PATH];
ZeroMemory(lpFile,sizeof(lpFile));
GetSystemDirectory(lpFile, MAX_PATH);
_tcscat(lpFile, LOGFILENAME);
TCHAR lpMutexName[] = _T("U8SETUPERRLOG");
HANDLE hMutex;
try
{
hMutex = OpenMutex(MUTEX_ALL_ACCESS,FALSE,lpMutexName);
if(!hMutex)
{
hMutex = CreateMutex(NULL,FALSE,lpMutexName);
}
if(!hMutex)
return 0;
WaitForSingleObject(hMutex,INFINITE);
inputFile.Open(lpFile,CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite);
inputFile.SeekToEnd();
COleDateTime time = COleDateTime::GetCurrentTime();
CString sMsg = time.Format(_T("[%Y-%m-%d %H:%M:%S]"));
TCHAR* lpSource = new TCHAR[MAX_LENGTH];
ZeroMemory(lpSource,MAX_LENGTH);
_tcscpy(lpSource,lpSrc);
_tcscat(lpSource,_T(":"));
_tcscat(lpSource,lpMsg);
_tcscat(lpSource,_T("\n"));
sMsg.Insert(sMsg.GetLength(),lpSource);
inputFile.WriteString(sMsg);
inputFile.Close();
delete[] lpSource;
}
catch(...)
{
}
ReleaseMutex(hMutex);
return 0;
}
void _stdcall ParserConfigFile(LPCTSTR fileName)
{
::CoInitialize(NULL);
#ifdef _DEBUG2
logf << "ParserConfigFile " << fileName<<endl;
#endif
try
{
MSXML2::IXMLDOMDocumentPtr pXmlDoc = NULL;
_variant_t varRet((bool)TRUE);
pXmlDoc.CreateInstance("Msxml2.DOMDocument");
varRet = pXmlDoc->load(fileName);
if(!(bool)varRet)
{
#ifdef _DEBUG2
logf <<"GetParseError"<<endl;
#endif
GetParseError(pXmlDoc);
return;
}
_bstr_t name = pXmlDoc->documentElement->attributes->getNamedItem(_bstr_t("name"))->text;
MSXML2::IXMLDOMNodeListPtr nodeListprt = pXmlDoc->documentElement->childNodes;
int n = nodeListprt->length;
for (int i=0; i<nodeListprt->length; i++)
{
ParserMsi(nodeListprt->item[i]->childNodes);
}
}
catch(_com_error& err)
{
GetComErr(err);
}
catch(...)
{
GetError();
}
::CoUninitialize();
}
void GetParseError(MSXML2::IXMLDOMDocumentPtr pXmlDoc)
{
MSXML2::IXMLDOMParseErrorPtr errPtr = pXmlDoc->GetparseError();
BSTR bstrErr;
errPtr->get_reason(&bstrErr);
//AfxMessageBox((LPCTSTR)bstrErr);
USES_CONVERSION;
LPCTSTR pErrStr = OLE2T(bstrErr);
WriteLog(_T("GetParseError "), pErrStr);
SysFreeString(bstrErr);
}
void ParserMsi(MSXML2::IXMLDOMNodeListPtr msiPtr)
{
for(int i=0; i< msiPtr->length; i++)
{
const _bstr_t name = msiPtr->item[i]->attributes->getNamedItem(_bstr_t("name"))->text;
#ifdef _DEBUG2
logf << (char*)name<<endl;
#endif
MSXML2::IXMLDOMNodeListPtr filesPtr = msiPtr->item[i]->childNodes;
bstrSet fileSet;
if (g_MsiFileMap.find(name) != g_MsiFileMap.end())
{
fileSet = g_MsiFileMap[name];
}
for(int j=0; j <filesPtr->length; j++)
{
_bstr_t fileName = filesPtr->item[j]->attributes->getNamedItem(_bstr_t("name"))->text;
#ifdef _DEBUG2
logf << (char*)fileName <<endl;
#endif
fileSet.insert(fileName);
}
int n = fileSet.size();
g_MsiFileMap[name] = fileSet;
}
}
void GetComErr(LPTSTR lpSource,_com_error& err)
{
_bstr_t bstrErr(err.ErrorMessage());
bstrErr += "\n"+err.Description();
WriteLog(lpSource,(LPTSTR)bstrErr);
}
void GetComErr(_com_error& err)
{
_bstr_t bstrErr(err.ErrorMessage());
bstrErr += "\n"+err.Description();
// AfxMessageBox((LPTSTR)bstrErr);
WriteText(_T("GetComError"), (LPTSTR)bstrErr);
}
//-----------------------辅助函数----------------
// dll.cpp : Defines the initialization routines for the DLL.
//
#include "stdafx.h"
#define DLLINTERFACE __declspec(dllexport)
#include "msifunction.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
typedef set<_bstr_t> bstrSet;
map<_bstr_t, bstrSet> g_MsiFileMap;
const unsigned int BUFF_SIZE = 1024;
TCHAR buff[BUFF_SIZE] = {0};
#define LOGFILENAME _T("\\U8SetupError.log")
#define MAX_LENGTH 4096
//#define IDS_OnOpenWrite 136
#ifdef _DEBUG2
ofstream logf("c:\\debug.txt", ios::app);
#endif
#import "msxml3.dll" named_guids
using namespace MSXML2;
void ReadSetFromFile(bstrSet& theSet, LPCTSTR fileName, LPCTSTR targetDir);
void WriteSetToFile(bstrSet& theSet, LPCTSTR fileName, LPCTSTR targetDir);
CString GetInstallerPath(LPCTSTR targetDir);
void GetAbstractPathValue();
//CString targetDir;
CString g_WindowsDir;
CString g_WinSysDir;
bstrSet g_bsInstalledFile;
inline void DebugPrint (LPCTSTR lpszMessage,...)
{
#ifdef _DEBUG
va_list VAList;
static TCHAR szMsgBuf[1024];
va_start(VAList,lpszMessage);
wvsprintf(szMsgBuf,lpszMessage,VAList);
va_end(VAList);
OutputDebugString(szMsgBuf);
#endif
}
inline UINT WINAPI GetSystemWindows(LPTSTR lpBuffer,UINT uSize)
{
UINT uiRet = GetSystemDirectory(lpBuffer,uSize);
if(uiRet>0&&uiRet<=uSize)
{
_tcsupr(lpBuffer);
LPTSTR lpSys = _tcsstr(lpBuffer,_T("SYSTEM32"));
if(lpSys) *--lpSys = '\0';
}
return uiRet;
}
void GetError(LPTSTR lpSource);
void _stdcall WriteLog(LPCTSTR lpSource,LPCTSTR lpMsg);
int WriteText(LPCTSTR lpSrc,LPCTSTR lpMsg);
void GetError();
void _stdcall ParserConfigFile(LPCTSTR fileName);
void GetComErr(LPTSTR lpSource,_com_error& err);
void GetParseError(MSXML2::IXMLDOMDocumentPtr pXmlDoc);
void ParserMsi(MSXML2::IXMLDOMNodeListPtr msiPtr);
void GetComErr(_com_error& err);
/
void _stdcall AddConfigFile(LPCTSTR fileName, LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
bstrSet configSet;
ReadSetFromFile(configSet, _T("ConfigSet.log"), targetDir);
TCHAR * pName = _tcsdup(fileName);
configSet.insert(_tcslwr(pName));
free(pName);
WriteSetToFile(configSet, _T("ConfigSet.log"), targetDir);
}
void _stdcall AddReinstalledFile(LPCTSTR fileName)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
TCHAR * pName = _tcsdup(fileName);
g_bsInstalledFile.insert(_tcslwr(pName));
free(pName);
}
BOOL _stdcall IsReinstalledFile(LPCTSTR fileName)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
TCHAR * pName = _tcsdup(fileName);
set<_bstr_t>::iterator bsIterator =g_bsInstalledFile.find(_tcslwr(pName));
free(pName);
if(bsIterator!=g_bsInstalledFile.end())
return TRUE;
else
return FALSE;
}
void _stdcall WriteCACompareDateFile(LPCTSTR fileName,LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
bstrSet configSet;
ReadSetFromFile(configSet, _T("CACOMPAREDATE.log"), targetDir);
TCHAR * pName = _tcsdup(fileName);
configSet.insert(_tcslwr(pName));
free(pName);
WriteSetToFile(configSet, _T("CACOMPAREDATE.log"), targetDir);
}
BOOL _stdcall IsExistCACompareDateFile(LPCTSTR fileName,LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CString result;
result = CString(targetDir) + _T("\\Installer\\CACOMPAREDATE.log");
if (PathFileExists(result) == FALSE)
return FALSE;
bstrSet configSet;
ReadSetFromFile(configSet, _T("CACOMPAREDATE.log"), targetDir);
TCHAR * pName = _tcsdup(fileName);
set<_bstr_t>::iterator bsIterator =configSet.find(_tcslwr(pName));
free(pName);
if(bsIterator!=configSet.end())
return TRUE;
else
return FALSE;
}
void _stdcall AddInstalledMsi(LPCTSTR fileName, LPCTSTR targetDir)
{
WriteLog(_T("AddInstalledMsi "), fileName);
WriteLog(_T("AddInstalledMsi "), targetDir);
AFX_MANAGE_STATE(AfxGetStaticModuleState());
#ifdef _DEBUG2
logf << "AddInstalledMsi" << fileName <<endl;
#endif
bstrSet installedSet;
ReadSetFromFile(installedSet, _T("MsiSet.log"), targetDir);
TCHAR * pName = _tcsdup(fileName);
installedSet.insert(_tcslwr(pName));
free(pName);
WriteSetToFile(installedSet, _T("MsiSet.log"), targetDir);
}
void _stdcall WriteConfigFile_bak(LPTSTR str, LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
#ifdef _DEBUG2
logf << "WriteConfigFile" <<endl;
#endif
GetAbstractPathValue();
bstrSet installedSet;
ReadSetFromFile(installedSet, _T("MsiSet.log"), targetDir);
bstrSet configSet;
ReadSetFromFile(configSet, _T("ConfigSet.log"), targetDir);
bstrSet::iterator iter;
for(iter= configSet.begin(); iter != configSet.end(); iter++)
{
ParserConfigFile(*iter);
}
#ifdef _DEBUG2
int num = installedSet.size();
int num2 = g_MsiFileMap.size();
logf << "installedSet.size " << num << endl;
logf << "g_MsiFileMap.size " << num2 << endl;
#endif
bstrSet dependencisSet;
map<_bstr_t, bstrSet >::iterator it;
for (it = g_MsiFileMap.begin(); it != g_MsiFileMap.end(); it++)
{
if(installedSet.find(it->first) == installedSet.end())
{
CString msiName = (TCHAR*)it->first;
CString fileName = CString(targetDir) + _T("\\Installer\\") + msiName.Left(msiName.GetLength() - 4) + _T(".config");
ofstream of(fileName);
if (of)
{
bstrSet fileSet = it->second;
bstrSet::iterator it2;
for(it2 = fileSet.begin(); it2 != fileSet.end(); it2++)
{
CString path=(char*)*it2;
path.Replace(_T("%windir%"), g_WindowsDir);
path.Replace(_T("%sysdir%"), g_WinSysDir);
path.Replace(_T("%targetdir%"), targetDir);
of <<(LPCTSTR)(path)<<endl;
}
of.close();
}
else
{
// CString msg;
// msg.LoadString(IDS_OnOpenWrite);
// msg += _T(":");
// msg += fileName;
// AfxMessageBox(msg);
}
dependencisSet.insert(it->first);
_tcscat(str, (char*)(it->first));
_tcscat(str, _T(","));
}
}
WriteSetToFile(dependencisSet, _T("DependenceSet.log"), targetDir);
}
//忽略大小写比较
int CompareIgnoreCase(CString str1,CString str2)
{
wchar_t *str11=new wchar_t[255];
wchar_t *str12=new wchar_t[255];
for(int i=0;i<str1.GetLength();i++)
{
str11[i]=str1[i];
}
str11[i]='\0';
for(i=0;i<str2.GetLength();i++)
{
str12[i]=str2[i];
}
str12[i]='\0';
int result= wcscmp(_wcsupr((wchar_t *)str11),wcsupr((wchar_t *)str12));
delete str11;
delete str12;
return result;
}
//add by zhangxiong
DWORD _stdcall StopService(SC_HANDLE hSCM, SC_HANDLE hService, bool fStopDependencies, DWORD dwTimeout)
{
SERVICE_STATUS ss;
DWORD dwStartTime = GetTickCount();
if (!QueryServiceStatus( hService, &ss ))
return GetLastError();
if (ss.dwCurrentState == SERVICE_STOPPED)
return ERROR_SUCCESS;
while(ss.dwCurrentState == SERVICE_STOP_PENDING )
{
Sleep( ss.dwWaitHint );
if (!QueryServiceStatus( hService, &ss ))
return GetLastError();
if (ss.dwCurrentState == SERVICE_STOPPED)
return ERROR_SUCCESS;
if (GetTickCount() - dwStartTime > dwTimeout)
return ERROR_TIMEOUT;
}
if (fStopDependencies)
{
DWORD i;
DWORD dwBytesNeeded;
DWORD dwCount;
LPENUM_SERVICE_STATUS lpDependencies = NULL;
ENUM_SERVICE_STATUS ess;
SC_HANDLE hDepService;
if ( EnumDependentServices( hService, SERVICE_ACTIVE, lpDependencies, 0, &dwBytesNeeded, &dwCount ))
{
}
else
{
if(GetLastError() != ERROR_MORE_DATA)
return GetLastError();
lpDependencies = (LPENUM_SERVICE_STATUS) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwBytesNeeded);
if (!lpDependencies)
return GetLastError();
__try
{
if (!EnumDependentServices(hService, SERVICE_ACTIVE, lpDependencies, dwBytesNeeded, &dwBytesNeeded,&dwCount))
return GetLastError();
for (i = 0; i < dwCount; i++)
{
ess = *(lpDependencies + i);
hDepService = OpenService( hSCM, ess.lpServiceName, SERVICE_STOP | SERVICE_QUERY_STATUS );
if (!hDepService )
return GetLastError();
__try
{
if (!ControlService( hDepService, SERVICE_CONTROL_STOP,&ss))
return GetLastError();
while (ss.dwCurrentState != SERVICE_STOPPED)
{
Sleep(ss.dwWaitHint);
if (!QueryServiceStatus(hDepService, &ss))
return GetLastError();
if (ss.dwCurrentState == SERVICE_STOPPED)
break;
if (GetTickCount() - dwStartTime > dwTimeout)
return ERROR_TIMEOUT;
}
}
__finally {
CloseServiceHandle( hDepService );
}
}
}
__finally
{
HeapFree( GetProcessHeap(), 0, lpDependencies );
}
}
}
if (!ControlService(hService, SERVICE_CONTROL_STOP, &ss))
return GetLastError();
while (ss.dwCurrentState != SERVICE_STOPPED)
{
Sleep(ss.dwWaitHint);
if (!QueryServiceStatus(hService, &ss))
return GetLastError();
if (ss.dwCurrentState == SERVICE_STOPPED)
break;
if (GetTickCount() - dwStartTime > dwTimeout)
return ERROR_TIMEOUT;
}
return ERROR_SUCCESS;
}
//end by zhangxiong
//add by zhangxiong
bool _stdcall GetMemory()
{
MEMORYSTATUS memStatus;
memset(&memStatus,0x00,sizeof(MEMORYSTATUS));
memStatus.dwLength=sizeof(MEMORYSTATUS);
GlobalMemoryStatus(&memStatus);
SIZE_T zt=memStatus.dwAvailVirtual;
//zt+=memStatus.dwTotalPhys;
if((float)zt/(1024.0f*1024.0f*1024.0f)> 1.0)
return true;
return false;
}
//end by zhangxiong
void _stdcall WriteConfigFile(LPTSTR str,LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
#ifdef _DEBUG2
logf << "WriteConfigFile" <<endl;
#endif
GetAbstractPathValue();
bstrSet installedSet;
ReadSetFromFile(installedSet, _T("MsiSet.log"), targetDir);
bstrSet configSet;
ReadSetFromFile(configSet, _T("ConfigSet.log"), targetDir);
bstrSet::iterator iter;
for(iter= configSet.begin(); iter != configSet.end(); iter++)
{
ParserConfigFile(*iter);
}
//处理
const int strMSINumber=38;
const int strHRNumber=10;
const int strOthersNumber=8;
CString strMSI[strMSINumber]={"u8erp-public-au.msi","u8erp-public-eai.msi","u8erp-public-uap.msi",
"u8erp-cw-nb.msi","u8erp-cw-common.msi","u8erp-cw-ca.msi","u8erp-cw-casc.msi","u8erp-cw-pm.msi",
"u8erp-cw-fm.msi","u8erp-cw-cm.msi","u8erp-crm-cs.msi","u8erp-crm-sr.msi","u8erp-scm-pu.msi","u8erp-scm-hu.msi",
"u8erp-scm-common.msi","u8erp-scm-kc.msi","u8erp-scm-pa.msi","u8erp-scm-sa.msi","u8erp-scm-ex.msi","u8erp-scm-st.msi","u8erp-scm-ja.msi",
"u8erp-scm-qm.msi","u8erp-scm-ia.msi","u8erp-crm-sr.msi","u8erp-scm-im.msi","u8erp-scm-eb.msi","u8erp-scm-hy.msi","u8erp-scm-vm.msi","u8erp-u8m-common.msi",
"u8erp-u8m-pffc.msi","u8erp-u8m-eq.msi","u8erp-bpm-fd.msi","u8erp-bpm-common.msi",
"u8erp-bpm-gf.msi","u8erp-bi-bw.msi","u8erp-scm-ez.msi","u8erp-scm-om.msi","u8erp-scm-pdm.msi"};
//hr
CString strHR[strHRNumber]={"u8erp-hr-common.msi","u8erp-hr-hm.msi","u8erp-hr-wa.msi","u8erp-hr-tm.msi",
"u8erp-hr-rt.msi","u8erp-hr-ht.msi","u8erp-hr-wm.msi","u8erp-hr-tr.msi",
"u8erp-hr-pf.msi","u8erp-hr-pr.msi"
};
CString strOthers[strOthersNumber]={"u8erp-cw-gl.msi","u8erp-cw-mr.msi","u8erp-cw-fa.msi","u8erp-cw-ar.msi","u8erp-cw-ap.msi","u8erp-cw-sc.msi","u8erp-cw-fb.msi","u8erp-cw-ne.msi"};
bool isExistsMSI=false;
bool isExistsHR=false;
bool isExistsOthers=false;
int n=0;
CString strFind(str);
bstrSet::iterator it2;
bstrSet::iterator it3;
bstrSet::iterator it4;
//判断是否在strSCM
for(int i=0;i<strMSINumber;i++)
{
for (it2 = installedSet.begin(); it2 != installedSet.end(); it2++)
{
CString msiName((char*)(*it2));
if(CompareIgnoreCase(msiName,strMSI[i]) == 0)
{
isExistsMSI=true;
break;
}
}
}
//判断是否在strHR
for(i=0;i<strHRNumber;i++)
{
for (it3 = installedSet.begin(); it3 != installedSet.end(); it3++)
{
CString msiName((char*)(*it3));
if(CompareIgnoreCase(msiName,strHR[i]) == 0)
{
isExistsHR=true;
break;
}
}
}
//判断是否在其它七个中,添加EAI
for(i=0;i<strOthersNumber;i++)
{
for (it4 = installedSet.begin(); it4 != installedSet.end(); it4++)
{
CString msiName((char*)(*it4));
if(CompareIgnoreCase(msiName,strOthers[i]) == 0)
{
isExistsOthers=true;
break;
}
}
}
_bstr_t name(L"");
bstrSet fileSet;
//添加
if(isExistsMSI)
{
_bstr_t msi;
for(i=0;i<strMSINumber;i++)
{
fileSet.insert(name);
msi=_bstr_t(strMSI[i]);
g_MsiFileMap[msi]=fileSet;
}
//添加七项
//总账
fileSet.insert(name);
msi=_bstr_t(L"u8erp-cw-gl.msi");
g_MsiFileMap[msi]=fileSet;
//UFO
fileSet.insert(name);
msi=_bstr_t(L"u8erp-cw-mr.msi");
g_MsiFileMap[msi]=fileSet;
//固定资产
fileSet.insert(name);
msi=_bstr_t(L"u8erp-cw-fa.msi");
g_MsiFileMap[msi]=fileSet;
//应收
fileSet.insert(name);
msi=_bstr_t(L"u8erp-cw-ar.msi");
g_MsiFileMap[msi]=fileSet;
//应付
fileSet.insert(name);
msi=_bstr_t(L"u8erp-cw-ap.msi");
g_MsiFileMap[msi]=fileSet;
//应付
fileSet.insert(name);
msi=_bstr_t(L"u8erp-cw-sc.msi");
g_MsiFileMap[msi]=fileSet;
//费用预算
fileSet.insert(name);
msi=_bstr_t(L"u8erp-cw-fb.msi");
g_MsiFileMap[msi]=fileSet;
//预算。
fileSet.insert(name);
msi=_bstr_t(L"u8erp-cw-ne.msi");
g_MsiFileMap[msi]=fileSet;
}
if(isExistsHR)
{
_bstr_t hr;
_bstr_t msi;
for(i=0;i<strHRNumber;i++)
{
fileSet.insert(name);
hr=_bstr_t(strHR[i]);
g_MsiFileMap[hr]=fileSet;
}
//EAI
fileSet.insert(name);
msi=_bstr_t(L"u8erp-public-eai.msi");
g_MsiFileMap[msi]=fileSet;
}
if(isExistsOthers)
{
_bstr_t others;
_bstr_t msi;
for(i=0;i<strOthersNumber;i++)
{
fileSet.insert(name);
others=_bstr_t(strOthers[i]);
g_MsiFileMap[others]=fileSet;
}
//EAI
fileSet.insert(name);
msi=_bstr_t(L"u8erp-public-eai.msi");
g_MsiFileMap[msi]=fileSet;
}
#ifdef _DEBUG2
int num = installedSet.size();
int num2 = g_MsiFileMap.size();
logf << "installedSet.size " << num << endl;
logf << "g_MsiFileMap.size " << num2 << endl;
#endif
bstrSet dependencisSet;
map<_bstr_t, bstrSet >::iterator it;
for (it = g_MsiFileMap.begin(); it != g_MsiFileMap.end(); it++)
{
if(installedSet.find(it->first) == installedSet.end())
{
CString msiName = (TCHAR*)it->first;
CString fileName = CString(targetDir) + _T("\\Installer\\") + msiName.Left(msiName.GetLength() - 4) + _T(".config");
ofstream of(fileName);
if (of)
{
bstrSet fileSet = it->second;
bstrSet::iterator it2;
for(it2 = fileSet.begin(); it2 != fileSet.end(); it2++)
{
CString path=(char*)*it2;
path.Replace(_T("%windir%"), g_WindowsDir);
path.Replace(_T("%sysdir%"), g_WinSysDir);
path.Replace(_T("%targetdir%"), targetDir);
if(path!=_T(""))
of <<(LPCTSTR)(path)<<endl;
}
of.close();
}
else
{
/*CString msg;
msg.LoadString(IDS_OnOpenWrite);
msg += _T(":");
msg += fileName;
AfxMessageBox(msg);*/
}
//CString msiName1 = (TCHAR*)it->first;
dependencisSet.insert(it->first);
//调用的地方没有分配指针
//_tcscat(str, it->first);
//_tcscat(str, _T(","));
_tcscat(str, (char*)(it->first));
_tcscat(str, _T(","));
}
}
// WriteSetToFile(dependencisSet, _T("DependenceSet.log"));
WriteSetToFile(dependencisSet, _T("DependenceSet.log"), targetDir);
}
void _stdcall AppendInstalledMsi(LPCTSTR fileName, LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
}
void _stdcall RemoveInstalledMsi(LPCTSTR fileName, LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
WriteLog(_T("RemoveInstalledMsi "), fileName);
bstrSet installedSet;
ReadSetFromFile(installedSet, _T("MsiSet.log"), targetDir);
TCHAR * pName = _tcsdup(fileName);
installedSet.erase(_tcslwr(pName));
free(pName);
WriteSetToFile(installedSet, _T("MsiSet.log"), targetDir);
}
void _stdcall GetAllDenpendenceMsi(LPTSTR str, LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
bstrSet dependencisSet;
ReadSetFromFile(dependencisSet, _T("DependenceSet.log"), targetDir);
bstrSet::iterator it;
for (it = dependencisSet.begin(); it != dependencisSet.end(); it++)
{
_tcscat(str, (char*)(*it));
_tcscat(str, _T(","));
}
WriteLog(_T("GetAllDenpendenceMsi result is "), str);
}
void _stdcall RemoveConfigFile(LPCTSTR fileName, LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
WriteLog(_T("RemoveConfigFile "), fileName);
bstrSet configSet;
ReadSetFromFile(configSet, _T("ConfigSet.log"), targetDir);
TCHAR * pName = _tcsdup(fileName);
configSet.erase(_tcslwr(pName));
free(pName);
WriteSetToFile(configSet, _T("ConfigSet.log"), targetDir);
}
void _stdcall GetAllInstalledMsi(LPTSTR str, LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
bstrSet installedSet;
ReadSetFromFile(installedSet, _T("MsiSet.log"), targetDir);
bstrSet::iterator it;
for (it = installedSet.begin(); it != installedSet.end(); it++)
{
CString msiName((char*)(*it));
_tcscat(str, msiName.Mid(6,msiName.GetLength()-10));
_tcscat(str, _T(","));
}
WriteLog(_T("GetAllInstalledMsi result is "), str);
}
void _stdcall GetAllInstalledMsiFullName(LPTSTR str, LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
bstrSet installedSet;
ReadSetFromFile(installedSet, _T("MsiSet.log"), targetDir);
bstrSet::iterator it;
for (it = installedSet.begin(); it != installedSet.end(); it++)
{
CString msiName((char*)(*it));
//_tcscat(str, msiName.Mid(6,msiName.GetLength()-10));
_tcscat(str, _T(","));
}
WriteLog(_T("GetAllInstalledMsiFullName result is "), str);
}
UINT _stdcall GetAllInstalledMsiCount(LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
bstrSet installedSet;
ReadSetFromFile(installedSet, _T("MsiSet.log"), targetDir);
CString msiStr;
bstrSet::iterator it;
for (it = installedSet.begin(); it != installedSet.end(); it++)
{
msiStr +=CString((char*)(*it))+_T(",");
}
WriteLog(_T("GetAllInstalledMsiCount"),msiStr);
return installedSet.size();
}
UINT _stdcall GetAllDenpendenceMsiCount(LPCTSTR targetDir)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
bstrSet dependencisSet;
ReadSetFromFile(dependencisSet, _T("DependenceSet.log"), targetDir);
CString dependStr;
bstrSet::iterator it;
for (it = dependencisSet.begin(); it != dependencisSet.end(); it++)
{
dependStr +=CString((char*)(*it))+_T(",");
}
WriteLog(_T("GetAllDenpendenceMsiCount"),dependStr);
CString str;
str.Format(_T("%d"), dependencisSet.size());
WriteLog(_T("dependencisSet size"),str );
return dependencisSet.size();
}
typedef BOOL (__stdcall *CHECKVERSION)(DWORD,DWORD,DWORD,DWORD,PDWORD);
BOOL _stdcall IsWindows2008()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
HINSTANCE hinstance = LoadLibrary(_T("Kernel32.dll"));
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
BOOL bIsWindows2008 = FALSE;
CHECKVERSION ProcAdd;
if (hinstance != NULL)
{
ProcAdd = (CHECKVERSION) GetProcAddress(hinstance, TEXT("GetProductInfo"));
int iVersion;
if (NULL != ProcAdd)
{
fRunTimeLinkSuccess = TRUE;
(ProcAdd) ( (DWORD)6,(DWORD)0,(DWORD)0,(DWORD)0,(PDWORD)&iVersion );
//the Vista ProductInfo Type Number
if(
iVersion == 1 || iVersion == 2 || iVersion == 3 || iVersion == 4 ||
iVersion == 5 || iVersion == 6 || iVersion == 11 || iVersion == 16
)
bIsWindows2008 = FALSE;
//the windows2008 ProductInfo Type Number
else if(
iVersion == 7 || iVersion == 13 || iVersion == 8 || iVersion == 12 ||
iVersion == 10 || iVersion == 14 || iVersion == 17 || iVersion == 15
)
bIsWindows2008 = TRUE;
else
bIsWindows2008 = FALSE;
}
fFreeResult = FreeLibrary(hinstance);
}
if (! fRunTimeLinkSuccess)
bIsWindows2008 = FALSE;
return bIsWindows2008;
}
//-----------------------辅助函数----------------
void ReadSetFromFile(bstrSet& theSet, LPCTSTR fileName, LPCTSTR targetDir)
{
ifstream infs(GetInstallerPath(targetDir) + fileName);
if(infs)
{
while(infs.getline(buff, BUFF_SIZE))
{
theSet.insert(buff);
}
}
infs.close();
}
void WriteSetToFile(bstrSet& theSet, LPCTSTR fileName, LPCTSTR targetDir)
{
ofstream ofs(GetInstallerPath(targetDir) + fileName);
if (ofs)
{
bstrSet::iterator it;
for(it= theSet.begin(); it != theSet.end(); it++)
{
ofs << (char*)(*it) <<endl;
}
}
ofs.close();
}
CString GetInstallerPath(LPCTSTR targetDir)
{
CString result;
//if(targetDir.IsEmpty())
//{
// GetAbstractPathValue();
if (PathFileExists(targetDir) == FALSE)
{
CreateDirectory(targetDir, NULL);
}
//}
result = CString(targetDir) + _T("\\Installer\\");
if (PathFileExists(result) == FALSE)
{
CreateDirectory(result, NULL);
}
return result;
}
void GetAbstractPathValue()
{
TCHAR path[MAX_PATH+1] = {0};
//GetWindowsDirectory(path,MAX_PATH);
//for terminal service issue
GetSystemWindows(path,MAX_PATH);
g_WindowsDir = path;
ZeroMemory(path,sizeof(path));
GetSystemDirectory(path,MAX_PATH);
g_WinSysDir = path;
}
void GetError()
{
LPVOID lpMsgBuf;
if (!FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL ))
{
return;
}
WriteLog(_T("GetError"), (LPTSTR)lpMsgBuf);
LocalFree(lpMsgBuf);
}
void GetError(LPTSTR lpSource)
{
LPVOID lpMsgBuf;
if (!FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL ))
{
return;
}
WriteLog(lpSource,(LPTSTR)lpMsgBuf);
LocalFree(lpMsgBuf);
}
void _stdcall WriteLog(LPCTSTR lpSource,LPCTSTR lpMsg)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
DWORD tid = GetCurrentThreadId();
CString cstr;
cstr.Format(_T("%s[%d] %s"),_T("Thread"),tid,lpSource);
LPTSTR lpsz = new TCHAR[cstr.GetLength()+1];
ZeroMemory(lpsz,cstr.GetLength()+1);
_tcscpy(lpsz,cstr);
WriteText(lpsz,lpMsg);
delete[] lpsz;
}
int WriteText(LPCTSTR lpSrc,LPCTSTR lpMsg)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CStdioFile inputFile;
TCHAR lpFile[MAX_PATH];
ZeroMemory(lpFile,sizeof(lpFile));
GetSystemDirectory(lpFile, MAX_PATH);
_tcscat(lpFile, LOGFILENAME);
TCHAR lpMutexName[] = _T("U8SETUPERRLOG");
HANDLE hMutex;
try
{
hMutex = OpenMutex(MUTEX_ALL_ACCESS,FALSE,lpMutexName);
if(!hMutex)
{
hMutex = CreateMutex(NULL,FALSE,lpMutexName);
}
if(!hMutex)
return 0;
WaitForSingleObject(hMutex,INFINITE);
inputFile.Open(lpFile,CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite);
inputFile.SeekToEnd();
COleDateTime time = COleDateTime::GetCurrentTime();
CString sMsg = time.Format(_T("[%Y-%m-%d %H:%M:%S]"));
TCHAR* lpSource = new TCHAR[MAX_LENGTH];
ZeroMemory(lpSource,MAX_LENGTH);
_tcscpy(lpSource,lpSrc);
_tcscat(lpSource,_T(":"));
_tcscat(lpSource,lpMsg);
_tcscat(lpSource,_T("\n"));
sMsg.Insert(sMsg.GetLength(),lpSource);
inputFile.WriteString(sMsg);
inputFile.Close();
delete[] lpSource;
}
catch(...)
{
}
ReleaseMutex(hMutex);
return 0;
}
void _stdcall ParserConfigFile(LPCTSTR fileName)
{
::CoInitialize(NULL);
#ifdef _DEBUG2
logf << "ParserConfigFile " << fileName<<endl;
#endif
try
{
MSXML2::IXMLDOMDocumentPtr pXmlDoc = NULL;
_variant_t varRet((bool)TRUE);
pXmlDoc.CreateInstance("Msxml2.DOMDocument");
varRet = pXmlDoc->load(fileName);
if(!(bool)varRet)
{
#ifdef _DEBUG2
logf <<"GetParseError"<<endl;
#endif
GetParseError(pXmlDoc);
return;
}
_bstr_t name = pXmlDoc->documentElement->attributes->getNamedItem(_bstr_t("name"))->text;
MSXML2::IXMLDOMNodeListPtr nodeListprt = pXmlDoc->documentElement->childNodes;
int n = nodeListprt->length;
for (int i=0; i<nodeListprt->length; i++)
{
ParserMsi(nodeListprt->item[i]->childNodes);
}
}
catch(_com_error& err)
{
GetComErr(err);
}
catch(...)
{
GetError();
}
::CoUninitialize();
}
void GetParseError(MSXML2::IXMLDOMDocumentPtr pXmlDoc)
{
MSXML2::IXMLDOMParseErrorPtr errPtr = pXmlDoc->GetparseError();
BSTR bstrErr;
errPtr->get_reason(&bstrErr);
//AfxMessageBox((LPCTSTR)bstrErr);
USES_CONVERSION;
LPCTSTR pErrStr = OLE2T(bstrErr);
WriteLog(_T("GetParseError "), pErrStr);
SysFreeString(bstrErr);
}
void ParserMsi(MSXML2::IXMLDOMNodeListPtr msiPtr)
{
for(int i=0; i< msiPtr->length; i++)
{
const _bstr_t name = msiPtr->item[i]->attributes->getNamedItem(_bstr_t("name"))->text;
#ifdef _DEBUG2
logf << (char*)name<<endl;
#endif
MSXML2::IXMLDOMNodeListPtr filesPtr = msiPtr->item[i]->childNodes;
bstrSet fileSet;
if (g_MsiFileMap.find(name) != g_MsiFileMap.end())
{
fileSet = g_MsiFileMap[name];
}
for(int j=0; j <filesPtr->length; j++)
{
_bstr_t fileName = filesPtr->item[j]->attributes->getNamedItem(_bstr_t("name"))->text;
#ifdef _DEBUG2
logf << (char*)fileName <<endl;
#endif
fileSet.insert(fileName);
}
int n = fileSet.size();
g_MsiFileMap[name] = fileSet;
}
}
void GetComErr(LPTSTR lpSource,_com_error& err)
{
_bstr_t bstrErr(err.ErrorMessage());
bstrErr += "\n"+err.Description();
WriteLog(lpSource,(LPTSTR)bstrErr);
}
void GetComErr(_com_error& err)
{
_bstr_t bstrErr(err.ErrorMessage());
bstrErr += "\n"+err.Description();
// AfxMessageBox((LPTSTR)bstrErr);
WriteText(_T("GetComError"), (LPTSTR)bstrErr);
}
//-----------------------辅助函数----------------
StdAfx.cpp 文件内容
// stdafx.cpp : source file that includes just the standard includes
// dll.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
MSIFunction.h 文件内容
// dll.h : main header file for the DLL DLL
//
#if !defined(AFX_DLL_H__90B8306B_5F9E_4BBE_A18E_98817361AA76__INCLUDED_)
#define AFX_DLL_H__90B8306B_5F9E_4BBE_A18E_98817361AA76__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include<windows.h>
#include <tchar.h>
#include <stdio.h>
#include<winsvc.h>
DLLINTERFACE void _stdcall AddConfigFile(LPCTSTR fileName, LPCTSTR targetDir);
DLLINTERFACE void _stdcall AddInstalledMsi(LPCTSTR fileName, LPCTSTR targetDir);
DLLINTERFACE void _stdcall WriteConfigFile(LPTSTR str, LPCTSTR targetDir);
DLLINTERFACE bool _stdcall GetMemory();
DLLINTERFACE DWORD _stdcall StopService(SC_HANDLE hSCM, SC_HANDLE hService, bool fStopDependencies, DWORD dwTimeout);
DLLINTERFACE void _stdcall AppendInstalledMsi(LPCTSTR fileName, LPCTSTR targetDir);
DLLINTERFACE void _stdcall RemoveInstalledMsi(LPCTSTR fileName, LPCTSTR targetDir);
DLLINTERFACE void _stdcall GetAllDenpendenceMsi(LPTSTR str, LPCTSTR targetDir);
DLLINTERFACE void _stdcall RemoveConfigFile(LPCTSTR fileName, LPCTSTR targetDir);
DLLINTERFACE void _stdcall GetAllInstalledMsi(LPTSTR str, LPCTSTR targetDir);
DLLINTERFACE void _stdcall GetAllInstalledMsiFullName(LPTSTR str, LPCTSTR targetDir);
DLLINTERFACE UINT _stdcall GetAllInstalledMsiCount(LPCTSTR targetDir);
DLLINTERFACE UINT _stdcall GetAllDenpendenceMsiCount(LPCTSTR targetDir);
DLLINTERFACE void _stdcall AddReinstalledFile(LPCTSTR fileName);
DLLINTERFACE BOOL _stdcall IsReinstalledFile(LPCTSTR fileName);
DLLINTERFACE void _stdcall WriteCACompareDateFile(LPCTSTR fileName,LPCTSTR targetDir);
DLLINTERFACE BOOL _stdcall IsExistCACompareDateFile(LPCTSTR fileName,LPCTSTR targetDir);
DLLINTERFACE BOOL _stdcall IsWindows2008();
#endif // !defined(AFX_DLL_H__90B8306B_5F9E_4BBE_A18E_98817361AA76__INCLUDED_)
Resource.h 文件内容
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by DLL.RC
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 1000
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 1000
#define _APS_NEXT_COMMAND_VALUE 32771
#endif
#endif
StdAfx.h 文件内容
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__8BC60E2D_409C_45D0_AD27_6BEAEDB0A3A8__INCLUDED_)
#define AFX_STDAFX_H__8BC60E2D_409C_45D0_AD27_6BEAEDB0A3A8__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#pragma warning(disable : 4250 4251 4786 4290)
#define _CRT_SECURE_NO_DEPRECATE
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxole.h> // MFC OLE classes
#include <afxodlgs.h> // MFC OLE dialog classes
#include <afxdisp.h> // MFC Automation classes
#endif // _AFX_NO_OLE_SUPPORT
#ifndef _AFX_NO_DB_SUPPORT
#include <afxdb.h> // MFC ODBC database classes
#endif // _AFX_NO_DB_SUPPORT
#ifndef _AFX_NO_DAO_SUPPORT
#include <afxdao.h> // MFC DAO database classes
#endif // _AFX_NO_DAO_SUPPORT
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <fstream>
using namespace std;
#include <comutil.h>
#include <ATLCONV.h>
#include "shlwapi.h"
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__8BC60E2D_409C_45D0_AD27_6BEAEDB0A3A8__INCLUDED_)
Resource.h 文件内容
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by Tester.rc
//
#define IDM_ABOUTBOX 0x0010
#define IDD_ABOUTBOX 100
#define IDS_ABOUTBOX 101
#define IDD_TESTER_DIALOG 102
#define IDR_MAINFRAME 128
#define IDC_BUTTON1 1000
#define IDC_BUTTON2 1001
#define IDC_ADDCONFIG 1002
#define IDC_WRITECONFIG 1003
#define IDC_ADDINSTALLED 1004
#define IDC_NEEDFILES 1005
#define IDC_CREATWEB 1006
#define IDC_GUID 1007
#define IDC_BUTTON3 1008
#define IDC_INITINSTALL 1009
#define IDC_CLEARINSTALL 1010
#define IDC_GETALLDENPENDENCEMSI 1011
#define IDC_BUTTON4 1012
#define IDC_BUTTON5 1013
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1014
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
StdAfx.h 文件内容
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__4CE0E562_8D66_47A3_A5A8_9FDC3407A563__INCLUDED_)
#define AFX_STDAFX_H__4CE0E562_8D66_47A3_A5A8_9FDC3407A563__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__4CE0E562_8D66_47A3_A5A8_9FDC3407A563__INCLUDED_)
Tester.h 文件内容
// Tester.h : main header file for the TESTER application
//
#if !defined(AFX_TESTER_H__80655D25_13BF_4DE3_89E4_80C1CA67CD11__INCLUDED_)
#define AFX_TESTER_H__80655D25_13BF_4DE3_89E4_80C1CA67CD11__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
/
// CTesterApp:
// See Tester.cpp for the implementation of this class
//
class CTesterApp : public CWinApp
{
public:
CTesterApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTesterApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CTesterApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TESTER_H__80655D25_13BF_4DE3_89E4_80C1CA67CD11__INCLUDED_)
TesterDlg.h 文件内容
// TesterDlg.h : header file
//
#if !defined(AFX_TESTERDLG_H__80671E69_504D_4639_BB46_3420F3486D57__INCLUDED_)
#define AFX_TESTERDLG_H__80671E69_504D_4639_BB46_3420F3486D57__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/
// CTesterDlg dialog
class CTesterDlg : public CDialog
{
// Construction
public:
CTesterDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CTesterDlg)
enum { IDD = IDD_TESTER_DIALOG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTesterDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CTesterDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
virtual void OnOK();
afx_msg void OnButton1();
afx_msg void OnExist();
afx_msg void OnAddconfig();
afx_msg void OnAddinstalled();
afx_msg void OnWriteconfig();
afx_msg void OnNeedfiles();
afx_msg void OnCreateWeb();
afx_msg void OnGuid();
afx_msg void OnRun();
afx_msg void OnInitInstall();
afx_msg void OnClearInstall();
afx_msg void OnGetalldenpendencemsi();
afx_msg void OnGetAllInstalledMsi();
afx_msg void OnCleaning();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TESTERDLG_H__80671E69_504D_4639_BB46_3420F3486D57__INCLUDED_)
\res\Tester.rc2 文件内容
//
// TESTER.RC2 - resources Microsoft Visual C++ does not edit directly
//
#ifdef APSTUDIO_INVOKED
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED
/
// Add manually edited resources here...
/
测试界面