Group: Security - Library: advapi32
The ImpersonateLoggedOnUser function lets the calling thread impersonate the security context of a logged-on user. The user is represented by a token handle.
How to run FoxPro application under different user name (impersonating user)
BOOL ImpersonateLoggedOnUser(
HANDLE hToken
);
DECLARE INTEGER ImpersonateLoggedOnUser IN advapi32;
INTEGER hToken
hToken [in] Handle to a primary or impersonation access token that represents a logged-on user.
If the function succeeds, the return value is nonzero.
hToken can be a token handle returned by a call to LogonUser, CreateRestrictedToken, DuplicateToken, DuplicateTokenEx, OpenProcessToken, or OpenThreadToken functions.