+ if (valType == varprop::VT_STRING)
+ {
+ String strVal = EscapeValue(value.GetString());
+ LPCWSTR text = strVal.c_str();
+ retValReg =WritePrivateProfileString(lpAppName, name.c_str(), text, GetFilePath());
+ }
+ else if (valType == varprop::VT_INT)
+ {
+ DWORD dwordVal = value.GetInt();
+ String strVal = strutils::to_str(dwordVal);
+ LPCWSTR text = strVal.c_str();
+ retValReg =WritePrivateProfileString(lpAppName, name.c_str(), text, GetFilePath());
+ }
+ else if (valType == varprop::VT_BOOL)
+ {
+ DWORD dwordVal = value.GetBool() ? 1 : 0;
+ String strVal = strutils::to_str(dwordVal);
+ LPCWSTR text = strVal.c_str();
+ retValReg = WritePrivateProfileString(lpAppName, name.c_str(), text, GetFilePath());
+ }
+ else if (valType == varprop::VT_NULL)
+ {
+ auto [strPath, strValueName] = SplitName(name);
+ if (!strValueName.empty())
+ retValReg = WritePrivateProfileString(lpAppName, name.c_str(), nullptr, GetFilePath());
+ else
+ {
+ auto iniFileMap = Load(GetFilePath());
+ for (auto& [key, value2] : iniFileMap)
+ {
+ if (key.find(strPath) == 0 && key.length() > strPath.length() && key[strPath.length()] == '/')
+ retValReg = WritePrivateProfileString(lpAppName, key.c_str(), nullptr, GetFilePath());
+ }
+ }
+ }
+ else
+ {
+ retVal = COption::OPT_UNKNOWN_TYPE;
+ }
+
+ if (!retValReg)
+ {
+ retVal = COption::OPT_ERR;
+ }
+ return retVal;