handle

Access is denied - when trying to get the url (text) from address bar's handle

隐身守侯 提交于 2019-12-01 17:54:54
I'm trying to extract the URL from the address bar of IE. (IE 8 on Windows 7) using the following C# code. static string GetUrlFromIE() { IntPtr windowHandle = APIFuncs.getForegroundWindow(); IntPtr childHandle; String strUrlToReturn = ""; //try to get a handle to IE's toolbar container childHandle = APIFuncs.FindWindowEx(windowHandle, IntPtr.Zero, "WorkerW", IntPtr.Zero); if (childHandle != IntPtr.Zero) { //get a handle to address bar childHandle = APIFuncs.FindWindowEx(childHandle, IntPtr.Zero, "ReBarWindow32", IntPtr.Zero); if (childHandle != IntPtr.Zero) { childHandle = APIFuncs

Manage a .NET app to shutdown gracefully when terminated/killed

南笙酒味 提交于 2019-12-01 17:53:12
We have a .NET console app that has many foreground threads. If we kill the process using Task Manager or issuing killjob, kill from the command line in windows, is there a way by which we can gracefully shut down the application (adding manged code within the .net console app), something like having a function being called say TodoBeforeShutdown() that disposes objects, closes any open connections, etc. P.S. - I read the other threads and they all suggested different ways to kill the process, rather than my specific question, what is the best way we can handle a terminate process, within the

How to capture mousemove events beneath child controls

邮差的信 提交于 2019-12-01 17:49:39
问题 I am trying to handle a mouseclick event on a particular form that should fire if the mouse cursor falls between a set of coordinates - lets say a square. I understand that if I had an empty form I could simply tie in to the mousemove event and off I go. But in reality there may be up to 10 different overlapping controls and in my test app the mousemove event only fires if the cursor is on the actual form itself and not if its over a child control. Does anyone know how to handle this event

Access is denied - when trying to get the url (text) from address bar's handle

旧巷老猫 提交于 2019-12-01 17:27:33
问题 I'm trying to extract the URL from the address bar of IE. (IE 8 on Windows 7) using the following C# code. static string GetUrlFromIE() { IntPtr windowHandle = APIFuncs.getForegroundWindow(); IntPtr childHandle; String strUrlToReturn = ""; //try to get a handle to IE's toolbar container childHandle = APIFuncs.FindWindowEx(windowHandle, IntPtr.Zero, "WorkerW", IntPtr.Zero); if (childHandle != IntPtr.Zero) { //get a handle to address bar childHandle = APIFuncs.FindWindowEx(childHandle, IntPtr

Force create handle for Control

﹥>﹥吖頭↗ 提交于 2019-12-01 15:55:07
I'm currently creating a silent print module. The current control I'm using is, it's making sure that the control handle is already created ( IsHandleCreated ). I did everything to cheat this with no luck at all. Do you have ideas in mind on how can I create a handle for the control without displaying any in the screen? denisenkom Try to overload CreateParams property getter. In it clear the WS_VISIBLE flag. You have to access the Handle property (put the result in a dummy variable or something). Look in Reflector; it forces handle creation. I had the same problem with some other controls and

MapViewOfFile failes with errorCode 6 (Invalid Handle)

十年热恋 提交于 2019-12-01 14:52:29
Im trying to map the file to the memory and use MapViewOfFile(), but it failes with error code 6. I tried just about anything, I also read about big files being the problem, but the problem happens also with a 1kb file. my code: HANDLE hFile = CreateFile(pFile, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); e = GetLastError(); printf("CreateFile Errorcode %d\n", GetLastError()); if (hFile == INVALID_HANDLE_VALUE) { printf("Error: could not create handle to file"); printf("CreateFileMapping error code: %d", e) return 1; } printf("successfully created a Handle to try.txt");

MapViewOfFile failes with errorCode 6 (Invalid Handle)

被刻印的时光 ゝ 提交于 2019-12-01 14:24:38
问题 Im trying to map the file to the memory and use MapViewOfFile(), but it failes with error code 6. I tried just about anything, I also read about big files being the problem, but the problem happens also with a 1kb file. my code: HANDLE hFile = CreateFile(pFile, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); e = GetLastError(); printf("CreateFile Errorcode %d\n", GetLastError()); if (hFile == INVALID_HANDLE_VALUE) { printf("Error: could not create handle to file"); printf(

Passing additional arguments through function handle in Matlab

我们两清 提交于 2019-12-01 06:01:05
I have a function to optimize, say Function, in Matlab. This function depends on variables (say x) over which I want to optimize and one parameter (say, Q) which does not need to be optimized.Hence, the function Function(x,Q). In other words, I have an array of values for Q and want to find optimal x values for each Q. However, I cannot find a way how to pass those Q values when using function handle @Function in optimization function. So, my question is how to pass those Q values when using function handle in optimization functions, for example fmincon(@Function,x0,A,b)? Try using anonymous

Can a Window Handle in .NET change it's value?

六月ゝ 毕业季﹏ 提交于 2019-12-01 03:51:23
During the lifetime of a .NET process, does the handle of a System.Windows.Forms.Form , lets say the main form used in Application.Run(form) actually change it's value, i.e. if using the value of the handle in a different process, e.g. IntPtr handle = User32.FindWindow(null, "Name") , is there a case where that handle might be invalidated by the .NET runtime? EDIT I need to know the handles because I want to use SendMessage and WM_COPYDATA and the like for IPC. A window handle is guaranteed to be valid and not get reused for as long as the window lives. It's index like in nature, valid

Get running process given process handle

雨燕双飞 提交于 2019-12-01 03:49:23
can someone tell me how i can capture a running process in c# using the process class if i already know the handle? Id rather not have not have to enumerate the getrunning processes method either. pInvoke is ok if possible. In plain C#, it looks like you have to loop through them all: // IntPtr myHandle = ... Process myProcess = Process.GetProcesses().Single( p => p.Id != 0 && p.Handle == myHandle); The above example intentionally fails if the handle isn't found. Otherwise, you could of course use SingleOrDefault . Apparently, it doesn't like you requesting the handle of process ID 0 , hence