明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1163|回复: 4

怎样把文件添加到启动组?

[复制链接]
发表于 2015-7-24 08:34 | 显示全部楼层 |阅读模式
怎样通过编程的方式将文件添加到启动组?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2015-7-24 19:07 来自手机 | 显示全部楼层
写入注册表 kean有相关的例子
 楼主| 发表于 2015-7-25 22:16 | 显示全部楼层
请老师给个链接!
发表于 2015-7-27 22:37 来自手机 | 显示全部楼层
置顶的kean专题
发表于 2015-8-10 11:08 | 显示全部楼层
    ''' <summary>
    ''' 让程序随CAD自动启动
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub RegisterMyApp()

        '获得 AutoCAD 应用程序注册表键
        Dim sProdKey As String = HostApplicationServices.Current.RegistryProductRootKey
        'Dim sAppName As String = "MyApp"
        Dim sAppName As String = My.Application.Info.AssemblyName

        Dim regAcadProdKey As RegistryKey = Registry.CurrentUser.OpenSubKey(sProdKey)
        Dim regAcadAppKey As RegistryKey = regAcadProdKey.OpenSubKey("Applications", True)

        '检查“MyApp”键是否存在
        Dim subKeys() As String = regAcadAppKey.GetSubKeyNames()
        For Each sSubKey As String In subKeys
            '' 如果已经存在就退出  If the application is already registered, exit
            If (sSubKey.Equals(sAppName)) Then
                '删除已经添加
                UnregisterMyApp()
                'MsgBox("已经添加了!", MsgBoxStyle.Exclamation, "提示")
                'regAcadAppKey.Close()
                'Exit Sub
            End If
        Next

        '' 获得模块的位置   Get the location of this module
        Dim sAssemblyPath As String = Assembly.GetExecutingAssembly().Location

        '' 注册应用程序  Register the application
        Dim regAppAddInKey As RegistryKey = regAcadAppKey.CreateSubKey(sAppName)
        regAppAddInKey.SetValue("DESCRIPTION", sAppName, RegistryValueKind.String)
        regAppAddInKey.SetValue("LOADCTRLS", 14, RegistryValueKind.DWord)
        regAppAddInKey.SetValue("LOADER", sAssemblyPath, RegistryValueKind.String)
        regAppAddInKey.SetValue("MANAGED", 1, RegistryValueKind.DWord)

        regAcadAppKey.Close()
    End Sub

    ''' <summary>
    ''' 删除程序自启动
    ''' </summary>
    ''' <remarks></remarks>
    Public Sub UnregisterMyApp()
        '' 获得 AutoCAD 应用程序注册表键Get the AutoCAD Applications key
        Dim sProdKey As String = HostApplicationServices.Current.RegistryProductRootKey
        'Dim sAppName As String = "MyApp"
        Dim sAppName As String = My.Application.Info.AssemblyName

        Dim regAcadProdKey As RegistryKey = Registry.CurrentUser.OpenSubKey(sProdKey)
        Dim regAcadAppKey As RegistryKey = regAcadProdKey.OpenSubKey("Applications", True)

        '' 删除应用程序键  Delete the key for the application
        Try
            regAcadAppKey.DeleteSubKeyTree(sAppName)
        Catch ex As Exception
            MsgBox("已经取消了!", MsgBoxStyle.Exclamation, "提示")
        End Try

        regAcadAppKey.Close()
    End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-26 17:51 , Processed in 0.497645 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表