How to take file ownership to the current user using win32 api
问题 I want to take file ownership using win32 api, and I want my code to work on both xp and win7 anyway, here is what i came up with Function that changes the ownership of the file int ChangeFileOwner() { HANDLE token; char *filename = "c:\\file1.txt"; //(not owned by the current user) DWORD len; PSECURITY_DESCRIPTOR security = NULL; int retValue = 1; PSID sid; // Get the privileges you need if (OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &token)) { if(!SetPrivilege(