mirror of https://github.com/dahall/Vanara.git
More work on WTSApi32
parent
8acca80194
commit
79ceb6112e
|
@ -3700,6 +3700,12 @@ namespace Vanara.PInvoke
|
|||
/// <returns>A <see cref="System.String"/> that represents this instance.</returns>
|
||||
public string ToString(uint allocatedBytes) => StringHelper.GetString(handle, CharSet.Auto, allocatedBytes);
|
||||
|
||||
/// <summary>Marshals data from this memory to a newly allocated managed object of the type specified by a generic type parameter.</summary>
|
||||
/// <typeparam name="T">The type of the object to which the data is to be copied. This must be a structure.</typeparam>
|
||||
/// <param name="allocatedBytes">If known, the total number of bytes allocated to the native memory in <paramref name="ptr"/>.</param>
|
||||
/// <returns>A managed object that contains the data that this memory points to.</returns>
|
||||
public T ToStructure<T>(uint allocatedBytes) => handle.Convert<T>(allocatedBytes == 0 ? uint.MaxValue : allocatedBytes);
|
||||
|
||||
#if ALLOWSPAN
|
||||
/// <summary>Creates a new span over this allocated memory.</summary>
|
||||
/// <returns>The span representation of the structure.</returns>
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Vanara.PInvoke
|
||||
{
|
||||
/// <summary>Items from the WTSApi32.dll</summary>
|
||||
public static partial class WTSApi32
|
||||
{
|
||||
/// <summary>Specifies the type of hint represented by a call to <see cref="WTSSetRenderHint"/>.</summary>
|
||||
[PInvokeData("wtshintapi.h", MSDNShortId = "NF:wtshintapi.WTSSetRenderHint")]
|
||||
public enum RENDER_HINT
|
||||
{
|
||||
/// <summary>
|
||||
/// The previous hint is cleared.
|
||||
/// <para>pHintData must be <c>NULL</c>.</para>
|
||||
/// </summary>
|
||||
RENDER_HINT_CLEAR = 0x0,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the presence of moving video.
|
||||
/// <para>
|
||||
/// pHintData contains a RECT structure which specifies the coordinates and size of the rendering area. These per-monitor
|
||||
/// DPI-aware coordinates are relative to the client coordinates of the window represented by the hwndOwner parameter.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
RENDER_HINT_VIDEO = 0x1,
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the presence of a window mapping.
|
||||
/// <para>
|
||||
/// pHintData contains a RECT structure which specifies the coordinates and size of the rendering area. These per-monitor
|
||||
/// DPI-aware coordinates are relative to the client coordinates of the window represented by the hwndOwner parameter.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <c>Windows 8 and Windows Server 2012:</c> The coordinates are not DPI-aware before Windows 8.1 and Windows Server 2012 R2.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
RENDER_HINT_MAPPEDWINDOW = 0x2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>
|
||||
/// Used by an application that is displaying content that can be optimized for displaying in a remote session to identify the
|
||||
/// region of a window that is the actual content.
|
||||
/// </para>
|
||||
/// <para>In the remote session, this content will be encoded, sent to the client, then decoded and displayed.</para>
|
||||
/// </summary>
|
||||
/// <param name="pRenderHintID">
|
||||
/// The address of a value that identifies the rendering hint affected by this call. If a new hint is being created, this value must
|
||||
/// contain zero. This function will return a unique rendering hint identifier which is used for subsequent calls, such as clearing
|
||||
/// the hint.
|
||||
/// </param>
|
||||
/// <param name="hwndOwner">
|
||||
/// The handle of window linked to lifetime of the rendering hint. This window is used in situations where a hint target is removed
|
||||
/// without the hint being explicitly cleared.
|
||||
/// </param>
|
||||
/// <param name="renderHintType">
|
||||
/// <para>Specifies the type of hint represented by this call.</para>
|
||||
/// <para>RENDER_HINT_CLEAR (0)</para>
|
||||
/// <para>The previous hint is cleared.</para>
|
||||
/// <para>pHintData must be <c>NULL</c>.</para>
|
||||
/// <para>RENDER_HINT_VIDEO (1)</para>
|
||||
/// <para>Indicates the presence of moving video.</para>
|
||||
/// <para>
|
||||
/// pHintData contains a RECT structure which specifies the coordinates and size of the rendering area. These per-monitor DPI-aware
|
||||
/// coordinates are relative to the client coordinates of the window represented by the hwndOwner parameter.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <c>Windows 8 and Windows Server 2012:</c> The coordinates are not DPI-aware before Windows 8.1 and Windows Server 2012 R2.
|
||||
/// </para>
|
||||
/// <para>RENDER_HINT_MAPPEDWINDOW (2)</para>
|
||||
/// <para>Indicates the presence of a window mapping.</para>
|
||||
/// <para>
|
||||
/// pHintData contains a RECT structure which specifies the coordinates and size of the rendering area. These per-monitor DPI-aware
|
||||
/// coordinates are relative to the client coordinates of the window represented by the hwndOwner parameter.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// <c>Windows 8 and Windows Server 2012:</c> The coordinates are not DPI-aware before Windows 8.1 and Windows Server 2012 R2.
|
||||
/// </para>
|
||||
/// </param>
|
||||
/// <param name="cbHintDataLength">The size, in <c>BYTE</c> s, of the pHintData buffer.</param>
|
||||
/// <param name="pHintData">
|
||||
/// <para>Additional data for the hint.</para>
|
||||
/// <para>The format of this data is dependent upon the value passed in the renderHintType parameter.</para>
|
||||
/// </param>
|
||||
/// <returns>If this function succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</returns>
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/wtshintapi/nf-wtshintapi-wtssetrenderhint HRESULT WTSSetRenderHint( UINT64
|
||||
// *pRenderHintID, HWND hwndOwner, DWORD renderHintType, DWORD cbHintDataLength, BYTE *pHintData );
|
||||
[DllImport(Lib_WTSApi32, SetLastError = false, ExactSpelling = true)]
|
||||
[PInvokeData("wtshintapi.h", MSDNShortId = "NF:wtshintapi.WTSSetRenderHint")]
|
||||
public static extern HRESULT WTSSetRenderHint(ref ulong pRenderHintID, HWND hwndOwner, RENDER_HINT renderHintType, uint cbHintDataLength, [In, Optional] IntPtr pHintData);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<AssemblyName>UnitTest.PInvoke.WTSApi32</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\PInvoke\WTSApi32\Vanara.PInvoke.WTSApi32.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,29 @@
|
|||
using NUnit.Framework;
|
||||
using NUnit.Framework.Internal;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using static Vanara.PInvoke.WTSApi32;
|
||||
|
||||
namespace Vanara.PInvoke.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class WTSApi32Tests
|
||||
{
|
||||
[OneTimeSetUp]
|
||||
public void _Setup()
|
||||
{
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void _TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WTSEnumerateServersTest()
|
||||
{
|
||||
Assert.That(WTSEnumerateServers(null, out var servers), ResultIs.Successful);
|
||||
servers.WriteValues();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue