Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Get WinBatch Process Environment Block Dump GetEnvironmentStringsA FreeEnvironmentStringsA Kernel32.dll DllCall IntControl 32
*OR*
DllCall code for looking at the WinBatch process environment block
strOld = DirGet() DirChange("d:\") ; Set WD of d drive - assumes d is mounted. DirChange(strOld) ; Get a pointer to the block. hKernel32 = DllLoad(StrCat(DirWindows(1),"Kernel32.dll")) pEnv = DllCall(hKernel32,long:"GetEnvironmentStringsA") ; Convoluted method for handling embedded nulls. strEnvBlock = "" x = 0 bDone = 0 While !bDone cValue = IntControl(32, pEnv+x, "byte", 0, 0) If cValue == 0 ; Check for double null block terminator. If IntControl(32, pEnv+x+1, "byte", 0, 0) == 0 Then bDone = @TRUE Else cValue = Char2Num(@LF) ; Change embedded null to lf. EndIf strEnvBlock = StrCat(strEnvBlock,Num2Char(cValue)) x = x + 1 EndWhile ; Clean up DllCall(hKernel32,long:"FreeEnvironmentStringsA",long:pEnv) DllFree(hKernel32) ; Display the block. ; Note that MSFT flatly states that an env variable cannot have ; an '=' in its name but drive variables do... AskItemlist("Environment Block Dump",strEnvBlock,@LF,@UNSORTED,@SINGLE,0)
Article ID: W17930
Filename: Get WinBatch Process Environment Block.txt
File Created: 2011:09:29:14:47:40
Last Updated: 2011:09:29:14:47:40