| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 516 人关注过本帖
标题: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
快速回复:windows线性编程
数据加载中...
 
   



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

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