Passing a parameter to CreateThread
Date : March 29 2020, 07:55 AM
should help you out The problem here is that your thread function has the wrong calling convention. You need to declare it with the stdcall convention: function ThreadProc(param: Pointer) : DWORD; stdcall;
type
TBlah = class(TThread)
protected
procedure Execute; override;
public
fe: Integer;
end;
procedure TBlah.Execute;
begin
ShowMessage(IntToStr(fe));
end;
var
b: TBlah;
begin
b := TBlah.Create(True);
b.fe := 42;
b.Start;
b.WaitFor;
end.
|
multiple arguments to CreateThread function
Date : March 29 2020, 07:55 AM
seems to work fine You can create a structure that holds all relevant data and pass a pointer to an instance of that structure (filled with the appropriate parameters) to CreateThread() In your thread creation function you will need to cast the LPVOID back to a pointer to your structure to use it.
|
C - Passing struct addresses as function arguments
Date : March 29 2020, 07:55 AM
may help you . &planet->distance is actually evaluated as &(planet->distance), so means taking address of the member of the structure, which scanf() requires for updating that member with input value.
|
Passing struct argument to CreateThread() and not receiving char* variable
Tag : cpp , By : cmhudson
Date : March 29 2020, 07:55 AM
I wish this helpful for you Assuming you set 'chunk' in the initialize data code then the pointer in the remote address space will be referencing the address in the local process. The easy way to get around this would be to make chunk an array (probably the last member of the struct) and allocate a block large enough to hold chunk's data.
|
Win32 CreateThread() Arguments Zero'ed?
Tag : cpp , By : protagonist
Date : March 29 2020, 07:55 AM
|