VB¸´ÖÆÎļþ¼ÐµÄ·½·¨(·ÇFSO)
http://www.webuc.net/ddf3/archive/2005/08/25/6142.aspx
²»ÓÃFSOµÄ¸´ÖÆÎļþ¼ÐµÃ·½·¨£¿
ÓÃAPIº¯Êý SHFileOperation
ÒÔÏÂÊÇʹÓÃSHFileOperationɾ³ý¸´ÖÆÒƶ¯ÎļþµÄÀý×Ó£¬¿ÉÒÔ¸´ÖÆÎļþ¼Ð
Private Type SHFILEOPSTRUCT
¡¡¡¡hwnd As Long
¡¡¡¡wFunc As Long
¡¡¡¡pfrom As String
¡¡¡¡pTo As String
¡¡¡¡fFlags As Integer
¡¡¡¡fAnyOperationsAborted As Long
¡¡¡¡hNameMappings As Long
¡¡¡¡lpszProgressTitle As String 'Ö»ÓÐÔÚ FOF_SIMPLEPROGRESS ʱÓÃ
End Type
Private Declare Function SHFileOperation Lib _
"shell32.dll" Alias "SHFileOperationA" (lpFileOp _
As SHFILEOPSTRUCT) As Long
'wFunc ³£Êý
'FO_COPY¡¡ °Ñ pfrom Îļþ¿½±´µ½ pTo¡£
Const FO_COPY = &H2
'FO_DELETE ɾ³ý pfrom ÖеÄÎļþ£¨pTo ºöÂÔ£©¡£
Const FO_DELETE = &H3
'FO_MOVE¡¡ °Ñ pfrom ÎļþÒÆ¶¯µ½ pTo¡£
Const FO_MOVE = &H1
'fFlag ³£Êý
'FOF_ALLOWUNDO ÔÊÐí Undo ¡£
Const FOF_ALLOWUNDO = &H40
'FOF_NOCONFIRMATION ²»ÏÔʾϵͳȷÈ϶Ի°¿ò¡£
Const FOF_NOCONFIRMATION = &H10
'FOF_NOCONFIRMMKDIR ²»ÌáʾÊÇ·ñн¨Ä¿Â¼¡£
Const FOF_NOCONFIRMMKDIR = &H200
'FOF_SILENT ²»ÏÔʾ½ø¶È¶Ô»°¿ò
Const FOF_SILENT = &H4
'Àý×Ó£º
Dim SHFileOp As SHFILEOPSTRUCT
' ɾ³ý
SHFileOp.wFunc = FO_DELETE
SHFileOp.pfrom = "c:\config.old" + Chr(0)
SHFileOp.fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATION
Call SHFileOperation(SHFileOp)
' ɾ³ý¶à¸öÎļþ
SHFileOp.wFunc = FO_DELETE
SHFileOp.pfrom = "c:\config.old" +Chr(0) + "c:\autoexec.old"+Chr(0)
SHFileOp.fFlags = FOF_ALLOWUNDO
Call SHFileOperation(SHFileOp)
' ¿½±´
SHFileOp.wFunc = FO_COPY
SHFileOp.pfrom = "c:\t"
SHFileOp.pTo = "d:\"
SHFileOp.fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMMKDIR
Call SHFileOperation(SHFileOp)
' ÒÆ¶¯
SHFileOp.wFunc = FO_MOVE
SHFileOp.pfrom = "c:\config.old" + Chr(0)
SHFileOp.pTo = "d:\t"
SHFileOp.fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATION
Call SHFileOperation(SHFileOp)
»òÕß
shell "cmd.exe /c xcopy "+chr(34)+"C:\н¨Îļþ¼Ð c:\aa /q /e" +chr(34)
Ïà¹ØÎĵµ£º
È«ÆÁ
Private Sub Form_Load()
Me.Width = Screen.Width
Me.Height = Screen.Height
Me.WindowState = 2
End Sub
Öö¥
1.ÔÚVBµÄͨÓôúÂëÀïдÈëAPIÉùÃ÷
Private Declare Function SetWindowPos& Lib "user32" (ByVal hwnd As Long, _
&n ......
MSComm¿Ø¼þÌṩÁËÁ½ÖÖ´¦ÀíͨÐŵķ½Ê½£ºÒ»ÖÖΪʼþÇý¶¯·½Ê½£¬¸Ã·½Ê½Ï൱ÓÚÒ»°ã³ÌÐòÉè¼ÆÖеÄÖжϷ½Ê½¡£µ±´®¿Ú·¢Éúʼþ»ò´íÎóʱ£¬MSComm¿Ø¼þ»á²úÉúOnCommʼþ£¬Óû§³ÌÐò¿ÉÒÔ²¶»ñ¸Ãʼþ½øÐÐÏàÓ¦´¦Àí¡£±¾ÎĵÄÁ½¸öÀý×Ó¾ù²ÉÓø÷½Ê½¡£ÁíÒ»ÖÖΪ²éѯ·½Ê½£¬ÔÚÓû§³ÌÐòÖÐÉè¼Æ¶¨Ê±»ò²»¶¨Ê±²éѯ MSComm¿Ø¼þµÄijЩÊôÐÔÊÇ·ñ·¢Éú±ä»¯£¬´Ó¶øÈ ......
Private Sub Form_load()
'ÅжϳÌÐòÊÇ·ñÒѾÔËÐÐ
If App.PrevInstance
Then
MsgBox "±¾³ÌÐòÒѾÔËÐУ¡", vbInformation Or vbOKOnly, "ÌáʾÐÅÏ¢"
Unload
Me
Exit Sub
&n ......
http://topic.csdn.net/t/20060401/19/4656391.html
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function SetPriorityClass Lib "kernel32" (ByVal hProcess As Long, ByVal dwPriorityClass As Long) As Long
Const IDLE_PRIORITY_CLASS = &H40 'нø³ÌÓ¦¸ÃÓзdz£µÍµÄ ......