com

How does one return a local CComSafeArray to a LPSAFEARRAY output parameter?

a 夏天 提交于 2019-12-04 02:31:59
I have a COM function that should return a SafeArray via a LPSAFEARRAY* out parameter. The function creates the SafeArray using ATL's CComSafeArray template class. My naive implementation uses CComSafeArray<T>::Detach() in order to move ownership from the local variable to the output parameter: void foo(LPSAFEARRAY* psa) { CComSafeArray<VARIANT> ret; ret.Add(CComVariant(42)); *psa = ret.Detach(); } int main() { CComSafeArray<VARIANT> sa; foo(sa.GetSafeArrayPtr()); std::cout << sa[0].lVal << std::endl; } The problem is that CComSafeArray::Detach() performs an Unlock operation so that when the

Make my COM assembly call asynchronous

ⅰ亾dé卋堺 提交于 2019-12-04 02:27:01
I've just "earned" the privilege to maintain a legacy library coded in C# at my current work. This dll: Exposes methods for a big legacy system made with Uniface, that has no choice but calling COM objects. Serves as a link between this legacy system, and another system's API. Uses WinForm for its UI in some cases. More visually, as I understand the components : *[Big legacy system in Uniface]* ==[COM]==> [C# Library] ==[Managed API]==> *[Big EDM Management System]* The question is: One of the methods in this C# Library takes too long to run and I "should" make it asynchronous! I'm used to C#,

Call COM object from classic ASP

江枫思渺然 提交于 2019-12-04 02:16:14
问题 How to call COM object from classic ASP? I tried hard but cannot find a good tutorial. Any recommendations? I am using C# in classic ASP. 回答1: If you're using JavaScript: var obj = new ActiveXObject("Some.Object") For example, see this page: http://www.webreference.com/js/column55/activex.html This assumes that "Some.Object" has been registered as a COM object (for example, using "regsvr32 /register SomeObject.dll"). For further reading, O'Reilly had a decent book on this and you might

COM Interface Guid

落花浮王杯 提交于 2019-12-04 01:44:59
I'm not much into COM interfaces, so i have a small question, say I have this code: [Guid("148BD528-A2AB-11CE-B11F-00AA00530503"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] internal interface IEnumWorkItems { [PreserveSig()] int Next([In] uint RequestCount, [Out] out System.IntPtr Names, [Out] out uint Fetched); void Skip([In] uint Count); void Reset(); void Clone([Out, MarshalAs(UnmanagedType.Interface)] out IEnumWorkItems EnumWorkItems); } How do I know that "148BD528-A2AB-11CE-B11F-00AA00530503" corresponds to IEnumWorkItems : http://msdn.microsoft.com/en-us/library/aa380706(VS

How to best convert CString to BSTR to pass it as an “in” parameter into a COM method?

你。 提交于 2019-12-04 00:53:42
问题 I need to convert a CString instance into a properly allocated BSTR and pass that BSTR into a COM method. To have code that compiles and works indentically for both ANSI and Unicode I use CString::AllocSysString() to convert whatever format CString to a Unicode BSTR. Since noone owns the returned BSTR I need to take care of it and release it after the call is done in the most exception-safe manner posible and with as little code as possible. Currently I use ATL::CComBSTR for lifetime

What is difference between RegSvr and RegServer?

不想你离开。 提交于 2019-12-04 00:22:36
问题 Are /RegServer and /RegSvr the same or different, if different why/how? For example I have seen (example from a 32-bit OS) this style: RegSvr32 COM.exe or RegSvr32 COM.dll Or as an alternative (which was on a 64-bit OS): COM.exe /RegServer COM.exe /RegSvr Are these different approaches doing the same thing? 回答1: COM servers are registered the same way in 32- bit 64-bit operating systems. The question is related to self-registration, the most straightforward way to register COM server - by

Excel .NET COM - Automation error. The system cannot find the file specified

烈酒焚心 提交于 2019-12-04 00:17:05
I have a .NET 2.0 COM object that's used by VBA in Excel. It works fine on my dev machine, but when trying to use it on a clean VM workstation I get this error: Automation error. The system cannot find the file specified. The dll is registered with "regasm /tlb /codebase mycom.dll" and not put in the GAC. I don't have administration rights on the VM box Any ideas? You need to either invoke regasm with the full path to the assembly as the codebase parameter value or put the assembly into some location which is always on the path for searching libraries. Otherwise it will not be found when the

Which is correct? catch (_com_error e) or catch (_com_error& e)?

我只是一个虾纸丫 提交于 2019-12-04 00:05:27
Which one should I use? catch (_com_error e) or catch (_com_error& e) JaredPar The second. Here is my attempt at quoting Sutter "Throw by value, catch by reference" Learn to catch properly: Throw exceptions by value (not pointer) and catch them by reference (usually to const ). This is the combination that meshes best with exception semantics. When rethrowing the same exception, prefer just throw; to throw e; . Here's the full Item 73. Throw by value, catch by reference. The reason to avoid catching exceptions by value is that it implicitly makes a copy of the exception. If the exception is of

Difference between COM DLL and ActiveX control

拟墨画扇 提交于 2019-12-03 23:35:29
Few similarities I know.. Both cannot execute by themself. It needs some program to instantiate it. COM DLL & ActiveX controls are platform independant. (is it so...?) Both requires to support the interface IUnknown and exposes three methods QueryInterface , AddRef , and Release . It also requires to be registered before using and un-registered after done with it. But how are they different? Can someone please list it down? Also my understanding is ActiveX controls are OLE custom controls (OCX). I have heard of terms like ActiveX DLLs. Is it another form of ActiveX control or something

What's the Matlab equivalent of NULL, when it's calling COM/ActiveX methods?

眉间皱痕 提交于 2019-12-03 23:35:15
I maintain a program which can be automated via COM. Generally customers use VBS to do their scripting, but we have a couple of customers who use Matlab's ActiveX support and are having trouble calling COM object methods with a NULL parameter . They've asked how they do this in Matlab - and I've been scouring Mathworks' COM/ActiveX documentation for a day or so now and can't figure it out. Their example code might look something like this: function do_something() OurAppInstance = actxserver('Foo.Application'); OurAppInstance.Method('Hello', NULL) end where NULL is where in another language, we