一个EXE文件有一个窗体旁边站了一个TXT文件,每当TXT文件中写一句
"游戏"   c:\1\游戏.link
EXE中的窗体就多了个"游戏"的按钮,并在点击这个按钮时启动 游戏.link ,从而达到启动游戏的目的

解决方案 »

  1.   

    动态添加控件+ ShellExecute(API),难度不大,搜搜以前的帖子
      

  2.   

    就是打开快捷方式吗?
    用下面声明的api
    Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    Public Const SW_HIDE = 0
    Public Const SW_NORMAL = 1
    Public Const SW_MAX = 10
    Public Const SW_SHOWMAXIMIZED = 3
    Public Const SW_SHOWMINIMIZED = 2
    Public Const SW_SHOWDEFAULT = 10 
      

  3.   

    在form里放一个command,Visible 设为falseOption Explicit
    Dim filename As String
    Private Sub Command1_Click()
        Shell filename
    End SubPrivate Sub Form_Load()
        Dim sFileName As String
        Dim strTemp As String
        sFileName = App.Path & "\1.txt"
        Open sFileName For Input As #1
        Line Input #1, strTemp
        Close #1
            If Left(strTemp, 2) = "游戏" Then
            Command1.Visible = True
            filename = Mid(strTemp, 3)
        End If
    End Sub
      

  4.   

    1.txt建在工程的同一目录下,里面的内容就是 "游戏 c:\1\游戏.link"
    你再根据你的情况修改下上面的东东,大概能满足你的要求了
      

  5.   

    Option ExplicitPrivate Sub Command1_Click(Index As Integer)
        Shell Command1(Index).Tag, vbNormalFocus
    End SubPrivate Sub Form_Load()
    Command1(0).Left = 0
    Dim str1, str2, s
        Open "c:\1.txt" For Input As 1
            While Not EOF(1)
                Input #1, str1, str2
                s = s + 1
                Load Command1(s)
                Command1(s).Caption = str1
                Command1(s).Tag = str2
                Command1(s).Visible = True
                Command1(s).Left = Command1(s - 1).Left + Command1(s).Width + 100
            Wend
        Close
    End Sub1.txt 内容格式如:PhotoShop CS,"D:\Program Files\PhotoShop CS\Photoshop.exe"
    ......可以加载多个游戏命令按钮
      

  6.   

    上面程序 要先添加一个command1 并将index 改为0,将Visible 设为0
      

  7.   

    Option ExplicitPrivate Sub Command1_Click(Index As Integer)
        Shell Command1(Index).Tag, vbNormalFocus
    End SubPrivate Sub Form_Resize()
    Command1(0).Left = -Command1(0).Width - 100
    Dim str1, str2, s
        Open "c:\1.txt" For Input As 1
            While Not EOF(1)
                Input #1, str1, str2
                s = s + 1
                Load Command1(s)
                Command1(s).Caption = str1
                Command1(s).Tag = str2
                Command1(s).Visible = True
                Command1(s).Left = Command1(s - 1).Left + Command1(s).Width + 100
                Command1(s).Top = Command1(s - 1).Top
                If (s Mod 3 = 1) And s > 3 Then
                    Command1(s).Left = 0
                    Command1(s).Top = Command1(s).Top + Command1(s).Height + 100
                End If
            Wend
        CloseEnd Sub