檢查字型是否存在的方法

飲雪俊楓發表於2018-12-05

        這裡貼一段VB的程式碼,C#參照也是類似的,讀取C盤字型庫中的字型,判斷字型是否存在,不存在即可使用特殊方法對字型進行安裝

這對部分B/S搭建的軟體還是能起到作用的,畢竟有些軟體設定的字型在系統庫中並不存在,如果不安得話,會出現各種亂碼的情況,所以

才需要這麼做

Private Sub CheckPmingLiuFont() Implements IHealthCheck.CheckPmingLiuFont
        Try
            Dim lo_Fkey As RegistryKey = Registry.LocalMachine
            Dim lo_Rkey As RegistryKey = lo_Fkey.OpenSubKey("SOFTWAREMicrosoftWindows NTCurrentVersionFonts")
            Dim ls_FontName() As String = lo_Rkey.GetValueNames()
            Print("20. Check the PMingLiu font.")
            For Each c In ls_FontName
                Dim myvalue As String = lo_Rkey.GetValue(c).ToString
                If myvalue = "mingliu.ttc" Then
                    Print("PMingLiu is existing.")
                    Exit Sub
                End If
            Next
        Catch ex As Exception
        End Try
    End Sub

 

相關文章