how send parameters on CreateThread()?
on a class:
Option Explicit
Private Declare Function CreateThread Lib "kernel32" (lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadID As Long) As Long
Private Declare Function TerminateThread Lib "kernel32" (ByVal hThread As Long, ByVal dwExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private hThreadID As Long
Private hThread As Long
Public Sub Execute(FunctionName As Long, Optional parameters As Long = 0)
hThread = CreateThread(ByVal 0&, 0&, FunctionName, ByVal parameters, 0&, hThreadID)
End Sub
on module:
Option Explicit
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Sub Test(parameters As Long)
Dim s As String
CopyMemory s, ByVal parameters, Len(parameters)
Debug.Print s
End Sub
on form1:
Option Explicit
Dim s As Multithread
Private Sub Command1_Click()
Set s = New Multithread
Dim nome As String
nome = "Joaquim"
s.Execute AddressOf Test, StrPtr(nome)
End Sub
my problem is how i send parameters on CreateThread() function and get it.