Click here to Skip to main content
15,891,248 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
QuestionMemory leak problem. Pin
sirtimid3-Sep-11 8:39
sirtimid3-Sep-11 8:39 
AnswerRe: Memory leak problem. Pin
Stephen Hewitt4-Sep-11 1:33
Stephen Hewitt4-Sep-11 1:33 
GeneralRe: Memory leak problem. Pin
sirtimid4-Sep-11 10:19
sirtimid4-Sep-11 10:19 
QuestionGetting AppData Directory Path Pin
jwalker3432-Sep-11 17:02
jwalker3432-Sep-11 17:02 
AnswerRe: Getting AppData Directory Path Pin
Richard Andrew x643-Sep-11 10:19
professionalRichard Andrew x643-Sep-11 10:19 
GeneralRe: Getting AppData Directory Path Pin
jwalker3435-Sep-11 9:52
jwalker3435-Sep-11 9:52 
GeneralRe: Getting AppData Directory Path Pin
Richard Andrew x645-Sep-11 10:13
professionalRichard Andrew x645-Sep-11 10:13 
AnswerRe: Getting AppData Directory Path Pin
MicroVirus6-Sep-11 1:28
MicroVirus6-Sep-11 1:28 
Though what the other poster said is correct, you need to make a few extra modifications. First I'll give you the working 'proper' code, and then I'll explain:
C++
    // String buffer for holding the path and filename
    TCHAR strPath[ MAX_PATH + 50 ];

// Get the special folder path.
SHGetSpecialFolderPath(
    0,       // Hwnd
    strPath, // String buffer.
    CSIDL_APPDATA, // CSLID of folder
    FALSE ); // Create if doesn't exists?

_tcscat(strPath, _T("\\SSST\\Settings.ini"));

MessageBox(NULL, strPath, NULL, MB_OK);


First of all, you were mixing WCHAR definitions with TCHAR functions (such as _tcscat, MessageBox). Depending on whether you compile for Unicode or not, the TCHAR definition changed from a char to a wchar_t, and so do all the tchar.h routines, as well as the Windows API functions (which switch to their wide variants).
To fix this, use TCHAR and LPTSTR's in your program. For string literals, enclose them in a _T macro as shown, which automatically adds the L prefix if needed and omits it if not unicode.
Then a simplification: you can just strcat (_tcscat) in strPath, no need to add extra variables and certainly no need to use new, which adds the overhead of extra memory management and can lead to memory leaks if you forget to clean it up.

And finally, the last argument of the MessageBox is a UINT flag, and not a pointer, so you shouldn't pass NULL to it, but rather one of the predefined constants.

Hope this helps.
GeneralRe: Getting AppData Directory Path Pin
jwalker3436-Sep-11 5:44
jwalker3436-Sep-11 5:44 
GeneralRe: Getting AppData Directory Path Pin
MicroVirus6-Sep-11 15:31
MicroVirus6-Sep-11 15:31 
GeneralRe: Getting AppData Directory Path Pin
jwalker3437-Sep-11 16:03
jwalker3437-Sep-11 16:03 
Questionhelp me!!! Pin
zz526335731-Aug-11 5:30
zz526335731-Aug-11 5:30 
QuestionHow to use forms / dialog boxes with an ATL Project / BHO? Pin
abetterword23-Aug-11 4:22
abetterword23-Aug-11 4:22 
AnswerRe: How to use forms / dialog boxes with an ATL Project / BHO? Pin
MicroVirus6-Sep-11 2:06
MicroVirus6-Sep-11 2:06 
QuestionFailure to Recognise Base Class [modified] Pin
Bram van Kampen19-Aug-11 13:47
Bram van Kampen19-Aug-11 13:47 
AnswerRe: Failure to Recognise Base Class Pin
Richard MacCutchan20-Aug-11 0:23
mveRichard MacCutchan20-Aug-11 0:23 
GeneralRe: Failure to Recognise Base Class Pin
Bram van Kampen20-Aug-11 15:47
Bram van Kampen20-Aug-11 15:47 
GeneralRe: Failure to Recognise Base Class Pin
Richard MacCutchan20-Aug-11 23:32
mveRichard MacCutchan20-Aug-11 23:32 
AnswerRe: Failure to Recognise Base Class Pin
«_Superman_»22-Aug-11 13:14
professional«_Superman_»22-Aug-11 13:14 
QuestionCommon Controls Issue Pin
Tracy Software16-Aug-11 2:55
Tracy Software16-Aug-11 2:55 
Questioniterator default value [modified] Pin
liquid_5-Aug-11 1:34
liquid_5-Aug-11 1:34 
AnswerRe: iterator default value Pin
Stephen Hewitt6-Aug-11 20:40
Stephen Hewitt6-Aug-11 20:40 
GeneralRe: iterator default value Pin
liquid_7-Aug-11 9:18
liquid_7-Aug-11 9:18 
QuestionSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ Pin
VeganFanatic24-Jul-11 8:44
VeganFanatic24-Jul-11 8:44 
QuestionRe: SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ Pin
Richard MacCutchan24-Jul-11 21:09
mveRichard MacCutchan24-Jul-11 21:09 

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.