IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

API, COM et SDKs Delphi Discussion :

traduction d'une struture C en Object pascal


Sujet :

API, COM et SDKs Delphi

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau candidat au Club
    Inscrit en
    Avril 2004
    Messages
    1
    Détails du profil
    Informations forums :
    Inscription : Avril 2004
    Messages : 1
    Par défaut traduction d'une struture C en Object pascal
    Bonjour, je doit utiliser une Dll en C et j'ai le respectif header, mais je ne connais pas le C et je ne sais pas comment traduire une structure assez spécial qui se trouve dans le header. Quelqu'un pourrait me donner un coup de main?

    Code c : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    / structure for transfering anything for an asynchronous task
    typedef struct _FEISC_TASK_INIT
    {
    void* pAny;			// pointer to anything, which is eflected as the first parameter 
    									// in the callback function (e.g. can be used to pass the object pointer)
    	unsigned char	ucBusAdr;		// busaddress for serial communication
    	unsigned int	uiChannelType;	// defines the channel type to be used
    	int				iConnectByHost;	// if 0: TCP/IP connection is initiated by reader. otherwise by host
    	char			cIPAdr[16];		// server ip address
    									// note: only for channel type FEISC_TASK_CHANNEL_TYPE_NEW_TCP
    	int				iPortNr;		// server or host port address
    									// note: only for channel type FEISC_TASK_CHANNEL_TYPE_NEW_TCP
    	unsigned int	uiTimeout;		// timeout for asynchronous task
    	unsigned int	uiFlag;			// specifies the use of the union (e.g. FEISC_TASKCB_1)
     
    	union
    	{
    		// for notification and inventory task
    		void	(*cbFct1)(	void* pAny,					// [in] pointer to anything (from struct _FEISC_TASK_INIT)
    							int iReaderHnd,				// [in] reader handle of FEISC
    							int iTaskID,				// [in] task identifier from FEISC_StartAsyncTask(..)
    							int iError,					// [in] OK (=0), error code (<0) or status byte from reader (>0)
    							unsigned char ucCmd,		// [in]	reader command
    							unsigned char* ucRspData,	// [in] response data
    							int iRspLen );				// [in] local port number which received the notification
     
    		// only for notification task
    		void	(*cbFct2)(	void* pAny,					// [in] pointer to anything (from struct _FEISC_TASK_INIT)
    							int iReaderHnd,				// [in] reader handle of FEISC
    							int iTaskID,				// [in] task identifier from FEISC_StartAsyncTask(..)
    							int iError,					// [in] OK (=0), error code (<0) or status byte from reader (>0)
    							unsigned char ucCmd,		// [in]	reader command
    							unsigned char* ucRspData,	// [in] response data
    							int iRspLen,				// [in] length of response data
    							char* cRemoteIP,			// [in] ip address of the reader
    							int iLocalPort );			// [in] local port number which received the notification

  2. #2
    Expert éminent
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    14 081
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 14 081
    Par défaut
    Ajoute les Balises [ CODE] et peux-tu fournir ce que tu as déjà commencé à traduire, on peut t'aider sur les parties difficiles ...

    regarde la Strcuture _LARGE_INTEGER de Windows.pas, cela te montre comment faire une union ...

    pour déclarer un pointeur de fonction regarde TFNHookProc de Windows.pas
    Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !
    Attention Troll Méchant !
    "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
    Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
    L'ignorance n'excuse pas la médiocrité !

    L'expérience, c'est le nom que chacun donne à ses erreurs. (Oscar Wilde)
    Il faut avoir le courage de se tromper et d'apprendre de ses erreurs

  3. #3
    Membre Expert

    Profil pro
    Inscrit en
    Novembre 2007
    Messages
    1 519
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Novembre 2007
    Messages : 1 519
    Billets dans le blog
    1
    Par défaut
    Les void* sont notamment à remplacer par le type Pointer.

  4. #4
    Expert éminent
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 55
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Par défaut
    voila :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
     
    // structure for transfering anything for an asynchronous task
    type
      _FEISC_TASK_INIT = record
        pAny          : Pointer; 	// pointer to anything, which is eflected as the first parameter
    									            // in the callback function (e.g. can be used to pass the object pointer)
        ucBusAdr      : Char;      // busaddress for serial communication
        uiChannelType : Cardinal;	// defines the channel type to be used
        iConnectByHost: Integer;	// if 0: TCP/IP connection is initiated by reader. otherwise by host
        cIPAdr        : array[0..15] of Char;	// server ip address
    									            // note: only for channel type FEISC_TASK_CHANNEL_TYPE_NEW_TCP
        iPortNr       : Integer;	// server or host port address
    									            // note: only for channel type FEISC_TASK_CHANNEL_TYPE_NEW_TCP
        uiTimeout     : Cardinal;  // timeout for asynchronous task
        uiFlag        : Cardinal;	// specifies the use of the union (e.g. FEISC_TASKCB_1)
        case Byte of
          0 : (cbFct1 : procedure(
                          pAny: Pointer;     // [in] pointer to anything (from struct _FEISC_TASK_INIT)
                          iReadHnd,          // [in] reader handle of FEISC
                          iTaskID,           // [in] task identifier from FEISC_StartAsyncTask(..)
                          iError: Integer;   // [in] OK (=0), error code (<0) or status byte from reader (>0)
                          ucCmd: Char;       // [in]	reader command
                          ucRspData: PChar;  // [in] response data
                          iRspLen: Integer   // [in] local port number which received the notification
                        )
               );
          1 : (cbFct2 : procedure(
                          pAny: Pointer;     // [in] pointer to anything (from struct _FEISC_TASK_INIT)
                          iReadHnd,          // [in] reader handle of FEISC
                          iTaskID,           // [in] task identifier from FEISC_StartAsyncTask(..)
                          iError: Integer;   // [in] OK (=0), error code (<0) or status byte from reader (>0)
                          ucCmd: Char;       // [in]	reader command
                          ucRspData: PChar;  // [in] response data
                          iRspLen: Integer;  // [in] length of response data
                          cRemoteIP: PChar;  // [in] ip address of the reader
                          iLocalPort: Integer
                        )
               );
        end;
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  5. #5
    Expert éminent
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    14 081
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 14 081
    Par défaut
    Merci Paul Toth, tu n'avais pas remarqué que l'on avait pris soin de l'aiguiller pour qu'il avance et comprenne ce qu'il faisait ... maintenant, il n'a plus qu'a copier coller ... tu ne connais pas pas le proverbe de Confucius : "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson."

    pour les procédures, il manque la convention d'appel à mon avis !
    Aide via F1 - FAQ - Guide du développeur Delphi devant un problème - Pensez-y !
    Attention Troll Méchant !
    "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson" Confucius
    Mieux vaut se taire et paraître idiot, Que l'ouvrir et de le confirmer !
    L'ignorance n'excuse pas la médiocrité !

    L'expérience, c'est le nom que chacun donne à ses erreurs. (Oscar Wilde)
    Il faut avoir le courage de se tromper et d'apprendre de ses erreurs

  6. #6
    Membre Expert Avatar de edam
    Homme Profil pro
    Développeur Delphi/c++/Omnis
    Inscrit en
    Décembre 2003
    Messages
    1 894
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur Delphi/c++/Omnis
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2003
    Messages : 1 894
    Par défaut
    Citation Envoyé par ShaiLeTroll Voir le message
    Merci Paul Toth, tu n'avais pas remarqué que l'on avait pris soin de l'aiguiller pour qu'il avance et comprenne ce qu'il faisait ... maintenant, il n'a plus qu'a copier coller ... tu ne connais pas pas le proverbe de Confucius : "Quand un homme a faim, mieux vaut lui apprendre à pêcher que de lui donner un poisson."

    pour les procédures, il manque la convention d'appel à mon avis !
    là, je suis pas d'accord avec toi, il est difficile pour un non Cfist( comme delphiste ) de convertire un code c vers un autre language,
    à propos, c'est la premiére fois que je vois une déclaration d'une procedure dans un record

Discussions similaires

  1. Réponses: 6
    Dernier message: 21/09/2007, 14h18
  2. Concatener une variable a un object?
    Par critok dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 25/02/2006, 19h38
  3. Traduction d'une requete Access vers Oracle
    Par twizell dans le forum Oracle
    Réponses: 2
    Dernier message: 13/02/2006, 21h27
  4. Traduction d'une requete Update jet en sql server
    Par verbatim56 dans le forum MS SQL Server
    Réponses: 1
    Dernier message: 17/01/2006, 12h10
  5. Réponses: 13
    Dernier message: 13/06/2003, 14h13

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo