Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.
#include "crt/stdlib.bi"Sub main() Print environ("PATH")End Submain()
#include "crt/stdlib.bi"Print *getenv("PATH")
I just changed getenv to environ and it worked fine.
#include "crt/stdlib.bi"Sub main() Print "Homedrive: " & environ("HOMEDRIVE") Print "OS: " & environ("OS") Print "PROMPT: " & environ("PROMPT")End Submain()
Homedrive: C:OS: Windows_NTPROMPT: $p$g
4. Are you actually looking at the compiler output?
#include once "windows.bi"'Windows Master Registry Block is stored in the registry,'at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" as REG_SZ'sDeclare Function SetEnvironment(VarName As String, VarValue As String) As BooleanConst WM_SETTINGSCHANGE = &H1AFunction SetEnvironment(VarName As String,VarValue As String) As Boolean Dim UseRoot as HKEY,usekey As String Dim hk as HKEY Dim returnvalue As Boolean returnvalue=False UseRoot=HKEY_LOCAL_MACHINE UseKey= "SYSTEM\CurrentControlSet\Control\Session Manager\Environment\" 'Open the key... If RegOpenKeyEx(UseRoot,UseKey,0,KEY_ALL_ACCESS,@hk) = ERROR_SUCCESS Then 'hk is a pointer to the key, use it with RegSetValueEx()... SetLastError(0) if RegSetValueEx(hk,StrPtr(VarName),0,REG_SZ,StrPtr(VarValue),Len(VarValue)+1)<>ERROR_SUCCESS Then Print "RegSetValueEx Failed." + "GetLastError returns " + Str(GetLastError()) End If RegCloseKey(hk) Else Print "RegOpenKeyEx Failed. GetLastError() returns " + Str(GetLastError()) End If PostMessage HWND_BROADCAST,WM_SETTINGSCHANGE,0,StrPtr("Environment") return returnvalueEnd FunctionSetEnvironment("Testing","howdy")
I keep wondering why the OP doesn't just use a cmd script ("batch file") to do the things that he wants, and he never answers. This makes me wonder if he is trying to do some kind of script-kiddie thing. Since he steadfastly refuses to tell us, the help he is going to get will not be focused.
not to hide, but the source file is getting a bit large so as a way of making it run faster.
is it the fact that my routine is so simple that you can't wrap your head around it
i dont' know how much clearer than to post my code to make you happy (i did post the routine that is not working). Im not a scriptkiddie nor a kid at all, im a director of a marketing firm and have a need to take my batch files (that run on an sql server) and make them faster (and now with more capabilities, having moved to freebasic.) i have been doing things in the batch file with no issue's but wanted to make things faster, so am i allowed by you to move my batch file into a higher level language? is there some tribunal that i need to attend prior to getting help from you??? is it the fact that my routine is so simple that you can't wrap your head around it and wonder if i have an ulterior motive??? Did I not tip at the gate the proper amount??? Should I move to another forum to get help??? Who's in charge, I want to talk to the management about this!!! Outrageous! Preposterous! Bullocks!!!
The Environment Block of a process is a copy of the environment block of the parent process, or a new, default Environment Block (depending how you spawn the child process).