Manual copy of pywin32 code