新手 求实现多线程的例程 我现在一个程序 需要实现8个串口同时通讯 而且彼此不影响有人告诉我需要用多线程来实现但本人从来没有用过求个相关例程来研究下 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 #include <windows.h>#include <conio.h>DWORD WINAPI ThreadFunc( LPVOID lpParam ) { char szMsg[80]; wsprintf( szMsg, "Parameter = %d.", *(DWORD*)lpParam ); MessageBox( NULL, szMsg, "ThreadFunc", MB_OK ); return 0; } VOID main( VOID ) { DWORD dwThreadId, dwThrdParam = 1; HANDLE hThread; char szMsg[80]; hThread = CreateThread( NULL, // default security attributes 0, // use default stack size ThreadFunc, // thread function &dwThrdParam, // argument to thread function 0, // use default creation flags &dwThreadId); // returns the thread identifier // Check the return value for success. if (hThread == NULL) { wsprintf( szMsg, "CreateThread failed." ); MessageBox( NULL, szMsg, "main", MB_OK ); } else { _getch(); CloseHandle( hThread ); }} 请问如何保证只有一个进程读写数据库? 如何在vs2008中添加消息响应函数 Tab Control中的标签不显示 为什么这段代码的运行结果是不能在editbox里显示信息呢 有关位图背景透明的问题??????? 如何在Edit控件中限制输入为英文字符(在中文输入法下)? API HOOK的致命疑问! 取得网卡地址 关于CFormView的问题,请大家帮忙,谢谢 请问怎么判断一个连接已断开 网络编程 谁有MAPX的中文版教程啊 给个 谢谢了
#include <conio.h>DWORD WINAPI ThreadFunc( LPVOID lpParam )
{
char szMsg[80]; wsprintf( szMsg, "Parameter = %d.", *(DWORD*)lpParam );
MessageBox( NULL, szMsg, "ThreadFunc", MB_OK ); return 0;
}
VOID main( VOID )
{
DWORD dwThreadId, dwThrdParam = 1;
HANDLE hThread;
char szMsg[80]; hThread = CreateThread(
NULL, // default security attributes
0, // use default stack size
ThreadFunc, // thread function
&dwThrdParam, // argument to thread function
0, // use default creation flags
&dwThreadId); // returns the thread identifier
// Check the return value for success.
if (hThread == NULL)
{
wsprintf( szMsg, "CreateThread failed." );
MessageBox( NULL, szMsg, "main", MB_OK );
}
else
{
_getch();
CloseHandle( hThread );
}
}