Created
September 23, 2014 07:10
-
-
Save zxlooong/26a5a67ea67fc574b80f to your computer and use it in GitHub Desktop.
windows 相关操作
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BOOL CWyPassEdit::IsAdministrator() | |
{ | |
//判断是否管理员模式 | |
BOOL bIsElevated = FALSE; | |
HANDLE hToken = NULL; | |
UINT16 uWinVer = LOWORD(GetVersion()); | |
uWinVer = MAKEWORD(HIBYTE(uWinVer),LOBYTE(uWinVer)); | |
if (uWinVer < 0x0600)//不是VISTA、Windows7 | |
{ | |
bIsElevated = TRUE; | |
return bIsElevated; | |
} | |
if (OpenProcessToken(GetCurrentProcess(),TOKEN_QUERY,&hToken)) | |
{ | |
DWORD TokenIsElevated; | |
DWORD dwReturnLength = 0; | |
if (GetTokenInformation(hToken,/*TokenElevation*/(_TOKEN_INFORMATION_CLASS)20,&TokenIsElevated,sizeof(DWORD),&dwReturnLength)) | |
{ | |
if (dwReturnLength == sizeof(DWORD)&&(TokenIsElevated == 1)) | |
bIsElevated = TRUE; | |
} | |
CloseHandle( hToken ); | |
hToken = NULL; | |
} | |
return bIsElevated; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BOOL CWyPassEdit::IsIE() | |
{ | |
BOOL bIE = TRUE; | |
char szFileFullPath[256] = {0}; | |
::GetModuleFileNameA(NULL,static_cast<LPSTR>(szFileFullPath),256); | |
if(std::strstr(szFileFullPath, "iexplore.exe") == NULL) | |
{ | |
bIE = FALSE; | |
} | |
return bIE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment