Kernel32 GetComputerName

 

Hi all,

Been a while since I have done this sort of coding, so I'm a little rusty...


I need to get the computername and am trying:


#import "kernel32.dll"
string GetComputerNameA(string lpBuffer, int nSize);
#import

int start()
{
   string name;
      
   GetComputerNameA(name,32767);
   
   Print(name);
   return(0);
}   


but of course it doesn't work! I am on a borrowed computer and don't have access to any of my own notes, links etc.


Can anyone please help? I am not even too sure I have the GetComputerNameA definition correct?

 
Never mind... forgot about MT4 and "strings" Thanks for reading though.
 

Perhaps you should read the manual.
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

Strings are wide since Build 600+ (2014)

Buffer and size ares an output, passed by reference.
          GetComputerNameW function (winbase.h) - Win32 apps | Microsoft Learn

Reason: