title: Passing a parameter to CreateThread
body: <p>I am having a problem passing a class reference as the parameter to the ThreadProc in a call to CreateThread. Here is a sample program that demonstrates the problem I am having:</p>
  
  <pre><code>program test;
  
  {$APPTYPE CONSOLE}
  
  uses
    SysUtils, Windows, Dialogs;
  
  type
      TBlah = class
          public
          fe: Integer;
      end;
  
  function ThreadProc(param: Pointer) : DWORD;
  begin
      ShowMessage(IntToStr(TBlah(param).fe));
  
      Result := 0;
  end;
  
  var
      tID: DWORD;
      handle: THandle;
      b: TBlah;
  begin
      b := TBlah.Create;
      b.fe := 54;
  
      handle := CreateThread(nil, 0, @ThreadProc, Pointer(b), 0, tID);
  
      WaitForSingleObject(handle, INFINITE); 
  end.
  </code></pre>
  
  <p>The call to <code>ShowMessage</code> pops up a message box that has something like <code>245729105</code> in it, not <code>54</code> like I expect.</p>
  
  <p>This is probably just a basic misunderstanding of how Delphi works, so could someone please tell me how to get this working properly?</p>