com

How to compare BSTR against a string in c/c++?

扶醉桌前 提交于 2019-12-01 03:04:47
wprintf(L"Selecting Audio Input Device: %s\n", varName.bstrVal); if(0 == strcmp(varName.bstrVal, "IP Camera [JPEG/MJPEG]"))... The above reports : error C2664: 'strcmp' : cannot convert parameter 1 from 'BSTR' to 'const char *' Brian R. Bondy You have to use wcscmp instead: if(0 == wcscmp(varName.bstrVal, L"IP Camera [JPEG/MJPEG]")) { } Here is a description of the BSTR data type , it has a length prefix and a real string part which is just an array of WCHAR characters. It also has 2 NULL terminators. The only thing to look out for is that the BSTR data type can contain embedded NULLs in the

Can I create and use a COM class without registering it in the registry?

风流意气都作罢 提交于 2019-12-01 02:14:01
I need to make a custom COM object that is going to end up looking similar to this: static const GUID IID_ClientCommunicator = { 0x5219b44a, 0x874, 0x449e,{ 0x86, 0x11, 0xb7, 0x8, 0xd, 0xbf, 0xa6, 0xab } }; static const GUID CLSID_ClientCommunicator = { 0x5219b44b, 0x874, 0x449e,{ 0x86, 0x11, 0xb7, 0x8, 0xd, 0xbf, 0xa6, 0xab } }; class ATL_NO_VTABLE CClientCommunicator: public CComObjectRootEx<CComSingleThreadModel>, public CComCoClass<CClientCommunicator, &CLSID_ClientCommunicator>, public IDispatchImpl<CClientCommunicator, &IID_ClientCommunicator, 0, /*wMajor =*/ 1, /*wMinor =*/ 0> { public:

Passing string array from VB6 to C#.net

安稳与你 提交于 2019-12-01 02:12:12
问题 How to pass a VB6 string array [Assume, s =Array("a", "b", "c", "d")] to C#.Net through COM Interop? I tried to implement passing C# string array to VB and VB string array to C# as below C#->VB working fine but other way (VB=>C#) giving a compile error called "Function or interface marked as restricted, or the function uses an automation type not supported in visual basic" . My code below C# public interface ITest { string[] GetArray(); void SetArray(string[] arrayVal ); } public class Test :

COM封装字节数组,并用于C#/c++中

混江龙づ霸主 提交于 2019-12-01 02:07:29
由于项目开发需要,原有的程序用C++开发,但是现有用C#开发,所以需要对用C++开发的接口利用COM进行封装,供c#语言调用,在此处用到一个字节数组,所以此处对其进行封装。 (一)用到的COM接口: 1.1 SAFEARRAY的创建 SAFEARRAY* SafeArrayCreate( VARTYPE vt, unsigned int cDims, SAFEARRRAYBOUND * rgsabound ); VARTYPE 数组数据的类型,此处为:VT_UI1表示1个字节的BYTE类型。具体类型如下: VT_UI1 无符号1字节整数(BYTE)数组 VT_UI2 无符号2字节整数(WORD)数组 VT_UI4 无符号4字节整数(DWORD)数组 VT_UINT 无符号整数(UINT)数组 VT_INT 有符号整数(INT)数组 VT_I1 有符号1字节整数数组 VT_I2 有符号2字节整数数组 VT_I4 有符号4字节整数数组 VT_R4 IEEE 4字节浮点数(float)数组 VT_R8 IEEE 8字节浮点数(double)数组 VT_CY 8字节定点数货币值数组 VT_BSTR VB字符串数组 VT_DECIMAL 12字节定点数(大数字)数组 VT_ERROR 标准错误编号数组 VT_BOOL 布尔值数组 VT_DATE 日期型数组 VT_VARIANT VB

Move manifest file to dll?

冷暖自知 提交于 2019-12-01 01:13:57
I'm using a third party component in my application that is distributed either as a COM component, or can be referenced using a .manifest file. Either way it is loaded using CoCreateInstance(). The files needed for the third party component reside in a subfolder. The component developer told me to include a .manifest file in the Visual Studio 2010 settings (in the "Manifest" section) of the executable, and loading the component works without problems. Now I'm using the third party component from a DLL only, to encapsulate the features used from the third party component. I'm loading the DLL

How can I start a specific excel version in com automation?

泄露秘密 提交于 2019-12-01 01:09:09
I use Excel via COM automation (in c#), but it seems that the problem has no control over what version of excel is started on the box - we use both Excel 9 and Excel 11 and one specific set of spreadsheets requires excel 9 else they wont work. I included the excel 9 com references but on another persons machine excel 11 started. How can I fix this ? Phil Price I'm unsure of the ProgId's (friendly names on CLSID Guids) used for Excel, but a quick look leads me to 'Excel.Application', as the type you might activate. Take a look under HKEY_CLASSES_ROOT, on my machine I see "Excel.Application" and

JSON.Stringify fails on Scripting.Dictionary objects

ぃ、小莉子 提交于 2019-12-01 00:46:10
I am working on an ASP classic project where I have implemented the JScript JSON class found here . It is able to interop with both VBScript and JScript and is almost exactly the code provided at json.org . I am required to use VBScript for this project by the manager of my team. It works very well on primitives and classes defined within ASP. But I have need for Dictionary objects which from my knowledge are only available through COM interop. (via Server.CreateObject("Scripting.Dictionary") ) I have the following class which represents a product: (ProductInfo.class.asp) <% Class ProductInfo

Deploying COM components with ClickOnce application

强颜欢笑 提交于 2019-12-01 00:38:11
We're developing a C# WPF (.Net 4.0) application that requires screen "recording". We've evaluated ByteScout's Screen Capture SDK (free trial available), and it does exactly what we need to it. However, the problem is that our application is designed to be deployed by ClickOnce, to our clients' machines (not on our network), and who will likely be logged in as limited, non-administrative users. The SDK has a redistributable component, but this requires to be installed separately - no good for ClickOnce. ByteScout seemingly address this need in their documentation, under the section

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

最后都变了- 提交于 2019-12-01 00:35:13
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 with IID '{5DFA18E8-4E71-4ADC-A812-6B166C242561}' failed due to the following error: No such interface

How to create a IDirect3DSurface from an IBuffer or byte array in UWP

梦想与她 提交于 2019-12-01 00:02:36
I want to create a video from a few RenderTargetBitmap s in UWP. I am doing that by using MediaClips . From RenderTargetBitmap i can get an IBuffer or byte array of pixels. To create a MediaClip I need either an image file or an IDirect3DSurface . Creating an image just to create a clip is very expensive, so I thought of using IDirect3DSurface . How can I do this? I have tried this: RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(); await renderTargetBitmap.RenderAsync(RenderedGrid, 100, 100); IBuffer pixels = await renderTargetBitmap.GetPixelsAsync(); var values = Enum