史萊姆論壇

返回   史萊姆論壇 > 專業主討論區 > 程式語言討論區
忘記密碼?
論壇說明 標記討論區已讀

歡迎您來到『史萊姆論壇』 ^___^

您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的!

請點擊這裡:『註冊成為我們的一份子!』

Google 提供的廣告


發文 回覆
 
主題工具 顯示模式
舊 2016-04-19, 12:31 AM   #1
魔術王子
版區管理員
 
魔術王子 的頭像
榮譽勳章
UID - 115097
在線等級: 級別:42 | 在線時長:1971小時 | 升級還需:50小時級別:42 | 在線時長:1971小時 | 升級還需:50小時
註冊日期: 2004-01-13
住址: 魔術學園
文章: 2931
精華: 0
現金: 14698 金幣
資產: 2678318 金幣
預設 程式 - [使用版本VB2008]檔案直接刪除的程式[檔案剪碎工具]

顧名思義就是直接刪除檔案而不丟入回收桶(有人建議命名為碎紙機)
當將要刪除的檔案拖曳到程式圖示上時,程式就會顯示是否永久刪除這些檔案
如果直接執行程式,會出現建立捷徑及清空回收桶的功能
有試過用C++ Builder寫,可惜的是C++ Builder無法處理UTF-8格式的檔名
以下是程式碼:

引用:
作者: Form1.vb
Public Class Form1
PHP 語法:
    Private Declare Function SHEmptyRecycleBin Lib "shell32.dll" Alias "SHEmptyRecycleBinA" (ByVal hWnd As Int32ByVal pszRootPath As StringByVal dwFlags As Int32) As Int32
    
Private Declare Function SHUpdateRecycleBinIcon Lib "shell32.dll" () As Int32

    
Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgsHandles MyBase.Load
        
If My.Application.CommandLineArgs.Count 0 Then
            Application
.DoEvents()
            If 
MsgBox("確定要永久刪除這 " My.Application.CommandLineArgs.Count " 個項目?"MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
                
For 0 To My.Application.CommandLineArgs.Count 1
                    
If My.Computer.FileSystem.FileExists(My.Application.CommandLineArgs(i).ToStringThen
                        My
.Computer.FileSystem.DeleteFile(My.Application.CommandLineArgs(i).ToStringFileIO.UIOption.OnlyErrorDialogsFileIO.RecycleOption.DeletePermanently)
                    Else
                        
My.Computer.FileSystem.DeleteDirectory(My.Application.CommandLineArgs(i).ToStringFileIO.DeleteDirectoryOption.DeleteAllContents)
                    
End If
                
Next
            End 
If
            
Close()
        
End If
        If 
My.Computer.FileSystem.FileExists(My.Computer.FileSystem.SpecialDirectories.Desktop "\檔案剪碎工具.LNK"Then Button2.Enabled False
    End Sub

    
Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button1.Click
        SHEmptyRecycleBin
(Me.HandlevbNullString0)
        
SHUpdateRecycleBinIcon()
    
End Sub

    
Private Sub Button2_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button2.Click
        Dim strFolder 
As String My.Computer.FileSystem.CurrentDirectorystrEXE As String "Shredder.exe"
        
Dim objWS As Object
        objWS 
CreateObject("WScript.Shell")
        
With objWS.CreateShortCut(objWS.SpecialFolders("Desktop") & "\檔案剪碎工具.LNK"'& Replace(strEXE, ".EXE", ".LNK", 1, , 1))
            .TargetPath = objWS.ExpandEnvironmentStrings(strFolder & "\" & strEXE)
            .WorkingDirectory = strFolder
            .Description = "檔案剪碎工具"
            .WindowStyle = 4
            .IconLocation = objWS.ExpandEnvironmentStrings(strFolder & "\" & strEXE & ",0")
            .Save()
        End With
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Close()
    End Sub
End Class 
以下是表單:
引用:
作者: Form1.Designer.vb
PHP 語法:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial 
Class Form1
    Inherits System
.Windows.Forms.Form

    
'Form 覆寫 Dispose 以清除元件清單。
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    '
為 Windows Form 設計工具的必要項
    
Private components As System.ComponentModel.IContainer

    
'注意: 以下為 Windows Form 設計工具所需的程序
    '
可以使用 Windows Form 設計工具進行修改。
    
'請不要使用程式碼編輯器進行修改。
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.Button3 = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'Button1
        '
        
Me.Button1.Location = New System.Drawing.Point(1212)
        
Me.Button1.Name "Button1"
        
Me.Button1.Size = New System.Drawing.Size(7523)
        
Me.Button1.TabIndex 0
        Me
.Button1.Text "清空回收桶"
        
Me.Button1.UseVisualStyleBackColor True
        
'
        '
Button2
        
'
        Me.Button2.Location = New System.Drawing.Point(12, 41)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(75, 23)
        Me.Button2.TabIndex = 1
        Me.Button2.Text = "建立捷徑"
        Me.Button2.UseVisualStyleBackColor = True
        '
        'Button3
        '
        
Me.Button3.Location = New System.Drawing.Point(1270)
        
Me.Button3.Name "Button3"
        
Me.Button3.Size = New System.Drawing.Size(7523)
        
Me.Button3.TabIndex 2
        Me
.Button3.Text "關閉"
        
Me.Button3.UseVisualStyleBackColor True
        
'
        '
Form1
        
'
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(100, 104)
        Me.Controls.Add(Me.Button3)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "Form1"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Shredder"
        Me.ResumeLayout(False)

    End Sub
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents Button3 As System.Windows.Forms.Button

End Class 

此帖於 2016-04-30 10:42 AM 被 mini 編輯.
__________________
『唸金母心咒:嗡。金母。悉地。吽。』
持此咒者,可免一切瘟疫,一切瘟神抱頭四散。

魔術就是欣賞神奇的效果
如果魔術的秘密被破解了
那魔術就失去欣賞的價值
魔術王子 目前離線  
送花文章: 1517, 收花文章: 1551 篇, 收花: 3886 次
回覆時引用此帖
向 魔術王子 送花的會員:
mini (2016-04-22)
感謝您發表一篇好文章
發文 回覆


主題工具
顯示模式

發表規則
不可以發文
不可以回覆主題
不可以上傳附加檔案
不可以編輯您的文章

論壇啟用 BB 語法
論壇啟用 表情符號
論壇啟用 [IMG] 語法
論壇禁用 HTML 語法
Trackbacks are 禁用
Pingbacks are 禁用
Refbacks are 禁用

相似的主題
主題 主題作者 討論區 回覆 最後發表
程式 - [使用版本VB2008]純文字RPG遊戲 魔術王子 程式語言討論區 0 2015-02-03 10:51 PM
程式 - [使用版本VB2008]螢幕擷取 魔術王子 程式語言討論區 0 2014-02-07 08:43 PM
程式 - [使用版本VB2008]TIF圖檔瀏覽 魔術王子 程式語言討論區 0 2014-02-06 09:01 PM
程式 - [使用版本VB2008]在桌面建立程式捷徑 魔術王子 程式語言討論區 0 2014-02-06 08:31 PM
程式 - [使用版本VB2008]使用INI檔儲存程式最後狀態 魔術王子 程式語言討論區 0 2014-02-05 07:46 PM


所有時間均為台北時間。現在的時間是 05:18 PM


Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2024, Jelsoft Enterprises Ltd.


SEO by vBSEO 3.6.1