如何使用WINDOWS自带的线程池,我的环境是vc6.0,这个函数QueueUserWorkItem 提示错误?
解决方案 »
- 如何清除MFC中Static中已有的图像?
- 关于sqlite3源码中SQLITE_OMIT_WSD的问题,望大侠指点一下!
- ADO处理数据库有完全相同的记录时,查询删除出错,请问是什么问题
- 编译产生c1.exe什么原因?
- 打开记录集时为什么出现“无效的描叙符索引”错误?
- COM技术内幕P31的问题,请教高手:何谓“非虚拟继承”???
- 哪位兄弟知道有SQL SERVER 下载?版本不限,马上给分.
- CWebBrowse2编程入门级问题
- buffer too small!!
- 在同一个函数前半部分我修改某条数据库记录,然后关闭,接着进行一些其它处理,在函数后半部分,我重新打开数据库,能否读到改变后的记录?
- 一个关于线程池的问题
- 请教如何找出程序中哪一个线程池CPU占用率太高
Client: Requires Windows XP or Windows 2000 Professional.
Server: Requires Windows Server 2003 or Windows 2000 Server.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
you must add this:
#define _WIN32_WINNT 0x0500
before include windows.h
#include <clocale>
#include <ctime>
#include <iostream>
#include <vector>
#include <algorithm>
#include <winsock2.h>
#include <mswsock.h>int main(int argc,char **argv)
{
if(argc==2)
DefPort=atoi(argv[1]); InitializeCriticalSection(&csProtection);
SetUnhandledExceptionFilter(MyExceptionFilter);
SetConsoleCtrlHandler(ShutdownHandler,TRUE); hIocp=CreateIoCompletionPort(INVALID_HANDLE_VALUE,NULL,0,0); WSADATA data={ 0 };
WSAStartup(0x0202,&data); hListen=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if(INVALID_SOCKET==hListen)
{
ShutdownHandler(0);
}
SOCKADDR_IN addr={ 0 };
addr.sin_family=AF_INET;
addr.sin_port=htons(DefPort);
if(bind(hListen,reinterpret_cast<PSOCKADDR>(&addr),
sizeof(addr))==SOCKET_ERROR)
{
ShutdownHandler(0);
}
if(listen(hListen,256)==SOCKET_ERROR)
ShutdownHandler(0); SYSTEM_INFO si={ 0 };
GetSystemInfo(&si);
si.dwNumberOfProcessors<<=1; for(int i=0;i<si.dwNumberOfProcessors;i++)
{
QueueUserWorkItem(ThreadProc,hIocp,WT_EXECUTELONGFUNCTION);
}
....
}
#define _WIN32_WINNT 0x0500
before include windows.h
#include <clocale>
#include <ctime>
#include <iostream>
#include <vector>
#include <algorithm>
#include <winsock2.h>
#include <mswsock.h>
这个函数的地方,编译说QueueUserWorkItem和WT_EXECUTELONGFUNCTION这个不认
2、VC2003的windows.h中有这个函数的定义。
你可以升级一下SDK或用VS2003如果还不行就在stdafx.h文件的开头加入:
#ifndef WINVER
#define WINVER 0x0400
#endif#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endi
#ifndef _WIN32_WINDOWS
#define _WIN32_WINDOWS 0x0410
#endif