Win32 console application "TestEnvironment.exe" demonstrates the usage of class Environment which allows access to several aspects of the runtime environment (directories, command line, environment variable). More...
Win32 console application "TestEnvironment.exe" demonstrates the usage of class Environment which allows access to several aspects of the runtime environment (directories, command line, environment variable).
Log: Run with specific command line arguments (see below):
Initial settings after default construction GetNameOfComputer : SIRIUS GetNameOfUser : Gerald GetCommandLineStr : TestEnvironment.exe -trace TestEnvironment.6 -verbous 2.15 ThisWillBeSkipped -optWithoutParam -lastOpt lastValue GetExeFileFullPath : C:\My Target\debug\TestEnvironment.exe GetExeDir : C:\My Target\debug GetExeDrive : C: GetSourceDir : c:\userdata\gerald\sw\c\testtoolbox GetSourceDrive : c: GetOutputDir : C:\My Target\debug GetReferenceDir : C:\My Target\debug Cut Source dir (CutSourceDirAfter), explicitly set out/ref dirs (SetOutputDir, SetReferenceDir) GetSourceDir : c:\userdata\gerald\sw GetOutputDir : W:\MyDirs\TestOutput GetReferenceDir : Z:\MyArchive\Expected Test Reactions Explicitly set source directory (SetSourceDir) GetSourceDir : Q:\SomeImaginaryDir\MyProject GetSourceDrive : Q: Aceessing command line GetCommandLine : TestEnvironment.exe -trace TestEnvironment.6 -verbous 2.15 ThisWillBeSkipped -optWithoutParam -lastOpt lastValue Existence Check (IsExistingCommandLineOption) -trace : true -notExisting : false Access as string (GetCommandLineOption) -verbous : >2.15< -trace : >TestEnvironment.6< -notExisting : >< Access as numeric value (GetCommandLineOptionVal<>, ignoring conversion errors) -verbous (int) : 2 -verbous (float) : 2.15 -trace (long) : 0 -notExisting (double): 0 Detecting conversion errors by catching exceptions Could not convert command line option >-trace< with value >TestEnvironment.6< to type >long< Could not convert command line option >-notExisting< with value >< to type >double< Accessing system environment variables Existence Check (IsExistingSystemEnvVariable,GetSystemEnvVariable) TTB_TestVariable : [not existing] TTB_TestVariable2 : false HOMEPATH : true Access as string (GetSystemEnvVariable) TTB_TestVariable : >< TTB_TestVariable2 : >< HOMEPATH : >\Dokumente und Einstellungen\Gerald< Access as string after having set some values (SetSystemEnvVariable) TTB_TestVariable : >17.345 ABC 0123< TTB_TestVariable2 : >ABCD< Reading as numeric value (GetSystemEnvVariableVal<>, ignoring conversion errors) TTB_TestVariable (long) : 17 TTB_TestVariable (double) : 17.345 TTB_TestVariable2 (long) : 0 TTB_NotExistingVariable (double) : 0 Detecting conversion errors by catching exceptions Could not convert environment variable >TTB_TestVariable2< with value >ABCD< to type >long< Could not convert environment variable >TTB_NotExistingVariable< with value >< to type >double< Starting not existing exefile (StartExeFile,GetErrorDescription) Start of executable d:\NotExistingDir\notepad.exe failed (details (GetErrorDescription) see trace output) Starting second instance of this application to verify changed environment variables Second instance starts here: Only checking environment variables TTB_TestVariable : >17.345 ABC 0123< TTB_TestVariable2 : >ABCD< TTB_LongVariable : >12345< TTB_DoubleVariable : >3.14< TTB_BoolVariable : >1< HOMEPATH : >\Dokumente und Einstellungen\Gerald< Second instance terminates now Success starting second instance C:\My Target\debug\TestEnvironment.exe