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

C# Discussion :

Probléme de convertion C en C# Appelle callback


Sujet :

C#

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2011
    Messages
    907
    Détails du profil
    Informations personnelles :
    Localisation : France, Vienne (Poitou Charente)

    Informations forums :
    Inscription : Mai 2011
    Messages : 907
    Points : 85
    Points
    85
    Par défaut Probléme de convertion C en C# Appelle callback
    Bonjour,

    Je suis entrain de convertir un projet C en C#

    Originale :
    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
    #pragma pack(push,1)
    typedef struct {
    	int sizecb;
    	HWND hWnd;
    	struct {
    		char *idopen;
    		char *soft;
    		int highver;
    		int lowver;
    		bool showerror;
    		void *ext;
    	}in_open;
    	struct {
    		void *defaut;
    		void *software;
    		void *param;
    	}io_info;
    	struct {
    		bool releaseafteropen;
    	}misc;
    	struct {
    		DWORD errmaster;
    		DWORD errchild;
    	}out_error;
    	HANDLE (_stdcall *load)(void *param,HWND hWnd,int sizemaster,void *master,int sizechild,void *child,char *password,void *infomaster,void *infochild,DWORD *errmaster,DWORD *errchild);
    }TOPENGLICS_APILOAD,*POPENGLICS_APILOAD;
    #pragma pack(pop)
    C# :
    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
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    namespace demo_realtimesolution
    {
        class openglics
        {
            IntPtr hLic;
            //[System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
             IntPtr emuleload(IntPtr param,IntPtr hWnd,int sizemaster,IntPtr master,int sizechild,IntPtr child,IntPtr password,IntPtr infomaster,IntPtr infochild,ref UInt32 errmaster,ref UInt32 errchild)
            {
     
    	        return IntPtr.Zero;
            }
            [System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential,
        Pack = 1)]
            public unsafe struct in_open
            {
                public char* idopen;
                public char* soft;
                public UInt32 highver;
                public UInt32 lowver;
                public bool showerror;
                public void* ext;
            }
            public unsafe struct io_info
            {
                public void* defaut;
                public void* software;
                public void* param;
            }
            public unsafe struct misc
            {
                public bool releaseafteropen;
            }
            public unsafe  struct out_error
            {
                public UInt32 errmaster;
                public UInt32 errchild;
            }
            public unsafe struct OPENGLICS_APILOAD
            {
                public int sizecb;
    	        public IntPtr hWnd;
                public in_open varin_open;
                public io_info vario_info;
                public misc var_misc;
                public out_error var_outerror;
     
                [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
                public delegate IntPtr loadlicense(IntPtr param, IntPtr hWnd, int sizemaster, IntPtr master, int sizechild, IntPtr child, char* password, void* infomaster, void* infochild, ref UInt32 errmaster, ref UInt32 errchild);
                public loadlicense li;
     
            }
            void LoadLicense()
            {
                unsafe
                {
     
                    OPENGLICS_APILOAD on = new OPENGLICS_APILOAD();
                    //on.sizecb = on.s           
                    on.varin_open.idopen = null;
                    on.varin_open.highver = 1;
                    on.varin_open.lowver = 3;
                    on.varin_open.showerror = true;
                   // char[] soft=string.to
                    on.varin_open.soft =  (char*)(void*)System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi("STRING");
     
                    //apiload.io_info.defaut = &lic_solumaze;
                    on.vario_info.defaut = null;
                    on.li = emuleload; //INTERESSANT ICI !!! ERREUR CS0123
     
                }
     
     
            }
        }
    }
    Pouvez-vous m'aider ?

    Je m'explique , je vais passer cette structure nommé "on" à ma DLL ecrite en C , et la fonction on.li de C# doit être appeler par ma DLL.

    J'ai l'erreur de compilation :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    error CS0123: No overload for 'emuleload' matches delegate 'demo_realtimesolution.openglics.OPENGLICS_APILOAD.loadlicense
    Merci

  2. #2
    Membre expert
    Avatar de GuruuMeditation
    Homme Profil pro
    .Net Architect
    Inscrit en
    Octobre 2010
    Messages
    1 705
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : .Net Architect
    Secteur : Conseil

    Informations forums :
    Inscription : Octobre 2010
    Messages : 1 705
    Points : 3 568
    Points
    3 568
    Par défaut
    Et si tu remplaces char*, void* par IntPtr dans le définition de ton delegate?
    Microsoft MVP : Windows Platform

    MCPD - Windows Phone Developer
    MCPD - Windows Developer 4

    http://www.guruumeditation.net

    “If debugging is the process of removing bugs, then programming must be the process of putting them in.”
    (Edsger W. Dijkstra)

  3. #3
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2011
    Messages
    907
    Détails du profil
    Informations personnelles :
    Localisation : France, Vienne (Poitou Charente)

    Informations forums :
    Inscription : Mai 2011
    Messages : 907
    Points : 85
    Points
    85
    Par défaut
    Citation Envoyé par GuruuMeditation Voir le message
    Et si tu remplaces char*, void* par IntPtr dans le définition de ton delegate?
    C'est résolu , laborieux ;

    Je met resolut

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème de Convertion de types
    Par simtim dans le forum GTK+ avec C & C++
    Réponses: 6
    Dernier message: 27/05/2007, 22h54
  2. [WebForms]convertion caracteres speciaux avant appel proc. stockee
    Par jejefeds dans le forum Général Dotnet
    Réponses: 2
    Dernier message: 03/01/2007, 10h42
  3. Réponses: 2
    Dernier message: 18/11/2006, 15h06
  4. Problème de convertion en NodeList
    Par imhotep_zr7s dans le forum XSL/XSLT/XPATH
    Réponses: 6
    Dernier message: 05/09/2006, 11h54
  5. Problème de variable lors d'1 appel de fonction PHP
    Par kriekbellevue dans le forum Général JavaScript
    Réponses: 14
    Dernier message: 14/02/2006, 17h49

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