Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to change windows path programmatically
Message
De
19/12/2004 11:36:57
 
 
À
15/12/2004 10:28:42
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00969441
Message ID:
00970404
Vues:
35
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform