请问API函数GetComputerName在Delphi中怎么用,那两个参数对应的Delphi类型是什么,怎么用,怎么我经常报告错误呢,急着用,请各位高手剁帮忙,谢谢啦

解决方案 »

  1.   

    var
      ComputerBuf: StringBuilder;
      ComputerBufLen: DWord;
    begin
      //Set max size buffer to ensure success
      ComputerBuf := StringBuilder.Create(MAX_COMPUTERNAME_LENGTH);
      ComputerBufLen := ComputerBuf.Capacity;
      if GetComputerName(ComputerBuf, ComputerBufLen) then
        MessageBox.Show(ComputerBuf.ToString)
    end;
      

  2.   

    汗..对一楼的代码有点迷惑..
    StringBuilder是什么类型?
    MessageBox是自已做的类吗?
    把一楼的代码改了一下.在Win2000+Delphi7下测试通过..var
      ComputerBuf:array[0..127] of Char;
      ComputerBufLen: DWord;
    begin
      ComputerBufLen:=128;
      GetComputerName(ComputerBuf ,ComputerBufLen) ;
      Showmessage(ComputerBuf);
    end;