Visual Basic Forum

Visual Basic Forum
für VB6 und VB.NET Programmierer
 
RegistrierenRegistrieren  LoginLogin
Neues Thema eröffnen   Neue Antwort erstellen    Visual Basic Forum Foren-Übersicht -> [VB6] Fragen - Antworten
Autor
Nachricht
GGX_
Newbie
Newbie

Anmeldedatum: 12.06.2007
Beiträge: 10

CMD abfragen
Verfasst am: 29.07.2007, 19:13

Hi Leute,

Ich versuche seit längerer Zeit CMD.exe zu starten und auszulesen.
So wie hier: http://www.kulpa-online.com/tipps-vb-diverses-10017.html nur ohne dem Dos fenster das kurz geöffnet wird.
Kann mir von euch vieleicht jemand sagen wie dies möglich ist?

Danke im Vorraus!
Meine letzte Hoffung...
 
Hamtaro_
« Moderator »<b><font color=green>« Moderator »</font



Anmeldedatum: 06.05.2007
Beiträge: 217
Wohnort: NRW


Verfasst am: 30.07.2007, 07:18

versuchs mal damit: [code]Public Declare Function CreatePipe Lib "kernel32.dll" (phReadPipe As Long, phWritePipe As Long, lpPipeAttributes As Any, ByVal nSize As Long) As Long
Public Declare Function CreateProcessA Lib "kernel32.dll" (ByVal lpApplicationName As Long, ByVal lpCommandLine As String, lpProcessAttributes As SECURITY_ATTRIBUTES, lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Public Declare Function CloseHandle Lib "kernel32.dll" (ByVal hHandle As Long) As Long
Public Declare Function ReadFile Lib "kernel32.dll" (ByVal hFile As Long, ByVal lpBuffer As String, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal lpOverlapped As Any) As Long
Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * 260
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadID As Long
End Type
Private Type STARTUPINFO
cb As Long
lpReserved As Long
lpDesktop As Long
lpTitle As Long
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Public Function DOSOutput(ByVal mCommand As String) As String
On Error Resume Next
Dim proc As PROCESS_INFORMATION, start As STARTUPINFO, sa As SECURITY_ATTRIBUTES, ret As Long, hReadPipe As Long, hWritePipe As Long, lngBytesread As Long, strBuff As String

sa.nLength = Len(sa)
sa.bInheritHandle = 1
sa.lpSecurityDescriptor = 0

If CreatePipe(hReadPipe, hWritePipe, sa, 0) = 0 Then Exit Function

start.cb = Len(start)
start.dwFlags = 257
start.hStdOutput = hWritePipe
start.hStdError = hWritePipe

If CreateProcessA(0, mCommand, sa, sa, 1, 32, 0, 0, start, proc) <> 1 Then Exit Function

CloseHandle hWritePipe

strBuff = String$(256, vbNullChar)
Do
ret = ReadFile(hReadPipe, strBuff, 256, lngBytesread, 0&)
DOSOutput = DOSOutput & Left$(strBuff, lngBytesread)
DoEvents
Loop While ret <> 0

CloseHandle proc.hProcess
CloseHandle proc.hThread
CloseHandle hReadPipe
CloseHandle lngBytesread
End Function

[/code]
Wie findet ihr meine Sig?
 
Neues Thema eröffnen   Neue Antwort erstellen    Visual Basic Forum Foren-Übersicht -> [VB6] Fragen - Antworten

Tags: abfragen, cmd

 
 Verwandte Themen   Aufrufe   Letzter Beitrag 
Keine neuen Beiträge Wie kann ich mich bei euch anmelden?? 914 20.05.2002, 01:28
Keine neuen Beiträge Eine kleine Frage an euch.. 1023 30.09.2007, 09:57
Keine neuen Beiträge .exe erstellen 793 29.03.2007, 18:32
Keine neuen Beiträge exe 645 30.01.2007, 21:34
Keine neuen Beiträge .exe erstellen 730 25.12.2006, 15:14
 


[ Time: 0.1539s ][ Queries: 85 (0.0824s) ][ GZIP on - Debug on ]