handle

passing a HANDLE variable to an unmanaged .dll in C++/CLI

烈酒焚心 提交于 2019-12-08 04:57:26
问题 I am trying to wrap an unmanaged c++ dll that talks to a video capture card in c++/CLI so i can reference the functions from a c# project that i have. I am having trouble getting the 1st wrapped call to work as I am new to c++/cli syntax. here is what i have. here is the function declataion i am trying to wrap. __declspec(dllimport) BOOL AZ_DeviceCreate(HANDLE& hLiveEvent, DWORD* hEncoderEvent, DWORD* pdwEncoderAddress, HANDLE& hAudioEvent, DWORD& dwAudioAddress); here is my c++/cli .h file

Matlab — handle objects

折月煮酒 提交于 2019-12-07 21:43:09
问题 There is a handle class Foo : classdef Foo < handle properties (SetAccess = public, GetAccess = public) x end methods function obj = foo(x) % constructor obj.x = x; end end end I create an object of Foo : data = [1 2]; foo = Foo(data); % handle object I would like to create a reference ( handle ) variable a that points to foo.x . Is this possible in Matlab? For example, the following does not work: a = foo.x; % here `a` equals [1 2], `a` is not a handle object foo.x = [3 4]; % set property `x

can't I set transparency of a window by its handle in c#?

纵饮孤独 提交于 2019-12-07 14:01:28
问题 i am trying to set transparency of all windows. I have following code. public partial class Form1 : Form { [DllImport("user32.dll")] static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); [DllImport("user32.dll")] static extern int GetWindowLong(IntPtr hWnd, int nIndex); [DllImport("user32.dll")] static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags); public const int GWL_EXSTYLE = -20; public const int WS_EX_LAYERED = 0x80000;

Is relying on the type of a Windows handle being a pointer ok?

偶尔善良 提交于 2019-12-07 13:56:19
问题 Windows handles are sometimes annoying to remember to clean up after (doing GDI with created pens and brushes is a great example). An RAII solution is great, but is it really that great making one full (Rule of Five) RAII class for each different type of handle? Of course not! The best I can see would be one full generic RAII class with other classes just defining what to do when the handle should be cleaned up, as well as other handle-specific aspects. For example, a very simple module class

How can I tell if a Windows module handle is still valid?

旧巷老猫 提交于 2019-12-07 05:42:15
问题 A module can be unloaded, so how can I tell for sure if it is still in memory? I have a handle to it, obtained from GetModuleHandle. When I tried calling GetHandleInformation on it I see error 0xc0000008 - "An invalid HANDLE was specified." This happened before it could have been unloaded. 回答1: The term "handle" is a bit overloaded here - lots of different classes of objects in the Win32 API are called "Handles". GetHandleInformation is used for handles to kernel objects - files, registry

Why doesn't my Perl blessed filehandle doesn't return true with `can('print')`'?

不羁岁月 提交于 2019-12-07 05:36:22
问题 For some reason, I can't get filehandles working with Expect.pm's log_file method. I originally got help on How can I pass a filehandle to Perl Expect's log_file function?, where it was suggested that I use an IO::Handle filehandle to pass to the method. This seems to be a different issue, so I thought I'd start a new question. This is the offending section of Expect.pm: if (ref($file) ne 'CODE') { croak "Given logfile doesn't have a 'print' method" if not $fh->can("print"); $fh->autoflush(1)

SafeFileHandle.Close throws an exception but the handle is valid and works

大城市里の小女人 提交于 2019-12-07 02:28:38
问题 I'm having a problem with custom cursors in a WPF application. I use the following code to create the Cursor objects: [DllImport("user32.dll")] private static extern IntPtr CreateIconIndirect(ref IconInfo icon); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool GetIconInfo(IntPtr hIcon, ref IconInfo pIconInfo); private static Cursor CreateCursor(string cursorName, System.Drawing.Bitmap bmp, int xHotspot, int yHotspot, out SafeFileHandle handle) {

Do I have to close inherited handle later owned by child process?

*爱你&永不变心* 提交于 2019-12-07 01:00:58
问题 Microsoft played safe here. In their article, "Creating a Child Process with Redirected Input and Output", they are saying: The remaining open handles are cleaned up when this process terminates. To avoid resource leaks in a larger application, close handles explicitly. Which is perfectly useless. What handles? In which process? I want to get my head around it. When a handle is created in parent process with SECURITY_ATTRIBUTES.bInheritHandle = TRUE , a child process can see and use it, and

Android, handle SQLiteConstraintException

我们两清 提交于 2019-12-06 20:44:31
问题 I've got this method in Android: public void insertarTitulo(String _id, String title, String url){ ContentValues cv = new ContentValues(); cv.put("_id", _id); cv.put("title", title); cv.put("URL", url); try{ getWritableDatabase().insert("book", "book", cv); }catch(SQLiteConstraintException e){ Log.e(MyActivity.LOGTAG, "This code doesn't show"); } close(); } title value is unique so when I insert a duplicate value throws me the Constraint error, so far that's correct. Everything works as

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

岁酱吖の 提交于 2019-12-06 11:28:11
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 confused about the concept of handles. Thank you in advance! The handle indirectly points to an kernel