procedure TForm1.Button7Click(Sender: TObject);
var
  s:array[0..255]of char;
  size:Cardinal;begin
  for size:=0 to 255 do
    s[size]:=#0;
  size := 257;
  GetComputerName(s,size);
  caption:=s;end;project->import type lib...
或CreateOleObject 请大家去 http://www.new7wonders.com/c/voting.php 投长城一票

解决方案 »

  1.   

    在delphi里不用向vb那样生命一大堆的api,我们只要uses相关的单元,delphi就可以自动识别你要用的api函数了。
    dll文件的引用老鬼讲的方法可以的。产生tlb好像是必然的吧。
      

  2.   

    使用dll
    unit djcvt;interface
    uses Windows;
    function PcmtoWave(PcmFileName:Pchar;WaveFileName:Pchar):Integer; stdcall; far  external 'djcvt.dll';
    implementationend.
    ApI:delphi自身已经集成了API函数,只要use相应的单元,就可以直接使用了。
      

  3.   

    delphi 可以自动为dll生产unit接口
      

  4.   

    procedure TForm1.Button1Click(Sender: Tobject);
    var
      ComputerName: array[0..MAX_COMPUTERNAME_LENGTH+1] of char;  // holds the name
      Size: Integer;                                              // holds the size
    begin
      {initialize the computer name size variable}
      Size := MAX_COMPUTERNAME_LENGTH+1;  {retrieve the computer name}
      if GetComputerName(ComputerName, Size) then    Edit1.Text := StrPas(Computername)
      else Showmessage('Computer Name Not Found');
    end;procedure TForm1.Button2Click(Sender: TObject);
    var
      ComputerName: array[0..MAX_COMPUTERNAME_LENGTH+1] of char;  // holds the name
    begin
      {copy the specified name to the ComputerName buffer}
      StrPCopy(ComputerName, Edit1.Text);  {set the computer name}
      if SetComputerName(ComputerName) then    ShowMessage('Computer Name Reset Setting will be used at next startup')
      else ShowMessage('Computer Name Not Reset');
    end;
      

  5.   

    你怎么调用DLL中的函数呢?function GetComputerName(lpBuffer: PChar; var nSize: DWORD): BOOL; stdcall;external 'kernel32.dll' name 'GetComputerNameA';当然该API封装在Windows单元,可以直接用!至于ActiveX控件,Component->Import ActiveX Control
      

  6.   

    例:调用DLL中的API
    Function sndPlaySoundA(lpszSound:LPCSTR ;fuSound:UINT):Boolean stdcall; external 'winmm.dll';
      

  7.   

    调用api只需要在uses单元中将声明函数包含进去就可以了