2007년 4월 8일 일요일

MFC Using registry key

리지스트리 이용하기
Using registry key

InitInstance()에

    ...
    SetRegistryKey(_T("My App"));
    ...
    
라고 하면

    HKEY_CURRENT_USER\Software\My App\(Project name)
    
아래에 저장된다.


이것은 Demo only로 OnDraw에 이런 짓은 하지 말기를...
AfxGetApp()->WriteProfileXXX()
AfxGetApp()->GetProfileXXX()
함수 참조

void CGdiplusDemoView::OnDraw(CDC* pDC)
{
    Graphics g(pDC->m_hDC);
    CString sTest;

    AfxGetApp()->WriteProfileString(L"Section", L"Entry", L"Value");

    // Create font
    FontFamily fontFamily(L"Arial");
    Font font(&fontFamily, 24, FontStyleBold, UnitPixel);

    // Create brush
    SolidBrush brush(Color(255, 0, 0, 255));

    // Center alignment
    StringFormat stringFormat;
    stringFormat.SetAlignment(StringAlignmentCenter);
    stringFormat.SetLineAlignment(StringAlignmentCenter);

    sTest = AfxGetApp()->GetProfileString(L"Section", L"Entry");
    PointF pointF(100, 100);
    g.DrawString(sTest, sTest.GetLength(), &font, pointF, &stringFormat, &brush);
}


댓글 없음: