Jumat, 22 Oktober 2010

File dan Folder Properties

Fungsi berikut ini digunakan untuk membuka jendela properties dari file, folder, dan drive.

[ VB 6.0 ]
Buat Module baru dan ketikkan :
Private Type SHELLEXECUTEINFO
cbSize As Long
fMask As Long
hwnd As Long
lpVerb As String
lpFile As String
lpParameters As String
lpDirectory As String
nShow As Long
hInstApp As Long
lpIDList As Long
lpClass As String
hkeyClass As Long
dwHotKey As Long
hIcon As Long
hProcess As Long
End Type
Private Declare Function ShellExecuteEx Lib "shell32" Alias "ShellExecuteExA" (SEI As SHELLEXECUTEINFO) As Long

Public Sub ShowProperties(ByVal PathName As String)
Dim SEI As SHELLEXECUTEINFO
SEI.cbSize = Len(SEI)
SEI.fMask = &HC
SEI.lpVerb = "properties"
SEI.lpFile = PathName
Call ShellExecuteEx(SEI)
End Sub




[ VB .NET ]
Buat Module baru dan ketikkan :
<System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)> Private Class SHELLEXECUTEINFO
Public cbSize As Integer
Public fMask As Integer
Public hwnd As Integer
<System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr), Microsoft.VisualBasic.VBFixedString(255)> Public lpVerb As String = ""
<System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr), Microsoft.VisualBasic.VBFixedString(255)> Public lpFile As String = ""
<System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr), Microsoft.VisualBasic.VBFixedString(255)> Public lpParameters As String = ""
<System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.LPWStr), Microsoft.VisualBasic.VBFixedString(255)> Public lpDirectory As String = ""
Public nShow As Integer
Public hInstApp As Integer
Public lpIDList As Integer
Public lpClass As String
Public hkeyClass As Integer
Public dwHotKey As Integer
Public hIcon As Integer
Public hProcess As Integer
End Class

Private Declare Auto Function ShellExecuteEX Lib "shell32.dll" Alias "ShellExecuteEx" (ByVal SEI As SHELLEXECUTEINFO) As Integer

Public Sub ShowProperties(ByVal PathName As String)
Dim SEI As New SHELLEXECUTEINFO
SEI.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(GetType(SHELLEXECUTEINFO))
SEI.lpFile = PathName
SEI.fMask = &HC
SEI.lpVerb = "properties"
ShellExecuteEX(SEI)
End Sub




Contoh : Misalkan Anda inngin membuka properti file yang berlokasi di "D:\Documents\Picture\Logo\Gambar.jpg", tinggal ketikkan :
ShowProperties ("D:\Documents\Picture\Logo\Gambar.jpg")

Label: , , ,

0 Komentar:

Posting Komentar

Pengunjung yang baik selalu meninggalkan jejak berupa komentar. :)

Berlangganan Posting Komentar [Atom]

<< Beranda