<?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[Problem mit fstream und GetUserName.]]></title><description><![CDATA[<p>Hi Leute ich wollte heute ein Programm erstellen da will ich dass es auch andere<br />
Benutzer benutzen können.</p>
<pre><code>TCHAR name [ UNLEN + 1 ];
		DWORD size = UNLEN + 1;

		if (GetUserName( (TCHAR*)name, &amp;size ))
		cout &lt;&lt; &quot;Hello, &quot; &lt;&lt; name &lt;&lt; &quot;!\n&quot;;
		else
		cout &lt;&lt; &quot;Hello, unnamed person!\n&quot;;
//so bekomme ich den UserName
//aber wie kann ich jetzt machen dass da nicht Patrick steht sondern dass auch //andere benutzer die dann zb. einen anderen Namen haben das auch benutzen können.
fstream fout2(&quot;C:\\Users\\Patrick\\Downloads\\Buch\\msvcp110d.dll&quot;, ios::out | ios::binary);
</code></pre>
<p>Danke schonmal im voraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/320263/problem-mit-fstream-und-getusername</link><generator>RSS for Node</generator><lastBuildDate>Fri, 24 Jul 2026 05:54:40 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/320263.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 22 Sep 2013 08:21:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit fstream und GetUserName. on Sun, 22 Sep 2013 08:21:29 GMT]]></title><description><![CDATA[<p>Hi Leute ich wollte heute ein Programm erstellen da will ich dass es auch andere<br />
Benutzer benutzen können.</p>
<pre><code>TCHAR name [ UNLEN + 1 ];
		DWORD size = UNLEN + 1;

		if (GetUserName( (TCHAR*)name, &amp;size ))
		cout &lt;&lt; &quot;Hello, &quot; &lt;&lt; name &lt;&lt; &quot;!\n&quot;;
		else
		cout &lt;&lt; &quot;Hello, unnamed person!\n&quot;;
//so bekomme ich den UserName
//aber wie kann ich jetzt machen dass da nicht Patrick steht sondern dass auch //andere benutzer die dann zb. einen anderen Namen haben das auch benutzen können.
fstream fout2(&quot;C:\\Users\\Patrick\\Downloads\\Buch\\msvcp110d.dll&quot;, ios::out | ios::binary);
</code></pre>
<p>Danke schonmal im voraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2354585</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2354585</guid><dc:creator><![CDATA[DerTechniker123321]]></dc:creator><pubDate>Sun, 22 Sep 2013 08:21:29 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit fstream und GetUserName. on Sun, 22 Sep 2013 08:36:50 GMT]]></title><description><![CDATA[<p>Ich glaube, du musst ins C Board.</p>
<p>Nein warte, du benutzt ja <code>fstream</code> !</p>
<pre><code>DWORD size = UNLEN + 1;
std::basic_string&lt;TCHAR&gt; name(size);

if ( GetUserName( &amp;name[0], &amp;size) )
{
        name.resize( size - 1 );
        cout &lt;&lt; &quot;Hello, &quot; &lt;&lt; name &lt;&lt; &quot;!\n&quot;; // Hier kann es zu Problemen kommen, je nach dem wie TCHAR definiert ist.
}
else
        std::cerr &lt;&lt; &quot;Couldn't retreive user name!&quot;;
</code></pre>
<p>So, das ist besser.</p>
<p>Und um den User-Namen einzusetzen, kannst du<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb762280(v=vs.85).aspx" rel="nofollow"> <code>GetUserProfileDirectory</code> </a>nutzen.<br />
Oder du hängst den User-Namen an <code>C:\\Users\\</code> an, ich bin mir allerdings nicht gewiss, ob das immer funktioniert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2354590</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2354590</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Sun, 22 Sep 2013 08:36:50 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit fstream und GetUserName. on Sun, 22 Sep 2013 09:30:14 GMT]]></title><description><![CDATA[<p>Also mit fstream habe ichs jetzt raus nur bei _mkdir</p>
<p>kann ich nicht dieses hier machen:</p>
<pre><code>TCHAR name [ UNLEN + 1 ];
		DWORD size = UNLEN + 1;

		if (GetUserName( (TCHAR*)name, &amp;size ))
		cout &lt;&lt; &quot;Hello, &quot; &lt;&lt; name &lt;&lt; &quot;!\n&quot;;
		else
		cout &lt;&lt; &quot;Hello, unnamed person!\n&quot;;
		string tada = name;
fstream fout2(&quot;C:\\Users\\&quot;+tada+&quot;\\Downloads\\Buch\\msvcp110d.dll&quot;, ios::out | ios::binary);
</code></pre>
<p>dies funktioniert aber dies funktioniert nicht:</p>
<pre><code>_mkdir(&quot;C:\\Users\\&quot;+tada+&quot;\\Downloads\\Buch&quot;);
</code></pre>
<p>Da kommt dann der Error : Dies ist keine passende Konvertierungsform</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2354600</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2354600</guid><dc:creator><![CDATA[DerTechniker123321]]></dc:creator><pubDate>Sun, 22 Sep 2013 09:30:14 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit fstream und GetUserName. on Sun, 22 Sep 2013 09:39:18 GMT]]></title><description><![CDATA[<pre><code>fstream fout2(&quot;C:\\Users\\&quot;+tada+&quot;\\Downloads\\Buch\\msvcp110d.dll&quot;, ios::out | ios::binary);
</code></pre>
<p>Wenn du nur schreiben willst, dann nimmst du gefälligst einen ofstream:</p>
<pre><code>ofstream out(&quot;C:\\Users\\&quot;+tada+&quot;\\Downloads\\Buch\\msvcp110d.dll&quot;, ios::binary);
</code></pre>
<p>Dieses hier:</p>
<pre><code>_mkdir(&quot;C:\\Users\\&quot;+tada+&quot;\\Downloads\\Buch&quot;);
</code></pre>
<p>kann auch nicht funktionieren, da _mkdir einen C-String erwartet. Ergänzung:</p>
<pre><code>_mkdir( (&quot;C:\\Users\\&quot;+tada+&quot;\\Downloads\\Buch&quot;).c_str() );
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2354602</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2354602</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Sun, 22 Sep 2013 09:39:18 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit fstream und GetUserName. on Sun, 22 Sep 2013 11:01:27 GMT]]></title><description><![CDATA[<p>Sone schrieb:</p>
<blockquote>
<pre><code>fstream fout2(&quot;C:\\Users\\&quot;+tada+&quot;\\Downloads\\Buch\\msvcp110d.dll&quot;, ios::out | ios::binary);
</code></pre>
<p>Wenn du nur schreiben willst, dann nimmst du gefälligst einen ofstream:</p>
<pre><code>ofstream out(&quot;C:\\Users\\&quot;+tada+&quot;\\Downloads\\Buch\\msvcp110d.dll&quot;, ios::binary);
</code></pre>
<p>Dieses hier:</p>
<pre><code>_mkdir(&quot;C:\\Users\\&quot;+tada+&quot;\\Downloads\\Buch&quot;);
</code></pre>
<p>kann auch nicht funktionieren, da _mkdir einen C-String erwartet. Ergänzung:</p>
<pre><code>_mkdir( (&quot;C:\\Users\\&quot;+tada+&quot;\\Downloads\\Buch&quot;).c_str() );
</code></pre>
</blockquote>
<p>Vielen Dank dir das kann geschlossen werden</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2354627</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2354627</guid><dc:creator><![CDATA[DerTechniker123321]]></dc:creator><pubDate>Sun, 22 Sep 2013 11:01:27 GMT</pubDate></item></channel></rss>