본문 바로가기
개발/WIN32-MFC

[WIN32] 터미널 환경 체크방법

by -=HaeJuK=- 2015. 6. 15.

WIN32 API를 이용하여 터미널 환경 체크하기

WIN32 API인 GetsystemMetrics()를 이용하여 터미널 환경임을 체크해 봅시다.

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsystemmetrics

CODE

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
bool GetTerminalServiceClientStatus()
{
    bool bResult = false;
 
    if(0 == ::GetSystemMetrics(SM_REMOTESESSION))
    { 
        bResult =  false
    }
    else 
    { 
        bResult = true
    }
    return success;
}
 
int main(int argc, CHAR* argv[])
{
    while(true)
    {
        printf("Detect Remote DeskTop %d\r\n",GetTerminalServiceClientStatus());
        Sleep(1000);
    }
    return 0;
}
cs

 

총평

::GetSystemMetrics() 함수를 이용하여 REMOTESESSION에서 현재 프로그램이 실행 중인지 여부를 판단 할 수 있습니다.
"가상환경"로 검출이 가능하지만 가상화 솔루션의 제작 방식에 따라서 다르게 동작 할 수 있습니다. 

반응형