Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to change windows path programmatically
Message
De
19/12/2004 15:21:04
 
 
À
19/12/2004 11:36:57
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00969441
Message ID:
00970443
Vues:
15
Thank you Gregory!

That is actually more useful than changing the autoexec or whatever.

Alex

>>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
>*---------------------------------------------------------------------------
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform