|
| Autor |
Nachricht |
BadboyGER_ Tutorial Leser

Anmeldedatum: 03.10.2007 Beiträge: 67
|
[Hilfe] DoS Fenster in Form einbauen.
Verfasst am: 24.04.2008, 16:40 |
|
|
Hallo,
wie das Thema schon sagt , möchte ich das DoS/CMD Fenster bei mir in die Form einfügen lassen. Ich möchte das man dort auch Befehle eintippen kann und abschicken kann. Hat bitte einer einen Source Code für mich.
MfG.
BadboyGER
 |
|
| |
|
 |
exe-cute_ Poster


Anmeldedatum: 21.10.2007 Beiträge: 154
|
Verfasst am: 24.04.2008, 22:48 |
|
|
Für die original Console:
cmd.exe starten und mittels SetParent in deine Form/Picturebox laden.
Google einfach mal. |
|
| |
|
 |
BadboyGER_ Tutorial Leser

Anmeldedatum: 03.10.2007 Beiträge: 67
|
Verfasst am: 26.04.2008, 13:09 |
|
|
Ok werde ich mal Versuchen
// Edit :
Sry ich finde überhaupt nix brauchbares. Bitte gebt mir einen SRC.
Das wäre Perfekt wenn der Source direkt die cmd.exe wählt.
MfG.
BadboyGER
 |
|
| |
|
 |
Hamtaro_ « Moderator »

Anmeldedatum: 06.05.2007 Beiträge: 217 Wohnort: NRW
|
|
| |
|
 |
The-God-of-all_ Poster

Anmeldedatum: 20.05.2007 Beiträge: 170 Wohnort: App.Path
|
Verfasst am: 26.04.2008, 13:32 |
|
|
In dem Fall würde ich es anders machen, der Source sucht das Fenster anhand des Titels. Damit ist es möglich, dass wir den Handle gar nicht finden oder ein anderes Konsolen Fenster als das was wir gestartet haben erwischen.
Die Funktion Shell gibt die ProcessID zurück. Mit dieser kann man den Handle eines Fensters suchen.
Finden eines Handles anhand der ProcessID
Funktionsreferenz zur Funktion SetParent
Edit: Ich habe das mal ausprobiert, unter Windows Vista funktioniert SetParent nicht mit der Konsole. Mit anderen Programmen hat es aber funktioniert. Ich habe mal mit den Funktionen von Microsoft mal eine Funktion AddWindow geschrieben, die Automatisch das angegebene Programm in das andere Fenster lädt.
| Code: | Option Explicit
Public Const GW_HWNDNEXT = 2
Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, _
ByVal hWndNewParent As Long) As Long
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 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
Function AddWindow(Program As String, windowHWND As Long) As Long
Dim pid As Long
Dim newHWND As Long
pid = Shell(Program)
newHWND = GetWinHandle(pid)
SetParent newHWND, windowHWND
AddWindow = newHWND
End Function |
Aufgerufen wird sie so:
| Code: | | AddWindow "calc", Me.HWND |
|
|
| |
|
 |
BadboyGER_ Tutorial Leser

Anmeldedatum: 03.10.2007 Beiträge: 67
|
Verfasst am: 26.04.2008, 13:59 |
|
|
Danke für die Antworten.
// Edit;
Es klappt bei XP auch nicht mit der CMD , die CMD wird immer so aufgrufen.
Das heißt sie wird nicht in die Form implementiert. Bei calc und so geht alles.
MfG.
BadboyGER
 |
|
| |
|
 |
jojo4ever_ Poster

Anmeldedatum: 22.07.2007 Beiträge: 108
|
|
| |
|
 |