cheapstr
asked on
find which user is logged on
i am trying to make a dialog app that will clean up my hard drive automatically. the question is uxing winxp, the temporary internet files and cookies, are under c:\\documents and settings\'user'. how can i find out the username for that folder of the user presently logged on?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
to kiranvj:
worked like a charm, and i will accept your answer, but i'll add an extra 200 points if you can show me how to get into that folder. (I dont know how to use a varialbe when specifying the path c:\documents and settings\"username")?
worked like a charm, and i will accept your answer, but i'll add an extra 200 points if you can show me how to get into that folder. (I dont know how to use a varialbe when specifying the path c:\documents and settings\"username")?
>>but i'll add an extra 200 points if you can show me how to get into that folder
You won't need to - as I wrote: just call
char* pszUserProfile = getenv ( "USERPROFILE");
and you'll get the *full* path anyway. Any reason you have chosen to ignore my comment?
You won't need to - as I wrote: just call
char* pszUserProfile = getenv ( "USERPROFILE");
and you'll get the *full* path anyway. Any reason you have chosen to ignore my comment?
Sorry if this sounds a bit offensive, but why wouldn't I get the points, since I answered the question first?
Thanks.
Thanks.
That's true, also...
>>I dont know how to use a varialbe when specifying the path c:\documents and settings\"username")?
plz try some think like this
////////////////////////
CString path;
path.Format("c:\\documents
AfxMessageBox(path);
///////////////////////
hope this helps
kiranvj
I posted the first correct answer to this problem, so I believe that my answer should be accepted.
Of course, I'd be willing to split the points since other people have also given good advice. :)
Of course, I'd be willing to split the points since other people have also given good advice. :)
hi..
i think i deserve some points, i would recommend a split of points.
>>ch0c
i know u posted an answer first, but i think the questioner did not understand it, and my post contains the full code. He used my code and he liked it , its clear from his feedback.
kiranvj
i think i deserve some points, i would recommend a split of points.
>>ch0c
i know u posted an answer first, but i think the questioner did not understand it, and my post contains the full code. He used my code and he liked it , its clear from his feedback.
kiranvj
Ok, you're right. Splitting the points would probably be fairest.
*plonk*
char* pszUserProfile = getenv ( "USERPROFILE");
which will return "c:\documents and settings\'user'" correctly for all localized versions of Windows (on a german Windows, that would e.g. be "c:\Dokumente und Einstellungen\'user'")