DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Thread: thread id

  1. #1
    Stephen Toner Guest

    thread id


    Hi,
    I have been trying to integrate an application which uses PostThreadMessage
    to pass messages between the different layers. Now however I wish to pass
    a message to the main MFC application, and was wondering if this method could
    still be used. If so how can one find the thread ID for the primary thread
    running within the application.
    Thanks for any help,
    Stephen

  2. #2
    Jan Sears Guest

    Re: thread id

    Windows API provides a function

    DWORD GetCurrentThreadId();

    Or if you need a handle to the thread use..

    HANDLE GetCurrentThread(VOID);

    Parameters
    This function has no parameters.

    Return Values
    The return value is a pseudo handle for the current thread.

    Remarks
    A pseudo handle is a special constant that is interpreted as the current
    thread handle. The calling thread can use this handle to specify itself
    whenever a thread handle is required. Pseudo handles are not inherited by
    child processes.

    This handle has the maximum possible access to the thread object. For
    systems that support security descriptors, this is the maximum access
    allowed by the security descriptor for the calling process. For systems that
    do not support security descriptors, this is THREAD_ALL_ACCESS.

    The function cannot be used by one thread to create a handle that can be
    used by other threads to refer to the first thread. The handle is always
    interpreted as referring to the thread that is using it. A thread can create
    a "real" handle to itself that can be used by other threads, or inherited by
    other processes, by specifying the pseudo handle as the source handle in a
    call to the DuplicateHandle function.

    The pseudo handle need not be closed when it is no longer needed. Calling
    the CloseHandle function with this handle has no effect. If the pseudo
    handle is duplicated by DuplicateHandle, the duplicate handle must be
    closed.

    Requirements
    Windows NT/2000: Requires Windows NT 3.1 or later.
    Windows 95/98: Requires Windows 95 or later.
    Header: Declared in Winbase.h; include Windows.h.
    Library: Use Kernel32.lib.

    I hope this helps...

    Jan Sears


    "Stephen Toner" <toners5@hotmail.com> wrote in message
    news:3a5b17e1$1@news.devx.com...
    >
    > Hi,
    > I have been trying to integrate an application which uses

    PostThreadMessage
    > to pass messages between the different layers. Now however I wish to pass
    > a message to the main MFC application, and was wondering if this method

    could
    > still be used. If so how can one find the thread ID for the primary

    thread
    > running within the application.
    > Thanks for any help,
    > Stephen




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links