com

Sending and receiving arrays over COM

霸气de小男生 提交于 2019-12-05 23:22:07
What is the right way to receive and send arrays over COM? Here's my attempt so far: a safearray of doubles wrapped in a variant. //takes variant holding safearray of doubles //returns a similar variant having multipled every element by 2 STDMETHODIMP MyComClass::safearraytimestwo(VARIANT in, VARIANT* out) { CComSafeArray<double> sa_in; sa_in.Attach(*in.pparray); ULONG size = sa_in.GetCount(); CComSafeArray<double> *out_sa = new CComSafeArray<double>(size); for (long i=0;i<size;i++) out_sa->SetAt(i,sa_in[i]*2); out = new CComVariant(out_sa); return S_OK; } Problems: - currently compilation

Can we use COM objects in C# project?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 23:17:04
I have made a C# COM object by following the tutorial. http://www.codeproject.com/Articles/18939/C-Com Now I want to use this in C#. When I go to add reference \ com \ myComObject it gives me error. It says that the library was imported from a .NET assembly and cannot be added. Add a reference to the .NET assembly instead. I think it is saying it is a com visible .net assembly and you should add the .net assembly directly as a .net assenbly. The technique you link to is how to write a .net assemby that can be referenced from VB6. There is no need to add this as a com reference to a .net

Undefined reference to CLSID_MMDeviceEnumerator and IID_IMMDeviceEnumerator

做~自己de王妃 提交于 2019-12-05 22:38:32
Trying to compile an example code using COM and CoCreateInstance() using MinGW-w64 in C fails. #include <windows.h> #include <mmdeviceapi.h> #include <endpointvolume.h> #include <stdlib.h> #include <stdio.h> extern const CLSID CLSID_MMDeviceEnumerator; extern const IID IID_IMMDeviceEnumerator; int main( void ) { CoInitialize( NULL ); LPVOID device = NULL; const HRESULT ok = CoCreateInstance( &CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, &device ); CoUninitialize(); return EXIT_SUCCESS; } Compiling with: gcc main.c libole32.a -Wall -Wextra -o a Even though

CoCreateInstance exact match in .NET?

巧了我就是萌 提交于 2019-12-05 22:35:31
I have in-proc (DLL) COM Server, but I settled in to run as DllSurrogate, for this reason from unmanaged code (Delphi) i have: function TComWrapper.GetServer: IUnknown; begin OleCheck(CoCreateInstance(ServerData^.ClassId, nil, CLSCTX_LOCAL_SERVER, IUnknown, Result)); end; from C# am using now: [DllImport("ole32.dll", EntryPoint = "CoCreateInstance", CallingConvention = CallingConvention.StdCall)] static extern UInt32 CoCreateInstance([In, MarshalAs(UnmanagedType.LPStruct)] Guid rclsid, IntPtr pUnkOuter, UInt32 dwClsContext, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs

How to use PowerShell to access methods and properties of a Third-Party OLE DLL?

Deadly 提交于 2019-12-05 21:34:06
I am trying to write a PowerShell script which could access methods and properties of a third-party OLE DLL. The software vendor provided a working example in vbscript to achieve the same result. Below is an excerpt of the codes: Set objOLE = CreateObject("NETIQOLE.APPMANAGER") objOLE.Logon strInstance, strRepository, strUserID, strPwd ... However, when I tried to code in PowerShell as below: $objOLE = New-Object -ComObject "NETIQOLE.APPMANAGER" $objOLE | Get-Member I got output below and didn't see any relevant method or property. TypeName: System.__ComObject Name MemberType Definition ---- -

MultiThreading COMObject and UI Thread (C#)

岁酱吖の 提交于 2019-12-05 21:16:04
This is my first post here as actually i usually solve all my issue with the awesome post database you can find here. But I'm actually stuck right now: I'm working on a project following the MVVM including a COM object. As I read during my research, I understand that the COM object is only accessible from the thread which created it. My COM object implements the following interface interface IComUpdate { void Update(); } So when I create my COM object, each time there is an update (I dont know when, its random) the COM Server will call the Update() of the COM object class I did implement. My

C# Proper Way to Close Multiple Excel Objects With Excel Process Destroyed

与世无争的帅哥 提交于 2019-12-05 21:13:15
I have a C# console program. When it runs, it instantiates some Excel objects such as: (openExcelO). When the program is done running, I have a method to close down Excel (closeExcel) and that is supposed to properly clean up the Excel process. In task manager I can see the remnants of Excel that remain. The shut down routines were cobbled together from internet examples: private void openExcelO (string dir) { try { xlApp = new Excel.Application(); xlWorkBook = xlApp.Workbooks.Open(dir + "PortfolioOptimization5.xlsm", 0, false, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform

Why is my DLL failing to register?

自作多情 提交于 2019-12-05 20:37:51
I am building a project in VS2005 and several of my DLLs are failing to register. The error message I am getting in Visual Studio is: Project : error PRJ0019: A tool returned an error code from "Registering ActiveX Control..." which is nicely vague. When I register the DLL manually through the command line (using regsv32.exe , I get the following error: LoadLibrary("test.ocx") failed - This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix the problem. I ran Dependency Walker ( depends.exe ) on the culprit .ocx file but it

How to implement a simple add-in for MS Excel on C++

无人久伴 提交于 2019-12-05 20:35:19
I need a help for implementing add-in for Excel 2010 or higher on C++, the only functionality of this add-in is renaming of current Excel sheet. The add-in should create new custom tab on the Ribbon with name: “Test Add-in”, this tab contains group with name “My Functionality”, this group contains large button with some picture with name “Rename Current Sheet”. After clicking on the button, I should show the following dialog: User can enter new name, click ok and after this, the name of current sheet will be changed. I understand that I need to use #import directive for getting references to

Problem creating COM-library only containing enum's

人盡茶涼 提交于 2019-12-05 20:33:19
I'm am doing a COM-interop project. Substituting some VB and C++ ATL COM projects with C# and .NET Interop. When i define enumerations in .NET and they are made ComVisible, they get exposed as Typelib.EnumType_EnumValue enstead of just Typelib.EnumValue. The typelib exporter does this to ensure that the value names are unique. But i know that all my enum's are unique, so i don't want the underscores. Also there is a lot of client code that needs alteration if i don't get rid of the underscores. To find a solution to this problem, i have defined the enum's in an IDL-file and creating a typelib