diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2016-06-13 14:38:27 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2016-06-13 14:38:27 +0000 |
commit | 12079f831a61d7016719884102355c93d461abe3 (patch) | |
tree | f5b3336f10e606014ee6ce635c5675da64db0dc1 /plugins | |
parent | 8cf571c5ea48be2d281d2c83ed0f2dba6f2c32f4 (diff) |
lua winapi: GetOpenFileName function
git-svn-id: http://svn.miranda-ng.org/main/trunk@16966 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/MirLua/Modules/WinAPI/src/winapi.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/plugins/MirLua/Modules/WinAPI/src/winapi.cpp b/plugins/MirLua/Modules/WinAPI/src/winapi.cpp index 974010d7b6..bb1606ba35 100644 --- a/plugins/MirLua/Modules/WinAPI/src/winapi.cpp +++ b/plugins/MirLua/Modules/WinAPI/src/winapi.cpp @@ -1704,6 +1704,26 @@ static int global_GetCurrentProcessId(lua_State *L) return 1;
}
+static int global_GetOpenFileName(lua_State *L)
+{
+ const char *szExt = luaL_optstring(L, 1, nullptr);
+ _A2T tszExt(szExt);
+ wchar_t buff[MAX_PATH], f[2] = { 0, 0 };
+
+ OPENFILENAME ofn = { 0 };
+ ofn.lStructSize = sizeof(ofn);
+ ofn.lpstrFile = buff;
+ ofn.nMaxFile = _countof(buff);
+ ofn.lpstrDefExt = tszExt;
+ ofn.lpstrFilter = f;
+
+ if (GetOpenFileNameW(&ofn))
+ lua_pushstring(L, T2Utf(buff));
+ else
+ lua_pushnil(L);
+ return 1;
+}
+
static luaM_consts consts[] =
{
{ "TRUE", TRUE },
@@ -1961,6 +1981,7 @@ static luaL_Reg winApi[] = { "CoInitialize", global_CoInitialize },
{ "CoUninitialize", global_CoUninitialize },
{ "GetCurrentProcessId", global_GetCurrentProcessId },
+ { "GetOpenFileName", global_GetOpenFileName },
{ NULL, NULL }
};
|