8,484
edits
m (/cat, fixed section header issue)  | 
				Paradox-01 (talk | contribs)  m (improving key search)  | 
				||
| Line 176: | Line 176: | ||
         Next  |          Next  | ||
     End Sub  |      End Sub  | ||
==Code snippets (v2)==  | |||
===Registry===  | |||
; Check if key exists  | |||
 Private Function getXsiFromRegistry() As String()  | |||
        Dim oRegKey As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\\Softimage\\SOFTIMAGE Application")  | |||
        Dim XsiPathInReg As String = ""  | |||
        If oRegKey Is Nothing Then  | |||
            XsiPathInReg = ""  | |||
        Else  | |||
            Dim Arr = oRegKey.GetSubKeyNames  | |||
            For Each n In Arr  | |||
                If InStr(n, "Softimage_Mod_Tool_7.5|Application|bin") > 0 Then  | |||
                    XsiPathInReg = Replace(n, "|", "\")  | |||
                    If Directory.Exists(XsiPathInReg) = False Then  | |||
                        XsiPathInReg = ""  | |||
                    End If  | |||
                End If  | |||
            Next  | |||
            oRegKey.Close()  | |||
        End If  | |||
        If XsiPathInReg = "" Then  | |||
            Return New String() {"", "notvalid"}  | |||
        Else  | |||
            Return New String() {XsiPathInReg, "valid"}  | |||
        End If  | |||
    End Function  | |||
    If getXsiFromRegistry(1) = "valid" Then  | |||
        MsgBox(getXsiFromRegistry(0))  | |||
    End If  | |||
: example of a valid, returned path: C:\Softimage\Softimage_Mod_Tool_7.5\Application\bin  | |||
[[Category:Modding tutorials]]  | [[Category:Modding tutorials]]  | ||
edits