473,811 Members | 2,717 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with ATL COM code for a kind of collection !

Hello! I have been looking for a VB 6 collection like object (BUT
Faster) for some time now without success.
Not being a C++ programmer the thought of writting my collection/map
type COM Object didn't make my days very sunny.
Anyway I google for some code and I found something that manages to be
as slow as VB6 collection ;(

The Item method returns a variant and I wondered if returning wouldn't
be faster (I just want to return COM objects). SO i tried to make some
changes:
I'm posting the code I wrote (It compiles but I use It from VB6 it
returns something but aparently not an object?!

The goal is to create a fast (faster than VB6 collection)
map/collection to map BSTR to COM Objects.

Any help would be appreciated.
Thanks for your attention and help.
Jorge C.

std::map< CAdapt< CComBSTR >, IUnknown* > m_map;

STDMETHOD(get_I temV3)(BSTR Key, IUnknown** ppVal)
{

HRESULT hr = S_OK;
CComBSTR var=Key;

std::map< CAdapt< CComBSTR >, IUnknown* >::iterator it;

it = m_map.find(var) ;
if (it == m_map.end())
return E_FAIL;
IUnknown* pElement;
// Get the item
pElement = (*it).second;

// Put the IUnknown into pItem (Also implicit AddRef())
return pElement->QueryInterface (IID_IUnknown, (void**) &ppVal);

//return S_OK;
}

STDMETHOD(AddV3 )(VARIANT Key, IUnknown* pValue)
{
// Get a BSTR from the VARIANT
CComBSTR str;
HRESULT hr = VCUE::GenericCo py<BSTR, VARIANT>::copy( &str, &Key);

// If we can't convert to a string, just return
if (FAILED(hr))
return hr;

// Check whether item already exists
if (m_map.find(str ) != m_map.end())
return E_FAIL; // item with this key already exists

// Add the item to the map
m_map[str] = pValue;
pValue->AddRef();
return S_OK;
}

May 7 '06 #1
1 2437
"rdc02271" <rd******@yahoo .com> schrieb im Newsbeitrag news:11******** **************@ e56g2000cwe.goo glegroups.com.. .
STDMETHOD(get_I temV3)(BSTR Key, IUnknown** ppVal) .... return pElement->QueryInterface (IID_IUnknown, (void**) &ppVal);


This should be
return pElement->QueryInterface (IID_IUnknown, (void**) ppVal);

or better

(*ppVal) = pElement;
(*ppVal)->AddRef();
return S_OK;

For more detailed answers try microsoft.publi c.vc.atl.

HTH
Heinz
May 7 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
293
by: Stephen | last post by:
I am trying to compare the tables in two similar environments using the SQLDMO object. I am able to use this object to access different SQL servers and choose two different databases. The versions of the databases are slightly different so I would like to be able to compare them for things like datatypes, primary and foreign keys, number of records etc. I know that there are packages out there that do this kind of thing but I have to...
9
2942
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with a device. The definition of the table is as follows: CREATE TABLE devicedata ( device_id int NOT NULL REFERENCES devices(id), -- id in the device
8
5484
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
8
477
by: frank | last post by:
Below is some code for doing and insert into one of my tables. The inserts do not work because a duplicate key exists, which I want to happen. The problem is, I cannot get access to return an error for this condition. What can I do to get access to return an error on my query? Thanks
1
1707
by: Tim | last post by:
Hi, I'm very new to .NET and am programming in C#. I have a web application where i have two list boxes. Its kind of like a shopping card where you can add items from one 'locations' list box to the 'locations selected' (cart) listbox. I have a hirarchy of locations - main locations and sub locations. main locations being the parent locations, and the sub locations being the child locations. I want to be able to check to see if the...
5
1523
by: Tim::.. | last post by:
Hi can someone please tell me how I change this directory service query so that it searches through each record in the active directory and returns all the accounts! At the moment I can only get the query to return one account at a time! I presume I have to create some kind of loop on the following so I return all the users SAM info???? Dim SamAccount As String = Right(inSAM, Len(inSAM) - InStr(inSAM, "\"))
7
7143
by: Satish | last post by:
Hi Friends I am little confused about the shadows keyword in VB.NET could anyone explain with an example about Shadows keyword Many thanks Satish
83
7884
by: deppy_3 | last post by:
Hi.I am started learning Programm language C before some time.I am trying to make a programm about a very simple "sell shop".This programm hasn't got any compile problem but when i run it i face some other ploblems which i can not correct.I would appreciated if someone take a look at my programm so as to help me.I tried many times to find out where my mistakes are but i didn't manage something. I have made some comments due to the programm...
2
10051
by: hcaptech | last post by:
This is my Test.can you help me ? 1.Which of the following statement about C# varialble is incorrect ? A.A variable is a computer memory location identified by a unique name B.A variable's name is used to access and read the value stored in it C.A variable is allocated or deallocated in memory during runtime D.A variable can be initialized at the time of its creation or later 2. The.……types feature facilitates the definition of classes...
0
9728
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10648
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10389
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9205
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6890
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3867
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.