Environment.Item

導入

v3.5

詳細

システム環境変数のString値を設定したり、戻したりします。

注:Python スクリプト言語では、環境変数の設定にこのプロパティを使用することはできません。パラメタリゼーションされたプロパティの設定を win32 拡張機能がサポートしていないためです。代わりに、下に示すように、XSIUtils の Python COM サポートの生成後に Environment.SetItem メソッドを使用します。

Python 2.3 以降および win32 拡張機能 1.55 以降を使用して、XSIUtils タイプ ライブラリ用の Python COM サポートを生成できます。これにより、項目プロパティの設定が可能な SetItem( name, value)メソッドが作成されます(Environment.SetItem を参照)。

XSIUtils をサポートする Python COM を生成するには、XSIUtils タイプライブラリの makepy.py ユーティリティを実行します。これにより、XSIUtils モジュールがサポートするプロパティおよびオブジェクトのメソッドの説明を含む .py ファイルが生成されます。

C#構文

// get accessor

String IEnvironment.get_Item( String in_bstrName );

// set accessor

IEnvironment.set_Item( String in_bstrName, String pVal );

1. VBScript の例

' how to create and set a new environment variable

XSIUtils.Environment("MY_HOME") = XSIUtils.Environment.Item("XSI_USERHOME")

LogMessage( "my home folder: " + XSIUtils.Environment.Item("MY_HOME") )

2. Python の例

# This example illustrates how to create and set a new environment variable.

# Note that the SetItem method can only be used if python 2.3 or later 

# and win32 extension 1.55 or later are installed and the generated 

# Python COM Support exists for the XSIUtils library. 

# The Python COM support for the XSIUtils can be generated by running the makepy.py 

# utility on the XSIUtils type library. This will generated .py stubs contain

# descriptions of the object's methods and properties supported by the module.

import sys

Application.LogMessage( "Python Version " + sys.version )

if sys.version_info >= (2, 3):

	XSIUtils.Environment.SetItem( "MY_HOME", XSIUtils.Environment.Item("XSI_USERHOME") )

	Application.LogMessage( XSIUtils.Environment.Item("MY_HOME") )

else:

	Application.LogMessage( "Can't use Environment.SetItem with this version" )

関連項目

Environment.SetItem