如上

解决方案 »

  1.   

    function GetComputerName: string;
    var
      pcComputer: PChar;
      dwCSize: DWORD;
    begin
      dwCSize := MAX_COMPUTERNAME_LENGTH + 1;
      result := '';
      GetMem(pcComputer, dwCSize);
      try
        if Windows.GetComputerName(pcComputer, dwCSize) then
          Result := pcComputer;
      finally
        FreeMem(pcComputer);
      end;
    end;//获取本地计算机的IP地址function GetComputerIP: string;
    var
      ch: array[1..32] of Char;
      i: Integer;
      WSData: TWSAData;
      MyHost: PHostEnt;
      S_IP: string;
    begin
      if WSAstartup(2, wsdata) <> 0 then
        EXIT;
      if getHostName(@ch[1], 32) <> 0 then
        EXIT;
      MyHost := GetHostByName(@ch[1]);
      if MyHost = nil then
        EXIT
      else
      begin
        for i := 1 to 4 do
        begin
          S_IP := S_IP + inttostr(Ord(MyHost.h_addr^[i - 1]));
          if i < 4 then
            S_IP := S_IP + '.';
        end;
      end;
      RESULT := S_IP;
    end;