本文整理汇总了C#中System.UIntPtr.ToUInt32方法的典型用法代码示例。如果您正苦于以下问题:C# UIntPtr.ToUInt32方法的具体用法?C# UIntPtr.ToUInt32怎么用?C# UIntPtr.ToUInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.UIntPtr
的用法示例。
在下文中一共展示了UIntPtr.ToUInt32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LowLevelKeyboardProc
private IntPtr LowLevelKeyboardProc(int nCode, UIntPtr wParam, IntPtr lParam)
{
if (nCode >= 0)
if (wParam.ToUInt32() == (int)InterceptKeys.KeyEvent.WM_KEYDOWN ||
wParam.ToUInt32() == (int)InterceptKeys.KeyEvent.WM_KEYUP ||
wParam.ToUInt32() == (int)InterceptKeys.KeyEvent.WM_SYSKEYDOWN ||
wParam.ToUInt32() == (int)InterceptKeys.KeyEvent.WM_SYSKEYUP)
_hookedKeyboardCallbackAsync.BeginInvoke((InterceptKeys.KeyEvent)wParam.ToUInt32(), Marshal.ReadInt32(lParam), null, null);
return InterceptKeys.CallNextHookEx(_hookId, nCode, wParam, lParam);
}
示例2: ToStatus
public static StatusMode ToStatus(UIntPtr wParam)
{
if (!Enum.IsDefined(StatusEnumType, (int)wParam.ToUInt32()))
throw new ArgumentException("wParam", TextResources.ExceptionMsg_InvalidValueToTranslate);
return (StatusMode)(wParam);
}
示例3: KeyboardHook
public static UIntPtr KeyboardHook(int nCode, UIntPtr wParam, IntPtr lParam)
{
try
{
if (nCode == 0)
{
var wm = (WinAPI.WM)wParam.ToUInt32();
Mubox.WinAPI.WindowHook.KBDLLHOOKSTRUCT keyboardHookStruct = (Mubox.WinAPI.WindowHook.KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(Mubox.WinAPI.WindowHook.KBDLLHOOKSTRUCT));
if (OnKeyboardInputReceived(wm, keyboardHookStruct))
{
return new UIntPtr(1);
}
}
}
catch (Exception ex)
{
ex.Log();
}
try
{
return Mubox.WinAPI.WindowHook.CallNextHookEx(hHook, nCode, wParam, lParam);
}
catch (Exception ex)
{
ex.Log();
}
return new UIntPtr(1);
}
示例4: HookCallback
/// <include file='ManagedHooks.xml' path='Docs/KeyboardHook/HookCallback/*'/>
protected override void HookCallback(int code, UIntPtr wparam, IntPtr lparam)
{
if (KeyboardEvent == null)
{
return;
}
int vkCode = 0;
KeyboardEvents kEvent = (KeyboardEvents)wparam.ToUInt32();
if (kEvent != KeyboardEvents.KeyDown &&
kEvent != KeyboardEvents.KeyUp &&
kEvent != KeyboardEvents.SystemKeyDown &&
kEvent != KeyboardEvents.SystemKeyUp)
{
return;
}
GetKeyboardReading(wparam, lparam, ref vkCode);
VirtualKeys vk = (VirtualKeys)vkCode;
System.Windows.Forms.Keys key = ConvertKeyCode(vk);
if (key == System.Windows.Forms.Keys.Attn)
{
return;
}
KeyboardEvent(kEvent, key);
}
示例5: LowLevelKeyboardProc
private IntPtr LowLevelKeyboardProc(int nCode, UIntPtr wParam, IntPtr lParam)
{
bool continues = true;
if (nCode >= 0)
{
if (wParam.ToUInt32() == (int)KeyEvent.WM_KEYDOWN ||
wParam.ToUInt32() == (int)KeyEvent.WM_KEYUP ||
wParam.ToUInt32() == (int)KeyEvent.WM_SYSKEYDOWN ||
wParam.ToUInt32() == (int)KeyEvent.WM_SYSKEYUP)
{
if (hookedKeyboardCallback != null)
continues = hookedKeyboardCallback((KeyEvent)wParam.ToUInt32(), Marshal.ReadInt32(lParam), CheckModifiers());
}
}
if (continues)
{
return InterceptKeys.CallNextHookEx(hookId, nCode, wParam, lParam);
}
return (IntPtr)1;
}
示例6: InternalOnDataReceived
internal static void InternalOnDataReceived(
IntPtr room, IntPtr participant, IntPtr data, UIntPtr dataLength, bool isReliable,
IntPtr userData)
{
GooglePlayGames.OurUtils.Logger.d("Entering InternalOnDataReceived: " + userData.ToInt64());
var callback = Callbacks.IntPtrToPermanentCallback
<Action<NativeRealTimeRoom, MultiplayerParticipant, byte[], bool>>(userData);
using (var nativeRoom = NativeRealTimeRoom.FromPointer(room))
{
using (var nativeParticipant = MultiplayerParticipant.FromPointer(participant))
{
if (callback == null)
{
return;
}
byte[] convertedData = null;
if (dataLength.ToUInt64() != 0)
{
convertedData = new byte[dataLength.ToUInt32()];
Marshal.Copy(data, convertedData, 0, (int)dataLength.ToUInt32());
}
try
{
callback(nativeRoom, nativeParticipant, convertedData, isReliable);
}
catch (Exception e)
{
GooglePlayGames.OurUtils.Logger.e("Error encountered executing InternalOnDataReceived. " +
"Smothering to avoid passing exception into Native: " + e);
}
}
}
}
示例7: LowLevelKeyboardProc
private IntPtr LowLevelKeyboardProc(int nCode, UIntPtr wParam, IntPtr lParam)
{
string chars = "";
if (nCode >= 0)
if (wParam.ToUInt32() == (int)InterceptKeys.KeyEvent.WM_KEYDOWN ||
wParam.ToUInt32() == (int)InterceptKeys.KeyEvent.WM_KEYUP ||
wParam.ToUInt32() == (int)InterceptKeys.KeyEvent.WM_SYSKEYDOWN ||
wParam.ToUInt32() == (int)InterceptKeys.KeyEvent.WM_SYSKEYUP)
{
// Captures the character(s) pressed only on WM_KEYDOWN
chars = InterceptKeys.VKCodeToString((uint)Marshal.ReadInt32(lParam),
(wParam.ToUInt32() == (int)InterceptKeys.KeyEvent.WM_KEYDOWN ||
wParam.ToUInt32() == (int)InterceptKeys.KeyEvent.WM_SYSKEYDOWN));
hookedKeyboardCallbackAsync.BeginInvoke((InterceptKeys.KeyEvent)wParam.ToUInt32(), Marshal.ReadInt32(lParam), chars, null, null);
}
return InterceptKeys.CallNextHookEx(hookId, nCode, wParam, lParam);
}
示例8: GetCommandString
public void GetCommandString(
UIntPtr idCmd,
uint uFlags,
IntPtr pReserved,
StringBuilder pszName,
uint cchMax)
{
int index = Convert.ToInt32(idCmd.ToUInt32());
String[] texts = Constants.getLabels(currentActionDispacher.CurrentActions[index]);
// To change
switch ((GCS)uFlags)
{
case GCS.VERBW:
pszName.Clear();
pszName.Append(texts[1]);
break;
case GCS.HELPTEXTW:
pszName.Clear();
pszName.Append(texts[2]);
break;
}
}
示例9: MouseHook
public static UIntPtr MouseHook(int nCode, UIntPtr wParam, IntPtr lParam)
{
try
{
if (nCode == 0)
{
var wm = (WinAPI.WM)wParam.ToUInt32();
if (wm == WinAPI.WM.MOUSEMOVE)
{
if (DateTime.Now.Ticks <= _nextMouseMoveAccept)
{
// a.k.a not handled
return Mubox.WinAPI.WindowHook.CallNextHookEx(hHook, nCode, wParam, lParam);
}
_nextMouseMoveAccept = DateTime.Now.AddMilliseconds(50).Ticks; // 20fps - we limit this to ease off of network and cpu utilization for mousemove, the framerate choice here is arbitrary
}
Mubox.WinAPI.WindowHook.MSLLHOOKSTRUCT mouseHookStruct = (Mubox.WinAPI.WindowHook.MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(Mubox.WinAPI.WindowHook.MSLLHOOKSTRUCT));
if (OnMouseInputReceived(wm, mouseHookStruct))
{
return new UIntPtr(1); // handled
}
}
}
catch (Exception ex)
{
ex.Log();
}
try
{
return Mubox.WinAPI.WindowHook.CallNextHookEx(hHook, nCode, wParam, lParam);
}
catch (Exception ex)
{
ex.Log();
}
return UIntPtr.Zero;
}
示例10: HookCallback
/// <include file='ManagedHooks.xml' path='Docs/MouseHook/HookCallback/*'/>
protected override void HookCallback(int code, UIntPtr wparam, IntPtr lparam)
{
if (MouseEvent == null)
{
return;
}
int x = 0, y = 0;
MouseEvents mEvent = (MouseEvents)wparam.ToUInt32();
switch(mEvent)
{
case MouseEvents.LeftButtonDown:
GetMousePosition(wparam, lparam, ref x, ref y);
break;
case MouseEvents.LeftButtonUp:
GetMousePosition(wparam, lparam, ref x, ref y);
break;
case MouseEvents.MouseWheel:
break;
case MouseEvents.Move:
GetMousePosition(wparam, lparam, ref x, ref y);
break;
case MouseEvents.RightButtonDown:
GetMousePosition(wparam, lparam, ref x, ref y);
break;
case MouseEvents.RightButtonUp:
GetMousePosition(wparam, lparam, ref x, ref y);
break;
default:
//System.Diagnostics.Trace.WriteLine("Unrecognized mouse event");
break;
}
MouseEvent(mEvent, new Point(x, y));
}
示例11: LowLevelKeyboardProc
private IntPtr LowLevelKeyboardProc(int nCode, UIntPtr wParam, IntPtr lParam)
{
bool block = false;
if (nCode >= 0)
{
if (wParam.ToUInt32() == (int)KeyEvent.WM_KEYDOWN ||
wParam.ToUInt32() == (int)KeyEvent.WM_KEYUP ||
wParam.ToUInt32() == (int)KeyEvent.WM_SYSKEYDOWN ||
wParam.ToUInt32() == (int)KeyEvent.WM_SYSKEYUP)
{
_hookedKeyboardCallback((KeyEvent)wParam.ToUInt32(), Marshal.ReadInt32(lParam), ref block);
}
}
if (block)
{
return new IntPtr(-1);
}
return CallNextHookEx(_hookId, nCode, wParam, lParam);
}
示例12: LowLevelKeyboardProc
private IntPtr LowLevelKeyboardProc(int nCode, UIntPtr wParam, IntPtr lParam)
{
/* TODO: Change BeginInvoke to Invoke to block windows from handling things like the start key */
if (nCode >= 0)
if (wParam.ToUInt32() == (int)InterceptKeys.KeyEvent.WM_KEYDOWN ||
wParam.ToUInt32() == (int)InterceptKeys.KeyEvent.WM_KEYUP ||
wParam.ToUInt32() == (int)InterceptKeys.KeyEvent.WM_SYSKEYDOWN ||
wParam.ToUInt32() == (int)InterceptKeys.KeyEvent.WM_SYSKEYUP)
hookedKeyboardCallbackAsync.BeginInvoke((InterceptKeys.KeyEvent)wParam.ToUInt32(), Marshal.ReadInt32(lParam), null, null);
return InterceptKeys.CallNextHookEx(hookId, nCode, wParam, lParam);
}
示例13: Write
/// <summary>
/// Write
/// </summary>
/// <param name="dataBuffer">Data buffer</param>
/// <param name="numBytesToWrite">Number bytes to write</param>
/// <param name="numBytesWritten">Number bytes written</param>
/// <returns>A <see cref="FT_STATUS"/></returns>
public FT_STATUS Write(byte[] dataBuffer, int numBytesToWrite, ref uint numBytesWritten)
{
FT_STATUS status = FT_STATUS.FT_OTHER_ERROR;
UIntPtr written = new UIntPtr(0);
try { status = FT_Write(_currentHandle, dataBuffer, numBytesToWrite, out written); } catch { }
numBytesWritten = written.ToUInt32();
return status;
}
示例14: SetWindowLongPtr
public static IntPtr SetWindowLongPtr (HandleRef hWnd, int nIndex, UIntPtr dwNewLong) {
if (IntPtr.Size == 8)
return SetWindowLongPtr64(hWnd, nIndex, dwNewLong);
else
return new IntPtr(SetWindowLong32(hWnd, nIndex, dwNewLong.ToUInt32()));
}
示例15: Refresh
public void Refresh()
{
StringBuilder sb = new StringBuilder();
// get caption
sb.EnsureCapacity(10240);
bool WindowTimedOut = false;
UIntPtr lRes = new UIntPtr(1860);
int lResult = SendMessageTimeout(Handle, WM_GETTEXT, 10240, sb, SMTO_ABORTIFHUNG, 1000, out lRes);
if (lResult == 0)
{
Trace.TraceError("SendMessageTimeout() failed with {0}", Marshal.GetLastWin32Error());
WindowTimedOut = true;
Objects[(int)WindowItemTypes.Title] = "?";
}
else
{
//Trace.TraceInformation("lResult: {0}, lRes: {1}", lResult, lRes.ToUInt32());
Objects[(int)WindowItemTypes.Title] = sb.ToString();
}
// get class name
sb = new StringBuilder();
sb.EnsureCapacity(10240);
GetClassName(Handle, sb, 10240);
Objects[(int)WindowItemTypes.Class] = sb.ToString();
uint style = GetWindowLong(Handle, GWL_STYLE);
Objects[(int)WindowItemTypes.Style] = DecodeWindowStyle(style);
Objects[(int)WindowItemTypes.ExStyle] = GetWindowLong(Handle, GWL_EXSTYLE);
Objects[(int)WindowItemTypes.ID] = GetWindowLong(Handle, GWL_ID);
RECT r = new RECT();
GetWindowRect(Handle, ref r);
Objects[(int)WindowItemTypes.Size] = string.Format("({0}, {1})", r.Width, r.Height);
Objects[(int)WindowItemTypes.Position] = string.Format("({0}, {1})", r.Top, r.Left);
UIntPtr ProcessID = new UIntPtr(0);
uint ThreadID = GetWindowThreadProcessId(Handle, out ProcessID);
Objects[(int)WindowItemTypes.TID] = ThreadID;
Objects[(int)WindowItemTypes.PID] = ProcessID.ToUInt32();
ForegroundColor = Color.Black;
if ((r.Width == r.Height) && (r.Width == 0))
{
ForegroundColor = Color.Gray;
}
if ((style & WS_VISIBLE) == 0)
{
ForegroundColor = Color.Gray;
}
if (WindowTimedOut)
{
ForegroundColor = Color.Red;
}
}