Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than user32, prefix the name with the module name and a period.
CreateWindow (user32)
.
THIS IS NOT THE CREATEWINDOW API!
You've had over a decade to get this shit right. What's your excuse?
C# Signature:
[DllImport("user32.dll", EntryPoint="CreateWindowStation", CharSet=CharSet.Unicode, SetLastError=true)]
public static extern IntPtr CreateWindowStation(
[MarshalAs(UnmanagedType.LPWStr)] string name,
[MarshalAs(UnmanagedType.U4)] int reserved, // must be zero.
[MarshalAs(UnmanagedType.U4)] WINDOWS_STATION_ACCESS_MASK desiredAccess,
[MarshalAs(UnmanagedType.LPStruct)] SecurityAttributes attributes);
User-Defined Types:
None.
Notes:
None.
Tips & Tricks:
Please add some!
Sample Code:
[StructLayout(LayoutKind.Sequential)]
public class SecurityAttributes
{
#region Struct members
[MarshalAs(UnmanagedType.U4)]
private int mStuctLength;
/// <summary>
/// Base class for the safe handles used for Windows Station and Desktop API.
/// </summary>
public abstract class BaseSafeHandle : SafeHandleZeroOrMinusOneIsInvalid
{
protected BaseSafeHandle(IntPtr handle, bool ownsHandle)
: base(ownsHandle)
{
SetHandle(handle);
}
/// <summary>
/// Close the native handle. The real call is dependent on whether it is
/// a WindowsStation or a Desktop.
/// </summary>
/// <param name="handle">Handle to be closed.</param>
/// <returns>true if successful, false other wise.</returns>
protected abstract bool CloseNativeHandle(IntPtr handle);
public class SafeWindowStationHandle : BaseSafeHandle
{
public SafeWindowStationHandle(IntPtr handle, bool ownsHandle)
: base(handle, ownsHandle)
{ }
protected override bool CloseNativeHandle(IntPtr handle)
{
return WindowStationAndDesktop.CloseWindowStation(handle);
}
}
public static SafeWindowStationHandle CreateWindowStation(string name)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentException("Invalid window station name", "name");
}
IntPtr handle = WindowStationAndDesktop.CreateWindowStation(name, 0,
WINDOWS_STATION_ACCESS_MASK.WINSTA_ALL_ACCESS, null);
if (handle == IntPtr.Zero)
{
int error = Marshal.GetLastWin32Error();
throw new Win32Exception(error);
}
SafeWindowStationHandle safeHandle = new SafeWindowStationHandle(handle, true);
return safeHandle;
}
Alternative Managed API:
Do you know one? Please contribute it!
Click to read this page
11/30/2018 2:31:03 AM - -79.133.249.105
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).