6 个解决方案
#1
GetProfileInt()只能读Win.ini文件中某个指定段的某个键的值。WriteProfileString()完成相反的功能。
如果你想把信息写入Win.ini中的话,可以用这两个文件,用法很简单的。
如果你想把信息写入Win.ini中的话,可以用这两个文件,用法很简单的。
#2
WriteProfileInt,WriteProfileString用于想注册表或应用程序的。INI文件中写入信息,GeytProfileInt,GetProfileString则用于从注册表或。INT文件中读取信息。GetProfileInt返回相应的第三个参数的入口号。
#3
AfxGetApp()->WriteProfileString("discover", "IP", str);
AfxGetApp()->GetProfileString("discover", "IP");
试一下就知道,生成一个youproject.ini文件在系统winnt目录下
AfxGetApp()->GetProfileString("discover", "IP");
试一下就知道,生成一个youproject.ini文件在系统winnt目录下
#4
我这有个事例。
响应WM_CLSOE
WINDOWPLACEMENT WndStatus;
WndStatus.length = sizeof(WINDOWNPLACEMENT);
GetWindowPlacement(&WndStatus);
AfxGetApp()->WriteProfileInt("WNDSTATUS","FLAG",WndStatus.flags);
AfxGetApp()->WriteProfileInt("WNDSTATUS","SHOWCMD",WndStatus.showCmd);
AfxGetApp()->WriteProfileInt("WNDSTATUS","LEFT",WndStatus.rcNormalPosition.left);
AfxGetApp()->WriteProfileInt("WNDSTATUS","RIGHT",WndStatus.rcNormalPosition.right);
AfxGetApp()->WriteProfileInt("WNDSTATUS","TOP",WndStatus.rcNormalPosition.top);
AfxGetApp()->WriteProfileInt("WNDSTATUS","BOTTOM",WndStatus.rcNormalPosition.bottom);
SaveBarState(AfxGetApp()->m_pszProfileName);
CFrameWnd::OnClose();
响应WM_CLSOE
WINDOWPLACEMENT WndStatus;
WndStatus.length = sizeof(WINDOWNPLACEMENT);
GetWindowPlacement(&WndStatus);
AfxGetApp()->WriteProfileInt("WNDSTATUS","FLAG",WndStatus.flags);
AfxGetApp()->WriteProfileInt("WNDSTATUS","SHOWCMD",WndStatus.showCmd);
AfxGetApp()->WriteProfileInt("WNDSTATUS","LEFT",WndStatus.rcNormalPosition.left);
AfxGetApp()->WriteProfileInt("WNDSTATUS","RIGHT",WndStatus.rcNormalPosition.right);
AfxGetApp()->WriteProfileInt("WNDSTATUS","TOP",WndStatus.rcNormalPosition.top);
AfxGetApp()->WriteProfileInt("WNDSTATUS","BOTTOM",WndStatus.rcNormalPosition.bottom);
SaveBarState(AfxGetApp()->m_pszProfileName);
CFrameWnd::OnClose();
#5
在程序重启时,读取注册表信息,并重新设置窗口信息。
添加bool m_bFirst;
响应CMainFrame的ActivateFrame消息处理函数
void CMainFrame::ActiveFrame(int nCmdShow)
{
if(m_bFirst)//用来表示是否初次激活窗口
{
m_bFirst = FALSE;
WINDOWPLACEMENT WndStatus;
CRect rect;
rect.left =AfxGetApp()->GetProfileInt("WNDSTATUS","LEFT",100);
rect.top=AfxGetApp()->GetProfileInt("WNDSTATUS","TOP",100);
rect.right =AfxGetApp()->GetProfileInt("WNDSTATUS","RIGHT",500);
rect.bottom =AfxGetApp()->GetProfileInt("WNDSTATUS","BOTTOM",400);
WndStatus.rcNormalPosition = rect;
WndStatus.flags= AfxGetApp()->GetProfileInt("WNDSTATUS","FLAG",0);
nCmdShow = AfxGetApp()->GetProfileInt("WNDSTATUS","SHOWCMD",SW_SHOW);
WndStatus.showCmd = nCmdShow;
WndStatus.ptMinPosition = CPoint(0,0);
WndStatus.ptMaxPosition = CPoint(-GetSystemMetrics(SM_CXBORDER),GetSysTemMetrics(SM_CYBORDER));
LoadBarState(AfxGetApp()->m_pszProfileName);
SetWindowPlacement(&WndStatus);
}
CFrameWnd::ActivateFrame(nCmdShow);
}
添加bool m_bFirst;
响应CMainFrame的ActivateFrame消息处理函数
void CMainFrame::ActiveFrame(int nCmdShow)
{
if(m_bFirst)//用来表示是否初次激活窗口
{
m_bFirst = FALSE;
WINDOWPLACEMENT WndStatus;
CRect rect;
rect.left =AfxGetApp()->GetProfileInt("WNDSTATUS","LEFT",100);
rect.top=AfxGetApp()->GetProfileInt("WNDSTATUS","TOP",100);
rect.right =AfxGetApp()->GetProfileInt("WNDSTATUS","RIGHT",500);
rect.bottom =AfxGetApp()->GetProfileInt("WNDSTATUS","BOTTOM",400);
WndStatus.rcNormalPosition = rect;
WndStatus.flags= AfxGetApp()->GetProfileInt("WNDSTATUS","FLAG",0);
nCmdShow = AfxGetApp()->GetProfileInt("WNDSTATUS","SHOWCMD",SW_SHOW);
WndStatus.showCmd = nCmdShow;
WndStatus.ptMinPosition = CPoint(0,0);
WndStatus.ptMaxPosition = CPoint(-GetSystemMetrics(SM_CXBORDER),GetSysTemMetrics(SM_CYBORDER));
LoadBarState(AfxGetApp()->m_pszProfileName);
SetWindowPlacement(&WndStatus);
}
CFrameWnd::ActivateFrame(nCmdShow);
}
#6
更正:sizeof(WINDOWPLACEMENT),GetSystemMetrics
#1
GetProfileInt()只能读Win.ini文件中某个指定段的某个键的值。WriteProfileString()完成相反的功能。
如果你想把信息写入Win.ini中的话,可以用这两个文件,用法很简单的。
如果你想把信息写入Win.ini中的话,可以用这两个文件,用法很简单的。
#2
WriteProfileInt,WriteProfileString用于想注册表或应用程序的。INI文件中写入信息,GeytProfileInt,GetProfileString则用于从注册表或。INT文件中读取信息。GetProfileInt返回相应的第三个参数的入口号。
#3
AfxGetApp()->WriteProfileString("discover", "IP", str);
AfxGetApp()->GetProfileString("discover", "IP");
试一下就知道,生成一个youproject.ini文件在系统winnt目录下
AfxGetApp()->GetProfileString("discover", "IP");
试一下就知道,生成一个youproject.ini文件在系统winnt目录下
#4
我这有个事例。
响应WM_CLSOE
WINDOWPLACEMENT WndStatus;
WndStatus.length = sizeof(WINDOWNPLACEMENT);
GetWindowPlacement(&WndStatus);
AfxGetApp()->WriteProfileInt("WNDSTATUS","FLAG",WndStatus.flags);
AfxGetApp()->WriteProfileInt("WNDSTATUS","SHOWCMD",WndStatus.showCmd);
AfxGetApp()->WriteProfileInt("WNDSTATUS","LEFT",WndStatus.rcNormalPosition.left);
AfxGetApp()->WriteProfileInt("WNDSTATUS","RIGHT",WndStatus.rcNormalPosition.right);
AfxGetApp()->WriteProfileInt("WNDSTATUS","TOP",WndStatus.rcNormalPosition.top);
AfxGetApp()->WriteProfileInt("WNDSTATUS","BOTTOM",WndStatus.rcNormalPosition.bottom);
SaveBarState(AfxGetApp()->m_pszProfileName);
CFrameWnd::OnClose();
响应WM_CLSOE
WINDOWPLACEMENT WndStatus;
WndStatus.length = sizeof(WINDOWNPLACEMENT);
GetWindowPlacement(&WndStatus);
AfxGetApp()->WriteProfileInt("WNDSTATUS","FLAG",WndStatus.flags);
AfxGetApp()->WriteProfileInt("WNDSTATUS","SHOWCMD",WndStatus.showCmd);
AfxGetApp()->WriteProfileInt("WNDSTATUS","LEFT",WndStatus.rcNormalPosition.left);
AfxGetApp()->WriteProfileInt("WNDSTATUS","RIGHT",WndStatus.rcNormalPosition.right);
AfxGetApp()->WriteProfileInt("WNDSTATUS","TOP",WndStatus.rcNormalPosition.top);
AfxGetApp()->WriteProfileInt("WNDSTATUS","BOTTOM",WndStatus.rcNormalPosition.bottom);
SaveBarState(AfxGetApp()->m_pszProfileName);
CFrameWnd::OnClose();
#5
在程序重启时,读取注册表信息,并重新设置窗口信息。
添加bool m_bFirst;
响应CMainFrame的ActivateFrame消息处理函数
void CMainFrame::ActiveFrame(int nCmdShow)
{
if(m_bFirst)//用来表示是否初次激活窗口
{
m_bFirst = FALSE;
WINDOWPLACEMENT WndStatus;
CRect rect;
rect.left =AfxGetApp()->GetProfileInt("WNDSTATUS","LEFT",100);
rect.top=AfxGetApp()->GetProfileInt("WNDSTATUS","TOP",100);
rect.right =AfxGetApp()->GetProfileInt("WNDSTATUS","RIGHT",500);
rect.bottom =AfxGetApp()->GetProfileInt("WNDSTATUS","BOTTOM",400);
WndStatus.rcNormalPosition = rect;
WndStatus.flags= AfxGetApp()->GetProfileInt("WNDSTATUS","FLAG",0);
nCmdShow = AfxGetApp()->GetProfileInt("WNDSTATUS","SHOWCMD",SW_SHOW);
WndStatus.showCmd = nCmdShow;
WndStatus.ptMinPosition = CPoint(0,0);
WndStatus.ptMaxPosition = CPoint(-GetSystemMetrics(SM_CXBORDER),GetSysTemMetrics(SM_CYBORDER));
LoadBarState(AfxGetApp()->m_pszProfileName);
SetWindowPlacement(&WndStatus);
}
CFrameWnd::ActivateFrame(nCmdShow);
}
添加bool m_bFirst;
响应CMainFrame的ActivateFrame消息处理函数
void CMainFrame::ActiveFrame(int nCmdShow)
{
if(m_bFirst)//用来表示是否初次激活窗口
{
m_bFirst = FALSE;
WINDOWPLACEMENT WndStatus;
CRect rect;
rect.left =AfxGetApp()->GetProfileInt("WNDSTATUS","LEFT",100);
rect.top=AfxGetApp()->GetProfileInt("WNDSTATUS","TOP",100);
rect.right =AfxGetApp()->GetProfileInt("WNDSTATUS","RIGHT",500);
rect.bottom =AfxGetApp()->GetProfileInt("WNDSTATUS","BOTTOM",400);
WndStatus.rcNormalPosition = rect;
WndStatus.flags= AfxGetApp()->GetProfileInt("WNDSTATUS","FLAG",0);
nCmdShow = AfxGetApp()->GetProfileInt("WNDSTATUS","SHOWCMD",SW_SHOW);
WndStatus.showCmd = nCmdShow;
WndStatus.ptMinPosition = CPoint(0,0);
WndStatus.ptMaxPosition = CPoint(-GetSystemMetrics(SM_CXBORDER),GetSysTemMetrics(SM_CYBORDER));
LoadBarState(AfxGetApp()->m_pszProfileName);
SetWindowPlacement(&WndStatus);
}
CFrameWnd::ActivateFrame(nCmdShow);
}
#6
更正:sizeof(WINDOWPLACEMENT),GetSystemMetrics