在WIN95以前,WINDOWS还没有引入注册表的概念,WINDOWS是利用INI文件来存储计算机相关配置的,在API里,WINDOWS提供了丰富的API函数来操作INI文件,LV里也专门有个子类别封装了这些API函数,使用非常方便。
LV使用INI文件来存储配置,应用非常广泛,生成执行文档后也自动生成一个INI文件。
LV主要在下列情况下使用INI文件:
存储前面板或者前面板特定控件的默认值和当前值
存储本次应用的运行结果供下一次启动是调用
存储硬件配置文件
存储硬件配置是非常重要的,比如一般的板卡都有16个数字输出,外部接继电器来控制外部设备,继电器是比较容易损坏的,而通常16个继电器中是有备用的,如何在不改变软件和硬件的情况下把输出更改到另外的继电器上,这样,只需要简单地改动一下外部接线就可以了那,使用配置文件可以轻松实现。
INI文件结构很简单,装了多操作系统的人都知道,WINDOWS本身有个BOOT.INI
[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP
Professional" /noexecute=optin /fastdetect
我们看一下LV软件本身也利用了INI文件来保存配置。
[LabVIEW]
server.tcp.port=3363
server.tcp.enabled=TRUE
server.tcp.access="+127.0.0.1"
IsFirstLaunch=False
PaletteHidddenControlCategories_LocalHost="Modern;System;Classic;Control
Design & Simulation;.NET & ActiveX;Addons;"
PaletteHidddenFunctionlCategories_LocalHost="Programming;Measurement
I/O;Instrument I/O;Vision and Motion;Mathematics;Signal
Processing;Data Communication;Connectivity;Control Design &
Simulation;SignalExpress;Addons;"
menuSetup="default"
saveFloaterLocations=True
find.viListFlags=4
LastErrorListSize=0,0,379,486
paletteStyle="NamedIcons"
NoAdvice070=",CleanUpWire,FlatSequence"
SaveChanges_ApplyToAll=True
PropPageBounds="398;181;884;636"
RecentFiles.pathList="C:\Program Files\National Instruments\LabVIEW
8.5\examples\DAQmx\Analog In\Measure Voltage.llb\Acq&Graph
Voltage-Int Clk.vi;C:\Program Files\National Instruments\LabVIEW
8.5\examples\DAQmx\Analog In\Measure Voltage.llb\Acq&Graph
Voltage-Ext Clk-Analog Ref.vi;C:\Documents and
Settings\Administrator\Local Settings\Temporary Internet
Files\Content.IE5\7M9NS8HF\chart%20right%20to%20left[1].vi;C:\Documents
and Settings\Administrator\My
Documents\windows_environment_variable_reader_writer\Windows
Environment Variable Reader Writer.vi;C:\Documents and
Settings\Administrator\My Documents\MDI.llb\Simple MDI
Demo.vi;D:\Control 1.ctl;C:\Program Files\National
Instruments\LabVIEW 8.5\vi.lib\tree\Tree
Sorter.llb\Join.vi;C:\Program Files\National Instruments\LabVIEW
8.5\vi.lib\Utility\notifier.llb\Create Notifier.vi;C:\Program
Files\National Instruments\LabVIEW
8.5\vi.lib\Utility\notifier.llb\Wait On Notification.vi;C:\Program
Files\National Instruments\LabVIEW
8.5\vi.lib\Utility\inputDevices.llb\Acquire Input Data.vi"
ShowBufferAllocationsArrays=True
ShowBufferAllocationsClusters=True
ShowBufferAllocationsStrings=False
ShowBufferAllocationsPaths=False
ShowBufferAllocationsScalars=False
ShowBufferAllocationsVariants=False
ShowBufferAllocationsOther=False
NewDlgRecentMainTemplates.pathList="C:\Program Files\National
Instruments\LabVIEW
8.5\templates\Frameworks\DesignPatterns\ProducerConsumerEvents.vit"
NewDlgBounds="700;480"
NewDlgRecentTemplates.pathList=""
NewDlgLastSelected="8E4D36AD-F776-4C48-97C6-C1D85EFE889F"
NewDlgSmall=False
NewDlgCollapsed="77E350A8-F9AA-43FF-85E2-454279EBB9A7/Frameworks 3F7CF7A8-5E4D-4EDC-AA25-FA4A326988EF 8E4D36AD-F776-4C48-97C6-C1D85EFE889F"
SuperSecretPrivateSpecialStuff=True
colorHistoryItemA=00000BFF
RecentFiles.projectPathList="C:\Documents and
Settings\Administrator\My Documents\xcontrol events\xcontrol
events\XControl Events Project.lvproj;C:\Program Files\National
Instruments\LabVIEW 8.5\examples\general\xcontrols\Dual Mode
Thermometer\Simple Dual Mode Thermometer XControl.lvproj;C:\Program
Files\National Instruments\LabVIEW
8.5\examples\lvdsc\XControls\Spinner\Spinner.lvproj;C:\Documents
and Settings\Administrator\My Documents\Linked_List_Project\Linked
List\Linked_List_Project.lvproj;D:\TEST\Untitled Project
1.lvproj;C:\Documents and Settings\Administrator\My
Documents\Scripting_Tools_0.16.02\Scripting Tools\Scripting
Tools.lvproj;C:\Documents and Settings\Administrator\My
Documents\IconEditor_85_V2.2\IconEditor.lvproj;C:\Documents and
Settings\Administrator\My Documents\第一名_何凌_公司问题\第一名 何凌 公司问题\Src\VI
company.lvproj"
ProjectExplorer.ClassicPosition=143,53,543,415
colorHistoryItemB=009A8574
editRecentPaths="C:\Program Files\National Instruments\LabVIEW
8.5\vi.lib\Utility\sysinfo.llb;C:\Program Files\National
Instruments\LabVIEW 8.5\vi.lib\Utility\semaphor.llb;C:\Program
Files\National Instruments\LabVIEW
8.5\vi.lib\Utility\miscctls.llb;C:\Program Files\National
Instruments\LabVIEW 8.5\vi.lib\Utility\GetType.llb;C:\Program
Files\National Instruments\LabVIEW
8.5\vi.lib\Utility\inputDevices.llb;C:\Program Files\National
Instruments\LabVIEW 8.5\vi.lib\Utility\notifier.llb;C:\Program
Files\National Instruments\LabVIEW 8.5\vi.lib\tree\Tree Sorter.llb"
LLBMgr_ActivePlugins=""
LLBMgr_RecentPath="C:\Documents and Settings\Administrator\My
Documents\MDI.llb"
colorHistoryItemC=00FF8242
autoerr=2
colorHistoryItemD=00000FDC
colorHistoryItemE=003100DC
colorHistoryItemF=00FFFFFF
colorHistoryItemG=00FF3D00
colorHistoryItemH=000F00DC
colorHistoryItemI=004AFF42
colorHistoryItemJ=00C88E00
colorHistoryItemK=000025FF
exoticControls=TRUE
NoAdvice080=",ClassBrowser"
SuperPrivateScriptingFeatureVisible=True
SuperSecretPrivateSpecialStuff=True
superPrivateScriptingFeatureSichtbar=True
FPFont="0" 18
BDFont="0" 18
toolPaletteLoc=494,22,645,100
LVLibraryThemeColor=006699FF
ini文件非常简单,是文本文件,可以用WINDOWS记事本直接打开,组成结构是一个简单的树型结构,说明如下:
[section1]
key1_section1=VALUE
key2_section2=VALUE
key3_section3=VALUE
[section2]
key1_section2=value
key2_section2=value
key3_section2=value
可以看出结构非常简单,每个INI文件又一个或者多个SECTION组成,每个SECTION又一系列键和键值组成,值的类型可以是BOOLEAN
,DOUBLE,I32,U32,STIRNG,PATH等等


