MS Access 中的应用程序图标路径

发布于 2024-07-16 06:31:09 字数 43 浏览 2 评论 0原文

如何以编程方式访问 MS Access 2003 中的应用程序图标路径?

How do you access the Application Icon path in MS Access 2003 programmatically?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回眸一笑 2024-07-23 06:31:09

它是数据库对象的自定义属性(“AppIcon”)。

Set dbs = CurrentDb
sAppIconPath = dbs.Properties("AppIcon")

注意 - 如果该属性不存在,您将收到错误消息。

Access 帮助中的此代码显示了如何创建属性:

示例

以下示例显示如何更改 Microsoft Access 数据库 (.mdb) 中的 AppIcon 和 AppTitle 属性。 如果尚未设置或创建属性,则必须使用 CreateProperty 方法创建它们并将它们附加到 Properties 集合。

Sub cmdAddProp_Click()
    Dim intX As Integer
    Const DB_Text As Long = 10
    intX = AddAppProperty("AppTitle", DB_Text, "My Custom Application")
    intX = AddAppProperty("AppIcon", DB_Text, "C:\Windows\Cars.bmp")
    CurrentDb.Properties("UseAppIconForFrmRpt") = 1
    Application.RefreshTitleBar
End Sub

Function AddAppProperty(strName As String, _
        varType As Variant, varValue As Variant) As Integer
    Dim dbs As Object, prp As Variant
    Const conPropNotFoundError = 3270

    Set dbs = CurrentDb
    On Error GoTo AddProp_Err
    dbs.Properties(strName) = varValue
    AddAppProperty = True

AddProp_Bye:
    Exit Function

AddProp_Err:
    If Err = conPropNotFoundError Then
        Set prp = dbs.CreateProperty(strName, varType, varValue)
        dbs.Properties.Append prp
        Resume
    Else
        AddAppProperty = False
        Resume AddProp_Bye
    End If
End Function

It's a custom property ("AppIcon") of the database object.

Set dbs = CurrentDb
sAppIconPath = dbs.Properties("AppIcon")

Note - you will get an error if the property doesn;t exist.

This code from the Access Help shows how to create the property:

Example

The following example shows how to change the AppIcon and AppTitle properties in a Microsoft Access database (.mdb). If the properties haven't already been set or created, you must create them and append them to the Properties collection by using the CreateProperty method.

Sub cmdAddProp_Click()
    Dim intX As Integer
    Const DB_Text As Long = 10
    intX = AddAppProperty("AppTitle", DB_Text, "My Custom Application")
    intX = AddAppProperty("AppIcon", DB_Text, "C:\Windows\Cars.bmp")
    CurrentDb.Properties("UseAppIconForFrmRpt") = 1
    Application.RefreshTitleBar
End Sub

Function AddAppProperty(strName As String, _
        varType As Variant, varValue As Variant) As Integer
    Dim dbs As Object, prp As Variant
    Const conPropNotFoundError = 3270

    Set dbs = CurrentDb
    On Error GoTo AddProp_Err
    dbs.Properties(strName) = varValue
    AddAppProperty = True

AddProp_Bye:
    Exit Function

AddProp_Err:
    If Err = conPropNotFoundError Then
        Set prp = dbs.CreateProperty(strName, varType, varValue)
        dbs.Properties.Append prp
        Resume
    Else
        AddAppProperty = False
        Resume AddProp_Bye
    End If
End Function
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文