title: How to change a file's ownership in windows
body: <p>I am trying to change a file's ownership through c++ in windows(windows 7 and up) to a specific user. I have read through <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa379620%28v=vs.85%29.aspx" rel="nofollow">this</a> example but it does not seem to be of much help. I would like to be able to create a function like <code>SetFileOwner(LPTSTR user, LPTSTR fileStr)</code> that sets the owner of fileStr to be the specified user.</p>
  
  <p>It seems that I need a SID to set the owner and then use <code>SetNamedSecurityInfo</code>. Is there another option that will allow me to set ownership by username? Is there a way to get SID from username(sorry if this question is stupid - I am not really into how windows rights and ownership work)?</p>