Click here to Skip to main content
15,890,690 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionSQL server database for development Pin
IlanTal29-Aug-05 0:02
IlanTal29-Aug-05 0:02 
AnswerRe: SQL server database for development Pin
IlanTal29-Aug-05 0:06
IlanTal29-Aug-05 0:06 
QuestionHow to getting the string of head position?? Pin
ebinaini28-Aug-05 23:47
ebinaini28-Aug-05 23:47 
AnswerRe: How to getting the string of head position?? Pin
Eytukan29-Aug-05 0:04
Eytukan29-Aug-05 0:04 
AnswerRe: How to getting the string of head position?? Pin
Rage29-Aug-05 0:05
professionalRage29-Aug-05 0:05 
AnswerRe: How to getting the string of head position?? Pin
Bob Ciora29-Aug-05 1:19
Bob Ciora29-Aug-05 1:19 
QuestionNeed help....... Pin
Member 216100428-Aug-05 23:36
Member 216100428-Aug-05 23:36 
QuestionBack slashes '\' and SHGetSpecialFolderPath Pin
caykahve28-Aug-05 23:14
caykahve28-Aug-05 23:14 
Hi,

I have a problem with using a path. I have to obtain the program files' path programatically, therefore I use this function.
// Get Program Files Path
CString PFPath;
SHGetSpecialFolderPath(NULL,PFPath.GetBuffer(_MAX_PATH), 

CSIDL_PROGRAM_FILES, FALSE);
MessageBox(PFPath);

and the message box says:
C:\Program Files

I need to add something at the end of this string and then i try to use it in another function which needs the paths in double back slashes like:
"C:\\Program Files"

Then I try to do a conversion in PFPath in order to double the backslashes to change from
"C:\Program Files" to "C:\Program Files"
// double
   int i=0;
   i = PFPath.Find("\\",i);
   while( i>-1 )
   {
      CString found;
      found.Format("Backslash found at index: %d",i);
      MessageBox(found);
      //Insert a \ in front of the found one to double it
      PFPath.Insert(i,(CString)"\\");      
      MessageBox(PFPath);
      //Get the next one
      i += 2;
      i = PFPath.Find("\\",i);
   }
   if(i==-1)
      MessageBox("No more backslashes");
   MessageBox(PFPath);

The message box output of this path is:
Backslash found at index: 2
\
No more backslashes
\


As seen, the insert function turned the whole string into a single backslash instead of inserting one.
// extend the path
CString WholePath = PFPath + (CString)"\\some_folder\\myfile.exe";
SHELLEXECUTEINFO shellInfo;
...
shellInfo.lpFile = WholePath;
::ShellExecuteEx(&shellInfo);

The conversion cannot be done properly, and shellInfo.lpFile needs double slashes. Therefore ShellExecuteEx cannot receive the path.

I have also tried the '\' conversion issue with CString::Replace; CString::left, CString::Right and concetanation with operator +. Now I'm almost convinced that it is not possible to do it with the CString class. Confused | :confused:

Is there any other way to convert the '\' to '\\'?

Regards and thanks in advance,
Caykahve

-- modified at 5:49 Monday 29th August, 2005
AnswerRe: Back slashes '\' and SHGetSpecialFolderPath Pin
Achim Klein29-Aug-05 0:02
Achim Klein29-Aug-05 0:02 
GeneralRe: Back slashes '\' and SHGetSpecialFolderPath Pin
caykahve29-Aug-05 0:18
caykahve29-Aug-05 0:18 
GeneralRe: Back slashes '\' and SHGetSpecialFolderPath Pin
Achim Klein29-Aug-05 0:43
Achim Klein29-Aug-05 0:43 
GeneralRe: Back slashes '\' and SHGetSpecialFolderPath Pin
Achim Klein29-Aug-05 0:53
Achim Klein29-Aug-05 0:53 
GeneralRe: Back slashes '\' and SHGetSpecialFolderPath Pin
caykahve29-Aug-05 1:07
caykahve29-Aug-05 1:07 
GeneralRe: Back slashes '\' and SHGetSpecialFolderPath Pin
Achim Klein29-Aug-05 1:27
Achim Klein29-Aug-05 1:27 
GeneralRe: Back slashes '\' and SHGetSpecialFolderPath Pin
caykahve29-Aug-05 1:48
caykahve29-Aug-05 1:48 
GeneralRe: Back slashes '\' and SHGetSpecialFolderPath Pin
Achim Klein29-Aug-05 1:57
Achim Klein29-Aug-05 1:57 
GeneralRe: Back slashes '\' and SHGetSpecialFolderPath Pin
Achim Klein29-Aug-05 2:21
Achim Klein29-Aug-05 2:21 
GeneralRe: Back slashes '\' and SHGetSpecialFolderPath Pin
caykahve29-Aug-05 3:17
caykahve29-Aug-05 3:17 
GeneralRe: Back slashes '\' and SHGetSpecialFolderPath Pin
Achim Klein29-Aug-05 3:39
Achim Klein29-Aug-05 3:39 
NewsRe: Back slashes '\' and SHGetSpecialFolderPath Pin
caykahve29-Aug-05 4:06
caykahve29-Aug-05 4:06 
AnswerRe: Back slashes '\' and SHGetSpecialFolderPath Pin
Jose Lamas Rios29-Aug-05 5:47
Jose Lamas Rios29-Aug-05 5:47 
QuestionSQL SERVER DATABASE Pin
sirtimid28-Aug-05 23:09
sirtimid28-Aug-05 23:09 
QuestionDefault Push Button Pin
Nishad S28-Aug-05 23:03
Nishad S28-Aug-05 23:03 
AnswerRe: Default Push Button Pin
Marc Soleda28-Aug-05 23:12
Marc Soleda28-Aug-05 23:12 
GeneralRe: Default Push Button Pin
Marc Soleda28-Aug-05 23:26
Marc Soleda28-Aug-05 23:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.