本文整理汇总了C++中CAutoGeneralHandle::GetPointer方法的典型用法代码示例。如果您正苦于以下问题:C++ CAutoGeneralHandle::GetPointer方法的具体用法?C++ CAutoGeneralHandle::GetPointer怎么用?C++ CAutoGeneralHandle::GetPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAutoGeneralHandle
的用法示例。
在下文中一共展示了CAutoGeneralHandle::GetPointer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: blockTickCount
CDirectoryWatcher::CDirectoryWatcher(void)
: m_bRunning(TRUE)
, m_bCleaned(FALSE)
, m_FolderCrawler(NULL)
, blockTickCount(0)
{
// enable the required privileges for this process
LPCTSTR arPrivelegeNames[] = { SE_BACKUP_NAME,
SE_RESTORE_NAME,
SE_CHANGE_NOTIFY_NAME
};
for (int i=0; i<(sizeof(arPrivelegeNames)/sizeof(LPCTSTR)); ++i)
{
CAutoGeneralHandle hToken;
if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, hToken.GetPointer()))
{
TOKEN_PRIVILEGES tp = { 1 };
if (LookupPrivilegeValue(NULL, arPrivelegeNames[i], &tp.Privileges[0].Luid))
{
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(tp), NULL, NULL);
}
}
}
unsigned int threadId = 0;
m_hThread = (HANDLE)_beginthreadex(NULL,0,ThreadEntry,this,0,&threadId);
}
示例2: GetProcessIntegrityLevel
DWORD CRemoteCacheLink::GetProcessIntegrityLevel() const
{
DWORD dwIntegrityLevel = SECURITY_MANDATORY_MEDIUM_RID;
CAutoGeneralHandle hProcess = GetCurrentProcess();
CAutoGeneralHandle hToken;
if (OpenProcessToken(hProcess, TOKEN_QUERY |
TOKEN_QUERY_SOURCE, hToken.GetPointer()))
{
// Get the Integrity level.
DWORD dwLengthNeeded;
if (!GetTokenInformation(hToken, TokenIntegrityLevel,
NULL, 0, &dwLengthNeeded))
{
DWORD dwError = GetLastError();
if (dwError == ERROR_INSUFFICIENT_BUFFER)
{
PTOKEN_MANDATORY_LABEL pTIL =
(PTOKEN_MANDATORY_LABEL)LocalAlloc(0, dwLengthNeeded);
if (pTIL != NULL)
{
if (GetTokenInformation(hToken, TokenIntegrityLevel,
pTIL, dwLengthNeeded, &dwLengthNeeded))
{
dwIntegrityLevel = *GetSidSubAuthority(pTIL->Label.Sid,
(DWORD)(UCHAR)(*GetSidSubAuthorityCount(pTIL->Label.Sid)-1));
}
LocalFree(pTIL);
}
}
}
}
return dwIntegrityLevel;
}
示例3: GetCacheID
CString GetCacheID()
{
CAutoGeneralHandle token;
DWORD len;
BOOL result = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, token.GetPointer());
if(result)
{
GetTokenInformation(token, TokenStatistics, NULL, 0, &len);
LPBYTE data = new BYTE[len];
GetTokenInformation(token, TokenStatistics, data, len, &len);
LUID uid = ((PTOKEN_STATISTICS)data)->AuthenticationId;
delete [ ] data;
CString t;
t.Format(_T("-%08x%08x"), uid.HighPart, uid.LowPart);
return t;
}
return _T("");
}
示例4: RunCmdList
//static function, Share with SyncDialog
UINT CProgressDlg::RunCmdList(CWnd* pWnd, STRING_VECTOR& cmdlist, STRING_VECTOR& dirlist, bool bShowCommand, CString* pfilename, volatile bool* bAbort, CGitGuardedByteArray* pdata, CGit* git)
{
UINT ret=0;
std::vector<std::unique_ptr<CBlockCacheForPath>> cacheBlockList;
std::vector<std::unique_ptr<CGit>> gitList;
if (dirlist.empty())
cacheBlockList.push_back(std::make_unique<CBlockCacheForPath>(git->m_CurrentDir));
else
{
for (const auto& dir : dirlist)
{
auto pGit = std::make_unique<CGit>();
pGit->m_CurrentDir = dir;
gitList.push_back(std::move(pGit));
cacheBlockList.push_back(std::make_unique<CBlockCacheForPath>(dir));
}
}
EnsurePostMessage(pWnd, MSG_PROGRESSDLG_UPDATE_UI, MSG_PROGRESSDLG_START, 0);
if(pdata)
pdata->clear();
for (size_t i = 0; i < cmdlist.size(); ++i)
{
if(cmdlist[i].IsEmpty())
continue;
if (bShowCommand)
{
CStringA str;
if (gitList.empty() || gitList.size() == 1 && gitList[0]->m_CurrentDir == git->m_CurrentDir)
str = CUnicodeUtils::GetMulti(cmdlist[i].Trim() + _T("\r\n\r\n"), CP_UTF8);
else
str = CUnicodeUtils::GetMulti((i > 0 ? _T("\r\n") : _T("")) + gitList[i]->m_CurrentDir + _T("\r\n") + cmdlist[i].Trim() + _T("\r\n\r\n"), CP_UTF8);
for (int j = 0; j < str.GetLength(); ++j)
{
if(pdata)
{
pdata->m_critSec.Lock();
pdata->push_back(str[j]);
pdata->m_critSec.Unlock();
}
else
pWnd->PostMessage(MSG_PROGRESSDLG_UPDATE_UI,MSG_PROGRESSDLG_RUN,str[j]);
}
if(pdata)
pWnd->PostMessage(MSG_PROGRESSDLG_UPDATE_UI,MSG_PROGRESSDLG_RUN,0);
}
PROCESS_INFORMATION pi;
CAutoGeneralHandle hRead;
int runAsyncRet = -1;
if (gitList.empty())
runAsyncRet = git->RunAsync(cmdlist[i].Trim(), &pi, hRead.GetPointer(), nullptr, pfilename);
else
runAsyncRet = gitList[i]->RunAsync(cmdlist[i].Trim(), &pi, hRead.GetPointer(), nullptr, pfilename);
if (runAsyncRet)
{
EnsurePostMessage(pWnd, MSG_PROGRESSDLG_UPDATE_UI, MSG_PROGRESSDLG_FAILED, -1 * runAsyncRet);
return runAsyncRet;
}
CAutoGeneralHandle piProcess(pi.hProcess);
CAutoGeneralHandle piThread(pi.hThread);
DWORD readnumber;
char lastByte = '\0';
char byte;
CString output;
while (ReadFile(hRead, &byte, 1, &readnumber, nullptr))
{
if(pdata)
{
if(byte == 0)
byte = '\n';
pdata->m_critSec.Lock();
if (byte == '\n' && lastByte != '\r')
pdata->push_back('\r');
pdata->push_back( byte);
lastByte = byte;
pdata->m_critSec.Unlock();
if(byte == '\r' || byte == '\n')
pWnd->PostMessage(MSG_PROGRESSDLG_UPDATE_UI,MSG_PROGRESSDLG_RUN,0);
}
else
pWnd->PostMessage(MSG_PROGRESSDLG_UPDATE_UI,MSG_PROGRESSDLG_RUN,byte);
}
if (pdata)
{
pdata->m_critSec.Lock();
bool post = !pdata->empty();
pdata->m_critSec.Unlock();
if (post)
EnsurePostMessage(pWnd, MSG_PROGRESSDLG_UPDATE_UI, MSG_PROGRESSDLG_RUN, 0);
}
//.........这里部分代码省略.........