Passing Variable Array in Non-Var parameters?

Hello, I want to pass an Array in EnumWindows function. When I make change to the array in EnumFunc it is not updated to the original array because I cannot make it pass as a VAR parameters. Do you have any idea how can I change the original array directly?

[code]
Function EnumFunc (ParentHwnd: hwnd; ThreadListR:lparam):Bool;stdcall;
Var
ThreadList:Array of Cardinal;
i:integer;
AThreadID:Cardinal;
Begin
Result:=True;
ThreadList:=Pointer(ThreadListR);
AThreadID:=GetWindowThreadProcessID(ParentHwnd,nil);
If AThreadID=0 then Exit;
If High(ThreadList)<>-1 then
For i:=Low(ThreadList) to High(ThreadList) do If ThreadList[i]=AThreadID then Exit;
SetLength(ThreadList,High(ThreadList)+2);
ThreadList[High(ThreadList)]:=AThreadID;
end;
[/code]
[code]
Var
ThreadList:Array of Cardinal;
Begin
EnumWindows(@EnumFunc,Longint(ThreadList));
Showmessage( inttostr( High(ThreadList) ) );
end;
[/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories