Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for WTSIsRemoteSession flag. #2152

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions win32/src/win32tsmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ static PyObject *PyWTSQuerySessionInformation(PyObject *self, PyObject *args, Py
case WTSConnectState: // @flag WTSConnectState|Int, from WTS_CONNECTSTATE_CLASS
ret = PyLong_FromLong(*(INT *)buf);
break;
case WTSIsRemoteSession: // @flag WTSIsRemoteSession|Boolean
ret = PyBool_FromLong(*(BYTE *)buf);
break;
case WTSClientDisplay: { // @flag WTSClientDisplay|Dict containing client's display settings
WTS_CLIENT_DISPLAY *wcd = (WTS_CLIENT_DISPLAY *)buf;
ret = Py_BuildValue("{s:k, s:k, s:k}", "HorizontalResolution", wcd->HorizontalResolution,
Expand Down Expand Up @@ -768,6 +771,7 @@ PYWIN_MODULE_INIT_FUNC(win32ts)
PyModule_AddIntConstant(module, "WTSClientAddress", WTSClientAddress);
PyModule_AddIntConstant(module, "WTSClientDisplay", WTSClientDisplay);
PyModule_AddIntConstant(module, "WTSClientProtocolType", WTSClientProtocolType);
PyModule_AddIntConstant(module, "WTSIsRemoteSession", WTSIsRemoteSession);

// WTS_CONFIG_CLASS
PyModule_AddIntConstant(module, "WTSUserConfigInitialProgram", WTSUserConfigInitialProgram);
Expand Down
19 changes: 19 additions & 0 deletions win32/test/test_win32ts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Tests for win32ts module

import unittest

import win32ts


class Win32TsTestCase(unittest.TestCase):
def test_is_remote_session(self):
ret = win32ts.WTSQuerySessionInformation(
win32ts.WTS_CURRENT_SERVER_HANDLE,
win32ts.WTS_CURRENT_SESSION,
win32ts.WTSIsRemoteSession,
)
self.assertIsInstance(ret, bool)


if __name__ == "__main__":
unittest.main()