com

Why so many parentheses in SUCCEEDED macro?

蹲街弑〆低调 提交于 2020-01-03 11:51:11
问题 Windows SDK features SUCCEEDED macro: #define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) -----------------------^-------------^----- clearly as with other macros there're parentheses to ensure right interpretation of the intent by compiler. What I don't get is why there are parentheses around (HRESULT)(hr) (I marked them with ^ character). hr is parenthesized so that some complex construct can be there, HRESULT is parenthesized to form a C-style cast, then the whole >= construct is parenthesized as

Redirect STDERR output from COM object wrapper in .NET

与世无争的帅哥 提交于 2020-01-03 11:44:12
问题 I'm trying to make use of the ImageMagick COM object (ImageMagickObject) in a .NET library. This library is intended to be called from IronRuby, but that isn't all that important. I want to take this approach because it will fit with my existing calls, which currently call the ImageMagick binaries as external processes. The COM object will take the same arguments as the binaries, but will save the process creation and are about 5x faster overall. My only hurdle is that the "Compare" method

How to prevent re-entrancy of WPF event handler during ActiveX method call?

一个人想着一个人 提交于 2020-01-03 07:33:30
问题 We're calling methods on an ActiveX component from within a WPF and STA application. This calling is late-bound performed via: res = ocx.GetType().InvokeMember(methodName, flags, null, ocx, args); ...where ocx is the ActiveX object retrieved with the System.Windows.Forms.AxHost.GetOcx() method. This call is performed from within a WPF event handler, say 'mouse clicked'. Now the problem. If we double-click the 'mouse clicked' event will trigger, running InvokeMember(). However, during this

How do I use a COM component from VB.NET?

ⅰ亾dé卋堺 提交于 2020-01-03 05:11:11
问题 How do I access a COM component from an ASP.NET page. I added reference to my ASP.NET project. The actual dll I got from the 3rd party is ePadIIu.dll but when I added it to the ASP.NET project it shows as ePadIIu.interop . I want to access all the methods and properties in the component. The sample I received from the 3rd party software uses vbscript to access all the methods. How do I use those methods in the code behind from default.aspx.vb . 回答1: When you added the reference to the COM

ActiveX Flash component in C# .NET 2.0 Application causes memory leak?

♀尐吖头ヾ 提交于 2020-01-03 04:32:15
问题 We have a C#/.NET 2.0 WinForm with an ActiveX ShockwaveFlashObject control on it. The program loops through a schedule of content and displays it over and over on the control, fullscreen, like this: axFlash.BringToFront(); axFlash.Movie = scheduleItem.FilePath; axFlash.Show(); axFlash.Play(); This works great, but after a couple of days running, the form on which the Flash ActiveX control resides will throw an exception like this: System.Runtime.InteropServices.SEHException: External

get_accChildCount returns 0 when it shouldn't

与世无争的帅哥 提交于 2020-01-03 03:42:05
问题 I'm trying to enumerate tabs of IE from an extension and from a standalone application. For one of the MSAA nodes get_accChildCount returns 0 when called from extension, while it should return 1 according to inspect and a call from standalone application. The problem was described previously at StackOverflow, yet it was solved via a hack that doesn't work for me. /clr and /MT are incompatible. Also there was a topic on MSDN with the same issue. There's no single answer there. If you run IE

MSMQ not invoking COM

天大地大妈咪最大 提交于 2020-01-03 03:07:31
问题 I made a COM object with c# and let VS register it for me. I can see it in registry and if I make a test app I can add a reference to it and it works as expected with all the methods available and functional. Now If I try and use it in a MSMQ rule nothing happens. It will not be invoked. Is this because it is a .NET assembly? Is it because I do not have VS Pro? Do you have any idea at all? 回答1: You haven't by any chance registered your component on a mapped network drive have you? MSMQ runs

Can a managed ref-class directly implement a COM interface?

社会主义新天地 提交于 2020-01-03 02:54:17
问题 Is there a built-in way to allow a managed ref-class to implement and expose a COM inerface that is safely callable from native code? Looking at the C# side, this is easily done by decorating the target interface with the proper COM-interop attributes, for example: Native Interface interface ISampleGrabberCB: public IUnknown { virtual STDMETHODIMP SampleCB( double SampleTime, IMediaSample *pSample ) = 0; virtual STDMETHODIMP BufferCB( double SampleTime, BYTE *pBuffer, long BufferLen ) = 0; };

COM Interop hang freezes entire COM system. How to cancel COM call

情到浓时终转凉″ 提交于 2020-01-03 02:33:05
问题 I am using a third party dll that is exposed via a COM Interop wrapper. However, one of the COM calls often freezes (never returns at least). To try to at least make my code a little more robust, I wrapped the call asynchronously ( _getDeviceInfoWaiter is a ManualResetEvent ) var backgroundWorker = new BackgroundWorker(); backgroundWorker.DoWork += (sender, eventArgs) => { var deviceInfo = _myCom.get_DeviceInfo(0); _serialNumber = deviceInfo.SerialNumber; _getDeviceInfoWaiter.Set(); };

HowTo: Display progress dialog using IFileOperation

会有一股神秘感。 提交于 2020-01-03 01:51:11
问题 I’m trying to get a progress dialog to display for my copy operation in some sample code. I’m using IFileOperation because I found that using SHFileOperation will not display a progress dialog if the files have already been copied to the target location. My hope is that IFileOperation is a little more sophisticated and can handle that situation. Here’s the sample code I’ve tried…. CComPtr<IOperationsProgressDialog> opProgressDlg; HRESULT hr = opProgressDlg.CoCreateInstance(CLSID