Je suis actuellement en train de développer un IHM en VB.Net.
Pour cela j'ai du intégrer une dll écrite en C et je doit utiliser une fonction qui prend en paramètre un double pointeur sur une structure.
Pour faire appel à cette fonction j'ai donc utiliser le code suivant:
<DllImport("CLT.dll", CallingConvention:=CallingConvention.Cdecl)> _
Public Shared Function clt_New(ByRef pObj As clt_Type, ByVal card As Integer) As Integer
End Function
foliv57
Messages postés420Date d'inscriptionvendredi 17 novembre 2006StatutMembreDernière intervention15 juillet 20149 9 juin 2013 à 14:49
Bonjour,
Je n'ai pas la possibilité de tester, mais je dirai de mémoire :
<DllImport("CLT.dll", CallingConvention:=CallingConvention.Cdecl)> _
Public Shared Function clt_New(ByRef pObj As IntPtr, ByVal card As Integer) As Integer
End Function
Sub Test()
Dim unClt_Type As clt_Type = New clt_Type()
Dim p_Obj As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(GetType(clt_Type)))
Marshal.StructureToPtr(unClt_Type, p_Obj, False)
Dim p2p_Obj As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(GetType(IntPtr)))
Marshal.StructureToPtr(p_Obj, p2p_Obj, False)
clt_New(p2p_Obj, 1)
End Sub
J'ai juste un doute sur le ByRef dans la déclaration de la fonction.
CGSI3, CLT.dll n'est pas trouvable sur internet c'est une librairie d'un outils électronique permettant de réaliser des mesures sur des cartes à puces.
Merci pour les informations, j'ai trouvé la solution ou foliv57 ma bien aidé:
Dim buffer As Integer = 250
Dim buffer_handle_card As Integer = 1
' generating a global handle
Dim Obj As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(buffer))
Dim handle_card As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(buffer_handle_card))
'convert it to an unmanaged pointer
Marshal.StructureToPtr(buffer, Obj, False)
Marshal.StructureToPtr(buffer_handle_card, handle_card, False)
'calling the dll function
MsgBox(clt_New(Obj, handle_card))
'removing the unmanaged pointer from the heap
Marshal.FreeHGlobal(handle_card)
Marshal.FreeHGlobal(Obj)
Sinon j’espère juste pouvoir t aider a trouver quelque chose de similaire a ce que tu recherche. Pourrais tu me dire ce que tu recherche dans cette DLL?
'CLT.dll' ne donne rien pour moi sur google. (ou sinon donne nous un lien)
Ensuite si tu veux te fabriquer un ami virtuel, tu peux sans aucun pb utiliser OpentK pour l'affichage et OpenCv pour l'acquisition de données par exemple par ta webcam.
Ce sont 2 projets écrit en langue C & dérivée, et utilisable dans vb.net et qui ont de multiples fonctions utilisable.
CGSI3