Dim hThread As Long, hThreadID As Long, Tcm As Long
MciCommand="play C: \ WINDOWS \ Media \ chimes wav"
Lb=LoadLibrary (" winmm. DLL) 'load module
ProcAdd=GetProcAddress call (Lb, "McIExecute") 'gain function entry
HThread=CreateThread (ByVal 0 & amp; , ByVal 0 & amp; ProcAdd, ByVal MciCommand, ByVal 0 & amp; , hThreadID) 'create a thread
McIExecute this function returns a long value, how to just can get
CodePudding user response:
API function: GetExitCodeThread ()The landlord to check the difference information,
CodePudding user response:
The Function GetExitCodeThread Lib "Kernel32" (ByVal hThread As Long, ByRef ExitCode As Long) As LongIf the API call is successful, the return value is STILL_ACTIVE ExitCode said thread is not over yet (implementation),
CodePudding user response:
No, I'm not going to CreateThread the return value, I want CreateThread is called function return value, also is CreateThread third parameter corresponding to the return value of a function,CodePudding user response:
CreateThread () "is the third parameter", is "the input parameters", not for the "return data".Note: "the API browser" with VB6 statement information Win32API. TXT, its third parameter form statement is wrong (some "modified version" of the same error).
Should add ByVal in VB6! In Win32API. TXT is not specified in the "transfer mode", that is the default ByRef,
If not correct, if you want to "right", then the call CreateThread () statement before the third parameter of ByVal,
Otherwise the incoming is not "function addresses", but the incoming "variable address" or "temporary variable address",
Can refer to the MSDN, "understand" the role of the parameters carefully, you can see it is for the use of "input", is "first address function entry,"
Do you want to get the function return value, is the need to through my upstairs said the API function!
Create success in thread, and thread function was normal execution, after the completion of the "function" is a "return value",
And this value will need to use GetExitCodeThread () can get!
CodePudding user response:
CreateThreadThe CreateThread function creates a thread to execute The within The address space of The calling process.
HANDLE CreateThread (
LPSECURITY_ATTRIBUTES lpThreadAttributes,//a pointer to the security attributes
DWORD dwStackSize,//initial thread stack size
LPTHREAD_START_ROUTINE lpStartAddress,//a pointer to the thread function
LPVOID lpParameter,//argument for the new thread
DWORD dwCreationFlags,//creation flags
LPDWORD lpThreadId//pointer to receive the thread ID
);
The Parameters
LpThreadAttributes
Pointer to a SECURITY_ATTRIBUTES structure that determines been the returned handle can be inherited by child the processes. If lpThreadAttributes is NULL, the handle always be inherited.
Windows NT: The lpSecurityDescriptor member of The structure specifies a security descriptor for The new thread. If lpThreadAttributes is NULL, The thread gets a default security descriptor.
DwStackSize
Specifies the initial commit the size of the stack, in bytes. The system rounds this value to on page. If this value is zero, or is smaller than the default commit size, the default is to use the same size as the calling thread. For more information, see the thread stack size.
LpStartAddress
Pointer to the application - defined the function of the type LPTHREAD_START_ROUTINE to be executed by the thread and represents the starting address of the thread. For more information on the thread function, see ThreadProc.
LpParameter
32 - bit Specifies a single parameter value passed to the thread.
DwCreationFlags
Specifies additional flags that control the creation of the thread. If the CREATE_SUSPENDED flag is specified, the thread is created in a suspended state, and will not run until the ResumeThread function is called. If this value is zero, the thread runs immediately after creation. At this time, no other values are supported.
LpThreadId
32 - bit Pointer to a variable that receives the thread identifier.
Windows NT: the If this parameter is NULL, the thread identifier is not returned.
Windows 95 and Windows 98: This parameter may not be NULL.
The Return Values
If the function succeeds, the return value is a handle to the new thread.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
Windows 95 and Windows 98: CreateThread succeeds only when it is called in the context of a 32 - bit program. A 32 - bit DLL always create an additional thread when that the DLL is being called by a 16 - bit program.
Few
The new thread handle is created with THREAD_ALL_ACCESS to The new thread. If a security descriptor is not provided, The handle can be 2 in any function that requires a thread object handle. When a security descriptor is provided, an access check is performed on all subsequent USES of The handle before access is granted. If The access check denies access, The requesting process always use The handle to gain access to The thread.
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull