当前位置: 源码素材网 » VB教程 » 详情页

VB临时文件添加和清空实例

  •   时间:2020-04-18
  • 概述:临时文件

VB源码生成临时文件,简易的临时文件管理,移去开始菜单文档中所有内容,添加到开始菜单的文档中,为测试方便,程序在运行后自动获取自身所在路径,方便添加到临时文件中,具体代码请看如下示:

VERSION 5.00
Begin VB.Form frmDocumentsList
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "临时文件管理"
   ClientHeight    =   1515
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   3690
   Icon            =   "frmDocumentsList.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   1515
   ScaleWidth      =   3690
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2
      Caption         =   "移去开始菜单文档中所有内容"
      Height          =   435
      Left            =   135
      TabIndex        =   2
      Top             =   1005
      Width           =   3390
   End
   Begin VB.TextBox Text1
      Height          =   315
      Left            =   915
      TabIndex        =   1
      Top             =   60
      Width           =   2610
   End
   Begin VB.CommandButton Command1
      Caption         =   "添加到开始菜单的文档中"
      Height          =   435
      Left            =   135
      TabIndex        =   0
      Top             =   480
      Width           =   3390
   End
   Begin VB.Label Label1
      AutoSize        =   -1  'True
      Caption         =   "文件名:"
      Height          =   180
      Left            =   165
      TabIndex        =   3
      Top             =   120
      Width           =   720
   End
End
Attribute VB_Name = "frmDocumentsList"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function SHAddToRecentDocs Lib "shell32.dll" (ByVal flags As Long, ByVal data As String) As Long
Private Const SHARD_PATH = 2&
Private Sub AddDocument(ps_Filename As String)
    Call SHAddToRecentDocs(SHARD_PATH, ps_Filename)
End Sub
Private Sub ClearDocuments()
    Call SHAddToRecentDocs(SHARD_PATH, vbNullString)
End Sub
Private Sub Command1_Click()
    AddDocument Text1.Text
End Sub
Private Sub Command2_Click()
    ClearDocuments
End Sub
Private Sub Form_Load()
 Text1.Text = App.Path & "\test.txt"
End Sub

    相关声明:

      若“VB临时文件添加和清空实例”有损您的权益,请告之我们删除内容。
      部分文章来源于网络,版权归原作者所有。