本文整理汇总了C++中CArray::RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C++ CArray::RemoveAt方法的具体用法?C++ CArray::RemoveAt怎么用?C++ CArray::RemoveAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArray
的用法示例。
在下文中一共展示了CArray::RemoveAt方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnRemoveUI
void CUIDesignerView::OnRemoveUI()
{
CArray<CControlUI*,CControlUI*> arrSelected;
m_MultiTracker.GetSelected(arrSelected);
//remove form
for (int i=0; i<arrSelected.GetSize(); i++)
{
CControlUI* pControl = arrSelected[i];
if(pControl == m_LayoutManager.GetForm())
{
arrSelected.RemoveAt(i);
break;;
}
}
m_UICommandHistory.Begin(arrSelected, actionDelete);
for(int i=0; i<arrSelected.GetSize(); i++)
{
CControlUI* pControl = arrSelected[i];
CControlUI* pParent=pControl->GetParent();
HTREEITEM hDelete=(HTREEITEM)(((ExtendedAttributes*)pControl->GetTag())->hItem);
g_pClassView->RemoveUITreeItem(hDelete);
RemoveUI(pControl);
if(pParent)
pParent->NeedUpdate();
}
m_UICommandHistory.End();
g_pPropertiesWnd->HideAllProperties(TRUE,TRUE);
m_MultiTracker.RemoveAll();
}
示例2: OnDbTogglebreakpoint
void CDebuggerView::OnDbTogglebreakpoint()
{
int pos = m_editor.SendEditor(SCI_GETCURRENTPOS);
int lineNumber = m_editor.SendEditor(SCI_LINEFROMPOSITION, pos);
// Is there a breakpoint currently here?
int breakpointIndex = FindBreakpoint(m_currentFileName, lineNumber);
if (breakpointIndex == -1)
{
// No, add it.
m_editor.SendEditor(SCI_MARKERDEFINE, MARKER_BREAKPOINT, SC_MARK_CIRCLE);
m_editor.SendEditor(SCI_MARKERSETFORE, MARKER_BREAKPOINT, RGB(0x00, 0x00, 0));
m_editor.SendEditor(SCI_MARKERSETBACK, MARKER_BREAKPOINT, RGB(0xff, 0x00, 0x00));
m_editor.SendEditor(SCI_MARKERADD, lineNumber, MARKER_BREAKPOINT);
// Add the breakpoint.
BreakpointInfo info;
info.m_fileName = m_currentFileName;
info.m_lineNumber = lineNumber;
m_breakpointInfo.Add(info);
}
else
{
// Remove the breakpoint.
m_editor.SendEditor(SCI_MARKERDELETE, lineNumber, MARKER_BREAKPOINT);
m_breakpointInfo.RemoveAt(breakpointIndex);
}
CString command;
command.Format(_T("DebugSetBreakpoint('%s',%d,%s)"), m_currentFileName, lineNumber,
(breakpointIndex == -1) ? _T("true") : _T("false"));
theApp.GetNetworkClient().SendCommand(command);
}
示例3: RemoveForm
void CUIDesignerView::RemoveForm(CArray<CControlUI*,CControlUI*>& arrSelected)
{
for (int i=0; i<arrSelected.GetSize(); i++)
{
CControlUI* pControl = arrSelected[i];
if(pControl == m_LayoutManager.GetForm())
{
arrSelected.RemoveAt(i);
break;
}
}
}
示例4: main
void main()
{
CArray arr;
arr.Add(1234);
arr.Add(23);
arr.Add(44);
arr.Add(21);
arr.Add(5);
arr.RemoveAt(2,20000000); //从第二个位置起,删除2个数据
arr.InsertAt(3,10,2);
int i = 0;
int nSize = arr.GetSize();
cout << "共有 " << nSize << " 条数据" << endl;
TYPE *p = arr.GetData();
qsort(p,nSize,sizeof(TYPE),compar);
while(i < nSize)
{
cout << arr[i] << endl;
++i;
}
}
示例5: GetRecentProfiles
HRESULT ProfileUtils::GetRecentProfiles(CArray<RegistryProfileInfo *, RegistryProfileInfo *> &arRecentProfiles) {
HRESULT hr = S_OK;
arRecentProfiles.RemoveAll();
_TCHAR tszActiveProfile[MAX_PATH];
unsigned long lLength = MAX_PATH;
DWORD dwEntriesCount = 0;
bool bSuccess = LRegistry::EnumRegistryValues(HKEY_CURRENT_USER,
_T("Software\\imc AG\\LECTURNITY\\Publisher\\Profiles\\Recent\\List"),
NULL, &dwEntriesCount, false);
if (!bSuccess)
hr = E_FAIL;
LRegistry::ENTRY **paEntries = NULL;
if (SUCCEEDED(hr)) {
paEntries = new LRegistry::ENTRY*[dwEntriesCount+1];
for (int i = 0; i < dwEntriesCount; ++i)
paEntries[i] = new LRegistry::ENTRY();
}
if (SUCCEEDED(hr)) {
bSuccess = LRegistry::EnumRegistryValues(HKEY_CURRENT_USER,
_T("Software\\imc AG\\LECTURNITY\\Publisher\\Profiles\\Recent\\List"),
paEntries, &dwEntriesCount, false);
if (!bSuccess)
hr = E_FAIL;
}
if (SUCCEEDED(hr)) {
for (int i = 0; i < dwEntriesCount; ++i) {
CString csName = paEntries[i]->lsName;
bool bSuccess = LRegistry::ReadStringRegistryEntry(HKEY_CURRENT_USER,
_T("Software\\imc AG\\LECTURNITY\\Publisher\\Profiles\\Recent\\List"),
csName, tszActiveProfile, &lLength);
if (bSuccess && lLength > 0) {
RegistryProfileInfo *pNewProfileInfo = new RegistryProfileInfo(csName, tszActiveProfile);
arRecentProfiles.Add(pNewProfileInfo);
int k = 0;
}
}
}
if (paEntries != NULL) {
for (int i = 0; i < dwEntriesCount; ++i)
delete paEntries[i];
delete[] paEntries;
}
if (SUCCEEDED(hr)) {
// check recent profiles (existance)
CArray<ProfileInfo *, ProfileInfo *> aProfileInformation;
hr = ReadCustomProfiles(aProfileInformation);
CArray<int, int> arPositionsToDelete;
// Remove all custom profiles which are no longer existing
arPositionsToDelete.RemoveAll();
for (int i = 0; i < arRecentProfiles.GetCount(); ++i) {
if (arRecentProfiles[i]->GetProfileType() == PublishingFormat::TYPE_CUSTOM) {
bool bFound = false;
for (int j = 0; j < aProfileInformation.GetCount() && !bFound; ++j) {
if (arRecentProfiles[i]->GetCustomProfileID() == aProfileInformation[j]->GetID())
bFound = true;
}
if (!bFound)
arPositionsToDelete.Add(i);
}
}
for (int i = arPositionsToDelete.GetCount()-1; i >= 0; --i) {
if (arRecentProfiles[arPositionsToDelete[i]] != NULL)
delete arRecentProfiles[arPositionsToDelete[i]];
arRecentProfiles.RemoveAt(arPositionsToDelete[i]);
}
// Remove old custom profile if there are more than five
bool bFinished = false;
while (!bFinished) {
int iCustomProfileCount = 0;
CTime *pOldest = NULL;
int iOldestPos = -1;
for (int i = 0; i < arRecentProfiles.GetCount(); ++i) {
if (arRecentProfiles[i]->GetProfileType() == PublishingFormat::TYPE_CUSTOM) {
CTime *pElementTime = arRecentProfiles[i]->GetLastActivatedTime();
if (pOldest == NULL ||
(pElementTime != NULL && *pElementTime < *pOldest)) {
pOldest = pElementTime;
iOldestPos = i;
}
++iCustomProfileCount;
}
}
if (iCustomProfileCount <= 5 || iOldestPos < 0)
bFinished = true;
//.........这里部分代码省略.........
示例6: DeleteColumn
void CItemData::DeleteColumn(int nColumn)
{
aTextColors.RemoveAt(nColumn);
aBkColors.RemoveAt(nColumn);
}
示例7: RemoveResourceFromStorage
// Diese Funktion entfernt die benötigten Ressourcen aus dem lokalen Lager des Systems und falls Ressourcenrouten
// bestehen auch die Ressourcen in den Startsystemen der Route. Aber nur falls dies auch notwendig sein sollte.
void CAssemblyList::RemoveResourceFromStorage(BYTE res, const CPoint &ko, std::vector<CSystem>& systems, CArray<CPoint>* routesFrom)
{
if (ko == CPoint(-1,-1))
return;
CSystem *system = &systems.at(ko.x+(ko.y)*STARMAP_SECTORS_HCOUNT);
// für Deritium gibt es keine Ressourcenroute
if (res != DERITIUM)
{
// zuerst wird immer versucht, die Ressourcen aus dem lokalen Lager zu nehmen
long remainingRes = GetNeededResourceInAssemblyList(0, res) - system->GetResourceStore(res);
// werden zusätzliche Ressourcen aus anderen Lagern benötigt, so kann das lokale Lager
// auf NULL gesetzt werden
if (remainingRes > 0)
{
*system->GetResourceStorages(res) = NULL;
// zusätzliche Ressourcen müssen aus den Lagern der Systeme mit den Ressourcenrouten
// bezogen werden. Dafür ein Feld anlegen, indem alle Startsysteme mit der zur Ressouce passenden
// Ressourcenroute beinhaltet sind.
struct ROUTELIST {
CResourceRoute *route;
CPoint fromSystem;
ROUTELIST() : route(0), fromSystem(0) {}
ROUTELIST(CResourceRoute *_route, CPoint _fromSystem) : route(_route), fromSystem(_fromSystem) {}
};
CArray<ROUTELIST> routes;
for (int j = 0; j < routesFrom->GetSize(); j++)
{
CPoint p = routesFrom->GetAt(j);
for (int k = 0; k < systems.at(p.x+(p.y)*STARMAP_SECTORS_HCOUNT).GetResourceRoutes()->GetSize(); k++)
{
// Stimmt die Ressource überein=
if (systems.at(p.x+(p.y)*STARMAP_SECTORS_HCOUNT).GetResourceRoutes()->GetAt(k).GetResource() == res)
{
// Stimmt das Zielsystem mit unserem überein?
if (systems.at(p.x+(p.y)*STARMAP_SECTORS_HCOUNT).GetResourceRoutes()->GetAt(k).GetKO() == ko)
{
// prüfen das die Route nicht schon verwendet wird
bool bUsed = false;
for (int l = 0; l < routes.GetSize(); l++)
if (routes.GetAt(l).fromSystem == p)
{
bUsed = true;
break;
}
if (!bUsed)
routes.Add(ROUTELIST(&systems.at(p.x+(p.y)*STARMAP_SECTORS_HCOUNT).GetResourceRoutes()->GetAt(k), p));
}
}
}
}
// in routes sind nun die Zeiger auf die richtigen Ressourcenrouten, also die Routen, welche auch den
// passenden Rohstoff liefern könnten.
while (routes.GetSize())
{
// zufällig eine Route aus den möglichen auswählen, damit nicht immer das gleiche System zuerst
// die Rohstoffe liefern muss, falls mehrere Routen der selben Art ins System eingehen.
int random = rand()%routes.GetSize();
int percent = 0;
CPoint start = routes.GetAt(random).fromSystem;
// sind im jeweiligen Lager des Startsystem genügend Rohstoffe vorhanden
if (systems.at(start.x+(start.y)*STARMAP_SECTORS_HCOUNT).GetResourceStore(res) >= (ULONG)remainingRes)
{
*systems.at(start.x+(start.y)*STARMAP_SECTORS_HCOUNT).GetResourceStorages(res) -= remainingRes;
if (GetNeededResourceInAssemblyList(0, res) > NULL)
percent = 100 * remainingRes / GetNeededResourceInAssemblyList(0, res);
CResourceRoute* pResRoute = routes.GetAt(random).route;
pResRoute->SetPercent((BYTE)percent);
remainingRes = 0;
}
else
{
remainingRes -= systems.at(start.x+(start.y)*STARMAP_SECTORS_HCOUNT).GetResourceStore(res);
if (GetNeededResourceInAssemblyList(0, res) > NULL)
percent = 100 * systems.at(start.x+(start.y)*STARMAP_SECTORS_HCOUNT).GetResourceStore(res) / GetNeededResourceInAssemblyList(0, res);
CResourceRoute* pResRoute = routes.GetAt(random).route;
pResRoute->SetPercent((BYTE)percent);
*systems.at(start.x+(start.y)*STARMAP_SECTORS_HCOUNT).GetResourceStorages(res) = NULL;
}
// ROUTELIST Eintrag entfernen, wenn dieser abgearbeitet wurde
routes.RemoveAt(random);
// werden keine Ressourcen mehr benötigt, so kann abgebrochen werden
if (remainingRes == 0)
{
routes.RemoveAll();
break;
}
}
ASSERT(remainingRes == 0);
}
// anderenfalls werden nur die benötigten Ressourcen aus dem lokalen Lager abgezogen
else
*system->GetResourceStorages(res) -= GetNeededResourceInAssemblyList(0, res);
}
else
//.........这里部分代码省略.........
示例8: addProToArr
void DLrtfhtml::addProToArr(CStringArray &arr,CArray<rtfProperty,rtfProperty&> &proArr)
{
CString temp;
CString protemp;
int count=arr.GetCount();
int j=0;
rtfProperty pro;//property struct
for(int i=0;i<arr.GetCount();i++)
{
temp=arr.GetAt(i);
memset(&pro,0,sizeof(rtfProperty));
if(temp.Compare(_T("\\b"))==0)
{
if(proIsExist(temp,proArr)==-1)
{
pro.data=0;
lstrcpy(pro.rtfType,temp.GetBuffer());
temp.ReleaseBuffer();
lstrcpy(pro.htmlTagB,_T("<b>"));
lstrcpy(pro.htmlTagE,_T("</b>"));
proArr.Add(pro);
}
}
else if(temp.Compare(_T("\\b0"))==0)
{
int id=proIsExist(temp,proArr);
if(id!=-1)
proArr.RemoveAt(id);
}
else if(temp.Compare(_T("\\i"))==0)
{
if(proIsExist(temp,proArr)==-1)
{
pro.data=0;
lstrcpy(pro.rtfType,temp.GetBuffer());
temp.ReleaseBuffer();
lstrcpy(pro.htmlTagB,_T("<i>"));
lstrcpy(pro.htmlTagE,_T("</i>"));
proArr.Add(pro);
}
}
else if(temp.Compare(_T("\\i0"))==0)
{
int id=proIsExist(temp,proArr);
if(id!=-1)
proArr.RemoveAt(id);
}
else if(temp.Compare(_T("\\ul"))==0)
{
if(proIsExist(temp,proArr)==-1)
{
pro.data=0;
lstrcpy(pro.rtfType,temp.GetBuffer());
temp.ReleaseBuffer();
lstrcpy(pro.htmlTagB,_T("<u>"));
lstrcpy(pro.htmlTagE,_T("</u>"));
proArr.Add(pro);
}
}
else if(temp.Compare(_T("\\ulnono"))==0)
{
int id=proIsExist(temp,proArr);
if(id!=-1)
proArr.RemoveAt(id);
}
else if(temp.Compare(_T("\\strike"))==0)
{
if(proIsExist(temp,proArr)==-1)
{
pro.data=0;
lstrcpy(pro.rtfType,temp.GetBuffer());
temp.ReleaseBuffer();
lstrcpy(pro.htmlTagB,_T("<strike>"));
lstrcpy(pro.htmlTagE,_T("</strike>"));
proArr.Add(pro);
}
}
else if(temp.Compare(_T("\\strike0"))==0)
{
int id=proIsExist(temp,proArr);
if(id!=-1);
proArr.RemoveAt(id);
}
else if(temp.Find(_T("\\fs"))>=0)
{
int num=strGetNumber(temp);
if(num<=0)
num=24;
int id=proIsExist(_T("\\fs"),proArr);
if(id==-1)
{
pro.data=num;
lstrcpy(pro.rtfType,_T("\\fs"));
//temp.ReleaseBuffer();
protemp.Format(_T("font-size:%d;"),num);
lstrcpy(pro.htmlTagB,protemp.GetBuffer());
protemp.ReleaseBuffer();
pro.single=TRUE;
proArr.Add(pro);
//.........这里部分代码省略.........
示例9: AdminHandler
//.........这里部分代码省略.........
if (!strcmp(variable, "listpos")) {
playlistpos = atoi(value);
}
}
token = strtok(NULL, "&");
}
}
int passok = 0;
if (strlen(g_AdminPassword) > 0) {
if (!strcmp(suppliedPass, g_AdminPassword)) {
*adminFlag = 1;
passok = 1;
}
else {
*adminFlag = 0;
passok = 0;
}
}
if (passok) {
int winampCommand = 0;
switch (action) {
case 2: PlayWinamp();
winampCommand = 1;
break;
case 3: PrevWinamp();
winampCommand = 1;
break;
case 4: PauseWinamp();
winampCommand = 1;
break;
case 5: StopWinamp();
winampCommand = 1;
break;
case 6: NextWinamp();
winampCommand = 1;
break;
case 7: repopulatePlaylistCache();
winampCommand = 1;
break;
}
if (winampCommand) {
char buf[255] = "";
_snprintf(buf, sizeof(buf)-1, "Location: /admin.cgi?pass=%s", g_AdminPassword);
send_headers(302, "Moved Temporarily", (char*) buf, 0, -1, -1 );
}
}
// }
// if (sscanf(request, "/admin.cgi?pass=%s&action=delete&listpos=%d", suppliedPass, &playlistpos) == 2) {
if (action == 1) {
if (strlen(g_AdminPassword) > 0) {
if (!strcmp(suppliedPass, g_AdminPassword)) {
*adminFlag = 1;
if (playlistpos-1 <= RequestQueue.GetUpperBound()) {
RequestQueue.RemoveAt(RequestQueue.GetUpperBound() - playlistpos + 1);
errorCode = DELETE_ACCEPTED;
}
else {
errorCode = ERR_POSITION_OUT_OF_RANGE;
}
}
else {
*adminFlag = 0;
errorCode = ERR_BAD_PASSWORD;
}
}
char location[1024] = "";
if (strlen(m_Referrer) > 0) {
if (errorCode == 0) {
_snprintf(location, sizeof(location)-1, "Location: %s", m_Referrer);
}
else {
_snprintf(location, sizeof(location)-1, "Location: %s&errorCode=%d", m_Referrer, errorCode);
}
}
else {
if (errorCode == 0) {
_snprintf(location, sizeof(location)-1, "Location: /playlist.cgi");
}
else {
_snprintf(location, sizeof(location)-1, "Location: /playlist.cgi?errorCode=%d", errorCode);
}
}
send_headers(302, "Moved Temporarily", (char*) location, 0, -1, -1 );
}
if (strlen(g_AdminPassword) > 0) {
if (!strcmp(suppliedPass, g_AdminPassword)) {
*adminFlag = 1;
}
else {
*adminFlag = 0;
}
}
return;
// if (sscanf(request, "/admin.cgi?pass=%s&errorCode=%d", suppliedPass, &errorCode) == 2) {
}
示例10: FunnyOnWritePoly
//.........这里部分代码省略.........
for(j=0;j<pbclst.GetSize();j++)
{
if (pbclst[j].BdryName==arclist[i].BoundaryMarker)
{
// A pbc or apbc can only be applied to 2 arcs
// at a time. If it is applied to multiple arcs
// at the same time, flag it and kick it out.
if (pbclst[j].narc==2)
{
MsgBox("An (anti)periodic BC is assigned to more than two arcs");
Undo(); UnselectAll();
return FALSE;
}
pbclst[j].seg[pbclst[j].narc]=i;
pbclst[j].narc++;
}
}
}
j=0;
while(j<pbclst.GetSize())
{
// check for a bc that is a mix of arcs and segments.
// this is an error, and it should get flagged.
if ((pbclst[j].nseg>0) && (pbclst[j].narc>0))
{
MsgBox("Can't mix arcs and segments for (anti)periodic BCs");
Undo(); UnselectAll();
return FALSE;
}
// remove any periodic BC's that aren't actually in play
if((pbclst[j].nseg<2) && (pbclst[j].narc<2)) pbclst.RemoveAt(j);
else j++;
}
for(j=0;j<pbclst.GetSize();j++)
{
// check to see if adjoining entries are applied
// to objects of compatible size/shape, and
// reconcile meshing on the objects.
// for segments:
if(pbclst[j].nseg>0){
// make sure that lines are pretty much the same length
if(fabs(LineLength(pbclst[j].seg[0])
-LineLength(pbclst[j].seg[1]))>1.e-06)
{
MsgBox("(anti)periodic BCs applied to dissimilar segments");
Undo(); UnselectAll();
return FALSE;
}
// make sure that both lines have the same spacing
double len1,len2,len;
len1=linelist[pbclst[j].seg[0]].MaxSideLength;
len2=linelist[pbclst[j].seg[1]].MaxSideLength;
if(len1<=0) len1=len2;
if(len2<=0) len2=len1;
len=min(len1,len2);
linelist[pbclst[j].seg[0]].MaxSideLength=len;
linelist[pbclst[j].seg[1]].MaxSideLength=len;
示例11: CorruptedData
void CCorruptionBlackBox::CorruptedData(uint32 nStartPos, uint32 nEndPos){
if (nEndPos - nStartPos >= EMBLOCKSIZE){
ASSERT( false );
return;
}
// convert pos to relative block pos
uint16 nPart = nStartPos / PARTSIZE;
uint32 nRelStartPos = nStartPos - nPart*PARTSIZE;
uint32 nRelEndPos = nEndPos - nPart*PARTSIZE;
if (nRelEndPos >= PARTSIZE){
ASSERT( false );
return;
}
if (nPart >= m_aaRecords.GetCount()){
//ASSERT( false );
m_aaRecords.SetSize(nPart+1);
}
uint32 nDbgVerifiedBytes = 0;
CArray<uint32, uint32> aGuiltyClients;
for (int i= 0; i < m_aaRecords[nPart].GetCount(); i++){
if (m_aaRecords[nPart][i].m_BBRStatus == BBR_NONE){
if (m_aaRecords[nPart][i].m_nStartPos >= nRelStartPos && m_aaRecords[nPart][i].m_nEndPos <= nRelEndPos){
nDbgVerifiedBytes += (m_aaRecords[nPart][i].m_nEndPos-m_aaRecords[nPart][i].m_nStartPos)+1;
m_aaRecords[nPart][i].m_BBRStatus = BBR_CORRUPTED;
aGuiltyClients.Add(m_aaRecords[nPart][i].m_dwIP);
}
else if (m_aaRecords[nPart][i].m_nStartPos < nRelStartPos && m_aaRecords[nPart][i].m_nEndPos > nRelEndPos){
// need to split it 2*
uint32 nTmpEndPos1 = m_aaRecords[nPart][i].m_nEndPos;
uint32 nTmpStartPos1 = nRelEndPos + 1;
uint32 nTmpStartPos2 = m_aaRecords[nPart][i].m_nStartPos;
uint32 nTmpEndPos2 = nRelStartPos - 1;
m_aaRecords[nPart][i].m_nEndPos = nRelEndPos;
m_aaRecords[nPart][i].m_nStartPos = nRelStartPos;
m_aaRecords[nPart].Add(CCBBRecord(nTmpStartPos1, nTmpEndPos1, m_aaRecords[nPart][i].m_dwIP, m_aaRecords[nPart][i].m_BBRStatus));
m_aaRecords[nPart].Add(CCBBRecord(nTmpStartPos2, nTmpEndPos2, m_aaRecords[nPart][i].m_dwIP, m_aaRecords[nPart][i].m_BBRStatus));
nDbgVerifiedBytes += (m_aaRecords[nPart][i].m_nEndPos-m_aaRecords[nPart][i].m_nStartPos)+1;
m_aaRecords[nPart][i].m_BBRStatus = BBR_CORRUPTED;
aGuiltyClients.Add(m_aaRecords[nPart][i].m_dwIP);
}
else if (m_aaRecords[nPart][i].m_nStartPos >= nRelStartPos && m_aaRecords[nPart][i].m_nStartPos <= nRelEndPos){
// need to split it
uint32 nTmpEndPos = m_aaRecords[nPart][i].m_nEndPos;
uint32 nTmpStartPos = nRelEndPos + 1;
m_aaRecords[nPart][i].m_nEndPos = nRelEndPos;
m_aaRecords[nPart].Add(CCBBRecord(nTmpStartPos, nTmpEndPos, m_aaRecords[nPart][i].m_dwIP, m_aaRecords[nPart][i].m_BBRStatus));
nDbgVerifiedBytes += (m_aaRecords[nPart][i].m_nEndPos-m_aaRecords[nPart][i].m_nStartPos)+1;
m_aaRecords[nPart][i].m_BBRStatus = BBR_CORRUPTED;
aGuiltyClients.Add(m_aaRecords[nPart][i].m_dwIP);
}
else if (m_aaRecords[nPart][i].m_nEndPos >= nRelStartPos && m_aaRecords[nPart][i].m_nEndPos <= nRelEndPos){
// need to split it
uint32 nTmpStartPos = m_aaRecords[nPart][i].m_nStartPos;
uint32 nTmpEndPos = nRelStartPos - 1;
m_aaRecords[nPart][i].m_nStartPos = nRelStartPos;
m_aaRecords[nPart].Add(CCBBRecord(nTmpStartPos, nTmpEndPos, m_aaRecords[nPart][i].m_dwIP, m_aaRecords[nPart][i].m_BBRStatus));
nDbgVerifiedBytes += (m_aaRecords[nPart][i].m_nEndPos-m_aaRecords[nPart][i].m_nStartPos)+1;
m_aaRecords[nPart][i].m_BBRStatus = BBR_CORRUPTED;
aGuiltyClients.Add(m_aaRecords[nPart][i].m_dwIP);
}
}
}
// check if any IPs are already banned, so we can skip the test for those
for(int k = 0; k < aGuiltyClients.GetCount();){
// remove doubles
for(int y = k+1; y < aGuiltyClients.GetCount();){
if (aGuiltyClients[k] == aGuiltyClients[y])
aGuiltyClients.RemoveAt(y);
else
y++;
}
if (theApp.clientlist->IsBannedClient(aGuiltyClients[k])){
AddDebugLogLine(DLP_DEFAULT, false, _T("CorruptionBlackBox: Suspicous IP (%s) is already banned, skipping recheck"), ipstr(aGuiltyClients[k]));
aGuiltyClients.RemoveAt(k);
}
else
k++;
}
AddDebugLogLine(DLP_HIGH, false, _T("Found and marked %u recorded bytes of %u as corrupted in the CorruptionBlackBox records, %u clients involved"), nDbgVerifiedBytes, (nEndPos-nStartPos)+1, aGuiltyClients.GetCount());
if (aGuiltyClients.GetCount() > 0){
// parse all recorded data for this file to produce a statistic for the involved clients
// first init arrays for the statistic
CArray<uint32, uint32> aDataCorrupt;
CArray<uint32, uint32> aDataVerified;
aDataCorrupt.SetSize(aGuiltyClients.GetCount());
aDataVerified.SetSize(aGuiltyClients.GetCount());
for (int j = 0; j < aGuiltyClients.GetCount(); j++)
aDataCorrupt[j] = aDataVerified[j] = 0;
// now the parsing
for (int nPart = 0; nPart < m_aaRecords.GetCount(); nPart++){
for (int i = 0; i < m_aaRecords[nPart].GetCount(); i++){
for(int k = 0; k < aGuiltyClients.GetCount(); k++){
if (m_aaRecords[nPart][i].m_dwIP == aGuiltyClients[k]){
if (m_aaRecords[nPart][i].m_BBRStatus == BBR_CORRUPTED){
// corrupted data records are always counted as at least blocksize or bigger
aDataCorrupt[k] += max((m_aaRecords[nPart][i].m_nEndPos-m_aaRecords[nPart][i].m_nStartPos)+1, EMBLOCKSIZE);
}
else if(m_aaRecords[nPart][i].m_BBRStatus == BBR_VERIFIED){
//.........这里部分代码省略.........
示例12: QueryRegister
//.........这里部分代码省略.........
if (Rs.Open(strSQL))
{
INT i = 0;
while (!Rs.IsEof())
{
INT nTmp = 0;
CString strTmp;
CCardOpenInfo CardOpenInfo;
Rs.GetFieldValue(_T("serialNum"), strTmp);
CardOpenInfo.SetSerialNum(strTmp);
Rs.GetFieldValue(_T("name"), strTmp);
CardOpenInfo.SetUserName(strTmp);
Rs.GetFieldValue(_T("idNumber"), strTmp);
CardOpenInfo.SetIdNumber(strTmp);
Rs.GetFieldValue(_T("memberId"), nTmp);
CardOpenInfo.SetMemberId(nTmp);
Rs.GetFieldValue(_T("operationDateTime"), strTmp);
CardOpenInfo.SetOperationDateTime(strTmp);
Rs.GetFieldValue(_T("operator"), strTmp);
CardOpenInfo.SetOperator(strTmp);
i++;
CardOpenDBArray.Add(CardOpenInfo);
Rs.MoveNext();
}
Rs.Close();
}
pDb->Release();
for (INT ii = 0; ii < CardOpenDBArray.GetCount(); ii++)
{
#ifdef _DEBUG
if (CardOpenDBArray.GetAt(ii).GetMemberId() == 178547)
{
int kkk = 0;
}
#endif
CString strSQL;
strSQL.Append(_T("SELECT returned.* "));
strSQL.Append(_T("FROM returned "));
strSQL.AppendFormat(_T("WHERE returned.memberId = '%d' AND returned.classId in %s ")
, CardOpenDBArray.GetAt(ii).GetMemberId(), GetCommonClassIdAsString());
strSQL.AppendFormat(_T("AND returned.returnDate >= '%s'")
, CardOpenDBArray.GetAt(ii).GetOperationDateTime());
strSQL.Append(_T(" ORDER BY returned.returnDate DESC"));
CIBALog::GetInstance()->WriteFormat(CIBALog::ELT_SQL, _T("QueryReturned:%s"), strSQL);
CADODBConnInfo* pDb = NULL;
if (!CIBADAL::GetInstance()->GetDBConnInfo(pDb)) return;
CADORecordset Rs(pDb->GetConn());
if (Rs.Open(strSQL))
{
if (!Rs.IsEof())
{
CardOpenDBArray.RemoveAt(ii);
ii--;
}
Rs.Close();
}
pDb->Release();
}
for (INT jj = 0; jj < CardOpenDBArray.GetCount(); jj++)
{
INT nTmp = 0;
CString strTmp;
m_InfoList.InsertItem(jj, CardOpenDBArray.GetAt(jj).GetSerialNum());
m_InfoList.SetItemText(jj, 1, CardOpenDBArray.GetAt(jj).GetUserName());
m_InfoList.SetItemText(jj, 3, CardOpenDBArray.GetAt(jj).GetIdNumber());
strTmp.Format(_T("%d"), CardOpenDBArray.GetAt(jj).GetMemberId());
m_InfoList.SetItemText(jj, 4, strTmp);
m_InfoList.SetItemText(jj, 5, CardOpenDBArray.GetAt(jj).GetOperationDateTime());
}
CardOpenDBArray.RemoveAll();
}
示例13: EnumSerialPorts
void CEnumSerial::EnumSerialPorts(CArray<SSerInfo,SSerInfo&> &asi, BOOL bIgnoreBusyPorts)
{
// Clear the output array
asi.RemoveAll();
// Use different techniques to enumerate the available serial
// ports, depending on the OS we're using
OSVERSIONINFO vi;
vi.dwOSVersionInfoSize = sizeof(vi);
if (!GetVersionEx(&vi))
{
CString str;
str.Format(_T("Could not get OS version. (err=%lx)"), GetLastError());
throw str;
}
// Handle windows 9x and NT4 specially
if (vi.dwMajorVersion < 5)
{
if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT)
EnumPortsWNt4(asi);
else
Win9xListPorts(asi);
}
else
{
// Win2k and later support a standard API for
// enumerating hardware devices.
EnumPortsWdm(asi);
}
for (int ii=0; ii<asi.GetSize(); ii++)
{
SSerInfo& rsi = asi[ii];
if (bIgnoreBusyPorts)
{
// Only display ports that can be opened for read/write
HANDLE hCom;
hCom = CreateFile(rsi.strDevPath, GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, 0, NULL);
if (hCom == INVALID_HANDLE_VALUE)
{
// It can't be opened; remove it.
asi.RemoveAt(ii);
ii--;
continue;
}
else
{
// It can be opened! Close it and add it to the list
CloseHandle(hCom);
}
}
// Come up with a name for the device.
// If there is no friendly name, use the port name.
if (rsi.strFriendlyName.IsEmpty())
rsi.strFriendlyName = rsi.strPortName;
// If there is no description, try to make one up from
// the friendly name.
if (rsi.strPortDesc.IsEmpty())
{
// If the port name is of the form "ACME Port (COM3)"
// then strip off the " (COM3)"
rsi.strPortDesc = rsi.strFriendlyName;
int startdex = rsi.strPortDesc.Find(_T(" ("));
int enddex = rsi.strPortDesc.Find(_T(")"));
if ( (startdex > 0) && (enddex == (rsi.strPortDesc.GetLength()-1)))
rsi.strPortDesc = rsi.strPortDesc.Left(startdex);
}
}
}
示例14: CleanedFillupBug
BOOL CUPnpMgr::CleanedFillupBug()
{
CSingleLock localLock(&m_cs, TRUE);
if (FAILED(m_nat.SearchDevice()))
return FALSE;
HRESULT hr;
USHORT usIndex;
USHORT usExternalPort;
CString strProtocol;
CString strDesc;
CString strInternalClient;
CString strLocalIP;
CArray<CUPnpNatMapping, const CUPnpNatMapping&> arrMapping;
CUPnpNatMapping mapping;
strLocalIP = GetLocalIPStr();
for (usIndex = 0; usIndex < 128; usIndex++) // 最多查询128项,以防止有些路由器可能会一直返回成功。
{
hr = m_nat.GetGenericPortMappingEntry(usIndex, NULL, &usExternalPort, &strProtocol,
NULL, &strInternalClient, NULL, &strDesc);
if (-1 != strDesc.Find(_T("eMule ("))) // 描述里包含指定字样
{
if (strInternalClient == strLocalIP) // 是本机添加的映射
m_nat.DeletePortMapping(CString(_T("")),usExternalPort, strProtocol);
else
{
mapping.m_strInternalClient = strInternalClient;
mapping.m_wExternalPort = usExternalPort;
mapping.m_strProtocol = strProtocol;
arrMapping.Add(mapping);
}
}
if (FAILED(hr)) // 返回Failed结果,表示已经全部取完了。
break;
}
// 如果同一ip做的eMule映射超过3项,则很有可能是以前的bug所致。则清除。<begin>
int i;
int iMappingCount;
CString strTestIp;
while (! arrMapping.IsEmpty())
{
strTestIp = arrMapping[0].m_strInternalClient;
iMappingCount = 0;
for (i = 0; i < arrMapping.GetCount(); i++)
{
if (strTestIp == arrMapping[i].m_strInternalClient)
iMappingCount++;
}
for (i = arrMapping.GetCount() - 1; i >= 0; i--)
{
if (strTestIp == arrMapping[i].m_strInternalClient)
{
if (iMappingCount > 3)
{
m_nat.DeletePortMapping(CString(_T("")),
arrMapping[i].m_wExternalPort,
arrMapping[i].m_strProtocol);
}
arrMapping.RemoveAt(i);
}
}
}
// 如果同一ip做的eMule映射超过3项,则很有可能是以前的bug所致。则清除。<end>
return TRUE;
}