뀨읭
접속 : 5024   Lv. 59

Category

Profile

Counter

  • 오늘 : 107 명
  • 전체 : 2042152 명
  • Mypi Ver. 0.3.1 β
[MFC] ini 파일 불러오기 (0) 2023/09/16 AM 10:33
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
void CK2Dlg::LoadTestStandard()
{
    const unsigned int testStandardSize = sizeof(TEST::STANDARD) / sizeof(float);
 
    for (unsigned int fileIndex = 0; fileIndex < TEST::testCaseCnt; fileIndex++)
    {
        float tempTestStandard[testStandardSize] = { 0, };        // 데이터저장용 임시구조체
        unsigned int memPos = 0;                                // 쓰기 메모리 위치 변경 변수
 
        for (unsigned int sectionIndex = 0; sectionIndex < TEST::sectionCnt; sectionIndex++)
        {
            for (unsigned int keyIndex = 0; ; keyIndex++)
            {
                if((keyIndex == 0&& (keyIndex == TEST::testItemCnt[sectionIndex]))    // 비어있는 메시지인 경우
                { 
                    memPos++;                                                            // 쓰기 메모리 위치만 변경하고
                    break;                                                                // 다음으로 메시지로 이동
                }
 
                if (keyIndex < TEST::testItemCnt[sectionIndex])
                {
                    char buff[100= { 0, };    // ini 파일에서 읽은 값 저장 변수
 
                    CString strSection = TEST::iniSection[sectionIndex];        // 섹션
                    CString strKey = TEST::iniKey[sectionIndex][keyIndex];        // 키
                    CString strFilename = TEST::fileName[fileIndex];            // 파일명
 
                    GetPrivateProfileStringA(strSection, strKey, "0", buff, sizeof(buff), strFilename);        // ini 파일에서 값 읽기
 
                    float fData = 0;            // 실수값 저장용
                    fData = _ttof(buff);        // 문자열을 실수값으로 변환
 
                    memcpy(&tempTestStandard[0+ memPos, &fData, sizeof(float));                // 임시구조체에 데이터 저장
                    memPos++;                                                                    // 쓰기 메모리 위치 변경
                }
                else
                {
                    break;
                }
            }
        }
        memcpy(&m_testStandard[fileIndex], &tempTestStandard[0], sizeof(TEST::STANDARD));        // 기준값 구조체로 임시 구조체의 값을 복사
    }
    printf("기준값 ini 불러오기 완료\n");
}
cs

신고

 
X