Click to Rate and Give Feedback
MSDN
MSDN Library
User Interface
Windows Shell
Shell Reference
Miscellaneous
 SHCreateThread Function

  Switch on low bandwidth view
SHCreateThread Function

Creates a thread.

Syntax

BOOL SHCreateThread(      
    LPTHREAD_START_ROUTINE pfnThreadProc,     void *pData,     SHCT_FLAGS dwFlags,     LPTHREAD_START_ROUTINE pfnCallback );

Parameters

pfnThreadProc
[in] A pointer to an application-defined function of the LPTHREAD_START_ROUTINE type. If a new thread was successfully created, this application-defined function is called in the context of that thread. SHCreateThread does not wait for the function pointed to by this parameter to complete before returning to its caller. The application-defined function's return value is the exit code of the thread.
pData
[in] A pointer to an optional application-defined data structure that contains initialization data. It is passed to the function pointed to by pfnThreadProc and, optionally, pfnCallback. This value can be NULL.
dwFlags
[in] The flags that control the behavior of the function. One or more of the CTF constants.
pfnCallback
[in] A pointer to an optional application-defined function of the LPTHREAD_START_ROUTINE type. This function is called in the context of the created thread before the function pointed to by pfnThreadProc is called. It will also receive pData as its argument. SHCreateThread will wait for the function pointed to by pfnCallback to return before returning to its caller. The return value of the function pointed to by pfnCallback is ignored.

Return Value

Returns TRUE if the thread is successfully created, or FALSE otherwise.

Remarks

The function pointed to by pfnThreadProc and pfnCallback must take the following form.

DWORD WINAPI ThreadProc(LPVOID pData)
{
  ...
}

The function name is arbitrary. The pData parameter points to an application-defined data structure with initialization information.

Function Information

Minimum DLL Versionshlwapi.dll version 5.0 or later
Custom ImplementationNo
Headershlwapi.h
Import libraryshlwapi.lib
Minimum operating systems Windows 2000, Windows NT 4.0 with Internet Explorer 5, Windows 98, Windows 95 with Internet Explorer 5

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
this function set the last error on failure      Chris_Guzak   |   Edit   |   Show History
use GetLastError() in the failure case



if (!SHCreateThread(...))
{
hr = HRESULT_FROM_WIN32(GetLastError());
}
else
{
....
}
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker