Problems with Thread

Hi i have a litle problem with my thread.
I want to give a parameter to the thread Procedure !

H:=1;
ComThread := CreateThread(nil, 16384, @ComThreadProc, Pointer(H), 0, ComThreadID);


procedure ComThreadProc(H : integer);
begin
    if H <> 1 then H := 1;
    with ComPorts[H] do

H is 0 in the Thread's procedure !
snoopy_SpyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

snoop_doggy_doggCommented:
Kinda gives me the willies...just tried it for myself...listening.
0
EpsylonCommented:
Try

ComThread := CreateThread(nil, 16384, @ComThreadProc, @H, 0, ComThreadID);

I think you should treat H in ComThreadProc as a pointer too....

Epsylon.
0
snoop_doggy_doggCommented:
Ep, that's what I thought too...but the cast is done automatically.  It still wont work, I bet.
0
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

EpsylonCommented:
Alright! This is it!

Just use the stdcall directive:

procedure ComThreadProc(H : Integer); stdcall;
begin
  if H = 1 then Beep;
end;

procedure TForm1.Button1Click(Sender: TObject);
var H: Integer;
    ComThread: Cardinal;
    ComThreadID: Cardinal;
begin
  H := 1;
  ComThread := CreateThread(nil, 16384, @ComThreadProc, Pointer(H), 0, ComThreadID);
end;

Eps.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
snoop_doggy_doggCommented:
Whoo hoo!!
0
EpsylonCommented:
Does it work now (it does for me). You can accept my comment as the answer if it does.
0
snoopy_SpyAuthor Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.