mfc中的CWinApp類

m_pszAppName 指定了應用程序的名字  ,先在構造函數中獲取字符串,如果沒有就在字符串表中獲取,
如果沒有根據進程的可執行程序的名字進行復制
在應用程序類的構造函數裏面載入圖標
    m_hIcon = AfxGetApp()->LoadIcon(IDI_ICON1);

調用CWinApp類成員函數的方法主要有兩種,一種是使用全局變量去調用,一種是使用MFC全局函數AfxGetApp()或者theApp的地址

配置文件讀寫在.ini的文件裏面
CString strSection = "My Section";
CString strStringItem = "My String Item";
CString strIntItem = "My Int Item";
CWinApp* pApp = AfxGetApp();
pApp->WriteProfileString(strSection, strStringItem, "test");
CString strValue;
strValue = pApp->GetProfileString(strSection, strStringItem);
ASSERT(strValue == "test");
pApp->WriteProfileInt(strSection, strIntItem, 1234);
int nValue;
nValue = pApp->GetProfileInt(strSection, strIntItem, 0);
ASSERT(nValue == 1234);

通過在初始化函數中使用SetRegister()函數可以把配置寫進註冊表,而不是寫進配置文件ini

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章