How to Get Computer Name

    Sep 16 2020 | 2:01 pm
    Anyone know how to get the computer name in C? The Max Object is "gestalt" and you can send "host" message to get it but I have no clue how with the sdk.

    • Sep 16 2020 | 2:34 pm
      it doesn't look like the gestalt header file is included in the SDK, but it does look like the functions are exported, so you can try including the following definitions somewhere and calling them in your external (obviously no guarantees of past/present/future support):
      long sysinfo_gestalt_get_sysv(void); void sysinfo_gestalt_get_sysvers(long *major, long *minor, long *patch); t_symbol *sysinfo_gestalt_get_systemversion(void); long sysinfo_gestalt_get_pid(void); t_symbol *sysinfo_gestalt_get_processname(void); long sysinfo_gestalt_get_processorcount(void); t_uint64 sysinfo_gestalt_get_physicalmemory(void); t_symbol *sysinfo_gestalt_get_hostname(void); t_atomarray *sysinfo_gestalt_get_arguments(void); t_dictionary *sysinfo_gestalt_get_environment(void); alternatively, the implementation used for hostname on mac is
      NSString *hostname = [[NSProcessInfo processInfo] hostName]; return gensym([hostname UTF8String]); and on win (uses JUCE so you will have to adapt to your needs)
      TCHAR text[128] = { 0 }; auto len = (DWORD) numElementsInArray (text) - 1; GetComputerNameEx (ComputerNamePhysicalDnsHostname, text, &len); return String (text, len);
    • Sep 16 2020 | 2:37 pm
      file an issue here to get these added, if you're so inclined :
    • Sep 16 2020 | 5:11 pm
      Thank you soo much Rob. This is a good start. Hopefully it’ll work.