Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Win32 equivalent of getuid()

Tags:

c++

windows

I'm in the process of porting a C++ library from Linux to Windows, and am having problems with getuid(), which is not supported in Windows.

Any ideas what I can use in its place?

like image 344
StevieG Avatar asked Dec 13 '22 01:12

StevieG


1 Answers

The Windows equivilent is actually the user's SID. You can get this by using the "GetTokenInformation" call and querying for the TokenUser information class.

To call GetTokenInformation, you need a handle to the users token, which you can get by calling OpenProcessToken (or OpenThreadToken if you're impersonating someone).

like image 58
ReinstateMonica Larry Osterman Avatar answered Dec 22 '22 05:12

ReinstateMonica Larry Osterman