标题:windows线性编程
取消只看楼主
qkhhss
Rank: 1
等 级:新手上路
帖 子:10
专家分:5
注 册:2010-11-11
结帖率:100%
已结贴  问题点数:10 回复次数:0 
windows线性编程
#include <iostream>
#include <windows.h>
using namespace std;

/*
HANDLE WINAPI CreateThread
{
       LPSECURITY_ATTRIBUTES ipThreadAttributes,
       SIZE_T dwStackSize,
       LPTHREAD_STRAT_ROUTINE lpStartAddress,
       LPVOID lpParameter,
       DWORD dwCreateFlags,
       LPDWORD lpThreadId
}
*/

DWORD WINAPI MyThreadStart(LPVOID);

int main()
{
    HANDLE hThread;
    DWORD dwThreadId;
   
    hThread = CreateThread(
              NULL,
              0,
              &MyThreadStart,
              "Hello, World",
              0,
              &dwThreadId);
    if (!hThread)
    {
           cout << "Thread Create error:" << GetLastError() << endl;
           system("pause");     
    }
    cout << GetCurrentThreadId() << ": Create thread " << hThread
         << dwThreadId << endl;
         
    //等待线程退出
    WaitForSingleObject(hThread, INFINITE);
   
    DWORD dwExitCode;
    GetExitCodeThread(hThread, &dwExitCode);
   
    cout << GetCurrentThreadId() << ":Thread exited: " << dwExitCode;
   
    CloseHandle(hThread);
    system("pause");
    return 0;
}

DWORD WINAPI MyThreadStart(LPVOID lpParameter)
{
      cout << GetCurrentThreadId() << ": "
           << reinterpret_cast< char* >(lpParameter);
           return 0;
}
30 E:\线性编程\CreateThread.cpp invalid conversion from `const void*' to `void*'
30 E:\线性编程\CreateThread.cpp   initializing argument 4 of `void* CreateThread(_SECURITY_ATTRIBUTES*, DWORD, DWORD (*)(void*), void*, DWORD, DWORD*)'
搜索更多相关主题的帖子: windows 线性 
2010-11-24 20:08



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-326775-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.281293 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved