<?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[aus C++ DLL String o.ä. an VB zurückgeben!]]></title><description><![CDATA[<p>Hilfe! Ich bin am Verzweifeln!</p>
<p>ich will nichts weiter als ein beschissenes Stück Text (mir egal ob char*, String, CString, BSTR, LPCSTR oder wie die ganzen Arschteile auch heißen) in ein VB programm transferieren.</p>
<p>Ich habe eine DLL mit der Funktion GetMacAddr:</p>
<p>char* GetMacAddr()</p>
<p>{<br />
char* mystring;<br />
char macStr[30];</p>
<p>BLA BLA....</p>
<p>BLA BLA</p>
<p>myString=macStr;</p>
<p>return myString;<br />
}</p>
<p>in vb ruf ichs so auf:</p>
<p>Private Declare Function GetMacAddr Lib &quot;C:\Program Files\Microsoft Visual Studio\MyProjects\mr\Release\mr.dll&quot; () As String</p>
<p>Dim myTest As String</p>
<p>myTest = GetMacAddr()</p>
<p>Leider bekomm ich dann nur einen leeren String zurück.</p>
<p>Hab auch schon probiert den string nicht als rückgabewert sondern als byRef Parameter zu übergeben...</p>
<p>void GetMacAddr(char* &amp;para)</p>
<p>in vb:<br />
Private Declare Function GetMacAddr Lib &quot;C:\Program Files\Microsoft Visual Studio\MyProjects\mr\Release\mr.dll&quot; (byREf para As String)</p>
<p>dim mystring as string</p>
<p>GetMacAddr(mystring)</p>
<p>ausgabe mystring =&gt; &quot;BAD DLL CALL CONVENATION&quot; oder speicherfehler oder etc.</p>
<p>Versuche seit ca. 10 stunden ein bekackte Mac-Adresse als einfaches Textstück an VB zu geben. Bitte bitte helft mir, ich bin echt grantig und verzweifelt.</p>
<p>Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/130380/aus-c-dll-string-o-ä-an-vb-zurückgeben</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Jul 2026 16:01:25 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/130380.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 22 Dec 2005 13:49:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to aus C++ DLL String o.ä. an VB zurückgeben! on Thu, 22 Dec 2005 13:49:16 GMT]]></title><description><![CDATA[<p>Hilfe! Ich bin am Verzweifeln!</p>
<p>ich will nichts weiter als ein beschissenes Stück Text (mir egal ob char*, String, CString, BSTR, LPCSTR oder wie die ganzen Arschteile auch heißen) in ein VB programm transferieren.</p>
<p>Ich habe eine DLL mit der Funktion GetMacAddr:</p>
<p>char* GetMacAddr()</p>
<p>{<br />
char* mystring;<br />
char macStr[30];</p>
<p>BLA BLA....</p>
<p>BLA BLA</p>
<p>myString=macStr;</p>
<p>return myString;<br />
}</p>
<p>in vb ruf ichs so auf:</p>
<p>Private Declare Function GetMacAddr Lib &quot;C:\Program Files\Microsoft Visual Studio\MyProjects\mr\Release\mr.dll&quot; () As String</p>
<p>Dim myTest As String</p>
<p>myTest = GetMacAddr()</p>
<p>Leider bekomm ich dann nur einen leeren String zurück.</p>
<p>Hab auch schon probiert den string nicht als rückgabewert sondern als byRef Parameter zu übergeben...</p>
<p>void GetMacAddr(char* &amp;para)</p>
<p>in vb:<br />
Private Declare Function GetMacAddr Lib &quot;C:\Program Files\Microsoft Visual Studio\MyProjects\mr\Release\mr.dll&quot; (byREf para As String)</p>
<p>dim mystring as string</p>
<p>GetMacAddr(mystring)</p>
<p>ausgabe mystring =&gt; &quot;BAD DLL CALL CONVENATION&quot; oder speicherfehler oder etc.</p>
<p>Versuche seit ca. 10 stunden ein bekackte Mac-Adresse als einfaches Textstück an VB zu geben. Bitte bitte helft mir, ich bin echt grantig und verzweifelt.</p>
<p>Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/947799</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/947799</guid><dc:creator><![CDATA[forsakingmax]]></dc:creator><pubDate>Thu, 22 Dec 2005 13:49:16 GMT</pubDate></item><item><title><![CDATA[Reply to aus C++ DLL String o.ä. an VB zurückgeben! on Thu, 22 Dec 2005 13:55:19 GMT]]></title><description><![CDATA[<p>Gib mal in deiner Funktion GetMacAddr das char - Array aus, ob das was drinsteht stimmt, oder ob's hier schon hakt.<br />
Btw. wenn du C++ nehmen kannst/willst wäre std::string komfortabler als char* :</p>
<pre><code class="language-cpp">std::string GetMacAddr() {
  std::string str;
  //lies Mac-Adresse in str rein
  return str;
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/947809</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/947809</guid><dc:creator><![CDATA[GPC]]></dc:creator><pubDate>Thu, 22 Dec 2005 13:55:19 GMT</pubDate></item><item><title><![CDATA[Reply to aus C++ DLL String o.ä. an VB zurückgeben! on Thu, 22 Dec 2005 13:58:37 GMT]]></title><description><![CDATA[<p>Das char* gibt einwandfrei den richtigen Wert aus (innerhalb der Funktion).</p>
<p>Ich habe es zuerst mit &quot;string&quot; gehabt, da hats dann aber in VB gekracht, wie ich den Wert einem VB-String zuweisen wollte =&gt; Absturtz des ganzen Visual Studios + Speicherfehlermeldung...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/947810</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/947810</guid><dc:creator><![CDATA[forsakingmax]]></dc:creator><pubDate>Thu, 22 Dec 2005 13:58:37 GMT</pubDate></item><item><title><![CDATA[Reply to aus C++ DLL String o.ä. an VB zurückgeben! on Thu, 22 Dec 2005 14:03:24 GMT]]></title><description><![CDATA[<p>Übrigens: Wenn ich in VB die Methode als &quot;AS LONG&quot; definiere, dann bekomm ich einen Wert zurück..alerdings nur ein &quot;1347046&quot; statt der Mac-Adresse. Ist das die Long-Versioneiner Speicheradresse? Ich versteh es sowieso nicht (c++-Newbie): ich bekomm ja einen POINTER con c++ zurück...und den pointer weiß ich einer variable zu...aber müsste ich nicht eigentlich das, worauf der Pointer zeigt, in die Variable speichern?? Wenn ja =&gt; Wie?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/947814</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/947814</guid><dc:creator><![CDATA[forsakingmax]]></dc:creator><pubDate>Thu, 22 Dec 2005 14:03:24 GMT</pubDate></item><item><title><![CDATA[Reply to aus C++ DLL String o.ä. an VB zurückgeben! on Thu, 22 Dec 2005 14:04:13 GMT]]></title><description><![CDATA[<p>in C++ hat ein char 1 Byte, in VB sieht die Sache ein wenig anders aus.<br />
Da hat ein String nämlich 10 Byte. EDIT: Einzelnes char gibt's da eh net.</p>
<p>Hier ein Link für dich: <a href="http://www.activevb.de/rubriken/kolumne/kol_4/cpptovbtypen.html" rel="nofollow">http://www.activevb.de/rubriken/kolumne/kol_4/cpptovbtypen.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/947815</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/947815</guid><dc:creator><![CDATA[GPC]]></dc:creator><pubDate>Thu, 22 Dec 2005 14:04:13 GMT</pubDate></item><item><title><![CDATA[Reply to aus C++ DLL String o.ä. an VB zurückgeben! on Thu, 22 Dec 2005 14:05:46 GMT]]></title><description><![CDATA[<p>Danke GPC, den Link habe ich natürlich shcon vor stunden entdeckt *gg* Dort steht auch nur C++ Type = char* =&gt; VB-Type = String. Sollte also so gehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/947817</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/947817</guid><dc:creator><![CDATA[forsakingmax]]></dc:creator><pubDate>Thu, 22 Dec 2005 14:05:46 GMT</pubDate></item><item><title><![CDATA[Reply to aus C++ DLL String o.ä. an VB zurückgeben! on Thu, 22 Dec 2005 14:09:21 GMT]]></title><description><![CDATA[<p>wenn ich deine string-Methode von vb aufruf, kackt alles ab.</p>
<p>Assembler hier (Fehler tritt in 3. zeile auf):</p>
<p>[...]<br />
1000133F mov cl,byte ptr [eax]<br />
10001341 mov edx,dword ptr [ebp-4]<br />
10001344 mov byte ptr [edx],cl<br />
10001346 push 0<br />
10001348 mov ecx,dword ptr [ebp-4]<br />
1000134B call 10001620<br />
10001350 mov eax,[1000D124]<br />
10001355 push eax<br />
10001356 push 0<br />
[...]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/947820</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/947820</guid><dc:creator><![CDATA[forsakingmax]]></dc:creator><pubDate>Thu, 22 Dec 2005 14:09:21 GMT</pubDate></item><item><title><![CDATA[Reply to aus C++ DLL String o.ä. an VB zurückgeben! on Thu, 22 Dec 2005 14:13:59 GMT]]></title><description><![CDATA[<p>Eh sorry, aber es ist schon 4 jahre her, dass ich das letzte mal was ernsthaft mit VB gemacht habe .</p>
<p>Dort steht auch</p>
<blockquote>
<p>Alle Zeigertypen (also datenTyp *varName oder erweiterte C++-Typen mit den Anfangsbuchstaben &quot;LP&quot; (für long pointer)) werden mit dem Long-Datentyp in Visual Basic implementiert (Ausnahme ist char*)</p>
</blockquote>
<p>wobei (wie du sagtest):<br />
char* -&gt; String<br />
char[NUM_OF_CHARS] -&gt; String * NUM_OF_CHARS</p>
<p>Das auch schon gelesen: <a href="http://pub13.ezboard.com/fvisualbasicexplorerfrm36.showMessage?topicID=214.topic" rel="nofollow">http://pub13.ezboard.com/fvisualbasicexplorerfrm36.showMessage?topicID=214.topic</a> ??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/947823</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/947823</guid><dc:creator><![CDATA[GPC]]></dc:creator><pubDate>Thu, 22 Dec 2005 14:13:59 GMT</pubDate></item><item><title><![CDATA[Reply to aus C++ DLL String o.ä. an VB zurückgeben! on Thu, 22 Dec 2005 14:17:00 GMT]]></title><description><![CDATA[<p>Ja, hab ich leider auch shcon gelesen. Der Typ macht's mit BSTR wobei das bei mir auch nicht funzt.</p>
<p>Angenommen der Long-Wert den die Funktion zurückgibt ist die SPeicheradresse. Weißt du zufällig, wie ich dann in VB den Wert der Speicheradresse auslesen kann?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/947829</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/947829</guid><dc:creator><![CDATA[forsakingmax]]></dc:creator><pubDate>Thu, 22 Dec 2005 14:17:00 GMT</pubDate></item><item><title><![CDATA[Reply to aus C++ DLL String o.ä. an VB zurückgeben! on Thu, 22 Dec 2005 14:21:23 GMT]]></title><description><![CDATA[<p>forsakingmax schrieb:</p>
<blockquote>
<p>Ja, hab ich leider auch shcon gelesen. Der Typ macht's mit BSTR wobei das bei mir auch nicht funzt.</p>
</blockquote>
<p>Fleißig gesucht hast du ja, Respekt. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
<blockquote>
<p>Angenommen der Long-Wert den die Funktion zurückgibt ist die SPeicheradresse. Weißt du zufällig, wie ich dann in VB den Wert der Speicheradresse auslesen kann?</p>
</blockquote>
<p>Adresse eines Zeigers kriegst du so raus:</p>
<pre><code class="language-cpp">char *p = &quot;XYZ&quot;;
cout&lt;&lt;&amp;p;
</code></pre>
<p>Der Long Wert, den du zurückkriegst, ist der andersweitig interpretierbar, evtl. nach Mac - Adresse?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/947831</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/947831</guid><dc:creator><![CDATA[GPC]]></dc:creator><pubDate>Thu, 22 Dec 2005 14:21:23 GMT</pubDate></item><item><title><![CDATA[Reply to aus C++ DLL String o.ä. an VB zurückgeben! on Thu, 22 Dec 2005 14:23:47 GMT]]></title><description><![CDATA[<p>Jetzt hab ich mal in der DLL folgenden Funktion registriert:</p>
<p>(bei deiner string-variante schmeirt er ja ab):</p>
<p>char* test() {<br />
char* str;<br />
str=&quot;huihuihui&quot;;<br />
return str;<br />
};</p>
<p>ruf ich jetzt die Funktiion in VB auf, kommt wengistens schonmal keine fehlermeldung - der string, der zurückkommt, ist aber trotzdem leer.</p>
<p>Private Declare Function test Lib &quot;C:\Program Files\Microsoft Visual Studio\MyProjects\mr\Release\mr.dll&quot; () As String</p>
<p>myTest = test()</p>
]]></description><link>https://www.c-plusplus.net/forum/post/947835</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/947835</guid><dc:creator><![CDATA[forsakingmax]]></dc:creator><pubDate>Thu, 22 Dec 2005 14:23:47 GMT</pubDate></item><item><title><![CDATA[Reply to aus C++ DLL String o.ä. an VB zurückgeben! on Thu, 22 Dec 2005 14:27:34 GMT]]></title><description><![CDATA[<p>Der Longwert ist nicht als MAC-Adresse interpretierbar, höchstens als Adresse =&gt; der Schmäh ist ja, dass auch bei diser schlanken Funktion eine Zahle 294584358 zurückkommt, wenn ich die funktion in vb auf LONG umstelle.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/947840</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/947840</guid><dc:creator><![CDATA[forsakingmax]]></dc:creator><pubDate>Thu, 22 Dec 2005 14:27:34 GMT</pubDate></item><item><title><![CDATA[Reply to aus C++ DLL String o.ä. an VB zurückgeben! on Thu, 22 Dec 2005 14:33:21 GMT]]></title><description><![CDATA[<p><a href="http://www.flipcode.com/articles/article_vbdlls.shtml" rel="nofollow">http://www.flipcode.com/articles/article_vbdlls.shtml</a></p>
<p>Ließ da mal den Abschnitt über Strings da steht auch wie man sie returned. Wichtigster Satz:</p>
<blockquote>
<p>In order to return a string, a system function must be called to properly allocate memory for it. Otherwise, the string will disappear when the function terminates and the client will receive garbage.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/947847</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/947847</guid><dc:creator><![CDATA[asdrubael]]></dc:creator><pubDate>Thu, 22 Dec 2005 14:33:21 GMT</pubDate></item><item><title><![CDATA[Reply to aus C++ DLL String o.ä. an VB zurückgeben! on Thu, 22 Dec 2005 14:36:20 GMT]]></title><description><![CDATA[<blockquote>
<pre><code class="language-cpp">char* test() {
char* str;
str=&quot;huihuihui&quot;;
return str;
};
</code></pre>
</blockquote>
<p>Sorry, das funzt so nicht. Wenn schon:</p>
<pre><code class="language-cpp">char* _stdcall test() {
  static char str[]=&quot;huihuihui&quot;;
  cout&lt;&lt;&quot;Wert: &quot;&lt;&lt;str&lt;&lt;'\n';
  cout&lt;&lt;&quot;Adresse: &quot;&lt;&lt;&amp;str&lt;&lt;'\n';
  return str;
};
</code></pre>
<p>Was ergeben sich nun für Werte?</p>
<p>EDIT: Pellaeon recht geb <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/947848</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/947848</guid><dc:creator><![CDATA[GPC]]></dc:creator><pubDate>Thu, 22 Dec 2005 14:36:20 GMT</pubDate></item><item><title><![CDATA[Reply to aus C++ DLL String o.ä. an VB zurückgeben! on Thu, 22 Dec 2005 14:33:41 GMT]]></title><description><![CDATA[<p>mal was anderes einwerf, auch wenns daran jetzt evtl nicht liegt: VB kann doch nur stdcall benutzen dachte ich. Wenn ich deine Funktion sehe, die du exportierst, hast du ja kein __stdcall mit hingeschrieben ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/947851</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/947851</guid><dc:creator><![CDATA[Pellaeon]]></dc:creator><pubDate>Thu, 22 Dec 2005 14:33:41 GMT</pubDate></item><item><title><![CDATA[Reply to aus C++ DLL String o.ä. an VB zurückgeben! on Thu, 22 Dec 2005 14:40:21 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/6287">@GPC</a>: doch, meine Variante funzt. Wenn ich die funktion in C++ aufrufe, haut alles hin. Gleiche wert bei deiner variante.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/9676">@Pellaeon</a>: Was bedeuted __stdcall dazuzuschreiben? Habs getan, macht aber no difference.</p>
<p>asdrubael, das klingt gut, schau ich mir mal an! Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/947857</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/947857</guid><dc:creator><![CDATA[forsakingmax]]></dc:creator><pubDate>Thu, 22 Dec 2005 14:40:21 GMT</pubDate></item><item><title><![CDATA[Reply to aus C++ DLL String o.ä. an VB zurückgeben! on Fri, 23 Dec 2005 09:35:00 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile.php?mode=viewprofile&amp;u=403" rel="nofollow">HumeSikkins</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=15" rel="nofollow">C++</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=4" rel="nofollow">WinAPI</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/948375</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/948375</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Fri, 23 Dec 2005 09:35:00 GMT</pubDate></item></channel></rss>