Skip to content

Instantly share code, notes, and snippets.

@alesleoignis
Created April 12, 2013 11:50
Show Gist options
  • Save alesleoignis/5371475 to your computer and use it in GitHub Desktop.
Save alesleoignis/5371475 to your computer and use it in GitHub Desktop.
get information about current session
#include <CoreFoundation/CoreFoundation.h>
#include <ApplicationServices/ApplicationServices.h>
CFStringRef shortUserName;
CFNumberRef userUID;
CFBooleanRef userIsActive;
CFBooleanRef loginCompleted;
int MyCGGetSessionInfo
{
CFDictionaryRef sessionInfoDict;
sessionInfoDict = CGSessionCopyCurrentDictionary();
if (sessionInfoDict == NULL)
{
printf("Unable to get session dictionary.");
return(1);
}
shortUserName = CFDictionaryGetValue(sessionInfoDict,
kCGSessionUserNameKey);
userUID = CFDictionaryGetValue(sessionInfoDict,
kCGSessionUserIDKey);
userIsActive = CFDictionaryGetValue(sessionInfoDict,
kCGSessionOnConsoleKey);
loginCompleted = CFDictionaryGetValue(sessionInfoDict,
kCGSessionLoginDoneKey);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment