There is no API function that does this directly, however you can combine multiple API calls for this. Of course, your program will have to satisfy any ACLs that apply to the process that interests you.
First, given the process id, you need to open the process descriptor. You can use OpenProcessfor this, requesting access rights PROCESS_QUERY_INFORMATION.
, OpenProcessToken, TOKEN_QUERY.
, GetTokenInformation, TokenUser, , SID. SID , LookupAccountSid.
CloseHandle , , .