com

Expose an event handler to VBScript users of my COM object

Suppose I have a COM object which users can access via a call such as: Set s = CreateObject("Server") What I'd like to be able to do is allow the user to specify an event handler for the object, like so: Function ServerEvent MsgBox "Event handled" End Function s.OnDoSomething = ServerEvent Is this possible and, if so, how do ...

Sample code for using IBM's PCOMM in C# o write an as400 screenscraper

Has anybody used C# to write a sample screen scraper for IBM as400? ...

Windows Server 2008: COM error: 0x800706F7 - The stub received bad data

I'm evaluating Server 2008. My C++ executable is getting this error. I've seen this error on MSDN that seems to have required a hot-fix for several previous OSes. Anyone else seen this? I get the same results for the 32 & 64 bit OS. Code snippet: HRESULT GroupStart([in] short iClientId, [in] VARIANT GroupDataArray, [out] short* pGr...

How do you unit-test code that interacts with and instantiates third-party COM objects?

One of the biggest issues currently holding me back from diving full steam into unit testing is that a really large percentage of the code I write is heavily dependent on third-party COM objects from different sources that also tend to interact with each other (I'm writing add-ins for Microsoft Office using several helper libraries if yo...

Exposing nested arrays to COM from .NET

I have a method in .NET (C#) which returns string[][]. When using RegAsm or TlbExp (from the .NET 2.0 SDK) to create a COM type library for the containing assembly, I get the following warning: WARNING: There is no marshaling support for nested arrays. This warning results in the method in question not being exported into the gener...

How do you efficiently copy BSTR to wchar_t[] ?

I have a BSTR object that I would like to convert to copy to a wchar__t object. The tricky thing is the length of the BSTR object could be anywhere from a few kilobytes to a few hundred kilobytes. Is there an efficient way of copying the data across? I know I could just declare a wchar_t array and alway allocate the maximum possible data...

Should I use a state machine or a sequence workflow in WF?

I have a repeatable business process that I execute every week as part of my configuration management responsibilities. The process does not change: I download change details into Excel, open the spreadsheet and copy out details based on a macro, create a Word document from an agenda template, update the agenda with the Excel data, creat...

How to iterate over all the page breaks in an Excel 2003 worksheet via COM

I've been trying to retrieve the locations of all the page breaks on a given Excel 2003 worksheet over COM. Here's an example of the kind of thing I'm trying to do: Excel::HPageBreaksPtr pHPageBreaks = pSheet->GetHPageBreaks(); long count = pHPageBreaks->Count; for (long i=0; i < count; ++i) { Excel::HPageBreakPtr pHPageBreak = pHPag...

Assistance porting commctrl commands to C#

In a C++ app, I have an hWnd pointing to a window running in a third party process. This window contains controls which extend the COM TreeView control. I am interested in obtaining the CheckState of this control. I use the hWnd to get an HTREEITEM using TreeView_GetRoot(hwnd) from commctrl.h hwnd points to the window and hItem is retur...

What does COINIT_SPEED_OVER_MEMORY do?

When calling CoInitializeEx, you can specify the following values for dwCoInit: typedef enum tagCOINIT { COINIT_MULTITHREADED = 0x0, COINIT_APARTMENTTHREADED = 0x2, COINIT_DISABLE_OLE1DDE = 0x4, COINIT_SPEED_OVER_MEMORY = 0x8, } COINIT; What does the suggestively titled "speed over memory" value do? Is it ignored...

.Net 2.0: How to subscribe to a event publisher on a remote computer using transient subscriptions?

My problem is that I want to have a server application (on a remote computer) to publish certain events to several client computers. The server and client communicate using .Net-Remoting so currently I am using remoted .Net-Events to get the functionality. But there is one drawback: when the server (the event publisher) comes offline and...

Using Component Object Model (COM) on non-Microsoft platforms

I'm regularly running into similar situations : I have a bunch of COM .DLLs (no IDL files) which I need to use and invoke to be able to access some foreign (non-open, non-documented) data format. Microsoft's Visual Studio platform has very nice capabilities to import such COM DLLs and use them in my project (Visual C++'s #import directi...

How To Read Active Directory Group Membership From PHP/IIS using COM?

I have the following code: $bind = new COM("LDAP://CN=GroupName,OU=Groups,OU=Division,DC=company,DC=local"); When I execute it from a command-prompt, it runs fine. When it runs under IIS/PHP/ISAPI, it barfs. Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `LDAP://CN=...[cut]...,DC=local': An...

Firing COM events in C++ - Synchronous or asynchronous?

I have an ActiveX control written using the MS ATL library and I am firing events via pDispatch->Invoke(..., DISPATCH_METHOD). The control will be used by a .NET client and my question is this - is the firing of the event a synchronous or asynchronous call? My concern is that, if synchronous, the application that handles the event coul...

What is the most efficient way to handle the lifecycle of an object with COM interop?

I have a Windows Workflow application that uses classes I've written for COM automation. I'm opening Word and Excel from my classes using COM. I'm currently implementing IDisposable in my COM helper and using Marshal.ReleaseComObject(). However, if my Workflow fails, the Dispose() method isn't being called and the Word or Excel handles ...

C# COM Office Automation - RPC_E_SYS_CALL_FAILED

I'm writing a C# program that acts as a PowerPoint 2007 plugin. On some machines, some calls to the PowerPoint object model throws a COMException with the message RPC_E_SYS_CALL_FAILED. I couldn't find any specific advice on what to do regarding this error, or how to avoid it. From Googling it looks like something to do with the message ...

How to determine the amount of memory used by unmanaged code

I'm working against a large COM library (ArcObjects) and I'm trying to pinpont a memory leak. What is the most reliable way to determine the amount of memory used by unmanaged code/objects. What performance counters can be used? ...

QDrag destroyed while dragging

I have a Windows/Linux Qt 4.3 application that uses drag and drop in a QTreeView. I have two very similar applications which use the same set of Qt libraries. Drag and drop works in both on Linux but in only in one on Windows. In the application that does not work the QDrag object gets deleted as soon as the mouse is moved. I...

How to refer to the path to an assembly in the GAC within registry entries added by a Windows Installer package?

I have a .NET assembly that contains classes to be registered as ServicedComponent through EnterpriseServices (COM+) and invoked through COM RPC by a third-party application. Therefore, I need to both add it to the GAC and add a registry entry under HKEY_CLASSES_ROOT\CLSID\{clsid}\CodeBase with the path to the assembly DLL within the GA...

Unit-testing COM written in .NET

Is there a way to unit-test COM-visible .NET assemblies from .NET (not via direct .NET assembly reference)? When i add reference in my test project to the COM component whitten in .NET it complains. ...