Click here to Skip to main content
15,902,198 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Making video slider using Win32 Pin
IGx8926-Oct-03 10:13
IGx8926-Oct-03 10:13 
Generalselect() Pin
Alexander M.,25-Oct-03 13:37
Alexander M.,25-Oct-03 13:37 
GeneralRe: select() Pin
Johnny ²25-Oct-03 21:43
Johnny ²25-Oct-03 21:43 
Generalruntime C++ linking Pin
Alexander M.,25-Oct-03 12:10
Alexander M.,25-Oct-03 12:10 
GeneralRe: runtime C++ linking Pin
Jörgen Sigvardsson26-Oct-03 5:41
Jörgen Sigvardsson26-Oct-03 5:41 
QuestionCurrent username? Pin
M.u.m.b.a25-Oct-03 8:32
M.u.m.b.a25-Oct-03 8:32 
AnswerRe: Current username? Pin
Alexander M.,25-Oct-03 11:44
Alexander M.,25-Oct-03 11:44 
AnswerRe: Current username? Pin
Blake Coverett25-Oct-03 19:19
Blake Coverett25-Oct-03 19:19 
That's because you have configured your service to run under the LocalSystem account and that is in fact the correct username.

Presumably what you want is to find out the username of the whomever is logged onto the interactive console at the time? (Keeping in mind that the answer might be 'no one'.)

A sketch of the solution is as follows:

1) Call OpenWindowStation("WinSta0", FALSE, WINSTA_READATTRIBUTES) to a handle to the interactive WindowStation.
2) Call GetUserObjectInformation(hWinSta, UOI_USER_SID, ...) to get the SID of the user currently logged onto that WindowStation.
3) Call LookupAccountSid(...) to get the username from the SID returned above.

Points to consider:

If you are running on a version of the OS with Terminal Services installed you should start with the WTSEnumerateSessions() first to determine which WindowStation name you care about. This includes WinXP and W2K3 as they use the terminal services infrastructure all the time.

You may not really want the name, for anything security related you should probably be comparing against or logging that SID obtained in step three directly. Usernames can be duplicated between local and domain accounts and can change over the lifetime of an account, SIDs do not.

-Blake
Generalthis is so weird - try it and see Pin
Oinka25-Oct-03 8:06
Oinka25-Oct-03 8:06 
GeneralRe: this is so weird - try it and see Pin
Michael P Butler25-Oct-03 9:05
Michael P Butler25-Oct-03 9:05 
GeneralHey thanks that worked - but I'm still confused Pin
Oinka25-Oct-03 9:14
Oinka25-Oct-03 9:14 
GeneralRe: Hey thanks that worked - but I'm still confused Pin
Michael P Butler25-Oct-03 9:33
Michael P Butler25-Oct-03 9:33 
GeneralC++ Data Structures (3rd), Chapter 3, Exercise 8 a+b, pg 171 Pin
aLiSoN374225-Oct-03 7:58
sussaLiSoN374225-Oct-03 7:58 
GeneralRe: C++ Data Structures (3rd), Chapter 3, Exercise 8 a+b, pg 171 Pin
Oinka25-Oct-03 8:56
Oinka25-Oct-03 8:56 
GeneralC++ Data Structures (3rd), Chapter 4, Exercise 14, p 267 Pin
aLiSoN374225-Oct-03 7:56
sussaLiSoN374225-Oct-03 7:56 
GeneralRe: C++ Data Structures (3rd), Chapter 4, Exercise 14, p 267 Pin
joshfl25-Oct-03 8:45
joshfl25-Oct-03 8:45 
GeneralRe: C++ Data Structures (3rd), Chapter 4, Exercise 14, p 267 Pin
Oinka25-Oct-03 10:21
Oinka25-Oct-03 10:21 
GeneralRe: C++ Data Structures (3rd), Chapter 4, Exercise 14, p 267 Pin
Terry O'Nolley25-Oct-03 14:34
Terry O'Nolley25-Oct-03 14:34 
GeneralRe: C++ Data Structures (3rd), Chapter 4, Exercise 14, p 267 Pin
Jörgen Sigvardsson26-Oct-03 5:45
Jörgen Sigvardsson26-Oct-03 5:45 
GeneralPlotting Graphs Pin
emrosa25-Oct-03 7:30
emrosa25-Oct-03 7:30 
GeneralRe: Plotting Graphs Pin
Oinka25-Oct-03 10:11
Oinka25-Oct-03 10:11 
GeneralNeed help developing algorithm Pin
Steven M Hunt25-Oct-03 5:54
Steven M Hunt25-Oct-03 5:54 
GeneralRe: Need help developing algorithm Pin
CillyMe25-Oct-03 8:05
CillyMe25-Oct-03 8:05 
GeneralRe: Need help developing algorithm Pin
Steven M Hunt25-Oct-03 8:24
Steven M Hunt25-Oct-03 8:24 
GeneralRe: Need help developing algorithm Pin
Oinka25-Oct-03 8:49
Oinka25-Oct-03 8:49 

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.