Problème dans un composant avec Winsock

Résolu
Utilisateur anonyme - 20 mars 2007 à 14:11
 Utilisateur anonyme - 20 mars 2007 à 17:27
Salut à tous,

Voila un bout de composant,

------------------------------
unit SMTPClient;


interface


uses
Windows,WinSock,Classes;


type
  TIdentification=(atNone,atLogin);
  TSMTPClient = class( TComponent)
  private
  FSock:TSocket;
    { Private declarations }
  protected
  Fidentification:TIdentification;
  FPassword:String;
  FUSerName:String;
  FPort:cardinal;
  FSMTPAddress:string;
    { Protected declarations }
  public
    { Public declarations }
    constructor Create(AOwner:TComponent); override;
  published
  Property Identification:TIdentification Read FIdentification Write FIdentification Default atNone;
  property Password: string Read FPassword Write FPassword;
  property UserName: string Read FUserName Write FUserName;
  property port: cardinal Read FPort Write  Fport Default 25;
  property SMTPAddress: string Read FSMTPAddress Write FSMTPAddress;
  Function Connect:String;
    { Published declarations }
  end;


procedure Register;


implementation


procedure Register;
begin
  RegisterComponents('Sdk', [TSMTPClient]);
end;


constructor TSMTPClient.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
end;


Function TSMTPClient.Connect:String;
VAR
  WSAData:TWSAData;
  SockAddrIn:TSockAddrIn;
  i:integer;
Begin
WSAStartUp(257,WSAData);
FSock:=Socket(AF_INET,SOCK_STREAM,IPPROTO_IP);
With SockAddrIn Do
  begin
  sin_family:=AF_INET;
  sin_port:=htons(Fport);
  sin_addr.S_addr:=inet_addr(PChar(FSMTPAddress));
  End;
Connect(FSock,SockAddrIn,SizeOf(SockAddrIn));
End;
end.

-----------------------

L'IDE pointe sur la ligne rouge et m'indique une erreur : "trop de paramètres". Hors en regardant l'aide de delphi , il n'apparait aucune erreur de ce type.

Je pète un plomb . Merci

2 réponses

japee Messages postés 1727 Date d'inscription vendredi 27 décembre 2002 Statut Modérateur Dernière intervention 6 novembre 2021 8
20 mars 2007 à 14:40
Salut Francky,

J'ai pas trop le temps de m'y pencher, mais essaye :

Winsock.Connect(FSock,SockAddrIn,SizeOf(SockAddrIn));

pour voir...
3
Utilisateur anonyme
20 mars 2007 à 17:27
Merci Japee 
0
Rejoignez-nous