-2

Ok this is probably a noob issue... probably a really newb issue lol, but I am a newb so here it goes:

I want to write down the following text in an edit control: C:\Documents and Settings\Blah\Desktop\myText.txt

I wrote the following code:

SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)"C:\Documents and Settings\Blah\Desktop\myText.txt");

And it does write in the edit control, however it doesn't write exactly what I wanted, rather it writes:

C:Documents and SettingsBlahDesktopmyText.txt

which is everything except the "\" symbol.... Now I have looked everywhere for a solution but haven't found one cause I am a newb.

Question:: What do I have to write in the fourth parameter so that the "\" can also be included?

computerWizard
  • 94
  • 3
  • 12
  • 3
    Backslashes. They must be escaped. – Frédéric Hamidi Apr 29 '14 at 18:29
  • What do you mean they must be escaped? I need to write them in the edit box, so what would I include in the (LPARAM)"what do I include here" in order for the backslashes to appear? – computerWizard Apr 29 '14 at 18:31
  • @FrédéricHamidi :D. I'm not going to make a fool of myself by trying to work out the exact syntax here without preview (original comment with unescaped backslashes deleted, for anyone who missed it). – dlf Apr 29 '14 at 18:31
  • 1
    @computerWizard, you would do nothing in that case. Backslashes only have to be escaped in literals. – Frédéric Hamidi Apr 29 '14 at 18:32
  • @FrédéricHamidi (it confused me because I doubled one but not the other, and they both wound up looking the same) – dlf Apr 29 '14 at 18:34
  • @dlf, for what it's worth I tried too but did not succeed (markdown gets in the way). Let's try again: `\\ `. – Frédéric Hamidi Apr 29 '14 at 18:34
  • hahah this was kinda funny. Simple solution but lots of discussion :P. Thanks to all you guys btw – computerWizard Apr 29 '14 at 18:55

1 Answers1

4

You need to escape your backslashes:

SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM)"C:\\Documents and Settings\\Blah\\Desktop\\myText.txt");
ElGavilan
  • 6,610
  • 16
  • 27
  • 36