DWORD SIDLength = 0;
DWORD RefDomainNameLength = 0;
SID_NAME_USE SIDNameUse;
::LookupAccountName(NULL, _T("MYCOMPUTERNAME\\"), NULL, &SIDLength, NULL, &RefDomainNameLength, &SIDNameUse);
PSID psid = (PSID)new BYTE[SIDLength];
LPTSTR domain = new TCHAR[RefDomainNameLength];
::LookupAccountName(NULL, _T("MYCOMPUTERNAME\\"), psid, &SIDLength, domain, &RefDomainNameLength, &SIDNameUse);
LPTSTR StringSid;
::ConvertSidToStringSid(psid, &StringSid);
::LocalFree(StringSid);
delete[] domain;
delete[] (BYTE*)psid;