|
Don't use strlen with TCHAR strings, use the _tcslen version. All string manipulation routines have a non-unicode version, a unicode version and a version which depends on your unicode settings. You should use the last one in your case.
For your error, manipulating TCHAR strings is the same as manipulating char strings: if you want to copy the string, then you should use _tcscpy, if you only want to make the pointer points to the same address, then just assign the pointer directly:
TCHAR* cNextSection=lpszRetrunBuffer;
Warning, in that case you do not copy the string.
|
|
|
|
|
|
HI
I want to show the multiline message in a message box .
what i have done is i have taken the instruction dialog on which i have put text control
and i want my text to be put into this text control , the text is multiline.
Please provide comments
|
|
|
|
|
You have to insert the new line character ("\n") in your string:
MessageBox("This is\na mutliline\ntext","Test");
|
|
|
|
|
Can it be applicable to bstr strings also ..
because my data required new line character after specific strings ??
|
|
|
|
|
pandit84 wrote: Can it be applicable to bstr strings also ..
Yeah I guess so. Just try it out.
pandit84 wrote: because my data required new line character after specific strings ??
What do you mean ? I don't understand your sentence...
|
|
|
|
|
Yes sir...got success..
Sir "??" was spelling mistake...please ignore..
|
|
|
|
|
Hi,
I am working using c++ STL and want to know how memory is allocated for vector when we d0 push_back() and other operations. Is memory allocated sequentially or it maintains addresses with it. Also I want to know that I have an vector of structures which is define globally and the struct contains an int and a CString. In my main(), I make structure only with int variable and empty CString and push_back them in vector. Now in another function I assign some local CString to vector elements. Will it work properly?
Please find the below sample code snippet:
struct Data
{
int n;
CString str;
};
vector<data> FData;
main()
{
struct Data tmpData;
for ( ingt i=0; i<10; i++ )
{
tmpData.n = i;
FData.push_back(tmpData);
}
Foo();
}
void Foo()
{
vector<data>::iterator FD_Iter;
for ( FD_Iter = FData.begin( ) ; FD_Iter != FData.end( ) ; FD_Iter++ )
{
CString local = "Akash";
FD_Iter->str = local;
}
}</data></data>
Please explain if after execution of Foo(), Shall I have properly filled FData?
Thanks,
Akash
|
|
|
|
|
Akash Agrawal wrote: want to know how memory is allocated for vector when we d0 push_back()
IMO, vector uses heap to keep it's elements.
Akash Agrawal wrote: Will it work properly?
What happened when you tried?
|
|
|
|
|
1) Heap is OK, but I waana know, that for each push_back(), does it add memory sequentially or relocate it for added size.
2) Working is not guaranteed in my opinion. I am seeing some indefinite behavior especially when use this in multi threaded case.
|
|
|
|
|
Akash Agrawal wrote: I am seeing some indefinite behavior especially when use this in multi threaded case.
I can't see where you have used synchronization mechanisms in your code.
|
|
|
|
|
All STL containers do a new and delete for extending memory.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Akash Agrawal wrote: how memory is allocated for vector when we d0 push_back() and other operations. Is memory allocated sequentially or it maintains addresses with it
A vector maintains a pointer to a single area of memory, which contains space for vector.capacity() items. When you push_back, if vector.size() is less than vector.capacity() , the new element just gets added after the last active item in the memory area. If vector.size() is equal to vector.capacity() , then a new area of memory, bigger than vector.capacity() , is allocated. The existing elements are copied to the start of that area and the old block of memory deallocated.
After the TR1 release of the STL specification, the area of memory managed by a vector is guaranteed to be contiguous. Previously, that was not guaranteed, although most implementations did use an algorithm that caused the memory to be contiguous.
Akash Agrawal wrote: In my main(), I make structure only with int variable and empty CString and push_back them in vector. Now in another function I assign some local CString to vector elements. Will it work properly?
Yes. A vector copies your data into its storage, rather than storing a reference.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks Stuart,
Nice explanation
|
|
|
|
|
Hello Friends
I m using remove(filename);but how i can delete if it using somewhere in project means is there any way that if i free that file and do this remove command.Or is there any other method to delete the file?
Thanks & Regards
Yogesh
|
|
|
|
|
How about MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT?
|
|
|
|
|
I used this but it is not working bro.Let me explain u in brief.In my application i m creating one file and at some conditions i hv to delete that file and that file is deleting only for the first time means after creation if i dont close the application. If i close the app then reopen then i perform operation of deletion on that file it is not deleting.Thats why i want to know is any way to get then free before deletion?Or any other reason?
Thanks
|
|
|
|
|
Try _unlink
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
_unlink is also not working dear.Please suggest me some other solution.
|
|
|
|
|
|
yogeshs wrote: I used this but it is not working bro.
And did you call GetLastError() to find out why?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
When u create/open the file, try to specify the FILE_SHARE_DELETE parameter.
|
|
|
|
|
yogeshs wrote: but how i can delete if it using somewhere in project...
Define using?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I assume "using" means that it's "open"ed and you still want to delete it nonetheless.
You could try "ShFileOperation".
This signature was proudly tested on animals.
|
|
|
|
|
Hello everyone,
It's a really straightforward question this time: I have a process handle and I wish to detect if that handle is one to my app. I have a function where I receive a handle to a process, and if the handle is a handle to any other app but mine, I send a message to it.
I've tried using GetProcessImageFileName, but unfortunately it returns garbage data...
char processName[255];
GetProcessImageFileName(ProcessHandle,processName,256);
MessageBox(NULL,processName,"hehehaha",MB_ICONINFORMATION);
Which leads to another non-related question. You see, I'm trying to hook NtTerminateProcess and deny all requests to terminate my own process. The hook works fine, but when I call the real NtTerminateProcess from inside the hookproc the process it's called on crashes. I am completely at a loss of why this is happening and would appreciate it if someone explained it to me.
When it crashes the error is The instruction at "0x10002383" referenced memory at "0x0000000c". The memory could not be "read" . It's always the same two addresses for any process.
Thanks a lot.
P.S. Please, please, PLEASE do not reply with a message asking "Why would you want to do such a thing". This is for educational purposes only, and I mean that.
modified on Friday, March 20, 2009 1:51 AM
|
|
|
|