From d90a7bfca694e956879221ba24f4b54cd35379f3 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sat, 5 Sep 2015 17:09:17 +0000 Subject: MirLua: fix registry read & write git-svn-id: http://svn.miranda-ng.org/main/trunk@15277 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/m_windows.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'plugins/MirLua/src') diff --git a/plugins/MirLua/src/m_windows.cpp b/plugins/MirLua/src/m_windows.cpp index 9aee495b44..c42be30335 100644 --- a/plugins/MirLua/src/m_windows.cpp +++ b/plugins/MirLua/src/m_windows.cpp @@ -214,7 +214,7 @@ static int lua_GetRegValue(lua_State *L) ptrT valueName(mir_utf8decodeT(luaL_checkstring(L, 3))); HKEY hKey = 0; - LSTATUS res = ::RegOpenKeyEx(hRootKey, path, NULL, KEY_WRITE, &hKey); + LSTATUS res = ::RegOpenKeyEx(hRootKey, path, NULL, KEY_READ, &hKey); if (res != ERROR_SUCCESS) { lua_pushvalue(L, 4); @@ -248,7 +248,10 @@ static int lua_GetRegValue(lua_State *L) case REG_SZ: case REG_LINK: case REG_EXPAND_SZ: - lua_pushlstring(L, ptrA(Utf8EncodeT((TCHAR*)value)), length); + { + ptrA str(Utf8EncodeT((TCHAR*)value)); + lua_pushlstring(L, str, mir_strlen(str)); + } break; default: @@ -302,7 +305,7 @@ static int lua_SetRegValue(lua_State *L) case LUA_TSTRING: type = REG_SZ; - length = mir_strlen(lua_tostring(L, 4)); + length = mir_strlen(lua_tostring(L, 4)) * sizeof(TCHAR); value = (BYTE*)mir_utf8decodeT(lua_tostring(L, 4)); break; -- cgit v1.2.3