com

VBScript “Type Mismatch” issue with “[in, out] BSTR * ” parameter

烂漫一生 提交于 2019-12-02 00:29:40
I'm working with third-party COM object that has some of its methods passing values back as BSTR pointer. Since VBscript supports only Variant type attempts to use in a way like Object.Method(sMyString) reasonably end with "Type mismatch" error. I suspect this error is generated by the COM object itself rather then VBscript interpreter since the object gets string instead of pointer. I tried to workaround it defining array of strings but it's still the same error. So I was wondering if someone had similar problem and what workarounds were utilized. Just to emphasize. I DO NOT have control over

When implementing several COM interfaces at once how do I upcast to IUnknown?

旧城冷巷雨未停 提交于 2019-12-01 23:32:47
Suppose my COM object implements two or more COM interfaces: class CMyClass : public IPersistFile, public IPersistStream { }; when implementing QueryInterface() I need to be able to return an IUnknown* pointer. Since both base interfaces are derived from IUnknown I cannot upcast implicitly - such upcast would be umbiguous. To upcast explicitly I need to use either of the two ways: if( iid == __uuidof( IUnknown ) ) { *ppv = static_cast<IPersistFile*>( this ); static_cast<IPersistFile*>( this )->AddRef(); return S_OK; } or if( iid == __uuidof( IUnknown ) ) { *ppv = static_cast<IPersistStream*>(

Controlling the volume of other applications

一曲冷凌霜 提交于 2019-12-01 22:33:30
I am trying to make an app that controls the volume of another process using the Windows 7 Audio API. What I'm looking for is the ISimpleAudioVolume for the session used by the other process. I have tried using the IAudioSessionEnumerator but it will only give me the IAudioSessionControl2 of the session. Using the IAudioSessionControl I have managed to receive notifications when I change the volume through sndvol but not change it myself. I have also tried using GetSimpleAudioVolume() from IAudioSessionManager but it will only give me sessions within the current process. How do you do it? It

What is a String[*] and how do I cast it?

旧时模样 提交于 2019-12-01 21:46:35
问题 I'm currently in the unfortunate position of having to call a VBA macro from C#, via the COM Interop. The macro returns an array of strings and looks something like: Public Function Foo() As String() which I'm then trying to cast to an array of strings in C# like this: var result = (string[])xlApp.Run("Foo", ... missing args ...) which then results in the runtime error: Unable to cast object of type 'System.String[*]' to type 'System.String[]'. Does anyone know what a String[*] is, and do you

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

十年热恋 提交于 2019-12-01 21:38:14
问题 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? 回答1: 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

MIDL changes the Interface name

百般思念 提交于 2019-12-01 21:28:20
I have a COM dll , which is consumed by .NET applications using COM Inter-op. In one of the CoClasses , there is an Interface called IT6TrackData and it has one get property called TrackData From the IDL file: Interface IT6TrackData { [propget, id(1)] HRESULT TrackData([out, retval] SAFEARRAY(BYTE) *pVal); } When the TLB file is viewed for the above IDL file, it shows the property as trackData ( t in lower case) For some reason the Client application were referring to this property as trackData and everything was working fine until now. As part of enhancement the above Interface was upgraded

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

佐手、 提交于 2019-12-01 21:05:23
How can I parse an unmanaged code in TLB (Of unmanaged COM server) in C#? By creating a managed wrapper using tlbimp.exe . 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

Is there any way to debug compiled components using Matlab Debugger?

怎甘沉沦 提交于 2019-12-01 21:01:11
Is there a way in which I can debug my compiled Matlab components, using native Matlab debugger, like Visual Studio "Attach to process" option, or something like that? I mean EXE stand-alone files, DLLs, COM in-process servers or .NET components. You can't debug them in the sense of being able to step through the MATLAB code line by line, as you can with MATLAB's own debugger prior to compilation. One of the steps that the MATLAB deployment products take is to encrypt the MATLAB code (so you can preserve your IP when distributing the deployed component). The ability to step through the code in

DCOM server and client both written in .NET

不打扰是莪最后的温柔 提交于 2019-12-01 20:59:42
I'm developing a DCOM server in .NET 4 (VS2010, C#). By itself, this is working fine. Now, I also need to develop a .NET client for this DCOM server, but I am unable to add a reference to the TypeLib. Visual Studio will tell me the type library was exported from a .NET assembly and cannot be added as a reference. Answers to this question suggests that I should be able to use TlbImp.exe to generate a wrapper assembly, but it will refuse to do so as well: TlbImp : error TI1029 : Type library 'MyWrapper' was exported from a CLR assembly and cannot be re-imported as a CLR assembly. I understand

Determine the Process ID of the Client Process communicating with a COM RPC Server

回眸只為那壹抹淺笑 提交于 2019-12-01 20:55:47
In a COM RPC Model, if the Server is running on a separate process, is it possible to know, the Process ID of the client Process communicating with the Server? Use Case I have an Out Process RPC Server which can receive request from one or more client process. Occasionally, the server needs to know the Client Process to write data back to the client address space using Write Process Memory . Also Note, the API Signatures, the way the buffer is getting allocated and the APIs are getting called are beyond my control. 来源: https://stackoverflow.com/questions/18770684/determine-the-process-id-of