Boujour à tous

Je voudrais essayer d'ecrire en mémoire, un tableau sous format ASCII, et en LPSTR, de façon à pouvoir le lire avec une DLL standard.

J'ai créé avec beaucoup de mal ce code, mais cela ne marche pas
Si quelqu'un avait la gentillesse de me donner un coup de pouce

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
Private Declare Function HeapAlloc Lib "kernel32" (ByVal hHeap As Long, ByVal dwFlags As Long, ByVal dwBytes As Long) As Long
Private Declare Function HeapFree Lib "kernel32" (ByVal hHeap As Long, ByVal dwFlags As Long, lpMem As Any) As Long
Private Declare Function GetProcessHeap Lib "kernel32" () As Long
Private Declare Sub CopyMemoryWrite Lib "kernel32" Alias "RtlMoveMemory" (Destination As Long, ByVal Source As String, ByVal Length As Long)
Private Declare Sub ShowArrayString Lib "TheDll.dll" (ByRef ArrayPtr As ArrayStruct)
 
Private Sub Form_Load()
 
 Dim TheArray(10) As String
 Dim ArrayString As ArrayStruct
 Dim ArrayLen As Integer
 Dim OffsetPtr As Long
 Dim hHeap As Long
 Dim ArrayAscii As String
 
 ChDir App.Path
 CurDir Left(App.Path, 3)
 
 For i = 1 To UBound(TheArray())
  TheArray(i) = "Sentence n° " + Str(i)
  ArrayLen = ArrayLen + Len("Sentence n° " + Str(i))
 Next
 
 ArrayString.Size = UBound(TheArray())
 hHeap = GetProcessHeap()
 ArrayString.Ptr = HeapAlloc(hHeap, 0, ArrayLen)
 OffsetPtr = ArrayString.Ptr
 
 For i = 1 To UBound(TheArray())
  ArrayAscii = StrConv(TheArray(i), vbFromUnicode)
  CopyMemoryWrite OffsetPtr, ArrayAscii, LenB(ArrayAscii)
  OffsetPtr = OffsetPtr + LenB(ArrayAscii)
 Next
 
 ShowArrayString ArrayString
 HeapFree GetProcessHeap(), 0, ArrayString.Ptr
 
End Sub
Je vous remercie et vous souhaite une bonne soirée