com

How to read TLB (type libraries) of unmanaged code from C#?

你离开我真会死。 提交于 2019-12-01 20:54:03
问题 How can I parse an unmanaged code in TLB (Of unmanaged COM server) in C#? 回答1: By creating a managed wrapper using tlbimp.exe. 回答2: Once I wrote a TLB browser in VB. I used a COM component that shipped with VB 6 called TlbInf32.dll (you can still find this component in the web I guess). Best 来源: https://stackoverflow.com/questions/2778862/how-to-read-tlb-type-libraries-of-unmanaged-code-from-c

Consuming a .Net library via COM or direct integration in Java

百般思念 提交于 2019-12-01 20:48:45
I have to admit the last time I programmed in Java was a data structures class in high school. So please be kind to this Java noob. I have spent a good deal of time putting together a C# COM library at work. This library relies heavily on some new .Net technologies (WPF being the big one) so translating it into another language is not really an option. I have tested consuming this library from C++ through the COM interface and that was simple enough. I wanted to also prove that this same library could be used from a Java program. So the problem that I have run into is that I can not find a

Is there any purpose of ComDefaultInterface for a COM Callable Wrapper?

◇◆丶佛笑我妖孽 提交于 2019-12-01 20:36:55
问题 What is the purpose of ComDefaultInterfaceAttribute attribute, if the managed object with ClassInterfaceType.None is marshaled as either IUnknown or IDispatch , anyway? Consider the following C# class AuthenticateHelper , which implements COM IAuthenticate : [ComImport] [Guid("79eac9d0-baf9-11ce-8c82-00aa004ba90b")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAuthenticate { [PreserveSig] int Authenticate( [In, Out] ref IntPtr phwnd, [In, Out, MarshalAs

How to get the GIT in Delphi 7?

倖福魔咒の 提交于 2019-12-01 20:36:49
问题 I'm trying to get the Global Interface Table by using the following code (Delphi): uses Comobj, ActiveX; var cGIT : IGlobalInterfaceTable = NIL; const CLSID_StdGlobalInterfaceTable: TGUID = '{00000146-0000-0000-C000-000000000046}'; function GIT : IGlobalInterfaceTable; begin if (cGIT = NIL) then OleCheck (CoCreateInstance (CLSID_StdGlobalInterfaceTable, NIL, CLSCTX_ALL, IGlobalInterfaceTable, cGIT )); Result := cGIT; end; However, CoCreateInstance throws a "Class Not Registered" exception.

Can't co-create object / Can't find moniker | Jacob

谁都会走 提交于 2019-12-01 20:33:30
When creating an ActiveXComponent using JACOB I get the following error. com.jacob.com.ComFailException: Can't co-create object at com.jacob.com.Dispatch.createInstanceNative(Native Method) at com.jacob.com.Dispatch.<init>(Dispatch.java:99) at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java:58) at com.paston.jacobtest.RidderIQ.main(RidderIQ.java:30) The COM object which I need to use from a program which doesn't register its DLLs by itself during installation. To register the DLL I used the 64bit version of RegAsm according to this article that could help. Also, I tried to load

Is there any purpose of ComDefaultInterface for a COM Callable Wrapper?

て烟熏妆下的殇ゞ 提交于 2019-12-01 19:30:38
What is the purpose of ComDefaultInterfaceAttribute attribute, if the managed object with ClassInterfaceType.None is marshaled as either IUnknown or IDispatch , anyway? Consider the following C# class AuthenticateHelper , which implements COM IAuthenticate : [ComImport] [Guid("79eac9d0-baf9-11ce-8c82-00aa004ba90b")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAuthenticate { [PreserveSig] int Authenticate( [In, Out] ref IntPtr phwnd, [In, Out, MarshalAs(UnmanagedType.LPWStr)] ref string pszUsername, [In, Out, MarshalAs(UnmanagedType.LPWStr)] ref string pszPassword);

Handling CoCreateInstance return value

别等时光非礼了梦想. 提交于 2019-12-01 19:00:54
Here's a code sample creating a COM object: CComPtr<IBaseFilter> pFilter; auto hr = CoCreateInstance(CLSID_DMOWrapperFilter, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, reinterpret_cast<void**>(&pFilter)); I've seen somewhere that checking if CoCreateInstance() succeeded should look like this: if (SUCCEEDED(hr) && pFilter != nullptr) { // code goes here } What if I would check only hr ? Wouldn't it be enough? Should I also check that filter != nullptr ? //would this be enough? if (SUCCEEDED(hr)) { // code goes here } This question also concerns other COM methods like QueryInterface() . Having

How to check whether a PE file (DLL,EXE) is a COM component?

被刻印的时光 ゝ 提交于 2019-12-01 18:57:11
I need to write a stub module which, when given a PE (DLL/EXE) as input, will determine whether it is a normal Win32 DLL/EXE or COM DLL/EXE. I need to determine this programatically. Are there any Windows APIs for this purpose? I suspect that this is something that would be very hard to do with near 100% accuracy. Some thoughts though: A COM DLL will export functions like DllRegisterServer and DllUnregisterServer. You could use LoadLibrary() to load the Dll, and then GetProcAddress() to check for the presence of these functions. If they're there then its highly likely that its a COM dll. A

How to check if a class implements an interface, with respecting supersets?

烈酒焚心 提交于 2019-12-01 18:46:21
I am learning about COM and Interfaces and have following experimental code: type IA = interface(IInterface) ['{C9C5C992-3F67-48C5-B215-7DCE6A61F0E8}'] end; IB = interface(IA) ['{F1799437-AD12-471B-8716-F1D93D1692FC}'] end; IC = interface(IB) ['{01780E8C-C47D-468E-8E42-4BFF3F495D51}'] end; TBO = class(TInterfacedObject, IB) end; procedure TForm1.FormCreate(Sender: TObject); var x: TBO; a: IInterface; begin x := TBO.Create; IInterface(x)._AddRef; if Assigned(TBO.GetInterfaceEntry(IA)) then memo1.lines.add('GetInterfaceEntry IA: OK'); // Why not? if Assigned(TBO.GetInterfaceEntry(IB)) then memo1

How to release inprocess COM Server object from Excel VBA

为君一笑 提交于 2019-12-01 18:19:14
How do you force Excel (2007) VBA to release references to a COM server object? I have written an inprocess (Single instance DLL) COM Server in Visual Foxpro 9 SP2 which is instantiated from Excel 2007 VBA code on my development machine. Excel seems to be holding a reference to the COM object/dll even though I set it = Nothing. This prevents me from rebuilding the DLL due to a "File access is denied TestCOM.dll" message until I quit Excel which is a pain everytime I want to make a change and test it. I have boiled the code down to a very simple test setup: The VFP9 project (TestCOM) has just