|
Yeah - keep quite.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Yeah - keep quite.
What? You can hear me typing?
led mike
|
|
|
|
|
I'm trying to find an easy way to convert a CString to a char* without having to do it character-by-character.
I've tried memcpy unsuccessfully. Anyone have any tricks?
|
|
|
|
|
CString provides a (LPCTSTR) cast operator for this.BTW, what are you trying to achieve ?
can't you just use CString::operator[]() or CString::GetAt() to retrieve a character in the CString object ?
|
|
|
|
|
I want to get the entire string into a char array in case I can't figure out how to do something else.
|
|
|
|
|
I believe toxcct meant "what do you want to do that for ?"
|
|
|
|
|
super_ttd wrote: what do you want to do that for ?
exactly.
As I am suspecting the OP to have asked this for a darken reason, I'm not sure casting the CString object would be worth it...
|
|
|
|
|
|
|
USAFHokie80 wrote: You rock
Probably, but certainly not on this post...
please read my answer to him[^]
|
|
|
|
|
NO, definitely not !
GetBuffer() is not there for casting purpose !
Moreover, the OP seem not to really know what he wants that for, so instead of saying amen to a query-for-code, better understand why such a thing is asked for...
I'm more likely to think he's trying to iterate on every characters of the string, so no need for cast for this ; a simple use of the [] operator would do !
BTW, I'm almost certain that Roger Allen (which is also a great codeproject member) would not reply so nowadays... notice that he replied so, but it was in year 2000 !
at last, read this[^] and tell me if you see somewhere in Microsoft recomendations to use GetBuffer() .
modified on Friday, August 22, 2008 11:16 AM
|
|
|
|
|
I was merely posting a link to a thread that was of the same subject - I was not involved with any of those thread posts I thought it would be helpful to USAFHokie80 here..
Regards,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
Introduction to Object-Oriented JavaScript
|
|
|
|
|
Yeah... GetBuffer doesn't work.
But this works:
char* str = (char*)(LPCTSTR)str2
|
|
|
|
|
USAFHokie80 wrote: Yeah... GetBuffer doesn't work.
hum, correction : GetBuffer DOES work, but it's not there for that.
|
|
|
|
|
That's a horrible cast, and a good example why casts are bad. If you needed the
cast to get that to compile then you did something wrong.
It should be
const char* str = str2;
If your CString is always based on a "char" character type, then you
should be using a CStringA.
Mixing generic and fixed character types negates the usefulness of
generic character types (i.e. your code will fail on a Unicode build).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
toxcct wrote: Moreover, the OP seem not to really know what he wants that for, so instead of saying amen to a query-for-code, better understand why such a thing is asked for...
better understand stuff! BAH, we don't need no freakin understanding we just writ cods plezzzzz
led mike
|
|
|
|
|
lol... was it urgentz ? I didn't read so, so it means I had time to think about design !
|
|
|
|
|
Is there an easy way to search a CFile for a string and get the index?
|
|
|
|
|
USAFHokie80 wrote: Is there an easy way to search a CFile
No you have to search the file line by line
USAFHokie80 wrote: get the index
The index based on what?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
the index for a file position where the string begins.
|
|
|
|
|
|
Yes, assuming you put the contents of said file in a searchable buffer
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I want to check whether the current user has the rights to delete a file.
I've looked at two approaches. The first is to call CreateFile with the creation disposition flags set to OPEN_EXISTING. This would give the right answer most of time, apart from when the user has the delete permission explicitly disabled.
I've also looked at GetEffectiveRightsFromAcl. This looks as if this would do it for local files, but the documentation states A trustee's group rights are enumerated by GetEffectiveRightsFromAcl on the local computer, even if the trustee is accessing objects on a remote computer. This function does not evaluate group rights on remote computers. which implies that it's not going to be reliable on a network drive, which may be hosted on a different OS anyway.
Could someone suggest a better way of doing this?
|
|
|
|
|
Hello
I am doing computer engineering and i needed some guidance
regarding my project.
1st of all i want to know whether it is possible to disable usb ports
and CD rom "POWER" through VC++.
If yes then could you please guide me on it?
Thanks
|
|
|
|
|
I don't know about removing power but you can lock volumes with DeviceIoControl() with the FSCTL_LOCK_VOLUME which means that your process has exclusive access to that volume. Take a look at the documentation here. You could do this with the CD drive.
You can disable USB ports from the registry (which can be done programatically); take a look at this article for more info.
Hope this helps,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
Introduction to Object-Oriented JavaScript
modified on Friday, August 22, 2008 8:44 AM
|
|
|
|