SETENVIRON
- 来源: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgSetenviron
- 最后更新: 2022-03-26
设置系统环境变量
语法
declare function Setenviron ( byref varexpression as string ) as long用法
result = Setenviron( varexpression )参数
varexpression
以下列(或等效)形式表示的环境变量名称和值:varname=varstring。
(varname 为环境变量的名称,varstring 为要设置的文本值)
返回值
成功时返回零(0),否则返回非零值。
说明
修改系统环境变量。除系统默认的变量外,还有几个其他可编辑的变量。例如 fbgfx,可以通过它选择 FreeBASIC 图形库使用的图形驱动程序形式。
示例
start GeSHi
'e.g. to set the system variable "path" to "c:":
Shell "set path" 'shows the value of path
SetEnviron "path=c:"
Shell "set path" 'shows the new value of pathend GeSHi
start GeSHi
vb
'' WINDOWS ONLY EXAMPLE! - We just set the graphics method to use
'' GDI rather than DirectX (or Direct2D added on new systems).
'' You may note a difference in FPS.
SetEnviron("fbgfx=GDI")
'' Desktop width/height
Dim As Long ScrW, ScrH, BPP
ScreenInfo ScrW, ScrH, BPP
'' Create a screen at the half width/height of your monitor.
'' Normally this would be slow, but GDI is fairly fast for this kind
'' of thing.
ScreenRes ScrW/2, ScrH/2, BPP
'' Start our timer/
Dim As Double T = Timer
'' Lock our page
ScreenLock
Do
'' Print time since last frame
Locate 1, 1
Print "FPS: " & 1 / ( Timer - T )
T = Timer
'' Flip our screen
ScreenUnlock
ScreenLock
'' Commit a graphical change to our screen.
Cls
Loop Until Len(Inkey)
'' unlock our page.
ScreenUnlockend GeSHi
平台差异
- 在 Linux 中,
varexpression必须是持久的(字面量、在主代码中声明的变量或在过程中声明的静态变量),因为 Linux 不会记忆字符串本身,只记录指向其数据字符的指针。
与QB的区别
- 在 QB 中,
Setenviron被称为Environ。
参见
EnvironShell
返回 目录