zoukankan      html  css  js  c++  java
  • 环境变量.JAVA_HOME

    1、资料:(我的文章)

      http://www.cnblogs.com/cppskill/p/8341263.html

    2、

      2.1、界面

      2.2、代码

    unit formMain;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, Registry, IniFiles;
    
    type
      TfrmMain = class(TForm)
        btnRegeditWrite: TButton;
        Memo1: TMemo;
        btnRegeditRead: TButton;
        edtJavaHome: TEdit;
        procedure btnRegeditWriteClick(Sender: TObject);
        procedure FormCreate(Sender: TObject);
        procedure btnRegeditReadClick(Sender: TObject);
      public
        function ReadString( _dwRootKey :DWORD; const _strPath, _strKey :string; var _strOut : string):Integer;
        function WriteString(_dwRootKey :DWORD; const _strPath, _strKey, _strValue :string):Integer;
      public
        function ReadIni():integer;
      end;
    
    var
      frmMain: TfrmMain;
    
    implementation
    
    {$R *.dfm}
    
    function TfrmMain.ReadString(_dwRootKey :DWORD; const _strPath, _strKey: string; var _strOut: string): Integer;
    var reg :TRegistry;
    begin
      Result := 0;
      reg := TRegistry.Create;
      try
        reg.RootKey := _dwRootKey;//HKEY_LOCAL_MACHINE; //'SYSTEMCurrentControlSetControlSession ManagerEnvironment'
        if not reg.OpenKey( _strPath, false ) then
        begin
          Result := -1;
          Exit;
        end;
    
        _strOut := reg.ReadString(_strKey);
      finally
        reg.CloseKey;
        reg.Destroy;
      end;
    end;
    
    function TfrmMain.WriteString(_dwRootKey: DWORD; const _strPath, _strKey, _strValue: string): Integer;
    var reg :TRegistry;
    begin
      reg := TRegistry.Create;
      try
        reg.RootKey := _dwRootKey;//HKEY_LOCAL_MACHINE; //'SYSTEMCurrentControlSetControlSession ManagerEnvironment'
        if not reg.OpenKey( _strPath, false ) then
        begin
          Result := -1;
          Exit;
        end;
    
        reg.WriteString( _strKey, _strValue );
      finally
        reg.CloseKey;
        reg.Destroy;
      end;
    end;
    
    
    procedure TfrmMain.FormCreate(Sender: TObject);
    begin
      ReadIni;
      btnRegeditReadClick(nil);
    end;
    
    procedure TfrmMain.btnRegeditWriteClick(Sender: TObject);
    var strValue :string;
    begin
      Memo1.Lines.Add('');
    // HKEY_LOCAL_MACHINESYSTEMControlSet001Session ManagerEnvironmentpath
    // HKEY_CURRENT_USER Environment
    // HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment (官方)
    
      //strValue := 'C:Program FilesJavajdk1.8.0_152;AAA';
      //strValue := 'C:Program FilesJavajdk1.8.0_152';
      strValue := trim(edtJavaHome.Text);
      if (strValue = '') then
      begin
        Memo1.Lines.Add('新的 JAVA_HOME 的值为空 .');
        Exit;
      end;
      
      if 0>WriteString(HKEY_LOCAL_MACHINE,
        'SYSTEMCurrentControlSetControlSession ManagerEnvironment', 'JAVA_HOME', strValue) then
      begin
        Memo1.Lines.Add('注册表写入失败 .');
        Exit;
      end;
      Memo1.Lines.Add('注册表写入成功 .');
    end;
    
    procedure TfrmMain.btnRegeditReadClick(Sender: TObject);
    var strValue :string;
    begin
      Memo1.Lines.Add('');
    
      if (0 > ReadString(HKEY_LOCAL_MACHINE,
        'SYSTEMCurrentControlSetControlSession ManagerEnvironment', 'JAVA_HOME', strValue)) then
      begin
        Memo1.Lines.Add('读取 注册表 出错');
        Exit;
      end;
      Memo1.Lines.Add('HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironmentJAVA_HOME');
      Memo1.Lines.Add('   '+strValue);
    end;
    
    function TfrmMain.ReadIni(): integer;
    var ini :Tinifile;
        strX86, strX64 :string;
        strFileName :string;
    begin
      strFileName := ExtractFilePath(Paramstr(0)) + '_EnvironmentVariable.ini';
      ini := Tinifile.Create(strFileName);
      try
        strX86 := ini.ReadString('JAVA_HOME', 'Win7x86', '');
        strX64 := ini.ReadString('JAVA_HOME', 'Win7x64', '');
    
        Memo1.Lines.Add('JAVA_HOME(Win7x86) : '+strX86);
        Memo1.Lines.Add('JAVA_HOME(Win7x64) : '+strX64);
      finally
        ini.Free;
      end;
    end;
    
    end.

      2.3、ini文件(_EnvironmentVariable.ini)

    3、

    4、

    5、

  • 相关阅读:
    Serialization and deserialization are bottlenecks in parallel and distributed computing, especially in machine learning applications with large objects and large quantities of data.
    Introduction to the Standard Directory Layout
    import 原理 及 导入 自定义、第三方 包
    403 'Forbidden'
    https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
    These interactions can be expressed as complicated, large scale graphs. Mining data requires a distributed data processing engine
    mysqldump --flush-logs
    mysql dump 参数
    mysql dump 参数
    如果是在有master上开启了该参数,记得在slave端也要开启这个参数(salve需要stop后再重新start),否则在master上创建函数会导致replaction中断。
  • 原文地址:https://www.cnblogs.com/CodeSkill/p/8341464.html
Copyright © 2011-2022 走看看