里面有一个参数要用到函数起始地址,比如我在线程内要调用到getdata这个函数,应怎样调用?请高手指教

解决方案 »

  1.   

    给你个例子吧 网上找的var
      Form1: TForm1;
      ThreadHandle: THandle;                 // holds the handles the threads
      ThreadHandle2: THandle;
      CriticalSection: TRTLCriticalSection;  // holds the critical section infoimplementation{$R *.DFM}function ThreadFunc(Info: Pointer): Integer; stdcall;
    var
      Count : Integer;    // general loop control variable
    begin
      {performing the EnterCriticalSection function prevents the second thread   from executing until this thread leaves the critical section}
      EnterCriticalSection(CriticalSection);  {show a visual display}
      for Count := 0 to 100 do
      begin
        Form1.Edit1.Text := IntToStr(Count);
      end;  {display a message}
      Form1.Edit1.Text := 'Hello from the thread!';  {pause for a second}
      Sleep(1000);  {leave the critical section and exit the thread}  LeaveCriticalSection(CriticalSection);
      ExitThread(4);
    end;procedure TForm1.Button1Click(Sender: TObject);
    var
      ThreadId1, ThreadId2: DWORD;   // holds the created thread identifiers
    begin
      {initialize the critical section information}
      InitializeCriticalSection(CriticalSection);  {create and execute the first thread}
      ThreadHandle := CreateThread(nil, 0, @ThreadFunc, nil, 0, ThreadId1);  {create and execute the second thread}
      ThreadHandle2 := CreateThread(nil, 0, @ThreadFunc, nil, 0, ThreadId1);
    end;procedure TForm1.FormDestroy(Sender: TObject);
    begin
      {we are done, so destroy the critical section information}
      DeleteCriticalSection(CriticalSection);
    end;
      

  2.   

    给楼主的建议,既然你用delphi了,为什么不用delphi自己的tthread类
    自己创建线程,容易出错误
      

  3.   

    从 TThread 继承,创建自己的类呀,这样比较容易控制。