Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to change windows path programmatically
Message
From
19/12/2004 11:36:57
 
 
To
15/12/2004 10:28:42
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00969441
Message ID:
00970404
Views:
34
This message has been marked as the solution to the initial question of the thread.
>How can you change the windows path programmatically, in a way that takes into account the operating system version?
>
>TIA,
>
>Alex

You can using a bit af api. This is for the running process and its children and is not permanent
function Do_it()

	declare integer GetEnvironmentVariable in kernel32 ;
		string @lpName, ;	&& // environment variable name
		string @lpBuffer,;	&& // buffer for variable value
		integer nSize			&& // size of buffer
	
	declare integer SetEnvironmentVariable in kernel32 ;
		string @lpName,;	&& // environment variable name
		string @lpValue		&& // new value for variable
		
	
	local Success
	Success = TRUE

	local s, n
	s = space(8192)
	
	do case
	case !m.Success
	
	otherwise
		n = GetEnvironmentVariable('PATH', @s, len(m.s))
		
	endcase
	
	do case
	case !m.Success
	
	case empty(m.n)
		assert FALSE
		Success = FALSE
	
	
	case empty(SetEnvironmentVariable('PATH', left(m.s, m.n) + ';c:\temp'))
		assert FALSE
		Success = FALSE
	
	endcase
	
	return m.Success

	
endfunc
*---------------------------------------------------------------------------
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform