و إذا تم ذلك اريد تشغيل ملف تنفيذي من عليها
هل يمكن ذلك ؟؟؟؟؟؟؟؟؟
وفقكم الله
و إذا تم ذلك اريد تشغيل ملف تنفيذي من عليها
هل يمكن ذلك ؟؟؟؟؟؟؟؟؟
وفقكم الله
معقول لا يوجد من يجيب سؤالي ؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟
انا محتار!!!!!!!!!!!!!!!!!
اريد طريقة معرفة رمز cd-rom برمجيا او بأختصار اريد تشغيل برنامج من على السي دي عن طريق مفتاح داخل نموذج او عند فتح النموذج و طبعا ماينفعش حد يقولي اكتب المسار الخاص بالسي دي روم لأنه يختلف من جهاز لأخر
اريد جوابا سريعا من فضلكم اثابكم الله.
وشكرا مقدما
أخى الكريم
اتمنى لو كنت أكثر حلما
عموما اليك هذه الدالة
' **********************************************************************
'
' FUNCTION:
' GetFirstCdRomDriveLetter()
'
' PURPOSE:
' Finds the first CD-ROM device and then returns its drive letter.
'
' ARGUMENTS:
' None
'
' RETURNS:
' A string that represents the first CD-ROM drive letter. If the
' function fails for any reason, it returns vbNullString.
'
' **********************************************************************
Declare Function GetDriveType Lib "kernel32" Alias _
"GetDriveTypeA" (ByVal nDrive As String) As Long
Declare Function GetLogicalDriveStrings Lib "kernel32" Alias _
"GetLogicalDriveStringsA" (ByVal nBufferLength As Long, _
ByVal lpBuffer As String) As Long
Public Const DRIVE_CDROM As Long = 5
Function GetFirstCdRomDriveLetter() As String
' Declare variables.
Dim lDriveType As Long
Dim strDrive As String
Dim lStart As Long: lStart = 1
' Create a string to hold the logical drives.
Dim strDrives As String
strDrives = Space(150)
' Get the logial drives on the system.
' If the function fails it returns zero.
Dim lRetVal As Long
lRetVal = GetLogicalDriveStrings(150, strDrives)
' Check to see if GetLogicalDriveStrings() worked.
If lRetVal = 0 Then
' Get GetLogicalDriveStrings() failed.
GetFirstCdRomDriveLetter = vbNullString
Exit Function
End If
' Get the string that represents the first drive.
strDrive = Mid(strDrives, lStart, 3)
Do
' Test the first drive.
lDriveType = GetDriveType(strDrive)
' Check if the drive type is a CD-ROM.
If lDriveType = DRIVE_CDROM Then
' Found the first CD-ROM drive on the system.
GetFirstCdRomDriveLetter = strDrive
Exit Function
End If
' Increment lStart to next drive in the string.
lStart = lStart + 4
' Get the string that represents the first drive.
strDrive = Mid(strDrives, lStart, 3)
Loop While (Mid(strDrives, lStart, 1) <> vbNullChar)
End Functionو هذا مثال لتطبيقها
Sub Main
Dim strDriveLetter as String
' Call the GetFirstCdRomDriveLetter() and store the
' return value in strDriveLetter.
strDriveLetter = GetFirstCdRomDriveLetter()
' Display the drive letter in a message box.
MsgBox strDriveLetter
End Subو لفتح اى ملف
ضع هذا الكود فى وحدة نمطية
Public Enum actionType OpenFile End Enum Public Const SW_SHOWNORMAL As Long = 1 Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _ (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _ ByVal lpParameters As String, ByVal lpDirectory As String, _ ByVal nShowCmd As Long) As Long Function ExecuteFile(fileName As String, action As actionType) Dim sAction As String ShellExecute 0, sAction, fileName, vbNullString, "", SW_SHOWNORMAL End Function
و لاستدعاء الدالة
استخدم هذا الكود
ExecuteFile "C:\MyFile.xls", OpenFile
غير امتداد الملف الى ما يناسبك
تم تعديل هذه المشاركة بواسطة Abo_Yossof في 24 نوفمبر 2010 في 01:14
Abo_Yossof كتب:أخى الكريم
اتمنى لو كنت أكثر حلما
عموما اليك هذه الدالة
' ********************************************************************** ' ' FUNCTION: ' GetFirstCdRomDriveLetter() ' ' PURPOSE: ' Finds the first CD-ROM device and then returns its drive letter. ' ' ARGUMENTS: ' None ' ' RETURNS: ' A string that represents the first CD-ROM drive letter. If the ' function fails for any reason, it returns vbNullString. ' ' ********************************************************************** Declare Function GetDriveType Lib "kernel32" Alias _ "GetDriveTypeA" (ByVal nDrive As String) As Long Declare Function GetLogicalDriveStrings Lib "kernel32" Alias _ "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, _ ByVal lpBuffer As String) As Long Public Const DRIVE_CDROM As Long = 5 Function GetFirstCdRomDriveLetter() As String ' Declare variables. Dim lDriveType As Long Dim strDrive As String Dim lStart As Long: lStart = 1 ' Create a string to hold the logical drives. Dim strDrives As String strDrives = Space(150) ' Get the logial drives on the system. ' If the function fails it returns zero. Dim lRetVal As Long lRetVal = GetLogicalDriveStrings(150, strDrives) ' Check to see if GetLogicalDriveStrings() worked. If lRetVal = 0 Then ' Get GetLogicalDriveStrings() failed. GetFirstCdRomDriveLetter = vbNullString Exit Function End If ' Get the string that represents the first drive. strDrive = Mid(strDrives, lStart, 3) Do ' Test the first drive. lDriveType = GetDriveType(strDrive) ' Check if the drive type is a CD-ROM. If lDriveType = DRIVE_CDROM Then ' Found the first CD-ROM drive on the system. GetFirstCdRomDriveLetter = strDrive Exit Function End If ' Increment lStart to next drive in the string. lStart = lStart + 4 ' Get the string that represents the first drive. strDrive = Mid(strDrives, lStart, 3) Loop While (Mid(strDrives, lStart, 1) <> vbNullChar) End Functionو هذا مثال لتطبيقها
Sub Main Dim strDriveLetter as String ' Call the GetFirstCdRomDriveLetter() and store the ' return value in strDriveLetter. strDriveLetter = GetFirstCdRomDriveLetter() ' Display the drive letter in a message box. MsgBox strDriveLetter End Subو لفتح اى ملف
ضع هذا الكود فى وحدة نمطية
Public Enum actionType OpenFile End Enum Public Const SW_SHOWNORMAL As Long = 1 Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _ (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _ ByVal lpParameters As String, ByVal lpDirectory As String, _ ByVal nShowCmd As Long) As Long Function ExecuteFile(fileName As String, action As actionType) Dim sAction As String ShellExecute 0, sAction, fileName, vbNullString, "", SW_SHOWNORMAL End Functionو لاستدعاء الدالة
استخدم هذا الكود
ExecuteFile "C:\MyFile.xls", OpenFileغير امتداد الملف الى ما يناسبك
اولا انا شاكر جدا لردك و حلمك و باعتذر اخي الكريم حيث ان الموضوع غاية في الأهمية
ثانيا من الواضح لم استطيع التعبير جيدا عن ما اريده دعني اشرحه من جديد:
بالنسبة للجزء الأول من ردك و الخاص بالدالة فهو جيد جدا ومفيد و قد فهمته جيدا اما الجزء الثاني الخاص بالملف فانا اريد فتح ملف تنفيذي موجود على الأسطوانة و ذلك من خلال فتح نموذج داخل الأكسيس بمعنى انه [ حدث عند الفتح ] يذهب اوتوماتيكيا لفتح هذا الملف لبدء عملية تثبيت البرنامج الموجود على الأسطوانة وطبعا مسار الأسطوانة يختلف من جهاز لأخر
فجهزي مثلا السيدي روم رمز الدريف [\:L] و جهاز العمل الدريف [\:E] المقصود من كلامي انه مهما كان مكان الدرايف يعمل البرنامج
البرنامج الموجود على الأسطوانة مساره L:\setup.exe طبعا بغض النظر عن رمز الدرايف.
شاكر لحسن المتابعة مشرفنا القدير.
aelshaikh كتب:اولا انا شاكر جدا لردك و حلمك و باعتذر اخي الكريم حيث ان الموضوع غاية في الأهميةثانيا من الواضح لم استطيع التعبير جيدا عن ما اريده دعني اشرحه من جديد:بالنسبة للجزء الأول من ردك و الخاص بالدالة فهو جيد جدا ومفيد و قد فهمته جيدا اما الجزء الثاني الخاص بالملف فانا اريد فتح ملف تنفيذي موجود على الأسطوانة و ذلك من خلال فتح نموذج داخل الأكسيس بمعنى انه [ حدث عند الفتح ] يذهب اوتوماتيكيا لفتح هذا الملف لبدء عملية تثبيت البرنامج الموجود على الأسطوانة وطبعا مسار الأسطوانة يختلف من جهاز لأخرفجهزي مثلا السيدي روم رمز الدريف [\:L] و جهاز العمل الدريف [\:E] المقصود من كلامي انه مهما كان مكان الدرايف يعمل البرنامج البرنامج الموجود على الأسطوانة مساره L:\setup.exe طبعا بغض النظر عن رمز الدرايف.شاكر لحسن المتابعة مشرفنا القدير.
اخى الكريم
و ما الداعى من الكود الاول اذا فوظيفته ان يعطيك درايف السى دى
عموما جرب المرفق
و ان شاء الله يلبى ما تريد