Einstellungen für eigene Programme speichern



  • Wie kann ich Einstellungen für mein eigenes Programm vom Benutzer verändern und speichern lassen ? Ich bräuchte sozusagen eine eigene Registry.



  • Sony-man 1 schrieb:

    Wie kann ich Einstellungen für mein eigenes Programm vom Benutzer verändern und speichern lassen ? Ich bräuchte sozusagen eine eigene Registry.

    entweder in HKEY_LOKAL_USER

    oder in einer*.ini datei, die du irgendwo sinnvoll hinterlegst.

    Esco



  • Kanst dir ne klasse dafür schreiben, die
    dann die Daten hält und speichert.

    class Config
    {
    public:
    	int Geta();
    	void Seta(int A);
    	int Getb();
    	void Setb(int B);
    public:
    	Config();
    	virtual ~Config();
    	ostream& operator<<(ostream& o);
    	istream& operator<<(istream& i);
    private:
    	int a;	int b;	Config(const Config& copy);
    	Config& operator=(const Config& copy);
    protected:
    
    };
    
    #include"stdafx.h"
    #include "Config.h"
    
    // Config
    
     Config::Config()
    {
    
    }
    
     Config::~Config()
    {
    
    }
    
     Config::Config(const Config& copy)
    {
    
    }
    
    Config& Config::operator=(const Config& copy)
    {
    	return *this;
    }
    
    ostream& Config::operator<<(ostream& o)
    {
    	o << a << '  ' << b;
    	return o;
    }
    
    istream& Config::operator<<(istream& i)
    {
    	i >> a;
    	i >> b;
    	return i;
    }
    
    int Config::Geta()
    {
    	return a;
    }
    
    void Config::Seta(int A)
    {
    	a = A;
    }
    
    int Config::Getb()
    {
    	return b;
    }
    
    void Config::Setb(int B)
    {
    	b = B;
    }
    

    Devil



  • Speichern in der Registry:

    SetRegistryKey(_T("R-Section R-Item")); Sollte in MyApp.cpp enthalten sein

    Da wo es gebraucht wird:

    CWinApp* pApp = AfxGetApp();
    pApp -> WriteProfileString(R - Section,R - Item, zu speichernder Text);

    und wiederholen mit

    pApp -> ReadProfileString(R - Section,R - Item, zu speichernder Text);

    Es gibt auch ProfileInt etc.


Anmelden zum Antworten