衡玉's Blog

Happy coding

MFC的dll中创建子线程,并发送消息

衡玉 posted @ 2010年2月21日 22:50 in windows 服务编程 , 3013 阅读

 ATL创建的windows服务,只是负责控制,而将业务逻辑放在mfc的dll中,建立线程后,在发送消息,代码如下

 

extern "C" __declspec(dllexport) void _DllMain()
{
	unsigned nThreadId;
	HANDLE hThread = (HANDLE)_beginthreadex(NULL,0, &ThreadMain,NULL, 0, &nThreadId);
	Sleep(1000);
	PostThreadMessage(nThreadId, WM_TIMEISUP, NULL, NULL);
}

unsigned __stdcall ThreadMain(LPVOID pParam)
{
	MSG msg;
	while(true){
		if(::GetMessage(&msg, NULL, NULL, NULL)) {
			switch(msg.message){
				case WM_TIMEISUP:
				{
					Download d;
					break;
				}
				default:
					break;
			}
		}
	};
	
	/*
	MSG msg;
	while(::PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE)) {
		switch(msg.message) {
			case WM_TIMEISUP:
			{
				Download d;
				break;
			}
			default:
				break;
		}
	}*/
	return 0;
}

 

 

Avatar_small
Uttarakhand Board Qu 说:
2022年8月29日 21:15

UK Board 10th Previous Question Paper are very important for the Preparation of Public Exam of UBSE for the Students. 10th Students of can easily get their Latest and most valuable Mock Test Paper from this website. Uttarakhand Board Question Paper Students only have to Download the UBSE 10th Mock Test Paper 2023 for all the important subjects are available Including the Hindi, English, Social Science, Mathematics, Science, Home Science, Sanskrit, Painting etc. Boardmodelpaper.com Provide UBSE Board 10th Class Latest and Last Year Exam Study Material for Syllabus, Question Paper etc, Hindi, English Medium Pdf Format.

Avatar_small
Word to Pdf 说:
2022年12月24日 18:05

Microsoft Word, one of the most popular Office tools, may be used to produce reports, letters, apps, e-books, and even forms. Would you like to convert Word to PDF using office tools? This simple guide helps you to learn how to convert MS Word to PDF or XPS format on Windows, macOS, and iOS devices. Word to Pdf Utilizing an online converter is the most practical approach to converting Word to PDF if you need to convert a smaller number of Documents.

Avatar_small
10th Question Paper 说:
2023年2月15日 17:57

10th Question Paper 2024 is Get Available by the Board of Secondary Education. The Model Question Paper for class 10th will deliver in online mode on the authority site. The Model Paper will comprise of the subject-wise New Question Paper, day, timings, 10th Question Paper 2024 and significant guidelines for test day. In this article, the up-and-comer will get the data about the 10th Class Latest Question Paper 2024 including delivering PDF and how to download the Latest Question Paper.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter