互斥量和查用户权限
STDMETHODIMP CSoftCheck::CheckUserAccount(BOOL *isAol)
{
long rtVal = 0;
HKEY hKey = 0;
rtVal = RegCreateKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\HaHaHa"),0,REG_NONE, REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hKey,NULL);
if (rtVal != ERROR_SUCCESS)
{
*isAol = FALSE;
}else
{
rtVal = RegDeleteKey(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\HaHaHa"));
if (rtVal != ERROR_SUCCESS)
{
*isAol = FALSE;
}else
{
*isAol = TRUE;
}
}
return S_OK;
}
STDMETHODIMP CSoftCheck::CheckRun(BSTR updateName, BOOL *isRun)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
HANDLE hMutex = CreateMutexW(NULL, FALSE, updateName);
m_isOk = hMutex;
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
*isRun = FALSE;
}else
{
*isRun = TRUE;
}
return S_OK;
}
runas可以提升权限吗?
http://www.cctry.com/forum.php?mod=viewthread&tid=231702&page=1#pid1023033
EnableDebugPrivilge(SE_DEBUG_NAME,TRUE);