handle

Hooking TerminateProcess & Getting Info From The Handle It Supplies

允我心安 提交于 2019-12-25 16:00:34
问题 If you want to stop a process from being terminated, one way is to hook into TerminateProcess (or NtTerminateProcess). If the process is terminating itself (because you closed its window, for example), the handle supplied to those functions is NULL, so you can find out what executable is being terminated using GetCurrentProcess() & GetModuleFileNameEx(). As GetCurrentProcess() returns a pseudo-handle, you can access it with no problems. If one process is terminating another, though, the

Cellfun with Structfun as function?

╄→гoц情女王★ 提交于 2019-12-25 10:02:18
问题 My data are in the form of a cell array of structs. I am trying to implement a cellfun call that takes structfun as its function that, at the end of the day, will resize all of the vectors in the struct to the passed-in size. E.g. I have a 4-cell array each with a struct that contains one vector (going to be multiple vectors once I figure this out), and I want to resize each vector from index1 to index2 fun = function(foo, index1, index2) cellfun(@structfun(@(x) x(index1:index2), foo,

Error in creating windows handle

拈花ヽ惹草 提交于 2019-12-25 00:36:27
问题 I have created a .net 2.0 windows application. This application creates form controls dynamically. Now when I am trying to run the application, it is throwing an exception "Error in creating windows handle". After this, application gets hang and nothing happens. At the first time, form gets displayed properly. On a particular event I am trying to reload the same form, while that time I am getting this exception. Anybody knows how to get rid of this. Any kind of help would be great full :) 回答1

Matlab openfig to existing figure

自作多情 提交于 2019-12-24 16:54:30
问题 When in Matlab I use openfig(filename); to open a saved figure, it always opens a new window. All the 'reuse' argument does is not load the file when it appears to already be open. However, I wish to open the file into a given figure , and just overwrite its contents. Is there a way to pass a figure handle to openfig , or is there another function that would accomplish this? So in code, what I would like to do is something along the following lines: f = figure; openfig(filename, 'Figure',f);

EndUpdateResource() throws Error 110 The system cannot open the device or file specified when windowsexplorer is open at the output location

陌路散爱 提交于 2019-12-24 16:37:02
问题 The following code throws a 110 Error on the EndUpdateResource call only when windows explorer is open at D:\test\output\ where the executable is being copied to: std::ifstream in("C:\\Windows\\notepad.exe", std::ios::binary); std::ofstream out("D:\\test\\output\\notepad.exe", std::ios::binary); out << in.rdbuf(); in.close(); out.close(); Handle hUpdateRes = BeginUpdateResource(_T("D:\\test\\output\\notepad.exe"), FALSE); EndUpdateResource(hUpdateRes, FALSE); As long as I don't have that

Portably opening a handle to stdin many times in a single session

对着背影说爱祢 提交于 2019-12-24 00:58:58
问题 Code: main = do putStrLn "4917 Microprocessor\nEnter the Machine Code to be run: " inp <- getContents putStrLn "The output of the Program is:" fState <- ((runStateT _4917) . construct . parse) inp args <- getArgs if elem "-v" args then putStrLn ("\nFinal state was: " ++ (show . snd) fState) else return () putStrLn "\n================================ RESTART ================================" main where parse xs = array (0,15) $ zip [0..15] $ take 16 $ map ((makeArbInt 4) . read) (words (filter

How to use Control.FromHandle?

半城伤御伤魂 提交于 2019-12-23 19:42:02
问题 i saw a method called Control.FromHandle wich (should) give you the access to it. Now, i wanted to try it using this code [DllImport("user32.dll", SetLastError = true)] static extern IntPtr FindWindow(string lpClassName, string lpWindowName); // Find window by Caption only. Note you must pass IntPtr.Zero as the first parameter. [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)] static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName); [DllImport(

How to get the handle of 3rd party application's button using c#?

梦想的初衷 提交于 2019-12-23 16:53:40
问题 I am trying to generate an click event in a third party application. As a start I tried to simulate a click in calculator. Here's the code" IntPtr hwnd = IntPtr.Zero; IntPtr hwndChild = IntPtr.Zero; //Get a handle for the Calculator Application main window hwnd = FindWindow(null, "Calculator"); hwndChild = FindWindowEx(hwnd, IntPtr.Zero, "Button", "1"); //send BN_CLICKED message SendMessage(hwndChild, BM_CLICK, IntPtr.Zero, IntPtr.Zero); But using this code I am not getting the handle of the

How to Compare Two variable of HANDLE type

孤者浪人 提交于 2019-12-23 16:35:49
问题 I have a variable of HANDLE type. First HANDLE variable is a process HANDLE (with name hProcess) that does not have PROCESS_QUERY_INFORMATION access right. Second variable is a process HANDLE (with name hwndProcess) too that I have opened via OpenProcess function and have PROCESS_QUERY_INFORMATION access right. I am sure both processes should have same handle. But when i compare them as below, it returns false; if (hProcess==hwndProcess) {do something} How shall I do it? 回答1: There is not an

Can properties of an object handle returned from a function be used without first assigning to a temporary variable?

好久不见. 提交于 2019-12-23 12:42:48
问题 I have a function that returns a handle to an instantiated object. Something like: function handle = GetHandle() handle = SomeHandleClass(); end I would like to be able to use the return value like I would if I was writing a program in C: foo = GetHandle().property; However, I get an error from MATLAB when it tries to parse that: ??? Undefined variable "GetHandle" or class "GetHandle". The only way I can get this to work without an error is to use a temporary variable as an intermediate step: