handle

Handle is semi-closed error in Haskell?

孤街浪徒 提交于 2019-12-23 12:29:38
问题 I am getting this error in GHCI : *** Exception: <stdin>: hGetLine: illegal operation (handle is semi-closed) After running this code : main = do interact $ unlines . fmap proccess . take x . lines readLn :: IO Int And I am pretty sure the cause is take x . Is there any better way to read only x lines of input using interact or is interact just a solo player? 回答1: What you're trying to do isn't possible with interact . Behind the scenes interact claims the entirety of stdin for itself with

How to write to the alternate screen buffer on Windows using only the standard libary?

有些话、适合烂在心里 提交于 2019-12-23 11:58:05
问题 I am working on an alternate screen feature for my cross-platform terminal manipulating crate. Situation When I want to write something to console I can use the following code to write to the current standard output. This works on both UNIX and Windows systems: write!(::std::fmt::io::stdout(), "Some text"). When I switch to the alternate screen, I don't want to write to the current standard output but to the alternate screen. This works differently depending on which platform you are on. The

C++ Why Sendmessage doesnt work?

旧街凉风 提交于 2019-12-23 06:37:48
问题 In C#, this SendMessage function raise up volume successfull: [DllImport("user32.dll")] public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); SendMessage(Handle, 0x319, (int)Handle, APPCOMMAND_VOLUME_UP); But in C++, this SendMessage function dont work, that is volume doesnt rise up: // HWND hwnd = CreateWindow(... SetWindowText(hwnd, "Hi"); // Worked SendMessage(hwnd, WM_APPCOMMAND, (int)hwnd, APPCOMMAND_VOLUME_UP); // Don't work What do I wrong? Can you help

C++ Why Sendmessage doesnt work?

若如初见. 提交于 2019-12-23 06:35:05
问题 In C#, this SendMessage function raise up volume successfull: [DllImport("user32.dll")] public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); SendMessage(Handle, 0x319, (int)Handle, APPCOMMAND_VOLUME_UP); But in C++, this SendMessage function dont work, that is volume doesnt rise up: // HWND hwnd = CreateWindow(... SetWindowText(hwnd, "Hi"); // Worked SendMessage(hwnd, WM_APPCOMMAND, (int)hwnd, APPCOMMAND_VOLUME_UP); // Don't work What do I wrong? Can you help

Get handle of top window (Sort windows by Z index)

北战南征 提交于 2019-12-23 05:00:25
问题 I am trying to write a method which takes List of window handles and returns handle of the window which has highest z index among others. But in vain. Can anybody give me a suggestion how to do that? 回答1: I'll help you out: [DllImport("user32.dll", SetLastError = true)] static extern IntPtr GetWindow(IntPtr hWnd, GetWindow_Cmd uCmd); enum GetWindow_Cmd : uint { GW_HWNDFIRST = 0, GW_HWNDLAST = 1, GW_HWNDNEXT = 2, GW_HWNDPREV = 3, GW_OWNER = 4, GW_CHILD = 5, GW_ENABLEDPOPUP = 6 } private IntPtr

How come some controls don't have a windows handle?

青春壹個敷衍的年華 提交于 2019-12-23 03:05:02
问题 I want to get the window handle of some controls to do some stuff with it (requiring a handle). The controls are in a different application. Strangely enough; I found out that many controls don't have a windows handle, like the buttons in the toolbar (?) in Windows Explorer. Just try to get a handle to the Folder/Search/(etc) buttons. It just gives me 0. So.. first question: how come that some controls have no windows handle? Aren't all controls windows, in their hearts? (Just talking about

c# MainWindowHandle always zero

允我心安 提交于 2019-12-23 01:12:35
问题 I read a few threads about the MainWindowHandle but i couldnt find a solution for my problem, i'm starting a gui application and want to get the MainWindowHandle through the process object, but the handle value is always zero if i'm not going to wait with thread.sleep() until the gui is loaded. i'm also tried to use WaitForInputIdle but it didnt help at all. process.Start(); process.WaitForInputIdle(1000); while (process.MainWindowHandle == IntPtr.Zero) { Thread.Sleep(100); } // do something

How can I open a .NET FileStream object from a Python file handle?

烂漫一生 提交于 2019-12-22 12:36:10
问题 I need to open a writable file handle in Python and then hand off the file descriptor to a function in a .NET assembly (accessed via pythonnet's clr module. Getting from the Python file object to the win32 HANDLE* is fairly straightforward, as shown in this question: import clr from Microsoft.Win32.SafeHandles import SafeFileHandle from System.IO import FileStream, FileAccess pyf=open("c:/temp/testing123.txt","w") fileno=pyf.fileno() print fileno # 6 handle = msvcrt.get_osfhandle(fileno)

What happens to a process handle once the process was ended?

久未见 提交于 2019-12-22 12:23:17
问题 if I have a handle to some windows process which has stopped (killed or just ended): Will the handle (or better the memory behind it) be re-used for another process? Or will GetExitCodeProcess() for example get the correct result forever from now on? If 1. is true: How "long" would GetExitCodeProcess() work? If 2. is true: Wouldn't that mean that I can bring down the OS with starting/killing new processes, since I create more and more handles (and the OS reserves memory for them)? I'm a bit

Is it possible to test a function handle without try block?

删除回忆录丶 提交于 2019-12-21 17:19:50
问题 Is is possible to replace the following code with something which does not use exceptions? The handle x is a provided handle. I want to test it for validity (having actual code to back the handle) before use. x = @notreallyafunction; try x(); catch disp('Sorry function does not exist.'); end 回答1: To test function handles such as for screening out the bogus x=@notreallyafunction in your question, you can use the functions command to check the handle and get the referenced function's name, type