ممكن كود يعمل في الفيجوال بيزك يعمل علي فتح وغلق برنامج
EXE
وشكراااااااا
ممكن كود يعمل في الفيجوال بيزك يعمل علي فتح وغلق برنامج
EXE
وشكراااااااا
تشغيل ملف EXE يتم عن طريق الأمر Shell , أما غلقه فممكن عن طريق الحصول على مقبض النافذة بتاعته و أرسال رسالة WM_CLOSE له.
إقرأ معى:
----
المثقفون العرب .. المزورون العرب: تأبين محمود درويش نموذجا
ماذا خسر العالم بانحطاط المسلمين ؟!! للعلامه: أبو الحسن الندوى (كتاب هام لكل مسلم).
المنهجية ومقدمات في الطلب (لطلاب العلم الشرعى)
ما ذكره الأخ msayed صحيح و متابعةً لما ذكره:
يمكنك الحصول على مقبض النافذة Window Handle من خلال توابع API و الكود التالي يوضح ذلك:
ضع الكود التالي في موديول Module
Public Const GW_HWNDNEXT = 2
Public Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, _
ByVal wCmd As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
(ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hwnd As Long, lpdwprocessid As Long) As Long
Function ProcIDFromWnd(ByVal hwnd As Long) As Long
Dim idProc As Long
' Get PID for this HWnd
GetWindowThreadProcessId hwnd, idProc
' Return PID
ProcIDFromWnd = idProc
End Function
Function GetWinHandle(hInstance As Long) As Long
Dim tempHwnd As Long
' Grab the first window handle that Windows finds:
tempHwnd = FindWindow(vbNullString, vbNullString)
' Loop until you find a match or there are no more window handles:
Do Until tempHwnd = 0
' Check if no parent for this window
If GetParent(tempHwnd) = 0 Then
' Check for PID match
If hInstance = ProcIDFromWnd(tempHwnd) Then
' Return found handle
GetWinHandle = tempHwnd
' Exit search loop
Exit Do
End If
End If
' Get the next window handle
tempHwnd = GetWindow(tempHwnd, GW_HWNDNEXT)
Loop
End Functionو هذا الكود في زر الحصول على مقبض النافذة:
Private Sub Command1_Click()
Dim hInst As Long ' Instance handle from Shell function.
Dim hWndApp As Long ' Window handle from GetWinHandle.
Dim buffer As String ' Holds caption of Window.
Dim numChars As Integer ' Count of bytes returned.
' Shell to an application
hInst = Shell("calc.exe")
' Begin search for handle
hWndApp = GetWinHandle(hInst)
If hWndApp <> 0 Then
' Init buffer
buffer = Space$(128)
' Get caption of window
numChars = GetWindowText(hWndApp, buffer, Len(buffer))
' Display window's caption
MsgBox "You shelled to the Application: " & Left$(buffer, numChars)
End If
End Subو في حال وجود أي مشاكل يرجى الإفصاح عنها للفائدة العامة.
مؤسس شبكة مواقع إجابتي أول شبكة مواقع عربية للأسئلة والأجوبة
هذا الموضوع مغلق.