AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein C++-DLL --> Delphi - dynamischer struct-Array?

C++-DLL --> Delphi - dynamischer struct-Array?

Ein Thema von Legato · begonnen am 20. Jun 2007 · letzter Beitrag vom 20. Jun 2007
 
Legato

Registriert seit: 31. Mai 2007
6 Beiträge
 
Delphi 2006 Enterprise
 
#1

C++-DLL --> Delphi - dynamischer struct-Array?

  Alt 20. Jun 2007, 14:18
Huhu,

ich habe eine Funktion in C++, die einen Pointer auf eine struct entgegennimmt und diese dynamisch füllen soll. Die Anzahl der Elemente wird erst in der Funktion selber bekannt. Hier eine reduzierte Testversion davon:
Code:
struct ContactType
{
//   __int64 id;
//   char *name;
   int protocol;
};

extern "C" __declspec(dllexport) int ContactManagerSOAP_GetContactTypes(ContactType* result)
{
   int count = 1;
   result = new ContactType[count];
   for (int i = 0; i <= count; i++) {
      result[i].protocol = 3;
   }
   return count;
}
Nun sollte der Array ja theoretisch ein Element enthalten.

Ich rufe das ganze in Delphi auf:

Delphi-Quellcode:
type
   ContactManagerSOAP_ContactType = record
//      a: INT64;
//      b: PChar;
      c: Integer;
   end;
  ContactManagerSOAP_ContactTypeArray = array of ContactManagerSOAP_ContactType;

function _ContactManagerSOAP_GetContactTypes(var result: ContactManagerSOAP_ContactTypeArray) : Integer; cdecl; external '../DLL/ObjectWebservice.dll';

procedure TDataDisplayForm.btnGetContactTypesClick(Sender: TObject);
var
  ContactTypes: ContactManagerSOAP_ContactTypeArray;
  count: Integer;
begin
// SetLength(ContactTypes, 1);
  count := _ContactManagerSOAP_GetContactTypes(ContactTypes);
  ShowMessage(IntToStr(ContactTypes[0].c));
end;
Klappt nicht - ContactTypes enthält 0 Elemente, c zeigt ins Nichts.

Sieht jemand, was ich falsch mache, oder hat eine Idee, wie ich das ganze stattdessen lösen könnte?

Mit liebem Gruß,
Tobias
Tobias
The highest sounds are hardest to hear.
Going forward is a way to retreat.
Great talent shows itself late in life.
Even a perfect program still has bugs.
  Mit Zitat antworten Zitat
 

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:17 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz