|
If that really is a security feature, then one of two things is up:
The functionality you are trying to use is not being used correctly or is undocumented, and just used to work before things were fixed/changed -or-
There is a bug in the MSVCRT.DLL provided in Vista.
All things being equal - I would presume the former, no offense intended, otherwise Vista would not be backward compatible and that is a rather stupid thing to do.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Hello,
When I use the insert function in vector from STL the pointer becomes invalid from the point where it was inserted.
So how do I use the next elements from the vector
Prithaa
|
|
|
|
|
please show how you're doing thing ?
|
|
|
|
|
Hello,
class CRICH
{
};
vector<CRICH*>m_table;
CRICH *CRICHobj = new CRICH;
m_table.insert(&m_table[2],1,CRICHobj);
Now the pointers after 2 become invalid if I already have vector of about 10 elements of CRICH*
Prithaa
|
|
|
|
|
can't you just us std::vector<>::push_back() ?
|
|
|
|
|
Hello,
But how does a insert work.I want to insert elements in betweeen a vector.
How reorganize invalid pointers
Prithaa
|
|
|
|
|
class CRICH {};
vector<CRICH*> m_table;
CRICH *CRICHobj = new CRICH;
m_table.push_back(CRICHobj);
the danger with with a vector of pointer (rather than a pointer of objects, is that you have to be very careful with memory leaks.
when removing an element from the vector, you should always think to delete it.
for instance, when cleaning the vector:
vector<CRICH*>::iterator it;
for (it = m_table.begin(); it != m_table.end(); it++) {
delete(*it);
}
m_table.clear();
the best is still to declare a vector<CRICH> m_table (by object), and then, only add objects like this :
CRICH CRICHobj = CRICH();
m_table.push_back(CRICHobj);
then, no need to care about deletes, and you can just do a m_table.clear()
|
|
|
|
|
Hello,
Thanks for the details of vector of pointers.
But then what should I do about the insert in a vector.
How can I access the all the elements of the vector once I insert
Prithaa
|
|
|
|
|
prithaa wrote: But then what should I do about the insert in a vector
i shown you the code !!!
prithaa wrote: How can I access the all the elements of the vector once I insert
hum, you should learn about iterators...
|
|
|
|
|
Hello,
Thanks for your support and replies
I'll check up iterators.
Thanks
Prithaa
|
|
|
|
|
prithaa wrote: Now the pointers after 2 become invalid if I already have vector of about 10 elements of CRICH*
what do you mean by that ? do you keep external pointers ( outside of the vector ? ) to those objects ?
inserting in the middle of a vector will invalidate the iterators, but should not invalidate the pointers.
for example, p4 is still a valid pointer to the element.
std::vector<patate*> myVectorPatate;
patate* p = new patate( 1 );
myVectorPatate.push_back( p );
p = new patate( 2 );
myVectorPatate.push_back( p );
p = new patate( 3 );
myVectorPatate.push_back( p );
patate* p4 = new patate( 4 );
myVectorPatate.push_back( p4 );
p = new patate( 5 );
myVectorPatate.push_back( p );
p = new patate( 6 );
myVectorPatate.push_back( p );
p = new patate( 7 );
myVectorPatate.push_back( p );
for ( unsigned int i = 0; i < myVectorPatate.size(); i++ )
{
patate* p = myVectorPatate[i];
std::cout << p->m_i << std::endl;
}
p = new patate( 33 );
myVectorPatate.insert( myVectorPatate.begin() + 2, p );
for ( unsigned int i = 0; i < myVector.size(); i++ )
{
patate* p = myVectorPatate[i];
std::cout << p->m_i << std::endl;
}
|
|
|
|
|
Hello,
So the pointers do not become invalid is what you mean
Prithaa
|
|
|
|
|
I cannot solve something for days now.
I am using a CCheckListBox component in my application, and it works nicely. I decided to set the project to be statically linked. After solving some issues with linking, it was running. However, I could see nothing in the listbox! It was working for some extent, as clicking on the 'invisible' items, the desired thing has happened, but the items were missing. I set back to dynamical linking, and it was working again, so I suspect it might not be a bug in my code..?
When I set the 'owner-draw style' and 'has strings' attribute to false, (after some commenting out...), at least the text has appeared there with statical linking, but I cannot get further than this.. Can anybody help me?.. I am getting desperate..
|
|
|
|
|
Magonnew wrote: When I set the 'owner-draw style' and 'has strings' attribute to false...
CCheckListBox is only for owner-drawn controls.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I know that, but I was desperate enough to even try that.
|
|
|
|
|
I have got the following function, that formats the string with dynamic params, but here i am using MFC CString class and its method AppendFormatV
void FormatStringWithDynamicParams(LPCTSTR lpszFormat, ...)<br />
{<br />
<br />
va_list args;<br />
va_start(args, lpszFormat);<br />
<br />
CString strMsg;<br />
strMsg.AppendFormatV(lpszFormat, args);<br />
}<br />
<br />
CString strTest="Test";<br />
DWORD dwTest=233;<br />
FormatStringWithDynamicParams("Here is one dynamic param :%s ",strTest);<br />
FormatStringWithDynamicParams("Here are 2 dynamic params:%s:%d ",strTest,dwTest);
Here it is working for both of the function calls, but i want above feature, without using MFC, i.e not using CString class, can any one help me in that.
Warm Regards,
Mushq
|
|
|
|
|
Are you looking for vsprintf() ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
::_vsntprintf(...)
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Thanks Paresh.
But I want to know which API system uses to create a folder on vista. It is not CreateDirectory.
|
|
|
|
|
Santosh - The DON wrote: But I want to know which API system uses to create a folder on vista.
CreateDirectory().
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
It's not CreateDirectory(), I have tried using API Monitor, may be some shell's API.
Anyway thanks!
|
|
|
|
|
You didn't read the documentation. CreateDirectory() is available for use on Vista. Have you taken into consideration that you are using it incorrectly, or that perhaps it is a permission-related issue?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
eventually the Shell will call it.
|
|
|
|
|
( keep in mind I don't have Vista )
SHCreateDirectory() ?
|
|
|
|
|