有一个单元以声名API,好像是window,打开它看。
先注册ActiveX DLL,然后用createobject();

解决方案 »

  1.   

    1、uses windows;
    2、uses Comobj;
      

  2.   

    声明WindowsAPI:function GetComputerName(lpBuffer: PChar; var nSize: DWORD): BOOL; stdcall;实际上,大部分Windows API包含在Windows.pas中,只要用use包括即可直接调用。但注意字符串要使用PChar类型,可以将string类型转换为pChar类型。查pChar,帮助中有例子,最后要加上stdcall,表示该函数采用windows API的标准调用方式,而不是Delphi缺省的pascal调用方式。
      

  3.   

    例子:在D6运行通过!!!
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TForm1 = class(TForm)
        StaticText1: TStaticText;
        StaticText2: TStaticText;
        Edit1: TEdit;
        Edit2: TEdit;
        Button1: TButton;
        Button2: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
    var
      s:array[1..127] of char;
      i:DWord;
    begin
      GetComputerName(@s,i);
      //获取计算机名
      Edit1.Text:=s;
    end;
    procedure TForm1.Button2Click(Sender: TObject);
    begin
      if SetComputerName(PChar(Edit2.text)) then
      //更改计算机名成功
        ShowMessage('您的计算机已改名为'+Edit2.Text)
      else
        ShowMessage('改名失败');
    end;end.