<?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[Registry]]></title><description><![CDATA[<p>Also ich wollte iegentlich nur mal eben einen Autostart einrivhten und dass ging eigentlich bisher auch immer aber irgendwas mache ich anscheinend grade falsch.</p>
<pre><code class="language-cpp">char pfadname[500];
HKEY hKey;
GetModuleFileName(NULL, pfadname, 500);
RegCreateKey(HKEY_LOCAL_MACHINE,&quot;SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\&quot;,&amp;hKey);
RegSetValueEx(hKey,&quot;Test1&quot;,0,REG_SZ,pfadname,strlen(pfadname)+1);
RegCloseKey(hKey);
</code></pre>
<p>Was stimmt daran nicht?Eigentlich sollte doch dann einfach der Pfad meines Programmes geschreiben werden oder????</p>
<p>Thx</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/206311/registry</link><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Apr 2026 07:26:17 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/206311.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 23 Feb 2008 13:02:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Registry on Sat, 23 Feb 2008 13:02:17 GMT]]></title><description><![CDATA[<p>Also ich wollte iegentlich nur mal eben einen Autostart einrivhten und dass ging eigentlich bisher auch immer aber irgendwas mache ich anscheinend grade falsch.</p>
<pre><code class="language-cpp">char pfadname[500];
HKEY hKey;
GetModuleFileName(NULL, pfadname, 500);
RegCreateKey(HKEY_LOCAL_MACHINE,&quot;SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\&quot;,&amp;hKey);
RegSetValueEx(hKey,&quot;Test1&quot;,0,REG_SZ,pfadname,strlen(pfadname)+1);
RegCloseKey(hKey);
</code></pre>
<p>Was stimmt daran nicht?Eigentlich sollte doch dann einfach der Pfad meines Programmes geschreiben werden oder????</p>
<p>Thx</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1461464</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1461464</guid><dc:creator><![CDATA[Frager45673]]></dc:creator><pubDate>Sat, 23 Feb 2008 13:02:17 GMT</pubDate></item><item><title><![CDATA[Reply to Registry on Sat, 23 Feb 2008 13:08:32 GMT]]></title><description><![CDATA[<p>Ich habe jetzt, da die Fehlermeldung sich über die char(die kein byte war <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> ) beschwert hat, so abgeändert:</p>
<pre><code class="language-cpp">byte pfadname[500];
HKEY hKey;
GetModuleFileName(NULL, (char*)pfadname, 500);
RegCreateKey(HKEY_LOCAL_MACHINE,&quot;SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\&quot;,&amp;hKey);
RegSetValueEx(hKey,&quot;Test1&quot;,0,REG_SZ,pfadname,strlen((char*)pfadname)+1);
RegCloseKey(hKey);
</code></pre>
<p>Jetzt gibt es auch keinen Fehler mehr!!!!....<br />
Aber leider wird der Wert trotzdem nicht erstellt <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>
<p>Woran kann das liegen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1461469</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1461469</guid><dc:creator><![CDATA[Frager45673]]></dc:creator><pubDate>Sat, 23 Feb 2008 13:08:32 GMT</pubDate></item><item><title><![CDATA[Reply to Registry on Sat, 23 Feb 2008 14:28:30 GMT]]></title><description><![CDATA[<p>Casten sollte man immer vermeiden, wenn man nicht weis was man tut!<br />
Entweder: Übersetze Dein Projekt mit &quot;Multi-byte Character-Set&quot; (Projekteinstellungen|General) oder verwende die TCHAR-Typen... z.B.:</p>
<pre><code class="language-cpp">TCHAR szPfadName[1024];
GetModuleFileName(NULL, szPfadName, 1024);
</code></pre>
<p>Und natürlich die Rückgabewerte prüfen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1461532</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1461532</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 23 Feb 2008 14:28:30 GMT</pubDate></item><item><title><![CDATA[Reply to Registry on Sat, 23 Feb 2008 23:32:27 GMT]]></title><description><![CDATA[<p>Ich benutze Multybyte. ABer ohen den casst gibt es einen Compilerfehler</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1461770</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1461770</guid><dc:creator><![CDATA[Test546576]]></dc:creator><pubDate>Sat, 23 Feb 2008 23:32:27 GMT</pubDate></item><item><title><![CDATA[Reply to Registry on Sun, 24 Feb 2008 07:51:11 GMT]]></title><description><![CDATA[<p>Dann änder &quot;byte&quot; nach &quot;char&quot; oder nimm einfach meinen Code...<br />
PS: Leider muss man bei &quot;RegSetValueEx&quot; casten... da man bei diese Funktion verschiedene Datentypen übergeben kann...<br />
PPS: Auch solltest Du *alle* Rückgabewerte prüfen, ob ein Fehler auftrat!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1461801</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1461801</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sun, 24 Feb 2008 07:51:11 GMT</pubDate></item><item><title><![CDATA[Reply to Registry on Sun, 24 Feb 2008 13:51:05 GMT]]></title><description><![CDATA[<p>Hmm... Kannst du vllt mein Codebeispiel nochmal richtig posten? Ich weiß jetzt nciht genau in was ich das jetzt casten soll und von welchem Typ die variable sein soll. Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1461950</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1461950</guid><dc:creator><![CDATA[Fragezeichen4556]]></dc:creator><pubDate>Sun, 24 Feb 2008 13:51:05 GMT</pubDate></item><item><title><![CDATA[Reply to Registry on Sun, 24 Feb 2008 14:15:23 GMT]]></title><description><![CDATA[<p>Ich verstehe nicht, was an dem Beispiel in der Hilfe unverständlich ist:<br />
<a href="http://msdn2.microsoft.com/en-us/library/aa363634(VS.85).aspx" rel="nofollow">http://msdn2.microsoft.com/en-us/library/aa363634(VS.85).aspx</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1461971</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1461971</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sun, 24 Feb 2008 14:15:23 GMT</pubDate></item><item><title><![CDATA[Reply to Registry on Sun, 24 Feb 2008 14:24:48 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">void CreateRegistryEntry (char *lpEntryName,
                          char *lpEntryOption = NULL,
                          char *lpEntryValue = NULL,
                          HKEY hKey = HKEY_LOCAL_MACHINE,
                          char *lpRegistryPath = NULL)
{
    HKEY hk;

    char szBuffer[MAX_PATH + 2];
    char szResult[MAX_PATH + 5 + sizeof (lpEntryOption)];
    GetModuleFileName (NULL, szBuffer, MAX_PATH);

    if (lpRegistryPath == NULL)
        RegCreateKey (hKey, &quot;SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run&quot;, &amp;hk);
    else
        RegCreateKey (hKey, lpRegistryPath, &amp;hk);

    if (lpEntryValue == NULL)
    {
        if (lpEntryOption == NULL)
            lstrcpy (szResult, szBuffer);
        else
            wsprintf (szResult, &quot;\&quot;%s\&quot; %s&quot;, szBuffer, lpEntryOption);

        RegSetValueEx (hk, lpEntryName, 0, REG_SZ, szResult, strlen (szResult));
    }
    else
        RegSetValueEx (hk, lpEntryName, 0, REG_SZ, lpEntryValue, strlen (lpEntryValue));

    RegCloseKey (hk);
}

void DeleteRegistryEntry (char *lpEntryName,
                          HKEY hKey = HKEY_LOCAL_MACHINE,
                          char *lpRegistryPath = NULL)
{
    HKEY hk;

    if (lpRegistryPath == NULL)
        RegCreateKey (hKey, &quot;SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run&quot;, &amp;hk);
    else
        RegCreateKey (hKey, lpRegistryPath, &amp;hk);

    RegDeleteValue (hk, lpEntryName);

    RegCloseKey (hk);
}

bool PeruseRegistryEntry (char *lpEntryName,
                          HKEY hKey = HKEY_LOCAL_MACHINE,
                          char *lpRegistryPath = NULL)
{
    HKEY hk;
    bool bReturn = false;

    if (lpRegistryPath == NULL)
        RegCreateKey (hKey, &quot;SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run&quot;, &amp;hk);
    else
        RegCreateKey (hKey, lpRegistryPath, &amp;hk);

    if (RegQueryValueEx (hk, lpEntryName, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
        bReturn = true;
    else
        bReturn = false;

    RegCloseKey (hk);

    return bReturn;
}
</code></pre>
<p>sind mal drei funktionen...also man kann entweder direkt autostart einträge damit erstellen, oder auch sonst welche eben je nach parameter übergabe...<br />
als beispiel für autostart-einträge:</p>
<pre><code class="language-cpp">//Autostart-Eintrag erstellen
CreateRegistryEntry (&quot;Autostart&quot;);
//Autostart-Eintrag löschen
DeleteRegistryEntry (&quot;Autostart&quot;);
//Überprüfen ob Autostart-Eintrag vorhanden ist
PeruseRegistryEntry (&quot;Autostart&quot;);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1461973</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1461973</guid><dc:creator><![CDATA[Fake oder Echt]]></dc:creator><pubDate>Sun, 24 Feb 2008 14:24:48 GMT</pubDate></item></channel></rss>