unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    function ss():integer;
  end;var
  Form1: TForm1;implementation{$R *.dfm}function tform1.ss ():integer;
  begin
    edit1.Text:='33';
  end;procedure TForm1.Button1Click(Sender: TObject);
var
  mythead:thandle;
  id:dword;
begin
   mythead:=createthread(nil,0,@ss,nil,0,id);
end;end.错误:
Build
  [Warning] Unit1.pas(31): Return value of function 'TForm1.ss' might be undefined
  [Error] Unit1.pas(38): Variable required
  [Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'

解决方案 »

  1.   

    function ss():integer; 这个函数不是这么定义的吧 要么就    function ss :integer; 这样就是代表有个整形的返回值  要么就      function ss(i: integer):integer; 里面写个参数  看你需要什么样的你才定义哪种     LZ 给分吧  错误就在这呢~~~
      

  2.   

    不要使用Windows带的API创建线程!!!建议使用Delphi提供的TThread类创建线程,非常简单的!!!以下代码是线程类的定义unit SendThread;interfaceUses
        Classes, Ora, ReadBuf, SoapHTTPClient, AiAccount;Type
        PSendThread = ^TSendThread;
        TSendThread = Class( TThread )
        Private
               Oracle : TOraSession;
               StoredProc : TOraStoredProc;
               Data : TSendData;
               Ws : AIServiceSoap;
               HTTPRIO : THTTPRIO;           Function Pr_Update_Msg( Const ID : String;
                                       Const ErrCode : String ) : Integer;           Procedure InitStoredProc;
        Public
              Constructor Create( _Oracle : TOraSession;
                                  _Data : TSendData );
              Destructor Destroy; Override;
              Procedure Start;
              Procedure Stop;
        Protected
                 Procedure Execute; Override;
        End;implementationuses Globe, SysUtils, DB, ActiveX, Logs;{ TSendThread }constructor TSendThread.Create(_Oracle: TOraSession; _Data : TSendData );
    begin
         Oracle := _Oracle;     InitStoredProc;     Data := _Data;     HTTPRIO := THTTPRIO.Create( Nil );     HTTPRIO.URL := WSDL;     HTTPRIO.HTTPWebNode.UseUTF8InHeader := True;     Ws := HTTPRIO As AIServiceSoap;     If( ProxyConfig.Use_Flag ) Then
         Begin
              HTTPRIO.HTTPWebNode.UserName := ProxyConfig.User;
              HTTPRIO.HTTPWebNode.Password := ProxyConfig.Password;
              If( ProxyConfig.Port = 0 ) Then
              Begin
                   HTTPRIO.HTTPWebNode.Proxy := ProxyConfig.IP;
              End
              Else
              Begin
                   HTTPRIO.HTTPWebNode.Proxy := ProxyConfig.IP + ':' + IntToStr( ProxyConfig.Port );
              End;
         End;     FreeOnTerminate := True;     Inherited Create( False );
    end;destructor TSendThread.Destroy;
    begin
         If( StoredProc.Active ) Then
         Begin
              StoredProc.Close;
         End;     StoredProc.Free;     HTTPRIO := Nil;     Inherited;
    end;procedure TSendThread.Execute;
    Var
       Head : TSTKHead;
       Error_Code : WideString;
    begin
         CoUninitialize;
         CoInitialize( Nil );     Head := TSTKHead.Create;
         Try
            Head.ID := Data.ID;
            Head.CMDID := 0;
            Head.Source_ID := SOURCE_ID;
            Try
               Log.WriteLog( '调用WebService,参数为:ID=' + Head.ID + ',' +
                             'Account_No=' + Data.Account_No + ',' +
                             'Info_Type=' + IntToStr( Data.Info_Type ) + ',' +
                             'Info_Content=' + Data.Info_Content + ',' +
                             'Timestamp=' + Data.Timestamp, Head.ID);
               Error_Code := Ws.SendMsg( Head,
                                         Data.Account_No,
                                         Data.Info_Type,
                                         Data.Info_Content,
                                         Data.Timestamp );
               Log.WriteLog( '调用Webservice成功,返回值为' + Error_Code, Head.ID );
            Except
                  On E : Exception Do
                  Begin
                       Log.WriteLog( '调用Webservice异常,信息为:' + E.Message, Head.ID );
                  End;
            End;        If( Copy( Error_Code, 6, 3 ) = '000' ) Then
            Begin
                 Inc( SuccessCount );
            End;        Pr_Update_Msg( Data.ID, Error_Code );
         Finally
                ThreadBuffer.UpdateOverFlag( Data.ID );
                Head.Free;
         End;
         CoUninitialize;
         Terminate;
    end;procedure TSendThread.InitStoredProc;
    begin
         StoredProc := TOraStoredProc.Create( Nil );     StoredProc.Session := Oracle;     StoredProc.Params.Clear;     StoredProc.StoredProcName := 'Pr_Update_Msg';     StoredProc.Params.Add;
         StoredProc.Params[ 0 ].Name := 'iID';
         StoredProc.Params[ 0 ].DataType := ftString ;
         StoredProc.Params[ 0 ].ParamType := ptInput;     StoredProc.Params.Add;
         StoredProc.Params[ 1 ].Name := 'iErrCode';
         StoredProc.Params[ 1 ].DataType := ftString ;
         StoredProc.Params[ 1 ].ParamType := ptInput;     StoredProc.Params.Add;
         StoredProc.Params[ 2 ].Name := 'oResult';
         StoredProc.Params[ 2 ].DataType := ftString;
         StoredProc.Params[ 2 ].ParamType := ptOutput;
    end;function TSendThread.Pr_Update_Msg(const ID, ErrCode: String): Integer;
    begin
         Result := 0;
         Log.WriteLog( '开始调用存储过程,参数为:ID=' + ID + ',' +
                       'ErrCode=' + ErrCode, ID );
         StoredProc.Close;
         StoredProc.Params[ 0 ].Value := ID;
         StoredProc.Params[ 1 ].Value := ErrCode;                 
         Try
            StoredProc.ExecProc;        Result := StoredProc.Params[ 2 ].AsInteger;        Log.WriteLog( '调用存储过程成功', ID );
         Except
               On E : Exception Do
               Begin
                    Log.WriteLog( '调用存储过程异常,信息为' + E.Message, ID );
               End;
         End;
    end;procedure TSendThread.Start;
    begin
         Resume;
    end;procedure TSendThread.Stop;
    begin
         Terminate;
    end;end.
    以下的代码是生成线程的实例!!!TSendThread.Create( Oracle, PData^ );需要注意的是,例子中的线程是自管理的,不需要人工释放资源!!!对于非自管理的线程需要手工处理!!!