Beispiel #1
0
BOOL CIniFile::GetStruct(const wchar_t *const pwchSection,
	const wchar_t *const pwchKeyWord,
	void *const pvStruct,
	const UINT unStructSize)
{
	assert(NULL != pwchSection);
	assert(NULL != pwchKeyWord);
	assert(NULL != pvStruct);
	assert(unStructSize > 0);

	return GetPrivateProfileStructW(pwchSection, pwchKeyWord, pvStruct, unStructSize, m_wchPath);
}
Beispiel #2
0
BOOL ATEIniFile::ReadKey(const ATEStr& szSection, const ATEStr& szKey, INIKey& key)
{
    if(szSection.IsEmpty()) { return FALSE; }
    if(szKey.IsEmpty()) { return FALSE; }

    switch(key.type)
    {
    case KEY_DWORD:
    {
        INT32 nRet = GetPrivateProfileIntW(szSection.GetHead(),
                                           szKey.GetHead(),
                                           INIKey::INVALID_DWORD,
                                           m_szFilePath.GetHead());
        if (INIKey::INVALID_DWORD == nRet) { return FALSE; }
        key.val.dwVal = nRet;
        return TRUE;
    }
        break;
    case KEY_STRING:
    {
        //function have bugs for only one entry.
        GetPrivateProfileStringW(szSection.GetHead(),
                                 szKey.GetHead(),
                                 NULL,
                                 key.val.szVal,
                                 INIKey::MAX_KEY_SIZE,
                                 m_szFilePath.GetHead());

        if (0 == key.val.szVal[0]) { return FALSE; }
        return TRUE;
    }
        break;
    case KEY_STRUCT:
    {
        BOOL bRet = GetPrivateProfileStructW(szSection.GetHead(),
                                             szKey.GetHead(),
                                             &(key.val.binVal[0]),
                                             INIKey::MAX_KEY_SIZE,
                                             m_szFilePath.GetHead());
        if (!bRet) { return FALSE; }
        return TRUE;
    }
        break;
    default:
        return FALSE;
        break;
    }

    return FALSE;
}