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
12 changes: 12 additions & 0 deletions src/core/IronPython.Modules/_winapi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
using IronPython.Runtime;
using IronPython.Runtime.Operations;

using Microsoft.Win32.SafeHandles;

[assembly: PythonModule("_winapi", typeof(IronPython.Modules.PythonWinApi), PlatformsAttribute.PlatformFamily.Windows)]
namespace IronPython.Modules {
[SupportedOSPlatform("windows")]
Expand Down Expand Up @@ -234,6 +236,16 @@ public static int WaitForSingleObject(BigInteger handle, int dwMilliseconds) {
return WaitForSingleObjectPI(new IntPtr((long)handle), dwMilliseconds);
}

public static void SetNamedPipeHandleState(BigInteger named_pipe, object? mode, object? max_collection_count, object? collect_data_timeout) {
if (max_collection_count is not null) throw new NotImplementedException();
if (collect_data_timeout is not null) throw new NotImplementedException();
var pipeHandle = new SafePipeHandle(new IntPtr((long)named_pipe), false);
int m = Converter.ConvertToInt32(mode);
var result = Interop.Kernel32.SetNamedPipeHandleState(pipeHandle, ref m, IntPtr.Zero, IntPtr.Zero);

if (!result) throw PythonNT.GetLastWin32Error();
}

#endregion

#region struct's and enum's
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.Win32.SafeHandles;

using System;
using System.Runtime.InteropServices;

internal static partial class Interop {
internal static partial class Kernel32 {
[DllImport(Libraries.Kernel32, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern unsafe bool SetNamedPipeHandleState(
SafePipeHandle hNamedPipe,
ref int lpMode,
IntPtr lpMaxCollectionCount,
IntPtr lpCollectDataTimeout
);
}
}
Loading