书上有这么一段话: 一些 windows 函数调用成功可能是缘于不同的原因。例如,创建一个具名事件内核对象时,以下两种情况均会成功:对象实际完成创建,或者存在另一个同名的事件内核对象。应用程序也许需要知道成功的原因。为返回这种信息,Microsoft 选择采用“上一个错误代码”(last error code)机制。所以,特定函数调用成功时,可以调用 GetLastError 来确定额外的信息。对于具有这种行为的函数,Platform SDK 文档会清楚指明能以这种方式调用 GetLastError 。文档中提供了 CreateEvent 函数的一个例子;如果已经存在具名事件,就返回 ERROR_ALREADY_EXISTS。
解决方案 »
- CString为什么被高级程序员唾弃?
- [求助]完成端口,10053错误。 如果发送方速度大于接收方就会有这个错误
- 什么情况下会出现对话框关闭了,但程序没结束?
- 看了VC技术内幕中的COM部分,不是太明白,求一些COM的资料?另再问MFC中关加解密,信息摘要,数字签名的几个类?谢谢,在线等。
- 为什么不能加载"Psapi.dll",求助
- 如何将一个网站名转为IP地址啊?
- 调用WIN32 DLL内的函数出错,怪怪怪!!!急急急!!!
- tcl/tk 与C程序的问题!送上100分!
- CString 转成 int类型?
- 使用detours在win7 64位下会漏抓部分函数的问题
- 我现在有个图片的路径,如何将图片显示到picture control 上
- 怎么用NetShareAdd指定共享权限
__in_opt LPSECURITY_ATTRIBUTES lpEventAttributes,
__in BOOL bManualReset,
__in BOOL bInitialState,
__in_opt LPCTSTR lpName
);lpName
The name of the event object. The name is limited to MAX_PATH characters. Name comparison is case sensitive. If lpName matches the name of an existing named event object, this function requests the EVENT_ALL_ACCESS access right. In this case, the bManualReset and bInitialState parameters are ignored because they have already been set by the creating process. If the lpEventAttributes parameter is not NULL, it determines whether the handle can be inherited, but its security-descriptor member is ignored. If lpName is NULL, the event object is created without a name.If lpName matches the name of an existing semaphore, mutex, waitable timer, job, or file-mapping object, the function fails and the GetLastError function returns ERROR_INVALID_HANDLE. This occurs because these objects share the same name space.The name can have a "Global\" or "Local\" prefix to explicitly create the object in the global or session name space. The remainder of the name can contain any character except the backslash character (\). For more information, see Kernel Object Namespaces. Fast user switching is implemented using Terminal Services sessions. Kernel object names must follow the guidelines outlined for Terminal Services so that applications can support multiple users.Windows 2000: If Terminal Services is not running, the "Global\" and "Local\" prefixes are ignored. The remainder of the name can contain any character except the backslash character.
The object can be created in a private namespace. For more information, see Object Namespaces.
LPSECURITY_ATTRIBUTES lpEventAttributes, // SD
BOOL bManualReset, // reset type
BOOL bInitialState, // initial state
LPCTSTR lpName // object name
);新建一个事件,名字可以有两种方式,一种是给名称,一种是不给名称
CreateEvent(NULL,FALSE,FALSE,"Object"); // 具名对象
CreateEvent(NULL,FALSE,FALSE,NULL);