Settings Path ändern?



  • Hallo,
    habe hier einen Code, welcher meine Variablen in eine Datei speichert. Im Moment wird es in C:\Windows gespeichert. Ich will aber, dass es am selben Platz gespeichert wird, wo sich die Application befindet.
    Hier der Code:

    BOOL WritePrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, int nInteger, LPCTSTR lpFileName){
        TCHAR lpString[ 1024 ];
        wsprintf( lpString, "%d", nInteger );
        return WritePrivateProfileString( lpAppName, lpKeyName, lpString, lpFileName );
    }
    void Settings::Save( void ){
    	char szIniFile [ MAX_PATH ] = "settings.cfg";
    	WritePrivateProfileInt( "CVARS", "a", a, szIniFile );
    
    }
    void Settings::Load( void ){
    	char szIniFile[ MAX_PATH ] = "settings.cfg";
    	a = GetPrivateProfileIntA( "CVARS", "a", a, szIniFile );
    

    Danke im Voraus!



  • Dann verwandle szIniFile in einen absoluten und nicht in einen relativen Pfad.

    MSDN schrieb:

    If the lpFileName parameter does not contain a full path and file name for the file, WritePrivateProfileString searches the Windows directory for the file. If the file does not exist, this function creates the file in the Windows directory.

    Außedem falsches Unterforum - WinAPI.



  • Habe es nicht geschafft, da ich noch neu @c++ bin .. kannst du mir sagen, was genau zu machen ist?



  • Dieser Thread wurde von Moderator/in Jochen Kalmbach aus dem Forum C++/CLI mit .NET in das Forum WinAPI verschoben.

    Im Zweifelsfall bitte auch folgende Hinweise beachten:
    C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?

    Dieses Posting wurde automatisch erzeugt.


Anmelden zum Antworten