1. 程式人生 > >VC++ 執行緒例項

VC++ 執行緒例項

test.h

class{
public:
    static DWORD WINAPI DoScanRdpWeakPwdProcess(LPVOID lpParam);
}

test.cpp

函式(){
    HANDLE thread_listening_rdp = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)CScanWeakPasswd::DoScanRdpWeakPwdProcess, this, 0, NULL);
}

DWORD WINAPI CScanWeakPasswd::DoScanRdpWeakPwdProcess(LPVOID lpParam)
{
    CScanWeakPasswd* pScanWeakPwd = (CScanWeakPasswd*)lpParam;
	while (1)
	{
		Sleep(10);
		//HWND hWnd = ::FindWindow(NULL, "test999");
		//if (hWnd)
		//{
		//	bRDP = true;
		//	PostMessage(hWnd, WM_QUIT, 0, 0);
		//}

		HWND hWnd = ::FindWindow(NULL, "Remote Desktop Security");
		if (hWnd)
		{
			PostMessage(hWnd, WM_QUIT, 0, 0);
		}
	}

	return 0;
}