|
在实际使用中,好像没有这么复杂.
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Sub myflashTrustFiles_creater()
Dim systemdisk As String
systemdisk = GetSysDir()
Dim yyy, a As Object
Set yyy = CreateObject("Scripting.FileSystemObject")
If yyy.FolderExists(systemdisk & "\WINDOWS\system32\Macromed\Flash\FlashPlayerTrust") = True Then yyy.DeleteFolder systemdisk & "\WINDOWS\system32\Macromed\Flash\FlashPlayerTrust"
yyy.CreateFolder (systemdisk & "\WINDOWS\system32\Macromed\Flash\FlashPlayerTrust")
If yyy.FileExists(systemdisk & "\WINDOWS\system32\Macromed\Flash\FlashPlayerTrust\myTrustFiles.cfg") = True Then
Kill systemdisk & "\WINDOWS\system32\Macromed\Flash\FlashPlayerTrust\myTrustFiles.cfg"
End If
Set yyy = CreateObject("Scripting.FileSystemObject")
Set a = yyy.CreateTextFile(systemdisk & "\WINDOWS\system32\Macromed\Flash\FlashPlayerTrust\myTrustFiles.cfg", True)
a.WriteLine (systemdisk & "\")
a.Close
If yyy.FolderExists(systemdisk & "\WINDOWS\system32\Macromed\Flash\FlashPlayerTrust\FlashPlayerTrust") = True Then yyy.DeleteFolder systemdisk & "\WINDOWS\system32\Macromed\Flash\FlashPlayerTrust\FlashPlayerTrust"
yyy.CreateFolder (systemdisk & "\WINDOWS\system32\Macromed\Flash\FlashPlayerTrust\FlashPlayerTrust")
If yyy.FileExists(systemdisk & "\WINDOWS\system32\Macromed\Flash\FlashPlayerTrust\FlashPlayerTrust\myTrustFiles.cfg") = True Then
Kill systemdisk & "\WINDOWS\system32\Macromed\Flash\FlashPlayerTrust\FlashPlayerTrust\myTrustFiles.cfg"
End If
Set yyy = CreateObject("Scripting.FileSystemObject")
Set a = yyy.CreateTextFile(systemdisk & "\WINDOWS\system32\Macromed\Flash\FlashPlayerTrust\FlashPlayerTrust\myTrustFiles.cfg", True)
a.WriteLine (systemdisk & "\")
a.Close
Set yyy = Nothing
Set a = Nothing
End Sub
Private Function GetSysDir() As String
Dim sSave As String
Dim Ret As Long
sSave = Space(255)
Ret = GetSystemDirectory(sSave, 255)
GetSysDir = Left$(sSave, 2)
End Function
然后在Workbook_Open中调用即可,即是插入如下代码:
Call myflashTrustFiles_creater |
|