本文整理汇总了C++中CAtlList::GetAt方法的典型用法代码示例。如果您正苦于以下问题:C++ CAtlList::GetAt方法的具体用法?C++ CAtlList::GetAt怎么用?C++ CAtlList::GetAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAtlList
的用法示例。
在下文中一共展示了CAtlList::GetAt方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddPoint
void CEllipseCenterGroup::AddPoint(CAtlList<EllipseCenter>& centers, IntersectFunction intersect, int x, int y)
{
POSITION pos = centers.GetTailPosition();
while (pos) {
POSITION posCur = pos;
auto& center = centers.GetPrev(pos);
int dyIntersect = intersect(x - center.x, y - center.y);
if (dyIntersect != CEllipse::NO_INTERSECT_INNER) {
int yIntersect = (dyIntersect == CEllipse::NO_INTERSECT_OUTER) ? (y - m_pEllipse->GetYRadius() - 1) : (center.y + dyIntersect);
if (yIntersect < center.yStopDrawing) {
center.yStopDrawing = yIntersect;
if (pos && center.yStopDrawing <= centers.GetAt(pos).yStopDrawing) {
centers.RemoveAt(posCur);
}
} else {
break;
}
}
}
auto& center = centers.GetAt(centers.AddTail());
center.x = x;
center.y = y;
center.yStopDrawing = y + m_pEllipse->GetYRadius();
}
示例2: SortInfoByExtension
void CDSFilters::SortInfoByExtension(CAtlList<DSFilterInfo*>& InfoList, const TCHAR* pcszExtension)
{
DSFilterInfo* pInfo = NULL;
POSITION pos = InfoList.GetHeadPosition();
while (pos)
{
BOOL bMatched = FALSE;
pInfo = InfoList.GetAt(pos);
if (pInfo != NULL)
{
POSITION pos2 = pInfo->extensions.GetHeadPosition();
while (pos2)
{
CString& extension = pInfo->extensions.GetNext(pos2);
if (extension.CompareNoCase(pcszExtension+1))
{
bMatched = TRUE;
break;
}
}
if (bMatched)
{
InfoList.MoveToHead(pos);
}
}
InfoList.GetNext(pos);
}
}
示例3: FindMainMovie
HRESULT CHdmvClipInfo::FindMainMovie(LPCTSTR strFolder, CString& strPlaylistFile, CAtlList<PlaylistItem>& MainPlaylist, CAtlList<PlaylistItem>& MPLSPlaylists)
{
HRESULT hr = E_FAIL;
CString strPath(strFolder);
CString strFilter;
MPLSPlaylists.RemoveAll();
CAtlList<PlaylistItem> Playlist;
WIN32_FIND_DATA fd = {0};
strPath.Replace(_T("\\PLAYLIST\\"), _T("\\"));
strPath.Replace(_T("\\STREAM\\"), _T("\\"));
strPath += _T("\\BDMV\\");
strFilter.Format(_T("%sPLAYLIST\\*.mpls"), strPath);
HANDLE hFind = FindFirstFile(strFilter, &fd);
if (hFind != INVALID_HANDLE_VALUE) {
REFERENCE_TIME rtMax = 0;
REFERENCE_TIME rtCurrent;
CString strCurrentPlaylist;
do {
strCurrentPlaylist.Format(_T("%sPLAYLIST\\%s"), strPath, fd.cFileName);
Playlist.RemoveAll();
// Main movie shouldn't have duplicate M2TS filename...
if (ReadPlaylist(strCurrentPlaylist, rtCurrent, Playlist) == S_OK) {
if (rtCurrent > rtMax) {
rtMax = rtCurrent;
strPlaylistFile = strCurrentPlaylist;
MainPlaylist.RemoveAll();
POSITION pos = Playlist.GetHeadPosition();
while (pos) {
MainPlaylist.AddTail(Playlist.GetNext(pos));
}
hr = S_OK;
}
if (rtCurrent >= (REFERENCE_TIME)MIN_LIMIT * 600000000) {
PlaylistItem Item;
Item.m_strFileName = strCurrentPlaylist;
Item.m_rtIn = 0;
Item.m_rtOut = rtCurrent;
MPLSPlaylists.AddTail(Item);
}
}
} while (FindNextFile(hFind, &fd));
FindClose(hFind);
}
if (MPLSPlaylists.GetCount() > 1) {
// bubble sort
for (size_t j = 0; j < MPLSPlaylists.GetCount(); j++) {
for (size_t i = 0; i < MPLSPlaylists.GetCount() - 1; i++) {
if (MPLSPlaylists.GetAt(MPLSPlaylists.FindIndex(i)).Duration() < MPLSPlaylists.GetAt(MPLSPlaylists.FindIndex(i + 1)).Duration()) {
MPLSPlaylists.SwapElements(MPLSPlaylists.FindIndex(i), MPLSPlaylists.FindIndex(i + 1));
}
}
}
}
return hr;
}
示例4: GetMediaTypeDesc
//.........这里部分代码省略.........
if (pmt->formattype == FORMAT_WaveFormatEx) {
const WAVEFORMATEX *pInfo = GetFormatHelper(pInfo, pmt);
if (pmt->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
Infos.AddTail(L"DVD LPCM");
} else if (pmt->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
const WAVEFORMATEX_HDMV_LPCM *pInfoHDMV = GetFormatHelper(pInfoHDMV, pmt);
UNREFERENCED_PARAMETER(pInfoHDMV);
Infos.AddTail(L"HDMV LPCM");
}
if (pmt->subtype == MEDIASUBTYPE_DOLBY_DDPLUS) {
Infos.AddTail(L"Dolby Digital Plus");
} else {
switch (pInfo->wFormatTag) {
case WAVE_FORMAT_MPEG: {
const MPEG1WAVEFORMAT* pInfoMPEG1 = GetFormatHelper(pInfoMPEG1, pmt);
int layer = GetHighestBitSet32(pInfoMPEG1->fwHeadLayer) + 1;
Infos.AddTail(FormatString(L"MPEG1 - Layer %d", layer));
}
break;
default: {
CString codecName = CMediaTypeEx::GetAudioCodecName(pmt->subtype, pInfo->wFormatTag);
if (codecName.GetLength() > 0) {
Infos.AddTail(codecName);
}
}
break;
}
}
if (pInfo->nSamplesPerSec) {
Infos.AddTail(FormatString(L"%.1f kHz", double(pInfo->nSamplesPerSec)/1000.0));
}
if (pInfo->nChannels) {
Infos.AddTail(FormatString(L"%d chn", pInfo->nChannels));
}
if (pInfo->wBitsPerSample) {
Infos.AddTail(FormatString(L"%d bit", pInfo->wBitsPerSample));
}
if (pInfo->nAvgBytesPerSec) {
Infos.AddTail(FormatBitrate(pInfo->nAvgBytesPerSec * 8));
}
} else if (pmt->formattype == FORMAT_VorbisFormat) {
const VORBISFORMAT *pInfo = GetFormatHelper(pInfo, pmt);
Infos.AddTail(CMediaTypeEx::GetAudioCodecName(pmt->subtype, 0));
if (pInfo->nSamplesPerSec) {
Infos.AddTail(FormatString(L"%.1f kHz", double(pInfo->nSamplesPerSec)/1000.0));
}
if (pInfo->nChannels) {
Infos.AddTail(FormatString(L"%d chn", pInfo->nChannels));
}
if (pInfo->nAvgBitsPerSec) {
Infos.AddTail(FormatString(L"%d bit", pInfo->nAvgBitsPerSec));
}
if (pInfo->nAvgBitsPerSec) {
Infos.AddTail(FormatBitrate(pInfo->nAvgBitsPerSec * 8));
}
} else if (pmt->formattype == FORMAT_VorbisFormat2) {
const VORBISFORMAT2 *pInfo = GetFormatHelper(pInfo, pmt);
Infos.AddTail(CMediaTypeEx::GetAudioCodecName(pmt->subtype, 0));
if (pInfo->SamplesPerSec) {
Infos.AddTail(FormatString(L"%.1f kHz", double(pInfo->SamplesPerSec)/1000.0));
}
if (pInfo->Channels) {
Infos.AddTail(FormatString(L"%d chn", pInfo->Channels));
}
}
}
if (!Infos.IsEmpty()) {
CString Ret = pName;
Ret += " (";
bool bFirst = true;
for (POSITION pos = Infos.GetHeadPosition(); pos; Infos.GetNext(pos)) {
const CString& String = Infos.GetAt(pos);
if (bFirst) {
Ret += String;
} else {
Ret += L", " + String;
}
bFirst = false;
}
Ret += ')';
return Ret;
}
return pName;
}
示例5: depNode
//THIS FUNCTION IS QUITE COMPLICATED BECAUSE
//IT HAS TO DEAL WITH MAYA NAME MANGLING!
//tokenize the path.
//add each token into the element list which tracks the attributes and indices
//for each entry added make sure there are no parents left out from maya name mangling.
//after the list is populated and missing elements area added
//we reiterate and produce the final result.
MPlug FxInternal::DecodePlug(const CStringA& plugStr)
{
MPlug result;
MFnDependencyNode depNode(GetSite());
CAtlList<PathDecodeElement> elementList;
//tokenize the path
int iLastPos=0;
int iThisPos=0;
CStringA subStr;
while( iLastPos= iThisPos,
subStr=plugStr.Tokenize(".[]", iThisPos),
iThisPos != -1 )
{
//char lastChar= subStr[iLastPos];
//char thisChar= subStr[iThisPos];
//are we looking at a named portion?
if(iLastPos == 0
|| plugStr[iLastPos-1]=='.'
|| (plugStr[iLastPos-1]==']' && plugStr[iLastPos]=='.'))
{
//if the name is length zero then it must be the case when
// you do last[#]. The situation is caused by the sequence "]."
//if we dont have a name we can skip since only 1d arrays are allowed.
if(subStr.GetLength() > 0)
{
//everything we add is going to be based on the current tail.
//because we are adding parents, as we find parents we can continue
//to add them to this position so that they will order themselves properly
POSITION insertPos= elementList.GetTailPosition();
//calculate the cancel condition.
//it is the current tail's object if a tail exists otherwise NULL
//NULL indicates go all the way to the root
MObject cancelObj= MObject::kNullObj;
if(elementList.GetCount() > 0)
{
cancelObj= elementList.GetTail().Attribute.object();
}
//get the object we are currently working with
MObject thisObj= depNode.attribute(subStr.GetString());
if(thisObj.isNull())
return MPlug();//Critical element of the path was not found...return NULL
//add it to the list so that we have something to insertBefore
elementList.AddTail();
elementList.GetTail().Name= subStr;
elementList.GetTail().Attribute.setObject(thisObj);
//walk through all of the parents until we reach cancel condition.
//we can add the current element onto the list in the same way.
for( MFnAttribute itrAttr( elementList.GetTail().Attribute.parent() );
!itrAttr.object().isNull() && (cancelObj != itrAttr.object());
itrAttr.setObject(itrAttr.parent()))
{
PathDecodeElement element;
element.Attribute.setObject( itrAttr.object() );
//we change the position so that the grandparent is inserted before the parent
insertPos= elementList.InsertBefore( insertPos, element);
}
}
}
//are we looking at a numbered portion?
else if(plugStr[iLastPos-1]=='[' && plugStr[iThisPos-1]==']')
{
//if so change the array index.
elementList.GetTail().IsArray= true;
elementList.GetTail().Index = atoi( subStr.GetString() );
}
else
DXCC_ASSERT(false);//VERY POORLY FORMED STRING
}
//produce the result plug off of the elementList.
bool first= true;
for(POSITION pos= elementList.GetHeadPosition();
pos != NULL;
elementList.GetNext(pos))
{
PathDecodeElement& element= elementList.GetAt(pos);
//.........这里部分代码省略.........
示例6: GetAutoDestDirFromSize
//.........这里部分代码省略.........
goto clean0;
buffer.SetCount(512);
pBuffer = buffer.GetData();
dwSize = (DWORD)buffer.GetCount();
memset(pBuffer, 0, dwSize * sizeof(TCHAR));
dwSize = GetLogicalDriveStrings(dwSize, buffer.GetData());
if (dwSize > 2)
{
strDrv = pBuffer;
logicalDrvs.AddTail(strDrv);
for (DWORD i = 3; i < dwSize; ++i)
{
if (pBuffer[i] != 0 && pBuffer[i - 1] == 0)
{
strDrv = pBuffer + i;
logicalDrvs.AddTail(strDrv);
}
}
}
pos = logicalDrvs.GetHeadPosition();
while (pos)
{
POSITION current = pos;
CString _drv = logicalDrvs.GetNext(pos);
_drv.MakeLower();
if (_drv == _T("a:\\") || _drv == _T("b:\\"))
{
logicalDrvs.RemoveAt(current);
continue;
}
UINT uType = GetDriveType(_drv);
if (uType != DRIVE_FIXED &&
uType != DRIVE_REMOVABLE)
{
logicalDrvs.RemoveAt(current);
continue;
}
if (strSysDrv.CompareNoCase(_drv)==0)
{
logicalDrvs.RemoveAt(current);
continue;
}
RtlZeroMemory(szVolName, sizeof(szVolName));
RtlZeroMemory(szFileSystem, sizeof(szFileSystem));
fRetCode = GetVolumeInformation(
_drv,
szVolName,
MAX_PATH+1,
NULL,
NULL,
NULL,
szFileSystem,
MAX_PATH+1
);
if (!fRetCode)
{
logicalDrvs.RemoveAt(current);
continue;
}
}
pos = logicalDrvs.GetHeadPosition();
while (pos)
{
POSITION current = pos;
const CString& _drv = logicalDrvs.GetNext(pos);
BOOL fRetCode = GetDiskFreeSpace(
_drv,
&dwSectorsPerCluster,
&dwBytesPerSector,
&dwNumberOfFreeClusters,
&dwTotalNumberOfClusters
);
if (!fRetCode)
continue;
ULONGLONG uCurrentFreeSize = (ULONGLONG)dwNumberOfFreeClusters * dwSectorsPerCluster * dwBytesPerSector;
if (uCurrentFreeSize > uMaxSize)
{
max_size_pos = current;
uMaxSize = uCurrentFreeSize;
}
}
if (max_size_pos==NULL)
goto clean0;
strDir = logicalDrvs.GetAt(max_size_pos);
strDir += _T("系统盘大文件");
retval = TRUE;
clean0:
return retval;
}
示例7: Dump
void SZYamlDocument::Dump(CString& strText, int nDumpIndent/* = SZYAML_DUMP_INDENT*/)
{
POSITION pos = m_YamlItemList.GetHeadPosition();
struct _KeyStackNode
{
_KeyStackNode()
: nIndent(0)
, nChildIndent(0)
, bIsList(FALSE)
{
}
int nIndent;
int nChildIndent;
CString strKey;
BOOL bIsList;
};
CAtlList<_KeyStackNode> listKeyStack;
int nLastIndent = -1;
BOOL bListItem = FALSE, bPrintThisLine = TRUE;
CString strLine;
strText = _T("");
while (pos)
{
_YamlItem &item = m_YamlItemList.GetAt(pos);
if (listKeyStack.IsEmpty())
bListItem = FALSE;
else
bListItem = listKeyStack.GetTail().bIsList;
if (item.nIndent == nLastIndent + 1)
{
_KeyStackNode &newkey = listKeyStack.GetAt(listKeyStack.AddTail());
POSITION posNext = _GetNextPos(pos, TRUE);
newkey.nIndent = item.nIndent;
newkey.strKey = item.node.Key();
newkey.bIsList = (posNext != NULL);
}
else if (item.nIndent == nLastIndent)
{
_KeyStackNode &newkey = listKeyStack.GetTail();
POSITION posNext = _GetNextPos(pos, TRUE);
newkey.nIndent = item.nIndent;
newkey.strKey = item.node.Key();
newkey.bIsList = (posNext != NULL);
}
else if (item.nIndent < nLastIndent)
{
for (nLastIndent -= item.nIndent; nLastIndent > 0; -- nLastIndent)
listKeyStack.RemoveTail();
if (listKeyStack.IsEmpty())
bPrintThisLine = TRUE;
else
{
_KeyStackNode &newkey = listKeyStack.GetTail();
newkey.nIndent = item.nIndent;
if (newkey.strKey != item.node.Key())
{
newkey.strKey = item.node.Key();
POSITION posNext = _GetNextPos(pos, TRUE);
newkey.bIsList = (posNext != NULL);
}
else
bPrintThisLine = !newkey.bIsList;
}
}
#ifdef _SZYAML_DEBUG_TRACE
{ // Trace Key Stack
kconsole::printf(_T(" "));
for (POSITION pos = listKeyStack.GetHeadPosition(); pos != NULL; listKeyStack.GetNext(pos))
{
_KeyStackNode key = listKeyStack.GetAt(pos);
kconsole::settextcolor(TRUE, TRUE, TRUE, FALSE);
kconsole::printf(_T("(%d, '%s', %d)"), key.nIndent, key.strKey, key.bIsList);
kconsole::settextcolor(TRUE, TRUE, TRUE, TRUE);
}
kconsole::printf(_T("\r\n"));
}
#endif
// 这里对不确定长度的%s不使用Format,是因为MIN_CRT的格式化输出限制长度为1024,见atlstr.h
// by bbcallen 2009-07-02
if (bPrintThisLine)
{
if (bListItem)
{
strLine.Format(
_T("%s-%s"),
CString(_T(' '), (item.nIndent - 1) * nDumpIndent),
CString(_T(' '), nDumpIndent - 1)
);
//.........这里部分代码省略.........
示例8: Load
BOOL SZYamlDocument::Load(LPCTSTR lpszText)
{
BOOL bResult = FALSE;
BOOL bNotFinish = TRUE;
CString strText = lpszText, strLine, strKey, strValue;
int nThisLinePos = 0, nNextLinePos = 0, nColonPos = 0;
int nIndent = 0, nLineNum = 1;
struct _KeyStackNode
{
_KeyStackNode()
: nIndent(0)
, nChildIndent(0)
, bIsList(FALSE)
{
}
int nIndent;
int nChildIndent;
CString strKey;
BOOL bIsList;
};
CAtlList<_KeyStackNode> listKeyStack;
BOOL bNewChild = FALSE, bIsListItem = FALSE;
m_YamlItemList.RemoveAll();
if (!lpszText)
goto Exit0;
while (bNotFinish)
{
nNextLinePos = strText.Find(_T('\n'), nThisLinePos);
if (-1 == nNextLinePos)
{
bNotFinish = FALSE;
strLine = strText.Mid(nThisLinePos);
}
else
strLine = strText.Mid(nThisLinePos, nNextLinePos - nThisLinePos);
nIndent = 0;
// Get indent
while (_T(' ') == strLine[nIndent])
nIndent ++;
nColonPos = strLine.Find(_T(':'));
strKey = strLine.Left(nColonPos).Trim();
strValue = strLine.Mid(nColonPos + 1).Trim();
if (_T('-') == strKey[0])
{
int nIndentMore = 1;
while (_T(' ') == strKey[nIndentMore])
nIndentMore ++;
nIndent += nIndentMore;
strKey = strKey.Mid(nIndentMore);
bIsListItem = TRUE;
}
else
bIsListItem = FALSE;
if (bNewChild)
{
_KeyStackNode &LastKey = listKeyStack.GetTail();
LastKey.nChildIndent = nIndent;
if (bIsListItem)
LastKey.bIsList = TRUE;
#ifdef _SZYAML_DEBUG_TRACE
{ // Trace Key Stack
kconsole::printf(_T(" "));
for (POSITION pos = listKeyStack.GetHeadPosition(); pos != NULL; listKeyStack.GetNext(pos))
{
_KeyStackNode key = listKeyStack.GetAt(pos);
kconsole::printf(_T("(%d, '%s', %d)"), key.nChildIndent, key.strKey, key.bIsList);
}
kconsole::printf(_T("\r\n"));
}
#endif
}
strLine = strLine.Mid(nIndent);
if (strLine.IsEmpty())
continue;
while (!listKeyStack.IsEmpty())
{
_KeyStackNode &LastKey = listKeyStack.GetTail();
if (LastKey.nChildIndent == nIndent)
break;
//.........这里部分代码省略.........
示例9: OnBtnQuerySoft
VOID CBeikeSafeSoftmgrNecessHandler::OnBtnQuerySoft()
{
CString strSearch;
m_editQuery.GetWindowText(strSearch);
if (strSearch == BkString::Get(IDS_SOFTMGR_8016) )
return;
else if (strSearch.IsEmpty())
{
if (!m_strViewDetailSoftId.IsEmpty())
{
m_pSoftMgrMainUI->_QuerySoftMark(m_strViewDetailSoftId);
m_strViewDetailSoftId.Empty();
m_IEDetail.Show2(_T("about:blank"),NULL);
m_pMainDlg->SetItemVisible(IDC_SOFT_NECESS_DIV_RIGHT_LIST_SHOW,TRUE);
m_pMainDlg->SetItemVisible(IDC_SOFT_NECESS_DIV_RIGHT_DETAIL_SHOW,FALSE);
m_pMainDlg->SetItemVisible(IDC_SOFT_NECESS_SHOW_FREE_SOFT,TRUE);
m_pMainDlg->SetItemVisible(IDC_SOFT_NECESS_SHOW_NOPLUG_SOFT,TRUE);
if ( ::GetFocus() != m_editQuery.m_hWnd )
m_pSoftMgrMainUI->m_pDlg->SetFocus();
}
OnBtnSearchBack();
}
else
{
m_bShowType = TRUE;
BOOL bFreeChecked = m_pMainDlg->GetItemCheck(IDC_SOFT_NECESS_SHOW_FREE_SOFT);
BOOL bPlugChecked = m_pMainDlg->GetItemCheck(IDC_SOFT_NECESS_SHOW_NOPLUG_SOFT);
ATLASSERT (m_pSoftMgrMainUI->m_pSoftMgr!=NULL);
m_arrRightList.RemoveAll();
//读取
CSimpleArray<CSoftListItemData*> arrQuery;
void *pos = m_pSoftMgrMainUI->m_pSoftMgr->SearchSoft(strSearch, L"ar");
CAtlMap<CString,CString> soft;
while(0 == m_pSoftMgrMainUI->m_pSoftMgr->GetNextSoft(pos, GetInfoUseMap,&soft))
{
CString strTmp = soft[_T("softid")];
CSoftListItemData* pData = GetSoftDataByID(strTmp);
BOOL bCanInsert = FALSE;
if (pData)
{
if( bPlugChecked && bFreeChecked )
{
if ( !pData->m_bCharge && !pData->m_bPlug )
bCanInsert = TRUE;
}
else if ( bPlugChecked && !bFreeChecked )
{
if ( !pData->m_bPlug )
bCanInsert = TRUE;
}
else if ( !bPlugChecked && bFreeChecked )
{
if ( !pData->m_bCharge )
bCanInsert = TRUE;
}
else
bCanInsert = TRUE;
if (bCanInsert)
arrQuery.Add(pData);
}
}
m_pSoftMgrMainUI->m_pSoftMgr->FinalizeGet(pos);
//排序
CAtlList<CSoftListItemData*> arrOrder;
m_pSoftMgrMainUI->_SortArrayByOrder(arrQuery, arrOrder);
//构造
BOOL bQueryMark = FALSE;
CSoftListItemData *pDataTemp = NULL;
POSITION posTemp = arrOrder.GetHeadPosition();
while (posTemp)
{
pDataTemp = arrOrder.GetAt(posTemp);
if (pDataTemp)
{
NECESS_SOFT_LIST_DATA data;
data.bTitle = FALSE;
data.strSoftId = pDataTemp->m_strSoftID;
m_arrRightList.Add(data);
if (m_pSoftMgrMainUI->m_pInfoQuery)
{
// 获取分数
if (pDataTemp->m_fMark==0 )
{
int nTmp = _wtoi( pDataTemp->m_strSoftID );
m_pSoftMgrMainUI->m_pInfoQuery->AddSoft(nTmp);
bQueryMark = TRUE;
}
}
}
//.........这里部分代码省略.........
示例10: if
//.........这里部分代码省略.........
switch (reinterpret_cast<LPNMHDR>(lParam)->code)
{
case PSN_APPLY:
{
// Try to apply the modifications to the system.
MessageBox(NULL, _T("In Services page: PSN_APPLY"), _T("Info"), MB_ICONINFORMATION);
/*
//
// Move this away...
//
int iRetVal = MessageBox(NULL, _T("Would you really want to modify the configuration of your system ?"), _T("Warning"), MB_ICONWARNING | MB_YESNOCANCEL);
if (iRetVal == IDYES /\* modifications are OK *\/)
SetWindowLongPtr(hServicesPage, DWLP_MSGRESULT, PSNRET_NOERROR);
else if (iRetVal == IDNO /\* modifications are not OK *\/)
SetWindowLongPtr(hServicesPage, DWLP_MSGRESULT, PSNRET_NOERROR);
else // if (iRetVal == IDCANCEL) // There was an error...
SetWindowLongPtr(hServicesPage, DWLP_MSGRESULT, PSNRET_INVALID);
*/
//
// We modify the services which are stored in the user modification list.
//
// 1- Open the Service Control Manager for modifications.
SC_HANDLE hSCManager = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (hSCManager != NULL)
{
LPCWSTR svcName;
for (POSITION it = userModificationsList.GetHeadPosition(); it; userModificationsList.GetNext(it))
{
svcName = userModificationsList.GetAt(it);
// 2- Retrieve a handle to the service.
SC_HANDLE hService = OpenServiceW(hSCManager, svcName, SERVICE_QUERY_CONFIG | SERVICE_CHANGE_CONFIG);
if (hService == NULL)
{
// TODO : Show a message box.
continue;
}
DWORD dwBytesNeeded = 0;
QueryServiceConfigW(hService, NULL, 0, &dwBytesNeeded);
// if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
LPQUERY_SERVICE_CONFIG lpServiceConfig = (LPQUERY_SERVICE_CONFIG)MemAlloc(0, dwBytesNeeded);
if (!lpServiceConfig)
{
CloseServiceHandle(hService);
continue; // TODO ? Show a message box...
}
QueryServiceConfigW(hService, lpServiceConfig, dwBytesNeeded, &dwBytesNeeded);
if (lpServiceConfig->dwStartType == SERVICE_DISABLED) // We have a disabled service which is becoming to be enabled.
{
// 3a- Retrive the properties of the disabled service from the registry.
RegistryDisabledServiceItemParams params = {};
QUERY_REGISTRY_KEYS_TABLE KeysQueryTable[2] = {};
KeysQueryTable[0].QueryRoutine = GetRegistryKeyedDisabledServicesQueryRoutine;
KeysQueryTable[0].EntryContext = ¶ms;
RegQueryRegistryKeys(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services", KeysQueryTable, (PVOID)svcName);
if (bIsWindows && bIsPreVistaOSVersion && !params.bIsPresent)