|
While a BSTR can technically contain any data at all, it's most often used to hold a C-style (zero-terminated) UTF-16 string. Many BSTR wrappers also make the same assumption. Step into the COleVariant code and see if it is doing this.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
VB > soccer
|
|
|
|
|
If no other solution, you can use an alternative approach, based on STL strings: std::wstring for Unicode or std::string for ANSI. This kind of strings allows null character within the string.
For instance:
std::wstring s = L"abc";
s += L'\0';
s += L"def";
size_t length = s.length();
wchar_t c;
c = s[2];
c = s[3];
c = s[4];
const wchar_t * p = s.c_str();
Next, if you need this as OLE variant, I think you can use "safe arrays" for this. For instance, this fragment copies the above string to a safe array:
CComSafeArray< USHORT > sa;
sa.Add(s.length() + 1, (USHORT*)p);
Hope it helps.
-- modified at 3:58 Friday 16th June, 2006
|
|
|
|
|
Thanks for the suggestions. I managed to fix(hack) it. I was already using safe arrays as the task I'm performing must communicate with older COM and OLE objects. The problem seemed to be an error in one of the OLE cpp files in the MSVS directory. It seemed to call a standard strlen function regardless of the input type so I've changed the code to check for unicode and call wcslen if needed.
When I die I'd like to go peacefully in my sleep like my father, not screaming in terror like his passengers!!!
|
|
|
|
|
hi,
I got your reply and i follow it and i set up all directories which you mention in mail and ide also. you send me path and i click that path i got the page microsoft and in this page there some resolution and i follow the 2nd resolution in which the spawning error is mention and some process how you eliminate spawning error. but i am not succed in that i properly follow the step but still i got spawning error. tell the region how can i eliminate the spawning vcspawn.exe error.
Thanks
Nitin Dalal.
nitin
|
|
|
|
|
In my view, you should just uninstall visual studio or visual c++ what ever you have installed and reinstall it.
It would take not more then 30 min. Do it and then tell us if problem remains.
Wishing you best of luck...
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
hi,
It's nitin and you sent me answer of my question thanks for that.
because i am struggling with this error from three days and you me good solution.
once again thanks for that.if you have personal mail then send me back.
my e-mail: nitin.dalal@tatatechnologies.com and nitinb2004@yahoo.co.in.
Thanks...........
Nitin dalal
Tata technologies ltd.
Pune.
nitin
|
|
|
|
|
Can anybody temme how do i write/save a web page retrieved from internet server as a complete htm document..wid d accompanying folder containing all graphics,images?
Foll is a code which writes just d htm document on2 d disk of my m/c...
CString url2;
url2="www.google.com";
CString filepath;
filepath = "E:";
CString url3=url2.Mid(11,7);
filepath+=url3;
filepath+=".htm";
CFile myfile(filepath, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
//buf=where the page read is stored
//len=length of page read
while ((numread = pFile->Read(buf,len)) > 0)
{
myfile.Write(buf, numread);
}
myfile.Close();
|
|
|
|
|
See this:
http://www.codeguru.com/cpp/i-n/ieprogram/article.php/c4397/
Cheers
"Peace of mind through Technology"
|
|
|
|
|
Hi Guys,
Can u please refer some source code for studying Database access using MFC. What I need is, how to access a database ( say Microsoft Access ) through an MFC program.
Regards
Velayudhan
|
|
|
|
|
See Here[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thank You
|
|
|
|
|
Hi,
I have the following prototype in ActiveX to send the Array from my client program. The variable VarArray contains array of values, Can you please provide me an example to get the values of each index by using SafeArray.
void CSimpleAdditionAtxCtrl::Final(VARIANT* VarArray)
{
}
|
|
|
|
|
VARIANT varBuffer;
------------------
if(varBuffer.vt==(VT_ARRAY|VT_UI1))
{
DWORD dwSize=varBuffer.parray->rgsabound[0].cElements;
BYTE lpBuffer=new BYTE[dwSize];
memcpy( lpBuffer , varBuffer.parray->pvData,dwSize);
delete []lpBuffer;
}
alantop
|
|
|
|
|
sivaprakashshanmugam wrote: I have the following prototype in ActiveX to send the Array from my client program. The variable VarArray contains array of values, Can you please provide me an example to get the values of each index by using SafeArray.
Here m_vecIcecreamFlavors and m_vecIcecreamPrices are vecters of BSTR and float resp.
SAFEARRAYBOUND safeBound[2]; <br />
<br />
safeBound[0].cElements = m_vecIcecreamFlavors.size(); <br />
safeBound[0].lLbound = 0;<br />
<br />
safeBound[1].cElements = m_vecIcecreamPrices.size();<br />
safeBound[1].lLbound = 0 ;<br />
<br />
<br />
VariantInit(VarArray);<br />
pVariant->vt = VT_VARIANT | VT_ARRAY; <br />
pVariant->parray = SafeArrayCreate(VT_VARIANT,2,safeBound);<br />
<br />
<br />
std::vector<CComBSTR>::iterator iterFlavor;<br />
std::vector<float>::iterator iterPrices;<br />
<br />
<br />
<br />
long lDimension[2];<br />
int iFlavorIndex = 0;<br />
<br />
<br />
iterPrices = m_vecIcecreamPrices.begin();<br />
iterFlavor = m_vecIcecreamFlavors.begin(); <br />
<br />
<br />
while(iterFlavor != m_vecIcecreamFlavors.end()) <br />
{<br />
<br />
<br />
lDimension[1] = iFlavorIndex;<br />
lDimension[0] = 0;<br />
CComVariant variantFlavor(SysAllocString((*iterFlavor).m_str));<br />
SafeArrayPutElement(pVariant->parray,lDimension,&variantFlavor);<br />
<br />
<br />
<br />
lDimension[1] = iFlavorIndex;<br />
lDimension[0] = 1;<br />
CComVariant variantPrices(*iterPrices);<br />
SafeArrayPutElement(pVariant->parray,lDimension,&variantPrices);<br />
<br />
<br />
iFlavorIndex++;<br />
iterPrices++;<br />
iterFlavor++;<br />
<br />
<br />
}
Suppose Variant result is parameter passed for fillup then we can retrive the elements from the array as follows.
long lUDimension,lLDimension;<br />
<br />
SafeArrayGetUBound(result->parray,2,&lUDimension);<br />
SafeArrayGetLBound(result->parray,2,&lLDimension);<br />
VARIANT val[2];<br />
long Dimension[2];<br />
<br />
for(LONG i=lLDimension;i<=lUDimension;i++)<br />
{<br />
m_Data.InsertItem(i," ");<br />
Dimension[0]=0;<br />
Dimension[1]=i; <br />
HRESULT hr=SafeArrayGetElement(result->parray,Dimension,(void*)&val[0]);<br />
if(FAILED(hr))<br />
AfxMessageBox("Unable to read 1 element");<br />
m_Data.SetItemText(i,0,_com_util::ConvertBSTRToString(val[0].bstrVal));<br />
Dimension[0]=1;<br />
Dimension[1]=i; <br />
hr=SafeArrayGetElement(result->parray,Dimension,(void*)&val[1]);<br />
if(FAILED(hr))<br />
AfxMessageBox("Unable to read 2 element");<br />
m_Data.SetItemText(i,1,_com_util::ConvertBSTRToString(val[1].bstrVal));<br />
}
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
how can you make a listboxctrl show what line is selected without clicking on the line? a list of mp3's say i click the first one its hilited but when i click the next button i need it to hilite that one but i cant figure it out i tryed all the commands i could find.
|
|
|
|
|
Which control r u using ListCtrl or Listbox ?
nave
|
|
|
|
|
im using listctrl. sorry about that.
|
|
|
|
|
Use :
<br />
GetSelectionmark() <br />
SetSelectionMark()
Cheers
"Peace of mind through Technology"
|
|
|
|
|
ive tryed them everything works but it does not highlite the new line
|
|
|
|
|
locoone wrote: how can you make a listboxctrl show what line is selected without clicking on the line? a list of mp3's say i click the first one its hilited but when i click the next button i need it to hilite that one but i cant figure it out i tryed all the commands i could find.
See the following API's
SetItemState(...) in CListCtrl control
SetCurSel(...) in CListBox control
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
for SetitemState this is copied from msdn
nState
New values for the state bits.
nMask
Mask specifying which state bits to change
i dont know what they are asking for i cant find anything on what i should put in themi mean does nState mean CHECKED or WM_CHECKED i have no clue what they want.
|
|
|
|
|
If the fous is not current in the listctrl, set the Focus to listctrl using
SetFocus()
Then call
SetItemState( nItem, LVIS_SELECTED , LVIS_SELECTED );
nave
|
|
|
|
|
well that makes it highlite the next one but the firstone doesnt unhighlite im tired i might just be missing something will check tomorrow
|
|
|
|
|
Set the Single Selection style( LVS_SINGLESEL ) of the List ctlr. If this style is set only one item in the list ctrl will be selected at a time.
nave
|
|
|
|
|
that worked thanks dude
something is wrong somewhere my listctrl var is m_list but when i type m_list. it dont popup that windows with all the things i can do.
-- modified at 4:27 Saturday 17th June, 2006
|
|
|
|