⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inf.tcl

📁 windml3.0.3
💻 TCL
📖 第 1 页 / 共 5 页
字号:

    # make sure value does not consist of just spaces or tabs
    if {[regexp "\[^ \t\]+" $value]==0} {
        return no_value
    }

    # evaluate all strings between percent signs
    set value [percentEvaluate $value]

    return $value
}

#############################################################################
#
# checkPossibleRegRootNames - checks that the Registry root name is valid.
#
# Checks that <reg_root_string> is a valid value for the Windows registry.
# If a valid abbreviation, returns the full registry root name.  The
# special case HKEY_LOCAL_MACHINE_CURRENT_USER, used only by the inf routines,
# is allowed.
#
# SYNOPSIS
# checkPossibleRegRootNames <reg_root_string>
#
# PARAMETERS:
#   reg_root_string : a registry root name or abbreviation.
#
# RETURNS:
#   If a valid abbreviation, the full registry root name.
#   <reg_root_string> if valid.
#   "invalid" if reg_root_string is an invalid registry root name.
#
# ERRORS: N/A
#

proc checkPossibleRegRootNames {reg_root_string} {
    switch -exact -- $reg_root_string {
        HKCR {
                return HKEY_CLASSES_ROOT
        }
        HKCU {
                return HKEY_CURRENT_USER
        }
        HKLM {
                return HKEY_LOCAL_MACHINE
        }
        HKU {
                return HKEY_USERS
        }
        HKLMCU {
                return HKEY_LOCAL_MACHINE_CURRENT_USER
        }

        # these values do not have to be changed
        HKEY_CLASSES_ROOT {
                return $reg_root_string
        }
        HKEY_CURRENT_USER {
                return $reg_root_string
        }
        HKEY_LOCAL_MACHINE {
                return $reg_root_string
        }
        HKEY_USERS {
                return $reg_root_string
        }
        HKEY_LOCAL_MACHINE_CURRENT_USER {
                return $reg_root_string
        }

        # invalid registry root names
        no_value {
                infputs "INF processing: no value given for reg-root-string"
                return invalid
        }
        default {
                infputs "INF processing: invalid reg-root-string: $reg_root_string"
                return invalid
        }
    }
}

#############################################################################
#
# addSubKeyToRegistry - adds a subkey to the Window registry
#
# Adds the specified subkey "path" to the Windows registry.  For each subkey
# in the path, the subkey is automatially added to the registry if it does
# not already exist.  Thus full subkey path values can be specified
# for <subkey>, instead of having the user add one subkey value at a time.
#
# For the special case where <reg_root_string> is specified as
# HKEY_LOCAL_MACHINE_CURRENT_USER, if the user is installing under NT and
# has administrator privileges, the subkey will be added to both
# HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER.
#
# SYNOPSIS
# addSubKeyToRegisty <reg_root_string> <subkey> <logValue>
#
# PARAMETERS:
#   reg_root_string : a registry root name or abbreviation.
#   subkey : the subkey "path" to be added to the registry.
#   logValue : specifies whether to write to the log file.
#
# RETURNS: N/A
#
# ERRORS: N/A
#

proc addSubkeyToRegistry {reg_root_string subkey logValue} {
    global ctrlVals

    set subkeyList [split $subkey \\]
    set partialKey [lindex $subkeyList 0]

    # save the original value of subkeyList and partialKey
    set original_subkeyList $subkeyList
    set original_partialKey $partialKey


    if {[string compare $reg_root_string HKEY_LOCAL_MACHINE_CURRENT_USER] == 0} {
        if {$ctrlVals(NT) && $ctrlVals(admin)} {
            set reg_root_string_list {HKEY_LOCAL_MACHINE HKEY_CURRENT_USER}
        } else {
            set reg_root_string_list HKEY_CURRENT_USER
        }
    } else {
        set reg_root_string_list $reg_root_string
    }


    foreach reg_root_string $reg_root_string_list {
        # first create the first subkey below reg_root-string
        regKeyCreateLog $reg_root_string "" $partialKey noLog

        # if there is only one subkey, it has just been written.
        if {[llength $subkeyList]==1} {
            return
        }

        # remove the first subkey from the list
        set subkeyList [lrange $subkeyList 1 [expr [llength $subkeyList]-1]]

        # add the remaining subkeys
        foreach key $subkeyList {
            regKeyCreateLog $reg_root_string $partialKey $key $logValue
            append partialKey "\\$key"
        }

        # restore the subkeyList and partialKey for the next iteration
        set subkeyList $original_subkeyList
        set partialKey $original_partialKey
    }
}

#############################################################################
#
# addRegistryLine - adds values extracted from an inf file line to the
#                   registry
#
# Adds the specified value to the Windows Registry.  The subkey is also
# added to the Registry if it does not yet exist.  The format of the
# line read from the inf file is as follows (optional parameters in brackets):
#
#   reg_root_string, subkey, value_name, value, [logValue], [control var]
#
#   reg_root_string : a valid registry root name or abbreviation
#   subkey : the subkey under which the value is to be added.  May be
#            a "path".
#   value_name : name of the value to be added.
#   value : value to be added.
#   [logValue] : specifies whether to write to the setup log file.  "true" by
#                default.  Any other value disables writing to the log.
#   [control var] : conditional control variable allowing value to be written
#                   to the registry.  infVals(control var) must exist and be
#                   set to any value other than 0.
#
# If [control var] is specified, the global variable infVars(control var)
# must exist and be set to a value other than 0.  Otherwise the value will not
# be added to the registry.  This allows for conditional control of adding to
# the registry.
#
# For the special case where <reg_root_string> is specified as
# HKEY_LOCAL_MACHINE_CURRENT_USER, if the user is installing under NT and
# has administrator privileges, the subkey and value will be added to both
# HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER.
#
# SYNOPSIS
# addRegistryLine <line>
#
# PARAMETERS:
#   line : a comma delimited line containing values to be added to the
#          Windows Registry.
#
# RETURNS: N/A
#
# ERRORS: N/A
#

proc addRegistryLine {line} {
    global ctrlVals
    global infVals

    set reg_root_string [nthValueFromCommaDelimitedLine $line 1]
    set reg_root_string [checkPossibleRegRootNames $reg_root_string]
    if {[string compare $reg_root_string invalid] == 0} {
        infputs "INF Processing: cannot add values to registry: invalid reg-root-string: $line"
        return
    }
    if {[string compare $reg_root_string no_value] == 0} {
        infputs "INF Processing: no reg_root_string given: $line"
        return
    }

    set subkey [nthValueFromCommaDelimitedLine $line 2]
    set value_name [nthValueFromCommaDelimitedLine $line 3]
    set value [nthValueFromCommaDelimitedLine $line 4]    
    set logValue [nthValueFromCommaDelimitedLine $line 5]
    set controlvar [nthValueFromCommaDelimitedLine $line 6]

    # set default variables
    if {[string compare $logValue no_value]==0} {
        set logValue "true"
    }
    if {[string compare $value_name no_value]==0} {
        set value_name ""
    }
    if {[string compare $value no_value]==0} {
        set value ""
    }

    # check the control variable
    set addregistry 1
    if {[string compare $controlvar no_value] != 0} {
        if {![info exists infVals($controlvar)]} {
            # control variable is specified but does not exist
            set addregistry 0
            infputs "INF Processing: will not add to registry: $line"
            infputs "$controlvar specified but infVals($controlvar) not set"
        } elseif {$infVals($controlvar)==0} {
            # control variable is set to 0
            set addregistry 0
            infputs "INF Processing: will not add to registry: $line"
            infputs "$controlvar specified but infVals($controlvar) = 0"
        }
    }

    # changes for T2.2             
    if {$addregistry != 0} {
        infputs "INF Processing: adding to Registry:"
        infputs "$reg_root_string $subkey $value_name $value"
        addSubkeyToRegistry $reg_root_string $subkey $logValue
        if {[string compare $reg_root_string HKEY_LOCAL_MACHINE_CURRENT_USER] == 0} {
            if {$ctrlVals(NT) && $ctrlVals(admin)} {
                regValueWriteLog HKEY_LOCAL_MACHINE $subkey $value_name $value $logValue              
            }
            regValueWriteLog HKEY_CURRENT_USER $subkey $value_name $value $logValue  
        } else {
            regValueWriteLog $reg_root_string $subkey $value_name $value $logValue  
        }
    }
    
}

#############################################################################
#
# addIconLine - adds icon to a program group from the values read from
#               an inf file line
#
# Adds icon to the specified program group.  The program group is also
# created if it does not yet exist.  The format of the line to be read from
# the inf file is as follows (optional parameters in brackets):
#
#   group, item, exe, args, dir, fmin, iconIndex, iconPath, [logValue], [OS version], [control var]
#
#   group : the program group to add the icon
#   item : the icon name to be added to the program group
#   exe : the executable or file to be linked with the icon
#   args : the arguments for the executable
#   dir : the directory location of the executable or file.
#   fmin :
#   iconIndex :
#   iconPath: the path to the location of the file to be used as the icon bitmap
#   [logValue] : specifies whether to write to the setup log.  "true" by
#                default.  Any other value disables writing to the log.
#   [OS version] : NT3x, NT4x, or WIN95.  Specifies to add the icon only if the
#                  current OS being used for installation is that which is specified.
#                  If no value is specified the icon will be added for any OS.
#   [control var] : conditional control variable allowing icon to be added.
#                   infVals(control var) must exist and be set to any value other
#                   than 0.
#
# If [control var] is specified, the global variable infVars(control var)
# must exist and be set to a value other than 0.  Otherwise the icon will not
# be added.  This allows for conditional control of adding the icon to the
# program group.
#
# If the icon is to be added to the program group specified by the
# user <group> should be specified to be %defGroupGet% in the inf file.
#
# The icon executable directory and iconPath are written in relation to
# the destination directory specified by the user, i.e. the destination
# directory is prepended to the specified directory and iconPath.  The
# setup program itself queries the user for the destination directory.
#
# SYNOPSIS
# addIconLine <line>
#
# PARAMETERS:
#   line : a comma delimited line containing values in which to add an icon
#          to a program group.
#
# RETURNS: N/A
#
# ERRORS: N/A
#


proc addIconLine {line} {
    global ctrlVals
    global infVals

    set group [nthValueFromCommaDelimitedLine $line 1]
    set item [nthValueFromCommaDelimitedLine $line 2]
    set exe [nthValueFromCommaDelimitedLine $line 3]
    set args [nthValueFromCommaDelimitedLine $line 4]
    set dir [nthValueFromCommaDelimitedLine $line 5]
    set fmin [nthValueFromCommaDelimitedLine $line 6]
    set iconIndex [nthValueFromCommaDelimitedLine $line 7]
    set iconPath [nthValueFromCommaDelimitedLine $line 8]
    set logValue [nthValueFromCommaDelimitedLine $line 9]
    set osversion [nthValueFromCommaDelimitedLine $line 10]
    set controlvar [nthValueFromCommaDelimitedLine $line 11]


    set destinationDir [destDirGet]

    # add trailing slash to destinationDir if it does not exist
    set lastCharacter [string index $destinationDir [expr [string length $destinationDir]-1]]
    if {[string compare $lastCharacter \\] != 0} {
        append destinationDir \\
    }

    # set default values
    if {[string compare $fmin no_value]==0} {
        set fmin 0
    }
    if {[string compare $iconIndex no_value]==0} {
        set iconIndex 0
    }
    if {[string compare $logValue no_value]==0} {
        set logValue "true"
    }
    if {[string compare $args no_value]==0} {
        set args ""
    }

    set addicon 0

    # check the os version
    switch -exact -- $osversion {
        no_value { set addicon 1 }
        default {
           if {[string compare $osversion $ctrlVals(version)]==0} {
           set addicon 1
           } else {
               set addicon 0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -