Пример #1
0
bool COneCleanSetting::Load()
{
    bool retval = false;
    TiXmlDocument xmlDoc;
    const TiXmlElement *pXmlSetting = NULL;
    const TiXmlElement *pXmlStrings = NULL;
    const TiXmlElement *pXmlIntegers = NULL;
    const TiXmlElement *pXmlChild = NULL;
    KFilePath settingPath = KFilePath::GetFilePath(_Module.m_hInst);

    settingPath.RemoveFileSpec();
    settingPath.Append(L"cfg\\onekeyclean.xml");
    if (!xmlDoc.LoadFile(UnicodeToAnsi(settingPath.value()).c_str(), TIXML_ENCODING_UTF8))
        goto clean0;

    pXmlSetting = xmlDoc.FirstChildElement("setting");
    if (!pXmlSetting)
        goto clean0;

    pXmlStrings = pXmlSetting->FirstChildElement("strings");
    if (pXmlStrings)
    {
        pXmlChild = pXmlStrings->FirstChildElement("entry");
        while (pXmlChild)
        {
            std::string strName, strValue;

            strName = pXmlChild->Attribute("name");
            strValue = pXmlChild->Attribute("value");
            if (strcmp(strName.c_str(), "default_entrys") != 0)
            {
                m_vStringStore[strName] = Utf8ToUnicode(strValue);
            }

            pXmlChild = pXmlChild->NextSiblingElement("entry");
        }
    }

    pXmlIntegers = pXmlSetting->FirstChildElement("integers");
    if (pXmlIntegers)
    {
        pXmlChild = pXmlIntegers->FirstChildElement("entry");
        while (pXmlChild)
        {
            std::string strName;
            int nValue;

            strName = pXmlChild->Attribute("name");
            pXmlChild->QueryIntAttribute("value", &nValue);
            m_vIntegerStore[strName] = nValue;

            pXmlChild = pXmlChild->NextSiblingElement("entry");
        }
    }

    retval = true;

clean0:
    return retval;
}
Пример #2
0
BOOL KscToolVector::LoadTool(int nIndex, const std::wstring& strDll)
{
	BOOL retval = FALSE;
	KFilePath appPath = KFilePath::GetFilePath(NULL);
	KFilePath dllPath;
	HMODULE hDll = NULL;
	ShowDlg_t ShowDlg = NULL;

	appPath.RemoveFileSpec();

	dllPath = appPath;
	dllPath.Append(strDll);
	hDll = ::LoadLibraryW(dllPath);
	if (!hDll)
		goto clean0;

	ShowDlg = (ShowDlg_t)::GetProcAddress(hDll, "ShowDlg");
	if (!ShowDlg)
		goto clean0;

	m_hTools[nIndex].hDll = hDll;
	m_hTools[nIndex].pShowDlg = ShowDlg;
	m_hTools[nIndex].hWnd = NULL;

	retval = TRUE;

clean0:
	return retval;
}
Пример #3
0
bool KAppRes::PrepareRes()
{
    bool retval = false;
    KFilePath pathRes = KFilePath::GetFilePath(g_hInstance);
    HRSRC hResInfo = NULL;
    HGLOBAL hResDat = NULL;
    PVOID pResBuffer = NULL;
    DWORD dwResBuffer;
    wchar_t szTempPath[MAX_PATH] = { 0 };
    wchar_t szTempFilePath[MAX_PATH] = { 0 };
    //BOOL fRetCode;
    //DWORD dwWritten;

    pathRes.RemoveExtension();
    pathRes.AddExtension(L"kui");

    if (GetFileAttributesW(pathRes) != INVALID_FILE_ATTRIBUTES)
    {
        m_strResPackPath = pathRes.value();
    }
    else
    {
        hResInfo = FindResourceW(_ModulePtr->GetResourceInstance(), L"kuires.dat", L"SKIN");
        if (!hResInfo)
            goto clean0;
        
        hResDat = LoadResource(_ModulePtr->GetResourceInstance(), hResInfo);
        if (!hResDat)
            goto clean0;

        pResBuffer = LockResource(hResDat);
        if (!pResBuffer)
            goto clean0;

        dwResBuffer = SizeofResource(_ModulePtr->GetResourceInstance(), hResInfo);
		m_memZipRes.SetData(pResBuffer, dwResBuffer);

       /* GetTempPathW(MAX_PATH, szTempPath);
        GetTempFileNameW(szTempPath, L"kui", 0, szTempFilePath);
        m_hTempRes = CreateFileW(szTempFilePath, GENERIC_ALL, FILE_SHARE_READ, NULL, 
            CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, NULL);
        if (INVALID_HANDLE_VALUE == m_hTempRes)
            goto clean0;

        fRetCode = WriteFile(m_hTempRes, pResBuffer, dwResBuffer, &dwWritten, NULL);
        if (!fRetCode)
            goto clean0;

        fRetCode = FlushFileBuffers(m_hTempRes);

        m_strResPackPath = szTempFilePath;*/
    }
    
    retval = true;

clean0:
    return retval;
}
Пример #4
0
bool COneCleanSetting::Save()
{
    bool retval = false;
    TiXmlDocument xmlDoc;
    TiXmlDeclaration *pXmlDecl = new TiXmlDeclaration("1.0", "utf-8", "yes");
    TiXmlElement *pXmlSetting = new TiXmlElement("setting");
    TiXmlElement *pXmlStrings = new TiXmlElement("strings");
    TiXmlElement *pXmlIntegers = new TiXmlElement("integers");
    TiXmlElement *pXmlChild = NULL;
    StringStore::const_iterator i;
    IntegerStore::const_iterator j;
    KFilePath savePath = KFilePath::GetFilePath(_Module.m_hInst);

    savePath.RemoveFileSpec();
    savePath.Append(L"cfg\\onekeyclean.xml");
    xmlDoc.LinkEndChild(pXmlDecl);

    for (i = m_vStringStore.begin(); i != m_vStringStore.end(); ++i)
    {
        std::string strName;
        std::wstring strValue;

        strName = i->first;
        strValue = i->second;

        pXmlChild = new TiXmlElement("entry");
        if (!pXmlChild)
            goto clean0;
        if (strcmp(strName.c_str(), "default_entrys") == 0)
            continue;
        pXmlChild->SetAttribute("name", strName.c_str());
        pXmlChild->SetAttribute("value", UnicodeToUtf8(strValue).c_str());
        pXmlStrings->LinkEndChild(pXmlChild);
    }
    pXmlSetting->LinkEndChild(pXmlStrings);

    for (j = m_vIntegerStore.begin(); j != m_vIntegerStore.end(); ++j)
    {
        std::string strName;
        int nValue;

        strName = j->first;
        nValue = j->second;

        pXmlChild = new TiXmlElement("entry");
        if (!pXmlChild)
            goto clean0;

        pXmlChild->SetAttribute("name", strName.c_str());
        pXmlChild->SetAttribute("value", nValue);
        pXmlIntegers->LinkEndChild(pXmlChild);
    }
    pXmlSetting->LinkEndChild(pXmlIntegers);

    xmlDoc.LinkEndChild(pXmlSetting);

    retval = xmlDoc.SaveFile(UnicodeToAnsi(savePath.value()).c_str());

clean0:
    return retval;
}