当前位置: 首页>>代码示例>>C++>>正文


C++ CAtlFile::Create方法代码示例

本文整理汇总了C++中CAtlFile::Create方法的典型用法代码示例。如果您正苦于以下问题:C++ CAtlFile::Create方法的具体用法?C++ CAtlFile::Create怎么用?C++ CAtlFile::Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CAtlFile的用法示例。


在下文中一共展示了CAtlFile::Create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: IsValidPatchFile

BOOL IsValidPatchFile(LPCTSTR szFilename)
{
	// MSCF
	const CHAR szMagicMsu[] = {'M', 'S', 'C', 'F'};
	const CHAR szMagicExe[] = {'M', 'Z'};
	
	const int TEST_BUFFER_SIZE = 4;
	CHAR buffer[TEST_BUFFER_SIZE] = {0};

	BOOL bMatched = FALSE;
	CAtlFile file;
	if(S_OK == file.Create(szFilename, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING) )
	{		
		if(SUCCEEDED(file.Read(buffer, TEST_BUFFER_SIZE)))
		{
			LPCTSTR szDot = _tcsrchr(szFilename, _T('.'));
			if(szDot)
			{
				++szDot;
				if(_tcsicmp(szDot, _T("msu"))==0)
				{
					bMatched = memcmp(buffer, szMagicMsu, 4)==0;
				}
				else if(_tcsicmp(szDot, _T("exe"))==0)
				{
					bMatched = memcmp(buffer, szMagicExe, 2)==0;
				}
				else
					bMatched = TRUE;
			}
		}
		file.Close();
	}
	return bMatched;
}
开发者ID:6520874,项目名称:pcmanager,代码行数:35,代码来源:ImplRepairVul.cpp

示例2: SaveWords

bool Speller::SaveWords( LPCTSTR path, const WordContainer& words )
{
	CAtlFile file;
	bool result = false;

	if (SUCCEEDED(file.Create(path, GENERIC_WRITE, FILE_SHARE_READ, OPEN_ALWAYS)))
	{
		WordContainer::const_iterator it = words.begin();
		std::vector<char> data;

		for (; it != words.end(); ++it) 
		{
			data.clear();
			const StringType text = *it + _T("\n");

			UTF16toUTF8(text.c_str(), text.size(), data);

			if (!data.empty())
				file.Write(&data[0], static_cast<DWORD>(data.size()));
		}

		result = true;
	}

	return result;
}
开发者ID:bzindovic,项目名称:texniccenter-code,代码行数:26,代码来源:Speller.cpp

示例3: LoadWords

bool Speller::LoadWords( LPCTSTR path, WordContainer& words )
{
	CAtlFile file;
	bool result = false;

	if (SUCCEEDED(file.Create(path, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING))) {
		ULONGLONG size = 0;
		file.GetSize(size);

		if (size > 0) {
			std::vector<char> data(static_cast<unsigned>(size));

			if (SUCCEEDED(file.Read(&data[0], static_cast<DWORD>(data.size())))) {
				std::vector<wchar_t> unicode;
				UTF8toUTF16(&data[0], data.size(), unicode);

				std::wistringstream in(std::wstring(&unicode[0], unicode.size()));
				typedef std::istream_iterator<StringType,StringType::value_type,
					StringType::traits_type> iterator;

				std::copy(iterator(in),iterator(),std::inserter(words,words.end()));
				result = true;
			}
		}
	}

	return result;
}
开发者ID:bzindovic,项目名称:texniccenter-code,代码行数:28,代码来源:Speller.cpp

示例4: file_put_contents

BOOL file_put_contents(LPCTSTR lpszFilename, BYTE *pBuffer, INT nLen)
{
	CAtlFile file;
	if( FAILED( file.Create(lpszFilename, GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, CREATE_ALWAYS) ) )
		return FALSE;
	
	file.Write( pBuffer, nLen );
	file.Close();
	return TRUE;
}
开发者ID:6520874,项目名称:pcmanager,代码行数:10,代码来源:BeikeUtils.cpp

示例5: file_get_size

INT64 file_get_size(LPCTSTR lpszFilename)
{
	CAtlFile file;
	if( FAILED( file.Create(lpszFilename, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING) ) )
		return 0;

	ULONGLONG filesize = 0;
	file.GetSize(filesize);
	return filesize;
}
开发者ID:6520874,项目名称:pcmanager,代码行数:10,代码来源:BeikeUtils.cpp

示例6: _output_initialize

	virtual void _output_initialize()
	{
		if (SUCCEEDED(_file.Create(_T("debug.txt"), GENERIC_WRITE, FILE_SHARE_READ, OPEN_ALWAYS)))
		{
			SYSTEMTIME st;
			::GetLocalTime(&st);
			debugout(_T("----- %04d-%02d-%02d %02d:%02d:%02d -----"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
		}
		else
			_out_type = DEBUGOUT_STRING;
	}
开发者ID:kaina,项目名称:sandbox,代码行数:11,代码来源:debugout.hpp

示例7: SelfPurecallHandler

void DebugTools::SelfPurecallHandler(void)
{
	wchar_t filename[MAX_PATH];
	::GetModuleFileNameW(nullptr,filename,MAX_PATH);
	wcscat_s(filename,L".dmp");
	::MessageBox(nullptr,filename,L"PurecallHandler",0);
	CAtlFile file;
	file.Create(filename,FILE_WRITE_DATA,FILE_SHARE_READ,CREATE_ALWAYS);
	BOOL res=::MiniDumpWriteDump(::GetCurrentProcess(),::GetCurrentProcessId(),file,MiniDumpNormal,nullptr,nullptr,nullptr);
	file.Close();
	exit(0);
}
开发者ID:hkg36,项目名称:My_EXLIB,代码行数:12,代码来源:cexarray.cpp

示例8: HandleRequestService

bool CCoBroker::HandleRequestService(const tstring& dstUserId, ULONG dstSvcId, const tstring& srcUserId, ULONG srcSvcId, ULONG rId, ULONG rType, ULONG param, const tstring& params)
{
TRY_CATCH
	HRESULT result;
	EBrokerStartTypes startParam=BST_SAME;
	tstring url;
	{
		tstring::size_type iBeginUrl=params.find(_T(";;"));
		if(iBeginUrl!=tstring::npos)
		{
			tstring::size_type iEndUrl=params.find(_T(";;"),iBeginUrl+2);
			url=params.substr(iBeginUrl+2,(tstring::npos!=iEndUrl)?iEndUrl-iBeginUrl-2:tstring::npos);
		}
	}
	Log.Add(_MESSAGE_,_T("***HandleRequestService*** url=[%s]"),url.c_str());

	const TCHAR SESSION_ID_PARAMETER_NAME[]=_T("supportRequestId=");
	tstring::size_type iWebSId=url.find(SESSION_ID_PARAMETER_NAME);
	if(iWebSId!=tstring::npos&&iWebSId+_countof(SESSION_ID_PARAMETER_NAME)<url.size())
	{
		iWebSId+=_countof(SESSION_ID_PARAMETER_NAME)-1;
		tstring::size_type iWebSIdEnd=url.find_first_of(_T("&#"),iWebSId);
		if(tstring::npos==iWebSIdEnd)
			iWebSIdEnd=url.length();
		tstring sId=url.substr(iWebSId,iWebSIdEnd-iWebSId);
		Log.Add(_MESSAGE_,_T("***HandleRequestService*** sId=[%s]"),sId.c_str());
		SHA1Hash hash_buf;
		CRYPTO_INSTANCE.MakeHash((char*)sId.c_str(),sId.length()*sizeof(tstring::value_type),hash_buf);
		tstring hashString;
		for(int i=0;i<sizeof(hash_buf);++i)
			//hashString+=i2tstring((int)(unsigned char)hash_buf[i],16);
			hashString+=Format(_T("%02x"),(int)(unsigned char)hash_buf[i]);
		url.insert(iWebSIdEnd,tstring(_T("&sri="))+hashString);
	}
	//Log.Add(_WARNING_,_T("***HandleRequestService*** HASHING TURN OFF"));
	Log.Add(_MESSAGE_,_T("***HandleRequestService*** url=[%s]"),url.c_str());
	
	CAtlFile cnfg;
	if(S_OK==cnfg.Create(Format(_T("%s\\%s"),GetModulePath(GetCurrentModule()).c_str(),_T("Broker.cfg")).c_str(),GENERIC_READ,0,OPEN_EXISTING))
	{
		TRY_CATCH
			DWORD readLen=0;
			readLen=GetFileSize(cnfg.m_h,NULL);
			if(INVALID_FILE_SIZE==readLen&&readLen>32768)
				throw MCException_Win("Broker.cfg size obtaining failed or file too large");
			std::auto_ptr<char> buf(new char[readLen]);
			if(!ReadFile(cnfg.m_h,buf.get(),readLen,&readLen,NULL))
				throw MCException_Win("Broker.cfg file reading failed");
			startParam=EBrokerStartTypes(atol(buf.get()));
			Log.Add(_MESSAGE_,_T("***HandleRequestService*** file startParam=[0x%x]"),startParam);
		CATCH_LOG()
	}
开发者ID:SupportSpace,项目名称:SupportCenter,代码行数:52,代码来源:CCoBroker.cpp

示例9: SetContiInfo

bool CDTManager::SetContiInfo( CString file,CString& url,int64& len,int& cur )
{
	CAtlFile f;
	if(ERROR_SUCCESS!=f.Create(file,FILE_GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,CREATE_ALWAYS)!=ERROR_SUCCESS)
	{
		return false;
	}
	f.Write(&len,sizeof len);
	f.Write(&cur,sizeof cur);
	f.Write(url.GetBuffer(),url.GetLength()*2+2);
	f.Close();
	return true;
}
开发者ID:dreamsxin,项目名称:PcManager,代码行数:13,代码来源:DTManager.cpp

示例10: VerifyFile

DWORD CWinTrustVerifier::VerifyFile(LPCWSTR pwszFileFullPath, CWinTrustSignerInfoChain* pSignInfoChain)
{
    assert(pwszFileFullPath);
    CAtlFile hFile;
    HRESULT  hr = hFile.Create(
        pwszFileFullPath,
        GENERIC_READ,
        FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
        OPEN_EXISTING);
    if (FAILED(hr))
        return hr;

    return VerifyFile(pwszFileFullPath, hFile, pSignInfoChain);
}
开发者ID:binbibi,项目名称:winmod,代码行数:14,代码来源:wintrustverifier.cpp

示例11: IsPEFile

BOOL CWinTrustVerifier::IsPEFile(LPCWSTR pwszFileFullPath)
{
    assert(pwszFileFullPath);

    CAtlFile hFile;
    HRESULT  hr = hFile.Create(
        pwszFileFullPath,
        GENERIC_READ,
        FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
        OPEN_EXISTING);
    if (FAILED(hr))
        return hr;

    return IsPEFile(hFile);
}
开发者ID:binbibi,项目名称:winmod,代码行数:15,代码来源:wintrustverifier.cpp

示例12: GetFavicon

HICON	CFaviconManager::GetFaviconFromURL(LPCTSTR url)
{
    CString strFaviconURL;
    CString strHtmlPath;
    if (SUCCEEDED(::URLDownloadToCacheFile(NULL, url, strHtmlPath.GetBuffer(MAX_PATH), MAX_PATH, 0, NULL))) {
        strHtmlPath.ReleaseBuffer();
        CAtlFile	file;
        if (SUCCEEDED(file.Create(strHtmlPath, GENERIC_READ, 0, OPEN_EXISTING))) {
            enum { kMaxReadSize = 2000 };
            unique_ptr<char[]>	htmlContent(new char[kMaxReadSize + 1]);
            DWORD	dwReadSize = 0;
            file.Read((LPVOID)htmlContent.get(), kMaxReadSize, dwReadSize);
            htmlContent[dwReadSize] = '\0';

            boost::regex	rx("<link (?:(?<rel>rel=[\"']?(?:shortcut icon|icon)[\"']?) (?<href>href=[\"']?(?<url>[^ \"]+)[\"']?)|(?<href>href=[\"']?(?<url>[^ \"]+)[\"']?) (?<rel>rel=[\"']?(?:shortcut icon|icon)[\"']?))[^>]+>", boost::regex::icase);
            boost::cmatch	result;
            if (boost::regex_search(htmlContent.get(), result, rx)) {
                CString strhref = result["url"].str().c_str();
                DWORD	dwSize = INTERNET_MAX_URL_LENGTH;
                ::UrlCombine(url, strhref, strFaviconURL.GetBuffer(INTERNET_MAX_URL_LENGTH), &dwSize, 0);
                strFaviconURL.ReleaseBuffer();
            }
        }
    }
    if (strFaviconURL.IsEmpty()) {	// ルートにあるFaviconのアドレスを得る
        DWORD cchResult = INTERNET_MAX_URL_LENGTH;
        if (::CoInternetParseUrl(url, PARSE_ROOTDOCUMENT, 0, strFaviconURL.GetBuffer(INTERNET_MAX_URL_LENGTH), INTERNET_MAX_URL_LENGTH, &cchResult, 0) == S_OK) {
            strFaviconURL.ReleaseBuffer();
            strFaviconURL += _T("/favicon.ico");
        }
    }

    if (strFaviconURL.GetLength() > 0) {
        CCritSecLock	lock(s_cs);
        CIconHandle hIcon = GetFavicon(strFaviconURL);
        if (hIcon == NULL) {
            hIcon = _DownloadFavicon(strFaviconURL);
            if (hIcon) {
                s_mapIcon[std::wstring(strFaviconURL)] = hIcon;
                hIcon	= hIcon.DuplicateIcon();
            }
        } else {
            hIcon = hIcon.DuplicateIcon();
        }
        return hIcon;
    }
    return NULL;
}
开发者ID:amate,项目名称:unChromium,代码行数:48,代码来源:FaviconManager.cpp

示例13: SendSmallFile

BOOL CTcpAgent::SendSmallFile(CONNID dwConnID, LPCTSTR lpszFileName, const LPWSABUF pHead, const LPWSABUF pTail)
{
	ASSERT(lpszFileName != nullptr);

	CAtlFile file;
	HRESULT hr = file.Create(lpszFileName, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING);

	if(SUCCEEDED(hr))
	{
		ULONGLONG ullLen;
		hr = file.GetSize(ullLen);

		if(SUCCEEDED(hr))
		{
			ULONGLONG ullTotal = ullLen + (pHead ? pHead->len : 0) + (pTail ? pTail->len : 0);

			if(ullLen > 0 && ullTotal <= MAX_SMALL_FILE_SIZE)
			{
				CAtlFileMapping<> fmap;
				hr = fmap.MapFile(file);

				if(SUCCEEDED(hr))
				{
					WSABUF bufs[3] = {0};

					bufs[1].len = (ULONG)ullLen;
					bufs[1].buf = fmap;

					if(pHead) memcpy(&bufs[0], pHead, sizeof(WSABUF));
					if(pTail) memcpy(&bufs[2], pTail, sizeof(WSABUF));

					return SendPackets(dwConnID, bufs, 3);
				}
			}
			else if(ullLen == 0)
				hr = HRESULT_FROM_WIN32(ERROR_FILE_INVALID);
			else
				hr = HRESULT_FROM_WIN32(ERROR_FILE_TOO_LARGE);
		}
	}

	::SetLastError(hr & 0x0000FFFF);

	return FALSE;
}
开发者ID:kooyain,项目名称:HP-Socket,代码行数:45,代码来源:TcpAgent.cpp

示例14: LoadFromFile

BOOL CXmlManager::LoadFromFile( LPCTSTR szfilename )
{
	BOOL ret = FALSE;
	CAtlFile file;
	if(S_OK == file.Create(szfilename, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING) )
	{
		int nsize = ::GetFileSize(file, NULL);
		char* szbuf = new char[nsize + 1];
		if(szbuf)
		{
			if(S_OK == file.Read(szbuf, nsize))
			{
				szbuf[nsize] = 0;
				ret = LoadFromString(szbuf, nsize);
			}
			delete [] szbuf;
		}
	}
	return ret;
}
开发者ID:6520874,项目名称:pcmanager,代码行数:20,代码来源:XmlManager.cpp

示例15: GetContiInfo

bool CDTManager::GetContiInfo( CString file,CString& url,int64& len,int& cur )
{
	CAtlFile f;
	if(ERROR_SUCCESS!=f.Create(file,FILE_GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,OPEN_EXISTING)!=ERROR_SUCCESS)
	{
		return false;
	}
	if(ERROR_SUCCESS!=f.Read(&len,sizeof len)&&f.Read(&cur,sizeof cur)!=ERROR_SUCCESS)
		return false;
	f.Read(&cur,sizeof cur);
	ULONGLONG flen=0;
	f.GetSize(flen);
	wchar_t* buf=new wchar_t[((size_t)flen)/2+1];
	ZeroMemory(buf,((size_t)flen)/2+1);
	f.Read(buf,(DWORD)flen);
	url=buf;
	delete [] buf;
	f.Close();
	return true;
}
开发者ID:dreamsxin,项目名称:PcManager,代码行数:20,代码来源:DTManager.cpp


注:本文中的CAtlFile::Create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。