code: def get_final_path(path):
  	r
  	desired_access = api.NULL
  	share_mode = (
  		api.FILE_SHARE_READ | api.FILE_SHARE_WRITE | api.FILE_SHARE_DELETE
  	)
  	security_attributes = api.LPSECURITY_ATTRIBUTES()  # NULL pointer
  	hFile = api.CreateFile(
  		path,
  		desired_access,
  		share_mode,
  		security_attributes,
  		api.OPEN_EXISTING,
  		api.FILE_FLAG_BACKUP_SEMANTICS,
  		api.NULL,
  	)
  
  	if hFile == api.INVALID_HANDLE_VALUE:
  		raise WindowsError()
  
  	buf_size = api.GetFinalPathNameByHandle(
  		hFile, LPWSTR(), 0, api.VOLUME_NAME_DOS)
  	handle_nonzero_success(buf_size)
  	buf = create_unicode_buffer(buf_size)
  	result_length = api.GetFinalPathNameByHandle(
  		hFile, buf, len(buf), api.VOLUME_NAME_DOS)
  
  	assert result_length < len(buf)
  	handle_nonzero_success(result_length)
  	handle_nonzero_success(api.CloseHandle(hFile))
  
  	return buf[:result_length]
docs: r"""
  	For a given path, determine the ultimate location of that path.
  	Useful for resolving symlink targets.
  	This functions wraps the GetFinalPathNameByHandle from the Windows
  	SDK.
  
  	Note, this function fails if a handle cannot be obtained (such as
  	for C:\Pagefile.sys on a stock windows system). Consider using
  	trace_symlink_target instead.