找传奇、传世资源到传世资源站!

Delphi 应用之 获取windows环境参数信息

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

【例子介绍】 Delphi读取Windows环境参数信息.

【相关图片】

from clipboard

from clipboard 

【源码结构】

unit getUSERDNSDOMAIN;

interface

{uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
 }
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, WinSock, BtnListB, NB30, StrUtils, CryptUnit,
  OleCtrls, SHDocVw, ExtCtrls, DB, DBClient,
  uRODataSnapConnection, uROClient, uROWinInetHttpChannel, Grids, DBGrids,
  ImgList, uROBinMessage
  ;


type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    Panel1: TPanel;
    Button2: TButton;
    Button1: TButton;
    Edit1: TEdit;
    function ReadCupSet(setcmd: String): String;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);

  private
    { Private declarations }
  public
    function PathGetSystemPath: string;
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


function TForm1.PathGetSystemPath: string;
var
  Buf: array[0..255] of Char;
begin
  GetWindowsDirectory(@Buf, 255);
  Result := Buf;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  edit1.text := PathGetSystemPath();
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  edit1.text := ReadCupSet('USERDOMAIN');
end;

function TForm1.ReadCupSet(setcmd: String): String;
VAR
  EnvPtr, SavePtr: PChar;
  str, RE: string;
begin
  RE := 'no';
  EnvPtr := GetEnvironmentStrings;
  SavePtr := EnvPtr; //保存GetEnvironmentStrings的返回值,以后要调用FreeEnvironmentStrings来释放内存。
  repeat
    str := StrPas(EnvPtr);
    if AnsiStartsText(setcmd, STR) then
    BEGIN
      RE := rightstr(str, Length(str) - Length(setcmd) - 1);
    END;
    ListBox1.Items.Add(str);
    inc(EnvPtr, StrLen(EnvPtr)   1);
  until EnvPtr^ = #0;
  FreeEnvironmentStrings(SavePtr);
  RESULT := RE;
end;


end.

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复