initial checkin of yaulw (locally)
This commit is contained in:
27
Win32/Advapi32.cs
Normal file
27
Win32/Advapi32.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
namespace Yaulw.Win32
|
||||
{
|
||||
/// <remarks>
|
||||
/// Advapi.dll Entry Points * http://pinvoke.net/ *
|
||||
/// </remarks>
|
||||
public static class Advapi32
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves the current status of the specified service based on the specified information level
|
||||
/// </summary>
|
||||
/// <param name="hService">A handle to the service</param>
|
||||
/// <param name="InfoLevel">The service attributes to be returned</param>
|
||||
/// <param name="lpBuffer">A pointer to the buffer that receives the status information</param>
|
||||
/// <param name="cbBufSize">he size of the buffer pointed to by the lpBuffer</param>
|
||||
/// <param name="pcbBytesNeeded">A pointer to a variable that receives the number of bytes needed to store all status information</param>
|
||||
/// <returns>If the function succeeds, the return value is nonzero</returns>
|
||||
[DllImport("Advapi32.dll")]
|
||||
extern public static bool QueryServiceStatusEx(IntPtr hService, int InfoLevel, ref Structures.SERVICE_STATUS_PROCESS lpBuffer, int cbBufSize, out int pcbBytesNeeded);
|
||||
}
|
||||
}
|
||||
321
Win32/AtomMessenger.cs
Normal file
321
Win32/AtomMessenger.cs
Normal file
@@ -0,0 +1,321 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Yaulw.Win32
|
||||
{
|
||||
/// <remarks>
|
||||
/// Quick and Easy Atom Window Messages Communication between windows of different
|
||||
/// Processes.
|
||||
/// </remarks>
|
||||
public class AtomMessenger : IDisposable
|
||||
{
|
||||
#region Private Members
|
||||
private const string _AtomMsgIDFormat = "AtomMsgID-[{0}]";
|
||||
private string _AtomMsgStr = "";
|
||||
private uint _AtomMsg = 0;
|
||||
private bool _disposed = false;
|
||||
|
||||
// For Posted Atom Messages
|
||||
private const int MAGIC_NUMBER_POSTED_ATOM_KEYS = 7;
|
||||
private List<uint> _postedAtomKeys = new List<uint>();
|
||||
#endregion
|
||||
|
||||
#region Construction
|
||||
|
||||
/// <summary>
|
||||
/// Create an Atom Messaging Component with a Unique Identifier.
|
||||
/// The same Identifier should be used by all applications that want to pass
|
||||
/// Messages back and forth.
|
||||
/// ~You need to dispose of this Object only if you plan on using PostAtomMessage()
|
||||
/// </summary>
|
||||
/// <param name="UniqueWindowMessageIdentifier">An identifier for the Messaging</param>
|
||||
public AtomMessenger(Guid UniqueWindowMessageIdentifier)
|
||||
{
|
||||
if (UniqueWindowMessageIdentifier == null)
|
||||
throw new ArgumentNullException();
|
||||
|
||||
// Register the Unique Window Message
|
||||
_AtomMsgStr = String.Format(_AtomMsgIDFormat, UniqueWindowMessageIdentifier);
|
||||
_AtomMsg = User32.RegisterWindowMessage(_AtomMsgStr);
|
||||
if (_AtomMsg == 0)
|
||||
throw new Exception("RegisterWindowMessage Failed");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finalizer
|
||||
/// </summary>
|
||||
~AtomMessenger()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Atom Message Construction Helpers
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve ';' seperated values from an Atom Message
|
||||
/// </summary>
|
||||
/// <param name="AtomMessage">an atom message that contains multiple args</param>
|
||||
/// <returns>multiple args</returns>
|
||||
public string[] RetrieveMultipleValuesFromAtomMessage(string AtomMessage)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(AtomMessage))
|
||||
return AtomMessage.Split(';');
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create ';' seperated Atom message from multiple values
|
||||
/// </summary>
|
||||
/// <returns>an Atom Message containing multiple args</returns>
|
||||
public string SetMultipleValueInAtomMessage(params object[] args)
|
||||
{
|
||||
if (args != null)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (object a in args)
|
||||
{
|
||||
sb.Append(a.ToString());
|
||||
sb.Append(";");
|
||||
}
|
||||
|
||||
// Remove Trailing ";"
|
||||
sb = sb.Remove(sb.Length - 1, 1);
|
||||
return sb.ToString();
|
||||
}
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Atom Message Identify / Retrieval
|
||||
|
||||
/// <summary>
|
||||
/// Use this to check if the passed in Message is an Atom Message.
|
||||
/// The identifier of the Message must match the Message registered with the UniqueIdentifier
|
||||
/// </summary>
|
||||
/// <param name="m">a Windows.Forms Message</param>
|
||||
/// <returns>true if the Messages matches the one created by the UniqueIdentifier</returns>
|
||||
public bool IsAtomMessage(ref Message m)
|
||||
{
|
||||
return (m.Msg == _AtomMsg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the values passed in by an Atom Message
|
||||
/// </summary>
|
||||
/// <param name="m">a Windows.Forms Message</param>
|
||||
/// <param name="AtomMessage">the Message Retrieved from the Atom</param>
|
||||
/// <param name="hWndSrc">the source window who send it, if valid</param>
|
||||
public void GetAtomMessageValues(ref Message m, out string AtomMessage, out IntPtr hWndSrc)
|
||||
{
|
||||
AtomMessage = String.Empty;
|
||||
hWndSrc = IntPtr.Zero;
|
||||
|
||||
// Check to make sure this is an Atom Message
|
||||
if (!IsAtomMessage(ref m))
|
||||
return;
|
||||
|
||||
// Source is passed to us by wParam
|
||||
if(m.WParam != IntPtr.Zero && User32.IsWindow(m.WParam))
|
||||
hWndSrc = m.WParam;
|
||||
|
||||
// Now retrieve the Atom Message
|
||||
StringBuilder sb = new StringBuilder( 254 );
|
||||
uint AtomKey = (uint) m.LParam;
|
||||
uint slen = Kernel32.GlobalGetAtomName(AtomKey, sb, 254);
|
||||
if (slen == 0)
|
||||
return;
|
||||
|
||||
// Write out Retrieved Message
|
||||
AtomMessage = sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the values passed in by an Atom Message
|
||||
/// </summary>
|
||||
/// <param name="m">a Windows.Forms Message</param>
|
||||
/// <param name="AtomMessage">the Message with multiple values retrieved from the Atom</param>
|
||||
/// <param name="hWndSrc">the source window who send it, if valid</param>
|
||||
public void GetAtomMessageValues(ref Message m, out string[] AtomMessage, out IntPtr hWndSrc)
|
||||
{
|
||||
AtomMessage = null;
|
||||
hWndSrc = IntPtr.Zero;
|
||||
|
||||
// Check to make sure this is an Atom Message
|
||||
if (!IsAtomMessage(ref m))
|
||||
return;
|
||||
|
||||
// Source is passed to us by wParam
|
||||
if (m.WParam != IntPtr.Zero && User32.IsWindow(m.WParam))
|
||||
hWndSrc = m.WParam;
|
||||
|
||||
// Now retrieve the Atom Message
|
||||
StringBuilder sb = new StringBuilder(254);
|
||||
uint AtomKey = (uint)m.LParam;
|
||||
uint slen = Kernel32.GlobalGetAtomName(AtomKey, sb, 254);
|
||||
if (slen == 0)
|
||||
return;
|
||||
|
||||
// Write out Retrieved Message
|
||||
AtomMessage = RetrieveMultipleValuesFromAtomMessage(sb.ToString());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Send/Post Atom Message
|
||||
|
||||
/// <summary>
|
||||
/// Sends an Atom Message To the Specified Window or All Windows
|
||||
/// </summary>
|
||||
/// <param name="hWndSrc">Sender Windows (Nice to have), in case Receiver Needs it</param>
|
||||
/// <param name="hWndDst">Can be IntPtr.Zero to BroadCast the Message, otherwise specify window to send to</param>
|
||||
/// <param name="AtomMessage">The Message to Send * Can not be longer than 254 chars *</param>
|
||||
public void SendAtomMessage(IntPtr hWndSrc, IntPtr hWndDst, string AtomMessage)
|
||||
{
|
||||
// Is Broadcast?
|
||||
bool bBroadcast = (hWndDst==IntPtr.Zero);
|
||||
|
||||
// Check to make sure Atom Message is proper
|
||||
if(String.IsNullOrEmpty(AtomMessage) || AtomMessage.Length > 254)
|
||||
throw new ArgumentException("AtomMessage Invalid");
|
||||
|
||||
// Register Atom
|
||||
uint AtomKey = Kernel32.GlobalAddAtom(AtomMessage);
|
||||
if (AtomKey == 0)
|
||||
throw new Exception("GlobalAddAtom Failed");
|
||||
|
||||
// Send the Message
|
||||
if(bBroadcast)
|
||||
User32.SendMessage(Definitions.HWND_BROADCAST, (int)_AtomMsg, hWndSrc, (IntPtr)AtomKey);
|
||||
else
|
||||
User32.SendMessage(hWndDst, (int)_AtomMsg, hWndSrc, (IntPtr)AtomKey);
|
||||
|
||||
// We are done with the Atom
|
||||
Kernel32.GlobalDeleteAtom(AtomKey);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends an Atom Message To the Specified Window or All Windows
|
||||
/// </summary>
|
||||
/// <param name="hWndSrc">Sender Windows (Nice to have), in case Receiver Needs it</param>
|
||||
/// <param name="hWndDst">Can be IntPtr.Zero to BroadCast the Message, otherwise specify window to send to</param>
|
||||
/// <param name="AtomMessage">The Message to Send that has multiple values * Total string can not be longer than 254 chars *</param>
|
||||
public void SendAtomMessage(IntPtr hWndSrc, IntPtr hWndDst, string[] AtomMessage)
|
||||
{
|
||||
SendAtomMessage(hWndSrc, hWndDst, SetMultipleValueInAtomMessage(AtomMessage));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Post an Atom Message To the Specified Window or All Windows
|
||||
/// </summary>
|
||||
/// <param name="hWndSrc">Sender Windows (Nice to have), in case Receiver Needs it</param>
|
||||
/// <param name="hWndDst">Can be IntPtr.Zero to BroadCast the Message, otherwise specify window to send to</param>
|
||||
/// <param name="AtomMessage">The Message to Send * Can not be longer than 254 chars *</param>
|
||||
public void PostAtomMessage(IntPtr hWndSrc, IntPtr hWndDst, string AtomMessage)
|
||||
{
|
||||
// Is Broadcast?
|
||||
bool bBroadcast = (hWndDst == IntPtr.Zero);
|
||||
|
||||
// Check to make sure Atom Message is proper
|
||||
if (String.IsNullOrEmpty(AtomMessage) || AtomMessage.Length > 254)
|
||||
throw new ArgumentException("AtomMessage Invalid");
|
||||
|
||||
// Register a new Atom
|
||||
uint nAtomKey = Kernel32.GlobalAddAtom(AtomMessage);
|
||||
if (nAtomKey == 0)
|
||||
throw new Exception("GlobalAddAtom Failed");
|
||||
|
||||
// Send the Message
|
||||
if (bBroadcast)
|
||||
User32.PostMessage(Definitions.HWND_BROADCAST, (int)_AtomMsg, hWndSrc, (IntPtr)nAtomKey);
|
||||
else
|
||||
User32.PostMessage(hWndDst, (int)_AtomMsg, hWndSrc, (IntPtr)nAtomKey);
|
||||
|
||||
// Imp! Atom still must get Deleted, that is why we add it to DS
|
||||
AddPostedAtomKey(nAtomKey);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Post an Atom Message To the Specified Window or All Windows
|
||||
/// </summary>
|
||||
/// <param name="hWndSrc">Sender Windows (Nice to have), in case Receiver Needs it</param>
|
||||
/// <param name="hWndDst">Can be IntPtr.Zero to BroadCast the Message, otherwise specify window to send to</param>
|
||||
/// <param name="AtomMessage">The Message to Send that has multiple values * Can not be longer than 254 chars *</param>
|
||||
public void PostAtomMessage(IntPtr hWndSrc, IntPtr hWndDst, string[] AtomMessage)
|
||||
{
|
||||
PostAtomMessage(hWndSrc, hWndDst, SetMultipleValueInAtomMessage(AtomMessage));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Posted Atom Keys handling
|
||||
|
||||
/// <summary>
|
||||
/// Adds the Specified Posted Atom Key to the Posted Atoms DS.
|
||||
/// Clears the DS, if MAGIC_NUMBER_POSTED_ATOM_KEY has been reached.
|
||||
/// </summary>
|
||||
/// <param name="nKey">a unique AtomKey</param>
|
||||
private void AddPostedAtomKey(uint nKey)
|
||||
{
|
||||
if (_postedAtomKeys.Count >= MAGIC_NUMBER_POSTED_ATOM_KEYS)
|
||||
DeleteAllPostedAtomKeys();
|
||||
|
||||
_postedAtomKeys.Add(nKey);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all posted Atoms and Clears the PostedAtoms DS
|
||||
/// </summary>
|
||||
private void DeleteAllPostedAtomKeys()
|
||||
{
|
||||
foreach (uint Key in _postedAtomKeys)
|
||||
Kernel32.GlobalDeleteAtom(Key);
|
||||
|
||||
_postedAtomKeys.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
/// <summary>
|
||||
/// Dispose Posted Atom Strings
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
||||
// Use SupressFinalize in case a subclass
|
||||
// of this type implements a finalizer
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose Posted Atom Strings
|
||||
/// </summary>
|
||||
/// <param name="disposing">true, if called from within</param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!_disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (_postedAtomKeys.Count != 0)
|
||||
DeleteAllPostedAtomKeys();
|
||||
}
|
||||
|
||||
// Indicate that the instance has been disposed.
|
||||
_postedAtomKeys = null;
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
116
Win32/COM.cs
Normal file
116
Win32/COM.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
|
||||
namespace Yaulw.Win32
|
||||
{
|
||||
/// <remarks>
|
||||
/// COM Win32 Helper Functions
|
||||
/// </remarks>
|
||||
public static class COM
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a pointer to an implementation of IBindCtx (a bind context object). This object stores information about a particular moniker-binding operation
|
||||
/// </summary>
|
||||
/// <param name="reserved">This parameter is reserved and must be 0</param>
|
||||
/// <param name="ppbc">Address of an IBindCtx* pointer variable that receives the interface pointer to the new bind context object. </param>
|
||||
/// <returns>This function can return the standard return values E_OUTOFMEMORY and S_OK</returns>
|
||||
[DllImport("ole32.dll")]
|
||||
public static extern int CreateBindCtx(int reserved, out IBindCtx ppbc);
|
||||
|
||||
/// <summary>
|
||||
/// Use this to retrieve the Actice COM Object from the ROT, for the specified progId
|
||||
/// </summary>
|
||||
/// <param name="progId"></param>
|
||||
/// <returns>a valid com object, or null if error occured</returns>
|
||||
public static Object GetActiceCOMObject(string progId)
|
||||
{
|
||||
Object app = null;
|
||||
try
|
||||
{
|
||||
app = Marshal.GetActiveObject(progId);
|
||||
}
|
||||
catch (SystemException) { /* ignore */ }
|
||||
return app;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ROT Object Entry
|
||||
/// </summary>
|
||||
public struct RunningObject
|
||||
{
|
||||
public string name;
|
||||
public object o;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use this to Get All Running Objects in the ROT
|
||||
/// </summary>
|
||||
/// <returns>list of all Runnint Objects in the ROT</returns>
|
||||
public static List<RunningObject> GetRunningObjects()
|
||||
{
|
||||
// Get the table.
|
||||
var res = new List<RunningObject>();
|
||||
IBindCtx bc;
|
||||
|
||||
CreateBindCtx(0, out bc);
|
||||
IRunningObjectTable runningObjectTable;
|
||||
|
||||
bc.GetRunningObjectTable(out runningObjectTable);
|
||||
IEnumMoniker monikerEnumerator;
|
||||
runningObjectTable.EnumRunning(out monikerEnumerator);
|
||||
monikerEnumerator.Reset();
|
||||
|
||||
// Enumerate and fill our nice dictionary.
|
||||
IMoniker[] monikers = new IMoniker[1];
|
||||
IntPtr numFetched = IntPtr.Zero;
|
||||
|
||||
while (monikerEnumerator.Next(1, monikers, numFetched) == 0)
|
||||
{
|
||||
RunningObject running;
|
||||
monikers[0].GetDisplayName(bc, null, out running.name);
|
||||
runningObjectTable.GetObject(monikers[0], out running.o);
|
||||
res.Add(running);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use this to Get A specific type of Object from the ROT
|
||||
/// </summary>
|
||||
/// <returns>List of a specific type of Object in the ROT</returns>
|
||||
public static List<T> GetRunningObjectsOfType<T>()
|
||||
{
|
||||
// Get the table.
|
||||
var res = new List<T>();
|
||||
IBindCtx bc;
|
||||
|
||||
CreateBindCtx(0, out bc);
|
||||
IRunningObjectTable runningObjectTable;
|
||||
|
||||
bc.GetRunningObjectTable(out runningObjectTable);
|
||||
IEnumMoniker monikerEnumerator;
|
||||
runningObjectTable.EnumRunning(out monikerEnumerator);
|
||||
monikerEnumerator.Reset();
|
||||
|
||||
// Enumerate and fill our nice dictionary.
|
||||
IMoniker[] monikers = new IMoniker[1];
|
||||
IntPtr numFetched = IntPtr.Zero;
|
||||
|
||||
while (monikerEnumerator.Next(1, monikers, numFetched) == 0)
|
||||
{
|
||||
object o;
|
||||
runningObjectTable.GetObject(monikers[0], out o);
|
||||
|
||||
if (o is T)
|
||||
res.Add((T)o);
|
||||
o = null;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
70
Win32/Convert.cs
Normal file
70
Win32/Convert.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Yaulw.Win32
|
||||
{
|
||||
/// <remarks>
|
||||
/// Helper class to Convert Win32 Structures to DotNet and vice versa
|
||||
/// </remarks>
|
||||
public static class Convert
|
||||
{
|
||||
/// <summary>
|
||||
/// Use this to Convert to Win32 Window Message Enum from a C# Message
|
||||
/// </summary>
|
||||
/// <param name="m">a C# Message</param>
|
||||
/// <returns>a Win32 Message Enum</returns>
|
||||
public static Definitions.WM MessageToWin32WM(Message m)
|
||||
{
|
||||
Definitions.WM wm = Definitions.WM.WM_NULL;
|
||||
try { wm = (Definitions.WM)m.Msg; }
|
||||
catch (Exception) { wm = Definitions.WM.WM_NULL; }
|
||||
return wm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use this to Convert to a C# Rectangle from a Win32 RECT
|
||||
/// </summary>
|
||||
/// <param name="rect">a Win32 Rect</param>
|
||||
/// <returns>a C# Rectancle</returns>
|
||||
public static Rectangle RECTToRectangle(Structures.RECT rect)
|
||||
{
|
||||
return new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use this to Convert a Win32 RECT to a C# Rectangle
|
||||
/// </summary>
|
||||
/// <param name="rect">a C# Rectangle</param>
|
||||
/// <returns>a Win32 Rect</returns>
|
||||
public static Structures.RECT RectangleToRECT(Rectangle rect)
|
||||
{
|
||||
return Structures.RECT.FromXYWH(rect.Left, rect.Top, rect.Width, rect.Height);
|
||||
}
|
||||
|
||||
#region Win32Owner
|
||||
|
||||
/// <remarks>
|
||||
/// a IWin32Window Object commonly used by WinForms
|
||||
/// </remarks>
|
||||
public class Win32Owner : IWin32Window
|
||||
{
|
||||
public IntPtr Handle { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert a Handle to a Win32Owner Object
|
||||
/// </summary>
|
||||
/// <param name="hWnd">pass in a Window Handle</param>
|
||||
/// <returns>a newly created Win32Owner Object</returns>
|
||||
public static IWin32Window ConverthWndToIWin32Window(IntPtr hWnd)
|
||||
{
|
||||
return new Win32Owner() { Handle = hWnd };
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
601
Win32/Definitions.cs
Normal file
601
Win32/Definitions.cs
Normal file
@@ -0,0 +1,601 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Yaulw.Win32
|
||||
{
|
||||
/// <remarks>
|
||||
/// Win32 Enums and Consts (Definitions)
|
||||
/// </remarks>
|
||||
public static class Definitions
|
||||
{
|
||||
#region Constants
|
||||
|
||||
/// <summary>
|
||||
/// Virtual Key Board Key Up Event
|
||||
/// </summary>
|
||||
public const ushort KEYEVENTF_KEYUP = 0x0002;
|
||||
|
||||
/// <summary>
|
||||
/// Source Copy Option
|
||||
/// </summary>
|
||||
public const int SRCCOPY = 13369376;
|
||||
|
||||
/// <summary>
|
||||
/// Default Monitor Nearest
|
||||
/// </summary>
|
||||
public const int MONITOR_DEFAULTTONEAREST = 0x00000002;
|
||||
|
||||
/// <summary>
|
||||
/// Universal Max Path Const used in Many Win32 Paths
|
||||
/// </summary>
|
||||
public const int MAX_PATH = 255;
|
||||
|
||||
/// <summary>
|
||||
/// For Windows Hooking
|
||||
/// </summary>
|
||||
public const int WH_CBT = 5;
|
||||
|
||||
/// <summary>
|
||||
/// System is about to activate a window
|
||||
/// </summary>
|
||||
public const int HCBT_ACTIVATE = 5;
|
||||
|
||||
/// <summary>
|
||||
/// Used for SendMessage/PostMessage
|
||||
/// </summary>
|
||||
public static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
|
||||
|
||||
#region Service Constants - Advapi32.dll
|
||||
|
||||
/// <summary>
|
||||
/// Service Option
|
||||
/// </summary>
|
||||
public const int SERVICE_WIN32_OWN_PROCESS = 0x00000010;
|
||||
|
||||
/// <summary>
|
||||
/// Service Option
|
||||
/// </summary>
|
||||
public const int SERVICE_RUNS_IN_SYSTEM_PROCESS = 0x00000001;
|
||||
|
||||
/// <summary>
|
||||
/// Service Option
|
||||
/// </summary>
|
||||
public const int SC_STATUS_PROCESS_INFO = 0;
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Enums
|
||||
|
||||
/// <summary>
|
||||
/// AssocQueryString Options
|
||||
/// </summary>
|
||||
public enum AssocF : ushort
|
||||
{
|
||||
Init_NoRemapCLSID = 0x1,
|
||||
Init_ByExeName = 0x2,
|
||||
Open_ByExeName = 0x2,
|
||||
Init_DefaultToStar = 0x4,
|
||||
Init_DefaultToFolder = 0x8,
|
||||
NoUserSettings = 0x10,
|
||||
NoTruncate = 0x20,
|
||||
Verify = 0x40,
|
||||
RemapRunDll = 0x80,
|
||||
NoFixUps = 0x100,
|
||||
IgnoreBaseClass = 0x200
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DDE Commands
|
||||
/// </summary>
|
||||
public enum AssocStr : ushort
|
||||
{
|
||||
Command = 1,
|
||||
Executable,
|
||||
FriendlyDocName,
|
||||
FriendlyAppName,
|
||||
NoOpen,
|
||||
ShellNewValue,
|
||||
DDECommand,
|
||||
DDEIfExec,
|
||||
DDEApplication,
|
||||
DDETopic
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For Process DEP
|
||||
/// </summary>
|
||||
public enum DEP : int
|
||||
{
|
||||
PROCESS_DEP_DISABLE = 0x00000000,
|
||||
PROCESS_DEP_ENABLE = 0x00000001,
|
||||
PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION = 0x00000002,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Layered Windows
|
||||
/// </summary>
|
||||
public enum LayeredWindowAttribute_Value : int
|
||||
{
|
||||
LWA_COLORKEY = 0x00000001,
|
||||
LWA_ALPHA = 0x00000002
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mouse Events
|
||||
/// </summary>
|
||||
public enum MouseEvent : ushort
|
||||
{
|
||||
MOUSEEVENTF_LEFTDOWN = 0x02,
|
||||
MOUSEEVENTF_LEFTUP = 0x04,
|
||||
MOUSEEVENTF_RIGHTDOWN = 0x08,
|
||||
MOUSEEVENTF_RIGHTUP = 0x10
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OpenProcess Values
|
||||
/// </summary>
|
||||
public enum OpenProcess_Value : int
|
||||
{
|
||||
DELETE = 0x00010000,
|
||||
READ_CONTROL = 0x00020000,
|
||||
SYNCHRONIZE = 0x00100000,
|
||||
WRITE_DAC = 0x00040000,
|
||||
WRITE_OWNER = 0x00080000
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scrollbar values
|
||||
/// </summary>
|
||||
public enum ScrollBar_Value : int
|
||||
{
|
||||
SB_HORZ = 0,
|
||||
SB_VERT = 1,
|
||||
SB_CTL = 2,
|
||||
SB_BOTH = 3,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set Window Pos Actions
|
||||
/// </summary>
|
||||
public enum SetWindowPos_Action : uint
|
||||
{
|
||||
SWP_NOSIZE = 0x0001,
|
||||
SWP_NOMOVE = 0x0002,
|
||||
SWP_NOZORDER = 0x0004,
|
||||
SWP_NOREDRAW = 0x0008,
|
||||
SWP_NOACTIVATE = 0x0010,
|
||||
SWP_FRAMECHANGED = 0x0020,
|
||||
SWP_SHOWWINDOW = 0x0040,
|
||||
SWP_HIDEWINDOW = 0x0080,
|
||||
SWP_NOCOPYBITS = 0x0100,
|
||||
SWP_NOOWNERZORDER = 0x0200,
|
||||
SWP_NOSENDCHANGING = 0x0400,
|
||||
SWP_DRAWFRAME = SWP_FRAMECHANGED,
|
||||
SWP_NOREPOSITION = SWP_NOOWNERZORDER
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show Window Actions
|
||||
/// </summary>
|
||||
public enum ShowWindow_Action : int
|
||||
{
|
||||
SW_HIDE = 0,
|
||||
SW_SHOWNORMAL = 1,
|
||||
SW_NORMAL = 1,
|
||||
SW_SHOWMINIMIZED = 2,
|
||||
SW_SHOWMAXIMIZED = 3,
|
||||
SW_MAXIMIZE = 3,
|
||||
SW_SHOWNOACTIVATE = 4,
|
||||
SW_SHOW = 5,
|
||||
SW_MINIMIZE = 6,
|
||||
SW_SHOWMINNOACTIVE = 7,
|
||||
SW_SHOWNA = 8,
|
||||
SW_RESTORE = 9,
|
||||
SW_SHOWDEFAULT = 10,
|
||||
SW_FORCEMINIMIZE = 11,
|
||||
SW_MAX = 11
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// System Metrix
|
||||
/// </summary>
|
||||
public enum SystemMetric_Value : int
|
||||
{
|
||||
SM_CXSCREEN = 0,
|
||||
SM_CYSCREEN = 1,
|
||||
SM_CXVSCROLL = 2,
|
||||
SM_CYHSCROLL = 3,
|
||||
SM_CYCAPTION = 4,
|
||||
SM_CXBORDER = 5,
|
||||
SM_CYBORDER = 6,
|
||||
SM_CXDLGFRAME = 7,
|
||||
SM_CYDLGFRAME = 8,
|
||||
SM_CYVTHUMB = 9,
|
||||
SM_CXHTHUMB = 10,
|
||||
SM_CXICON = 11,
|
||||
SM_CYICON = 12,
|
||||
SM_CXCURSOR = 13,
|
||||
SM_CYCURSOR = 14,
|
||||
SM_CYMENU = 15,
|
||||
SM_CXFULLSCREEN = 16,
|
||||
SM_CYFULLSCREEN = 17,
|
||||
SM_CYKANJIWINDOW = 18,
|
||||
SM_MOUSEPRESENT = 19,
|
||||
SM_CYVSCROLL = 20,
|
||||
SM_CXHSCROLL = 21,
|
||||
SM_DEBUG = 22,
|
||||
SM_SWAPBUTTON = 23,
|
||||
SM_RESERVED1 = 24,
|
||||
SM_RESERVED2 = 25,
|
||||
SM_RESERVED3 = 26,
|
||||
SM_RESERVED4 = 27,
|
||||
SM_CXMIN = 28,
|
||||
SM_CYMIN = 29,
|
||||
SM_CXSIZE = 30,
|
||||
SM_CYSIZE = 31,
|
||||
SM_CXFRAME = 32,
|
||||
SM_CYFRAME = 33,
|
||||
SM_CXMINTRACK = 34,
|
||||
SM_CYMINTRACK = 35,
|
||||
SM_CXDOUBLECLK = 36,
|
||||
SM_CYDOUBLECLK = 37,
|
||||
SM_CXICONSPACING = 38,
|
||||
SM_CYICONSPACING = 39,
|
||||
SM_MENUDROPALIGNMENT = 40,
|
||||
SM_PENWINDOWS = 41,
|
||||
SM_DBCSENABLED = 42,
|
||||
SM_CMOUSEBUTTONS = 43
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GetWindowLong Values
|
||||
/// </summary>
|
||||
public enum WindowLong_Value : int
|
||||
{
|
||||
GWL_EXSTYLE = -20,
|
||||
GWL_STYLE = -16,
|
||||
GWL_WNDPROC = -4,
|
||||
GWL_HINSTANCE = -6,
|
||||
GWL_ID = -12,
|
||||
GWL_USERDATA = -21,
|
||||
DWL_DLGPROC = 4,
|
||||
DWL_MSGRESULT = 0,
|
||||
DWL_USER = 8
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Window Positions
|
||||
/// </summary>
|
||||
public enum WindowPos_Value : int
|
||||
{
|
||||
HWND_TOP = 0,
|
||||
HWND_BOTTOM = 1,
|
||||
HWND_TOPMOST = -1,
|
||||
HWND_NOTOPMOST = -2
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Windows Styles
|
||||
/// </summary>
|
||||
public enum WindowStyle_Value : uint
|
||||
{
|
||||
WS_MAXIMIZE = 0x01000000,
|
||||
WS_VISIBLE = 0x10000000,
|
||||
WS_POPUP = 0x80000000,
|
||||
WS_BORDER = 0x00800000,
|
||||
WS_CAPTION = 0x00C00000,
|
||||
WS_CHILD = 0x40000000,
|
||||
WS_CHILDWINDOW = 0x40000000,
|
||||
WS_EX_CLIENTEDGE = 0x00000200,
|
||||
WS_CLIPCHILDREN = 0x02000000,
|
||||
WS_CLIPSIBLINGS = 0x04000000,
|
||||
WS_DISABLED = 0x08000000,
|
||||
WS_DLGFRAME = 0x00400000,
|
||||
WS_GROUP = 0x00020000,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Windows Messages
|
||||
/// </summary>
|
||||
public enum WM : int
|
||||
{
|
||||
WM_NULL = 0x0000,
|
||||
WM_CREATE = 0x0001,
|
||||
WM_DESTROY = 0x0002,
|
||||
WM_MOVE = 0x0003,
|
||||
WM_SIZE = 0x0005,
|
||||
WM_ACTIVATE = 0x0006,
|
||||
WM_SETFOCUS = 0x0007,
|
||||
WM_KILLFOCUS = 0x0008,
|
||||
WM_ENABLE = 0x000A,
|
||||
WM_SETREDRAW = 0x000B,
|
||||
WM_SETTEXT = 0x000C,
|
||||
WM_GETTEXT = 0x000D,
|
||||
WM_GETTEXTLENGTH = 0x000E,
|
||||
WM_PAINT = 0x000F,
|
||||
WM_CLOSE = 0x0010,
|
||||
WM_QUERYENDSESSION = 0x0011,
|
||||
WM_QUIT = 0x0012,
|
||||
WM_QUERYOPEN = 0x0013,
|
||||
WM_ERASEBKGND = 0x0014,
|
||||
WM_SYSCOLORCHANGE = 0x0015,
|
||||
WM_ENDSESSION = 0x0016,
|
||||
WM_SHOWWINDOW = 0x0018,
|
||||
WM_CTLCOLOR = 0x0019,
|
||||
WM_WININICHANGE = 0x001A,
|
||||
WM_SETTINGCHANGE = 0x001A,
|
||||
WM_DEVMODECHANGE = 0x001B,
|
||||
WM_ACTIVATEAPP = 0x001C,
|
||||
WM_FONTCHANGE = 0x001D,
|
||||
WM_TIMECHANGE = 0x001E,
|
||||
WM_CANCELMODE = 0x001F,
|
||||
WM_SETCURSOR = 0x0020,
|
||||
WM_MOUSEACTIVATE = 0x0021,
|
||||
WM_CHILDACTIVATE = 0x0022,
|
||||
WM_QUEUESYNC = 0x0023,
|
||||
WM_GETMINMAXINFO = 0x0024,
|
||||
WM_PAINTICON = 0x0026,
|
||||
WM_ICONERASEBKGND = 0x0027,
|
||||
WM_NEXTDLGCTL = 0x0028,
|
||||
WM_SPOOLERSTATUS = 0x002A,
|
||||
WM_DRAWITEM = 0x002B,
|
||||
WM_MEASUREITEM = 0x002C,
|
||||
WM_DELETEITEM = 0x002D,
|
||||
WM_VKEYTOITEM = 0x002E,
|
||||
WM_CHARTOITEM = 0x002F,
|
||||
WM_SETFONT = 0x0030,
|
||||
WM_GETFONT = 0x0031,
|
||||
WM_SETHOTKEY = 0x0032,
|
||||
WM_GETHOTKEY = 0x0033,
|
||||
WM_QUERYDRAGICON = 0x0037,
|
||||
WM_COMPAREITEM = 0x0039,
|
||||
WM_GETOBJECT = 0x003D,
|
||||
WM_COMPACTING = 0x0041,
|
||||
WM_COMMNOTIFY = 0x0044,
|
||||
WM_WINDOWPOSCHANGING = 0x0046,
|
||||
WM_WINDOWPOSCHANGED = 0x0047,
|
||||
WM_POWER = 0x0048,
|
||||
WM_COPYDATA = 0x004A,
|
||||
WM_CANCELJOURNAL = 0x004B,
|
||||
WM_NOTIFY = 0x004E,
|
||||
WM_INPUTLANGCHANGEREQUEST = 0x0050,
|
||||
WM_INPUTLANGCHANGE = 0x0051,
|
||||
WM_TCARD = 0x0052,
|
||||
WM_HELP = 0x0053,
|
||||
WM_USERCHANGED = 0x0054,
|
||||
WM_NOTIFYFORMAT = 0x0055,
|
||||
WM_CONTEXTMENU = 0x007B,
|
||||
WM_STYLECHANGING = 0x007C,
|
||||
WM_STYLECHANGED = 0x007D,
|
||||
WM_DISPLAYCHANGE = 0x007E,
|
||||
WM_GETICON = 0x007F,
|
||||
WM_SETICON = 0x0080,
|
||||
WM_NCCREATE = 0x0081,
|
||||
WM_NCDESTROY = 0x0082,
|
||||
WM_NCCALCSIZE = 0x0083,
|
||||
WM_NCHITTEST = 0x0084,
|
||||
WM_NCPAINT = 0x0085,
|
||||
WM_NCACTIVATE = 0x0086,
|
||||
WM_GETDLGCODE = 0x0087,
|
||||
WM_SYNCPAINT = 0x0088,
|
||||
WM_NCMOUSEMOVE = 0x00A0,
|
||||
WM_NCLBUTTONDOWN = 0x00A1,
|
||||
WM_NCLBUTTONUP = 0x00A2,
|
||||
WM_NCLBUTTONDBLCLK = 0x00A3,
|
||||
WM_NCRBUTTONDOWN = 0x00A4,
|
||||
WM_NCRBUTTONUP = 0x00A5,
|
||||
WM_NCRBUTTONDBLCLK = 0x00A6,
|
||||
WM_NCMBUTTONDOWN = 0x00A7,
|
||||
WM_NCMBUTTONUP = 0x00A8,
|
||||
WM_NCMBUTTONDBLCLK = 0x00A9,
|
||||
WM_KEYDOWN = 0x0100,
|
||||
WM_KEYUP = 0x0101,
|
||||
WM_CHAR = 0x0102,
|
||||
WM_DEADCHAR = 0x0103,
|
||||
WM_SYSKEYDOWN = 0x0104,
|
||||
WM_SYSKEYUP = 0x0105,
|
||||
WM_SYSCHAR = 0x0106,
|
||||
WM_SYSDEADCHAR = 0x0107,
|
||||
WM_KEYLAST = 0x0108,
|
||||
WM_IME_STARTCOMPOSITION = 0x010D,
|
||||
WM_IME_ENDCOMPOSITION = 0x010E,
|
||||
WM_IME_COMPOSITION = 0x010F,
|
||||
WM_IME_KEYLAST = 0x010F,
|
||||
WM_INITDIALOG = 0x0110,
|
||||
WM_COMMAND = 0x0111,
|
||||
WM_SYSCOMMAND = 0x0112,
|
||||
WM_TIMER = 0x0113,
|
||||
WM_HSCROLL = 0x0114,
|
||||
WM_VSCROLL = 0x0115,
|
||||
WM_INITMENU = 0x0116,
|
||||
WM_INITMENUPOPUP = 0x0117,
|
||||
WM_MENUSELECT = 0x011F,
|
||||
WM_MENUCHAR = 0x0120,
|
||||
WM_ENTERIDLE = 0x0121,
|
||||
WM_MENURBUTTONUP = 0x0122,
|
||||
WM_MENUDRAG = 0x0123,
|
||||
WM_MENUGETOBJECT = 0x0124,
|
||||
WM_UNINITMENUPOPUP = 0x0125,
|
||||
WM_MENUCOMMAND = 0x0126,
|
||||
WM_CTLCOLORMSGBOX = 0x0132,
|
||||
WM_CTLCOLOREDIT = 0x0133,
|
||||
WM_CTLCOLORLISTBOX = 0x0134,
|
||||
WM_CTLCOLORBTN = 0x0135,
|
||||
WM_CTLCOLORDLG = 0x0136,
|
||||
WM_CTLCOLORSCROLLBAR = 0x0137,
|
||||
WM_CTLCOLORSTATIC = 0x0138,
|
||||
WM_MOUSEMOVE = 0x0200,
|
||||
WM_LBUTTONDOWN = 0x0201,
|
||||
WM_LBUTTONUP = 0x0202,
|
||||
WM_LBUTTONDBLCLK = 0x0203,
|
||||
WM_RBUTTONDOWN = 0x0204,
|
||||
WM_RBUTTONUP = 0x0205,
|
||||
WM_RBUTTONDBLCLK = 0x0206,
|
||||
WM_MBUTTONDOWN = 0x0207,
|
||||
WM_MBUTTONUP = 0x0208,
|
||||
WM_MBUTTONDBLCLK = 0x0209,
|
||||
WM_MOUSEWHEEL = 0x020A,
|
||||
WM_XBUTTONDOWN = 0x020B,
|
||||
WM_XBUTTONUP = 0x020C,
|
||||
WM_XBUTTONDBLCLK = 0x020D,
|
||||
WM_PARENTNOTIFY = 0x0210,
|
||||
WM_ENTERMENULOOP = 0x0211,
|
||||
WM_EXITMENULOOP = 0x0212,
|
||||
WM_NEXTMENU = 0x0213,
|
||||
WM_SIZING = 0x0214,
|
||||
WM_CAPTURECHANGED = 0x0215,
|
||||
WM_MOVING = 0x0216,
|
||||
WM_DEVICECHANGE = 0x0219,
|
||||
WM_MDICREATE = 0x0220,
|
||||
WM_MDIDESTROY = 0x0221,
|
||||
WM_MDIACTIVATE = 0x0222,
|
||||
WM_MDIRESTORE = 0x0223,
|
||||
WM_MDINEXT = 0x0224,
|
||||
WM_MDIMAXIMIZE = 0x0225,
|
||||
WM_MDITILE = 0x0226,
|
||||
WM_MDICASCADE = 0x0227,
|
||||
WM_MDIICONARRANGE = 0x0228,
|
||||
WM_MDIGETACTIVE = 0x0229,
|
||||
WM_MDISETMENU = 0x0230,
|
||||
WM_ENTERSIZEMOVE = 0x0231,
|
||||
WM_EXITSIZEMOVE = 0x0232,
|
||||
WM_DROPFILES = 0x0233,
|
||||
WM_MDIREFRESHMENU = 0x0234,
|
||||
WM_IME_SETCONTEXT = 0x0281,
|
||||
WM_IME_NOTIFY = 0x0282,
|
||||
WM_IME_CONTROL = 0x0283,
|
||||
WM_IME_COMPOSITIONFULL = 0x0284,
|
||||
WM_IME_SELECT = 0x0285,
|
||||
WM_IME_CHAR = 0x0286,
|
||||
WM_IME_REQUEST = 0x0288,
|
||||
WM_IME_KEYDOWN = 0x0290,
|
||||
WM_IME_KEYUP = 0x0291,
|
||||
WM_MOUSEHOVER = 0x02A1,
|
||||
WM_MOUSELEAVE = 0x02A3,
|
||||
WM_CUT = 0x0300,
|
||||
WM_COPY = 0x0301,
|
||||
WM_PASTE = 0x0302,
|
||||
WM_CLEAR = 0x0303,
|
||||
WM_UNDO = 0x0304,
|
||||
WM_RENDERFORMAT = 0x0305,
|
||||
WM_RENDERALLFORMATS = 0x0306,
|
||||
WM_DESTROYCLIPBOARD = 0x0307,
|
||||
WM_DRAWCLIPBOARD = 0x0308,
|
||||
WM_PAINTCLIPBOARD = 0x0309,
|
||||
WM_VSCROLLCLIPBOARD = 0x030A,
|
||||
WM_SIZECLIPBOARD = 0x030B,
|
||||
WM_ASKCBFORMATNAME = 0x030C,
|
||||
WM_CHANGECBCHAIN = 0x030D,
|
||||
WM_HSCROLLCLIPBOARD = 0x030E,
|
||||
WM_QUERYNEWPALETTE = 0x030F,
|
||||
WM_PALETTEISCHANGING = 0x0310,
|
||||
WM_PALETTECHANGED = 0x0311,
|
||||
WM_HOTKEY = 0x0312,
|
||||
WM_PRINT = 0x0317,
|
||||
WM_PRINTCLIENT = 0x0318,
|
||||
WM_HANDHELDFIRST = 0x0358,
|
||||
WM_HANDHELDLAST = 0x035F,
|
||||
WM_AFXFIRST = 0x0360,
|
||||
WM_AFXLAST = 0x037F,
|
||||
WM_PENWINFIRST = 0x0380,
|
||||
WM_PENWINLAST = 0x038F,
|
||||
WM_APP = 0x8000,
|
||||
WM_USER = 0x0400,
|
||||
WM_REFLECT = WM_USER + 0x1c00,
|
||||
WM_CHANGEUISTATE = 0x0127,
|
||||
WM_UPDATEUISTATE = 0x0128,
|
||||
WM_QUERYUISTATE = 0x0129
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Virtual Keyboard Keys
|
||||
/// </summary>
|
||||
public enum VK : ushort
|
||||
{
|
||||
SHIFT = 0x10,
|
||||
CONTROL = 0x11,
|
||||
MENU = 0x12,
|
||||
ESCAPE = 0x1B,
|
||||
BACK = 0x08,
|
||||
TAB = 0x09,
|
||||
RETURN = 0x0D,
|
||||
SPACE = 0x20,
|
||||
PRIOR = 0x21,
|
||||
NEXT = 0x22,
|
||||
END = 0x23,
|
||||
HOME = 0x24,
|
||||
LEFT = 0x25,
|
||||
UP = 0x26,
|
||||
RIGHT = 0x27,
|
||||
DOWN = 0x28,
|
||||
SELECT = 0x29,
|
||||
PRINT = 0x2A,
|
||||
EXECUTE = 0x2B,
|
||||
SNAPSHOT = 0x2C,
|
||||
INSERT = 0x2D,
|
||||
DELETE = 0x2E,
|
||||
HELP = 0x2F,
|
||||
NUMPAD0 = 0x60,
|
||||
NUMPAD1 = 0x61,
|
||||
NUMPAD2 = 0x62,
|
||||
NUMPAD3 = 0x63,
|
||||
NUMPAD4 = 0x64,
|
||||
NUMPAD5 = 0x65,
|
||||
NUMPAD6 = 0x66,
|
||||
NUMPAD7 = 0x67,
|
||||
NUMPAD8 = 0x68,
|
||||
NUMPAD9 = 0x69,
|
||||
MULTIPLY = 0x6A,
|
||||
ADD = 0x6B,
|
||||
SEPARATOR = 0x6C,
|
||||
SUBTRACT = 0x6D,
|
||||
DECIMAL = 0x6E,
|
||||
DIVIDE = 0x6F,
|
||||
F1 = 0x70,
|
||||
F2 = 0x71,
|
||||
F3 = 0x72,
|
||||
F4 = 0x73,
|
||||
F5 = 0x74,
|
||||
F6 = 0x75,
|
||||
F7 = 0x76,
|
||||
F8 = 0x77,
|
||||
F9 = 0x78,
|
||||
F10 = 0x79,
|
||||
F11 = 0x7A,
|
||||
F12 = 0x7B,
|
||||
OEM_1 = 0xBA, // ',:' for US
|
||||
OEM_PLUS = 0xBB, // '+' any country
|
||||
OEM_COMMA = 0xBC, // ',' any country
|
||||
OEM_MINUS = 0xBD, // '-' any country
|
||||
OEM_PERIOD = 0xBE, // '.' any country
|
||||
OEM_2 = 0xBF, // '/?' for US
|
||||
OEM_3 = 0xC0, // '`~' for US
|
||||
MEDIA_NEXT_TRACK = 0xB0,
|
||||
MEDIA_PREV_TRACK = 0xB1,
|
||||
MEDIA_STOP = 0xB2,
|
||||
MEDIA_PLAY_PAUSE = 0xB3,
|
||||
LWIN = 0x5B,
|
||||
RWIN = 0x5C
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// enum to hold the possible connection states
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum ConnectionStatusEnum : int
|
||||
{
|
||||
INTERNET_CONNECTION_MODEM = 0x1,
|
||||
INTERNET_CONNECTION_LAN = 0x2,
|
||||
INTERNET_CONNECTION_PROXY = 0x4,
|
||||
INTERNET_RAS_INSTALLED = 0x10,
|
||||
INTERNET_CONNECTION_OFFLINE = 0x20,
|
||||
INTERNET_CONNECTION_CONFIGURED = 0x40
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
388
Win32/Functions.cs
Normal file
388
Win32/Functions.cs
Normal file
@@ -0,0 +1,388 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
using SysIO = System.IO;
|
||||
using Diag = System.Diagnostics;
|
||||
using Yaulw.Tools;
|
||||
|
||||
namespace Yaulw.Win32
|
||||
{
|
||||
/// <remarks>
|
||||
/// Common Win32 .Net Wrapper Functions around Win32 for easier consumption by C#
|
||||
/// </remarks>
|
||||
public static class Functions
|
||||
{
|
||||
#region Byte / Word
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Low word of the specified int
|
||||
/// </summary>
|
||||
/// <param name="n">int to retrieve low word from</param>
|
||||
/// <returns>low word of the int</returns>
|
||||
public static int LOWORD(int n) { return (n & 0xffff); }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Low byte of the specified int
|
||||
/// </summary>
|
||||
/// <param name="n">int to retrieve low byte from</param>
|
||||
/// <returns>low byte of the int</returns>
|
||||
public static int LOBYTE(int n) { return (n & 0xff); }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the High word of the specified int
|
||||
/// </summary>
|
||||
/// <param name="n">int to retrieve high word from</param>
|
||||
/// <returns>high word of the int</returns>
|
||||
public static int HIWORD(int n) { return ((n >> 16) & 0xffff); }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the High byte of the specified int
|
||||
/// </summary>
|
||||
/// <param name="n">int to retrieve high byte from</param>
|
||||
/// <returns>high byte of the int</returns>
|
||||
public static int HIBYTE(int n) { return ((n >> 8) & 0xff); }
|
||||
|
||||
#endregion
|
||||
|
||||
#region RGB
|
||||
|
||||
/// <summary>
|
||||
/// Win32 RGB
|
||||
/// </summary>
|
||||
/// <param name="r">red value as int</param>
|
||||
/// <param name="g">green value as int</param>
|
||||
/// <param name="b">blue value as int</param>
|
||||
/// <returns>returns a Win32 RGB Value as int</returns>
|
||||
public static int RGB(int r, int g, int b)
|
||||
{
|
||||
int rs = r & 0xffff;
|
||||
int gs = (g << 8) & 0xffff;
|
||||
int bs = (b << 16) & 0xffff;
|
||||
return (rs | gs | bs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the Red Value from Win32 RGB Value
|
||||
/// </summary>
|
||||
/// <param name="rgbDWORD"></param>
|
||||
/// <returns>returns Red value</returns>
|
||||
public static int GetRValue(int rgbDWORD)
|
||||
{
|
||||
return LOBYTE(rgbDWORD);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the Green Value from Win32 RGB Value
|
||||
/// </summary>
|
||||
/// <param name="rgbDWORD"></param>
|
||||
/// <returns>returns Green value</returns>
|
||||
public static int GetGValue(int rgbDWORD)
|
||||
{
|
||||
return (LOBYTE(rgbDWORD >> 8));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the Blue Value from Win32 RGB Value
|
||||
/// </summary>
|
||||
/// <param name="rgbDWORD"></param>
|
||||
/// <returns>returns Blue value</returns>
|
||||
public static int GetBValue(int rgbDWORD)
|
||||
{
|
||||
return (LOBYTE(rgbDWORD >> 16));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Keyboard Functionallity
|
||||
|
||||
/// <summary>
|
||||
/// Use this Function to determine whether the user is holding down a specified key
|
||||
/// </summary>
|
||||
/// <param name="vKey">VK such as Ctrl/Alt/Shift</param>
|
||||
/// <returns>true if pressed down, false otherwise</returns>
|
||||
public static bool IsKeyPressed(Definitions.VK vKey)
|
||||
{
|
||||
short retVal = User32.GetKeyState(vKey);
|
||||
return (retVal < 0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ClientRect Functionallity
|
||||
|
||||
/// <summary>
|
||||
/// Get a windows client rectangle
|
||||
/// </summary>
|
||||
/// <param name="hWnd">A Window Handle</param>
|
||||
/// <returns>A Rectangle</returns>
|
||||
public static Rectangle GetClientRect(IntPtr hWnd)
|
||||
{
|
||||
Structures.RECT rect = new Structures.RECT();
|
||||
User32.GetClientRect(hWnd, out rect);
|
||||
return Convert.RECTToRectangle(rect);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a windows rectangle
|
||||
/// </summary>
|
||||
/// <param name="hWnd">The Window handle</param>
|
||||
/// <returns>A Rectangle</returns>
|
||||
public static Rectangle GetWindowRect(IntPtr hWnd)
|
||||
{
|
||||
Structures.RECT rect = new Structures.RECT();
|
||||
User32.GetWindowRect(hWnd, out rect);
|
||||
return Convert.RECTToRectangle(rect);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Client Size, taking into account the Chrome width
|
||||
/// </summary>
|
||||
/// <param name="hWnd">A Window Handle</param>
|
||||
/// <returns>A Rectangle</returns>
|
||||
public static Rectangle GetAbsoluteClientRect(IntPtr hWnd)
|
||||
{
|
||||
Rectangle windowRect = GetWindowRect(hWnd);
|
||||
Rectangle clientRect = GetClientRect(hWnd);
|
||||
int chromeWidth = (int)((windowRect.Width - clientRect.Width) / 2);
|
||||
return new Rectangle(new Point(windowRect.X + chromeWidth, windowRect.Y + (windowRect.Height - clientRect.Height - chromeWidth)), clientRect.Size);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Window Functionallity
|
||||
|
||||
/// <summary>
|
||||
/// Use this to get the name of a Window Class
|
||||
/// </summary>
|
||||
/// <param name="hWnd">A Window Handle</param>
|
||||
/// <returns>The name of the Window Class</returns>
|
||||
public static string GetWindowClassName(IntPtr hWnd)
|
||||
{
|
||||
StringBuilder ClassName = new StringBuilder(100);
|
||||
int nRet = User32.GetClassName(hWnd, ClassName, ClassName.Capacity);
|
||||
return ClassName.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use this to get the text of a Window
|
||||
/// </summary>
|
||||
/// <param name="hWnd">A Window Handle</param>
|
||||
/// <returns>The window Text</returns>
|
||||
public static string GetWindowText(IntPtr hWnd)
|
||||
{
|
||||
int length = User32.GetWindowTextLength(hWnd);
|
||||
StringBuilder sb = new StringBuilder(length + 1);
|
||||
User32.GetWindowText(hWnd, sb, sb.Capacity);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the Window Text of a Dialog Item
|
||||
/// </summary>
|
||||
/// <param name="hDlg">handle to Dialog</param>
|
||||
/// <param name="nIDDlgItem">uint Dialog Item</param>
|
||||
/// <returns>Window Text from the Dialog Item</returns>
|
||||
public static string GetDlgItemText(IntPtr hDlg, int nIDDlgItem)
|
||||
{
|
||||
// Get the handle of the dialog item
|
||||
IntPtr hItem = User32.GetDlgItem(hDlg, nIDDlgItem);
|
||||
if (hItem == IntPtr.Zero)
|
||||
return String.Empty;
|
||||
|
||||
return GetWindowText(hItem);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use this to retrieve the Process Object for a specific Window Handle
|
||||
/// </summary>
|
||||
/// <param name="hWnd">A Window Handle</param>
|
||||
/// <returns>A valid Process object or Null if error occured</returns>
|
||||
public static System.Diagnostics.Process GetProcessFromWindowHandle(IntPtr hWnd)
|
||||
{
|
||||
int findPID = 0;
|
||||
User32.GetWindowThreadProcessId(hWnd, ref findPID);
|
||||
System.Diagnostics.Process process = null;
|
||||
try
|
||||
{
|
||||
if (findPID > 0)
|
||||
process = System.Diagnostics.Process.GetProcessById(findPID);
|
||||
}
|
||||
catch (ArgumentException) { /* ignore */ }
|
||||
return process;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Find the first top level window for the specified process
|
||||
/// </summary>
|
||||
/// <param name="pid">Process ID</param>
|
||||
/// <returns>the hWnd for the first Window of the specifed or IntPtr.Zero if none found</returns>
|
||||
public static IntPtr GetFirstTopLevelWindowForProcess(int pid)
|
||||
{
|
||||
IntPtr Result = IntPtr.Zero;
|
||||
|
||||
// Enumerate the top-level windows
|
||||
User32.EnumWindowsProc proc = delegate(IntPtr hWnd, IntPtr lParam)
|
||||
{
|
||||
// Find the first Window that belongs to the specified Process
|
||||
if (User32.IsWindowVisible(hWnd) && (pid == GetProcessFromWindowHandle(hWnd).Id))
|
||||
{
|
||||
Result = hWnd;
|
||||
return false;
|
||||
}
|
||||
return true; // Keep Looking
|
||||
};
|
||||
User32.EnumWindows(proc, IntPtr.Zero);
|
||||
|
||||
// yippie
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="pid"></param>
|
||||
/// <returns></returns>
|
||||
public static IntPtr GetTopLevelChildWindowForProcess(int pid)
|
||||
{
|
||||
// To Do
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Desktop Window Functionallity
|
||||
|
||||
/// <summary>
|
||||
/// Get's the Desktop Window as a Win32Window Object
|
||||
/// </summary>
|
||||
/// <returns>a Win32Window Object</returns>
|
||||
public static IWin32Window GetDestopWindow()
|
||||
{
|
||||
return Convert.ConverthWndToIWin32Window(User32.GetDesktopWindow());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes orphaned Icons in the Taskbar
|
||||
/// <seealso cref="http://stackoverflow.com/questions/74723/can-you-send-a-signal-to-windows-explorer-to-make-it-refresh-the-systray-icons"/>
|
||||
/// <seealso cref="http://malwareanalysis.com/CommunityServer/blogs/geffner/archive/2008/02/15/985.aspx"/>
|
||||
/// </summary>
|
||||
public static void RefreshTaskbarNotificationArea()
|
||||
{
|
||||
// Find the Notification Area
|
||||
IntPtr hNotificationArea = IntPtr.Zero;
|
||||
hNotificationArea = User32.FindWindowEx
|
||||
(User32.FW(User32.FW(User32.FW(IntPtr.Zero, "Shell_TrayWnd"), "TrayNotifyWnd"), "SysPager"),
|
||||
IntPtr.Zero,
|
||||
"ToolbarWindow32",
|
||||
"Notification Area");
|
||||
|
||||
if (hNotificationArea == IntPtr.Zero || !User32.IsWindow(hNotificationArea))
|
||||
return;
|
||||
|
||||
// Get the Client Rect of the Notification Area
|
||||
Structures.RECT r;
|
||||
User32.GetClientRect(hNotificationArea, out r);
|
||||
|
||||
// Send Mouse Messages to the Notification Area
|
||||
for (int x = 0; x < r.right; x += 5)
|
||||
for (int y = 0; y < r.bottom; y += 5)
|
||||
User32.SendMessage(hNotificationArea, (int) Definitions.WM.WM_MOUSEMOVE, (IntPtr) 0, (IntPtr) ((y << 16) + x));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Process Kernel Functionallity
|
||||
|
||||
// SetProcessDEPPolicy Helpers
|
||||
private delegate bool SetProcessDEPPolicy_Delegate(int dwFlags);
|
||||
private static SetProcessDEPPolicy_Delegate SetProcessPolicy = null;
|
||||
|
||||
/// <summary>
|
||||
/// Use SetProcessDEPPolicy to set the DEP Policy for the currently running
|
||||
/// Process. This function checks to make sure that kernel32 has the function,
|
||||
/// before calling it. For Windows Systems that don't have DEP.
|
||||
/// </summary>
|
||||
/// <param name="dep">the specified dep to set</param>
|
||||
/// <returns>the return value of the SetProcessDEPPolicy, or false if it doesn't exist</returns>
|
||||
public static bool SetProcessDEPPolicy(Definitions.DEP dep)
|
||||
{
|
||||
IntPtr hKernel32 = Kernel32.LoadLibrary("Kernel32.dll"); // Get the DLL
|
||||
if (hKernel32 != IntPtr.Zero)
|
||||
{
|
||||
IntPtr procaddr = IntPtr.Zero;
|
||||
procaddr = Kernel32.GetProcAddress(hKernel32, "SetProcessDEPPolicy"); // Get the Function
|
||||
if (procaddr != null)
|
||||
{
|
||||
// Cast the Delegate
|
||||
SetProcessPolicy = (SetProcessDEPPolicy_Delegate)Marshal.GetDelegateForFunctionPointer(procaddr, typeof(SetProcessDEPPolicy_Delegate));
|
||||
|
||||
// Call it * Disabling DEP *
|
||||
return SetProcessPolicy((int)dep);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Short / Long FileName N' Path Conversions
|
||||
|
||||
/// <summary>
|
||||
/// Converts a LongFileNameNPath (Modern Windows Path) into a ShortFileNPath (Old Dos 8.3)
|
||||
/// ~File Must exist on the system
|
||||
/// </summary>
|
||||
/// <param name="longFileNameNPath">Long (Modern Windows Path) FileNameNPath or Path</param>
|
||||
/// <returns>Old Dos 8.3 Path</returns>
|
||||
public static string GetShortFileNameNPathOrPath(string longFileNameNPathOrPath)
|
||||
{
|
||||
if (String.IsNullOrEmpty(longFileNameNPathOrPath))
|
||||
return String.Empty;
|
||||
|
||||
// File MUST exist on the system * Otherwise conversions will fail *
|
||||
if(PathNaming.PathContainsFile(longFileNameNPathOrPath) && !SysIO.File.Exists(longFileNameNPathOrPath))
|
||||
return String.Empty;
|
||||
|
||||
// Directory MUST exist on the system * Otherwise conversions will fail *
|
||||
if(!PathNaming.PathContainsFile(longFileNameNPathOrPath) && !SysIO.Directory.Exists(longFileNameNPathOrPath))
|
||||
return String.Empty;
|
||||
|
||||
if (String.IsNullOrEmpty(longFileNameNPathOrPath) || !SysIO.Directory.Exists(longFileNameNPathOrPath))
|
||||
return "";
|
||||
|
||||
StringBuilder sb = new StringBuilder(Definitions.MAX_PATH);
|
||||
Kernel32.GetShortPathName(longFileNameNPathOrPath, sb, sb.Capacity);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a ShortFileNameNPath (Old Dos 8.3) into a long (Modern Windows Path)
|
||||
/// ~File Must exist on the system
|
||||
/// </summary>
|
||||
/// <param name="shortFileNameNPathOrPath">Old Dos 8.3 FileNameNPath or Path</param>
|
||||
/// <returns>new Modern Windows Path</returns>
|
||||
public static string GetLongFileNameNPathOrPath(string shortFileNameNPathOrPath)
|
||||
{
|
||||
if (String.IsNullOrEmpty(shortFileNameNPathOrPath))
|
||||
return String.Empty;
|
||||
|
||||
// File MUST exist on the system * Otherwise conversions will fail *
|
||||
if (PathNaming.PathContainsFile(shortFileNameNPathOrPath) && !SysIO.File.Exists(shortFileNameNPathOrPath))
|
||||
return String.Empty;
|
||||
|
||||
// Directory MUST exist on the system * Otherwise conversions will fail *
|
||||
if (!PathNaming.PathContainsFile(shortFileNameNPathOrPath) && !SysIO.Directory.Exists(shortFileNameNPathOrPath))
|
||||
return String.Empty;
|
||||
|
||||
StringBuilder sb = new StringBuilder(Definitions.MAX_PATH);
|
||||
Kernel32.GetLongPathName(shortFileNameNPathOrPath, sb, sb.Capacity);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
85
Win32/Gdi32.cs
Normal file
85
Win32/Gdi32.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Yaulw.Win32
|
||||
{
|
||||
/// <remarks>
|
||||
/// Gdi32.dll Entry Points * http://pinvoke.net/ *
|
||||
/// </remarks>
|
||||
public static class Gdi32
|
||||
{
|
||||
/// <summary>
|
||||
/// The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from
|
||||
/// the specified source device context into a destination device context.
|
||||
/// </summary>
|
||||
/// <param name="hdcDest">A handle to the destination device context</param>
|
||||
/// <param name="xDest">The x-coordinate, in logical units, of the upper-left corner of the destination rectangle</param>
|
||||
/// <param name="yDest">The y-coordinate, in logical units, of the upper-left corner of the destination rectangle</param>
|
||||
/// <param name="wDest">he width, in logical units, of the source and destination rectangles</param>
|
||||
/// <param name="hDest">The height, in logical units, of the source and the destination rectangles</param>
|
||||
/// <param name="hdcSource">A handle to the source device context</param>
|
||||
/// <param name="xSrc">The x-coordinate, in logical units, of the upper-left corner of the source rectangle</param>
|
||||
/// <param name="ySrc">The y-coordinate, in logical units, of the upper-left corner of the source rectangle</param>
|
||||
/// <param name="RasterOp">A raster-operation code. These codes define how the color data for the source rectangle is to be combined with the color data for the destination rectangle to achieve the final color</param>
|
||||
/// <returns>If the function succeeds, the return value is nonzero</returns>
|
||||
[DllImport("gdi32.dll")]
|
||||
extern public static bool BitBlt(IntPtr hdcDest, int xDest, int yDest, int wDest, int hDest, IntPtr hdcSource, int xSrc, int ySrc, int RasterOp);
|
||||
|
||||
/// <summary>
|
||||
/// This function creates a bitmap compatible with the device associated with the specified device context
|
||||
/// </summary>
|
||||
/// <param name="hdc">Handle to a device context</param>
|
||||
/// <param name="nWidth">Specifies the bitmap width, in pixels</param>
|
||||
/// <param name="nHeight">Specifies the bitmap height, in pixels</param>
|
||||
/// <returns>A handle to the bitmap indicates success. NULL indicates failure.</returns>
|
||||
[DllImport("gdi32.dll")]
|
||||
extern public static IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight);
|
||||
|
||||
/// <summary>
|
||||
/// This function creates a memory device context (DC) compatible with the specified device
|
||||
/// </summary>
|
||||
/// <param name="hdc">Handle to an existing device context</param>
|
||||
/// <returns>The handle to a memory device context indicates success. NULL indicates failure.</returns>
|
||||
[DllImport("gdi32.dll")]
|
||||
extern public static IntPtr CreateCompatibleDC(IntPtr hdc);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="lpszDriver"></param>
|
||||
/// <param name="passNULL"></param>
|
||||
/// <param name="passNULL2"></param>
|
||||
/// <param name="passNULL3"></param>
|
||||
/// <returns></returns>
|
||||
[DllImport("gdi32.dll")]
|
||||
extern public static IntPtr CreateDC(string lpszDriver, IntPtr passNULL, IntPtr passNULL2, IntPtr passNULL3);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="hDc"></param>
|
||||
/// <returns></returns>
|
||||
[DllImport("gdi32.dll")]
|
||||
extern public static IntPtr DeleteDC(IntPtr hDc);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="hDc"></param>
|
||||
/// <returns></returns>
|
||||
[DllImport("gdi32.dll")]
|
||||
extern public static IntPtr DeleteObject(IntPtr hDc);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="hdc"></param>
|
||||
/// <param name="bmp"></param>
|
||||
/// <returns></returns>
|
||||
[DllImport("gdi32.dll")]
|
||||
extern public static IntPtr SelectObject(IntPtr hdc, IntPtr bmp);
|
||||
}
|
||||
}
|
||||
71
Win32/Kernel32.cs
Normal file
71
Win32/Kernel32.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Yaulw.Win32
|
||||
{
|
||||
/// <summary>
|
||||
/// Kernel32.dll Entry Points * http://pinvoke.net/ *
|
||||
/// </summary>
|
||||
public static class Kernel32
|
||||
{
|
||||
[DllImport("kernel32.dll")]
|
||||
extern public static bool AttachConsole(int dwProcessId);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
extern public static IntPtr CreateEvent(IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, [In] StringBuilder lpName);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
extern public static bool CloseHandle(IntPtr hHandle);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
extern public static bool FreeConsole();
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
extern public static int GetLastError();
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
extern public static uint GetPrivateProfileString(string lpAppName, string lpKeyName, string lpDefault, StringBuilder retVal, uint nSize, string lpFileName);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
extern public static IntPtr GetProcAddress(IntPtr hModule, String procname);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
extern public static int GetProcessId(IntPtr hProcess);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
extern public static uint GlobalAddAtom(string lpString);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
extern public static uint GlobalGetAtomName(uint nAtom, [Out] StringBuilder lpBuffer, int nSize);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
extern public static uint GlobalDeleteAtom(uint nAtom);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
extern public static IntPtr LoadLibrary(String dllname);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
extern public static IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
extern public static bool SetEvent(IntPtr hEvent);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
extern public static bool SetProcessDEPPolicy(int dwFlags);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
extern public static int WaitForSingleObject(IntPtr hHandle, uint dwMilliseconds);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
extern public static bool WritePrivateProfileString(string lpAppName, string lpKeyName, string lpString, string lpFileName);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
extern public static int GetShortPathName(string path, [Out] StringBuilder shortPath, int shortPathLength);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
extern public static int GetLongPathName(string path, [Out] StringBuilder longPath, int longPathLength);
|
||||
}
|
||||
}
|
||||
29
Win32/Shell32.cs
Normal file
29
Win32/Shell32.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Yaulw.Win32
|
||||
{
|
||||
/// <summary>
|
||||
/// Shell32.dll Entry Points * http://pinvoke.net/ *
|
||||
/// </summary>
|
||||
public static class Shell32
|
||||
{
|
||||
[DllImport("Shlwapi.dll")]
|
||||
extern public static uint AssocQueryString(Definitions.AssocF flags, Definitions.AssocStr str, string pszAssoc, string pszExtra, [Out] StringBuilder pszOut, [In][Out] ref uint pcchOut);
|
||||
|
||||
[DllImport("shell32.dll")]
|
||||
extern public static IntPtr FindExecutable(string lfFile, string lpDirectory, [Out] StringBuilder lpResult);
|
||||
|
||||
[DllImport("shell32.dll")]
|
||||
extern public static IntPtr ShellExecute(IntPtr hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd);
|
||||
|
||||
[DllImport("shell32.dll")]
|
||||
extern public static bool ShellExecuteEx(ref Structures.ShellExecuteInfo lpExecInfo);
|
||||
|
||||
[DllImport("shell32.dll")]
|
||||
extern public static long SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, int dwFlags, [Out] StringBuilder pszPath);
|
||||
}
|
||||
}
|
||||
166
Win32/Structures.cs
Normal file
166
Win32/Structures.cs
Normal file
@@ -0,0 +1,166 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Yaulw.Win32
|
||||
{
|
||||
/// <summary>
|
||||
/// Win32 Structs
|
||||
/// </summary>
|
||||
public static class Structures
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct RECT
|
||||
{
|
||||
public int left;
|
||||
public int top;
|
||||
public int right;
|
||||
public int bottom;
|
||||
public static RECT FromXYWH(int x, int y, int width, int height)
|
||||
{
|
||||
RECT rect = new RECT();
|
||||
rect.left = x;
|
||||
rect.top = y;
|
||||
rect.right = x + width;
|
||||
rect.bottom = y + height;
|
||||
return rect;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct SIZE
|
||||
{
|
||||
public int cx;
|
||||
public int cy;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct ShellExecuteInfo
|
||||
{
|
||||
public int cbSize;
|
||||
public uint fMask;
|
||||
public IntPtr hwnd;
|
||||
public string lpVerb;
|
||||
public string lpFile;
|
||||
public string lpParameters;
|
||||
public string lpDirectory;
|
||||
public uint nShow;
|
||||
public IntPtr hInstApp;
|
||||
public IntPtr lpIDList;
|
||||
public string lpClass;
|
||||
public IntPtr hkeyClass;
|
||||
public uint dwHotKey;
|
||||
public IntPtr hIcon_Monitor; // union DUMMYUNIONNAME
|
||||
public IntPtr hProcess;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 28)]
|
||||
public struct INPUT
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public uint type;
|
||||
[FieldOffset(4)]
|
||||
public KEYBDINPUT ki;
|
||||
};
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct KEYBDINPUT
|
||||
{
|
||||
public ushort wVk;
|
||||
public ushort wScan;
|
||||
public uint dwFlags;
|
||||
public long time;
|
||||
public uint dwExtraInfo;
|
||||
};
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct MONITORINFOEX
|
||||
{
|
||||
public int cbSize;
|
||||
public RECT rcMonitor;
|
||||
public RECT rcWork;
|
||||
public int dwFlags;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
|
||||
public string szDeviceName;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
public struct PAINTSTRUCT
|
||||
{
|
||||
public IntPtr hdc;
|
||||
public int fErase;
|
||||
public RECT rcPaint;
|
||||
public int fRestore;
|
||||
public int fIncUpdate;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
|
||||
public byte[] rgbReserved;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct NCCALCSIZE_PARAMS
|
||||
{
|
||||
public RECT rgrc0, rgrc1, rgrc2;
|
||||
public IntPtr lppos;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct SERVICE_STATUS_PROCESS
|
||||
{
|
||||
public int dwServiceType;
|
||||
public int dwCurrentState;
|
||||
public int dwControlsAccepted;
|
||||
public int dwWin32ExitCode;
|
||||
public int dwServiceSpecificExitCode;
|
||||
public int dwCheckPoint;
|
||||
public int dwWaitHint;
|
||||
public int dwProcessId;
|
||||
public int dwServiceFlags;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct FileDescriptorSet
|
||||
{
|
||||
// how many are set?
|
||||
public int Count;
|
||||
// an array of Socket handles
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MaxCount)]
|
||||
public IntPtr[] Array;
|
||||
|
||||
public static readonly int Size = Marshal.SizeOf(typeof(FileDescriptorSet));
|
||||
public static readonly FileDescriptorSet Empty = new FileDescriptorSet(0);
|
||||
public const int MaxCount = 64;
|
||||
|
||||
public FileDescriptorSet(int count)
|
||||
{
|
||||
Count = count;
|
||||
Array = count == 0 ? null : new IntPtr[MaxCount];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Structure used in select() call, taken from the BSD file sys/time.h.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct TimeValue
|
||||
{
|
||||
public int Seconds; // seconds
|
||||
public int Microseconds; // and microseconds
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct WSAData
|
||||
{
|
||||
public short wVersion;
|
||||
public short wHighVersion;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 257)]
|
||||
public string szDescription;
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 129)]
|
||||
public string szSystemStatus;
|
||||
public short iMaxSockets;
|
||||
public short iMaxUdpDg;
|
||||
public int lpVendorInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
187
Win32/User32.cs
Normal file
187
Win32/User32.cs
Normal file
@@ -0,0 +1,187 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Yaulw.Win32
|
||||
{
|
||||
/// <remark>
|
||||
/// User32.dll Entry Points * http://pinvoke.net/ *
|
||||
/// </remark>
|
||||
public static class User32
|
||||
{
|
||||
// Arg for SetWindowsHookEx()
|
||||
public delegate int WindowsHookProc(int nCode, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
// Arg for EnumWindows (EnumWindows Callback)
|
||||
public delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static IntPtr BeginPaint(IntPtr hWnd, ref Structures.PAINTSTRUCT paintStruct);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static int CallNextHookEx(int idHook, int nCode, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static bool EmptyClipboard();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static bool EndPaint(IntPtr hWnd, ref Structures.PAINTSTRUCT paintStruct);
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
extern public static bool EnumChildWindows(IntPtr hParent, Delegate lpEnumFunc, IntPtr lParam);
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
extern public static bool EnumWindows(Delegate lpEnumFunc, IntPtr lParam);
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
extern public static IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
|
||||
|
||||
/// <summary>
|
||||
/// Helper FindWindowEx Function * Useful *
|
||||
/// </summary>
|
||||
public static IntPtr FW(IntPtr hwndParent, string lpszClass)
|
||||
{
|
||||
return FindWindowEx(hwndParent, IntPtr.Zero, lpszClass, String.Empty);
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static bool GetClientRect(IntPtr hWnd, out Structures.RECT rect);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static int GetClipboardSequenceNumber();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static IntPtr GetDC(IntPtr ptr);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static IntPtr GetDCEx(IntPtr hWnd, IntPtr hrgnClip, int flags);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static IntPtr GetDesktopWindow();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static IntPtr GetDlgItem(IntPtr hDlg, int nIDDlgItem);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static uint GetDlgItemText(IntPtr hDlg, int nIDDlgItem, [Out] StringBuilder lpString, int nMaxCount);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static IntPtr GetFocus();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static IntPtr GetForegroundWindow();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static short GetKeyState(Definitions.VK vKey);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static bool GetMonitorInfo(IntPtr hMonitor, ref Structures.MONITORINFOEX monitorinfo);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static IntPtr GetParent(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static int GetSystemMetrics(int index);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static IntPtr GetTopWindow(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static IntPtr GetWindowDC(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static long GetWindowLong(IntPtr hWnd, int nIndex);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static bool GetWindowRect(IntPtr hWnd, out Structures.RECT rect);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static int GetWindowText(IntPtr hWnd, StringBuilder text, int count);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static int GetWindowTextLength(IntPtr hWnd);
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
extern public static int GetWindowThreadProcessId(IntPtr hWnd, ref int lpdwProcessId);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static IntPtr MonitorFromRect(ref Structures.RECT rect, int dwFlags);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static void mouse_event(Definitions.MouseEvent dwMouseEventFlags, long dx, long dy, long cButtons, long dwExtraInfo);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static bool IsWindow(IntPtr hwnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static bool IsWindowEnabled(IntPtr hwnd);
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
extern public static bool IsWindowVisible(IntPtr hwnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool LockWorkStation();
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
extern public static bool PostMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static uint RegisterWindowMessage(string lpString);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static bool ReleaseCapture();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDc);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static uint SendInput(uint nInputs, ref Structures.INPUT pInputs, int cbSize);
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
extern public static int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static IntPtr SetActiveWindow(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static IntPtr SetCapture(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static IntPtr SetFocus(IntPtr hwnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static int SetForegroundWindow(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static bool SetLayeredWindowAttributes(IntPtr hwnd, Int32 crKey, byte bAlpha, uint dwFlags);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static IntPtr SetParent(IntPtr child, IntPtr newParent);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static int SetWindowsHookEx(int idHook, WindowsHookProc lpfn, IntPtr hInstance, int threadId);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static long SetWindowLong(IntPtr hWnd, int nIndex, long dwNewLong);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static int ShowScrollBar(IntPtr hWnd, int wBar, int bShow);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static int ShowWindow(IntPtr hwnd, int nCmdShow);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
extern public static bool UnhookWindowsHookEx(int idHook);
|
||||
}
|
||||
}
|
||||
79
Win32/WSock32.cs
Normal file
79
Win32/WSock32.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Yaulw.Win32
|
||||
{
|
||||
/// <remarks>
|
||||
/// WSock32.dll Entry Points * http://pinvoke.net/ *
|
||||
/// </remarks>
|
||||
public static class WSock32
|
||||
{
|
||||
|
||||
[DllImport("wsock32.dll", CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true, SetLastError = true)]
|
||||
extern public static SocketError WSAStartup([In] short wVersionRequested, [Out] out Structures.WSAData lpWSAData);
|
||||
|
||||
[DllImport("wsock32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
|
||||
extern public static int WSACleanup();
|
||||
|
||||
[DllImport("wsock32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
|
||||
extern public static int select([In] int ignoredParameter,
|
||||
[In, Out] ref Structures.FileDescriptorSet readfds,
|
||||
[In, Out] ref Structures.FileDescriptorSet writefds,
|
||||
[In, Out] ref Structures.FileDescriptorSet exceptfds,
|
||||
[In] ref Structures.TimeValue timeout);
|
||||
|
||||
[DllImport("wsock32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
|
||||
extern public static int select([In] int ignoredParameter,
|
||||
[In, Out] ref Structures.FileDescriptorSet readfds,
|
||||
[In, Out] ref Structures.FileDescriptorSet writefds,
|
||||
[In, Out] ref Structures.FileDescriptorSet exceptfds,
|
||||
[In] IntPtr nullTimeout);
|
||||
|
||||
[DllImport("wsock32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
|
||||
extern public static int select([In] int ignoredParameter,
|
||||
[In, Out] ref Structures.FileDescriptorSet readfds,
|
||||
[In] IntPtr ignoredA,
|
||||
[In] IntPtr ignoredB,
|
||||
[In] ref Structures.TimeValue timeout);
|
||||
|
||||
[DllImport("wsock32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
|
||||
extern public static int select([In] int ignoredParameter,
|
||||
[In, Out] ref Structures.FileDescriptorSet readfds,
|
||||
[In] IntPtr ignoredA,
|
||||
[In] IntPtr ignoredB,
|
||||
[In] IntPtr nullTimeout);
|
||||
|
||||
[DllImport("wsock32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
|
||||
extern public static int select([In] int ignoredParameter,
|
||||
[In] IntPtr ignoredA,
|
||||
[In, Out] ref Structures.FileDescriptorSet writefds,
|
||||
[In] IntPtr ignoredB,
|
||||
[In] ref Structures.TimeValue timeout);
|
||||
|
||||
[DllImport("wsock32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
|
||||
extern public static int select([In] int ignoredParameter,
|
||||
[In] IntPtr ignoredA,
|
||||
[In, Out] ref Structures.FileDescriptorSet writefds,
|
||||
[In] IntPtr ignoredB,
|
||||
[In] IntPtr nullTimeout);
|
||||
|
||||
[DllImport("wsock32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
|
||||
extern public static int select([In] int ignoredParameter,
|
||||
[In] IntPtr ignoredA,
|
||||
[In] IntPtr ignoredB,
|
||||
[In, Out] ref Structures.FileDescriptorSet exceptfds,
|
||||
[In] ref Structures.TimeValue timeout);
|
||||
|
||||
[DllImport("wsock32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
|
||||
extern public static int select([In] int ignoredParameter,
|
||||
[In] IntPtr ignoredA,
|
||||
[In] IntPtr ignoredB,
|
||||
[In, Out] ref Structures.FileDescriptorSet exceptfds,
|
||||
[In] IntPtr nullTimeout);
|
||||
|
||||
}
|
||||
}
|
||||
19
Win32/Wininet.cs
Normal file
19
Win32/Wininet.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Yaulw.Win32
|
||||
{
|
||||
/// <remark>
|
||||
/// User32.dll Entry Points * http://pinvoke.net/ *
|
||||
/// </remark>
|
||||
public static class Wininet
|
||||
{
|
||||
[DllImport("wininet", CharSet = CharSet.Auto)]
|
||||
extern public static bool InternetGetConnectedState(ref Definitions.ConnectionStatusEnum flags, int dw);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
29
Win32/uxDwm.cs
Normal file
29
Win32/uxDwm.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Yaulw.Win32
|
||||
{
|
||||
/// <remarks>
|
||||
/// uxTheme.dll and dwmapi.dll Entry Points * http://pinvoke.net/ *
|
||||
/// </remarks>
|
||||
public static class uxDwm
|
||||
{
|
||||
/// <summary>
|
||||
/// Obtains a value that indicates whether Desktop Window Manager (DWM) composition is enabled
|
||||
/// </summary>
|
||||
/// <param name="pfEnabled">TRUE if DWM composition is enabled; otherwise, FALSE</param>
|
||||
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code</returns>
|
||||
[DllImport("dwmapi.dll")]
|
||||
extern public static long DwmIsCompositionEnabled(ref bool pfEnabled);
|
||||
|
||||
/// <summary>
|
||||
/// Reports whether the current application's user interface displays using visual styles
|
||||
/// </summary>
|
||||
/// <returns>TRUE, if the application has a visual style applied. FALSE otherwise</returns>
|
||||
[DllImport("uxTheme.dll")]
|
||||
extern public static bool IsAppThemed();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user