Click here to Skip to main content
15,915,603 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Answerfor you, VB Pin
toxcct28-Jun-07 7:35
toxcct28-Jun-07 7:35 
AnswerDon't answer this user Pin
leckey28-Jun-07 7:53
leckey28-Jun-07 7:53 
GeneralRe: Don't answer this user Pin
Hamid_RT28-Jun-07 8:25
Hamid_RT28-Jun-07 8:25 
GeneralRe: Don't answer this user Pin
leckey28-Jun-07 9:01
leckey28-Jun-07 9:01 
AnswerRe: C# Pin
Hamid_RT29-Jun-07 3:03
Hamid_RT29-Jun-07 3:03 
QuestionINI insted of Registry Pin
Abhijeet Pathak28-Jun-07 7:11
Abhijeet Pathak28-Jun-07 7:11 
AnswerRe: INI insted of Registry Pin
Joan M28-Jun-07 7:29
professionalJoan M28-Jun-07 7:29 
AnswerRe: INI insted of Registry Pin
Hans Dietrich28-Jun-07 8:34
mentorHans Dietrich28-Jun-07 8:34 
You can easily switch to using INI files. The major problem you will have is deciding where to put them - Microsoft discourages writing into any of the C:\Program Files folders, which is where your app will usually be installed. But, once you know where you want it, switching to INI file is easy:

  1. Construct path to INI file:
    BOOL CApp::InitInstance()
    {
        .
        .
        .
        m_strProfileFilePath = "";        // m_strProfileFilePath is CString member of CApp
    
        // let's put INI in exe directory
        m_strProfileFilePath = GetModulePath();
        m_strProfileFilePath += "\\";
        m_strProfileFilePath += "MyApp.ini";

  2. Next we need to clean up MFC's default INI string:
    // save our ini file name --
    // first free the string allocated by MFC at CWinApp startup.
    // The string is allocated before InitInstance is called.
    free((void*)m_pszProfileName);
    
    // Change the name of the .INI file.
    // The CWinApp destructor will free the memory.
    // Note:  must be allocated on heap
    m_pszProfileName = _strdup(m_strProfileFilePath);
    

  3. Now we can use the standard profile functions in CWinApp:
        // write some stuff to INI file 
    
    //    [FilesToAdd]
    //    File001=CRASH.DMP,Crash Dump,DMP File
    //    File002=ERRORLOG.TXT,Crash log,Text Document
    //    File003=MyApp.ini,INI File,Text Document
    
        WriteProfileString("FilesToAdd", "File001", "CRASH.DMP,Crash Dump,DMP File");
        WriteProfileString("FilesToAdd", "File002", "ERRORLOG.TXT,Crash log,Text Document");
        WriteProfileString("FilesToAdd", "File003", "MyApp.ini,INI File,Text Document");
        .
        .
        .



QuestionCStatic text box Pin
mcsherry28-Jun-07 6:07
mcsherry28-Jun-07 6:07 
AnswerRe: CStatic text box Pin
mcsherry28-Jun-07 6:27
mcsherry28-Jun-07 6:27 
AnswerRe: CStatic text box Pin
Wes Aday28-Jun-07 6:29
professionalWes Aday28-Jun-07 6:29 
AnswerRe: CStatic text box Pin
Mark Salsbery28-Jun-07 6:29
Mark Salsbery28-Jun-07 6:29 
Questionwhat's function? Pin
Max++28-Jun-07 6:00
Max++28-Jun-07 6:00 
AnswerRe: what's function? Pin
Wes Aday28-Jun-07 6:30
professionalWes Aday28-Jun-07 6:30 
GeneralRe: what's function? Pin
led mike28-Jun-07 6:33
led mike28-Jun-07 6:33 
GeneralRe: what's function? Pin
Mark Salsbery28-Jun-07 6:35
Mark Salsbery28-Jun-07 6:35 
GeneralRe: what's function? Pin
Wes Aday28-Jun-07 6:39
professionalWes Aday28-Jun-07 6:39 
QuestionRe: what's function? Pin
Mark Salsbery28-Jun-07 6:34
Mark Salsbery28-Jun-07 6:34 
AnswerRe: what's function? Pin
Max++28-Jun-07 7:00
Max++28-Jun-07 7:00 
AnswerRe: what's function? Pin
led mike28-Jun-07 7:52
led mike28-Jun-07 7:52 
AnswerRe: what's function? Pin
Adno28-Jun-07 8:55
Adno28-Jun-07 8:55 
GeneralRe: what's function? Pin
led mike28-Jun-07 9:21
led mike28-Jun-07 9:21 
GeneralRe: what's function? Pin
Adno28-Jun-07 9:44
Adno28-Jun-07 9:44 
AnswerRe: what's function? [modified] Pin
led mike28-Jun-07 9:23
led mike28-Jun-07 9:23 
GeneralRe: what's function? Pin
Mark Salsbery28-Jun-07 11:16
Mark Salsbery28-Jun-07 11:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.