网站首页  词典首页

请输入您要查询的函数:

 

术语 postthreadmessage
释义 PostThreadMessage
语法:
BOOL PostThreadMessage( DWORD idThread,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);
PostThreadMessage函数
PostThreadMessage函数的职位是对指定的线程消息队列消息。它返回而不等待线程处理消息。
参数
idThread
[in]的线程的消息是标识符被张贴。
函数失败如果指定的线程没有消息队列。该系统创建一个线程的消息队列当线程在作出第一次调用的用户或GDI的职能之一。有关详细信息,请参见备注部分。
微软Windows Vista和later.Message张贴受用户界面特权隔离(UIPI)。一个进程的线程才能张贴讯息只公布的线程消息队列在较低Level或等于完整过程。
视窗2000/XP的:这个线程必须要么属于作为调用线程,或具有相同本地唯一标识符(的LUID)的过程相同的桌面。否则,函数失败并返回ERROR_INVALID_THREAD_ID。
Windows Server 2003的SP1的:这个线程必须有SE_TCB_NAME特权张贴消息的线程属于一个相同的本地唯一标识符(的LUID)进程,但在不同的桌面。否则,函数失败并返回ERROR_INVALID_THREAD_ID。
消息
[in]指定消息的类型被张贴。
wParam
[in]指定附加消息的特定信息。
lparam的
[in]指定附加消息的特定信息。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。 GetLastError返回ERROR_INVALID_THREAD_ID如果idThread不是有效的线程标识符,或由idThread指定的线程没有消息队列。
备注
微软Windows Vista和更高版本。当一条消息封锁UIPI最后一个错误,与GetLastError函数检索,设置为5(拒绝访问)。
在何种信息发布必须已经创建了一个消息队列,否则对PostThreadMessage调用线程失败。使用下列方法之一来处理这种情况。
呼叫PostThreadMessage。如果失败,调用Sleep函数和调用PostThreadMessage了。重复,直到PostThreadMessage成功。
创建一个事件对象,然后创建线程。使用WaitForSingleObject函数等待该事件被设置在调用PostThreadMessage的信号状态。在以该消息将公布,请PeekMessage如下所示强制系统创建消息队列线程。
PeekMessage(&味精,空,WM_USER,WM_USER,PM_NOREMOVE)设置事件,表明该线程准备接收发布消息。
在何种信息检索张贴线程通过调用GetMessage或PeekMessage函数的消息。返回的MSG结构hWnd成员为NULL。
PostThreadMessage发送的消息不与一个窗口关联。作为一般规则,消息不与一个窗口可以不受DispatchMessage函数调度。因此,如果收件人线程在模式循环(由这些URL或DialogBox使用),邮件都将丢失。拦截线程信息,同时在模式循环,使用线程具体挂钩。
该系统不仅为系统消息编组(范围为0至(WM_USER -1))的。其他消息发送(即“= WM_USER)到另一个进程,则必须自定义编组。
视窗2000/XP的:有一个限制的10000每发布消息队列的消息。这个限制应足够大。如果您的申请一旦超过限额,应重新设计,以避免消耗太多的系统资源。若要调整此限制,修改以下注册表项。
HKEY_LOCAL_MACHINE
软件
微软
视窗新技
CurrentVersion
视窗
USERPostMessageLimit
可接受的最低值为4000。
在Windows 95/98/Me:PostThreadMessageW是支持的Unicode(MSLU)微软层。要使用此,您必须将某些文件到您的应用,概述了对Unicode的Microsoft层在Windows 95/98/Me系统。
功能信息
最低DLL版本 user32.dll
在Winuser.h中HeaderDeclared,头文件:winuser.h
import libraryUser32.lib
最低操作系统Windows 95,Windows NT 3.1
UnicodeImplemented为ANSI和Unicode版本。
参见
消息和消息队列概述,GetCurrentThreadId,GetMessage,GetWindowThreadProcessId,味精,PeekMessage,PostMessage,睡眠,WaitForSingleObject
==英文原文==PostThreadMessage Function
The PostThreadMessage function posts a message to the message queue of the specified thread. It returns without waiting for the thread to process the message.
Syntax
BOOL PostThreadMessage( DWORD idThread,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);
Parameters
idThread
[in] Identifier of the thread to which the message is to be posted.
The function fails if the specified thread does not have a message queue. The system creates a thread's message queue when the thread makes its first call to one of the User or GDI functions. For more information, see the Remarks section.
Microsoft Windows Vista and later.Message posting is subject to User Interface Privilege Isolation (UIPI). The thread of a process can post messages only to posted-message queues of threads in processes of lesser or equal integrity level.
Windows 2000/XP: This thread must either belong to the same desktop as the calling thread or to a process with the same locally unique identifier (LUID). Otherwise, the function fails and returns ERROR_INVALID_THREAD_ID.
Windows Server 2003 SP1: This thread must have the SE_TCB_NAME privilege to post a message to a thread that belongs to a process with the same locally unique identifier (LUID) but is in a different desktop. Otherwise, the function fails and returns ERROR_INVALID_THREAD_ID.
Msg
[in] Specifies the type of message to be posted.
wParam
[in] Specifies additional message-specific information.
lParam
[in] Specifies additional message-specific information.
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError . GetLastError returns ERROR_INVALID_THREAD_ID if idThread is not a valid thread identifier, or if the thread specified by idThread does not have a message queue.
Remarks
Microsoft Windows Vista and later. When a message is blocked by UIPI the last error, retrieved with GetLastError, is set to 5 (access denied).
The thread to which the message is posted must have created a message queue, or else the call to PostThreadMessage fails. Use one of the following methods to handle this situation.
Call PostThreadMessage. If it fails, call the Sleep function and call PostThreadMessage again. Repeat until PostThreadMessage succeeds.
Create an event object, then create the thread. Use the WaitForSingleObject function to wait for the event to be set to the signaled state before calling PostThreadMessage. In the thread to which the message will be posted, call PeekMessage as shown here to force the system to create the message queue.
PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE)Set the event, to indicate that the thread is ready to receive posted messages.
The thread to which the message is posted retrieves the message by calling the GetMessage or PeekMessage function. The hwnd member of the returned MSG structure is NULL.
Messages sent by PostThreadMessage are not associated with a window. As a general rule, messages that are not associated with a window cannot be dispatched by the DispatchMessage function. Therefore, if the recipient thread is in a modal loop (as used by MessageBox or DialogBox ), the messages will be lost. To intercept thread messages while in a modal loop, use a thread-specific hook.
The system only does marshalling for system messages (those in the range 0 to ( WM_USER -1)). To send other messages (those >= WM_USER) to another process, you must do custom marshalling.
Windows 2000/XP: There is a limit of 10,000 posted messages per message queue. This limit should be sufficiently large. If your application exceeds the limit, it should be redesigned to avoid consuming so many system resources. To adjust this limit, modify the following registry key.
HKEY_LOCAL_MACHINE
SOFTWARE
Microsoft
Windows NT
CurrentVersion
Windows
USERPostMessageLimit
The minimum acceptable value is 4000.
Windows 95/98/Me: PostThreadMessageW is supported by the Microsoft Layer for Unicode (MSLU). To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems .
Function Information
Minimum DLL Versionuser32.dll
HeaderDeclared in Winuser.h, include Windows.h
Import libraryUser32.lib
Minimum operating systemsWindows 95, Windows NT 3.1
UnicodeImplemented as ANSI and Unicode versions.
See Also
Messages and Message Queues Overview , GetCurrentThreadId , GetMessage , GetWindowThreadProcessId , MSG , PeekMessage , PostMessage , Sleep , WaitForSingleObject
==原始网址==http://msdn.microsoft.com/en-us/library/ms644946(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:26:25