本文整理汇总了C++中Format函数的典型用法代码示例。如果您正苦于以下问题:C++ Format函数的具体用法?C++ Format怎么用?C++ Format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Format函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Format
void GLFragmentDecompilerThread::AddCode(const std::string& code)
{
main.append(m_code_level, '\t') += Format(code) + "\n";
}
开发者ID:Bruceharper,项目名称:rpcs3,代码行数:4,代码来源:GLFragmentProgram.cpp
示例2: LoadTableMain
// Read the string table
bool LoadTableMain(wchar_t *filename)
{
BUF *b;
UINT64 t1, t2;
UCHAR hash[MD5_SIZE];
// Validate arguments
if (filename == NULL)
{
return false;
}
if (MayaquaIsMinimalMode())
{
return true;
}
if (UniStrCmpi(old_table_name, filename) == 0)
{
// Already loaded
return true;
}
t1 = Tick64();
// Open the file
b = ReadDumpW(filename);
if (b == NULL)
{
char tmp[MAX_SIZE];
StrCpy(tmp, sizeof(tmp), "Error: Can't read string tables (file not found).\r\nPlease check hamcore.se2.\r\n\r\n(First, reboot the computer. If this problem occurs again, please reinstall VPN software files.)");
Alert(tmp, NULL);
exit(-1);
return false;
}
Hash(hash, b->Buf, b->Size, false);
if (LoadUnicodeCache(filename, b->Size, hash) == false)
{
if (LoadTableFromBuf(b) == false)
{
FreeBuf(b);
return false;
}
SaveUnicodeCache(filename, b->Size, hash);
//Debug("Unicode Source: strtable.stb\n");
}
else
{
//Debug("Unicode Source: unicode_cache\n");
}
FreeBuf(b);
SetLocale(_UU("DEFAULE_LOCALE"));
UniStrCpy(old_table_name, sizeof(old_table_name), filename);
t2 = Tick64();
if (StrCmpi(_SS("STRTABLE_ID"), STRTABLE_ID) != 0)
{
char tmp[MAX_SIZE];
Format(tmp, sizeof(tmp), "Error: Can't read string tables (invalid version: '%s'!='%s').\r\nPlease check hamcore.se2.\r\n\r\n(First, reboot the computer. If this problem occurs again, please reinstall VPN software files.)",
_SS("STRTABLE_ID"), STRTABLE_ID);
Alert(tmp, NULL);
exit(-1);
return false;
}
//Debug("Unicode File Read Cost: %u (%u Lines)\n", (UINT)(t2 - t1), LIST_NUM(TableList));
return true;
}
开发者ID:alex-docker,项目名称:CE-dockerfiles,代码行数:77,代码来源:Table.c
示例3: GetTickCount
void __fastcall TProgressPanel::UpdateProgress(bool Regular)
{
float interval = 0.0;
if (Regular) {
DWORD ticks = GetTickCount();
if (ticks > this->FLastTicks) {
interval = ((float)(ticks - this->FLastTicks))/1000.0;
this->FCurElapsed += interval;
this->FOvrElapsed += interval;
}
this->FLastTicks = ticks;
}
UnicodeString oper = this->FOperation;
float cur, ovr;
long double cur_completed, ovr_completed;
if (this->FTotalWork > 0.00) {
cur = this->FCompleteRatio;
cur_completed = this->FCurrentWork*(long double)cur;
ovr_completed = this->FCommittedWork + cur_completed;
if (this->FTotalWork > 0.0) {
ovr = ovr_completed/this->FTotalWork;
}
else {
ovr = 0.0;
}
}
else {
cur = 0.00;
ovr = 0.00;
cur_completed = 0.0;
ovr_completed = 0.0;
}
UnicodeString cur_bytes, ovr_bytes, cur_eta, ovr_eta;
if (this->FCurrentBytes > 0) {
cur_bytes = Format(TXT_COMPLETED,
ARRAYOFCONST((this->FCompletedText, FormatDataSize(this->FCompletedBytes),
FormatDataSize(this->FCurrentBytes))));
}
if (this->FTotalBytes > 0) {
ovr_bytes = Format(TXT_COMPLETED,
ARRAYOFCONST((this->FCompletedText, FormatDataSize(this->FCommittedBytes + this->FCompletedBytes),
FormatDataSize(this->FTotalBytes))));
}
if (!this->FSubOperation.IsEmpty()) {
if (cur_bytes.IsEmpty()) cur_bytes = this->FSubOperation + L"...";
else cur_bytes += L" - " + this->FSubOperation;
}
if (Regular && (this->FEnableSpeed || this->FEnableETA!=ETA_NONE)) {
if (interval > 0.0) {
if (this->FEnableSpeed && this->FLastBytes >= 0) {
float speed = ((float)(this->FCompletedBytes - this->FLastBytes))/interval;
if (this->AveragerSpeed) {
this->AveragerSpeed->Add(speed);
speed = this->AveragerSpeed->GetAverage();
}
if (speed > 0) {
ovr_bytes += L" at " + FormatDataSize(speed, true);
}
}
if (this->FEnableETA!=ETA_NONE && this->FLastWork >= 0) {
float speed = ((float)(ovr_completed - this->FLastWork))/interval;
if (this->AveragerETA) {
this->AveragerETA->Add(speed);
speed = this->AveragerETA->GetAverage();
}
if (speed > 0.0) {
long secs_current = Round((this->FCurrentWork - cur_completed)/speed);
long secs_overall = Round((this->FTotalWork - ovr_completed)/speed);
if (this->FEnableETA&ETA_CURRENT && secs_current > 0 && secs_current < MAX_ETA) {
cur_eta = L"Time Left: " + FormatDuration(secs_current);
}
if (this->FEnableETA&ETA_OVERALL && secs_overall > 0 && secs_overall < MAX_ETA) {
ovr_eta = L"Time Left: " + FormatDuration(secs_overall);
}
}
}
}
if (this->EnableETA!=ETA_NONE) this->FLastWork = ovr_completed;
if (this->EnableSpeed) this->FLastBytes = this->FCompletedBytes;
}
//Assign UI values
this->lblOperation->Caption = ReplaceStr(oper, L"&", L"&&");
this->pbCurrent->Position = cur * (float)PROGRESSBAR_GRADATION;
this->lblCurPercent->Caption = IntToStr(Round(cur*100)) + L"%";
this->pbOverall->Position = ovr * (float)PROGRESSBAR_GRADATION;
this->lblOvrPercent->Caption = IntToStr(Round(ovr*100)) + L"%";
this->lblCurCompleted->Caption = cur_bytes;
this->lblOvrCompleted->Caption = ovr_bytes;
//.........这里部分代码省略.........
开发者ID:DesktopUpload,项目名称:DesktopUploader,代码行数:101,代码来源:TProgressPanel.cpp
示例4: re
BOOL CParseChText4::SaveChText(LPCWSTR filePath)
{
wstring loadFilePath = L"";
wstring loadTunerName = L"";
if( filePath == NULL ){
loadFilePath = this->filePath;
loadTunerName = this->tunerName;
}else{
loadFilePath = filePath;
wregex re(L".+\\\\(.+)\\(.+\\)\\.ChSet4\\.txt$");
wstring text(filePath);
wsmatch m;
if( regex_search(text, m, re) ){
loadTunerName = m[1];
loadTunerName += L".dll";
}
}
if( loadFilePath.size() == 0 ){
return FALSE;
}
if( loadTunerName.size() == 0 ){
return FALSE;
}
multimap<LONGLONG, CH_DATA4> sortList;
multimap<LONGLONG, CH_DATA4>::iterator itr;
for( itr = this->chList.begin(); itr != this->chList.end(); itr++ ){
LONGLONG Key = ((LONGLONG)itr->second.space)<<32 | ((LONGLONG)itr->second.ch)<<16 | (LONGLONG)itr->second.serviceID;
sortList.insert(pair<LONGLONG, CH_DATA4>(Key, itr->second));
}
// ファイル出力
HANDLE hFile = _CreateFile2( loadFilePath.c_str(), GENERIC_WRITE, FILE_SHARE_READ, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
if( hFile == INVALID_HANDLE_VALUE ){
return FALSE;
}
for( itr = sortList.begin(); itr != sortList.end(); itr++ ){
string chName="";
WtoA(itr->second.chName, chName);
string serviceName="";
WtoA(itr->second.serviceName, serviceName);
string networkName="";
WtoA(itr->second.networkName, networkName);
string strBuff;
Format(strBuff, "%s\t%s\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\r\n",
chName.c_str(),
serviceName.c_str(),
networkName.c_str(),
itr->second.space,
itr->second.ch,
itr->second.originalNetworkID,
itr->second.transportStreamID,
itr->second.serviceID,
itr->second.serviceType,
itr->second.partialFlag,
itr->second.useViewFlag,
itr->second.remoconID
);
DWORD dwWrite = 0;
WriteFile(hFile, strBuff.c_str(), (DWORD)strBuff.length(), &dwWrite, NULL);
}
CloseHandle(hFile);
wstring appIniPath = L"";
GetModuleIniPath(appIniPath);
wstring ipString;
DWORD ip;
DWORD port;
ip = GetPrivateProfileInt(L"SET_UDP", L"IP0", 2130706433, appIniPath.c_str());
Format(ipString, L"%d.%d.%d.%d",
(ip&0xFF000000)>>24,
(ip&0x00FF0000)>>16,
(ip&0x0000FF00)>>8,
(ip&0x000000FF) );
port = GetPrivateProfileInt( L"SET_UDP", L"Port0", 3456, appIniPath.c_str() );
// MediaPortal TV Serverのデータベースへ登録
if (this->dbCtrl.Connect(&this->mysql, MYSQL_HOST, MYSQL_USER, MYSQL_PASSWD, MYSQL_DB) != 0) {
return FALSE;
}
this->results = NULL;
CString sql = L"";
wstring wsql = L"";
int chkNum = 0;
this->dbCtrl.Begin(&this->mysql);
map<CString, int> lockTable;
lockTable[L"channelgroup"] = 2;
lockTable[L"tuningdetail"] = 2;
lockTable[L"groupmap" ] = 2;
//.........这里部分代码省略.........
开发者ID:xbmc-now,项目名称:MPB,代码行数:101,代码来源:ParseChText4Mp.cpp
示例5: Format
String Parser::clear(String arg)
{
return Format("Clear(%s)",OPENARRAY(TVarRec,(arg)));
}
开发者ID:icewall,项目名称:Hanoi,代码行数:4,代码来源:parser.cpp
示例6: ParseUrl
// Parse the URL
bool ParseUrl(URL_DATA *data, char *str, bool is_post, char *referrer)
{
char tmp[MAX_SIZE * 3];
char server_port[MAX_HOST_NAME_LEN + 16];
char *s = NULL;
char *host;
UINT port;
UINT i;
// Validate arguments
if (data == NULL || str == NULL)
{
return false;
}
Zero(data, sizeof(URL_DATA));
if (is_post)
{
StrCpy(data->Method, sizeof(data->Method), WPC_HTTP_POST_NAME);
}
else
{
StrCpy(data->Method, sizeof(data->Method), WPC_HTTP_GET_NAME);
}
if (referrer != NULL)
{
StrCpy(data->Referer, sizeof(data->Referer), referrer);
}
StrCpy(tmp, sizeof(tmp), str);
Trim(tmp);
// Determine the protocol
if (StartWith(tmp, "http://"))
{
data->Secure = false;
s = &tmp[7];
}
else if (StartWith(tmp, "https://"))
{
data->Secure = true;
s = &tmp[8];
}
else
{
if (SearchStrEx(tmp, "://", 0, false) != INFINITE)
{
return false;
}
data->Secure = false;
s = &tmp[0];
}
// Get the "server name:port number"
StrCpy(server_port, sizeof(server_port), s);
i = SearchStrEx(server_port, "/", 0, false);
if (i != INFINITE)
{
server_port[i] = 0;
s += StrLen(server_port);
StrCpy(data->Target, sizeof(data->Target), s);
}
else
{
StrCpy(data->Target, sizeof(data->Target), "/");
}
if (ParseHostPort(server_port, &host, &port, data->Secure ? 443 : 80) == false)
{
return false;
}
StrCpy(data->HostName, sizeof(data->HostName), host);
data->Port = port;
Free(host);
if ((data->Secure && data->Port == 443) || (data->Secure == false && data->Port == 80))
{
StrCpy(data->HeaderHostName, sizeof(data->HeaderHostName), data->HostName);
}
else
{
Format(data->HeaderHostName, sizeof(data->HeaderHostName),
"%s:%u", data->HostName, data->Port);
}
return true;
}
开发者ID:Leden,项目名称:SoftEtherVPN,代码行数:91,代码来源:Wpc.c
示例7: Zero
//.........这里部分代码省略.........
if (IsEmptyStr(header_name) == false && IsEmptyStr(header_value) == false)
{
AddHttpValue(h, NewHttpValue(header_name, header_value));
}
if (IsEmptyStr(data->Referer) == false)
{
AddHttpValue(h, NewHttpValue("Referer", data->Referer));
}
if (StrCmpi(data->Method, WPC_HTTP_POST_NAME) == 0)
{
ToStr(len_str, StrLen(post_data));
AddHttpValue(h, NewHttpValue("Content-Type", "application/x-www-form-urlencoded"));
AddHttpValue(h, NewHttpValue("Content-Length", len_str));
}
if (IsEmptyStr(data->AdditionalHeaderName) == false && IsEmptyStr(data->AdditionalHeaderValue) == false)
{
AddHttpValue(h, NewHttpValue(data->AdditionalHeaderName, data->AdditionalHeaderValue));
}
if (use_http_proxy)
{
AddHttpValue(h, NewHttpValue("Proxy-Connection", "Keep-Alive"));
if (IsEmptyStr(setting->ProxyUsername) == false || IsEmptyStr(setting->ProxyPassword) == false)
{
char auth_tmp_str[MAX_SIZE], auth_b64_str[MAX_SIZE * 2];
char basic_str[MAX_SIZE * 2];
// Generate the authentication string
Format(auth_tmp_str, sizeof(auth_tmp_str), "%s:%s",
setting->ProxyUsername, setting->ProxyPassword);
// Base64 encode
Zero(auth_b64_str, sizeof(auth_b64_str));
Encode64(auth_b64_str, auth_tmp_str);
Format(basic_str, sizeof(basic_str), "Basic %s", auth_b64_str);
AddHttpValue(h, NewHttpValue("Proxy-Authorization", basic_str));
}
}
send_str = HttpHeaderToStr(h);
FreeHttpHeader(h);
send_buf = NewBuf();
WriteBuf(send_buf, send_str, StrLen(send_str));
Free(send_str);
// Append to the sending data in the case of POST
if (StrCmpi(data->Method, WPC_HTTP_POST_NAME) == 0)
{
WriteBuf(send_buf, post_data, StrLen(post_data));
}
// Send
if (SendAll(s, send_buf->Buf, send_buf->Size, s->SecureMode) == false)
{
Disconnect(s);
ReleaseSock(s);
FreeBuf(send_buf);
*error_code = ERR_DISCONNECTED;
开发者ID:Leden,项目名称:SoftEtherVPN,代码行数:67,代码来源:Wpc.c
示例8: Format
void AutotestingSystem::SaveScreenShotNameToDB()
{
Logger::Debug("AutotestingSystem::SaveScreenShotNameToDB %s", screenShotName.c_str());
AutotestingDB::Instance()->Log("INFO", Format("screenshot: %s", screenShotName.c_str()));
}
开发者ID:galek,项目名称:dava.framework,代码行数:6,代码来源:AutotestingSystem.cpp
示例9: CreateBrokerThreadEntry
unsigned int __stdcall CreateBrokerThreadEntry(void *data)
{
TRY_CATCH
CoInitialize(0);
SBrokerThreadEntryData* inData = reinterpret_cast<SBrokerThreadEntryData*>(data);
SStartBroker *startBroker = reinterpret_cast<SStartBroker*>(inData->buf);
if (NULL == startBroker->buf || 0 == startBroker->bufSize)
throw MCException("NULL == startBroker->buf || 0 == startBroker->bufSize");
CComPtr<IDispatch> broker;
HRESULT hr;
if((hr=broker.CoCreateInstance(L"Broker.CoBroker",NULL,CLSCTX_LOCAL_SERVER))!=S_OK)
throw CExceptionBase(__LINE__,_T(__FILE__),_T(__DATE__),tstring(_T("CoBroker creation failed")),hr);
CScopedTracker<HGLOBAL> globalMem;
globalMem.reset(GlobalAlloc(GMEM_MOVEABLE, startBroker->bufSize), GlobalFree);
if (NULL == globalMem)
throw MCException_Win("Failed to GlobalAlloc");
CComPtr<IStream> stream;
hr = CreateStreamOnHGlobal(globalMem, FALSE, &stream);
if (S_OK != hr)
throw MCException_Win(Format(_T("Failed to GlobalAlloc; result = %X"),hr));
ULARGE_INTEGER size;
size.QuadPart = startBroker->bufSize;
hr = stream->SetSize(size);
if (S_OK != hr)
throw MCException_Win(Format(_T("Failed to stream->SetSize; result = %X"),hr));
hr = CoMarshalInterface(stream, IID_IDispatch, broker, MSHCTX_LOCAL, NULL, MSHLFLAGS_NORMAL);
if (S_OK != hr)
throw MCException_Win(Format(_T("Failed to CoMarshalInterface; result = %X"),hr));
ULARGE_INTEGER uLi;
LARGE_INTEGER li;
li.QuadPart = 0;
/// Writing stream to client process memory
stream->Seek(li, STREAM_SEEK_SET, NULL);
boost::scoped_array<char> localBuf;
ULONG readCount;
localBuf.reset(new char[startBroker->bufSize]);
hr = stream->Read(localBuf.get(), startBroker->bufSize, &readCount);
if (S_OK != hr)
throw MCException_Win(Format(_T("stream->Read; result = %X"),hr));
/// Writing stream date into client process memory
ULONG writtenCount;
if (FALSE == WriteProcessMemory(inData->clientProcess, startBroker->buf, localBuf.get(), readCount, &writtenCount))
throw MCException_Win("Failed to WriteProcessMemory ");
CoUninitialize();
Log.Add(_MESSAGE_,_T("Broker created and marshaled to BrokerProxy process"));
return TRUE;
CATCH_LOG()
CoUninitialize();
return FALSE;
}
开发者ID:uvbs,项目名称:SupportCenter,代码行数:65,代码来源:CRCHostProxy.cpp
示例10: CATCH_LOG
CATCH_LOG()
}
/// Preparing to set vncHooks
m_vncHooks.reset(NULL, CloseHandle);
LoadVNCHooks();
CATCH_THROW()
}
void CRCHostProxy::LoadVNCHooks()
{
TRY_CATCH
if (NULL != m_vncHooks.get())
return; //Already loaded
tstring fileName = Format(_T("%s\\vnchooks.dll"),GetModulePath(NULL).c_str());
m_vncHooks.reset(LoadLibrary(fileName.c_str()),FreeLibrary);
if (NULL != m_vncHooks)
{
m_unSetHooks = (UnSetHooksFn) GetProcAddress( m_vncHooks, _T("UnSetHooks"));
m_setMouseFilterHook = (SetMouseFilterHookFn) GetProcAddress( m_vncHooks, _T("SetMouseFilterHook"));
m_setKeyboardFilterHook = (SetKeyboardFilterHookFn) GetProcAddress( m_vncHooks, _T("SetKeyboardFilterHook"));
m_setHooks = (SetHooksFn) GetProcAddress( m_vncHooks, _T("SetHooks"));
} else
throw MCException_Win(Format(_T("Failed to load %s"),fileName.c_str()));
Log.Add(_MESSAGE_,_T("VNCHooks loaded"));
CATCH_LOG()
}
CRCHostProxy::~CRCHostProxy()
{
开发者ID:uvbs,项目名称:SupportCenter,代码行数:31,代码来源:CRCHostProxy.cpp
示例11: operator
void operator()(const Args&... args) const
{
writeln(Format(args...));
}
开发者ID:Fuyutsubaki,项目名称:OpenSiv3D,代码行数:4,代码来源:Print.hpp
示例12: CheckKey
void Parser::CheckKey(int c)
{
if(!Key(c)) ThrowError(Format("Missing %c", c));
}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:4,代码来源:Parser.cpp
示例13: SAFE_DELETE
BOOL CParseRecInfoText::ParseRecInfoText(LPCWSTR filePath)
{
if( filePath == NULL ){
return FALSE;
}
multimap<wstring, REC_FILE_INFO*>::iterator itr;
for( itr = this->recInfoMap.begin(); itr != this->recInfoMap.end(); itr++ ){
SAFE_DELETE(itr->second)
}
this->recInfoMap.clear();
this->recIDMap.clear();
this->nextID = 1;
this->loadFilePath = filePath;
HANDLE hFile = _CreateFile2( filePath, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if( hFile == INVALID_HANDLE_VALUE ){
return FALSE;
}
DWORD dwFileSize = GetFileSize( hFile, NULL );
if( dwFileSize == 0 ){
CloseHandle(hFile);
return TRUE;
}
char* pszBuff = new char[dwFileSize+1];
if( pszBuff == NULL ){
CloseHandle(hFile);
return FALSE;
}
ZeroMemory(pszBuff,dwFileSize+1);
DWORD dwRead=0;
ReadFile( hFile, pszBuff, dwFileSize, &dwRead, NULL );
string strRead = pszBuff;
CloseHandle(hFile);
SAFE_DELETE_ARRAY(pszBuff);
string parseLine="";
size_t iIndex = 0;
size_t iFind = 0;
while( iFind != string::npos ){
iFind = strRead.find("\r\n", iIndex);
if( iFind == (int)string::npos ){
parseLine = strRead.substr(iIndex);
//strRead.clear();
}else{
parseLine = strRead.substr(iIndex,iFind-iIndex);
//strRead.erase( 0, iIndex+2 );
iIndex = iFind + 2;
}
//先頭;はコメント行
if( parseLine.find(";") != 0 ){
//空行?
if( parseLine.find("\t") != string::npos ){
REC_FILE_INFO* item = new REC_FILE_INFO;
BOOL bRet = Parse1Line(parseLine, item);
if( bRet == FALSE ){
SAFE_DELETE(item)
}else{
wstring strKey;
Format(strKey, L"%04d%02d%02d%02d%02d%02d%04X%04X",
item->startTime.wYear,
item->startTime.wMonth,
item->startTime.wDay,
item->startTime.wHour,
item->startTime.wMinute,
item->startTime.wSecond,
item->originalNetworkID,
item->transportStreamID);
item->id = GetNextReserveID();
this->recInfoMap.insert( pair<wstring, REC_FILE_INFO*>(strKey,item) );
this->recIDMap.insert( pair<DWORD, REC_FILE_INFO*>(item->id,item) );
}
}
}
}
开发者ID:HK323232,项目名称:EDCB,代码行数:79,代码来源:ParseRecInfoText.cpp
示例14: AddCode
void VertexProgramDecompiler::AddCode(const std::string& code)
{
m_body.push_back(Format(code) + ";");
m_cur_instr->body.push_back(Format(code));
}
开发者ID:notoknight,项目名称:rpcs3,代码行数:5,代码来源:VertexProgramDecompiler.cpp
示例15: Construction
protected func Construction()
{
var graphic = Random(5);
if(graphic)
SetGraphics(Format("%d",graphic));
}
开发者ID:Fulgen301,项目名称:openclonk,代码行数:6,代码来源:Script.c
示例16: Format
void FragmentProgramDecompiler::AddCode(const std::string& code)
{
main.append(m_code_level, '\t') += Format(code) + "\n";
}
开发者ID:Majkel86,项目名称:rpcs3,代码行数:4,代码来源:FragmentProgramDecompiler.cpp
示例17: VehicleDataCallbackFuc
// 抓拍数据
void CALLBACK VehicleDataCallbackFuc(void *pUserData, VehicleData *pData)
{
TForm1 *pThis = (TForm1 *)pUserData;
if(pThis->tvConnectDev->Selected == NULL) return;
String strIP;
bool bFlag = false;
PDevInfo pDev = NULL;
TTreeNodes *nodes = pThis->tvConnectDev->Items;
if(nodes != NULL)
{
for(int i = 0; i < nodes->Count; i++)
{
if(TreeView_GetCheckState(pThis->tvConnectDev->Handle,nodes->Item[i]->ItemId))
{
String strViewIP = nodes->Item[i]->Text;
// 只显示指定抓拍的设备数据
strIP.sprintf("%s", pData->ucDeviceIP);
if(strIP == strViewIP)
{
bFlag = true;
break;
}
}
}
}
if(!bFlag) return;
int nColor = pData->PlateColor;
TDateTime dataTime = Now();
SYSTEMTIME tm;
GetSystemTime(&tm);
String strPlate = (char *)pData->ucPlate;
String strPath;
String strBigFile, strCifFile, strPlateFile, strPlateNoFile;
int iFileHandle = 0;
// 大图
if(pData->pucBigImage != NULL && pData->uiBigImageLen > 0)
{
strPath = pThis->strImagePath + strIP + "\\大图\\" + FormatDateTime("yyyymmdd", dataTime) + "\\";
pThis->CreateDirectoryRecurrent(strPath);
strBigFile = Format("%s%s%03d(%s).jpg", ARRAYOFCONST((strPath, dataTime.FormatString("hhmmss"), tm.wMilliseconds, strPlate)));
iFileHandle = FileCreate(strBigFile);
if(iFileHandle != 0)
{
FileWrite(iFileHandle, pData->pucBigImage, pData->uiBigImageLen);
FileClose(iFileHandle);
if(FileExists(strBigFile))
{
pThis->imgBigImg->Picture->LoadFromFile(strBigFile);
}
}
}
// CIF图
if(pData->pucCIFImage != NULL && pData->uiCIFImageLen > 0)
{
strPath = pThis->strImagePath + strIP + "\\CIF图\\" + dataTime.FormatString("yyyymmdd") + "\\";
pThis->CreateDirectoryRecurrent(strPath);
strCifFile = Format("%s%s%03d(%s).jpg", ARRAYOFCONST((strPath, dataTime.FormatString("hhmmss"), tm.wMilliseconds, strPlate)));
iFileHandle = FileCreate(strCifFile);
if(iFileHandle != 0)
{
FileWrite(iFileHandle, pData->pucCIFImage, pData->uiCIFImageLen);
FileClose(iFileHandle);
if(FileExists(strCifFile))
{
pThis->imgCIFImg->Picture->LoadFromFile(strCifFile);
}
}
}
// 车牌图
if(pData->pucPlateImage != NULL && pData->uiPlateImageLen > 0)
{
strPath = pThis->strImagePath + strIP + "\\车牌图\\" + dataTime.FormatString("yyyymmdd") + "\\";
pThis->CreateDirectoryRecurrent(strPath);
strPlateFile = Format("%s%s%03d(%s).jpg", ARRAYOFCONST((strPath, dataTime.FormatString("hhmmss"), tm.wMilliseconds, strPlate)));
iFileHandle = FileCreate(strPlateFile);
if(iFileHandle != 0)
{
FileWrite(iFileHandle, pData->pucPlateImage, pData->uiPlateImageLen);
FileClose(iFileHandle);
}
if(FileExists(strPlateFile))
{
pThis->imgPlateImg->Picture->LoadFromFile(strPlateFile);
}
}
// 车牌号码
//.........这里部分代码省略.........
开发者ID:houzhenggang,项目名称:zhitonghuiyuan,代码行数:101,代码来源:MainUnit.cpp
示例18: RunInstallScripts
//=================================================================================================
bool RunInstallScripts()
{
Info("Reading install scripts.");
WIN32_FIND_DATA data;
HANDLE find = FindFirstFile(Format("%s/install/*.txt", g_system_dir.c_str()), &data);
if(find == INVALID_HANDLE_VALUE)
return true;
vector<InstallScript> scripts;
Tokenizer t;
t.AddKeyword("install", 0);
t.AddKeyword("version", 1);
t.AddKeyword("remove", 2);
do
{
int major, minor, patch;
// read file to find version info
try
{
if(t.FromFile(Format("%s/install/%s", g_system_dir.c_str(), data.cFileName)))
{
t.Next();
if(t.MustGetKeywordId() == 2)
{
// old install script
if(sscanf_s(data.cFileName, "%d.%d.%d.txt", &major, &minor, &patch) != 3)
{
if(sscanf_s(data.cFileName, "%d.%d.txt", &major, &minor) == 2)
patch = 0;
else
{
// unknown version
major = 0;
minor = 0;
patch = 0;
}
}
}
else
{
t.AssertKeyword(0);
t.Next();
if(t.MustGetInt() != 1)
t.Throw(Format("Unknown install script version '%d'.", t.MustGetInt()));
t.Next();
t.AssertKeyword(1);
t.Next();
major = t.MustGetInt();
t.Next();
minor = t.MustGetInt();
t.Next();
patch = t.MustGetInt();
}
InstallScript& s = Add1(scripts);
s.filename = data.cFileName;
s.version = (((major & 0xFF) << 16) | ((minor & 0xFF) << 8) | (patch & 0xFF));
}
}
catch(const Tokenizer::Exception& e)
{
Warn("Unknown install script '%s': %s", data.cFileName, e.ToString());
}
} while(FindNextFile(find, &data));
FindClose(find);
if(scripts.empty())
return true;
std::sort(scripts.begin(), scripts.end());
GetModuleFileName(nullptr, BUF, 256);
char buf[512], buf2[512];
char* filename;
GetFullPathName(BUF, 512, buf, &filename);
*filename = 0;
DWORD len = strlen(buf);
LocalString s, s2;
for(vector<InstallScript>::iterator it = scripts.begin(), end = scripts.end(); it != end; ++it)
{
cstring path = Format("%s/install/%s", g_system_dir.c_str(), it->filename.c_str());
try
{
if(!t.FromFile(path))
{
Error("Failed to load install script '%s'.", it->filename.c_str());
continue;
}
Info("Using install script %s.", it->filename.c_str());
t.Next();
t.AssertKeyword();
//.........这里部分代码省略.........
开发者ID:lcs2,项目名称:carpg,代码行数:101,代码来源:Main.cpp
示例19: fopen_s
void ConvertInx::Convert( s_Inx* InxFile )
{
FILE* oldInx = nullptr;
FILE* bakInx = nullptr;
FILE* newInx = nullptr;
INT oldAddress = 0;
INT newAddress = 0;
fopen_s( &oldInx, InxFile->FullPath, "rb" );
fopen_s( &bakInx, Format( "%s.bak", GetName( InxFile->FullPath ) ), "wb+" );
if( !oldInx )
{
fclose( bakInx );
fprintf( lpDbg, "[ ERROR ] : %s\n", InxFile->FullPath );
return;
};
char oldData[ OLD_INX_SIZE ] = { 0 };
char newData[ NEW_INX_SIZE ] = { 0 };
fread_s( &oldData, OLD_INX_SIZE, OLD_INX_SIZE, sizeof( char ), oldInx );
fclose( oldInx );
DeleteFileA( InxFile->FullPath );
fwrite( oldData, OLD_INX_SIZE, sizeof( char ), bakInx );
fclose( bakInx );
fopen_s( &newInx, InxFile->FullPath, "wb+" );
while( oldAddress < OLD_INX_SIZE )
{
switch( newAddress )
{
case 0x63C: oldAddress = 0x844; break;
case 0x6A8: oldAddress = 0x8E4; break;
case 0x720: oldAddress = 0x990; break;
case 0x798: oldAddress = 0xA3C; break;
case 0x814: oldAddress = 0xAEC; break;
case 0x88C: oldAddress = 0xB98; break;
case 0x904: oldAddress = 0xC44; break;
case 0x97C: oldAddress = 0xCF0; break;
case 0x9F4: oldAddress = 0xD9C; break;
case 0xA6C: oldAddress = 0xE48; break;
case 0xAE4: oldAddress = 0xB18; break;
case 0xB5C: oldAddress = 0xBC4; break;
case 0xBD4: oldAddress = 0xC70; break;
case 0xF18C: oldAddress = 0x1598C; break;
case 0x10068: oldAddress = 0x16E80; break;
};
newData[ newAddress ] = oldData[ oldAddress ];
oldAddress++;
newAddress++;
};
fwrite( newData, NEW_INX_SIZE, sizeof( char ), newInx );
fclose( newInx );
fprintf( lpDbg, "Convertido: %s\n", InxFile->FullPath );
};
开发者ID:TreasurePT,项目名称:TreasurePT,代码行数:61,代码来源:convert_inx.cpp
示例20: _SlxConvertProfileRegKey
static void _SlxConvertProfileRegKey(const wchar_t* pszRegKey, CProfileSection* pSection)
{
// Open sub key
CSmartHandle<HKEY> Key;
if (RegOpenKeyEx(HKEY_CURRENT_USER, pszRegKey, 0, KEY_READ, &Key)==ERROR_SUCCESS)
{
// Enumerate all values
DWORD dwIndex=0;
TCHAR szName[MAX_PATH];
DWORD cbName=MAX_PATH;
DWORD dwType;
while (RegEnumValue(Key, dwIndex++, szName, &cbName, NULL, &dwType, NULL, NULL)==ERROR_SUCCESS)
{
switch (dwType)
{
case REG_SZ:
{
CUniString str;
if (RegGetString(Key, NULL, szName, str)==ERROR_SUCCESS)
{
pSection->SetValue(szName, str);
}
break;
}
case REG_DWORD:
{
DWORD dw;
if (RegGetDWORD(Key, NULL, szName, &dw)==ERROR_SUCCESS)
{
pSection->SetIntValue(szName, dw);
}
break;
}
case REG_BINARY:
{
CAutoPtr<IStream, SRefCounted> spStreamSrc;
if (SUCCEEDED(OpenRegistryStream(Key, NULL, szName, &spStreamSrc)))
{
CAutoPtr<IStream, SRefCounted> spStreamDest;
if (SUCCEEDED(CreateProfileStream(pSection->CreateEntry(szName), NULL, &spStreamDest)))
{
CopyStream(spStreamDest, spStreamSrc);
}
}
break;
}
}
// Reset size
cbName=MAX_PATH;
}
Key.Release();
}
// Copy sub sections
CUniStringVector vecSubSections;
RegEnumAllKeys(HKEY_CURRENT_USER, pszRegKey, vecSubSections);
for (int i=0; i<vecSubSections.GetSize(); i++)
{
_SlxConvertProfileRegKey(Format(L"%s\\%s", pszRegKey, vecSubSections[i]), pSection->CreateSection(vecSubSections[i]));
}
}
开发者ID:adhawkins,项目名称:SimpleLib,代码行数:68,代码来源:ProfileSettings.cpp
注:本文中的Format函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论