home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 18.ddi / MFC / SRC / APPUI.CP_ / APPUI.CP
Encoding:
Text File  |  1993-02-08  |  15.4 KB  |  569 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library. 
  2. // Copyright (C) 1992 Microsoft Corporation 
  3. // All rights reserved. 
  4. //  
  5. // This source code is only intended as a supplement to the 
  6. // Microsoft Foundation Classes Reference and Microsoft 
  7. // QuickHelp and/or WinHelp documentation provided with the library. 
  8. // See these sources for detailed information regarding the 
  9. // Microsoft Foundation Classes product. 
  10.  
  11. #include "stdafx.h"
  12.  
  13. #ifdef AFX_CORE2_SEG
  14. #pragma code_seg(AFX_CORE2_SEG)
  15. #endif
  16.  
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char BASED_CODE THIS_FILE[] = __FILE__;
  20. #endif
  21.  
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CWinApp User Interface Extensions
  24. /////////////////////////////////////////////////////////////////////////////
  25.  
  26. BEGIN_MESSAGE_MAP(CWinApp, CCmdTarget)
  27.     //{{AFX_MSG_MAP(CWinApp)
  28.     // Global File commands
  29.     ON_COMMAND(ID_APP_EXIT, OnAppExit)
  30.     // MRU - most recently used file menu
  31.     ON_UPDATE_COMMAND_UI(ID_FILE_MRU_FILE1, OnUpdateRecentFileMenu)
  32.     ON_UPDATE_COMMAND_UI(ID_FILE_MRU_FILE2, OnUpdateRecentFileMenu)
  33.     ON_UPDATE_COMMAND_UI(ID_FILE_MRU_FILE3, OnUpdateRecentFileMenu)
  34.     ON_UPDATE_COMMAND_UI(ID_FILE_MRU_FILE4, OnUpdateRecentFileMenu)
  35.     ON_COMMAND_EX(ID_FILE_MRU_FILE1, OnOpenRecentFile)
  36.     ON_COMMAND_EX(ID_FILE_MRU_FILE2, OnOpenRecentFile)
  37.     ON_COMMAND_EX(ID_FILE_MRU_FILE3, OnOpenRecentFile)
  38.     ON_COMMAND_EX(ID_FILE_MRU_FILE4, OnOpenRecentFile)
  39.     //}}AFX_MSG_MAP
  40. END_MESSAGE_MAP()
  41.  
  42.  
  43. void CWinApp::OnAppExit()
  44. {
  45.     // same as double-clicking on main window close box
  46.     ASSERT(m_pMainWnd != NULL);
  47.     m_pMainWnd->SendMessage(WM_CLOSE);
  48. }
  49.  
  50. CDocument* CWinApp::OpenDocumentFile(LPCSTR lpszFileName)
  51. {
  52.     // find the highest confidence
  53.     POSITION pos = m_templateList.GetHeadPosition();
  54.     CDocTemplate::Confidence bestMatch = CDocTemplate::noAttempt;
  55.     CDocTemplate* pBestTemplate = NULL;
  56.     CDocument* pOpenDocument = NULL;
  57.  
  58.     char szPath[_MAX_PATH];
  59.     _AfxFullPath(szPath, lpszFileName);
  60.  
  61.     while (pos)
  62.     {
  63.         CDocTemplate* pTemplate = (CDocTemplate*)m_templateList.GetNext(pos);
  64.         ASSERT(pTemplate->IsKindOf(RUNTIME_CLASS(CDocTemplate)));
  65.  
  66.         CDocTemplate::Confidence match;
  67.         ASSERT(pOpenDocument == NULL);
  68.         match = pTemplate->MatchDocType(szPath, pOpenDocument);
  69.         if (match > bestMatch)
  70.         {
  71.             bestMatch = match;
  72.             pBestTemplate = pTemplate;
  73.         }
  74.         if (match == CDocTemplate::yesAlreadyOpen)
  75.             break;      // stop here
  76.     }
  77.  
  78.     if (pOpenDocument != NULL)
  79.     {
  80.         POSITION pos = pOpenDocument->GetFirstViewPosition();
  81.         if (pos != NULL)
  82.         {
  83.             CView* pView = pOpenDocument->GetNextView(pos); // get first one
  84.             ASSERT_VALID(pView);
  85.             CFrameWnd* pFrame = pView->GetParentFrame();
  86.             if (pFrame != NULL)
  87.                 pFrame->ActivateFrame();
  88.             else
  89.                 TRACE0("Error: Can not find a frame for document to activate");
  90.             CFrameWnd* pAppFrame;
  91.             if (pFrame != (pAppFrame = (CFrameWnd*)AfxGetApp()->m_pMainWnd))
  92.             {
  93.                 ASSERT(pAppFrame->IsKindOf(RUNTIME_CLASS(CFrameWnd)));
  94.                 pAppFrame->ActivateFrame();
  95.             }
  96.         }
  97.         else
  98.         {
  99.             TRACE0("Error: Can not find a view for document to activate");
  100.         }
  101.         return pOpenDocument;
  102.             // file already open (even if we can't activate it)
  103.     }
  104.  
  105.     if (pBestTemplate == NULL)
  106.     {
  107.         TRACE0("Error: can't open document\n");
  108.         return FALSE;
  109.     }
  110.  
  111.     return pBestTemplate->OpenDocumentFile(szPath);
  112. }
  113.  
  114. int CWinApp::GetOpenDocumentCount()
  115. {
  116.     int nOpen = 0;
  117.     POSITION pos = m_templateList.GetHeadPosition();
  118.     while (pos)
  119.     {
  120.         CDocTemplate* pTemplate = (CDocTemplate*)m_templateList.GetNext(pos);
  121.         POSITION pos2 = pTemplate->GetFirstDocPosition();
  122.         while (pos2)
  123.         {
  124.             if (pTemplate->GetNextDoc(pos2) != NULL)
  125.                 nOpen++;
  126.         }
  127.     }
  128.     return nOpen;
  129. }
  130.  
  131. /////////////////////////////////////////////////////////////////////////////
  132. // DDE and ShellExecute support
  133.  
  134. // Registration strings (not localized)
  135. static char BASED_CODE szSystemTopic[] = "system";
  136. static char BASED_CODE szShellOpenFmt[] = "%s\\shell\\open\\%s";
  137. static char BASED_CODE szDDEExec[] = "ddeexec";
  138. static char BASED_CODE szCommand[] = "command";
  139. static char BASED_CODE szStdOpen[] = "[open(\"%1\")]";
  140. static char BASED_CODE szStdArg[] = " -e";
  141.  
  142. #ifdef AFX_INIT_SEG
  143. #pragma code_seg(AFX_INIT_SEG)
  144. #endif
  145.  
  146. void CWinApp::EnableShellOpen()
  147. {
  148.     ASSERT(m_atomApp == NULL && m_atomSystemTopic == NULL); // do once
  149.  
  150.     m_atomApp = ::GlobalAddAtom(m_pszExeName);
  151.     m_atomSystemTopic = ::GlobalAddAtom(szSystemTopic);
  152. }
  153.  
  154.  
  155. static BOOL NEAR PASCAL SetRegKey(LPCSTR lpszKey, LPCSTR lpszValue)
  156. {
  157.     if (::RegSetValue(HKEY_CLASSES_ROOT, lpszKey, REG_SZ,
  158.           lpszValue, lstrlen(lpszValue)) != ERROR_SUCCESS)
  159.     {
  160.         TRACE1("Warning: registration database update failed for key '%Fs'\n",
  161.             lpszKey);
  162.         return FALSE;
  163.     }
  164.     return TRUE;
  165. }
  166.  
  167. void CWinApp::RegisterShellFileTypes()
  168. {
  169.     ASSERT(!m_templateList.IsEmpty());  // must have some doc templates
  170.  
  171.     char szPathName[_MAX_PATH+10];
  172.     ::GetModuleFileName(AfxGetInstanceHandle(), szPathName, _MAX_PATH);
  173.     lstrcat(szPathName, szStdArg);      // "pathname -e"
  174.  
  175.     CString strFilterExt, strFileTypeId, strFileTypeName;
  176.     POSITION pos = m_templateList.GetHeadPosition();
  177.     while (pos)
  178.     {
  179.         CDocTemplate* pTemplate = (CDocTemplate*)m_templateList.GetNext(pos);
  180.         if (pTemplate->GetDocString(strFileTypeId,
  181.            CDocTemplate::regFileTypeId) && !strFileTypeId.IsEmpty())
  182.         {
  183.             // enough info to register it
  184.             if (!pTemplate->GetDocString(strFileTypeName,
  185.                CDocTemplate::regFileTypeName))
  186.                 strFileTypeName = strFileTypeId;    // use id name
  187.  
  188.             ASSERT(strFileTypeId.Find(' ') == -1);  // no spaces allowed
  189.  
  190.             // first register the type ID with our server
  191.             if (!SetRegKey(strFileTypeId, strFileTypeName))
  192.                 continue;       // just skip it
  193.  
  194.             char szBuff[_MAX_PATH*2];   // big buffer
  195.             wsprintf(szBuff, szShellOpenFmt, (LPCSTR)strFileTypeId,
  196.                 (LPCSTR)szDDEExec);
  197.             if (!SetRegKey(szBuff, szStdOpen))
  198.                 continue;       // just skip it
  199.             wsprintf(szBuff, szShellOpenFmt, (LPCSTR)strFileTypeId,
  200.                 (LPCSTR)szCommand);
  201.             if (!SetRegKey(szBuff, szPathName))
  202.                 continue;       // just skip it
  203.  
  204.             pTemplate->GetDocString(strFilterExt, CDocTemplate::filterExt);
  205.             if (!strFilterExt.IsEmpty())
  206.             {
  207.                 ASSERT(strFilterExt[0] == '.');
  208.                 LONG lSize = sizeof(szBuff);
  209.  
  210.                 if (::RegQueryValue(HKEY_CLASSES_ROOT, strFilterExt, szBuff,
  211.                     &lSize) != ERROR_SUCCESS || szBuff[0] == '\0')
  212.                 {
  213.                     // no association for that suffix
  214.                     (void)SetRegKey(strFilterExt, strFileTypeId);
  215.                 }
  216.             }
  217.         }
  218.     }
  219. }
  220.  
  221. #ifdef AFX_CORE3_SEG
  222. #pragma code_seg(AFX_CORE3_SEG)
  223. #endif
  224.  
  225. BOOL CWinApp::OnDDECommand(char* pszCommand)
  226. {
  227.     // open format is "[open("%s")]" - no whitespace allowed, one per line
  228.     static char BASED_CODE szOpenStart[] = "[open(\"";  // 7 characters
  229.     if (_fstrncmp(pszCommand, szOpenStart, 7) != 0)
  230.         return FALSE;       // not the Open command
  231.  
  232.     pszCommand += 7;
  233.     LPSTR lpszEnd = _AfxStrChr(pszCommand, '"');
  234.     if (lpszEnd == NULL)
  235.         return FALSE;       // illegally terminated
  236.  
  237.     // trim the string, and open the file
  238.     *lpszEnd = '\0';
  239.     OpenDocumentFile(pszCommand);
  240.     return TRUE;
  241. }
  242.  
  243. /////////////////////////////////////////////////////////////////////////////
  244. // Doc template support
  245.  
  246. void CWinApp::AddDocTemplate(CDocTemplate* pTemplate)
  247. {
  248.     ASSERT_VALID(pTemplate);
  249.     ASSERT(m_templateList.Find(pTemplate, NULL) == NULL);// must not be in list
  250.     m_templateList.AddTail(pTemplate);
  251. }
  252.  
  253. /////////////////////////////////////////////////////////////////////////////
  254. // Standard command helpers
  255.  
  256. BOOL CWinApp::SaveAllModified()
  257. {
  258.     POSITION pos = m_templateList.GetHeadPosition();
  259.     while (pos)
  260.     {
  261.         CDocTemplate* pTemplate = (CDocTemplate*)m_templateList.GetNext(pos);
  262.         ASSERT(pTemplate->IsKindOf(RUNTIME_CLASS(CDocTemplate)));
  263.         if (!pTemplate->SaveAllModified())
  264.             return FALSE;
  265.     }
  266.     return TRUE;
  267. }
  268.  
  269. void CWinApp::DoWaitCursor(int nCode)
  270. {
  271.     // 0 => restore, 1=> begin, -1=> end
  272.     ASSERT(nCode == 0 || nCode == 1 || nCode == -1);
  273.     ASSERT(afxData.hcurWait != NULL);
  274.     m_nWaitCursorCount += nCode;
  275.  
  276.     if (m_nWaitCursorCount > 0)
  277.     {
  278.         HCURSOR hcurPrev;
  279.         hcurPrev = ::SetCursor(afxData.hcurWait);
  280.         if (hcurPrev != NULL && hcurPrev != afxData.hcurWait)
  281.             m_hcurWaitCursorRestore = hcurPrev;
  282.     }
  283.     else
  284.     {
  285.         // turn everything off
  286.         m_nWaitCursorCount = 0;     // prevent underflow
  287.         ::SetCursor(m_hcurWaitCursorRestore);
  288.     }
  289. }
  290.  
  291. // get parent window for modal dialogs and message boxes.
  292. HWND PASCAL _AfxGetSafeOwner(CWnd* pParent)
  293. {
  294.     if (pParent != NULL)
  295.     {
  296.         ASSERT_VALID(pParent);
  297.         return pParent->m_hWnd;
  298.     }
  299.     HWND hWnd = AfxGetApp()->m_pMainWnd->GetSafeHwnd();
  300.     if (hWnd != NULL)
  301.     {
  302.         HWND hWndParent;
  303.         while ((hWndParent = ::GetParent(hWnd)) != NULL)
  304.             hWnd = hWndParent;
  305.         hWnd = ::GetLastActivePopup(hWnd);
  306.     }
  307.     return hWnd;
  308. }
  309.  
  310. int CWinApp::DoMessageBox(LPCSTR lpszPrompt, UINT nType, UINT nIDPrompt)
  311. {
  312.     HWND hWnd = _AfxGetSafeOwner(NULL);
  313.  
  314.     DWORD dwOldPromptContext = m_dwPromptContext;
  315.     if (nIDPrompt != 0)
  316.         m_dwPromptContext = HID_BASE_PROMPT+nIDPrompt;
  317.  
  318.     if ((nType & MB_ICONMASK) == 0)
  319.     {
  320.         switch (nType & MB_TYPEMASK)
  321.         {
  322.         case MB_OK:
  323.         case MB_OKCANCEL:
  324.             nType |= MB_ICONEXCLAMATION;
  325.             break;
  326.  
  327.         case MB_YESNO:
  328.         case MB_YESNOCANCEL:
  329.             nType |= MB_ICONQUESTION;
  330.             break;
  331.  
  332.         case MB_ABORTRETRYIGNORE:
  333.         case MB_RETRYCANCEL:
  334.             // No default icon for these types, since they are rarely used.
  335.             // The caller should specify the icon.
  336.             break;
  337.         }
  338.     }
  339.  
  340. #ifdef _DEBUG
  341.     if ((nType & MB_ICONMASK) == 0)
  342.         TRACE0("Warning: no icon specified for message box.\n");
  343. #endif
  344.  
  345.     int nRet = ::MessageBox(hWnd, lpszPrompt, m_pszAppName, nType);
  346.     m_dwPromptContext = dwOldPromptContext;
  347.     return nRet;
  348. }
  349.  
  350. int AFXAPI AfxMessageBox(LPCSTR lpszText, UINT nType, UINT nIDHelp)
  351. {
  352.     return AfxGetApp()->DoMessageBox(lpszText, nType, nIDHelp);
  353. }
  354.  
  355. int AFXAPI AfxMessageBox(UINT nIDPrompt, UINT nType, UINT nIDHelp)
  356. {
  357.     CString string;
  358.     if (!string.LoadString(nIDPrompt))
  359.     {
  360.         TRACE1("Error: failed to load message box prompt string 0x%04x\n",
  361.             nIDPrompt);
  362.         ASSERT(FALSE);
  363.     }
  364.     if (nIDHelp == (UINT)-1)
  365.         nIDHelp = nIDPrompt;
  366.     return AfxGetApp()->DoMessageBox(string, nType, nIDHelp);
  367. }
  368.  
  369. int CWnd::MessageBox(LPCSTR lpszText, LPCSTR lpszCaption /* = NULL */,
  370.     UINT nType /* = MB_OK */)
  371. {
  372.     if (lpszCaption == NULL)
  373.         lpszCaption = AfxGetAppName();
  374.     return ::MessageBox(GetSafeHwnd(), lpszText, lpszCaption, nType);
  375. }
  376.  
  377. /////////////////////////////////////////////////////////////////////////////
  378. // MRU file list default implementation
  379.  
  380. BOOL CWinApp::OnOpenRecentFile(UINT nID)
  381. {
  382.     ASSERT_VALID(this);
  383.  
  384.     ASSERT(nID >= ID_FILE_MRU_FILE1);
  385.     ASSERT(nID < ID_FILE_MRU_FILE1 + _AFX_MRU_COUNT);
  386.     ASSERT(m_strRecentFiles[nID - ID_FILE_MRU_FILE1].GetLength() != 0);
  387.  
  388.     TRACE2("MRU: open file (%d) %s\n", (nID - ID_FILE_MRU_FILE1) + 1, 
  389.             (const char*)m_strRecentFiles[nID - ID_FILE_MRU_FILE1]);
  390.  
  391.     OpenDocumentFile(m_strRecentFiles[nID - ID_FILE_MRU_FILE1]);
  392.     return TRUE;
  393. }
  394.  
  395. void CWinApp::AddToRecentFileList(const char* pszPathName)
  396.     // pszPathName must be a full path in upper-case ANSI character set
  397. {
  398.     ASSERT_VALID(this);
  399.     ASSERT(pszPathName != NULL);
  400.     ASSERT(AfxIsValidString(pszPathName));
  401.  
  402.     // update the MRU list
  403.     int iMRU;
  404.     int iMRULast;
  405.  
  406.     // if an existing MRU string matches file name
  407.     for (iMRU = 0; iMRU < _AFX_MRU_COUNT - 1; iMRU++)
  408.     {
  409.         if (m_strRecentFiles[iMRU] == pszPathName)
  410.             break;      // iMRU will point to matching entry
  411.     }
  412.  
  413.     // move MRU strings after this one down
  414.     for (iMRULast = iMRU; iMRULast > 0; iMRULast--)
  415.     {
  416.         ASSERT(iMRULast > 0);
  417.         ASSERT(iMRULast < _AFX_MRU_COUNT);
  418.  
  419.         m_strRecentFiles[iMRULast] = m_strRecentFiles[iMRULast - 1];
  420.     }
  421.  
  422.     // add our file name to the top
  423.     m_strRecentFiles[0] = pszPathName;
  424. }
  425.  
  426. void CWinApp::OnUpdateRecentFileMenu(CCmdUI* pCmdUI)
  427. {
  428.     ASSERT_VALID(this);
  429.     ASSERT(pCmdUI->m_pMenu != NULL);
  430.  
  431.     if (m_strRecentFiles[0].IsEmpty())
  432.     {
  433.         // no MRU files
  434.         pCmdUI->Enable(FALSE);
  435.         return;
  436.     }
  437.  
  438.     // when we get the update for the first entry, refill the list
  439.     ASSERT(pCmdUI->m_nID == ID_FILE_MRU_FILE1);
  440.  
  441.     for (int iMRU = 0; iMRU < _AFX_MRU_COUNT; iMRU++)
  442.         pCmdUI->m_pMenu->DeleteMenu(pCmdUI->m_nID + iMRU, MF_BYCOMMAND);
  443.  
  444.     char szCurDir[_MAX_PATH];
  445.     _AfxFullPath(szCurDir, "A");
  446.     int nCurDir = strlen(szCurDir) - 1;     // skip "A"
  447.  
  448.     for (iMRU = 0; iMRU < _AFX_MRU_COUNT; iMRU++)
  449.     {
  450.         char szBuff[_MAX_PATH];
  451.         char* pch;
  452.  
  453.         if (m_strRecentFiles[iMRU].IsEmpty())
  454.             break;
  455.  
  456.         pch = szBuff;
  457.         *pch++ = '&';
  458.         *pch++ = (char)('1' + iMRU);
  459.         *pch++ = ' ';
  460.         lstrcpy(pch, m_strRecentFiles[iMRU]);
  461.         if (_fmemcmp(szCurDir, m_strRecentFiles[iMRU], nCurDir) == 0)
  462.             lstrcpy(pch, pch + nCurDir);
  463.  
  464.         pCmdUI->m_pMenu->InsertMenu(pCmdUI->m_nIndex++, 
  465.             MF_STRING | MF_BYPOSITION, pCmdUI->m_nID++, szBuff);
  466.     }
  467.     // update end menu count
  468.     pCmdUI->m_nIndex--; // point to last menu added
  469.     pCmdUI->m_nIndexMax = pCmdUI->m_pMenu->GetMenuItemCount();
  470.  
  471.     pCmdUI->m_bEnableChanged = TRUE;    // all the added items are enabled
  472. }
  473.  
  474. #ifdef AFX_INIT_SEG
  475. #pragma code_seg(AFX_INIT_SEG)
  476. #endif
  477.  
  478. // INI strings are not localized
  479. static char BASED_CODE szFileSection[] = "Recent File List";
  480. static char BASED_CODE szFileEntry[] = "File%d";
  481. static char BASED_CODE szPreviewSection[] = "Settings";
  482. static char BASED_CODE szPreviewEntry[] = "PreviewPages";
  483.  
  484. void CWinApp::SaveStdProfileSettings()
  485. {
  486.     ASSERT_VALID(this);
  487.  
  488.     for (int iMRU = 0; iMRU < _AFX_MRU_COUNT; iMRU++)
  489.     {
  490.         if (m_strRecentFiles[iMRU].IsEmpty())
  491.             break;  // all done
  492.  
  493.         char szEntry[16];
  494.         wsprintf(szEntry, szFileEntry, iMRU + 1);
  495.         WriteProfileString(szFileSection, szEntry, m_strRecentFiles[iMRU]);
  496.     }
  497.  
  498.     if (m_nNumPreviewPages != 0)
  499.         WriteProfileInt(szPreviewSection, szPreviewEntry, m_nNumPreviewPages);
  500. }
  501.  
  502. #ifdef AFX_CORE3_SEG
  503. #pragma code_seg(AFX_CORE3_SEG)
  504. #endif
  505.  
  506. void CWinApp::LoadStdProfileSettings()
  507. {
  508.     ASSERT_VALID(this);
  509.  
  510.     for (int iMRU = 0; iMRU < _AFX_MRU_COUNT; iMRU++)
  511.     {
  512.         char szEntry[16];
  513.         wsprintf(szEntry, szFileEntry, iMRU + 1);
  514.         m_strRecentFiles[iMRU] = GetProfileString(szFileSection, szEntry);
  515.     }
  516.     m_nNumPreviewPages = GetProfileInt(szPreviewSection, szPreviewEntry, 0);
  517.         // 0 by default means not set
  518. }
  519.  
  520. // Profile API helpers
  521. UINT CWinApp::GetProfileInt(LPCSTR lpszSection, LPCSTR lpszEntry, int nDefault)
  522. {
  523.     ASSERT(lpszSection != NULL);
  524.     ASSERT(lpszEntry != NULL);
  525.     ASSERT(m_pszProfileName != NULL);
  526.  
  527.     return ::GetPrivateProfileInt(lpszSection, lpszEntry, nDefault,
  528.         m_pszProfileName);
  529. }
  530.  
  531. BOOL CWinApp::WriteProfileInt(LPCSTR lpszSection, LPCSTR lpszEntry, int nValue)
  532. {
  533.     ASSERT(lpszSection != NULL);
  534.     ASSERT(lpszEntry != NULL);
  535.     ASSERT(m_pszProfileName != NULL);
  536.  
  537.     char szT[16];
  538.     wsprintf(szT, "%d", nValue);
  539.     return WriteProfileString(lpszSection, lpszEntry, szT);
  540. }
  541.  
  542. CString CWinApp::GetProfileString(LPCSTR lpszSection, LPCSTR lpszEntry,
  543.             LPCSTR lpszDefault /*= NULL */)
  544. {
  545.     ASSERT(lpszSection != NULL);
  546.     ASSERT(lpszEntry != NULL);
  547.     ASSERT(m_pszProfileName != NULL);
  548.  
  549.     if (lpszDefault == NULL)
  550.         lpszDefault = "";       // don't pass in NULL
  551.     char szT[_MAX_PATH];
  552.     ::GetPrivateProfileString(lpszSection, lpszEntry, lpszDefault,
  553.         szT, sizeof(szT), m_pszProfileName);
  554.     return szT;
  555. }
  556.  
  557. BOOL CWinApp::WriteProfileString(LPCSTR lpszSection, LPCSTR lpszEntry,
  558.             LPCSTR lpszValue)
  559. {
  560.     ASSERT(lpszSection != NULL);
  561.     ASSERT(lpszEntry != NULL);
  562.     ASSERT(m_pszProfileName != NULL);
  563.  
  564.     return ::WritePrivateProfileString(lpszSection, lpszEntry, lpszValue,
  565.         m_pszProfileName);
  566. }
  567.  
  568. /////////////////////////////////////////////////////////////////////////////
  569.