int Profile_GetBoolean(const char *Section, const char *Key, int DefValue) { char buff[64]; int len = Profile_GetString(Section, Key, "", buff, sizearray(buff)); int ret = 0; // printf("int %s \n",buff); if (len == 0) { return DefValue; } if((buff[0] == 'y') || (buff[0] == 'Y') || (buff[0] == '1') || (buff[0] == 't') || (buff[0] == 'T')) { ret = 1 ; } else if((buff[0] == 'n') || (buff[0] == 'N') || (buff[0] == '0') || (buff[0] == 'f') || (buff[0] == 'F')) { ret = 0 ; } else { ret = DefValue ; } return ret; }
/** Profile_GetInteger() * \param Section the name of the section to search for * \param Key the name of the entry to find the value of * \param DefValue the default value in the event of a failed read * * \return the value located at Key */ long Profile_GetInteger(const char *Section, const char *Key, long DefValue) { char buff[64]; int len = Profile_GetString(Section, Key, "", buff, sizearray(buff)); // printf("int %s \n",buff); if (len == 0) return DefValue; if (buff[0] == '0' && String_ToUpperCase(buff[1]) == 'X') return String_AParseHexU32(buff); else return _tcstol(buff,NULL,10); }
void STEPluginLoad(HWND hWnd) { STEP_hWnd = hWnd; CSuperTagEditorApp *pApp = (CSuperTagEditorApp *)AfxGetApp(); CString strINI; { wchar_t* szName = pApp->MakeFileName(L"ini"); wchar_t drive[_MAX_DRIVE]; wchar_t dir[_MAX_DIR]; wchar_t buff[_MAX_PATH] = {'\0'}; _tsplitpath(szName, drive, dir, NULL, NULL); _tmakepath_s(buff,_MAX_PATH, drive, dir, L"Plugin", L"ini"); strINI = buff; BOOL isExists = Profile_Initialize(strINI, TRUE); Profile_Free(); if (!isExists) { _tmakepath_s(buff,_MAX_PATH, drive, dir, L"DefaultPlugin", L"ini"); strINI = buff; } delete szName; } CString strSection; int i; for ( i=0;;i++) { wchar_t buff[_MAX_PATH] = {'\0'}; strSection.Format(L"Load%03d", i); Profile_Initialize(strINI, TRUE); Profile_GetString(strSection, L"Path", L"", buff, sizeof(buff), strINI); Profile_Free(); if (wcslen(buff) == 0) { break; } PSTEPlugin pPlugin = STEPluginLoadFile(buff); if (pPlugin == NULL) { //pPlugin->bUse = false; MessageBox(hWnd, CString(L"プラグイン(") + buff + L")の読み込みに失敗しました", L"プラグインエラー", MB_ICONSTOP|MB_OK|MB_TOPMOST); continue; } Profile_Initialize(strINI, TRUE); pPlugin->bUse = Profile_GetInt(strSection, L"Use", 1, strINI) ? true : false; Profile_Free(); } STEP_wndToolBar->UpdatePluginButton(); }