|
Well, let's try to get it from the CString 's consumer point of view:
(1) requesting, via (explicit) cast a pointer to a const buffer means: "OK, I need the buffer but I'll not change it".
(2) requesting via GetBuffer() a pointer to the internal buffer means: "I need the buffer to make all the weirdest things I know to it".
Clearly method (2) is a bit crude for a mere copy operation.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
hi der, da getbuffr iz renamed in da latast sdk as GetBufferIKnowWhatImDoing()
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Indeed!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I strongly second that.
GetBuffer() is really to be forbidden for cast purpose
|
|
|
|
|
Maxim Zarus wrote: Is this wrong or right way?
It's wrong since sEndDate has no storage space; it's just a pointer (to wherever).
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
you mean, first allocate memory for sEndDate then i can use _tcscpy_s() .
its ok. i agree.
but is it also neccessary to allocate memory when CString::GetBuffer() has been used?
because i have seen in pervious post nobody ask to allocate memory for CString::GetBuffer() .
regards,
Maxim...
|
|
|
|
|
Maxim Zarus wrote: you mean, first allocate memory for sEndDate then i can use _tcscpy_s().
Yes.
Maxim Zarus wrote: but is it also neccessary to allocate memory when CString::GetBuffer() has been used?
Not necessarily. It all depends on what you are going to be doing with the returned pointer.
Maxim Zarus wrote: because i have seen in pervious post nobody ask to allocate memory for CString::GetBuffer().
CString::GetBuffer() is very often misused.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You can even use macrs A2W and W2A for conversions from multibyte-widechar and widechar-multibyte
For these macros you need to include "atlconv.h"
and also you need to write USES_CONVERSION macro before using these macros inside function.
|
|
|
|
|
|
please anybody can help me with the name of a code profiler tool for unmanaged C++ ?
I do'nt like something so much sophisticated as VTune..
I rather want a simple tool through which I can mark code regions and then after exection it just report to me the time spent on each region and the relative duration ratio for each region..
In another word is there something like SlickEdit Tools quick profiling feature, but rather for C++ unamanged code ?
|
|
|
|
|
See for IBM Rationals Code Coverage tool that comes with Purify plus
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hi,
How can I create Progress bar in the Listview subitem?
|
|
|
|
|
there are many samples on code project.
|
|
|
|
|
Click here[^]
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
|
I want to know how through use of MFC API we can do nslookup and query our DNS server to look for smtp mail server, responsible for forwarding our messages to other smtp servers on same network(doamin) or some other domain.
|
|
|
|
|
You can use DnsQuery() for this.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
How can I programatically retrieve the list of users available in the 'Administrators' group
which is accessible (in XP) through :
Right click 'My Computer' -> Manage -> Computer Management (Local) -> System Tools ->
Local Users and Groups -> Groups -> Administrators (double click).
Using NetUserEnum(), I am able to retrieve users who are also Administrators but entries like
XYZDomain\XYZAdminUser under the 'Administrators' group couldn't be retrieved.
How could I specifically retrieve entries like 'XYZDomain\XYZAdminUser'.
Thanks in Advance.
|
|
|
|
|
SherTeks wrote: How can I programatically retrieve the list of users available in the 'Administrators' group
which is accessible (in XP) through :
Right click 'My Computer' -> Manage -> Computer Management (Local) -> System Tools ->
Local Users and Groups -> Groups -> Administrators (double click).
Use NetLocalGroupGetMembers() .
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
Hi,
I wrote some multiThread application that upload some file to FTP server.
When i run 10 threads all work fine - but when i run 50 thread i have deadlock.
I attached my code - this is the Connection method that each thread calls
My code ...
bool FTPConnection::UploadInfo(CString MachineIpAddress, CString FileToDownload)
{
try
{
CMyInternetSession InternetSession;
CFtpConnection* ftpConnection = InternetSession.GetFtpConnection(MachineIpAddress, "admin", "admin");
if( !ftpConnection->SetCurrentDirectory("/SomeFtpFoled"))
{
int E = GetLastError();
return false;
}
if(!ftpConnection->PutFile(FileToDownload, FileToDownload))
{
int E = GetLastError();
return false;
}
return true;
}
catch (CException* e)
{
return false;
}
}
|
|
|
|
|
Are you syncronizing threads. If there is a problem of Syncronization of threads then try using Mutex, critical section etc. try to syncronize the threads.
|
|
|
|
|
The thread are synchronize.
I don't think that this is the synchronize problem because each thread is running ok.
But - when i press on pause button - i see that some thread(s) are still waiting on the line "GetFtpConnection" and other thread(s) are still waiting on "PutFile".
So i think that the synchronize of the thread is ok - and maybe i have some communication problem.
|
|
|
|
|
I don't think that the scenario you're talking about is 'dead lock'. You are calling the synchronous calls like PutFile which returns only when the task gets completed or failed. Try out with opening the file using OpenFile and Write functions. You'll get closer control over the code and thread.
- Malli...!
|
|
|
|