module Process

def get_windows_station_name

def get_windows_station_name
  winsta_name = FFI::MemoryPointer.new(:char, 256)
  return_size = FFI::MemoryPointer.new(:ulong)
  bool = GetUserObjectInformationA(
    GetProcessWindowStation(),  # Window station handle
    UOI_NAME,                   # Information to get
    winsta_name,                # Buffer to receive information
    winsta_name.size,           # Size of buffer
    return_size                 # Size filled into buffer
  )
  unless bool
    raise SystemCallError.new("GetUserObjectInformationA", FFI.errno)
  end
  winsta_name.read_string(return_size.read_ulong)
end