本文整理汇总了C++中CWinApp::GetProfileString方法的典型用法代码示例。如果您正苦于以下问题:C++ CWinApp::GetProfileString方法的具体用法?C++ CWinApp::GetProfileString怎么用?C++ CWinApp::GetProfileString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CWinApp
的用法示例。
在下文中一共展示了CWinApp::GetProfileString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CDialog
CRunMap::CRunMap(CWnd* pParent /*=NULL*/)
: CDialog(CRunMap::IDD, pParent)
{
m_bSwitchMode = FALSE;
//{{AFX_DATA_INIT(CRunMap)
m_iVis = -1;
m_bNoQuake = FALSE;
m_strQuakeParms = _T("");
m_bSaveVisiblesOnly = FALSE;
m_iLight = -1;
m_iCSG = -1;
m_iQBSP = -1;
//}}AFX_DATA_INIT
// read from ini
CWinApp *App = AfxGetApp();
m_iCSG = App->GetProfileInt(pszSection, "CSG", 0);
m_iQBSP = App->GetProfileInt(pszSection, "QBSP", 0);
// The onlyents option was moved to the CSG setting, so don't allow it for BSP.
if (m_iQBSP > 1)
{
m_iQBSP = 1;
}
m_iVis = App->GetProfileInt(pszSection, "Vis", 0);
m_iLight = App->GetProfileInt(pszSection, "Light", 0);
m_bNoQuake = App->GetProfileInt(pszSection, "No Game", 0);
m_strQuakeParms = App->GetProfileString(pszSection, "Game Parms", "");
}
示例2: OnBnClickedBrowseAVI
void ImageDialog::OnBnClickedBrowseAVI()
{
CWinApp* theApp = AfxGetApp();
char buffer[MAX_PATH];
string lastSave;
lastSave = theApp->GetProfileString("Last Config", "lastSave");
int trim = lastSave.rfind("\\");
lastSave = lastSave.substr(0, trim);
buffer[0] = '\0';
OPENFILENAME browse;
ZeroMemory(&browse, sizeof(browse));
browse.lStructSize = sizeof(browse);
browse.hwndOwner = this->m_hWnd;
browse.lpstrFile = buffer;
browse.nMaxFile = sizeof(buffer);
browse.lpstrFilter = "AVI Files\0*.avi\0";
browse.nFilterIndex = 1;
browse.lpstrTitle = "Save to AVI File";
browse.lpstrFileTitle = 0;
browse.lpstrInitialDir = lastSave.c_str();
browse.lpstrDefExt = "avi";
browse.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT;
if (GetSaveFileName(&browse) != 0)
{
AVIFilename.SetWindowText(buffer);
SetAviOptions();
aviwriter->OpenFile();
compressionButton.EnableWindow(TRUE);
}
}
示例3: OnButtonSource
void COptionsPage::OnButtonSource(void)
{
CString strPrompt;
strPrompt.LoadString(IDS_CHOOSE_SOURCE);
CFolderDialog dlgFolder(strPrompt, m_strSource, this, BIF_NEWDIALOGSTYLE);
if (dlgFolder.DoModal() == IDOK)
{
m_strSource = dlgFolder.GetFolderPath();
SetDlgItemText(IDC_EDIT_SOURCE, m_strSource);
#if (_MFC_VER < 0x0700)
CWinApp* pApp = AfxGetApp();
ASSERT_VALID(pApp);
if ((m_timeWrite = pApp->GetProfileInt(SZ_REGK_TIMES, m_strSource, -1)) != -1)
#else
CUpdateItApp* pApp = DYNAMIC_DOWNCAST(CUpdateItApp, AfxGetApp());
ASSERT_VALID(pApp);
if ((m_timeWrite = pApp->GetProfileTime(SZ_REGK_TIMES, m_strSource, -1)) != -1)
#endif // _MFC_VER
{
m_dtpWrite.SetTime(&m_timeWrite);
}
CString strDefTarget = m_strSource + _T(".Update");
SetDlgItemText(IDC_EDIT_TARGET, pApp->GetProfileString(SZ_REGK_TARGETS, m_strSource, strDefTarget));
}
}
示例4: AfxGetApp
/////////////////////////////////////////////////////////////////////////////
// Create font from info in the application profile. Reads info in the form
// facename, ptsize, weight, italic
//
zBOOL
ZFontUI::GetProfileFont( zCPCHAR cpcKey,
zCPCHAR cpcVal,
CFont& font,
CDC *pDC )
{
CWinApp *pApp = AfxGetApp( );
ASSERT_VALID( pApp );
CString zs = pApp->GetProfileString( cpcKey, cpcVal );
if ( zs.IsEmpty( ) )
return( FALSE );
LOGFONT lf;
zmemset( &lf, 0, sizeof( LOGFONT ) );
lf.lfCharSet = DEFAULT_CHARSET;
int bItalic;
int nPtSize;
// scanf is overkill, but I'm lazy
if ( sscanf( (zCPCHAR) zs, "%[a-zA-Z ],%d,%d,%d",
lf.lfFaceName, &nPtSize, &lf.lfWeight, &bItalic ) != 4 )
{
return( FALSE );
}
lf.lfHeight = MulDiv( -nPtSize, // convert ptsize to logical units
::GetDeviceCaps( pDC ? pDC->m_hDC : ::GetDC( 0 ), LOGPIXELSY ), 72 );
lf.lfItalic = bItalic; // because lf.lfItalic is a BYTE
font.DeleteObject( ); // bye
return( font.CreateFontIndirect( &lf ) );
}
示例5: ClearHistory
// removes all the items from the history list, and optionally deletes
// the registry items. Note that if the history list is generated from
// a CRecentFileList, then registry entries will not be deleted
void CHistoryCombo::ClearHistory(BOOL bDeleteRegistryEntries/*=TRUE*/)
{
ResetContent();
if (! m_sSection.IsEmpty() && bDeleteRegistryEntries)
{
// remove profile entries
CWinApp* pApp = AfxGetApp();
ASSERT(pApp);
CString sKey;
for (int n = 0; n < 1000/* prevent runaway*/; n++)
{
sKey.Format(KEY_PREFIX_FORMAT, m_sKeyPrefix, n);
CString sText = pApp->GetProfileString(m_sSection, sKey);
if (sText.IsEmpty())
break;
pApp->WriteProfileString(m_sSection, sKey, NULL); // remove entry
}
if (! m_sKeyCurItem.IsEmpty())
sKey = m_sKeyCurItem;
else if (m_sKeyPrefix.IsEmpty())
sKey = _T("Last");
else
sKey = m_sKeyPrefix;
pApp->WriteProfileString(m_sSection, sKey, NULL);
}
}
示例6: OnBnClickedBrowse
void ImageDialog::OnBnClickedBrowse()
{
CWinApp* theApp = AfxGetApp();
char buffer[MAX_PATH];
string lastSave;
lastSave = theApp->GetProfileString("Last Config", "lastSave");
int trim = lastSave.rfind("\\");
lastSave = lastSave.substr(0, trim);
buffer[0] = '\0';
OPENFILENAME browse;
ZeroMemory(&browse, sizeof(browse));
browse.lStructSize = sizeof(browse);
browse.hwndOwner = this->m_hWnd;
browse.lpstrFile = buffer;
browse.nMaxFile = sizeof(buffer);
browse.lpstrFilter = "All Files\0*.*\0";
browse.nFilterIndex = 1;
browse.lpstrTitle = "Select Save Path/Filename";
browse.lpstrFileTitle = 0;
browse.lpstrInitialDir = lastSave.c_str();
browse.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (GetSaveFileName(&browse) != 0)
{
string file(buffer);
pngwriter->SetFileName(file);
filePath.SetWindowText(pngwriter->GetFileName().c_str());
}
}
示例7: OnCreate
// MmView message handlers
int MmView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
m_timer_id = SetTimer(1, 500, 0);
// Set static handle
s_hwnd = GetSafeHwnd();
ModifyStyle(0, WS_CLIPCHILDREN); // reduce flicker
#ifdef WITH_SPLASH_SCREEN
LocateWelcomeDoc(TEXT(WITH_SPLASH_SCREEN));
#else
if(LocateWelcomeDoc(TEXT("..\\..\\Extras\\Welcome\\Welcome.smil")) ||
LocateWelcomeDoc(TEXT("Extras\\Welcome\\Welcome.smil")) ||
LocateWelcomeDoc(TEXT("Welcome.smil"))){;}
#endif
#ifdef WITH_SPLASH_SCREEN
PostMessage(WM_COMMAND, ID_HELP_WELCOME);
#else
CWinApp* pApp = AfxGetApp();
CString val = pApp->GetProfileString(_T("Settings"), _T("Welcome"));
if(val.IsEmpty()) {
// first time; write the string and play welcome
pApp->WriteProfileString(_T("Settings"), _T("Welcome"), _T("1"));
if(!m_welcomeDocFilename.IsEmpty())
PostMessage(WM_COMMAND, ID_HELP_WELCOME);
}
#endif
return 0;
}
示例8: AfxGetApp
CString
TestRunnerModel::loadHistoryEntry( int idx )
{
CWinApp *app = AfxGetApp();
ASSERT( app != NULL );
return app->GetProfileString( _T("CppUnit"), getHistoryEntryName( idx ) );
}
示例9: init
void CChatViewerFont::init()
{
CWinApp* app = AfxGetApp();
name = app->GetProfileString( "Style\\Font", "name", name.c_str() );
size = app->GetProfileInt( "Style\\Font", "size", size );
codepage = app->GetProfileInt( "Style\\Font", "codepage", codepage );
characterSet = app->GetProfileInt( "Style\\Font", "characterSet", characterSet );
}
示例10: SaveHistory
// saves the history to the profile specified when calling LoadHistory
// if no profile information (ie LoadHistory() wasn't called with it) then
// this function does nothing
void CHistoryCombo::SaveHistory(BOOL bAddCurrentItemToHistory/*=TRUE*/)
{
TRACE(_T("in CHistoryCombo::SaveHistory\n"));
if (m_sSection.IsEmpty())
return;
CWinApp* pApp = AfxGetApp();
ASSERT(pApp);
if (bAddCurrentItemToHistory)
{
CString sCurItem;
GetWindowText(sCurItem);
// trim it, so we items which differ only by a leading/trailing space
sCurItem.TrimLeft();
sCurItem.TrimRight();
if (! sCurItem.IsEmpty())
AddString(sCurItem);
}
// save history to info cached earlier
int nMax = min(GetCount(), m_nMaxHistoryItems + 1);
int n = 0;
for (n = 0; n < nMax; n++)
{
CString sKey;
sKey.Format(KEY_PREFIX_FORMAT, m_sKeyPrefix, n);
CString sText;
GetLBText(n, sText);
pApp->WriteProfileString(m_sSection, sKey, sText);
//TRACE(_T("m_sSection=%s sKey=%s sText=%s\n"), m_sSection, sKey, sText);
}
// remove redundant items
for (n = nMax; n < 1000/* prevent runaway*/; n++)
{
CString sKey;
sKey.Format(KEY_PREFIX_FORMAT, m_sKeyPrefix, n);
TRACE(_T("m_sKeyPrefix=%s\n"), m_sKeyPrefix);
CString sText = pApp->GetProfileString(m_sSection, sKey);
if (sText.IsEmpty())
break;
pApp->WriteProfileString(m_sSection, sKey, NULL); // remove entry
}
if (m_bSaveRestoreLastCurrent)
{
CString sText;
GetWindowText(sText);
CString sKey;
if (!m_sKeyCurItem.IsEmpty())
sKey = m_sKeyCurItem;
else if (m_sKeyPrefix.IsEmpty())
sKey = _T("Last");
else
sKey = m_sKeyPrefix;
pApp->WriteProfileString(m_sSection, sKey, sText);
}
}
示例11: ReadFromRegistry
bool CEsmOptions::ReadFromRegistry (void) {
CWinApp* pApp = AfxGetApp();
CString Buffer;
bool Result;
/* General options */
Buffer = pApp->GetProfileString(ESMSCR_REGSEC_GENERAL, ESMSCR_REGENTRY_AUTHORNAME, NULL);
SetAuthorName(Buffer);
Buffer = pApp->GetProfileString(ESMSCR_REGSEC_GENERAL, ESMSCR_REGENTRY_DATAPATH, NULL);
SetDataPath(Buffer);
TerminatePath(m_DataPath);
if (Buffer.IsEmpty()) {
FindMWRegistryPath();
}
else {
SetMWDataPath(Buffer);
}
m_BackupSaves = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_BACKUPSAVES, m_BackupSaves) != 0);
m_AllowExtFuncs = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_ALLOWEXTFUNCS, m_AllowExtFuncs) != 0);
m_StrictIDs = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_STRICTIDS, m_StrictIDs) != 0);
m_AllowBloodmoon = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_ALLOWBLOODMOON, m_AllowBloodmoon) != 0);
m_AllowTribunal = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_ALLOWTRIBUNAL, m_AllowTribunal) != 0);
/* Script options */
m_ScriptWarnLevel = pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_WARNLEVEL, m_ScriptWarnLevel);
m_NoScriptFormat = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_NOSCRFORMAT, m_NoScriptFormat) != 0);
m_UseExtraFile = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_USEEXTRAFILE, m_UseExtraFile) != 0);
m_NoScriptPrompt = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_NOSCRPROMPT, m_NoScriptPrompt) != 0);
m_InitialIndentLevel = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_INITIALINDENTLEVEL, m_InitialIndentLevel) != 0);
m_IndentCommentsMore = (pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_INDENTCOMMENTSMORE, m_IndentCommentsMore) != 0);
m_ScriptFormatType = pApp->GetProfileInt(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_SCRFORMAT, m_ScriptFormatType);
Buffer = pApp->GetProfileString(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_EXTRAFILE, m_ExtraFile);
SetExtraFile(Buffer);
Buffer = pApp->GetProfileString(ESMSCR_REGSEC_SCRIPT, ESMSCR_REGENTRY_SCRIPTINDENTSTRING, m_ScriptIndentString);
SetScriptIndentString(Buffer);
/* Script user format */
Result = m_UserScriptOptions.ReadFromRegistry();
return (Result);
}
示例12: testRegistration
bool CRegistrationDlg::testRegistration( bool initializingDialog )
{
if( initializingDialog )
{
// Get the app.
CWinApp * pApp = AfxGetApp( );
if( ! pApp )
return false;
// Read all the settings.
m_emailAddress = pApp->GetProfileString( REGISTRY_SECTION_REGISTRATION_INFO, REGISTRY_ENTRY_EMAIL_ADDRESS );
m_registrationKey = pApp->GetProfileString( REGISTRY_SECTION_REGISTRATION_INFO, REGISTRY_ENTRY_REGISTRATION_KEY );
}
else
{
UpdateData( );
}
// Get the expected registration key from this email address.
CString generatedKey;
CRegistrationHelper registrationHelper;
registrationHelper.generateRegistrationKey( m_emailAddress, generatedKey );
// Does the key match?
if( generatedKey == m_registrationKey )
{
// Get the app.
CWinApp * pApp = AfxGetApp( );
if( ! pApp )
return false;
// Save the settings for the future.
pApp->WriteProfileString( REGISTRY_SECTION_REGISTRATION_INFO, REGISTRY_ENTRY_EMAIL_ADDRESS, m_emailAddress );
pApp->WriteProfileString( REGISTRY_SECTION_REGISTRATION_INFO, REGISTRY_ENTRY_REGISTRATION_KEY, m_registrationKey );
// Update us and the drawing.
UpdateData( FALSE );
m_pG3DCallback->updateDrawing( );
return true;
}
return false;
}
示例13: LoadHistory
// loads the history from the specified profile area, and returns the
// text selected
// the profile area is kept so that in doesn't need to specified again
// when saving the history
CString CHistoryCombo::LoadHistory(LPCTSTR lpszSection, LPCTSTR lpszKeyPrefix,
BOOL bSaveRestoreLastCurrent/*=TRUE*/,
LPCTSTR lpszKeyCurItem/*=NULL*/)
{
if (lpszSection == NULL || lpszKeyPrefix == NULL || *lpszSection == '\0')
return "";
m_sSection = lpszSection;
m_sKeyPrefix = lpszKeyPrefix;
m_sKeyCurItem = lpszKeyCurItem == NULL ? "" : lpszKeyCurItem;
m_bSaveRestoreLastCurrent = bSaveRestoreLastCurrent;
CWinApp* pApp = AfxGetApp();
int n = 0;
CString sText;
do
{
CString sKey;
sKey.Format("%s%d", m_sKeyPrefix, n++);
sText = pApp->GetProfileString(m_sSection, sKey);
if (!sText.IsEmpty())
CComboBox::AddString(sText);
}while (!sText.IsEmpty());
if (m_bSaveRestoreLastCurrent)
{
CString sKey;
if (!m_sKeyCurItem.IsEmpty())
sKey = m_sKeyCurItem;
else if (m_sKeyPrefix.IsEmpty())
sKey = "Last";
else
sKey = m_sKeyPrefix;
sText = pApp->GetProfileString(m_sSection, sKey);
if (!sText.IsEmpty())
{
int nIndex = FindStringExact(-1, sText);
if (nIndex != -1)
SetCurSel(nIndex);
else if (GetStyle() & CBS_DROPDOWN)
SetWindowText(sText);
}
}
return sText;
}
示例14: Help
void FindDialog::Help()
{
CString str;
CWinApp *app;
app = AfxGetApp();
str = app->GetProfileString("help", "path");
str = str + "\\find_dialog.html";
ShellExecute(m_hWnd, "open", str, NULL, NULL, SW_SHOWNORMAL);
}
示例15: documentPath
void AppSetting:: loadApplicationSetting()
{
CWinApp* pApp = AfxGetApp();
showNavigation = pApp->GetProfileInt(REGKEY_APP_NAME, REGKEY_SHOW_NAVIGATION, 1) != 0;//0 -> false; 1 -> true
bShowHelpText = pApp->GetProfileInt(REGKEY_APP_NAME, REGKEY_DISPLAY_TEXT, 1) != 0;
bShowAxis = pApp->GetProfileInt(REGKEY_APP_NAME, REGKEY_DISPLAY_AXIS, 1) != 0;
objPath = pApp->GetProfileString(REGKEY_APP_NAME, REGKEY_OBJECT_PATH);
simulationDataPath = pApp->GetProfileString(REGKEY_APP_NAME, REGKEY_SIM_DATA_PATH);
CHAR my_documents[MAX_PATH];
HRESULT result = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, my_documents);
CString documentPath(my_documents);
documentPath.AppendFormat("\\%s", SETTING_NAME);
if (GetFileAttributes(documentPath) == INVALID_FILE_ATTRIBUTES)
{
CreateDirectory(documentPath,NULL);
}
}