atl

How to best convert CString to BSTR to pass it as an “in” parameter into a COM method?

六眼飞鱼酱① 提交于 2019-12-01 03:41:04
I need to convert a CString instance into a properly allocated BSTR and pass that BSTR into a COM method. To have code that compiles and works indentically for both ANSI and Unicode I use CString::AllocSysString() to convert whatever format CString to a Unicode BSTR. Since noone owns the returned BSTR I need to take care of it and release it after the call is done in the most exception-safe manner posible and with as little code as possible. Currently I use ATL::CComBSTR for lifetime management: ATL::CComBSTR converted; converted.Attach( sourceString.AllocSysString() ); //simply attaches to

ATL simple object wizard - “Object Xxx already exists” error

对着背影说爱祢 提交于 2019-12-01 03:14:39
问题 I am attempting to create a new COM object in my DLL using the ATL Simple Object Wizard in Visual Studio 2005. I enter the short name for the object, and all of the other fields are derived. However, when I click Next in the wizard, the following error message comes up: Object 'IXxxInterfaceName' already exists I have searched my entire solution for all references to IXxxInterfaceName and can't see it defined anywhere. How is the wizard determining that it exists already? 回答1: I never found

_stdcallthunk

↘锁芯ラ 提交于 2019-12-01 00:02:08
// c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\atlmfc\include\atlstdthunk.h // This is a part of the Active Template Library. // Copyright (C) Microsoft Corporation // All rights reserved. // // This source code is only intended as a supplement to the // Active Template Library Reference and related // electronic documentation provided with the library. // See these sources for detailed information regarding the // Active Template Library product. #ifndef __ATLSTDTHUNK_H__ #define __ATLSTDTHUNK_H__ #pragma once #pragma push_macro("new") #undef new

Exposing COM events to VBScript (ATL)

旧城冷巷雨未停 提交于 2019-11-30 23:01:24
I have built a COM server DLL in C++ with ATL by using the "ATL simple object" wizard. I followed Microsoft's ATLDLLCOMServer example. Everything works well except for one thing: I do not receive COM events in VBScript . I do receive the events in C#. I had events working in VBScript in an earlier MFC-based implementation as ActiveX control. My control is defined like this: class ATL_NO_VTABLE CSetACLCOMServer : public CComObjectRootEx<CComSingleThreadModel>, public CComCoClass<CSetACLCOMServer, &CLSID_SetACLCOMServer>, public IConnectionPointContainerImpl<CSetACLCOMServer>, public CProxy

Exposing managed events to COM using C++

我怕爱的太早我们不能终老 提交于 2019-11-30 21:38:51
问题 It is possible to exposed managed events written in C# to be exposed and used in a COM object written using c++. not being that familiar with com and atl. Can you please show what would the C++ side of things would look like for the example shown in the MSDN article http://msdn.microsoft.com/en-us/library/dd8bf0x3.aspx The VB6 code shown proves that it is doable. 回答1: The easiest way in C++ would be, IMO, to implement an event sink with help of ATL's IDispEventImpl and IDispEventSimpleImpl

332. Reconstruct Itinerary

拈花ヽ惹草 提交于 2019-11-30 17:51:21
1. 题目描述 Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus, the itinerary must begin with JFK . Note : 1. there are multiple valid itineraries, you should return the itinerary that has the smallest lexical order when read as a single string. For example, the itinerary ["JFK", "LGA"] has a smaller lexical order than ["JFK", "LGB"]. 2. You may assume all tickets form at least one valid itinerary. Example 1: Input: [["MUC", "LHR"], ["JFK", "MUC"], ["SFO

Warning C4251 when building a DLL that exports a class containing an ATL::CString member

て烟熏妆下的殇ゞ 提交于 2019-11-30 08:17:04
I am converting an ATL-based static library to a DLL and am getting the following warning on any exported classes that use the ATL CString class (found in atlstr.h): warning C4251: 'Foo::str_' : class 'ATL::CStringT' needs to have dll-interface to be used by clients of class 'Foo' I am correctly declaring the Foo class as exported via __declspec(dllexport) . Is this a warning I can safely ignore or am I doing something wrong? The DLL project settings are set to dynamically link with ATL, but this doesn't seem to make any difference. For example: #ifdef DLLTEST_EXPORTS #define DLLTEST_API _

STL,ATL,WTL的联系与区别

谁说我不能喝 提交于 2019-11-29 23:47:58
STL,ATL,WTL的联系与区别 STL 即 Standard Template Library STL(标准模板库)是惠普实验室开发的一系列软件的统称。它是由Alexander Stepanov、Meng Lee和David R Musser在惠普实验室工作时所开发出来的。现在虽说它主要出现在C++中,但在被引入C++之前该技术就已经存在了很长的一段时间。 STL的代码从广义上讲分为三类:algorithm(算法)、container(容器)和iterator(迭代器),几乎所有的代码都采用了模板类和模版函数的方式,这相比于传统的由函数和类组成的库来说提供了更好的代码重用机会。在C++标准中,STL被组织为下面的13个头文件:<algorithm>、<deque>、<functional>、<iterator>、<vector>、<list>、<map>、<memory>、<numeric>、<queue>、<set>、<stack>和<utility>。以下笔者就简单介绍一下STL各个部分的主要特点。 原文见:http://www.csdn.net/Develop/article/16%5C16310.shtm 从根本上说,STL是一些“容器”的集合,这些“容器”有list,vector,set,map等,STL也是算法和其他一些组件的集合。这里的“容器

Use CString in console app when using VS Express

两盒软妹~` 提交于 2019-11-29 16:23:46
I have a problem when trying to use CString. I have a console application written using VS2010Express. I have a piece of code I would like to use, but it uses CString. When I try to include the appropriate header atlstr.h (as far as I know) I get the famous error: Cannot open source file. After Goggling around for a while it seems that in general it should be possible, but the atlstr.h is not available to Express users. Questions: 1) Is that right ? 2) Can I avoid this problem somehow? Below is the code, (origin: http://www.cprogramming.com/tutorial/ado_c++_wrapper_classes.html ) If anyone has

Create CImage from Byte array

北战南征 提交于 2019-11-29 15:59:52
I need to create a CImage from a byte array (actually, its an array of unsigned char , but I can cast to whatever form is necessary). The byte array is in the form "RGBRGBRGB...". The new image needs to contain a copy of the image bytes, rather than using the memory of the byte array itself. I have tried many different ways of achieving this -- including going through various HBITMAP creation functions, trying to use BitBlt -- and nothing so far has worked. To test whether the function works, it should pass this test: BYTE* imgBits; int width; int height; int Bpp; // BYTES per pixel (e.g. 3)