//C++ virtual long getChunk (void** data, bool isPreset = false) { return 0; } virtual long setChunk (void* data, long byteSize, bool isPreset = false) { return 0; } //Delphi function getChunk(var data: pointer; isPreset: Boolean): longint; virtual; function setChunk(data: pointer; byteSize: longint; isPreset: Boolean): longint; virtual;I'm noting that data in getChunk is a pointer to a pointer, so has been declared in Delphi as a variable parameter so it is passed by reference. I thought this meant that I didn't need to allocate a variable of type ^pointer and fill it with @programs and set data to it's address. But I'm not sure. Anyway, this (edited down) is what I have tried to write. But I'm finding that the messagebox in setChunk() is displaying 'cleared', where it should be displaying 'saved'. Now I'm wondering if I should be allocating memory outside these functions and filling the memory and passing pointers to that inside the functions.
//Interface type kNumPrograms = 16; APluginProgram=class private fpar: Tfpar; name: array[0..50] of char; expression: array[0..254] of char; ... Tprograms = array[0..kNumPrograms-1] of APluginProgram; APlugin=class(AudioEffectX) public function getChunk(var data: pointer; isPreset: Boolean): longint; override; function setChunk(data: pointer; byteSize: longint; isPreset: Boolean): longint; override; ... //Implementation ... function APlugin.getChunk(var data: pointer; isPreset: Boolean): longint; begin inherited getChunk(data, isPreset); programs[curprogram].expression := 'saved'; data := @programs; Result := SizeOf(programs); end; function APlugin.setChunk(data: pointer; byteSize: longint; isPreset: Boolean): longint; begin inherited setChunk(data, byteSize, isPreset); if byteSize <> SizeOf(programs) then begin Result := 1; exit; end; programs[curprogram].expression := 'cleared'; programs := Tprograms(data^); MessageBox(0, PChar('programs[curprogram].expression = ' + programs[curprogram].expression), Nil, MB_OK); Result := 1; end;