<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Delphi Code in C++ Code umwandeln&#x2F;beschreiben ?]]></title><description><![CDATA[<p>Hey ich wuerde gerne folgenden Delphi Code in C++ realisieren.</p>
<pre><code>type
  PClient   = ^TClient;
  TClient   = record
    HostName    : String[20];  { Hostname }
    PeerIP      : string[15];  { Client IP address }
    TakeShot    : boolean;     { explained later }
    Connected,                 { Time of connect }
    LastAction  : TDateTime;   { Time of last transaction }
    Thread      : Pointer;     { Pointer to thread }
  end;

...
var
  Clients : TThreadList;
</code></pre>
<p>so hab ich es in cpp code umgewandelt:</p>
<pre><code>struct TClient
{
	String		PeerIP;     //			{ Client IP address }
	String		HostName;   //       { Hostname }
	bool			TakeShot;   //
	TDateTime	Connected;  //       { Time of connect }
	TDateTime	LastAction;	//       { Time of last transaction }
	TThread		*Thread;		//       { Pointer to thread }
};
</code></pre>
<p>wie man sehen kann fehlt aber eine deklaration,</p>
<pre><code>PClient   = ^TClient;
</code></pre>
<p>ich glaube es soll einen Zeiger auf die TClient-Struktur darstellen, den ich dann in meiner Formklasse deklariert habe:</p>
<pre><code>TClient *PClient;		// Zeiger auf Clientstruktur
	TThreadList *Clients;		// Clientliste
</code></pre>
<pre><code>procedure TMainFormServer.TCPServerConnect(AThread: TIdPeerThread);
var
  NewClient: PClient;
begin
  GetMem(NewClient, SizeOf(TClient));

  NewClient.PeerIP     := AThread.Connection.Socket.Binding.PeerIP;
  NewClient.HostName   := GStack.WSGetHostByAddr(NewClient.PeerIP);
  NewClient.TakeShot   := False;
  NewClient.Connected  := Now;
  NewClient.LastAction := NewClient.Connected;
  NewClient.Thread     := AThread;

  AThread.Data := TObject(NewClient);

  try
    Clients.LockList.Add(NewClient);
  finally
    Clients.UnlockList;
  end;
end;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/176949/delphi-code-in-c-code-umwandeln-beschreiben</link><generator>RSS for Node</generator><lastBuildDate>Sat, 15 Aug 2026 13:48:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/176949.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 26 Mar 2007 16:58:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Delphi Code in C++ Code umwandeln&#x2F;beschreiben ? on Mon, 26 Mar 2007 17:06:13 GMT]]></title><description><![CDATA[<p>Hey ich wuerde gerne folgenden Delphi Code in C++ realisieren.</p>
<pre><code>type
  PClient   = ^TClient;
  TClient   = record
    HostName    : String[20];  { Hostname }
    PeerIP      : string[15];  { Client IP address }
    TakeShot    : boolean;     { explained later }
    Connected,                 { Time of connect }
    LastAction  : TDateTime;   { Time of last transaction }
    Thread      : Pointer;     { Pointer to thread }
  end;

...
var
  Clients : TThreadList;
</code></pre>
<p>so hab ich es in cpp code umgewandelt:</p>
<pre><code>struct TClient
{
	String		PeerIP;     //			{ Client IP address }
	String		HostName;   //       { Hostname }
	bool			TakeShot;   //
	TDateTime	Connected;  //       { Time of connect }
	TDateTime	LastAction;	//       { Time of last transaction }
	TThread		*Thread;		//       { Pointer to thread }
};
</code></pre>
<p>wie man sehen kann fehlt aber eine deklaration,</p>
<pre><code>PClient   = ^TClient;
</code></pre>
<p>ich glaube es soll einen Zeiger auf die TClient-Struktur darstellen, den ich dann in meiner Formklasse deklariert habe:</p>
<pre><code>TClient *PClient;		// Zeiger auf Clientstruktur
	TThreadList *Clients;		// Clientliste
</code></pre>
<pre><code>procedure TMainFormServer.TCPServerConnect(AThread: TIdPeerThread);
var
  NewClient: PClient;
begin
  GetMem(NewClient, SizeOf(TClient));

  NewClient.PeerIP     := AThread.Connection.Socket.Binding.PeerIP;
  NewClient.HostName   := GStack.WSGetHostByAddr(NewClient.PeerIP);
  NewClient.TakeShot   := False;
  NewClient.Connected  := Now;
  NewClient.LastAction := NewClient.Connected;
  NewClient.Thread     := AThread;

  AThread.Data := TObject(NewClient);

  try
    Clients.LockList.Add(NewClient);
  finally
    Clients.UnlockList;
  end;
end;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1253168</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1253168</guid><dc:creator><![CDATA[t0b4d]]></dc:creator><pubDate>Mon, 26 Mar 2007 17:06:13 GMT</pubDate></item><item><title><![CDATA[Reply to Delphi Code in C++ Code umwandeln&#x2F;beschreiben ? on Mon, 26 Mar 2007 17:09:00 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Das unter dem type sind Deklarationen. Das würde in C++ etwa so aussehen.</p>
<pre><code class="language-cpp">struct TClient
{
    AnsiString HostName;  // Hostname 
    AnsiString PeerIP;    // Cleint IP address 
    bool TakeShot;        // explained later 
    TDateTime Connected;  // Time of connect 
    TDateTime LastAction; // Time of last transaction 
    void* Thread;         // Pointer to thread 
};
TClient* PClient;
</code></pre>
<p>und der Rest irgendwie so</p>
<pre><code class="language-cpp">void TMainFormServer::TCPServerConnect(TIdPeerThread* AThread)
{
  PClient NewClient = new TClient;

  NewClient-&gt;PeerIP     = AThread-&gt;Connection-&gt;Socket-&gt;Binding-&gt;PeerIP;
  NewClient-&gt;HostName   = GStack-&gt;WSGetHostByAddr(NewClient-&gt;PeerIP);
  NewClient-&gt;TakeShot   = false;
  NewClient-&gt;Connected  = Now();
  NewClient-&gt;LastAction = NewClient-&gt;Connected;
  NewClient-&gt;Thread     = AThread;

  AThread-&gt;Data = reinterpret_cast&lt;TObject*&gt;(NewClient);

  try
  {
    Clients-&gt;LockList-&gt;Add(NewClient);
  }
  __finally
  {
    Clients-&gt;UnlockList;
  }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1253175</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1253175</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Mon, 26 Mar 2007 17:09:00 GMT</pubDate></item><item><title><![CDATA[Reply to Delphi Code in C++ Code umwandeln&#x2F;beschreiben ? on Mon, 26 Mar 2007 17:27:06 GMT]]></title><description><![CDATA[<p>Danke fuer die schnelle Antwort,<br />
aber leider gibt es Probleme...</p>
<pre><code class="language-cpp">PClient NewClient = new TClient;
</code></pre>
<p>[C++ Fehler] unt_server.cpp(26): E2379 In Anweisung fehlt ;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1253195</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1253195</guid><dc:creator><![CDATA[t0b4d]]></dc:creator><pubDate>Mon, 26 Mar 2007 17:27:06 GMT</pubDate></item><item><title><![CDATA[Reply to Delphi Code in C++ Code umwandeln&#x2F;beschreiben ? on Mon, 26 Mar 2007 17:59:21 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>vermutlich hast du vergessen die Headerdatei von &quot;TClient&quot; zu includen oder es fehlt irgendwo vor der gezeigten Stelle ein Semikolon.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1253223</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1253223</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Mon, 26 Mar 2007 17:59:21 GMT</pubDate></item><item><title><![CDATA[Reply to Delphi Code in C++ Code umwandeln&#x2F;beschreiben ? on Mon, 26 Mar 2007 19:11:13 GMT]]></title><description><![CDATA[<p>nein, das ist es alles nicht!</p>
<p>mir kommt es so vor alls koennte er mit dem Variablen Typ PClient nichts anfangen. Wenn ich schreibe... (in der gleichen Zeile)</p>
<pre><code class="language-cpp">TClient NewClient;
</code></pre>
<p>...dann gehts!</p>
<p>Aber hat es dann auch die gleiche &quot;Funktion&quot; ?!</p>
<p>EDIT:</p>
<p>BITTE BEITRAG LÖSCHEN.... ich versuch jetzt etwas anderes !</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1253231</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1253231</guid><dc:creator><![CDATA[t0b4d]]></dc:creator><pubDate>Mon, 26 Mar 2007 19:11:13 GMT</pubDate></item><item><title><![CDATA[Reply to Delphi Code in C++ Code umwandeln&#x2F;beschreiben ? on Tue, 27 Mar 2007 08:18:28 GMT]]></title><description><![CDATA[<p>Wo ist der Unterschied zwischen</p>
<pre><code class="language-cpp">PClient NewClient;
</code></pre>
<p>und</p>
<pre><code class="language-cpp">PClient* NewClient = new TClient;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1253573</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1253573</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Tue, 27 Mar 2007 08:18:28 GMT</pubDate></item><item><title><![CDATA[Reply to Delphi Code in C++ Code umwandeln&#x2F;beschreiben ? on Tue, 27 Mar 2007 09:08:52 GMT]]></title><description><![CDATA[<p>So wie Braunstein sagte, sind TClient und PClient Deklarationen, so daß es korrekterweise</p>
<pre><code class="language-cpp">typedef TClient* PClient;
</code></pre>
<p>heißen muß.<br />
Nun kannst du entweder</p>
<pre><code class="language-cpp">TClient* NewClient = new TClient;
</code></pre>
<p>oder</p>
<pre><code class="language-cpp">PClient NewClient = new TClient;
</code></pre>
<p>schreiben, wobei erste zu bevorzugen ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1253634</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1253634</guid><dc:creator><![CDATA[Th]]></dc:creator><pubDate>Tue, 27 Mar 2007 09:08:52 GMT</pubDate></item><item><title><![CDATA[Reply to Delphi Code in C++ Code umwandeln&#x2F;beschreiben ? on Tue, 27 Mar 2007 09:09:11 GMT]]></title><description><![CDATA[<p>Ok, Ok, Ich habe das typedef oben vergessen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<pre><code class="language-cpp">typedef TClient* PClient;
</code></pre>
<p>So wäre das richtig. Das könnte man aber auch weglassen und dann gleich das hier schreiben.</p>
<pre><code class="language-cpp">TClient* NewClient = new TClient;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1253635</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1253635</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Tue, 27 Mar 2007 09:09:11 GMT</pubDate></item><item><title><![CDATA[Reply to Delphi Code in C++ Code umwandeln&#x2F;beschreiben ? on Fri, 27 Apr 2007 17:18:28 GMT]]></title><description><![CDATA[<p>Bei mir gibt der Teil mit der Threadlist immer eine Fehlermeldung.</p>
<p><a href="http://home.arcor.de/fokal/Error.JPG" rel="nofollow">http://home.arcor.de/fokal/Error.JPG</a></p>
<pre><code class="language-cpp">struct ClientData
{
  AnsiString IP;
  TIdPeerThread *Thread;
};
</code></pre>
<pre><code class="language-cpp">private:	// User declarations
        TThreadList *Clients;
</code></pre>
<pre><code class="language-cpp">void __fastcall TForm1::ServerConnect(TIdPeerThread *AThread)
{
  ClientData *ActClient = new ClientData;
  TIdSocketHandle *Handle = Server-&gt;Bindings-&gt;Add();
  Handle-&gt;IP = AThread-&gt;Connection-&gt;Socket-&gt;Binding-&gt;IP;
  Handle-&gt;Port = AThread-&gt;Connection-&gt;Socket-&gt;Binding-&gt;Port;
  ActClient-&gt;IP = Handle-&gt;IP;
  ActClient-&gt;Thread = AThread;
  AThread-&gt;Data = reinterpret_cast&lt;TObject*&gt;(ActClient);
  try
  {
    Clients-&gt;LockList()-&gt;Add(ActClient);
  }
  __finally
  {
    Clients-&gt;UnlockList();
  }
  Edit1-&gt;Text = Handle-&gt;IP;
  Edit2-&gt;Text = IntToStr(Handle-&gt;Port);
  MessageBox(0,&quot;Connected&quot;,&quot;Titel&quot;,MB_OK);
  delete ActClient;
}
</code></pre>
<p>Was mach ich denn hier falsch?</p>
<p>Ich kenn mich mit Threads leider überhaupt nicht aus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1274771</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1274771</guid><dc:creator><![CDATA[Tobi3000]]></dc:creator><pubDate>Fri, 27 Apr 2007 17:18:28 GMT</pubDate></item><item><title><![CDATA[Reply to Delphi Code in C++ Code umwandeln&#x2F;beschreiben ? on Fri, 27 Apr 2007 17:24:29 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p><a href="http://www.junix.ch/bcb/help/debug.html" rel="nofollow">Debugger</a> benutzen um Verlauf und Variablen deines Programms zu verfolgen.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1274779</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1274779</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Fri, 27 Apr 2007 17:24:29 GMT</pubDate></item></channel></rss>