public Main( RemoteHooking.IContext InContext, string serverName ) { mySendClientQueue = new Queue<Packet>(); mySendClientLock = new object(); mySendServerQueue = new Queue<Packet>(); mySendServerLock = new object(); myRecvFilter = new bool[256]; mySendFilter = new bool[256]; myRecvDelegate = new dSendRecv( ReceiveHook ); mySendDelegate = new dSendRecv( SendHook ); myPID = RemoteHooking.GetCurrentProcessId(); myThreadID = RemoteHooking.GetCurrentThreadId(); myDateStamp = GetDateStamp(); myServerSendBuffer = Marshal.AllocHGlobal( 65536 ); myClientSendBuffer = Marshal.AllocHGlobal( 65536 ); myServerBufferAddress = BitConverter.GetBytes( myServerSendBuffer.ToInt32() ); myClientBufferAddress = BitConverter.GetBytes( myClientSendBuffer.ToInt32() ); myClientInstance = new ClientInstance( serverName, true ); myClientInstance.SendCommand( Command.ClientID, myPID ); myClientInstance.SendPacketEvent += new dSendPacket( myClientInstance_sendPacketEvent ); myClientInstance.PingEvent += new dPing( myClientInstance_pingEvent ); myClientInstance.AddRecvFilterEvent += new dAddRecvFilter( myClientInstance_addRecvFilterEvent ); myClientInstance.AddSendFilterEvent += new dAddSendFilter( myClientInstance_addSendFilterEvent ); myClientInstance.RemoveRecvFilterEvent += new dRemoveRecvFilter( myClientInstance_removeRecvFilterEvent ); myClientInstance.RemoveSendFilterEvent += new dRemoveSendFilter( myClientInstance_removeSendFilterEvent ); myClientInstance.ClearRecvFilterEvent += new dClearRecvFilter( myClientInstance_clearRecvFilterEvent ); myClientInstance.ClearSendFilterEvent += new dClearSendFilter( myClientInstance_clearSendFilterEvent ); }
// This static method is required because legacy OSes do not support // SetWindowLongPtr internal static IntPtr SetWindowLongPtr(HandleRef hWnd, int nIndex, IntPtr dwNewLong) { if (IntPtr.Size == 8) return SetWindowLongPtr64(hWnd, nIndex, dwNewLong); else return new IntPtr(SetWindowLong32(hWnd, nIndex, dwNewLong.ToInt32())); }
private static int HookProcedureCallback(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0) { if (wParam.ToInt32() == (int)Native.Message.WM_LBUTTONDBLCLK && !IsReEnteredCallback()) { var handle = Process.GetCurrentProcess().MainWindowHandle; FindSlideViewWindowHandle(handle); if (IsMouseWithinSlideViewWindow() && DoubleClick != null) { DoubleClick(selectedRange); } } // Left mouse button up/released if (wParam.ToInt32() == (uint)Native.Message.WM_LBUTTONUP) { if (LeftButtonUp != null) { LeftButtonUp(); } } UpdateStartTime(); } return Native.CallNextHookEx(0, nCode, wParam, lParam); }
internal void OnCommand(IntPtr wParam) { if (((wParam.ToInt32() >> 16) & 0xffff) == SafeNativeMethods.THBN_CLICKED) { _thumbButtons[wParam.ToInt32() & 0xffff].OnClick(); } }
private void HandleMessage(IntPtr handle, int msg, IntPtr instance, IntPtr param1, IntPtr param2) { if(msg == MIM_OPEN) { } else if(msg == MIM_CLOSE) { } else if(msg == MIM_DATA) { delegateQueue.Post(HandleShortMessage, param1.ToInt32()); } else if(msg == MIM_MOREDATA) { delegateQueue.Post(HandleShortMessage, param1.ToInt32()); } else if(msg == MIM_LONGDATA) { delegateQueue.Post(HandleSysExMessage, param1); } else if(msg == MIM_ERROR) { delegateQueue.Post(HandleInvalidShortMessage, param1.ToInt32()); } else if(msg == MIM_LONGERROR) { delegateQueue.Post(HandleInvalidSysExMessage, param1); } }
public void H5Aget_nameTest1() { size_t buf_size = IntPtr.Zero; ssize_t size = IntPtr.Zero; hid_t att = H5A.create(m_v2_test_file, "H5Aget_name", H5T.IEEE_F64LE, m_space_scalar); Assert.IsTrue(att >= 0); // pretend we don't know the size size = H5A.get_name(att, buf_size, (StringBuilder)null); Assert.IsTrue(size.ToInt32() == 11); buf_size = new IntPtr(size.ToInt32() + 1); StringBuilder nameBuilder = new StringBuilder(buf_size.ToInt32()); size = H5A.get_name(att, buf_size, nameBuilder); Assert.IsTrue(size.ToInt32() == 11); string name = nameBuilder.ToString(); // names should match Assert.AreEqual("H5Aget_name", name); // read a truncated version buf_size = new IntPtr(3); nameBuilder = new StringBuilder(3); size = H5A.get_name(att, buf_size, nameBuilder); Assert.IsTrue(size.ToInt32() == 11); name = nameBuilder.ToString(); // names won't match Assert.AreNotEqual("H5Aget_name", name); Assert.AreEqual("H5", name); Assert.IsTrue(H5A.close(att) >= 0); }
public int HookProc(int nCode, IntPtr wParam, IntPtr lParam) { if (wParam.ToInt32() == Win32API.WM_KEYUP || wParam.ToInt32() == Win32API.WM_SYSKEYUP) { int vkCode = Marshal.ReadInt32(lParam); KeyboardHookStruct MyKeyboardHookStruct = (KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct)); Keys keyData = (Keys)MyKeyboardHookStruct.vkCode; //int check_i = 0; if (string.Format(keyData.ToString()) == "F12") { DateTime dt = DateTime.Now; string Time_name = dt.ToFileTime().ToString(); // 建立檔案串流(@ 可取消跳脫字元 escape sequence) StreamWriter sw = new StreamWriter(@"D:\" + Time_name + ".txt"); foreach (var aaa in listView1.Items) sw.WriteLine(aaa);// 寫入文字 sw.Close(); // 關閉串流 }else { listView1.Items.Add(string.Format(keyData.ToString())); } } return Win32API.CallNextHookEx(m_hookHandle, nCode, wParam, lParam); }
public void H5Pget_virtual_dsetnameTestVDS1() { hid_t vds = H5D.open(m_vds_class_file, "VDS"); Assert.IsTrue(vds >= 0); hid_t dcpl = H5D.get_create_plist(vds); Assert.IsTrue(dcpl >= 0); IntPtr count = IntPtr.Zero; Assert.IsTrue(H5P.get_virtual_count(dcpl, ref count) >= 0); Assert.IsTrue(3 == count.ToInt32()); string[] names = { "A", "B", "C" }; for (int i = 0; i < count.ToInt32(); ++i) { size_t index = new ssize_t(i); ssize_t len = H5P.get_virtual_filename(dcpl, index, null, IntPtr.Zero); Assert.IsTrue(len.ToInt32() > 0); StringBuilder name = new StringBuilder(len.ToInt32() + 1); len = H5P.get_virtual_dsetname(dcpl, index, name, len + 1); Assert.IsTrue(len.ToInt32() > 0); Assert.IsTrue(name.ToString() == names[i]); } Assert.IsTrue(H5P.close(dcpl) >= 0); Assert.IsTrue(H5D.close(vds) >= 0); }
public void H5Iget_nameTest1() { hid_t gid = H5G.create(m_v0_test_file, "AAAAAAAAAAAAAAAAAAAAA"); Assert.IsTrue(gid > 0); ssize_t buf_size = H5I.get_name(gid, (StringBuilder)null, IntPtr.Zero) + 1; Assert.IsTrue(buf_size.ToInt32() > 1); StringBuilder nameBuilder = new StringBuilder(buf_size.ToInt32()); IntPtr size = H5I.get_name(gid, nameBuilder, buf_size); Assert.IsTrue(size.ToInt32() > 0); Assert.IsTrue(nameBuilder.ToString() == "/AAAAAAAAAAAAAAAAAAAAA"); Assert.IsTrue(H5G.close(gid) >= 0); gid = H5G.create(m_v2_test_file, "AAAAAAAAAAAAAAAAAAAAA"); Assert.IsTrue(gid > 0); buf_size = H5I.get_name(gid, (StringBuilder)null, IntPtr.Zero) + 1; Assert.IsTrue(buf_size.ToInt32() > 1); nameBuilder = new StringBuilder(buf_size.ToInt32()); size = H5I.get_name(gid, nameBuilder, buf_size); Assert.IsTrue(size.ToInt32() > 0); Assert.IsTrue(nameBuilder.ToString() == "/AAAAAAAAAAAAAAAAAAAAA"); Assert.IsTrue(H5G.close(gid) >= 0); }
private unsafe void FileSystemEventCallback( FSEventStreamRef streamRef, IntPtr clientCallBackInfo, size_t numEvents, byte **eventPaths, FSEventStreamEventFlags *eventFlags, FSEventStreamEventId *eventIds) { // Try to get the actual watcher from our weak reference. We maintain a weak reference most of the time // so as to avoid a rooted cycle that would prevent our processing loop from ever ending // if the watcher is dropped by the user without being disposed. If we can't get the watcher, // there's nothing more to do (we can't raise events), so bail. FileSystemWatcher watcher; if (!_weakWatcher.TryGetTarget(out watcher)) { CancellationCallback(); return; } ExecutionContext context = _context; if (context is null) { // Flow suppressed, just run here ProcessEvents(numEvents.ToInt32(), eventPaths, new Span <FSEventStreamEventFlags>(eventFlags, numEvents.ToInt32()), new Span <FSEventStreamEventId>(eventIds, numEvents.ToInt32()), watcher); } else { ExecutionContext.Run( context, (object o) => ((RunningInstance)o).ProcessEvents(numEvents.ToInt32(), eventPaths, new Span <FSEventStreamEventFlags>(eventFlags, numEvents.ToInt32()), new Span <FSEventStreamEventId>(eventIds, numEvents.ToInt32()), watcher), this); } }
public void SetUpCodeCave() { CodeCaveHelper cv = new CodeCaveHelper(); //Let's get some space for our codecave origanGetNextPacket = memRead.GetCallFunction(Addresses.MyAddresses.GetnextPacket.Address); CodeCaveAdr = WinApi.VirtualAllocEx(TibiaHandle, IntPtr.Zero, 1024, WinApi.AllocationType.Commit | WinApi.AllocationType.Reserve, WinApi.MemoryProtection.ExecuteReadWrite); GotPacketAdr = WinApi.VirtualAllocEx(TibiaHandle, IntPtr.Zero, 1, WinApi.AllocationType.Commit | WinApi.AllocationType.Reserve, WinApi.MemoryProtection.ExecuteReadWrite); memRead.WriteByte(GotPacketAdr.ToInt32(), 0); cv.AddLine((byte)0xE8); cv.AddInt(((int)origanGetNextPacket - (CodeCaveAdr.ToInt32()) - 5)); // calls getnextPacket cv.AddLine((byte)0x8b, (byte)0xd8); // store eax cv.AddLine((byte)0xc7, (byte)0x05, (UInt32)GotPacketAdr.ToInt32(), (UInt32)0x00000001); //sets gotpacket to 1 cv.AddLine((byte)0x90); cv.AddLine((byte)0xA1, (UInt32)GotPacketAdr.ToInt32()); cv.AddLine((byte)0x83, (byte)0xF8, (byte)1); cv.AddLine((byte)0x74, (byte)0xF6); cv.AddLine((byte)0x8b, (byte)0xC3); cv.AddLine((byte)0xC3); System.Windows.Forms.Clipboard.SetText(CodeCaveAdr.ToString("X")); memRead.WriteBytes(CodeCaveAdr.ToInt32(), cv.Data, (uint)cv.Data.Length); Thread t = new Thread(new ThreadStart(ReadingPacket)); running = true; t.Start(); ReplaceCode(); }
private static IntPtr HookCallback(int code, IntPtr wParam, IntPtr lParam) { if (code == 0) { KeyboardDescription description = (KeyboardDescription)Marshal.PtrToStructure(lParam, typeof(KeyboardDescription)); bool isDown = false; if (wParam.ToInt32() == 0x100 || wParam.ToInt32() == 0x104) isDown = true; Keys keys = (Keys)description.KeyCode; if (isDown) { if (KeyDown != null) KeyDown(keys); } else { if (KeyUp != null) KeyUp(keys); } } return CallNextHookEx(hookHandle, code, wParam, lParam); }
public void ProcessWinMessage(int msg, IntPtr wParam, IntPtr lParam) { if (msg != 537) return; Console.WriteLine("UsbDetector\t:\tmsg = 0x{0} - wParam = 0x{1} - lParam = 0x{2}", (object)msg.ToString("X"), (object)wParam.ToInt32().ToString("X"), (object)lParam.ToInt32().ToString("X")); switch (wParam.ToInt32()) { case 24: Console.WriteLine("UsbDetector\t:Device config changed"); break; case 32768: Console.WriteLine("UsbDetector\t:Device arrival"); Console.WriteLine("DEVICE INTERFACE: Arrived"); this.OnStateChanged(this.GetDeviceName(lParam), DeviceState.Attached); break; case 32771: Console.WriteLine("UsbDetector\t:Device remove pending"); break; case 32772: Console.WriteLine("UsbDetector\t:Device remove complete"); Console.WriteLine("DEVICE INTERFACE: Removed"); this.OnStateChanged(this.GetDeviceName(lParam), DeviceState.Unattached); break; } }
public static int HiWord(IntPtr dWord) { if ((dWord.ToInt32() & 0x80000000) == 0x80000000) return (dWord.ToInt32() >> 16); else return (dWord.ToInt32() >> 16) & 0xffff; }
/// <summary> /// 解析。 /// </summary> /// <param name="message">メッセージ。</param> /// <param name="wparam">wparam。</param> /// <param name="lparam">lparam。</param> internal override void AnalyzeMessage(int message, IntPtr wparam, IntPtr lparam) { if (!HasFocus() || message != NativeCommonDefine.WM_COMMAND || ControlId != (wparam.ToInt32() & 0xFFFF)) { return; } switch ((int)(wparam.ToInt32() >> 16) & 0xFFFF) { case NativeComboBox.CBN_SELCHANGE: AddSentence(new TokenName(), ".EmulateSelectItem(" + NativeComboBox.GetCurSelInTarget(WindowHandle), new TokenAsync(CommaType.Before), ");"); break; case NativeComboBox.CBN_EDITCHANGE: if (!_isDropDownList) { string comboText = GetWindowText(); int curSel = NativeComboBox.GetCurSelInTarget(WindowHandle); if (curSel != -1) { string itemText = NativeComboBox.GetLBTextInTarget(WindowHandle, curSel); if (comboText == itemText) { return; } } AddSentence(new TokenName(), ".EmulateChangeEditText(" + NativeEditGenerator.AdjustText(comboText), new TokenAsync(CommaType.Before), ");"); } break; default: break; } }
public void H5RcreateTest4() { byte[] path = Encoding.UTF8.GetBytes(String.Join("/", m_utf8strings)); // make room for the trailling \0 byte[] name = new byte[path.Length + 1]; Array.Copy(path, name, path.Length); hsize_t[] dims = new hsize_t[] { 10, 20 }; hid_t space = H5S.create_simple(2, dims, null); Assert.IsTrue(space >= 0); hid_t dset = H5D.create(m_v2_test_file, name, H5T.STD_I32LE, space, m_lcpl_utf8); Assert.IsTrue(dset >= 0); hsize_t[] start = { 5, 10 }; hsize_t[] count = { 1, 1 }; hsize_t[] block = { 2, 4 }; Assert.IsTrue( H5S.select_hyperslab(space, H5S.seloper_t.SET, start, null, count, block) >= 0); byte[] refer = new byte[H5R.DSET_REG_REF_BUF_SIZE]; GCHandle hnd = GCHandle.Alloc(refer, GCHandleType.Pinned); Assert.IsTrue( H5R.create(hnd.AddrOfPinnedObject(), m_v2_test_file, name, H5R.type_t.DATASET_REGION, space) >= 0); ssize_t size = H5R.get_name(m_v2_test_file, H5R.type_t.DATASET_REGION, hnd.AddrOfPinnedObject(), (byte[])null, IntPtr.Zero); Assert.IsTrue(size.ToInt32() == name.Length); byte[] buf = new byte[size.ToInt32() + 1]; size = H5R.get_name(m_v2_test_file, H5R.type_t.DATASET_REGION, hnd.AddrOfPinnedObject(), buf, new IntPtr(buf.Length)); Assert.IsTrue(size.ToInt32() == name.Length); // we need to account for the leading "/", which was not included // in path for (int i = 0; i < name.Length; ++i) { Assert.IsTrue(name[i] == buf[i + 1]); } hid_t sel = H5R.get_region(dset, H5R.type_t.DATASET_REGION, hnd.AddrOfPinnedObject()); Assert.IsTrue(sel >= 0); hnd.Free(); Assert.IsTrue(H5S.extent_equal(space, sel) > 0); Assert.IsTrue(H5S.get_select_hyper_nblocks(space) == H5S.get_select_hyper_nblocks(sel)); Assert.IsTrue(H5S.close(sel) >= 0); Assert.IsTrue(H5D.close(dset) >= 0); Assert.IsTrue(H5S.close(space) >= 0); }
/// <summary> /// 解析。 /// </summary> /// <param name="message">メッセージ。</param> /// <param name="wparam">wparam。</param> /// <param name="lparam">lparam。</param> internal override void AnalyzeMessage(int message, IntPtr wparam, IntPtr lparam) { if (HasFocus() && message == NativeCommonDefine.WM_COMMAND && ControlId == (wparam.ToInt32() & 0xFFFF) && ((int)(wparam.ToInt32() >> 16) & 0xFFFF) == NativeEdit.EN_UPDATE) { AddSentence(new TokenName(), ".EmulateChangeText(" + AdjustText(GetWindowText()), new TokenAsync(CommaType.Before), ");"); } }
/// <summary> /// 解析。 /// </summary> /// <param name="message">メッセージ。</param> /// <param name="wparam">wparam。</param> /// <param name="lparam">lparam。</param> internal override void AnalyzeMessage(int message, IntPtr wparam, IntPtr lparam) { if (HasFocus() && message == NativeCommonDefine.WM_COMMAND && ControlId == (wparam.ToInt32() & 0xFFFF) && ((int)(wparam.ToInt32() >> 16) & 0xFFFF) == NativeListBox.LBN_SELCHANGE) { OnSelected(); } }
internal WindowHelper(string username) { FindWindow formfw = new FindWindow(new IntPtr(0), "StandardFrame", username + " - 客服工作台", 100); hwndwork = formfw.FoundHandle; dm.SetWindowState(hwndwork.ToInt32(), 8); dm.SetWindowState(hwndwork.ToInt32(), 1); FindWindow fw = new FindWindow(formfw.FoundHandle, "Internet Explorer_Server", "", 100); hwndworkmsg = fw.FoundHandle; FindWindow workeditfw = new FindWindow(formfw.FoundHandle, "RichEditComponent", "", 100); hwndworkedit = workeditfw.FoundHandle; }
internal static string IdToName (IntPtr id) { var dp = DependencyProperty.Lookup (id); if (dp != null) return dp.Name; if (Enum.IsDefined (typeof (WeakRefs), id.ToInt32 ())) return Enum.GetName (typeof (WeakRefs), id.ToInt32 ()); return "???"; }
public int HookProc(int nCode, IntPtr wParam, IntPtr lParam) { if (wParam.ToInt32() == Win32API.WM_KEYUP || wParam.ToInt32() == Win32API.WM_SYSKEYUP) { int vkCode = Marshal.ReadInt32(lParam); KeyboardHookStruct MyKeyboardHookStruct = (KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct)); Keys keyData = (Keys)MyKeyboardHookStruct.vkCode; listView1.Items.Add(string.Format("{0} {1} {2} {3}", nCode, wParam, lParam, keyData.ToString() )); } return Win32API.CallNextHookEx(m_hookHandle, nCode, wParam, lParam); }
public override IntPtr Read(IntPtr lpRes) { _strings = new Dictionary<string, StringResource>(); IntPtr pChild = base.Read(lpRes); while (pChild.ToInt32() < (lpRes.ToInt32() + _header.wLength)) { StringResource res = new StringResource(pChild); _strings.Add(res.Key, res); pChild = ResourceUtil.Align(pChild.ToInt32() + res.Header.wLength); } return new IntPtr(lpRes.ToInt32() + _header.wLength); }
public IntPtr IEFromhWnd(IntPtr hWnd) { if(!hWnd.Equals(0)) { if(!IsIEServerWindow(hWnd)) { // Get 1st child IE server window Win32.USER32.EnumChildProc myEnumChildProc = new Win32.USER32.EnumChildProc(EnumChild); Win32.USER32.EnumChildWindows(hWnd.ToInt32(), myEnumChildProc, hWnd.ToInt32()); } } return GhWnd; }
/// <summary> /// Read a string table. /// </summary> /// <param name="lpRes">Pointer to the beginning of the string table.</param> /// <returns>Pointer to the end of the string table.</returns> internal override IntPtr Read(IntPtr lpRes) { _strings.Clear(); IntPtr pChild = base.Read(lpRes); while (pChild.ToInt32() < (lpRes.ToInt32() + _header.wLength)) { StringTableEntry res = new StringTableEntry(pChild); _strings.Add(res.Key, res); pChild = ResourceUtil.Align(pChild.ToInt32() + res.Header.wLength); } return new IntPtr(lpRes.ToInt32() + _header.wLength); }
internal MouseHookEventArgs(IntPtr wparam, IntPtr lparam) { if (!Enum.IsDefined(typeof(MouseMessages), wparam.ToInt32())) message = MouseMessages.Unknown; else message = (MouseMessages)wparam.ToInt32(); MOUSEHOOKSTRUCT hs = (MOUSEHOOKSTRUCT)Marshal.PtrToStructure(lparam, typeof(MOUSEHOOKSTRUCT)); point = new Point(hs.pt.x, hs.pt.y); hwnd = hs.hwnd; hitTestCode = (HitTestCodes)hs.hitTestCode; extraInfo = hs.extraInfo; }
public override IntPtr Read(IntPtr lpRes) { _languages = new Dictionary<UInt16, UInt16>(); IntPtr pVar = base.Read(lpRes); while (pVar.ToInt32() < (lpRes.ToInt32() + _header.wLength)) { Kernel32.VAR_HEADER var = (Kernel32.VAR_HEADER) Marshal.PtrToStructure( pVar, typeof(Kernel32.VAR_HEADER)); _languages.Add(var.wLanguageIDMS, var.wCodePageIBM); pVar = new IntPtr(pVar.ToInt32() + Marshal.SizeOf(var)); } return new IntPtr(lpRes.ToInt32() + _header.wLength); }
private static bool HitCaptionTest(System.IntPtr hwnd, System.IntPtr lParam) { Window window = (Window)WinInterop.HwndSource.FromHwnd(hwnd).RootVisual; int x = lParam.ToInt32() << 16 >> 16, y = lParam.ToInt32() >> 16; var point = window.PointFromScreen(new Point(x, y)); if (point.Y > 24) { return(false); // Skip VisualTreeHelper.HitTest } var result = System.Windows.Media.VisualTreeHelper.HitTest(window, point); var textblock = result.VisualHit as TextBlock; return(textblock != null && textblock.Name == "PART_Titlelabel"); }
private static void ManageButtons(System.IntPtr device, System.IntPtr cookie, System.IntPtr value) { if (cookie.ToInt32() < 0 || cookie.ToInt32() > 19) { return; } Engine.Joystick joystick = GetJoystick(device); if (joystick == null) { return; } int buttonPressed = MacNative.IOHIDValueGetIntegerValue(value).ToInt32(); joystick.buttons [cookie.ToInt32()] = buttonPressed >= 1; }
public void H5Lget_name_by_idxTest2() { hid_t lcpl = H5P.copy(m_lcpl); Assert.IsTrue(lcpl >= 0); Assert.IsTrue(H5P.set_char_encoding(lcpl, H5T.cset_t.UTF8) >= 0); for (int i = 0; i < m_utf8strings.Length; ++i) { Assert.IsTrue( H5L.create_external(m_v0_class_file_name, "/", m_v0_class_file, m_utf8strings[i], lcpl) >= 0); } for (int i = 0; i < m_utf8strings.Length; ++i) { size_t buf_size = IntPtr.Zero; ssize_t size = H5L.get_name_by_idx(m_v0_test_file, ".", H5.index_t.NAME, H5.iter_order_t.NATIVE, (hsize_t)i, null, buf_size); buf_size = new IntPtr(size.ToInt32() + 1); StringBuilder nameBuilder = new StringBuilder(buf_size.ToInt32()); size = H5L.get_name_by_idx(m_v0_test_file, ".", H5.index_t.NAME, H5.iter_order_t.NATIVE, (hsize_t)i, nameBuilder, buf_size); } Assert.IsTrue(H5P.close(lcpl) >= 0); }
public void Lockdown() { //SendMessage(ValidHWND, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF); System.IntPtr intTemp = GetConsoleWindow(); PostMessage(intTemp.ToInt32(), WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF); LockWorkStation(); }
//--------------------------------------------------------------------------------------------------------------------------------------- // display windows dialog //--------------------------------------------------------------------------------------------------------------------------------------- private void displayDialog(System.IntPtr wndHandle, int dialogToShow) { // prep variables int i = -1; int iHandle = 0; // get parent handle if (wndHandle != System.IntPtr.Zero) { iHandle = wndHandle.ToInt32(); } // choose dialog to show bassed on if (dialogToShow == 1) { i = WNetConnectionDialog(iHandle, RESOURCETYPE_DISK); } else if (dialogToShow == 2) { i = WNetDisconnectDialog(iHandle, RESOURCETYPE_DISK); } // if error returned, throw if (i > 0) { throw new System.ComponentModel.Win32Exception(i); } }
public static System.Drawing.Color GetFirstColorHits(System.Drawing.Image image) { //TODO: Work over here - Not Ready System.Drawing.Color clrReturn = System.Drawing.Color.White; System.Collections.ArrayList arlColors = new System.Collections.ArrayList(); System.Collections.ArrayList arlColorsHits = new System.Collections.ArrayList(); System.Drawing.Bitmap bmp; System.Drawing.Imaging.BitmapData bmData; System.IntPtr ptr; int nOffSet, x, y, red, blue, green; bmp = (System.Drawing.Bitmap)image.Clone(); bmData = bmp.LockBits(new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format24bppRgb); ptr = bmData.Scan0; nOffSet = bmp.Height; for (y = 0; y < bmp.Height; y++) { for (x = 0; x < bmData.Width + 1; x++) { blue = System.Runtime.InteropServices.Marshal.ReadByte(ptr, 0); green = System.Runtime.InteropServices.Marshal.ReadByte(ptr, 1); red = System.Runtime.InteropServices.Marshal.ReadByte(ptr, 2); System.Drawing.Color clrCurrent = System.Drawing.Color.FromArgb(red, green, blue); IncreaseColorHits(ref arlColors, ref arlColorsHits, clrCurrent); ptr = new System.IntPtr(ptr.ToInt32() + 3); } ptr = bmData.Scan0; ptr = new System.IntPtr(ptr.ToInt32() + (bmData.Stride * y)); } ptr = new System.IntPtr(ptr.ToInt32() + nOffSet); bmp.UnlockBits(bmData); clrReturn = GetHigherColorHits(ref arlColors, ref arlColorsHits); return(clrReturn); }
/// <summary> /// 获取网卡地址的方法 /// </summary> /// <param name="NicId">网卡的ID ,形式如:{B50027F7-7A42-4F2D-8935-7620F1DB632F} 这样的字符串。</param> /// <returns></returns> public static string GetNicAddress(string NicId) { System.IntPtr hDevice = CreateFile("\\\\.\\" + NicId, 0x80000000 | 0x40000000, 0, IntPtr.Zero, 3, 4, IntPtr.Zero); if (hDevice.ToInt32() == -1) { return(null); } uint Len = 0; IntPtr Buffer = Marshal.AllocHGlobal(256); Marshal.WriteInt32(Buffer, 0x01010101); if (!DeviceIoControl(hDevice, 0x170002, Buffer, 4, Buffer, 256, ref Len, IntPtr.Zero)) { Marshal.FreeHGlobal(Buffer); CloseHandle(hDevice); return(null); } byte[] macBytes = new byte[6]; Marshal.Copy(Buffer, macBytes, 0, 6); Marshal.FreeHGlobal(Buffer); CloseHandle(hDevice); return(new System.Net.NetworkInformation.PhysicalAddress(macBytes).ToString()); }
public IOWatcher(IntPtr fd, EventTypes types, Loop loop, Action<IOWatcher, EventTypes> callback) : base(loop) { this.fd = fd; this.callback = callback; watcher_ptr = manos_io_watcher_create (fd.ToInt32 (), types, watcherCallback, GCHandle.ToIntPtr (gc_handle)); }
int HookCallbackProc(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode < 0) { return WinUtil.CallNextHookEx(m_hHook, nCode, wParam, lParam); } else { //Marshall the data from the callback. WinUtil.KeyboardHookStruct hookstruct = (WinUtil.KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(WinUtil.KeyboardHookStruct)); if (OnKeyDown != null && wParam.ToInt32() == WinUtil.WM_KEYDOWN) { Keys key = (Keys)hookstruct.vkCode; if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) key |= Keys.Shift; if ((Control.ModifierKeys & Keys.Control) == Keys.Control) key |= Keys.Control; KeyEventArgs e = new KeyEventArgs(key); e.Handled = false; OnKeyDown(e); if (e.Handled) return 1; } int result = 0; if (m_hHook != 0) result = WinUtil.CallNextHookEx(m_hHook, nCode, wParam, lParam); return result; } }
private IntPtr LowLevelKeyboardHookProc(int code, IntPtr wparam, IntPtr lparam) { if (code < 0) { return CallNextHookEx(mhhook, code, wparam, lparam); } else { var khs = (KeyboardHookStruct)Marshal.PtrToStructure(lparam, typeof(KeyboardHookStruct)); Debug.Print("Code-{0},WParam:{1},{2},{3},{4}", code, wparam, lparam, khs.VirtualKeyCode, khs.ScanCode, khs.Flags, khs.Time); MessageBox.Show(string.Format("Code-{0},WParam:{1},{2},{3},{4}", code, wparam, lparam, khs.VirtualKeyCode, khs.ScanCode, khs.Flags, khs.Time)); Debug.Print(khs.VirtualKeyCode.ToString()); MessageBox.Show(khs.VirtualKeyCode.ToString()); // alt tab if (khs.VirtualKeyCode == 9 && lparam.ToInt32() == 260 && khs.ScanCode == 15) { System.Console.WriteLine("Alt+Tab pressed!"); IntPtr val = new IntPtr(1); return val; } else { return CallNextHookEx(mhhook, code, wparam, lparam); } } }
public static void CloseFileDescriptor(IntPtr hFile) { if (RunningOnWindows) CloseHandle(hFile); else Close(hFile.ToInt32()); }
public static void SetRenderTextureWithDepth(System.IntPtr textureId, System.IntPtr depthId) { // We believe the id will not over 2^16. var combine = textureId.ToInt32() | (depthId.ToInt32() << 16); GL.IssuePluginEvent(SetRenderTextureHandlePtr, combine); }
public int Reconfigure(System.IntPtr pvContext, int dwFlags) { Debug.Assert(pvContext.ToInt32() == 7, "IGraphConfigCallback1"); Debug.Assert(dwFlags == 8, "IGraphConfigCallback2"); return(3); }
/// <summary> /// Sets the window long. /// </summary> /// <param name="hWnd">The h WND.</param> /// <param name="nIndex">Index of the n.</param> /// <param name="dwNewLong">The dw new long.</param> /// <returns>IntPtr.</returns> public static IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong) { if (IntPtr.Size == 8) return SetWindowLongPtr64(hWnd, nIndex, dwNewLong); else return new IntPtr(SetWindowLong32(hWnd, nIndex, dwNewLong.ToInt32())); }
public void GetMsg_GetMsg(IntPtr Handle, IntPtr Message, IntPtr wParam, IntPtr lParam) { if (count ++ < 10) "in GetMsg_GetMsg".info(); switch(Message.ToInt32()) { case win32.WM_CREATE: "(GetMsg_GetMsg) WM_CREATE".info(); break; case win32.WM_DESTROY: "(GetMsg_GetMsg) WM_DESTROY".info(); break; case win32.WM_MOVE: "(GetMsg_GetMsg) WM_MOVE".info(); break; case win32.WM_SIZE: "(GetMsg_GetMsg) WM_SIZE".info(); break; case win32.WM_ACTIVATE: "(GetMsg_GetMsg) WM_ACTIVATE".info(); break; case win32.WM_COMMAND: "(GetMsg_GetMsg) WM_COMMAND".info(); break; case win32.WM_SYSCOMMAND: "(GetMsg_GetMsg) WM_SYSCOMMAND".info(); break; case win32.WM_MENUCOMMAND: "(GetMsg_GetMsg) WM_MENUCOMMAND".info(); break; case win32.WM_MENUSELECT: "(GetMsg_GetMsg) WM_MENUSELECT".info(); break; } }
// returns true if event is handled private bool ProcessKeyPressInt(int nCode, IntPtr wParam, IntPtr lParam) { try { if (nCode < 0) return false; Func<Keys, bool> KeyPressed = LowLevelAdapter.KeyPressed; switch (wParam.ToInt32()) { case LowLevelAdapter.WM_KEYDOWN: case LowLevelAdapter.WM_SYSKEYDOWN: var keybdinput = (KEYBDINPUT)Marshal.PtrToStructure(lParam, typeof(KEYBDINPUT)); var keyData = (Keys)keybdinput.Vk; keyData |= KeyPressed(Keys.ControlKey) ? Keys.Control : 0; keyData |= KeyPressed(Keys.Menu) ? Keys.Alt : 0; keyData |= KeyPressed(Keys.ShiftKey) ? Keys.Shift : 0; var winPressed = KeyPressed(Keys.LWin) || KeyPressed(Keys.RWin); var args = new KeyboardEventArgs(keyData, winPressed); OnKeyboardEvent(args); return args.Handled; } } catch { } return false; }
public static void DrawToBitmap(IntPtr hWnd, Bitmap bmp) { if (!User32.IsWindow(hWnd)) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.Argument_InvalidHWnd, hWnd.ToInt32().ToString(CultureInfo.InvariantCulture))); } if (bmp == null) { throw new ArgumentNullException("bmp"); } using (Graphics g = Graphics.FromImage(bmp)) { IntPtr hDC = g.GetHdc(); User32.SendMessage( hWnd, WinUser.WM_PRINT, hDC, (IntPtr)(WinUser.PRF_CHILDREN | WinUser.PRF_CLIENT | WinUser.PRF_NONCLIENT | WinUser.PRF_ERASEBKGND) ); g.ReleaseHdc(hDC); } }
public static System.Drawing.Color GetFirstColor(System.Drawing.Image image) { if (image == null) { return(System.Drawing.Color.White); } System.Drawing.Color clrReturn = System.Drawing.Color.White; System.Drawing.Bitmap bmp; System.Drawing.Imaging.BitmapData bmData; System.IntPtr ptr; int nOffSet, x, y, red, blue, green; bmp = (System.Drawing.Bitmap)image.Clone(); bmData = bmp.LockBits(new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb); ptr = bmData.Scan0; nOffSet = bmp.Height; for (y = 0; y < 1; y++) { for (x = 0; x < 1; x++) { blue = System.Runtime.InteropServices.Marshal.ReadByte(ptr, 0); green = System.Runtime.InteropServices.Marshal.ReadByte(ptr, 1); red = System.Runtime.InteropServices.Marshal.ReadByte(ptr, 2); clrReturn = System.Drawing.Color.FromArgb(red, green, blue); ptr = new System.IntPtr(ptr.ToInt32() + 3); } ptr = bmData.Scan0; ptr = new System.IntPtr(ptr.ToInt32() + (bmData.Stride * y)); } ptr = new System.IntPtr(ptr.ToInt32() + nOffSet); bmp.UnlockBits(bmData); return(clrReturn); }
private IntPtr MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam) { IntPtr rv = IntPtr.Zero; MSLLHOOKSTRUCT mouseHookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT)); try { if (mouseHookStruct.IsInjected) { rv = User32.CallNextHookEx(hMouseHook, nCode, wParam, lParam); } else { if ((nCode >= 0) && (null != MouseEvent)) { MouseActivityArgs ma = MouseActivityArgs.CreateFromLowLevelHookProc(wParam.ToInt32(), mouseHookStruct); MouseEvent(ma); } rv = User32.CallNextHookEx(hMouseHook, nCode, wParam, lParam); } } catch (Exception e) { rv = User32.CallNextHookEx(hMouseHook, nCode, wParam, lParam); } return rv; }
public void H5Aget_name_by_idxTest1() { hid_t att = H5A.create(m_v2_test_file, "H5Aget_name", H5T.IEEE_F64LE, m_space_scalar); Assert.IsTrue(att >= 0); Assert.IsTrue(H5A.close(att) >= 0); att = H5A.create(m_v2_test_file, "H5Aget_name_by_idx", H5T.STD_I16LE, m_space_scalar); Assert.IsTrue(att >= 0); Assert.IsTrue(H5A.close(att) >= 0); size_t buf_size = IntPtr.Zero; ssize_t size = IntPtr.Zero; StringBuilder nameBuilder = new StringBuilder(19); buf_size = new IntPtr(19); size = H5A.get_name_by_idx(m_v2_test_file, ".", H5.index_t.NAME, H5.iter_order_t.NATIVE, 0, nameBuilder, buf_size); Assert.IsTrue(size.ToInt32() == 11); string name = nameBuilder.ToString(); // names should match Assert.AreEqual("H5Aget_name", name); nameBuilder.Clear(); size = H5A.get_name_by_idx(m_v2_test_file, ".", H5.index_t.NAME, H5.iter_order_t.NATIVE, 1, nameBuilder, buf_size); Assert.IsTrue(size.ToInt32() == 18); name = nameBuilder.ToString(); // names should match Assert.AreEqual("H5Aget_name_by_idx", name); // read a truncated version buf_size = new IntPtr(3); nameBuilder = new StringBuilder(3); size = H5A.get_name_by_idx(m_v2_test_file, ".", H5.index_t.NAME, H5.iter_order_t.NATIVE, 1, nameBuilder, buf_size); Assert.IsTrue(size.ToInt32() == 18); name = nameBuilder.ToString(); // names won't match Assert.AreNotEqual("H5Aget_name_by_idx", name); Assert.AreEqual("H5", name); }
/// <summary> /// 销毁对象 /// </summary> public virtual void Dispose() { if (intHandle.ToInt32() != 0) { DeleteObject(intHandle); intHandle = IntPtr.Zero; } }
public void H5Lget_name_by_idxTest1() { Assert.IsTrue( H5L.create_external(m_v0_class_file_name, "/", m_v0_test_file, "A", m_lcpl) >= 0); Assert.IsTrue( H5L.create_external(m_v0_class_file_name, "/", m_v0_test_file, "AB", m_lcpl) >= 0); Assert.IsTrue( H5L.create_external(m_v0_class_file_name, "/", m_v0_test_file, "ABC", m_lcpl) >= 0); size_t buf_size = IntPtr.Zero; ssize_t size = H5L.get_name_by_idx(m_v0_test_file, ".", H5.index_t.NAME, H5.iter_order_t.NATIVE, 1, null, buf_size); Assert.IsTrue(size.ToInt32() == 2); buf_size = new IntPtr(size.ToInt32() + 1); StringBuilder nameBuilder = new StringBuilder(buf_size.ToInt32()); size = H5L.get_name_by_idx(m_v0_test_file, ".", H5.index_t.NAME, H5.iter_order_t.NATIVE, 1, nameBuilder, buf_size); Assert.IsTrue(nameBuilder.ToString() == "AB"); Assert.IsTrue( H5L.create_external(m_v2_class_file_name, "/", m_v2_test_file, "A", m_lcpl) >= 0); Assert.IsTrue( H5L.create_external(m_v2_class_file_name, "/", m_v2_test_file, "AB", m_lcpl) >= 0); Assert.IsTrue( H5L.create_external(m_v2_class_file_name, "/", m_v2_test_file, "ABC", m_lcpl) >= 0); buf_size = IntPtr.Zero; size = H5L.get_name_by_idx(m_v2_test_file, ".", H5.index_t.NAME, H5.iter_order_t.NATIVE, 1, null, buf_size); Assert.IsTrue(size.ToInt32() == 2); buf_size = new IntPtr(size.ToInt32() + 1); nameBuilder = new StringBuilder(buf_size.ToInt32()); size = H5L.get_name_by_idx(m_v2_test_file, ".", H5.index_t.NAME, H5.iter_order_t.NATIVE, 1, nameBuilder, buf_size); Assert.IsTrue(nameBuilder.ToString() == "AB"); }
//release power requirement public void Release() { if (handle.ToInt32() != 0) { int result; result = ReleasePowerRequirement(handle); handle = System.IntPtr.Zero; } }
public static System.Int16 ReadInt16TSSS(System.IntPtr ptr) { //case - OnDataChange method and OnReadComplete method pvValues ptr if (ptr.ToInt32() == 9999) { return(10); } ptr = new IntPtr((int)System.Runtime.InteropServices.VarEnum.VT_I2); return(0); }
public void H5Eget_numTest1() { hid_t est = H5E.get_current_stack(); Assert.IsTrue(est >= 0); ssize_t size = H5E.get_num(est); Assert.IsTrue(size.ToInt32() >= 0); Assert.IsTrue(H5E.close_stack(est) >= 0); }
public static float[] xzimgAugmentedFaceDetect(System.IntPtr textureID) { #if UNITY_ANDROID && !UNITY_EDITOR AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject jo = jc.GetStatic <AndroidJavaObject>("currentActivity"); return(jo.Call <float[]>("xzimgAugmentedFaceDetect", textureID.ToInt32())); #else return(null); #endif }
bool System.Windows.Forms.IMessageFilter.PreFilterMessage(ref System.Windows.Forms.Message m) { if (m.Msg == 512) { Skybound.VisualTips.VisualTipTracker.ResetTimers(); Skybound.VisualTips.VisualTipTracker._LastMouseEventHwnd = m.HWnd; Skybound.VisualTips.VisualTipTracker._LastMouseEventControl = null; } else if (((m.Msg != 675) && (m.Msg != 513)) || Skybound.VisualTips.VisualTipTracker._LastMouseEventHwnd == m.HWnd) { Skybound.VisualTips.VisualTipTracker._LastMouseEventHwnd = System.IntPtr.Zero; Skybound.VisualTips.VisualTipTracker._LastMouseEventControl = null; } if (Skybound.VisualTips.VisualTipTracker.TrackingProvider == null) { goto label_1; } switch (m.Msg) { case 512: System.IntPtr intPtr1 = m.LParam; System.Drawing.Point point = new System.Drawing.Point(intPtr1.ToInt32()); Skybound.VisualTips.VisualTipTracker.TrackingProvider.TrackMouseMove(new System.Windows.Forms.MouseEventArgs(System.Windows.Forms.Control.MouseButtons, 0, point.X, point.Y, 0)); break; case 513: case 514: Skybound.VisualTips.VisualTipTracker.TrackingProvider.TrackMouseDownUp(); break; case 675: Skybound.VisualTips.VisualTipTracker.TrackingProvider.TrackMouseLeave(System.EventArgs.Empty); break; case 256: System.IntPtr intPtr2 = m.WParam; System.Windows.Forms.KeyEventArgs keyEventArgs = new System.Windows.Forms.KeyEventArgs((System.Windows.Forms.Keys)intPtr2.ToInt32()); Skybound.VisualTips.VisualTipTracker.TrackingProvider.TrackKeyDown(keyEventArgs); return(keyEventArgs.Handled); break; } label_1: if (m.Msg == 512) { Skybound.VisualTips.VisualTipTracker.ResetTimers(); } else if ((m.Msg == 256) && (Skybound.VisualTips.VisualTipProvider.WindowStack.Count > 0)) { System.IntPtr intPtr3 = m.WParam; return(Skybound.VisualTips.VisualTipProvider.WindowStack.ProcessKeyDown((System.Windows.Forms.Keys)intPtr3.ToInt32())); } return(false); }
protected override void WndProc(ref System.Windows.Forms.Message m) { if (m.Msg == 528) { System.IntPtr intPtr = m.WParam; if (intPtr.ToInt32() == 513) { System.Drawing.Point point = PointToScreen(new System.Drawing.Point((int)m.LParam)); OnFormClicked(new Oranikle.Studio.Controls.FormClickedEventArgs(point)); } } base.WndProc(ref m); }
private unsafe void FileSystemEventCallback( FSEventStreamRef streamRef, IntPtr clientCallBackInfo, size_t numEvents, byte **eventPaths, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] Interop.EventStream.FSEventStreamEventFlags[] eventFlags, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] FSEventStreamEventId[] eventIds) { Debug.Assert((eventPaths != null) && (numEvents.ToInt32() == eventFlags.Length) && (numEvents.ToInt32() == eventIds.Length)); // Try to get the actual watcher from our weak reference. We maintain a weak reference most of the time // so as to avoid a rooted cycle that would prevent our processing loop from ever ending // if the watcher is dropped by the user without being disposed. If we can't get the watcher, // there's nothing more to do (we can't raise events), so bail. FileSystemWatcher watcher; if (!_weakWatcher.TryGetTarget(out watcher)) { CancellationCallback(); return; } ExecutionContext context = _context; if (context is null) { // Flow suppressed, just run here ProcessEvents(numEvents.ToInt32(), eventPaths, eventFlags, eventIds, watcher); } else { ExecutionContext.Run( context, (object o) => ((RunningInstance)o).ProcessEvents(numEvents.ToInt32(), eventPaths, eventFlags, eventIds, watcher), this); } }
internal static string CString(System.IntPtr ptr) { System.IntPtr length = CFStringGetLength(ptr); if (length != IntPtr.Zero) { byte[] utf8_bytes = new byte[length.ToInt32() + 1]; if (CFStringGetCString(ptr, utf8_bytes, new IntPtr(utf8_bytes.Length), 0x08000100)) { return(Encoding.UTF8.GetString(utf8_bytes)); } } return(""); }
public void H5Rget_nameTest1() { byte[] path = Encoding.UTF8.GetBytes(String.Join("/", m_utf8strings)); // make room for the trailling \0 byte[] name = new byte [path.Length + 1]; Array.Copy(path, name, path.Length); Assert.IsTrue( H5G.close(H5G.create(m_v0_test_file, path, m_lcpl_utf8)) >= 0); byte[] refer = new byte [H5R.OBJ_REF_BUF_SIZE]; GCHandle hnd = GCHandle.Alloc(refer, GCHandleType.Pinned); Assert.IsTrue( H5R.create(hnd.AddrOfPinnedObject(), m_v0_test_file, name, H5R.type_t.OBJECT, -1) >= 0); ssize_t size = H5R.get_name(m_v0_test_file, H5R.type_t.OBJECT, hnd.AddrOfPinnedObject(), (byte[])null, IntPtr.Zero); Assert.IsTrue(size.ToInt32() == name.Length); // size does not include the trailling \0 byte[] buf = new byte[size.ToInt32() + 1]; size = H5R.get_name(m_v0_test_file, H5R.type_t.OBJECT, hnd.AddrOfPinnedObject(), buf, new IntPtr(buf.Length)); Assert.IsTrue(size.ToInt32() == name.Length); hnd.Free(); // we need to account for the leading "/", which was not included // in path for (int i = 0; i < name.Length; ++i) { Assert.IsTrue(name[i] == buf[i + 1]); } }
public Bitmap PreviewSymbol(IStyleGalleryClass pStyleGalleryClass, object galleryItem, int imgWidth, int imgHeight) { Bitmap bitmap = new Bitmap(imgWidth, imgHeight); Graphics graphics = Graphics.FromImage(bitmap); tagRECT rect = new tagRECT(); rect.right = bitmap.Width; rect.bottom = bitmap.Height; System.IntPtr hdc = graphics.GetHdc(); pStyleGalleryClass.Preview(galleryItem, hdc.ToInt32(), ref rect); graphics.ReleaseHdc(hdc); graphics.Dispose(); return(bitmap); }
public void H5Fget_files_imageTest1() { string fname = Path.GetTempFileName(); hid_t file = H5F.create(fname, H5F.ACC_TRUNC); Assert.IsTrue(file >= 0); IntPtr buf_len = new IntPtr(); ssize_t size = H5F.get_file_image(file, IntPtr.Zero, buf_len); Assert.IsTrue(size.ToInt32() > 0); IntPtr buf = H5.allocate_memory(new IntPtr(size.ToInt32()), 1); Assert.IsTrue(buf != IntPtr.Zero); Assert.IsTrue(H5F.get_file_image(file, IntPtr.Zero, buf_len).ToInt32() > 0); Assert.IsTrue(H5.free_memory(buf) >= 0); Assert.IsTrue(H5F.close(file) >= 0); File.Delete(fname); }
public void H5Aget_nameTest3() { byte[] name = Encoding.UTF8.GetBytes( String.Join(":", m_utf8strings)); byte[] name_buf = new byte [name.Length + 1]; Array.Copy(name, name_buf, name.Length); hid_t att = H5A.create(m_v0_test_file, name_buf, H5T.IEEE_F64BE, m_space_scalar, m_acpl); Assert.IsTrue(att >= 0); ssize_t buf_size = H5A.get_name(att, IntPtr.Zero, (byte[])null) + 1; Assert.IsTrue(buf_size.ToInt32() > 1); byte[] buf = new byte[buf_size.ToInt32()]; Assert.IsTrue(H5A.get_name(att, buf_size, buf).ToInt32() >= 0); for (int i = 0; i < buf.Length; ++i) { Assert.IsTrue(name_buf[i] == buf[i]); } Assert.IsTrue(H5A.close(att) >= 0); }