title: What's the best method for getting the local computer name in Delphi
body: <p>The code needs to be compatible with D2007 and D2009.</p>
  
  <hr>
  
  <p>My Answer: Thanks to everyone who answered, I've gone with:</p>
  
  <pre><code>function ComputerName : String;
  var
    buffer: array[0..255] of char;
    size: dword;
  begin
    size := 256;
    if GetComputerName(buffer, size) then
      Result := buffer
    else
      Result := ''
  end;
  </code></pre>