Udostępnij za pośrednictwem


CWinApp::m_pszAppName

Określa nazwę aplikacji.

LPCTSTR m_pszAppName;

Uwagi

Nazwa aplikacji może pochodzić z parametr przekazany do CWinApp Konstruktor, lub, jeżeli nie określono ciąg zasobów z Identyfikatorem AFX_IDS_APP_TITLE.Jeśli nazwa aplikacji nie znajduje się w zasobie, pochodzi z tego programu.Nazwa pliku EXE.

Zwrócone przez funkcję globalnego AfxGetAppName.m_pszAppNamepubliczne zmiennej typu jest const char *.

[!UWAGA]

Jeśli przypisania wartości do m_pszAppName, musi być dynamicznie przydzielane na stercie.CWinApp Wywołania destruktora wolnego() za pomocą tego wskaźnika.Wiele chcesz użyć _tcsdup() run-time library funkcji alokacji.Również zwolnić pamięć, skojarzone z bieżącego wskaźnika przed przypisaniem nowej wartości.Na przykład:

//First free the string allocated by MFC at CWinApp startup.
//The string is allocated before InitInstance is called.
free((void*)m_pszAppName);
//Change the name of the application file.
//The CWinApp destructor will free the memory.
m_pszAppName = _tcsdup(_T("c:\\somedir\\myapp.exe"));

Przykład

CWnd* pWnd = AfxGetMainWnd();
// Set pWnd to some CWnd object whose window has already
// been created.

// The following call to CWnd::MessageBox uses the application
// title as the message box caption.
pWnd->MessageBox(_T("Some message"), AfxGetApp()->m_pszAppName);

// A more direct way to get the application title is to 
// call AfxGetAppName:
pWnd->MessageBox(_T("Some message"), AfxGetAppName());

// An easier way to display a message box using the application
// title as the message box caption is to call AfxMessageBox:
AfxMessageBox(_T("Some message"));

Wymagania

Nagłówek: afxwin.h

Zobacz też

Informacje

Klasa CWinApp

Wykres hierarchii