Code : Tout sélectionner
Pointeur = CreationStructureStandard
Mais par contre Copymemory est peut etre mal parametré "Byval/Byref" ??
Code : Tout sélectionner
Pointeur = CreationStructureStandard
CopyMemoryStructure varPtr(VariableStructurer), Pointeur, 12
Code : Tout sélectionner
Public Type Complexe
String As String
Long As Long
Integer As Integer
End Type
Private Declare Function AfficheStructure Lib "f:\documents\code\kcc\DllPb.dll" (Variable As Complexe) As Long
Private Declare Function ModifieStructure Lib "f:\documents\code\kcc\DllPb.dll" (Variable As Complexe) As Long
Sub EmmissionStructure()
Dim VariableStructuree As Complexe
'ChDir App.Path
VariableStructuree.String = "Robert"
VariableStructuree.Integer = 25
VariableStructuree.Long = 77777
AfficheStructure VariableStructuree
ModifieStructure VariableStructuree
Phrase = Str(VariableStructuree.Integer) + Chr(13)
Phrase = Phrase + Str(VariableStructuree.Long) + Chr(13)
Phrase = Phrase + VariableStructuree.String
MsgBox Phrase, vbOKOnly, "Visual Basic - Reception d'une structure Standard de la DLL"
End Sub
Code : Tout sélectionner
Structure Complexe
String.s
Long.l
Integer.i
EndStructure
ProcedureDLL AfficheStructure(*Ptr.Complexe)
Phrase$ + Str(*Ptr\Integer) + Chr(13)
Phrase$ + Str(*Ptr\Long) + Chr(13)
Phrase$ + *Ptr\String
MessageRequester("", Phrase$)
EndProcedure
ProcedureDLL ModifieStructure(*Ptr.Complexe)
*Ptr\Integer = 10
*Ptr\Long = 25
*Ptr\String = "Roudou" ;attention à ne pas dépasser la taille de la chaine VB d'origine!!!!
EndProcedure
Je crois que pour une fois...tu n'es pas assez agressifje ne suis pas spécialiste du tout en VB , a vrai dire , ce langage est à gerbé , mais passons.
Apparement pas dans la DLL car elle envoie bien le pointeur, comme je te l'ai dit plus hautCa plante à quelle niveau du code VB ?
tu peut le balisé à coup de debug pour voir ou ca crash ?
Aaaaah enfin "quinquin" qui m'apprecie a ma juste valeur...ça fait plaisiry a pas de pointeur en VB banane
Code : Tout sélectionner
Pointeur = CreationStructureStandard
PointeurStructure = VarPtr(VariableStructurer)
CopyMemoryStructure PointeurStructure, ByVal Pointeur, 12
Code : Tout sélectionner
AfficheStructure VariableStructuree
MsgBox Str(VarPtr(VariableStructuree))
ModifieStructure VariableStructuree
Code : Tout sélectionner
ProcedureDLL ModifieStructure(*Ptr.Complexe)
MessageRequester("Essai", Str(*Ptr.Complexe))
*Ptr\Integer = 10
*Ptr\Long = 25
*Ptr\String = "Ribert"
ProcedureReturn #False
EndProcedure
Code : Tout sélectionner
Str(VarPtr(VariableStructuree))
Code : Tout sélectionner
ModifieStructure VariableStructuree
C'est possible, mais pas si sur, car en VB tout depend de la declaration du hautLà , tu lui passe la valeur de la variable , pas son adresse.
Code : Tout sélectionner
Private Declare Function ModifieStructure Lib "DllPb.dll" (Variable As Long) As Long
Code : Tout sélectionner
ModifieStructure VariableStructuree
Code : Tout sélectionner
ModifieStructure Byval VariableStructuree
Code : Tout sélectionner
Private Declare Function ModifieStructure Lib "DllPb.dll" (Byval Variable As Long) As Long
Code : Tout sélectionner
Private Declare Function ModifieStructure Lib "DllPb.dll" (Byval Variable As Long) As Long
ModifieStructure VariableStructuree
Ca plante dans la deuxieme fonction ModifieOù est-ce que ça plante?
Le VB6 SP6, le vrai l'unique, le merdiqueTu utilises comment VB, quelle version?
Oui j'avais vu, car ça c'est tout le debut de mon histoire de y'a deux trois ans.Ah! Et mets Roudou au lieu de roudoudou, car sinon ça dépasse!!!!
Code : Tout sélectionner
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal Size As Long)
Dim VariableStructurer As Complexe, Phrase As String, PointeurDll As Long, PointeurElement As Long
ChDir App.Path
PointeurDll = CreationStructureStandard
CopyMemory PointeurElement, ByVal PointeurDll, 4
VariableStructurer.String = Space$(lstrlen(PointeurElement))
lstrcpy VariableStructurer.String, PointeurElement
CopyMemory VariableStructurer.Long, ByVal PointeurDll + 4, 4
CopyMemory VariableStructurer.Integer, ByVal PointeurDll + 8, 4
Phrase = Str(VariableStructurer.Integer) + Chr(13)
Phrase = Phrase + Str(VariableStructurer.Long) + Chr(13)
Phrase = Phrase + VariableStructurer.String
MsgBox Phrase, vbOKOnly, "Visual Basic - Reception d'une structure Standard de la DLL"
Code : Tout sélectionner
Private Declare Sub CopyMemoryLong Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal Size As Long)
Code : Tout sélectionner
ProcedureDLL CreationStructureStandard()
Static VariableStructurer.Complexe
VariableStructurer\Integer = 10
VariableStructurer\Long = 1457859
VariableStructurer\String = "Coucou je viens de la DLL et je suis une structure"
ProcedureReturn @VariableStructurer
EndProcedure