English
Source / code snippets

reg_expand_sz, Environment

 

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

 
Alle Sprachen
System: Windows 8/10, XProfan X4
Programmieren, das spannendste Detektivspiel der Welt.
08/13/16  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

4.173 Views

Untitledvor 0 min.
p.specht11/18/21
Peter Max Müller11/18/21
Wilfried Friebe11/17/21
RudiB.11/17/21
More...

Themeninformationen

this Topic has 1 subscriber:

Michael W. (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie