+ Reply to Thread
Results 1 to 2 of 2

Thread: How to name a thread in VC++?

  1. #1

    How to name a thread in VC++?

    How to name a thread in VC++?

  2. #2
    Senior Member
    Join Date
    Feb 2012
    Posts
    109
    Following is the example:

    Code:
    typedef struct tagTHREADNAME_INFO
    {
    	DWORD dwType; // must be 0x1000
    	LPCSTR szName; // pointer to name (in user addr space)
    	DWORD dwThreadID; // thread ID (-1=caller thread)
    	DWORD dwFlags; // reserved for future use, must be zero
    } THREADNAME_INFO;
    
    void SetThreadName(DWORD dwThreadID, LPCSTR szThreadName)
    {
    	THREADNAME_INFO info;
    	info.dwType = 0x1000;
    	info.szName = szThreadName;
    	info.dwThreadID = dwThreadID;
    	info.dwFlags = 0;
    	
    	__try
    	{
    		RaiseException( 0x406D1388, 0, sizeof(info)/sizeof(DWORD), (DWORD*)&info );
    	}
    	__except(EXCEPTION_CONTINUE_EXECUTION)
    	{
    	}
    }
    Note:
    Now you can use Visual Studio IDE Debug->Threads. You should find the name of the thread in the list.

    Useful Link:
    http://blogs.msdn.com/b/stevejs/arch...19/505815.aspx

+ Reply to Thread

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