CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    121

    GetProfileString

    I hope someone can shed some light!!!

    I'm trying to get a path I've saved prior. When I do the GetprofilePath it never finds what I've set it to and I know it's there. Can someone tell me what I'm doing wrong. Thank you!

    Also It writes the information in my win.ini how do I make it to write in the registry?

    Thanks
    void CVRUtilitiesApp::OnBackupsetupPathtobackup()
    {
    // TODO: Add your command handler code here
    CString str = GetProfileString("Virtual Recorder", "Path to");
    if(!str.IsEmpty()){
    CDlgIni dlg;
    dlg.DoModal();
    }
    else{
    CPathVRecord dlgVR;
    dlgVR.DoModal();
    }
    }
    void CPathVRecord::OnOK()
    {
    bool canExit = true;
    UpdateData(TRUE);
    CString vRecord = GetVirtualRecorder();
    if(vRecord.IsEmpty()){
    AfxMessageBox(IDS_WARN_NOPATHENTERED, MB_OK|MB_ICONSTOP);
    canExit= false;

    }

    if(canExit){
    WriteProfileString("Virtual Recorder", "Path to", vRecord);
    CDlgIni dlg;
    dlg.DoModal();
    CDialog::OnOK();
    }
    }
    void CDlgIni::OnOK()
    {
    bool canExit = true;
    UpdateData(TRUE); //Will update all existing variables.
    CString backUpPath = GetBackUpPath();
    if(backUpPath.IsEmpty()){
    AfxMessageBox(IDS_WARN_NOPATHENTERED, MB_OK|MB_ICONSTOP);
    canExit= false;
    }
    else{
    Path path (ToString(backUpPath));
    Path pathreponse(ToString(backUpPath));
    Path pathLessons(ToString(backUpPath));
    pathreponse.AppendToPath("Lavac\\Record.sav");
    pathLessons.AppendToPath("Lavac\\Lecons");
    if(!pathreponse.IsDirect() || !pathLessons.IsDirect()){
    AfxMessageBox(IDS_WARN_BACKUPPATH_NOTEXIST, MB_OK|MB_ICONSTOP);
    canExit = false;
    }
    else{
    if(!theApp.IsVRecordActive()){
    bool iniChanged = true;
    Path destLesson = path;
    Path destResp = path;
    CString finalLesson= ToCString(destLesson.AppendToPath("Lavac\\LECONS"));
    CString finalResp = ToCString(destResp.AppendToPath("Lavac\\record.sav"));
    WritePrivateProfileString("DIRECTORIES", "LESSONS", finalLesson,"vrecord.ini");
    WritePrivateProfileString("DIRECTORIES", "FLOPPY", finalResp,"vrecord.ini");
    theApp.SetIniChanged(iniChanged);
    //VRIniInfo iniInfo;
    //Path getServerPath = ToString(iniInfo.GetServerBasePath());
    //CString serverPath = ToCString(getServerPath.AppendToPath("Lavac\\Vrecord"));
    CString str = AfxGetApp()->GetProfileString("Virtual Recorder", "Path to");
    ShellExecute (AfxGetMainWnd()->GetSafeHwnd(), "open", "Vrecord.exe", "/OEM/L:English/S/R/Admin", str , SW_SHOWNORMAL);

    }

    }
    }

    if(canExit)
    CDialog::OnOK();

    }


  2. #2
    Join Date
    May 1999
    Location
    Toronto, Ontario, Canada
    Posts
    155

    Re: GetProfileString

    Try initializing the following 2 variables in your CWinApp

    m_pszProfileName <---- The application's .INI filename.
    m_pszRegistryKey <---- Used to determine the full registry key for storing application profile settings.

    -Safai

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured