求助:createevent的用法

zhangliangli 2009-03-03 10:44:53
请问:在用CreateThread创建了一个线程之后要用CreateEvent创建一个事件需要怎么去做?
给点具体的例子!
...全文
226 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
千山飞鸟绝 2009-05-26
  • 打赏
  • 举报
回复
路过。
yangangs 2009-05-26
  • 打赏
  • 举报
回复
妖哥说的对,怎么把VC的头文件弄到BCB了
hxfjb 2009-03-08
  • 打赏
  • 举报
回复
代码是没有错的。
ccrun.com 2009-03-04
  • 打赏
  • 举报
回复
0分帖?本人专治各类0分帖。

楼上的代码不是运行错,而是编译错吧。stdafx.h是VC中的头文件,你在C++Builder中编译,当然找不到头文件了。把第一行去掉即可。
zhangliangli 2009-03-03
  • 打赏
  • 举报
回复
#include "stdafx.h"
#include<stdio.h>
#include<windows.h>
#include<iostream>
int _tmain(int argc, _TCHAR* argv[])
{
HANDLE hEvent = NULL;
hEvent = CreateEvent(NULL,FALSE,FALSE,"MyShare");

if(GetLastError()==ERROR_ALREADY_EXISTS)
{
printf("已经有一个事件在运行\r\n");
CloseHandle(hEvent);
hEvent=NULL;

return -1;
}

else
{
printf("只有一个事件在运行\r\n");


}
printf(("Last Error Code %d"),GetLastError());
printf("Wait For Press\n");

return 0;
}
这个运行也出错了?

1,221

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧