
本文共 2506 字,大约阅读时间需要 8 分钟。
������������������������������������������������������������
������������������������������������Win32 API������������������������������������������������������������������������������������������������������������������������������������
���������������
������������������������������������������������������������������������������������������������������������
test.h
���������������������������������������������������������������������test.cpp
������������������������������������������������������������������������������������������
1. ���������������
-
������������static������������������������
- ���
test.h
������static������������������������������������������������������������������������������������������
���������������
class Test {public: static void check(); static DWORD WINAPI Fun(LPVOID lpParamter);};
- ���
2. ���������������������
���main.cpp
������������CreateThread
������������������������������ startup routine���������������������������������������������_lpThreadId��������� ID���������������������������������������������������0������������������������������������������0������
���������
HANDLE hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Test::Fun, &test, 0, NULL);
������������������������������������������������������Test::Fun
������������������������������������������Test������������������������������������
3. ���������������������������
���test.cpp
������������������������������������������������������������ ���������������
Test *plocal = (Test*)lpParamter;plocal->check();
4. ���������������������������������
������GetLastError
������������������������������������������������
if (hThread == NULL) { int lastError = GetLastError(); cout << "���������������������������������" << lastError << endl;}
���������������������
- ���������������Windows 10 ��� newer
- ���������������Visual Studio ��� MinGW-w64
- ������������������
<windows.h>
���<iostream>
������������
���������������������
- ������������������
0 : Main Thread Display!
- ������������������
0 : Fun A Thread Fun Display!!
���������������������������������������������������������������������
���������������
- ������������������������������������������������
- ������������Test���������������
static
���������������������- ������������������������ DWORD������������0������������������
���������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
