1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Donation with Paypal!!!

    Go to your paypal account and send directly donation to [email protected]

    1 month - 10 $ - Standart VIP

    6 months - 20 $- Standart VIP

    1 year - 30 $- Standart VIP

    2 years - 50 $- Standart VIP

    Gold member for life - 150 $- Standart VIP

    High Vip (Standart VIP include) group please send PM or email to [email protected] for info

    After Donation please send email to [email protected]

  3. Donation Ways 2020


    Paysend
  4. Telegram

  5. Delphifan Magazine
Dismiss Notice

Donation with Paypal!!!

Go to your paypal account and send directly donation to [email protected]

1 month - 10 $ - Standart VIP

6 months - 20 $- Standart VIP

1 year - 30 $- Standart VIP

2 years - 50 $- Standart VIP

Gold member for life - 150 $- Standart VIP

High Vip (Standart VIP include) group please send PM or email to [email protected] for info

After Donation please send email to [email protected]

Dismiss Notice
For open hidden message no need write thanks, thank etc. Enough is click to like button on right side of thread.

Delphi - Read or Change Computer Name

Discussion in 'Delphi Programming' started by AdminDF, Feb 14, 2014.

  1. AdminDF
    Online

    AdminDFAdminDF is a Verified Member Delphifan Staff Member DF Staff

    Code:
    { Retrieve the computer name }
    function GetComputerName: string;
    var buffer: array[0..MAX_COMPUTERNAME_LENGTH + 1] of Char; 
    Size: Cardinal;
    begin 
    Size := MAX_COMPUTERNAME_LENGTH + 1; 
    Windows.GetComputerName(@buffer, Size); 
    Result := StrPas(buffer);
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin 
    ShowMessage(GetComputerName);
    end;
    
    { Set the computer name }
    function SetComputerName(AComputerName: string): Boolean;
    var 
    ComputerName: array[0..MAX_COMPUTERNAME_LENGTH + 1] of Char; 
    Size: Cardinal;
    begin 
    StrPCopy(ComputerName, AComputerName); 
    Result := Windows.SetComputerName(ComputerName);
    end;
    
    procedure TForm1.Button2Click(Sender: TObject);
    begin 
    if SetComputerName('NewComputerName') then 
    ShowMessage('Computer Name Reset Setting will be used at next startup.') else ShowMessage('Computer Name Not Reset');
    end;
     

Share This Page