728x90

C 4

C++ Microsecond Delay (Windows)

리눅스는 Delay API가 제공되는 것으로 알고 있다. 윈도우는 Delay API가 제공되지 않는다. Sleep API는 제공이 된다. 하지만 Sleep과 Delay는 엄연히 다르다. Sleep은 Context Switching을 일으키기 때문이다. 또한 Sleep의 파라미터는 Millisec 단위 인데 Sleep(1) 을 한다고 정확히 1 ms 를 쉬는것은 아니다 (약 10 ms 정도? 이는 CPU마다 다른것으로 알고잇다.) 잡설이 길었다. Windows에서 Microsecond 단위까지 Delay 를 줄 수 있게 QueryPerformanceCounter를 이용하여 간단히 함수를 만들었다. #include static float g_Frequency; QueryPerformanceFrequency(..

dev 2017.08.04

모니터 해상도 구하기

모니터 해상도 구하기 GetWindowRect(), GetDesktopWindow() CRect rc; ::GetWindowRect(GetDesktopWindow()->m_hWnd, &rc); int nWidth = rc.right - rc.left; int nHeight = rc.bottom - rc.top; GetSystemMetrics() int nWidth = GetSystemMetrics(SM_CXSCREEN); int nHeight = GetSystemMetrics(SM_CYSCREEN); GetDeviceCaps() HDC hDC = GetDC(); // 가져오는 HDC에 따라 듀얼모니터의 해상도도 가져올 수 있음 int nWidth = GetDeviceCaps(hDC, HORZRES); i..

dev/visual c++ 2017.07.21
728x90