/* 
 * 函数介绍: 检测BIN文件是否存在
 * 输入参数:
 * 输出参数: 
 * 返 回 值: BIN文件的个数
 */  
BYTE CPageSmartUpdate::detectBinFile(void)
{
    CStringArray strArrayFileNames;
    LPCTSTR file;
    BYTE ID;
    CString name;
    BYTE count = 0;

    //========= AIO-DSP DETECT ==============
    file = AIO_DSP_APP_BIN_NAME;
    CFileIO::GetFileNamesInDir(strArrayFileNames, file);
    if (strArrayFileNames.GetSize() > 0)
    {
        ID = SF_AIO_DSP_UPDATE;
        name = strArrayFileNames.GetAt(0); // 只获取第一个
        strArrayFileNames.RemoveAll();
        m_Target.insert(std::map<BYTE, CString>::value_type(ID, name));
        count++;
    }

    //========= AIO-STM DETECT ==============
    file = AIO_STM_APP_BIN_NAME;
    CFileIO::GetFileNamesInDir(strArrayFileNames, file);
    if (strArrayFileNames.GetSize() > 0)
    {
        ID = SF_AIO_STM_UPDATE;
        name = strArrayFileNames.GetAt(0); // 只获取第一个
        strArrayFileNames.RemoveAll();
        m_Target.insert(std::map<BYTE, CString>::value_type(ID, name));
        count++;
    }

    return count;
}
示例#2
0
void CGnuInfoDoc::GetPage(class CGnuInfoNode *want, CStringArray &p)
{

    if (want == 0 || !open || want->file == 0)
    {
        p.RemoveAll();
        p.Add ("Closed");
    }
    else {
        /* Build a string array in the target space,
           I tried using CString but it was too slow  */
        char buf[200];
        p.RemoveAll();
        want->file->set (want->offset);
        int  c = want->file->gc();
        while (c > 0 && c != 037) {
            int i = 0;
            while (c != '\n' && i < sizeof(buf)-1) {
                buf[i++] = (char)c;
                c = want->file->gc();
            }
            buf[i] = 0;
            c = want->file->gc();
            p.Add (buf);
        }
    }

}
示例#3
0
//--------------------------------------------------------------------------------
bool CSettingsFile::GetLine(int nIndex, CStringArray& sInfo)
	{
	sInfo.RemoveAll();
	if(m_nCurLine == -1 || nIndex < m_nCurLine)
		{
		SeekToBegin();
		m_nCurLine = 0;
		}

	while(ReadLine(sInfo))
		{
		if(sInfo.GetSize() < GetMinSize())
			{
			sInfo.RemoveAll();
			continue;
			}

		if(m_nCurLine == nIndex)
			{
			m_nCurLine++;
			return true;
			}
		
		sInfo.RemoveAll();
		m_nCurLine++;
		}

	return false;
	}
示例#4
0
//读取设置,一般不用调用,在本ARX初化时会调用
bool INISetting::ReadFile()
{
	int i;
	CString sFilePath;
	CStringArray aKey;
	CStringArray aValue;
	PtrStruct *pWillAdd;
	sFilePath=m_sINIFilePath;
	m_aAppNameArray.RemoveAll();
	//	DPrintf("\n ***当前的设置文件是 %s\n",sFilePath);

	//2003.3.6  
	//-------------->>>>何永平 加入求文件长度
	CFileStatus fs;
	if (CFile::GetStatus(sFilePath,fs) == FALSE)
		return false;
	if (m_pBuffer != NULL)
		delete [] m_pBuffer;
	m_pBuffer=new char[int(fs.m_size*1.5)];
	if (m_pBuffer == NULL)
	{
		CString sPrompt;
		sPrompt.Format("ini文件分配内存错!\n[%d]字节",int(fs.m_size*1.2));
		AfxMessageBox(sPrompt);
	}

	//清空全局变量
	//读取所有字段
	if (GetPrivateProfileSectionNames(m_pBuffer,INIBUFFERLENGTH-3,sFilePath) &&
		Get00Strings(m_pBuffer,m_aAppNameArray))
	{
		//清空过去的映射
		ClearMap();      
		//下面读取所有字段
		for (i=0;i<m_aAppNameArray.GetSize();i++)
		{
			aKey.RemoveAll();
			aValue.RemoveAll();
			pWillAdd=new PtrStruct;
			//读入字段,并把KEY 转为大写

			if (ReadIni(m_aAppNameArray[i],pWillAdd->Data,sFilePath))
			{
				CString sKey=m_aAppNameArray[i];
				sKey.MakeUpper();
				pWillAdd->sAppName=sKey;
				//加入到映射 
				m_mapStringToMap.SetAt(sKey,pWillAdd);
				//				DPrintf("\n ***读取 %s       %d个",pWillAdd->sAppName,pWillAdd->Data.GetCount());
			}
			else
			{
				delete pWillAdd;
				//				DPrintf("\n ***读取 %s 的 [%s]失败!\n",sFilePath,m_aAppNameArray[i]);
				;//这个是空句,至于用处嘛 ……
			}
		}
	}
	return !m_mapStringToMap.IsEmpty();
}
// 根据指定的父节点获取其对应的子节点数组
BOOL CLayerTreeDef::GetChildrenAliasName(CStringArray& ChildrenAliasNames, CStringArray& saNeed, const CString FatherAliasName)
{
	ChildrenAliasNames.RemoveAll(); saNeed.RemoveAll();

	CString sFatherId;
	if (GetIdByAliasName(sFatherId, FatherAliasName)==FALSE)  return FALSE;

	CStringArray saOrder;//辅助数组(排序)
	int nCount =  m_LayerTreeArray.GetSize();
	for (int i = 0; i <nCount; i++)
	{
		if (m_LayerTreeArray.GetAt(i).FatherId.CollateNoCase(sFatherId) == 0)  //判断ID是否相等
		{
			//根据排序确定插入位置
			int nOrder1 = atoi(m_LayerTreeArray.GetAt(i).OrderNum);
			int nNum = saOrder.GetSize();
			int nPos = 0;
			for (int j =nNum-1; j >= 0; j--){
				int nOrder2 = atoi(saOrder.GetAt(j));
				if (nOrder1 >= nOrder2)
				{
					nPos = j; break;  //记录插入位置
				}
			}

			//插入数据
			ChildrenAliasNames.InsertAt(nPos, m_LayerTreeArray.GetAt(i).AliasName);
			saNeed.InsertAt(nPos, m_LayerTreeArray.GetAt(i).NeedInf);
			saOrder.InsertAt(nPos, m_LayerTreeArray.GetAt(i).OrderNum);
		}
	}

	return (ChildrenAliasNames.GetSize() > 0);
}
void CItemCommerceSearchView::OnExcelOut(CString filepath, CString filename)
{
	CSpreadSheet sOutFile(filepath, "ListSheet");

	CStringArray readArray;
	CGridCellCheck *pCell;
	BOOL bCheck;

	sOutFile.BeginTransaction();
  // 加入标题
	int iCol = m_cDisplay.GetColumnCount();
	int iRow = m_cDisplay.GetRowCount();
    readArray.RemoveAll();
	int i,j;
	CString str;
    for(i =0; i< iCol;i++)
	{
        str = m_cDisplay.GetItemText(0,i);
		if(str =="")
			str= "0";
	     readArray.Add(str);
	}
	sOutFile.AddHeaders(readArray);

	// 加入数据

	for(i = 1; i < iRow; i++)
	{
		readArray.RemoveAll();
        for(j=0;j<iCol;j++) 
		{
			if(j>=1 && m_iName[j-1].tType == 4)
			{
				 pCell = (CGridCellCheck*)m_cDisplay.GetCell(i,j);
                bCheck = pCell->GetCheck();
				if(bCheck)
					str = "TRUE";
				else
					str = "FALSE";
			}
			else
			{
			   str = m_cDisplay.GetItemText(i,j);
			   if(str=="")
				   str = "/";
			}

			readArray.Add(str);
		}
		sOutFile.AddRow(readArray,i+1);
	}
  
	sOutFile.Commit();	

	AfxMessageBox("查询结果已经保存为文件:\n "+filename);
    
}
示例#7
0
int WINAPI FindDupes(const char* szList, HWND hParent)
{
	AFX_MANAGE_STATE(AfxGetAppModuleState());
	hStopEvent=CreateEvent(0,0,0,0);
	sListOfImages.RemoveAll();
	sListOfImagesToDelete.RemoveAll();
	sListOfImageDibs.RemoveAll();
	CString sFiles=szList;
	sFiles.Replace("\r","");
	sFiles+="\n";
	while(sFiles.GetLength()>0){
		CString sWPTitle=sFiles.SpanExcluding("\n");
		if(strlen(sWPTitle)!=strlen(sFiles)){
			sFiles=sFiles.Mid(strlen(sWPTitle)+1);
		}else{
			sFiles="";
		}
		if(sWPTitle!="" && FindMini(sFiles,sWPTitle+"\n")==-1){
			sListOfImages.Add(sWPTitle);
		}
	}
	if(hCheckThread){
		TerminateThread(hCheckThread,0);
		hCheckThread=0;
	}
	DWORD dwID=0;
	hCheckThread=CreateThread(0,0,CheckImages,0,0,&dwID);
	DialogBox(theApp.m_hInstance,MAKEINTRESOURCE(IDD_DIALOG),hParent,OptionsDialogProc);
	bStopCheck=1;
	csCheck.Lock();
	csCheck.Unlock();
	WaitForSingleObject(hStopEvent,1000);
	CloseHandle(hStopEvent);
	if(hCheckThread){
		TerminateThread(hCheckThread,0);
	}
	CloseHandle(hCheckThread);
	hCheckThread=0;
	hStopEvent=0;
	for(int i=0;i<sListOfImageDibs.GetSize();i++){
		if(sListOfImageDibs[i]){
			delete sListOfImageDibs[i];
		}
	}
	sPathInLeft="";
	sPathInRight="";
	if(btLeft){
		_bmpX()->ReleaseBmp(btLeft);
		btLeft=0;
	}
	if(btRight){
		_bmpX()->ReleaseBmp(btRight);
		btRight=0;
	}
	return lDeletedFiles;
}
示例#8
0
int CDbfFile::AddDBF4(char* psDBFAttList,CString sDelimiter, int nSize)
//used when strings separated by '\0'
{
	DBFHandle	hDBF;

	int			kk;
	CFileFind	ShapeFile;
	CString		sTmp;
	CStringArray	*psDBFAtt;
	psDBFAtt = new CStringArray();

	if (_bInit)
	{
		_bInit = false;
		ValidateDBF();
		DBFSetColumn(&_psDBFAttList);
	}
    // Open/Create the database.						
	hDBF = DBFOpen("r+b" );
	if( hDBF == NULL )
	{
		printf("DBFOpen failed: %s\n", _szDBFName);
		return 1;
	}
	
	int nStrStart = 0;
	for (kk = 0; kk < nSize; kk++)
	{
		psDBFAtt->RemoveAll();
		sTmp = "";
		while(psDBFAttList[nStrStart]!='\0')
		{
			sTmp = sTmp + psDBFAttList[nStrStart++];
		}
		nStrStart++;
		while (sTmp.Find(sDelimiter) != -1)
		{
			psDBFAtt->Add(sTmp.Left(sTmp.Find(sDelimiter)));
			sTmp.Delete(0, (sTmp.Find(sDelimiter) + 1));
		}
		if (!sTmp.IsEmpty())
			psDBFAtt->Add(sTmp);
		DBFAddRecord(hDBF, psDBFAtt);

	}

	psDBFAtt->RemoveAll();

/* -------------------------------------------------------------------- */
/*      Close and cleanup.                                              */
/* -------------------------------------------------------------------- */
	DBFClose( hDBF );
	delete(psDBFAtt);
	return 0;
}
示例#9
0
//----------------------------------------
void CExternalFilesAvisoGrid::SubstituteDimNames(CStringArray& dimNames)
{
  CStringArray replaced;

  dimNames.Replace(CExternalFilesAvisoGrid::m_INTERNAL_LAT_DIM_NAME, m_latDim->GetName(), replaced, true, false);

  CStringArray replacedDims = replaced;
  replaced.RemoveAll();

  replacedDims.Replace(CExternalFilesAvisoGrid::m_INTERNAL_LON_DIM_NAME, m_lonDim->GetName(), replaced, true, false);

  dimNames.RemoveAll();
  dimNames = replaced;
}
BOOL CDialogInvProcess::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	CArray<int,int>	arIds;
	CStringArray	arTickers;

	// Raw Materials
	CSQLInvProcess::Get(1, arIds, arTickers);
	for(int i=0; i<arIds.GetSize(); i++)
	{
		int nInd = m_listRaw.AddString(arTickers[i]);
		m_listRaw.SetItemData(nInd, arIds[i]);
	}

	// WIP
	arIds.RemoveAll();
	arTickers.RemoveAll();
	CSQLInvProcess::Get(2, arIds, arTickers);
	for(int i=0; i<arIds.GetSize(); i++)
	{
		int nInd = m_listWIP.AddString(arTickers[i]);
		m_listWIP.SetItemData(nInd, arIds[i]);
	}

	// QC
	arIds.RemoveAll();
	arTickers.RemoveAll();
	CSQLInvProcess::Get(3, arIds, arTickers);
	for(int i=0; i<arIds.GetSize(); i++)
	{
		int nInd = m_listQC.AddString(arTickers[i]);
		m_listQC.SetItemData(nInd, arIds[i]);
	}

	// Portfolio
	arIds.RemoveAll();
	arTickers.RemoveAll();
	CSQLInvProcess::Get(4, arIds, arTickers);
	for(int i=0; i<arIds.GetSize(); i++)
	{
		int nInd = m_listPort.AddString(arTickers[i]);
		m_listPort.SetItemData(nInd, arIds[i]);
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
示例#11
0
bool CBrowserHelper::GetFixedDrives(CStringArray& saDrives)
{
	saDrives.RemoveAll();

	TCHAR szDriveStrings[256] = _T("");
	DWORD dwDriveStringLength = ::GetLogicalDriveStrings(_countof(szDriveStrings), szDriveStrings);	
	if (dwDriveStringLength == 0 || dwDriveStringLength > _countof(szDriveStrings))
	{
		return false;
	}

	const TCHAR* pszDrive = szDriveStrings;
	while (dwDriveStringLength > 0)
	{
		DWORD dwDriveLength = (DWORD) _tcslen(pszDrive) + 1;

		UINT nDriveType = ::GetDriveType(pszDrive);
		if (nDriveType == DRIVE_FIXED)
		{
			saDrives.Add(pszDrive);
		}

		pszDrive += dwDriveLength;
		dwDriveStringLength -= dwDriveLength;
	}

	return true;
}
示例#12
0
int CRegKey2::GetNames(CStringArray& aNames, BOOL bSubKey) const
{
	ASSERT(m_hKey);

	aNames.RemoveAll();

	DWORD nKey = 0;
	TCHAR szName[1024];
	LONG lResult = ERROR_SUCCESS;

	while (lResult == ERROR_SUCCESS)
	{ 
		// Inside the loop because RegEnumValue will change it
		DWORD nNameLen = 1024;

		if (bSubKey)
			lResult = ::RegEnumKey(m_hKey, nKey, szName, nNameLen);
		else
			lResult = ::RegEnumValue(m_hKey, nKey, szName, &nNameLen, NULL, NULL, NULL, NULL);

		// we have a valid key name
		if (lResult == ERROR_SUCCESS)
			aNames.Add(szName);

		nKey++; // next 
	}

	return aNames.GetSize();
}
示例#13
0
void CACListWnd::SortList(CStringArray& m_List)
{
	int m_Count = (int)m_List.GetSize();
	int i;

	if (m_Count > 1)
	{
		CStringArray m_Liste1;
		m_Liste1.Copy(m_List);

		LPCTSTR* ppSortArray = new LPCTSTR[m_Count+1];


		for(i=0; i < m_Count; i++)
		{
			ppSortArray[i] = (LPCTSTR)m_Liste1.GetAt(i);
		}

		m_List.RemoveAll();

		qsort(ppSortArray, m_Count, sizeof(LPCTSTR), CompareString);

		for(i=0; i < m_Count; i++)
		{
			m_List.Add((LPCTSTR) ppSortArray[i]);
		}
		m_Liste1.RemoveAll();
		delete [] ppSortArray;
	}
}
示例#14
0
void  CDictSetupDlg::GetDictList(CStringArray& list, int& cur) {
	list.RemoveAll();
	cur = 0;
	for (int k = 0; k < RESERVED_DICTS; ++k)
		list.Add(g_res_dicts[k]);
	// fetch dictionaries list
	CString   dlist = CTVApp::GetStr(_T("Dictionary"));
	int	i = 0;
	int	cc = 0;
	while (i < dlist.GetLength() && dlist[i] >= '0' && dlist[i] <= '9') {
		cc = cc * 10 + dlist[i] - '0';
		++i;
	}
	if (i < dlist.GetLength() && dlist[i] == _T('?'))
		++i;
	for (; i < dlist.GetLength();) {
		int	  end = dlist.Find(_T('?'), i);
		if (end < 0)
			end = dlist.GetLength();
		if (dlist[i] == _T('*')) {
			++i;
			if (i >= end)
				continue;
		}
		list.Add(dlist.Mid(i, end - i));
		i = end + 1;
	}
	if (cc >= 0 && cc < list.GetSize())
		cur = cc;
}
示例#15
0
int
ODBCStringsMatrix::CutToSmallStrings(char* szString, CStringArray& arrSmallStrings)
	{
	int nLoop	= 0;
	int	nStart	= 0;
	arrSmallStrings.RemoveAll();

	while( szString[nLoop] != '\0' )
		{
		if( szString[nLoop] == ' ' )
			{
			char	cOld	= szString[nLoop];
			szString[nLoop]	= '\0';
			CString sValue	= (LPCTSTR)&szString[nStart];
			szString[nLoop]	= cOld;

			if( sValue.GetLength() )
				arrSmallStrings.Add(sValue);
			nStart			= nLoop + 1;
			}

		nLoop ++;
		}

	CString sValue	= (LPCTSTR)&szString[nStart];
	sValue.Remove(' ');
	if( sValue.GetLength() )
		arrSmallStrings.Add(sValue);

	return (long)arrSmallStrings.GetCount();
	}
示例#16
0
void CWaveFormDataHandler::vGetAllDefinedSignalsNames(CStringArray& omSignalNames)
{
    omSignalNames.RemoveAll();  // First clear the destination buffer.

	POSITION PosMsg = m_lstTempSignalWaveformInfo.GetHeadPosition();
	while (NULL != PosMsg)
	{
		SSigGeneration& ouCurrMsg = m_lstTempSignalWaveformInfo.GetNext(PosMsg);

		POSITION PosSig = ouCurrMsg.m_omSigWaveMapList.GetHeadPosition();
		while (NULL != PosSig)
		{
			sSigWaveMap& ouCurrSig = ouCurrMsg.m_omSigWaveMapList.GetNext(PosSig);

			CString omWaveformDetails; // Other information accompanies the signal
			
			if(!bIsSignalInMsgFoundInDB(ouCurrMsg.m_nMsgID, ouCurrSig.m_omSigName))
				continue;

			omWaveformDetails.Format(_T("%X ->%s (%s)"), ouCurrMsg.m_nMsgID, 
					ouCurrSig.m_omSigName, 
		    sWaveformInfo::omGetWaveformName(ouCurrSig.sWaveInfo.m_eSignalWaveType));

			omSignalNames.Add(omWaveformDetails); // [out] parameter is updated			
		}
	}
}
示例#17
0
/* Parse MAC concatened into String Array */
UINT CDeviceid::parseMacs( CString &csMac, CStringArray &csMacArray)
{
	UINT uNumber = 0,
		 uIndex = 0;
	CString csOneMac;

	try
	{
		csMacArray.RemoveAll();
		while (csMac.Mid( uIndex, MAC_STRING_LENGTH).GetLength() > 0)
		{
			csOneMac = csMac.Mid( uIndex, MAC_STRING_LENGTH);
			if (csOneMac.GetLength() == MAC_STRING_LENGTH)
			{
				// This a MAC address
				csMacArray.Add( csOneMac);
				uNumber ++;
			}
			uIndex += MAC_STRING_LENGTH;
		}
		return uNumber;
	}
	catch (CException *pEx)
	{
		pEx->Delete();
		return 0;
	}
}
示例#18
0
void CCANMonitorApp::OnChannelDatabaseAssociation(CStringArray* strFilePathArray, CFileDialog* fileDlg, INT iNumberOfActiveChannels)
{
    sg_asDbParams[CAN].m_ppvActiveDB = (void**)&(theApp.m_pouMsgSgInactive);
    sg_asDbParams[CAN].m_ppvImportedDBs = (void**)&(theApp.m_pouMsgSignal);

    CChannelDatabaseAssociationDlg channelDatabaseAssociationDlg(sg_asDbParams[CAN], strFilePathArray, fileDlg, iNumberOfActiveChannels);	// Create Dlg-instance
	
    CStringArray strOldFilePathArray; // copy-funktion
    strOldFilePathArray.RemoveAll();
    strOldFilePathArray.Copy(*strFilePathArray);
    
    if(channelDatabaseAssociationDlg.DoModal() == IDOK)	// Show Dlg
    {
        // Check if dissociation is required
        for(INT i = 0; i < iNumberOfActiveChannels; i++)
        {
            //if( strOldFilePathArray.GetAt(i) == (*strFilePathArray).GetAt(i) )
            //{
            //    // Disscociate current channel    // gelöschte dbs zurückgeben lassen und diese löschen
            //    int j = 0;
            //}
        }
    }
    else // Cancel
    {
        strFilePathArray->RemoveAll();
        strFilePathArray->Copy(strOldFilePathArray);
    }
    // Association itself of new databases is located somewhere else
}
示例#19
0
UINT CAutoComplete::GetMatches(LPCTSTR pszText, CStringArray& arMatches,
							   
							   BOOL bFirstOnly)
							   
{
	
	arMatches.RemoveAll();
	int nMatch = 0;
	CString s=pszText;
	if (s.GetLength()>0)
	{
		OnFirstString();
		CString sMatch;
		while (OnNextString(sMatch))
		{
			if (OnMatchString(s, sMatch))
			{
				TRACE("Add %s\n",(LPCTSTR)sMatch);
				arMatches.Add(sMatch);
				nMatch++;
				if (bFirstOnly)
					break;
			}
		}
	}
	return nMatch;
}
示例#20
0
void AppMenu::CleanUpMenus()
{
    IAcadMenuGroup* mnuGrp = NULL;
    for( int i = 0; i < stcMyTopMenuNames.GetSize(); i++ )
    {
        CString sMenu = stcMyTopMenuNames.GetAt( i );
        sMenu.Replace( _T( "&" ), _T( "" ) );

        if ( !GetAcadMenuGroup( &mnuGrp, sMenu ) )
        {
#ifdef _DEBUG
            acutPrintf( _T( "没有找到 %s 所属的菜单组,无法卸载。 " ), sMenu );
#endif

            //   mnuGrp->Release();
            continue;
        }

        //得到所有菜单组
        IAcadPopupMenus*  mnus = NULL;
        HRESULT hr = S_OK;
        hr = mnuGrp->get_Menus( &mnus );

        ClearMenu( mnus, sMenu );

        mnus->Release();
        mnuGrp->Release();

    }

    stcMyTopMenuNames.RemoveAll();
}
示例#21
0
// 提取所有字符串
int hgzExtractSubStrings1(			// 成功返回提取的子串数,不成功返回 0
	CStringArray& arr,				// 提取到的子串数组
	const CString& cstrFullString,	// 原字符串
	const CString& regexSep )		// 分隔符字符串
{
	//int size = arr.GetSize();
	arr.RemoveAll();
	// first of all, trim the preceding and ending regexSep strings.
	// use CString since it has trim functions.
	if (cstrFullString.GetLength() == 0) return 0;
	CString strSrc(cstrFullString);
	strSrc.TrimLeft(regexSep);
	strSrc.TrimRight(regexSep);
	if (strSrc.GetLength() == 0) return 0;

	// construct the regex object
	// regex_constants::syntax_option_type fl = std::regex_constants::icase; // 设置正则表达式选项 - 忽略大小写 
	tregex e(regexSep, std::regex_constants::icase);	// 定义正则表达式对象

	// m is the search result
	tsmatch m;
	// s is a std string, because regex_search can use only std string as its operands.
	std::tstring s((std::tstring)strSrc.GetString());
	while ( regex_search( s, m,	e ) ) {
		arr.Add(m.prefix().str().c_str());
		s = m.suffix().str();
	}
	arr.Add(s.c_str());

	//return arr.GetSize() - size;
	return arr.GetSize();
}
示例#22
0
文件: RecvM.cpp 项目: cocoljy/Test
// CRecvM 消息处理程序
void CRecvM::InsertDetail(int ID, int i)
{
	_RecordsetPtr m_pRecordset;
	m_pRecordset.CreateInstance(__uuidof(Recordset));

	CString id;
	id.Format(_T("%d"), ID);

	CStringArray ss;
	try {
		USES_CONVERSION;

		ss.RemoveAll();
		ss.Add(contain_box.GetItemText(i, 0));
		ss.Add(contain_box.GetItemText(i, 1));
		ss.Add(contain_box.GetItemText(i, 2));
		memset(sql, 0, sizeof(sql));
		strcat_s(sql, "insert into Detailed (ID, ProductName, ProductNum, Remark) values (");//, ProductName, ProductNum, Remark  , 'a', 'b', 'c'
		strcat_s(sql, T2A(id.GetBuffer()));  strcat_s(sql, ",'");
		strcat_s(sql, T2A(ss[0].GetBuffer()));  strcat_s(sql, "','");
		strcat_s(sql, T2A(ss[1].GetBuffer()));  strcat_s(sql, "','");
		strcat_s(sql, T2A(ss[2].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;
	}
}
示例#23
0
int FileMisc::LoadFileLines(LPCTSTR szPathname, CStringArray& aLines, int nLineCount)
{
	int nLinesRead = 0;
	aLines.RemoveAll();

	CStdioFile file;

	if (file.Open(szPathname, CFile::modeRead | CFile::shareDenyWrite))
	{
		if (file.GetLength())
		{
			if (nLineCount == -1)
			{
				nLineCount = INT_MAX;
			}

			// read lines
			CString sLine;
			while (file.ReadString(sLine) && nLinesRead < nLineCount)
			{
				aLines.Add(sLine);
				nLinesRead++;
			}
		}
	}

	return nLinesRead;
}
示例#24
0
BOOL CIBAOutputBar::CreateCheckOutList()
{
	const DWORD dwViewStyle = LVS_REPORT | LVS_NOSORTHEADER | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;

	if (!m_listCheckOut.Create(dwViewStyle, CRect(1, 1, 1, 1), &m_wndTabs, 6))
	{
		TRACE0("Failed to create Consumeoutput view\n");
		return FALSE;      // fail to create
	}

	CIBAString strHeader;
	strHeader.LoadString(IDS_REFUND_RECORD_HEAD); // _T("结账时间|用户级别|终端号|上机时间|上网账号|姓名|证件号码|金额|备注");

	CStringArray strArray;
	CIBAHelpper::SplitLine(strHeader, strArray);

	const UINT Width[] = {90, 80, 80, 140, 140, 80,140,100,170};

	int nColCount = sizeof(Width)/sizeof(UINT);
	if( nColCount != strArray.GetCount() )
	{
		strHeader = _T("结账时间|用户级别|终端号|上机时间|上网账号|姓名|证件号码|金额|备注");
		strArray.RemoveAll();
		CIBAHelpper::SplitLine(strHeader, strArray);
		nColCount = strArray.GetCount();
	}

	for (INT i = 0; i < nColCount; i++)
	{
		m_listCheckOut.InsertColumn(i, strArray.GetAt(i), LVCFMT_LEFT, Width[i]);
	}

	return TRUE;
}
示例#25
0
int CIpAddressesDlg::GetIPs( CStringArray &arrIPS )
{
    BOOL bRet = TRUE;
    char name[255];
    int i=0;
    PHOSTENT hostinfo;

  //first, clear the list
    arrIPS.RemoveAll();

  //get the host name
  if( gethostname ( name, sizeof(name)) == 0)
  {
    // get the host info
    if((hostinfo = gethostbyname(name)) != NULL)
    {
      // now, loop until the address list = null
      while( hostinfo->h_addr_list[i] != NULL )
      {
        //get the IP address
        char *ip_addr = inet_ntoa (*(struct in_addr *)
                        hostinfo->h_addr_list[i]);
        //add it to the array
        arrIPS.Add(CString(ip_addr)); 
        //increment the counter
        i++;
      }
    }
  }
  //return the array count
  return int(arrIPS.GetSize());
}
示例#26
0
// CComSetDlg 消息处理程序
INT_PTR		CComSetDlg::GetSerialPort(CStringArray &arrCom)
{
	arrCom.RemoveAll();
	HKEY	hkey;
	LONG32	lRes = RegOpenKeyEx(
		HKEY_LOCAL_MACHINE,_T("HARDWARE\\DEVICEMAP\\SERIALCOMM"),
		NULL,KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS|KEY_READ,&hkey);
	if (lRes == ERROR_SUCCESS)
	{
		TCHAR	tchKey[MAX_PATH];
		TCHAR	tchValue[20];
		DWORD	dwIndex = 0;
		DWORD	dwType = REG_SZ;
		while(lRes == ERROR_SUCCESS)
		{
			DWORD	dwCnt = MAX_PATH;
			DWORD	dwVCount = 20;
			lRes = RegEnumValue(hkey,dwIndex++,tchKey,&dwCnt,NULL,
				&dwType,(LPBYTE)tchValue,&dwVCount);
			if (lRes == ERROR_SUCCESS)
			{
				if(dwVCount >0 && dwCnt >0)
					arrCom.Add(tchValue);
			}
		}
	}
	RegCloseKey(hkey);
	return arrCom.GetSize();
}
void CXTPSyntaxEditLexCfgFileReader::ReadSource2(const CString& csFileName, CStringArray& arBuffer)
{
	try
	{
		arBuffer.RemoveAll();

		CStdioFile file;
		if (AfxOpenFile(file, csFileName, CFile::modeRead))
		{
			arBuffer.Add(_T(""));

			CString csBuffer;
			while(file.ReadString(csBuffer))
			{
				int nLen = csBuffer.GetLength();
				if (nLen && csBuffer[nLen - 1] == _T('\r'))
					csBuffer.Delete(nLen - 1);
				arBuffer.Add(csBuffer);
			}
		}
	}
	catch(CFileException* expFile)
	{
	#ifdef _DEBUG
		ProcessFileException(expFile);
	#endif
		expFile->Delete();
	}
}
示例#28
0
BOOL COXProcess::GetCurrentProcessEnvironment(CStringArray& arrEnvironmentString)
{

	arrEnvironmentString.RemoveAll();

	// Get a pointer to the environment block. 
	LPVOID lpvEnv=::GetEnvironmentStrings(); 
	if(lpvEnv==NULL)
	{
		TRACE(_T("COXProcess::GetCurrentProcessEnvironment: GetEnvironmentStrings() returned NULL pointer to environment block\n"));
		return FALSE;
	}
 
	// Variable strings are separated by NULL byte, and the block is 
	// terminated by a NULL byte. 
	CString sEnvironmentString;
	LPTSTR lpszVariable=(LPTSTR)lpvEnv;
	for(;;) 
	{ 
		sEnvironmentString=lpszVariable;
		if(sEnvironmentString.IsEmpty())
			break;
		else
		{
			arrEnvironmentString.Add(sEnvironmentString);
			lpszVariable+=(sEnvironmentString.GetLength()+1)*sizeof(TCHAR);
		}
	}
	
	::FreeEnvironmentStrings((LPTSTR)lpvEnv);

	return TRUE;
}
void CBCGPPlannerPrintMonth::GetCaptionFormatStrings (CStringArray& sa)
{
	sa.RemoveAll ();

	sa.Add (_T("dddd"));
	sa.Add (_T("ddd"));
}
示例#30
0
void ReadTokenList(CStringArray& stringArray, const CString& registryName)
{
	CString tokenStr = AfxGetApp()->GetProfileString("Config", registryName, "");
	stringArray.RemoveAll();
	if (tokenStr.IsEmpty())
	{
		return;
	}

	int curPos = 0;
	int nextPos;
	while (true)
	{
		// See if there is a comma.
		nextPos = tokenStr.Find('|', curPos);
		if (nextPos == -1)
			break;

		CString token = tokenStr.Mid(curPos, nextPos - curPos);
		curPos = nextPos + 1;
		stringArray.Add(token);
	}

	CString token = tokenStr.Mid(curPos);
	if (!token.IsEmpty())
		stringArray.Add(token);
}