473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problems dereferencing a variant

I downloaded some code from MSDN to allow the upload of a
file from an ASP page. I know that .NET can do this in an
easire fashion but converting all the code would just be
too much of a pain in the butt. The code works fine and I
can upload a file however when it processes the form it
does not expose the names (which it stores as a key in a
stl::map and also in a stl::set) of the input items it
loads into the CDictionary class. When I try to
dereference the key in the set I get a failure in the ASP
page. Here is the code;
typedef std::map<CComVariant, CComVariant> OurMap;
typedef std::set<CComVariant> CComVariantList;
OurMap m_map;
CComVariantList m_keys;

This is the function to return the value it works
STDMETHODIMP CDictionary::get_Item(VARIANT *key, VARIANT
*pVal)
{
if ((key->vt & ~VT_BYREF) != VT_BSTR) return
E_POINTER;

CComVariant varKey(*key);

OurMap::iterator theIterator = m_map.find(varKey);

if(theIterator == m_map.end()) {
VariantInit(pVal);
} else {
VariantCopy(pVal, &(*theIterator).second);
}
return S_OK;
}
This is my new function to return the key it does not work.
STDMETHODIMP CDictionary::get_Key(long idx, VARIANT *pVal)
{

//if ((key->vt & ~VT_BYREF) != VT_BSTR) return
E_POINTER;

//CComVariant varKey(*key);

CComVariantList::iterator i;
long j = 0;

for (i = m_keys.begin(); i != m_keys.end(); i++){
j++;
if (j == idx){

CComVariant varI = *i;

varI.Detach(pVal);

}
}

return S_OK;
}

I know that iterating through all of the elements in the
set to find a specific one to return is not the right way
but I don't have time nor the experties to write the
IDispatch Code and enum to allow the collection of keys to
be exposed so you can use a for each on it. can anybody
help?

Nov 17 '05 #1
0 1077

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

Similar topics

0
by: Matt Smith | last post by:
Hi, all. Just a quick question, when setting a COM process to read a value from a pre-defined register index, I think, I have to change the variable that the value will be returned to (as I have...
0
by: developer | last post by:
Hi All, I’m currently doing some POC testing for a new client for one of their existing applications, with the hopes of being able to migrate a lot of their existing code embedded in Excel VBA to...
0
by: pieter.breed | last post by:
Hi, background: ---------- I am the maintainer of a COM C++ dll that is used to read binary data from a specific file format. I was recently tasked to speed up the execution speed of this...
5
by: Rob | last post by:
Help me, I'm just beginning with programming in Access 2000. I've tried the http://www.mvps.org/access/api/api0001.htm but it won't work in Access. What am i doing wrong. I don't have...
4
by: Jean | last post by:
Hi all, I am trying to get this query right, but so far no joy... I have written the following code in the Field box of the QBD grid of a query: firstvalue:IIf(Not (IsNull()),,(IIf(Not...
1
by: Wayne | last post by:
I'm trying to save a report as a snapshot. If I use this code: DoCmd.OutputTo acOutputReport, "Snapshot Format (*.snp)", , False everything works fine, the file save dialogue box appears and...
1
by: David Mathog | last post by:
We've established that a line of code like: (void) function( (long *) &(something) ); may (and probably should) generate one of these warning: dereferencing type-punned pointer will break...
2
by: David | last post by:
Dear All I'm trying to use a multi-select listbox as criteria to either add new record or edit the current record of the destiantation table with each row selected in the box. This works fine...
3
by: Nathan | last post by:
Hi, I'm trying to do some network programming, but when I use 'struct addrinfo' or getaddrinfo, I see errors: gcc --std=c99 -Wall ipv6_test.c -o it ipv6_test.c: In function `main':...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...

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.