In der Demo hier kannst du den Ausführen-Dialog neu beschriften.
Wenn du nicht nur Copy & Paste machst wirst du es wohl auch anderswo hinbekommen.
Imports System.Runtime.InteropServices
Public Class Form1
Declare Unicode Function SHRunDialog Lib "shell32" Alias "#61" (ByVal hwnd _
As IntPtr, ByVal hIcon As IntPtr, _
ByVal sPath As String, ByVal Title As String, ByVal Prompt As _
String, ByVal Flags As Int32) As Int32
Declare Auto Function SendMessage Lib "user32" (ByVal hWnd As IntPtr, ByVal _
Msg As Int32, ByVal wParam As Int32, ByVal lParam As String) As Int32
Declare Function EnumChildWindows Lib "user32" (ByVal hWnd As IntPtr, ByVal _
Callback As EnumWinProc, ByVal lParam As IntPtr) As Boolean
Declare Auto Function FindWindow Lib "user32" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As IntPtr
Delegate Function EnumWinProc(ByVal hWnd As IntPtr, ByVal Param As IntPtr) _
As Boolean
Const WM_SETTEXT As Int32 = &HC
Private WithEvents Btn As New Button With {.Dock = DockStyle.Bottom, .Text _
= "Start", .Parent = Me}
Private Sub Form1_Shown(ByVal sender As Object, ByVal e As _
System.EventArgs) Handles Me.Shown
Me.CenterToScreen()
SHRunDialog(Nothing, Nothing, String.Empty, "Ausführen", "Prog." & _
"starten", 0)
End Sub
Private Sub Btn_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Btn.Click
Dim wnd = FindWindow(Nothing, "Ausführen") 'Fenster mit diesem
' Titeltext suchen
If Not wnd = Nothing Then
Dim hnd() = GetChildWindows(wnd) '9 ChildWindows
SendMessage(hnd(1), WM_SETTEXT, Nothing, "Lbl1") 'Programm
' starten
SendMessage(hnd(2), WM_SETTEXT, Nothing, "Lbl2") 'Öffnen
SendMessage(hnd(4), WM_SETTEXT, Nothing, "???.exe") 'das Textfeld
SendMessage(hnd(6), WM_SETTEXT, Nothing, "Btn1") 'OK
SendMessage(hnd(7), WM_SETTEXT, Nothing, "Btn2") 'Abbrechen
SendMessage(hnd(8), WM_SETTEXT, Nothing, "Btn3") 'Durchsuchen...
End If
End Sub
Private Function GetChildWindows(ByVal hnd As IntPtr) As IntPtr()
Dim childlist As New List(Of IntPtr), gh = GCHandle.Alloc(childlist)
EnumChildWindows(hnd, AddressOf EnumWindows, GCHandle.ToIntPtr(gh))
gh.Free()
Return childlist.ToArray
End Function
Private Function EnumWindows(ByVal Handle As IntPtr, ByVal param As IntPtr) _
As Boolean
Dim ptrlist = CType(GCHandle.FromIntPtr(param).Target, List(Of IntPtr))
ptrlist.Add(Handle)
Return True
End Function
End ClassMfG GPM 0 |