void CRecvM::OnBnClickedButton1() { UpdateData(TRUE); CStringArray ss; ss.Add(GetWndTextByCString(CmpyNameBox)); ss.Add(GetWndTextByCString(dateBox)); ss.Add(GetWndTextByCString(CourierNumBox)); ss.Add(GetWndTextByCString(CsgBox)); ss.Add(GetWndTextByCString(RecverBox)); ss.Add(GetWndTextByCString(remarkBox)); if (!(ss[0].GetLength() && ss[2].GetLength() && ss[3].GetLength() && ss[4].GetLength() && contain_box.GetItemCount())) { AfxMessageBox(_T("请填写完整信息!")); return; } _RecordsetPtr m_pRecordset; m_pRecordset.CreateInstance(__uuidof(Recordset)); try { USES_CONVERSION; memset(sql, 0, sizeof(sql)); strcat_s(sql, "insert into RecvInfo (CorpName, RecvDate, WaybillNum, Consignee, Receiver, Remark) values ('"); for (int i = 0; i < 5; i++) { strcat_s(sql, T2A(ss[i].GetBuffer())); strcat_s(sql, "','"); } strcat_s(sql, T2A(ss[5].GetBuffer())); strcat_s(sql, "')"); AfxMessageBox(CString(sql)); m_pRecordset->Open(sql, m_pConnection.GetInterfacePtr(), adOpenDynamic, adLockOptimistic, adCmdText); } catch(_com_error *e) { CString errormessage; errormessage.Format(_T("操作数据库失败!\r\n错误信息:%s"), e->ErrorMessage()); AfxMessageBox(errormessage); return; } updateListBox(showBox, ss[1]); UpdateData(FALSE); USES_CONVERSION; for (int i = 0; i < contain_box.GetItemCount(); i++) { InsertDetail(atoi(T2A(showBox.GetItemText(showBox.GetItemCount() - 1, 0).GetBuffer())), i); } contain_box.DeleteAllItems(); }
CTwainScanistor* CTwainSourceManager::OpenSource( LPCTSTR lpProductName ) { if(State != DSMOpen || OpenDSM() != 1) { return 0; } if(!lpProductName || !(*lpProductName)) { return 0; } std::auto_ptr<IEnumerator<TW_IDENTITY>> pEnumSrc(EnumSource()); if(pEnumSrc.get()) { std::string productName = T2A(lpProductName); while(pEnumSrc->MoveNext()) { if(productName == pEnumSrc->Current().ProductName) { return OpenSource(pEnumSrc->Current()); } } } return 0; }
void CBCGPMSOffice2007DemoView::OnFontname() { USES_CONVERSION; CBCGPRibbonBar* pRibbon = ((CMainFrame*) GetTopLevelFrame ())->GetRibbonBar (); ASSERT_VALID (pRibbon); CBCGPRibbonFontComboBox* pFontCombo = DYNAMIC_DOWNCAST ( CBCGPRibbonFontComboBox, pRibbon->FindByID (ID_FONT_FONT)); if (pFontCombo == NULL) { return; } CCharFormat cf; cf.szFaceName[0] = NULL; cf.dwMask = CFM_FACE | CFM_CHARSET; const CBCGPFontDesc* pDesc = pFontCombo->GetFontDesc (); ASSERT_VALID (pDesc); ASSERT(pDesc->m_strName.GetLength() < LF_FACESIZE); #if _MSC_VER >= 1300 lstrcpyn(cf.szFaceName, pDesc->m_strName, LF_FACESIZE); #else lstrcpynA(cf.szFaceName, T2A((LPTSTR) (LPCTSTR) pDesc->m_strName), LF_FACESIZE); #endif cf.bCharSet = pDesc->m_nCharSet; cf.bPitchAndFamily = pDesc->m_nPitchAndFamily; SetCharFormat (cf); }
/** * /remarks * * /retval - ERROR_SUCCESS (sequencer keeps going) * - <anything else> (error code for build, sequencer stops) * * /details - failaction = ignore * - return ERROR_SUCCESS * * - failaction = retry * - retry MAX_RETRY_ATTEMPTS times, then return * success || fail * * - failaction = quit * - return error code directly * * /note - modules loaded here are freed when the sequence ends * */ UINT CBldAction::ExecuteDll(void) { USES_CONVERSION; CString sMsg; UINT uiReturn = IDOK; LPCSTR szFn = T2A(m_strEntryPoint); HMODULE hDll = CBldActionDllManager::LoadDll(m_strScript); if (hDll) { ACTION_DLL_RUN pfn = (ACTION_DLL_RUN)::GetProcAddress(hDll, szFn); if (pfn) { uiReturn = pfn(static_cast<LPCTSTR>(m_strName)); sMsg.Format(L"action library: '%s' : attempt : %d", m_strScript, m_iRetryAttempts); WriteToLog(sMsg); } } sMsg.Format(L"return value : %d : %s", uiReturn, CRedHelperFn::GetErrorMsg(uiReturn)); WriteToLog(sMsg); return uiReturn; } //CBldAction::RunDll()
//加载文字处理函数 void CRecognitionTextView::OnLoadcharacter() { // TODO: 在此添加命令处理程序代码 if (fileCount > 0) { static TCHAR BASED_CODE szFilter[] = _T("Map Files (*.dat)|*.dat||"); //进行文件过滤 CFileDialog fileDialog(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, this); if(fileDialog.DoModal() == IDOK){ CString datFileName; datFileName = fileDialog.GetPathName(); MessageBox(datFileName); USES_CONVERSION; //声明标识符 FILE *file = fopen(T2A(datFileName), "rb"); //调用函数库实现CString到const char*转换 if(!file) { printf("打开文件失败"); return; } for(int i = 0 ;i<7356;i++) { //读取字符 fread(words[i], 2, 1, file); words[i][2] = '\0'; printf("%s\t",words[i]); } fclose(file); } } else { MessageBox(_T("请先加载图片")); } }
PixRectArray::PixRectArray(const StringArray &fileNames, StringArray &errors) { USES_CONVERSION; m_updateCounter = 0; for(size_t i = 0; i < fileNames.size(); i++) { const String &name = fileNames[i]; try { if(FileNameSplitter(name).getExtension().equalsIgnoreCase(_T(".gif"))) { int error; const char *namea = T2A(name.cstr()); GifFileType *gifFile = DGifOpenFileName(namea, &error); if(gifFile == NULL) { throwException(_T("%s"), GifErrorString(error)); } if(DGifSlurp(gifFile) != GIF_OK) { const String msg = GifErrorString(gifFile->Error); DGifCloseFile(gifFile, &error); throwException(_T("%s"), msg.cstr()); } const int imageCount = gifFile->ImageCount; for(int k = 0; k < imageCount; k++) { add(new GifPixRect(gifFile, k)); } DGifCloseFile(gifFile, &error); } else { add(GifPixRect::load(name)); } } catch(Exception e) { errors.add(e.what()); } } }
// Constructor. DBGSERV_API TraceService::TraceService() { try { // Read the trace file name and the log enable/disabled flag from the registry. DWORD dwTraceEnabled = Registry::RegGetDWORDValue(HKEY_CURRENT_USER, REG_TRACE_KEY_NAME, REG_TRACE_FLAG_VALUE_NAME); m_bLogEnabled = (dwTraceEnabled != 0); if (m_bLogEnabled) { String sLogFile = Registry::RegGetStringValue(HKEY_CURRENT_USER, REG_TRACE_KEY_NAME, REG_TRACE_FILE_NAME); USES_CONVERSION; m_sLogFile = T2A(const_cast<TCHAR*>(sLogFile.c_str())); // Log file is always ASCII. } } catch (const RegistryException& regException) { #ifdef _DEBUG ::OutputDebugString(_T("Registry exception while initializing the trace system\n")); ::OutputDebugString(regException.ToString().c_str()); ::OutputDebugString(_T("\n")); #else // Avoid "unreferenced local variable" warning. regException; #endif // The traces are disabled by default. m_bLogEnabled = FALSE; } // Alloc a thread local index. m_dwTlsIndex = ::TlsAlloc(); }
void CActionsSampleView::OnInitialUpdate() { CRichEditView::OnInitialUpdate(); USES_CONVERSION; // Set the printing margins (720 twips = 1/2 inch). SetMargins(CRect(720, 720, 720, 720)); CHARFORMAT cf; ZeroMemory(&cf, sizeof(CHARFORMAT)); CString strDefFont = _T("Tahoma"); cf.cbSize = sizeof(CHARFORMAT); cf.dwMask = CFM_BOLD |CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT | CFM_SIZE | CFM_COLOR | CFM_OFFSET | CFM_PROTECTED | CFM_FACE; cf.dwEffects = CFE_AUTOCOLOR; cf.yHeight = 200; //10pt cf.bPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; #if (_RICHEDIT_VER >= 0x0200) lstrcpyn(cf.szFaceName, strDefFont, LF_FACESIZE); #else lstrcpynA(cf.szFaceName, T2A((LPTSTR) (LPCTSTR) strDefFont), LF_FACESIZE); #endif GetRichEditCtrl().SetDefaultCharFormat(cf); }
BOOL CNNTPSocket::Connect(LPCTSTR pszHostAddress, int nPort) { USES_CONVERSION; if(m_hSocket == INVALID_SOCKET) return FALSE; SOCKADDR_IN sockAddr; ZeroMemory(&sockAddr, sizeof(sockAddr)); sockAddr.sin_family = AF_INET; sockAddr.sin_port = htons((u_short)nPort); char* pszAsciiHostAddress = T2A((LPTSTR) pszHostAddress); sockAddr.sin_addr.s_addr = inet_addr(pszAsciiHostAddress); if (sockAddr.sin_addr.s_addr == INADDR_NONE) { LPHOSTENT lphost; lphost = gethostbyname(pszAsciiHostAddress); if (lphost != NULL) sockAddr.sin_addr.s_addr = ((LPIN_ADDR)lphost->h_addr)->s_addr; else { return FALSE; } } return Connect((SOCKADDR*)&sockAddr, sizeof(sockAddr)); }
void AppLauncherDlg::OnChooseApp() { USES_CONVERSION; TCHAR szPath[MAX_PATH + 1]; memset(szPath, 0, sizeof(szPath)); TCHAR *lpszFilter = _T("EXE Files Only (*.exe)\0*.exe\0" "All Files (*.*)\0*.*\0\0"); OPENFILENAME ofn; memset(&ofn, 0, sizeof(ofn)); #if _WIN32_WINNT >= 0x0500 ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; #else ofn.lStructSize = sizeof(ofn); #endif ofn.Flags = OFN_FILEMUSTEXIST; ofn.lpstrFilter = lpszFilter; ofn.lpstrDefExt = _T("exe"); ofn.lpstrFile = szPath; ofn.nMaxFile = MAX_PATH; if (GetOpenFileName(&ofn)) { USES_CONVERSION; mOpenWith = T2A(szPath); SetDlgItemText(mHwndDlg, IDC_APPLICATION, szPath); CheckRadioButton(mHwndDlg, IDC_OPENWITHAPP, IDC_SAVETOFILE, IDC_OPENWITHAPP); } }
NiNodeRef Exporter::createNode(INode* maxNode, const string& name) { USES_CONVERSION; bool ismatch = strmatch(T2A(maxNode->GetName()), name); if (ismatch) { NodeToNodeMap::iterator itr = mNodeMap.find(maxNode); if (itr != mNodeMap.end()) return (*itr).second; } NiNodeRef node; if (!findNode(name, node)) { node = createNode(); BOOL noname = FALSE; if (!maxNode->GetUserPropBool(NP_NONAME, noname) || !noname) node->SetName(name); } if (wildmatch("noname*", name)) { maxNode->SetUserPropBool(NP_NONAME, TRUE); } mNodeMap[maxNode] = node; return node; }
STDMETHODIMP CoExtender::GetChannelSource( int iChannel, VCACONFIG_CHANNEL_SRC *pSrc) { // Tell them about the sources we support USES_CONVERSION; memset( pSrc, 0, sizeof( VCACONFIG_CHANNEL_SRC ) ); ASSERT( iChannel == 0 ); pSrc->iChannelId = 0; if( m_bVideo ) { // We provide video, so we tell them we'll stream through the IF pSrc->videoSrcType = VCACONFIG_SRC_IF; } else { // We want them to provide the video... switch( m_eVideoType ) { case VIDEO_DSHOW: pSrc->videoSrcType = VCACONFIG_SRC_DSHOW; break; case VIDEO_VLC: pSrc->videoSrcType = VCACONFIG_SRC_VLC; break; default: pSrc->videoSrcType = VCACONFIG_SRC_NULL; break; } } strcpy_s( pSrc->szVideoData, _countof( pSrc->szVideoData ), T2A(m_sVideoData.GetBuffer(0)) ); pSrc->fMediaTypeFlags = (m_bMeta & VCACONFIG_MEDIA_METADATA) | (m_bVideo & VCACONFIG_MEDIA_VIDEO); // Provides just meta return S_OK; }
void WriteLog(LPCTSTR pszLogFileName, LPCTSTR pszLog) { #ifdef _UNICODE USES_CONVERSION; #endif HANDLE hLogFile = ::CreateFile(pszLogFileName, GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if(hLogFile != INVALID_HANDLE_VALUE) ::SetFilePointer(hLogFile, 0, 0, FILE_END); else return; DWORD dwSize; SYSTEMTIME st; GetLocalTime(&st); CString strLog; strLog.Format(_T("[%02d-%02d %02d:%02d:%02d.%03d] %s\r\n"), st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, pszLog); #ifdef _UNICODE LPSTR lpszLog = T2A((LPTSTR)(LPCTSTR)strLog); ::WriteFile(hLogFile, lpszLog, (DWORD)::strlen(lpszLog), &dwSize, nullptr); #else ::WriteFile(hLogFile, strLog, strLog.GetLength(), &dwSize, nullptr); #endif ::CloseHandle(hLogFile); }
void setup_paths() { TCHAR rootpath_buffer[MAX_PATH]; char *rootpath; get_mame_root(rootpath_buffer, sizeof(rootpath_buffer) / sizeof(rootpath_buffer[0])); rootpath = (char *) T2A(rootpath_buffer); #ifdef MESS set_fileio_opt(rootpath, "biospath", "\\Bios"); set_fileio_opt(rootpath, "cheat_file", "\\cheat.cdb"); set_fileio_opt(rootpath, "softwarepath", "\\Software"); #else set_fileio_opt(rootpath, "rompath", "\\ROMs"); set_fileio_opt(rootpath, "cheat_file", "\\cheat.dat"); #endif set_fileio_opt(rootpath, "inipath", "\\Ini"); set_fileio_opt(rootpath, "samplepath", "\\Samples"); set_fileio_opt(rootpath, "cfg_directory", "\\Cfg"); set_fileio_opt(rootpath, "nvram_directory", "\\Nvram"); set_fileio_opt(rootpath, "memcard_directory", "\\Memcard"); set_fileio_opt(rootpath, "input_directory", "\\Inp"); set_fileio_opt(rootpath, "hiscore_directory", "\\Hi"); set_fileio_opt(rootpath, "artwork_directory", "\\Artwork"); set_fileio_opt(rootpath, "snapshot_directory", "\\Snap"); set_fileio_opt(rootpath, "history_file", "\\history.dat"); set_fileio_opt(rootpath, "mameinfo_file", "\\mameinfo.dat"); }
void TableInfo::put(RecordType &rec, UINT n, const String &v) const { if(v.length() > m_columns[n].getMaxStringLen()) { throwSqlError(SQL_STRING_TOO_LONG,_T("%s:String too long to fit in keyfield[%d]. len=%d. maxlen=%d") ,__TFUNCTION__,n,(UINT)v.length(),m_columns[n].getMaxStringLen()); } USES_CONVERSION; switch(getColumn(n).getType()) { case DBTYPE_CSTRING : case DBTYPE_CSTRINGN : { char tmp[MAXRECSIZE+1]; memset(tmp,0,sizeof(tmp)); strcpy(tmp,T2A((TCHAR*)v.cstr())); putBytes(rec,n,tmp); } break; case DBTYPE_WSTRING : case DBTYPE_WSTRINGN : { wchar_t tmp[MAXRECSIZE+1]; memset(tmp,0,sizeof(tmp)); wcscpy(tmp,T2W((TCHAR*)v.cstr())); putBytes(rec,n,tmp); } break; default: THROWFIELDNOTSTRING(n); } }
void CRecvM::updateListBox(CListCtrl &m_listCtrl, CString time) { _RecordsetPtr m_pRecordset; m_pRecordset.CreateInstance(__uuidof(Recordset)); try { memset(sql, 0, sizeof(sql)); strcat_s(sql, "select * from RecvInfo where RecvDate=#"); USES_CONVERSION; strcat_s(sql, T2A(time.GetBuffer())); strcat_s(sql, "#"); m_pRecordset->Open(sql, m_pConnection.GetInterfacePtr(), adOpenDynamic, adLockOptimistic, adCmdText); } catch(_com_error *e) { CString errormessage; errormessage.Format(_T("操作数据库失败!\r\n错误信息:%s"), e->ErrorMessage()); AfxMessageBox(errormessage); return; } showBox.DeleteAllItems(); try { if (!m_pRecordset->BOF) m_pRecordset->MoveFirst(); else { return; } int i = 0; while (!m_pRecordset->adoEOF) { _variant_t var1, var2, var3, var4, var5, var6, var7; var1 = m_pRecordset->GetCollect("ID"); var2 = m_pRecordset->GetCollect("CorpName"); var3 = m_pRecordset->GetCollect("RecvDate"); var4 = m_pRecordset->GetCollect("WaybillNum"); var5 = m_pRecordset->GetCollect("Consignee"); var6 = m_pRecordset->GetCollect("Receiver"); var7 = m_pRecordset->GetCollect("Remark"); CString p; p.Format(_T("%d"), var1.intVal); showBox.InsertItem(i, p); showBox.SetItemText(i, 1, var2.bstrVal); showBox.SetItemText(i, 2, CString(var3)); showBox.SetItemText(i, 3, var4.bstrVal); showBox.SetItemText(i, 4, var5.bstrVal); showBox.SetItemText(i, 5, var6.bstrVal); showBox.SetItemText(i, 6, var7.bstrVal); i++; m_pRecordset->MoveNext(); } m_pRecordset->Close(); } catch(_com_error *e) { CString errormessage; errormessage.Format(_T("数据库操作错误!\r\n错误信息:%s"), e->ErrorMessage()); AfxMessageBox(errormessage); } }
STDMETHODIMP InterfaceRuleAction::get_IMAPFolder(BSTR *pVal) { try { if (!m_pObject) return GetAccessDenied(); USES_CONVERSION; // Convert the modified UTF7 string into unicode. // Since hMailServer core don't know unicode, we // have to do it out here in the interface. HM::String sValue = m_pObject->GetIMAPFolder(); HM::String sResult = HM::ModifiedUTF7::Decode(T2A(sValue.GetBuffer())); *pVal = sResult.AllocSysString(); return S_OK; } catch (...) { return COMError::GenerateGenericMessage(); } }
void CDIL_CAN_i_VIEW::GetSystemErrorString() { LPVOID MsgBuf; DWORD Result = 0; Result = FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &MsgBuf, 0, nullptr ); if (Result <= 0) { m_Err = "system error message retrieval operation failed"; } else { m_Err = T2A((LPTSTR)MsgBuf); LocalFree(MsgBuf); } }
static void GetSystemErrorString() { LPVOID lpMsgBuf; DWORD dwResult = 0; dwResult = 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 ); if (dwResult <= 0) { strcpy(sg_acErrStr, "system error message retrieval operation failed"); } else { LPSTR pBuf = T2A((LPTSTR) lpMsgBuf); INITIALISE_DATA(sg_acErrStr); lstrcpy(sg_acErrStr, pBuf); // Free the buffer. LocalFree(lpMsgBuf); } }
BOOL CNtpSocket::Connect( LPCTSTR pszHostAddress, int nPort ) { // For correct operation of the T2A macro, see MFC Tech Note 59 USES_CONVERSION; // must have been created first ASSERT( m_hSocket != INVALID_SOCKET ); LPSTR lpszAscii = T2A( (LPTSTR)pszHostAddress ); // Determine if the address is in dotted notation SOCKADDR_IN sockAddr; memset( &sockAddr, 0, sizeof(sockAddr) ); sockAddr.sin_family = AF_INET; sockAddr.sin_port = htons( (u_short)nPort ); sockAddr.sin_addr.s_addr = inet_addr( lpszAscii ); // If the address is not dotted notation, then do a DNS lookup of it if( sockAddr.sin_addr.s_addr == INADDR_NONE ) { LPHOSTENT lphost; lphost = gethostbyname( lpszAscii ); if( lphost != NULL ) sockAddr.sin_addr.s_addr = ( (LPIN_ADDR)lphost->h_addr )->s_addr; else return FALSE; } // Call the protected version which takes an address // in the form of a standard C style struct return Connect( (SOCKADDR*)&sockAddr, sizeof(sockAddr) ); }
BOOL COptions::FreeXML(TiXmlElement *pXML, bool save) { ASSERT(pXML); if (!pXML) return FALSE; simple_lock lock(m_mutex); // As locked by GetXML m_mutex.unlock(); if (!save) { delete pXML->GetDocument(); return FALSE; } USES_CONVERSION; CStdString xmlFileName = GetExecutableDirectory() + _T("FileZilla Server.xml"); char* bufferA = T2A(xmlFileName); if (!bufferA) { delete pXML->GetDocument(); return FALSE; } if (!pXML->GetDocument()->SaveFile(bufferA)) { delete pXML->GetDocument(); return FALSE; } delete pXML->GetDocument(); return TRUE; }
// read dwCount bytes into lpszBuffer, and return number read // stop if source is empty, or when end of string reached DWORD _RichToolTipCtrlCookie::Read(LPBYTE lpBuffer, DWORD dwCount) { if (lpBuffer == NULL) return (DWORD)-1; // have we already had it all? DWORD dwLeft = m_dwLength - m_dwCount; if (dwLeft <= 0) // all done return 0; // start the source string from where we left off USES_CONVERSION; LPCSTR lpszText = (LPCSTR)T2A(m_sText.GetBuffer(0)) + m_dwCount; // only copy what we've got left if (dwLeft < dwCount) dwCount = dwLeft; // copy the text #if _MSC_VER >= 1400 strncpy_s((LPSTR)lpBuffer, dwCount, lpszText, _TRUNCATE); #else strncpy((LPSTR)lpBuffer, lpszText, dwCount); #endif // _MSC_VER // keep where we got to m_dwCount += dwCount; // return how many we copied return dwCount; }
TiXmlElement *COptions::GetXML() { simple_lock lock(m_mutex); USES_CONVERSION; CStdString xmlFileName = GetExecutableDirectory() + _T("FileZilla Server.xml"); char* bufferA = T2A(xmlFileName); if (!bufferA) { return 0; } TiXmlDocument *pDocument = new TiXmlDocument; if (!pDocument->LoadFile(bufferA)) { delete pDocument; return NULL; } TiXmlElement* pElement = pDocument->FirstChildElement("FileZillaServer"); if (!pElement) { delete pDocument; return NULL; } // Must call FreeXML m_mutex.lock(); return pElement; }
//-------------------------------------------------------------------------------- bool CSmallSocket::ConvertInAddr(LPCTSTR pIn, int nSocketPort, SOCKADDR_IN* pOut) { USES_CONVERSION; ::ZeroMemory(pOut, sizeof(SOCKADDR_IN)); LPSTR lpszAscii = T2A((LPTSTR) pIn); pOut->sin_family = AF_INET; if (lpszAscii == NULL) pOut->sin_addr.s_addr = htonl(INADDR_ANY); else { DWORD lResult = inet_addr(lpszAscii); if (lResult == INADDR_NONE) { SetLastError(WSAEINVAL); STRACE1("CSmallSocket::ConvertInAddr failed %ld\n", WSAEINVAL); return false; } pOut->sin_addr.s_addr = lResult; } pOut->sin_port = htons((u_short)nSocketPort); return true; }
bool CZipObj::UnZipFile(CString strZipPath, CString strUnzipPath) { USES_CONVERSION; int nPos = strZipPath.ReverseFind('.'); CString strPath = strZipPath.Left(nPos); //.zip strZipPath.GetLength() - 4 if (strUnzipPath != "") strPath = strUnzipPath; std::string strUtf8Path = CMyCodeConvert::Gb2312ToUtf8(T2A(strPath)); try { Poco::File p(strUtf8Path); //T2A(strPath) if (p.exists()) p.remove(true); } catch (Poco::Exception) { } HZIP hz = OpenZip(strZipPath, _strPwd.c_str()); ZIPENTRY ze; GetZipItem(hz, -1, &ze); int numitems = ze.index; SetUnzipBaseDir(hz, strPath); for (int i = 0; i < numitems; i++) { GetZipItem(hz, i, &ze); UnzipItem(hz, i, ze.name); } CloseZip(hz); return true; }
void CScanMgrDlg::DownLoadModel() { if (!_pCurrExam_ || !_pCurrSub_) return; g_nDownLoadModelStatus = 0; //先查本地列表,如果没有则请求,如果有,计算crc,和服务器不同则下载 USES_CONVERSION; CString modelPath = g_strCurrentPath + _T("Model"); modelPath = modelPath + _T("\\") + A2T(_pCurrSub_->strModelName.c_str()); std::string strModelPath = T2A(modelPath); ST_DOWN_MODEL stModelInfo; ZeroMemory(&stModelInfo, sizeof(ST_DOWN_MODEL)); stModelInfo.nExamID = _pCurrExam_->nExamID; stModelInfo.nSubjectID = _pCurrSub_->nSubjID; sprintf_s(stModelInfo.szUserNo, "%s", _strUserName_.c_str()); sprintf_s(stModelInfo.szModelName, "%s", _pCurrSub_->strModelName.c_str()); Poco::File fileModel(CMyCodeConvert::Gb2312ToUtf8(strModelPath)); if (fileModel.exists()) { std::string strMd5 = calcFileMd5(strModelPath); strncpy(stModelInfo.szMD5, strMd5.c_str(), strMd5.length()); } std::string strLog = "请求下载模板: "; strLog.append(stModelInfo.szModelName); g_pLogger->information(strLog); pTCP_TASK pTcpTask = new TCP_TASK; pTcpTask->usCmd = USER_NEED_DOWN_MODEL; pTcpTask->nPkgLen = sizeof(ST_DOWN_MODEL); memcpy(pTcpTask->szSendBuf, (char*)&stModelInfo, sizeof(ST_DOWN_MODEL)); g_fmTcpTaskLock.lock(); g_lTcpTask.push_back(pTcpTask); g_fmTcpTaskLock.unlock(); g_eDownLoadModel.wait(); if (g_nDownLoadModelStatus == 2) { //模板下载完成 strLog.append(" ==>此模板下载成功."); } else if (g_nDownLoadModelStatus == 3) { strLog.append(" ==>此模板本地以及存在且无修改,不需要重新下载."); } else if (g_nDownLoadModelStatus == -1) { strLog.append(" ==>服务器此科目模板不存在."); } else if (g_nDownLoadModelStatus == -2) { strLog.append(" ==>服务器读取文件失败."); } g_pLogger->information(strLog); }
EMHANDLER GetProcedureAddress(LPCTSTR pszEntryPoint) { USES_CONVERSION ; EMHANDLER pfn = (EMHANDLER)::GetProcAddress(g_AddInInstanceHandle, T2A(pszEntryPoint)); if(NULL != pfn) return pfn; THROW_STD_EXCEPTION(L"Failed to determine the function pointer for Notes") }
void CDialogOption::OnOK() { USES_CONVERSION; if (!UpdateData(TRUE)) { return; } AES aes; CString ak; CString sk; if (m_strAK.Trim().IsEmpty()) { MessageBox(_T("ÇëÊäÈë'AK'¡£")); return; } if (m_strSK.Trim().IsEmpty()) { MessageBox(_T("ÇëÊäÈë'SK'¡£")); return; } if (m_strHost.Trim().IsEmpty()) { MessageBox(_T("ÇëÊäÈë'·þÎñÆ÷µØÖ·'¡£")); return; } lc_bce_access_key_t key = { 0 }; strncpy_s(key.access_key_id, T2A(m_strAK), -1); strncpy_s(key.secret_access_key, T2A(m_strSK), -1); if (m_pParent->DoAuth(&key, m_strHost, FALSE)) { aes.Encrypt(m_strAK, ak); aes.Encrypt(m_strSK, sk); ConfigMgr::Instance().SetAk(ak); ConfigMgr::Instance().SetSk(sk); ConfigMgr::Instance().SetHost(m_strHost); m_pParent->UpdateLiveCaptureData(); EndDialog(IDOK); DestroyWindow(); } }
void DeployDevCabCommand::parseParameters() { USES_CONVERSION; cab_file = m_vecArgv[3]; app_name = m_vecArgv[4]; if (strcmp(T2A(m_vecArgv[5]), "1") == 0) use_shared_runtime = true; }
void CRecvM::OnLvnItemchangedList2(NMHDR *pNMHDR, LRESULT *pResult) { LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR); _RecordsetPtr m_pRecordset; m_listCtr.DeleteAllItems(); m_pRecordset.CreateInstance(__uuidof(Recordset)); USES_CONVERSION; int index = atoi(T2A(showBox.GetItemText(GetCurrentSelectedItemPosition(showBox), 0).GetBuffer())); CString a; a.Format(_T("%d"), index); remarkBox.SetWindowTextW(a); try { memset(sql, 0, sizeof(sql)); strcat_s(sql, "select * from Detailed where ID="); USES_CONVERSION; strcat_s(sql, T2A(a.GetBuffer())); m_pRecordset->Open(sql, m_pConnection.GetInterfacePtr(), adOpenDynamic, adLockOptimistic, adCmdText); } catch(_com_error *e) { CString errormessage; errormessage.Format(_T("操作数据库失败!\r\n错误信息:%s"), e->ErrorMessage()); AfxMessageBox(errormessage); return; } int i = 0; while (!m_pRecordset->adoEOF) { _variant_t var1, var2, var3; var1 = m_pRecordset->GetCollect("ProductName"); var2 = m_pRecordset->GetCollect("ProductNum"); var3 = m_pRecordset->GetCollect("Remark"); m_listCtr.InsertItem(i, var1.bstrVal); m_listCtr.SetItemText(i, 1, var2.bstrVal); m_listCtr.SetItemText(i, 2, var2.bstrVal); i++; m_pRecordset->MoveNext(); } *pResult = 0; }