Werkende code:
De vraag:
- In VB heb ik myMacro (Array van UDT)
- Die stuur ik naar de C++ Dll via de macro GetMacro.
- Daar doe ik bewerkingen op (met ao. new)
- Deze stuur ik trug naar VB via een pointer
1/ klopt deze denkwijze?
- terug in VB doe ik een CopyMemory van first naar de tabel temp()
2/
hoe wordt de data in temp() nu eigenlijk gedestroyed? Want wat ik zeker niet wil zijn geheugenlekken.
3/
Is de tabel opvullen in C++ sneller dan de array opvullen in VB (array = 68 bytes, inclusief verschillende pointers naar strings). De strings moeten geparsed worden uit een (dynamisch) bestand.
PS: whoami. Is dit nu een goede vraag of niet? Eigenlijk is dit juist zelfde als ik vorige keer gevraagd heb zenne...
C++:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| struct mMacro { long x; long y; }; long _stdcall GetMacro(mMacro** ppMacro, mMacro* first) { mMacro* structure = new mMacro[10]; //Populate structure[0], structure[1] etc. *ppMacro = structure; *first = temp[0]; return 10;//size of array } |
Visual Basic:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| Private Type mmacro x As Long y As Long End Type Private Declare Function GetMacro Lib "mydll.dll" (myMacro() As mMacro, first As mmacro) As Long Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) When you want to call GetMacro, write the following: Dim myMacro() As mMacro Dim temp() As mMacro Dim first As mMacro Dim lSize As Long lSize = GetMacro(myMacro, first) ReDim temp(lSize - 1) Call CopyMemory(temp(0), first, lSize * len(first)) |
De vraag:
- In VB heb ik myMacro (Array van UDT)
- Die stuur ik naar de C++ Dll via de macro GetMacro.
- Daar doe ik bewerkingen op (met ao. new)
- Deze stuur ik trug naar VB via een pointer
1/ klopt deze denkwijze?
- terug in VB doe ik een CopyMemory van first naar de tabel temp()
2/
hoe wordt de data in temp() nu eigenlijk gedestroyed? Want wat ik zeker niet wil zijn geheugenlekken.
3/
Is de tabel opvullen in C++ sneller dan de array opvullen in VB (array = 68 bytes, inclusief verschillende pointers naar strings). De strings moeten geparsed worden uit een (dynamisch) bestand.
PS: whoami. Is dit nu een goede vraag of niet? Eigenlijk is dit juist zelfde als ik vorige keer gevraagd heb zenne...