|
the \\ is required only when you hard code the \ character, to escape it (so that the single \ doesn't escape the character next to it.
but when you get a string, it's already constructed, thus no need for modify it.
|
|
|
|
|
I don't understand. So, I give an example:
CImage Image;
Image.Load("D:\Test.bmp") <-- can't load
Image.Load("D:\\Test.bmp") <-- can load
What happens when a function retrieves the path D:\Test.bmp? How can we use it ?
|
|
|
|
|
do you understand when I say "hard coding the string" ???
it means when you write the path yourself from within the source code...
so typing Image.Load("D:\\Test.bmp") is hard coding the path, thus you need to escape the \ char into '\\'.
also, writing Image.Load("D:\Test.bmp") is incorrect because the \ is in fact escaping the character next to it, so the compiler tries to understand '\t' as a single character (and as it exists, it will write it - the tab character - in the string between ':' and 'e').
now, if you get that path from an "Open File" dialog for instance, you wont have to iterate over that string to replace every \ with \\. get it now ?
|
|
|
|
|
Have you?
Try to look at [^].
But you really need a good tutorial on C programming language.
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
|
|
|
|
|
capint wrote: Image.Load("D:\Test.bmp") <-- can't load
Because D:est.bmp (or maybe D:<tab>est.bmp ) is what actually gets sent as the argument to Load() .
"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
|
|
|
|
|
DavidCrow wrote: D:est.bmp (or maybe D:est.bmp)
or even D:est.bmp !
(BTW I got what you meant, anyway kidding is irresistible to me...)
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
|
|
|
|
|
You're a such a bad guy.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
I know, buddy!
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
|
|
|
|
|
you could alternatively use / , most windows functions accept it, and the standard C library functions automatically convert it. \\ is ugly especially in long paths.
|
|
|
|
|
I still can't understand. I know about escape sequences U mean that the path we receive from window functions is OK ( we don't need to replace although they just have "\"), is that right ?
|
|
|
|
|
capint wrote: U mean that the path we receive from window functions is OK
Yes, because those are not being seen by the compiler. What happens at runtime is completely different.
"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
|
|
|
|
|
My problem is that. I receive the string from the function SystemParametersInfo and I use that string to load by Image.Load. It doesn't work
|
|
|
|
|
capint wrote: It doesn't work
Then something else is wrong. Does the file actually exist? What does Load() return?
"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
|
|
|
|
|
All my code is here :
TCHAR * Temp;
Temp = new TCHAR[100];
CString str;
SystemParametersInfo(SPI_GETDESKWALLPAPER,100,Temp,0);
CImage Image;
str = Temp;
Image.Load(str);
Image.ReleaseDC();
Image.Save(_T("D:\\Temp\\Desktop.bmp"));
I debuged & I saw clearly the path, of course, it exits
When I replace str by another string created manually, it works
|
|
|
|
|
Which statement is failing?
"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
|
|
|
|
|
No statement is failing. It just doesn't do anything. Actually, when I replace "\" by "/", it works. But I still wonder
|
|
|
|
|
capint wrote: No statement is failing.
How are you verifying this?
capint wrote: Actually, when I replace "\" by "/", it works. But I still wonder
Single slashes (like those used on Unix machines) can be used in place of double backslashes.
"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 realize, of course, that the path can be up to 260 characters long?
|
|
|
|
|
Hi for all
Does anyone knows a free API for video screen capture?
|
|
|
|
|
Do you want to capture of avi files?
|
|
|
|
|
My real intention is to select an area of the desktop(or other window) and record until I want to stop. After this I'll save in any format.
Something like Camstudio but much more simple.
|
|
|
|
|
|
Thanks for your answer ramid. I'll look. What I want is to create an implementation more generic, that works on Windows and Linux.
Again, thanks
|
|
|
|
|
You're welcome you can back to ask if you like.
|
|
|
|
|
Alex Cutovoi wrote: Something like Camstudio but much more simple.
Camstudio[^] is open source! You can just download the source and see how it has been done.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|