diff options
| author | Alexander Lantsev <aunsane@gmail.com> | 2015-07-13 08:32:15 +0000 | 
|---|---|---|
| committer | Alexander Lantsev <aunsane@gmail.com> | 2015-07-13 08:32:15 +0000 | 
| commit | ee57d99782d0a3a789b673f13cfdf96e1a77de23 (patch) | |
| tree | 2a93b64531da57568acbe636a9d418ebdd2713d6 /plugins/MirLua/src | |
| parent | 48aa58dc0d101f7f64a9b244b4dfb6751e9931e4 (diff) | |
MirLua: added GetIniValue, SetIniValue to m_windows
git-svn-id: http://svn.miranda-ng.org/main/trunk@14549 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src')
| -rw-r--r-- | plugins/MirLua/src/m_windows.cpp | 46 | 
1 files changed, 46 insertions, 0 deletions
diff --git a/plugins/MirLua/src/m_windows.cpp b/plugins/MirLua/src/m_windows.cpp index e42c9ece7b..26be06b0f2 100644 --- a/plugins/MirLua/src/m_windows.cpp +++ b/plugins/MirLua/src/m_windows.cpp @@ -25,10 +25,56 @@ static int lua_ShellExecute(lua_State *L)  	return 0;
  }
 +static int lua_GetIniValue(lua_State *L)
 +{
 +	ptrT path(mir_utf8decodeT(luaL_checkstring(L, 1)));
 +	ptrT section(mir_utf8decodeT(luaL_checkstring(L, 2)));
 +	ptrT key(mir_utf8decodeT(luaL_checkstring(L, 3)));
 +
 +	if (lua_isinteger(L, 4))
 +	{
 +		int default = lua_tointeger(L, 4);
 +
 +		UINT res = ::GetPrivateProfileInt(section, key, default, path);
 +		lua_pushinteger(L, res);
 +
 +		return 1;
 +	}
 +
 +	ptrT default(mir_utf8decodeT(lua_tostring(L, 4)));
 +
 +	TCHAR value[MAX_PATH] = { 0 };
 +	if (!::GetPrivateProfileString(section, key, default, value, _countof(value), path))
 +	{
 +		lua_pushvalue(L, 4);
 +	}
 +
 +	ptrA res(mir_utf8encodeT(value));
 +	lua_pushstring(L, res);
 +
 +	return 1;
 +}
 +
 +static int lua_SetIniValue(lua_State *L)
 +{
 +	ptrT path(mir_utf8decodeT(luaL_checkstring(L, 1)));
 +	ptrT section(mir_utf8decodeT(luaL_checkstring(L, 2)));
 +	ptrT key(mir_utf8decodeT(luaL_checkstring(L, 3)));
 +	ptrT value(mir_utf8decodeT(lua_tostring(L, 4)));
 +
 +	bool res = ::WritePrivateProfileString(section, key, value, path) != 0;
 +	lua_pushboolean(L, res);
 +
 +	return 1;
 +}
 +
  static luaL_Reg winApi[] =
  {
  	{ "MessageBox", lua_MessageBox },
 +	{ "GetIniValue", lua_GetIniValue },
 +	{ "SetIniValue", lua_SetIniValue },
 +
  	{ "ShellExecute", lua_ShellExecute },
  	{ NULL, NULL }
  | 
