private
    { Private declarations }
    procedure RecData;
  public
    { Public declarations }
  end;var
  Form1: TForm1;function OpenSocket(OnMsg: TOnMsg): LongInt; stdcall;
procedure CloseSocket; stdcall;
function GetMsg(Msg: Pointer; MsgLen: LongInt): LongInt; stdcall;
function GetConnected: LongInt; stdcall;
function GetBusy: LongInt; stdcall;function Login(UserID, Password: PChar; UserType, UseMarket: Char): LongInt; stdcall;
function Order(CustID, CommID: PChar; Price: Double; Volume: LongInt; Buysell, Offset, Hedge: Char): LongInt; stdcall;
function Repeal(OrderID: LongInt): LongInt; stdcall;
function QryOrder(CustID: PChar; States: PChar): LongInt; stdcall;
function QryContract(CustID: PChar): LongInt; stdcall;
function QryStore(CustID: PChar): LongInt; stdcall;
function QryFund(CustID: PChar): LongInt; stdcall;implementation{$R *.DFM}function OpenSocket; external 'Trade.dll' name 'OpenSocket';
procedure CloseSocket; external 'Trade.dll' name 'CloseSocket';
function GetMsg; external 'Trade.dll' name 'GetMsg';
function GetConnected; external 'Trade.dll' name 'GetConnected';
function GetBusy; external 'Trade.dll' name 'GetBusy';
function Login; external 'Trade.dll' name 'Login';
function Order; external 'Trade.dll' name 'Order';
function Repeal; external 'Trade.dll' name 'Repeal';
function QryOrder; external 'Trade.dll' name 'QryOrder';
function QryContract; external 'Trade.dll' name 'QryContract';
function QryStore; external 'Trade.dll' name 'QryStore';
function QryFund; external 'Trade.dll' name 'QryFund';procedure RecMsg; stdcall;
begin
  Form1.RecData;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
  OpenSocket(RecMsg);
end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  CloseSocket;
end;procedure TForm1.RecData;
var
  Ch: array [0..80000] of Char;
  MsgLen: LongInt;
  Msg: string;
begin
  MsgLen := GetMsg(@Ch[0],80000);
  while MsgLen > 0 do
  begin
    if MsgLen > 80000 then
      MsgLen := 80000;
    SetLength(Msg, MsgLen);
    Move(Ch[0], Msg[1], MsgLen);
    if (Copy(Msg, 1, 2) <> '29') or CheckBox1.Checked then
      Memo.Lines.Add(Msg);
    MsgLen := GetMsg(@Ch[0],80000);
  end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Caption := IntToStr(Login(PChar(seUserID.Text),PChar(sePassword.Text),scbUserType.Text[1],scbUseMarket.Text[1]));
end;procedure TForm1.Button2Click(Sender: TObject);
begin
  Label1.Caption := IntToStr(Order(PChar(''),PChar(seCommID.Text),StrToFloat(sePrice.Text),StrToInt(seVolume.Text),
         scbBuySell.Text[1],scbOffSet.Text[1],scbHedge.Text[1]));
end;procedure TForm1.Button3Click(Sender: TObject);
begin
  Label1.Caption := IntToStr(Repeal(StrToInt(seOrderID.Text)));
end;procedure TForm1.Button4Click(Sender: TObject);
begin
  Label1.Caption := IntToStr(QryOrder(PChar(''),PChar('0123456789abcd')));
end;procedure TForm1.Button5Click(Sender: TObject);
begin
  Label1.Caption := IntToStr(QryContract(PChar('')));
end;procedure TForm1.Button6Click(Sender: TObject);
begin
  Label1.Caption := IntToStr(QryStore(PChar('')));
end;procedure TForm1.Button7Click(Sender: TObject);
begin
  Label1.Caption := IntToStr(QryFund(PChar('')));
end;
整个delphi的程序是这个样子的,蓝线是我没有弄清楚的地方!
以下是我写的vb程序,这个是module1中的..
Declare Function opensocket Lib "trade.dll" Alias "OpenSocket" (ByVal onmsg As Long) As Long
Declare Sub CloseSocket Lib "trade.dll" ()
Declare Function GetMsg Lib "trade.dll" (ByVal msg As Long, ByVal msglen As Long) As Long
Declare Function GetConnected Lib "trade.dll" () As Long
Declare Function GetBusy Lib "trade.dll" () As Long
Declare Function Login Lib "trade.dll" (ByVal UserID As Any, ByVal Password As Any, ByVal UserType As Any, UseMarket As Any) As Long
Declare Function Order Lib "trade.dll" (ByVal CustID As Any, ByVal CommID As Any, ByVal price As Double, ByVal Volume As Any, ByVal Buysell As Byte, ByVal Offset As Byte, ByVal Hedge As Byte) As Long
Declare Function Repeal Lib "trade.dll" (ByVal OrderID As Long) As Long
Declare Function QryOrder Lib "trade,dll" (ByVal CustID As Any, ByVal States As Any) As Long
Declare Function QryContract Lib "trade.dll" (ByVal CustID As Any) As Long
Declare Function QryStore Lib "trade.dll" (ByVal CustID As Any) As Long
Declare Function QryFund Lib "trade.dll" (ByVal CustID As Any) As Long
Public Sub recmsg()
Call recdata
End Sub
Public Sub recdata()
Dim ch As String * 8000
Dim msglen As Long
msglen = Len(msg)
Do While msglen > 0
   If msglen > 8000 Then
      msglen = 8000
   End If
   If Mid(msg, 1, 2) Or Check1.SetFocus Then
   List1.AddItem (msg)
   msglen = GetMsg(ch(0), 8000)
   End
   Loop
End Sub
Public Sub opens()
Call opensocket(AddressOf recmsg)
End Sub
下面是标准代码中的
Private Sub Form_Load()
Call Module1.opens
End SubPrivate Sub Form_Unload(Cancel As Integer)
Call CloseSocket
End Sub
运行另外可以,就是不能显示正确的结果,我很急,明天要交差的,刚注册个新用户,就这么多分,全压啦!