<?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[GetWindowText mit string vergleichen?!]]></title><description><![CDATA[<p>Hallo,<br />
Ich schreibe derzeit an einem Programm, wo es am Anfang einen login gibt.<br />
Dafür hab ich Winapi benutzt und stehe nun vor einem seltsamen Problem.<br />
Ich habe eine Editbox und frage den Wert daraus mit GetWindowText(..); ab.<br />
Vergleiche ihn dann mit if( GetWindowTextString == String ) es kommt IMMER false herraus, ich habe mir beide strings schon ausgeben lassen, selbst wenn sie exakt gleich sind bekomme ich ein false.<br />
Es läuft wie folgt:</p>
<pre><code class="language-cpp">char Username[200] = &quot;Blabla&quot;;
char Password[200] = &quot;blablablablabl&quot;;
char UsernameInput[200]; 
GetWindowText(hwndEdit1, (LPSTR)UsernameInput, GetWindowTextLength(hwndEdit1)+1); 
char PasswordInput[200]; 
GetWindowText(hwndEdit2, (LPSTR)PasswordInput, GetWindowTextLength(hwndEdit2)+1); 
if( Username == UsernameInput )
MessageBox(.. Granted ..);
else
MessageBox(.. Denied ..);
</code></pre>
<p>Ich bekomme immer Denied?! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/288618/getwindowtext-mit-string-vergleichen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 19 Aug 2026 19:41:45 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/288618.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 20 Jun 2011 00:14:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to GetWindowText mit string vergleichen?! on Mon, 20 Jun 2011 00:14:46 GMT]]></title><description><![CDATA[<p>Hallo,<br />
Ich schreibe derzeit an einem Programm, wo es am Anfang einen login gibt.<br />
Dafür hab ich Winapi benutzt und stehe nun vor einem seltsamen Problem.<br />
Ich habe eine Editbox und frage den Wert daraus mit GetWindowText(..); ab.<br />
Vergleiche ihn dann mit if( GetWindowTextString == String ) es kommt IMMER false herraus, ich habe mir beide strings schon ausgeben lassen, selbst wenn sie exakt gleich sind bekomme ich ein false.<br />
Es läuft wie folgt:</p>
<pre><code class="language-cpp">char Username[200] = &quot;Blabla&quot;;
char Password[200] = &quot;blablablablabl&quot;;
char UsernameInput[200]; 
GetWindowText(hwndEdit1, (LPSTR)UsernameInput, GetWindowTextLength(hwndEdit1)+1); 
char PasswordInput[200]; 
GetWindowText(hwndEdit2, (LPSTR)PasswordInput, GetWindowTextLength(hwndEdit2)+1); 
if( Username == UsernameInput )
MessageBox(.. Granted ..);
else
MessageBox(.. Denied ..);
</code></pre>
<p>Ich bekomme immer Denied?! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2080892</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2080892</guid><dc:creator><![CDATA[Santo]]></dc:creator><pubDate>Mon, 20 Jun 2011 00:14:46 GMT</pubDate></item><item><title><![CDATA[Reply to GetWindowText mit string vergleichen?! on Mon, 20 Jun 2011 05:20:11 GMT]]></title><description><![CDATA[<p>Du kannst zwei char Arrays nicht mit == vergleichen (bzw. es wird nicht der Inhalt verglichen). Benutze dazu strcmp und die Verwandschaft.</p>
<p><a href="http://www.cplusplus.com/reference/clibrary/cstring/strcmp/" rel="nofollow">http://www.cplusplus.com/reference/clibrary/cstring/strcmp/</a></p>
<p><strong>Edit</strong><br />
Oder benutze std::string wo es geht.<br />
<a href="http://www.cplusplus.com/reference/string/string/" rel="nofollow">http://www.cplusplus.com/reference/string/string/</a><br />
<a href="http://www.cplusplus.com/reference/string/operators/" rel="nofollow">http://www.cplusplus.com/reference/string/operators/</a></p>
<pre><code class="language-cpp">#include &lt;string&gt;

// ... im Code
std::string Username = &quot;Blabla&quot;;

char UsernameInput[200]; 
GetWindowText(hwndEdit1, (LPSTR)UsernameInput, GetWindowTextLength(hwndEdit1)+1);

if (Username == UsernameInput)
{
   // Granted
}
else
{
   // Denied
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2080901</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2080901</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Mon, 20 Jun 2011 05:20:11 GMT</pubDate></item><item><title><![CDATA[Reply to GetWindowText mit string vergleichen?! on Mon, 20 Jun 2011 10:44:47 GMT]]></title><description><![CDATA[<p>Noch als Ergänzung: Du vergleichst in deinem Code die Adressen die eigentlich nie gleich sein dürfen (es sei denn du weist der eine dem anderen zu).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2081001</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2081001</guid><dc:creator><![CDATA[EOutOfResources]]></dc:creator><pubDate>Mon, 20 Jun 2011 10:44:47 GMT</pubDate></item><item><title><![CDATA[Reply to GetWindowText mit string vergleichen?! on Mon, 20 Jun 2011 20:47:17 GMT]]></title><description><![CDATA[<p>Danke schön.. hat mit std::string funktioniert!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2081401</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2081401</guid><dc:creator><![CDATA[Santo]]></dc:creator><pubDate>Mon, 20 Jun 2011 20:47:17 GMT</pubDate></item></channel></rss>