hamata00
11-29-2006, 09:08 PM
السلام عليكم
عن طريق API نستطيع ذلك
افتح مشروع جديد وأضف
1- text1
2- label1
3-CommonDialog1 تختارها من مرجع الادوات او قم بختيار الملف comdlg32.ocx من دليل system
4- Command1
اضف الكود الاتي :
Private Const OPEN_EXISTING = 3
Private Declare Function GetFileSize Lib "kernel32" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Sub Command1_Click()
Dim lngHandle As Long
Dim lngLong As Long
With Me
.CommonDialog1.DialogTitle = "Get File Size"
.CommonDialog1.ShowOpen
'If CommonDialog1.CancelError = True Then
'Text1.Text = " "
'Exit Sub
'End If
End With
FN = Me.CommonDialog1.FileName
lngHandle = CreateFile(FN, GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, 0, 0)
'Get the file's size
fsize = (GetFileSize(lngHandle, 0))
If fsize > 200000 Then
MsgBox "biiiiiiig", vbCritical, "File size"
Exit Sub
End If
Text1.Text = fsize / 1000 & " " & "Kbyat"
CloseHandle lngHandle
End Sub
Private Sub Form_Load()
Me.Top = (Screen.Height - Me.Height) / 2
Me.Left = (Screen.Width - Me.Width) / 2
Me.Caption = "Get File Size"
End Sub
هذه الخاصية تستعمل في الحمايات للتاكد من ان حجم الملف لا يتجاوز المحدد عندما يكون البرنامج نسخة عرض ..
ارجو الرد من الاعضاء بعد التجربة
عن طريق API نستطيع ذلك
افتح مشروع جديد وأضف
1- text1
2- label1
3-CommonDialog1 تختارها من مرجع الادوات او قم بختيار الملف comdlg32.ocx من دليل system
4- Command1
اضف الكود الاتي :
Private Const OPEN_EXISTING = 3
Private Declare Function GetFileSize Lib "kernel32" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Sub Command1_Click()
Dim lngHandle As Long
Dim lngLong As Long
With Me
.CommonDialog1.DialogTitle = "Get File Size"
.CommonDialog1.ShowOpen
'If CommonDialog1.CancelError = True Then
'Text1.Text = " "
'Exit Sub
'End If
End With
FN = Me.CommonDialog1.FileName
lngHandle = CreateFile(FN, GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0&, OPEN_EXISTING, 0, 0)
'Get the file's size
fsize = (GetFileSize(lngHandle, 0))
If fsize > 200000 Then
MsgBox "biiiiiiig", vbCritical, "File size"
Exit Sub
End If
Text1.Text = fsize / 1000 & " " & "Kbyat"
CloseHandle lngHandle
End Sub
Private Sub Form_Load()
Me.Top = (Screen.Height - Me.Height) / 2
Me.Left = (Screen.Width - Me.Width) / 2
Me.Caption = "Get File Size"
End Sub
هذه الخاصية تستعمل في الحمايات للتاكد من ان حجم الملف لا يتجاوز المحدد عندما يكون البرنامج نسخة عرض ..
ارجو الرد من الاعضاء بعد التجربة



