Skip to content

Commit

Permalink
LuaFAR: продолжение M#3175.
Browse files Browse the repository at this point in the history
- Убрана функция win.DeleteRegKeyEx.
- Функция win.DeleteRegKey принимает дополнительный параметр AccessMask (который игнорируется, если операционная система не поддерживает функцию RegDeleteKeyExW).
  • Loading branch information
shmuz committed Mar 7, 2016
1 parent 4b7b9ef commit 1fd0065
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 50 deletions.
30 changes: 3 additions & 27 deletions enc/enc_lua/luafar_manual.tsi
Expand Up @@ -9851,35 +9851,14 @@ mtime=3664128224
</article>
</node>
<node>
id=18
lv=3
dt=Text
nm=win.DeleteRegKey
mtime=3664134703
<article>
#_result = win.DeleteRegKey (RootKey, Key)
#_
#_**Parameters:**
#_ RootKey: string (one of: "HKLM", "HKCC", "HKCR", "HKCU", "HKU")
#_ Key: string
#_
#_**Returns:**
#_ result: boolean
#_
#_**Description:**
#_ This function deletes a registry key.
#_
</article>
</node>
<node>
id=521
lv=3
dt=Text
nm=win.DeleteRegKeyEx
nm=win.DeleteRegKey
ctime=3665073013
mtime=3665078849
mtime=3666541346
<article>
#_result = win.DeleteRegKeyEx (RootKey, Key, [AccessMask])
#_result = win.DeleteRegKey (RootKey, Key, [AccessMask])
#_
#_**Parameters:**
#_ RootKey: string (one of: "HKLM", "HKCC", "HKCR", "HKCU", "HKU")
Expand All @@ -9892,9 +9871,6 @@ mtime=3665078849
#_**Description:**
#_ This function deletes a registry key.
#_
#_**Note:**
#_ This function will return **false** if the function **RegDeleteKeyExW** is not supported
#_ by the operating system.
</article>
</node>
<node>
Expand Down
2 changes: 1 addition & 1 deletion plugins/luamacro/_globalinfo.lua
@@ -1,6 +1,6 @@
function export.GetGlobalInfo()
return {
Version = { 1, 0, 0, 562 },
Version = { 1, 0, 0, 563 },
MinFarVersion = { 3, 0, 0, 4450 },
Guid = win.Uuid("4EBBEFC8-2084-4B7F-94C0-692CE136894D"),
Title = "LuaMacro",
Expand Down
9 changes: 8 additions & 1 deletion plugins/luamacro/changelog
@@ -1,4 +1,11 @@
shmuel 06.03.2016 17:37:26 +0200 - build 562
shmuel 07.03.2016 19:41:34 +0200 - build 563

1. LuaFAR: продолжение M#3175.
- Убрана функция win.DeleteRegKeyEx.
- Функция win.DeleteRegKey принимает дополнительный параметр AccessMask (который игнорируется,
если операционная система не поддерживает функцию RegDeleteKeyExW).

shmuel 06.03.2016 17:37:26 +0200 - build 562

1. LuaFAR: фикс во внутренней функции GetFarColor для совместимости с LuaJIT 2.1.0-beta2.

Expand Down
30 changes: 10 additions & 20 deletions plugins/luamacro/luafar/win.c
Expand Up @@ -182,40 +182,31 @@ static int win_GetRegKey(lua_State *L)
return 2;
}

// Result = DeleteRegKey (Root, Key)
// Result = DeleteRegKey (Root, Key [, samDesired])
// Root: [string], one of "HKLM", "HKCC", "HKCR", "HKCU", "HKU"
// Key: registry key, [string]
// samDesired: access mask, [flag] ("KEY_WOW64_32KEY" or "KEY_WOW64_64KEY"; the default is 0)
// Returns:
// Result: TRUE if success, FALSE if failure, [boolean]
static int win_DeleteRegKey(lua_State *L)
{
long res;
HKEY hRoot = CheckHKey(L, 1);
const wchar_t* Key = check_utf8_string(L, 2, NULL);
long res = RegDeleteKeyW(hRoot, Key);
lua_pushboolean(L, res==ERROR_SUCCESS);
return 1;
}
REGSAM samDesired = (REGSAM) OptFlags(L, 3, 0);

// Result = DeleteRegKeyEx (Root, Key [, samDesired])
// Root: [string], one of "HKLM", "HKCC", "HKCR", "HKCU", "HKU"
// Key: registry key, [string]
// samDesired: access mask, [flag] ("KEY_WOW64_32KEY" or "KEY_WOW64_64KEY"; the default is 0)
// Returns:
// Result: TRUE if success, FALSE if failure, [boolean]
static int win_DeleteRegKeyEx(lua_State *L)
{
FARPROC ProcAddr;
HMODULE module = GetModuleHandleW(L"Advapi32.dll");
if (module && (ProcAddr = GetProcAddress(module, "RegDeleteKeyExW")) != NULL)
{
typedef LONG (WINAPI *pRegDeleteKeyEx)(HKEY, LPCTSTR, REGSAM, DWORD);
HKEY hRoot = CheckHKey(L, 1);
const wchar_t* Key = check_utf8_string(L, 2, NULL);
REGSAM samDesired = (REGSAM) OptFlags(L, 3, 0);
long res = ((pRegDeleteKeyEx)ProcAddr)(hRoot, Key, samDesired, 0);
return lua_pushboolean(L, res==ERROR_SUCCESS), 1;
res = ((pRegDeleteKeyEx)ProcAddr)(hRoot, Key, samDesired, 0);
}
else
{
res = RegDeleteKeyW(hRoot, Key);
}
return lua_pushboolean(L,0), 1;
return lua_pushboolean(L, res==ERROR_SUCCESS), 1;
}

// Result = DeleteRegValue (Root, Key, ValueName [, samDesired])
Expand Down Expand Up @@ -723,7 +714,6 @@ const luaL_Reg win_funcs[] =
{"CreateDir", win_CreateDir},
{"DeleteFile", win_DeleteFile},
{"DeleteRegKey", win_DeleteRegKey},
{"DeleteRegKeyEx", win_DeleteRegKeyEx},
{"DeleteRegValue", win_DeleteRegValue},
{"EnumRegKey", win_EnumRegKey},
{"EnumRegValue", win_EnumRegValue},
Expand Down
2 changes: 1 addition & 1 deletion plugins/luamacro/luamacro.rc
@@ -1,6 +1,6 @@
#include <farversion.hpp>

#define PLUGIN_BUILD 562
#define PLUGIN_BUILD 563
#define PLUGIN_DESC "Lua Macros for Far Manager"
#define PLUGIN_NAME "LuaMacro"
#define PLUGIN_FILENAME "luamacro.dll"
Expand Down

0 comments on commit 1fd0065

Please sign in to comment.