com

Calling Managed C# COM Objects from C#

妖精的绣舞 提交于 2019-12-30 11:19:27
问题 I am trying to call a C# COM object from C#. I created a class library in C# and exported a Type Library using tlbexe.exe. I then registered the type library using regtlibv12.exe. However when I add a reference to my COM object in Visual Studio I get an error saying: "The Active X type library ... was exported from a .NET assembly and cannot be added as a reference. Add a reference to the .NET assembly instead." Any assistance would be greatly appreciated. 回答1: A 64bit process cannot access

How to get the PIDL of an open explorer window?

≡放荡痞女 提交于 2019-12-30 10:57:11
问题 I know how to get all open explorer windows, using Microsoft Internet Controls COM library. From this, I am able to find the LocationURL of those windows. However, this is only set for paths on the file system. Seemingly when virtual objects are displayed, like network printers or the recycle bin, LocationURL is empty. LocationName still seems to be set to the name which is visible on the start bar. When LocationURL is set, this is sufficient for my purposes to know where the explorer window

Why does iterating a Hashtable with `For Each` not work in VBScript?

让人想犯罪 __ 提交于 2019-12-30 10:19:52
问题 Why can one iterate an ArrayList using For Each but not a Hashtable ? Dim i For Each i In CreateObject("System.Collections.ArrayList") ' no error Next For Each i In CreateObject("System.Collections.Hashtable") ' error Next Iterating the HashTable gives Object doesn't support this property or method. 回答1: Scripting languages have a technical limitation, they can only use the default interface of a coclass. They have no notion of interfaces at all and no back-door to obtain another interface

double calls to CoInitialize()

半腔热情 提交于 2019-12-30 08:51:10
问题 Let's say my application calls CoInitialize when it starts and CoUninitialize before it exists. Assuming I have a 3rd party component that's used by my application and does a similar thing, will this cause some kind of failure? is it okay to call CoInitialize when that call has already been submitted? will the second call fail? or will it just "let it pass" as it's already called. 回答1: CoInitialize will return S_FALSE if it has already been initialized in the calling thread. However, for both

double calls to CoInitialize()

╄→尐↘猪︶ㄣ 提交于 2019-12-30 08:51:07
问题 Let's say my application calls CoInitialize when it starts and CoUninitialize before it exists. Assuming I have a 3rd party component that's used by my application and does a similar thing, will this cause some kind of failure? is it okay to call CoInitialize when that call has already been submitted? will the second call fail? or will it just "let it pass" as it's already called. 回答1: CoInitialize will return S_FALSE if it has already been initialized in the calling thread. However, for both

Why won't my Setup Project Perform my Custom Registration Process

半城伤御伤魂 提交于 2019-12-30 08:42:10
问题 I am trying to write an Setup Project/Installer for a class library driver that I wrote in C# using Visual Studio 2008. The driver project has a section of code that looks like this... [ComRegisterFunction] public static void RegisterASCOM(Type t) { Trace.WriteLine("Registration Started."); DoRegistration(true); } In the driver project Properties -> "Assembly Information" I have set checked the box that says Make COM-Visible = true. I added a Setup Project to the solution in VS, added the

Why won't my Setup Project Perform my Custom Registration Process

◇◆丶佛笑我妖孽 提交于 2019-12-30 08:41:30
问题 I am trying to write an Setup Project/Installer for a class library driver that I wrote in C# using Visual Studio 2008. The driver project has a section of code that looks like this... [ComRegisterFunction] public static void RegisterASCOM(Type t) { Trace.WriteLine("Registration Started."); DoRegistration(true); } In the driver project Properties -> "Assembly Information" I have set checked the box that says Make COM-Visible = true. I added a Setup Project to the solution in VS, added the

Convention for passing BSTRs into COM functions from C# (COM interop)

巧了我就是萌 提交于 2019-12-30 08:19:06
问题 I am writing writing an API in COM in C++, and also writing a program which consumes this API in C#. My question is about BSTR memory management semantics when passing BSTRs into COM functions. Say my IDL looks like: HRESULT SomeFunction([in] BSTR input); Currently this function is implemented like this: HRESULT SomeFunction(BSTR input) { // Do stuff ..., then: SysFreeString(input); } When I call it from C# with something like SomeFunction(myString) , will C# generate something like this

COM interop object throws InvalidCastException in one project but not in other

拥有回忆 提交于 2019-12-30 07:28:09
问题 I have a COM object I imported in my test C# solution. Everything works fine and continues to do so. Then I imported the same COM object in my actual solution and as a test implemented the exact same lines as in the test project. When I run the real project I get an InvalidCastException Unable to cast COM object of type 'CTWebReport.WebReportCOMClass' to interface type 'CTWebReport.IWebReportCOM'. This operation failed because the QueryInterface call on the COM component for the interface

Delphi CreateOleObject events

送分小仙女□ 提交于 2019-12-30 07:10:28
问题 There is a code: var myobject: OleVariant; begin myobject := CreateOleObject('SomeNamespace.SomeClass'); end; This COM object has events (for example OnClick). How should I connect to these events without importing TLB? 回答1: You are working with COM late-binding, so do you need write a lot of code to handle events. this task is not difficult if you know COM, basically do you need follow these steps. Create a new object(class) derived from TInterfacedObject that implements IDispatch implement