changed to winapi functions