| |
|
|
Michael W. | Since I number of times over this Registry-type stumbled be, have I simply time two Opportunities tested circa on whom korrekten String To gelangen.
Declare string s
Cls
Print " ---------- ExpandEnvStr$(\q%path%\q)"
Print "PATH =",ExpandEnvStr$("%path%")
Print " ----- "
Print "AppData =",ExpandEnvStr$("%APPDATA%")
Print " ----- "
Print "UserProfile =",ExpandEnvStr$("%USERPROFILE%")
Print " ----- "
Print "Computername =",ExpandEnvStr$("%COMPUTERNAME%")
Print " ---------- GetEnvVars$()"
s = GetEnvVars$()
Print s
Print "Das sind", Len( s, "," ), "Environment-variables."
Print " ---------- ExpandEnvPath$(\q%APPDATA%\XProfan\Test\Test.data\q)"
Print ExpandEnvPath$("%APPDATA%")
Print " ---------- "
WaitKey
End
// intern
// worth$ = GetEnv$(EnvVar$)
// SetEnv EnvVar$, worth$
Proc ExpandEnvStr$
// a Registry-String the Type REG_EXPAND_SZ enträtseln
// s = ExpandEnvStr("%path%")
// big-/Kleinschreibung the Env-variables-names is alike.
Parameters string EnvStr
Declare mem inbuf,outbuf, int Size, string erg
Size = 32768// max.
Dim inbuf,Size
Dim outbuf,Size
String inbuf,0 = EnvStr
External("kernel32.dll","ExpandEnvironmentStringsA", inbuf, outbuf, Size)
erg = String $(outbuf,0)
Dispose inbuf,outbuf
Return erg
ENDPROC
Proc GetEnvVars$
// supply a comma-saparierten String
// with all Variablennamen the Environments back
// s = GetEnvVars$()
Declare mem buf
Declare long Size, EnvAdr, p, i
Declare string s, tmp, erg
Size = 32768// max.
Dim buf,Size
EnvAdr = External("kernel32.dll","GetEnvironmentStringsA")
buf = EnvAdr// Edit through area
Clear p, erg
s = String $(buf,p)
While Len(s) > 0
tmp = Trim $(SubStr$(s,1,"="))
Case Len(tmp) : erg = erg + "," + tmp
Inc p, Len(s) + 1
s = String $(buf,p)
EndWhile
Dispose buf
External("kernel32.dll","FreeEnvironmentStringsA",EnvAdr)
Case Len(erg) : erg = Del$(erg,1,1)
Return erg
ENDPROC
// the here wants by me unfortunately not...
Proc ExpandEnvPath$
// supplant defined Ordnernamen in a entire qualified way with ihren pertinent Values.
// s = ExpandEnvPath$("%APPDATA%\XProfan\Test\Test.data")
// ALLUSERSPROFILE, APPDATA, COMPUTERNAME, ProgramFiles, SystemDrive, SystemRoot, USERPROFILE
// The values existieren not all Environments. what not existing, becomes simply not Translated.
// %ALLUSERSPROFILE - the "ALL USERS" Profilordner
// %APPDATA% - Ordner for Anwendungsdaten the current User (Vista u higher)
// %COMPUTERNAME% - the Systemname
// %ProgramFiles% - the "Program Files" Ordner (Programmdateien)
// %SystemDrive% - the system-Laufwerksbuchstabe (z.B. C:)
// %SystemRoot% - the system-tribe-Ordner (z.B. C:\windows)
// %USERPROFILE% - the actually user-Profil (z.B. C:\USERS\<username>)
Parameters string EnvPath
Declare mem inbuf,outbuf, int Size,OK, string erg
Size = 32768// max.
Dim inbuf,Size
Dim outbuf,Size
String inbuf,0 = EnvPath
OK = External("shlwapi.dll","PathUnExpandEnvStringsA", inbuf, outbuf, Size)
Case OK : erg = String $(outbuf,0)
Dispose inbuf,outbuf
Return erg
ENDPROC
well Please, goes still (at least of/ one of it)
Keywords: Environment, ExpandEnvironmentStrings |
|
|
| |
|
|