Skip to content
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
2 changes: 1 addition & 1 deletion win32/Demos/service/pipeTestService.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def DoProcessClient(self, pipeHandle, tid):
if ok:
msg = (
"%s (on thread %d) sent me %s"
% (GetNamedPipeHandleState(pipeHandle)[4], tid, d)
% (GetNamedPipeHandleState(pipeHandle, False, True)[4], tid, d)
).encode("ascii")
WriteFile(pipeHandle, msg)
finally:
Expand Down
7 changes: 4 additions & 3 deletions win32/src/win32apimodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2125,15 +2125,16 @@ static PyObject *PyGetLongPathNameW(PyObject *self, PyObject *args)
return obLongPathNameW;
}

// @pymethod int|win32api|GetTickCount|Returns the number of milliseconds since windows started.
// @pymethod int|win32api|GetTickCount|Returns the (64bit) number of milliseconds since windows started. Uses Win API GetTickCount64().
static PyObject *PyGetTickCount(PyObject *self, PyObject *args)
{
if (!PyArg_ParseTuple(args, ":PyGetTickCount"))
return NULL;
PyW32_BEGIN_ALLOW_THREADS DWORD count = GetTickCount();
PyW32_BEGIN_ALLOW_THREADS
ULONGLONG count = GetTickCount64();
PyW32_END_ALLOW_THREADS

return Py_BuildValue("l", (long)count);
return Py_BuildValue("K", count);
}

// @pymethod string|win32api|GetTempPath|Retrieves the path of the directory designated for temporary files.
Expand Down
18 changes: 14 additions & 4 deletions win32/src/win32pipe.i
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ PyObject *FdCreatePipe(SECURITY_ATTRIBUTES *INPUT, DWORD nSize, int mode);
#define NMPWAIT_WAIT_FOREVER NMPWAIT_WAIT_FOREVER
#define NMPWAIT_USE_DEFAULT_WAIT NMPWAIT_USE_DEFAULT_WAIT
#define PIPE_UNLIMITED_INSTANCES PIPE_UNLIMITED_INSTANCES
#define PIPE_ACCEPT_REMOTE_CLIENTS PIPE_ACCEPT_REMOTE_CLIENTS
#define PIPE_REJECT_REMOTE_CLIENTS PIPE_REJECT_REMOTE_CLIENTS
#define FILE_FLAG_FIRST_PIPE_INSTANCE FILE_FLAG_FIRST_PIPE_INSTANCE

%{
// @pyswig (int, int, int/None, int/None, <o PyUnicode>|GetNamedPipeHandleState|Determines the state of the named pipe.
Expand All @@ -104,21 +107,28 @@ PyObject *MyGetNamedPipeHandleState(PyObject *self, PyObject *args)
PyObject *obCollectDataTimeout;

BOOL getCollectData = FALSE;
BOOL getUserName = FALSE;
// @pyparm <o PyHANDLE>|hPipe||The handle to the pipe.
// @pyparm int|bGetCollectionData|0|Determines of the collection data should be returned. If not, None is returned in their place.
// @pyparm int|bGetCollectionData|0|Determines if the collection data should be retrieved. If not, None is returned in their place.
// @pyparm int|bGetUserName|0|Determines if the username should be retrieved. Works only for a server handle and if the client opened the pipe with SECURITY_IMPERSONATION access.

if (!PyArg_ParseTuple(args, "O|i:GetNamedPipeHandleState", &obhNamedPipe, &getCollectData))
if (!PyArg_ParseTuple(args, "O|ii:GetNamedPipeHandleState", &obhNamedPipe, &getCollectData, &getUserName))
return NULL;
if (!PyWinObject_AsHANDLE(obhNamedPipe, &hNamedPipe))
return NULL;
TCHAR buf[512];
TCHAR buf[512] = L"";
if (getCollectData) {
pMaxCollectionCount = &MaxCollectionCount;
pCollectDataTimeout = &CollectDataTimeout;
} else
pMaxCollectionCount = pCollectDataTimeout = NULL;

if (!GetNamedPipeHandleState(hNamedPipe, &State, &CurInstances, pMaxCollectionCount, pCollectDataTimeout, buf, 512))
BOOL ok;
Py_BEGIN_ALLOW_THREADS
ok = GetNamedPipeHandleState(hNamedPipe, &State, &CurInstances, pMaxCollectionCount, pCollectDataTimeout,
getUserName ? buf : NULL, 512);
Py_END_ALLOW_THREADS
if (!ok)
return PyWin_SetAPIError("GetNamedPipeHandleState");
PyObject *obName = PyWinObject_FromTCHAR(buf);
if (getCollectData) {
Expand Down