zoukankan      html  css  js  c++  java
  • GDI为操作系统安装新字体

    Imports System.Drawing.Text
    Public Class Form1
        Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Integer, ByVal Msg As UInteger, ByVal wParam As Integer, ByVal lParam As Integer) As Long
        Declare Function AddFontResource Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String) As Long
        Declare Function WriteProfileString Lib "kernel32" Alias "WriteProfileStringA" (ByVal lpszSection As String, ByVal lpszKeyName As String, ByVal lpszString As String) As Long

        Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            Const WM_FONTCHANGE As Integer = &H1D
            Const HWND_BROADCAST As Integer = &HFFFF

            Dim InFont As New InstalledFontCollection
            Dim IsInstalledBarCodeFont As Boolean = False
            For Each k In InFont.Families
                If k.Name = "C39HrP36DmTt" Then
                    IsInstalledBarCodeFont = True
                    Exit For
                End If
            Next
            If IsInstalledBarCodeFont = False Then
                Dim Ret As Long
                Dim Res As Long
                Dim Ret2 As Long

                FileCopy(CurDir() & "C39HrP36DmTt.TTF", "C:WindowsFontsC39HrP36DmTt.TTF")
                Ret = AddFontResource("C:WindowsFontsC39HrP36DmTt.TTF")
                Res = SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0)
                Ret2 = WriteProfileString("fonts", "C39HrP36DmTt.TTF" + " (TrueType)", "C39HrP36DmTt.TTF")
            End If
            Me.Close()
        End Sub
    End Class

  • 相关阅读:
    面试题-酷家乐面试准备
    英语学习-第一次申请试译的小透明(未完待续)
    操作系统educative版本-笔记1
    周末日记-第一次相对正规的技术教学
    资料推荐-一个神奇的网站educative.io
    面试题-持续集成
    每天5分钟玩转容器技术-读书笔记-第六章
    每天5分钟玩转容器技术-读书笔记-第四章到第五章
    工作日记-文件柜驱动层开发总结
    DP套题练习1
  • 原文地址:https://www.cnblogs.com/longjin2018/p/11737582.html
Copyright © 2011-2022 走看看