|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Apr 2001
Messaggi: 17
|
Visual Basic 6: creare applicazioni DOS
salve a tutti.
La mia domanda è molto semplice: Come faccio a creare in VB6 un programma che gira sotto DOS ? Qualcuno ha mai usato il PartitionMagic sotto DOS ? ... beh ... io vorrei realizzare qualcosa del genere. Insomma fare un programma con tanto di form e mouse che sia avvia da DOS. Spero di essere stato chiaro. GRAZIE ! Joseph. |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
In DOS puro non puoi fare niente con VB... Al limite puoi fare qualcosa con la console in testo di Windows...
Codice:
Private Const BACKGROUND_INTENSITY = &H80&
Private Const BACKGROUND_SEARCH = &H20&
Private Const FOREGROUND_INTENSITY = &H8&
Private Const FOREGROUND_SEARCH = (&H10&)
Private Const ENABLE_LINE_INPUT = &H2&
Private Const ENABLE_ECHO_INPUT = &H4&
Private Const ENABLE_MOUSE_INPUT = &H10&
Private Const ENABLE_PROCESSED_INPUT = &H1&
Private Const ENABLE_WINDOW_INPUT = &H8&
Private Const ENABLE_PROCESSED_OUTPUT = &H1&
Private Const ENABLE_WRAP_AT_EOL_OUTPUT = &H2&
Private Const STD_OUTPUT_HANDLE = -11&
Private Const STD_INPUT_HANDLE = -10&
Private Const STD_ERROR_HANDLE = -12&
Private Const INVALID_HANDLE_VALUE = -1&
Private Declare Function AllocConsole Lib "kernel32" () As Long
Private Declare Function FreeConsole Lib "kernel32" () As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetStdHandle Lib "kernel32" (ByVal nStdHandle As Long) As Long
Private Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA" (ByVal hConsoleOutput As Long, lpBuffer As Any, ByVal nNumberOfCharsToWrite As Long, lpNumberOfCharsWritten As Long, lpReserved As Any) As Long
Private Declare Function ReadConsole Lib "kernel32" Alias "ReadConsoleA" (ByVal hConsoleInput As Long, ByVal lpBuffer As String, ByVal nNumberOfCharsToRead As Long, lpNumberOfCharsRead As Long, lpReserved As Any) As Long
Private Declare Function SetConsoleTextAttribute Lib "kernel32" (ByVal hConsoleOutput As Long, ByVal wAttributes As Long) As Long
Private Declare Function SetConsoleTitle Lib "kernel32" Alias "SetConsoleTitleA" (ByVal lpConsoleTitle As String) As Long
Private hConsoleOut As Long, hConsoleIn As Long, hConsoleErr As Long
Private Sub Form_Load()
'KPD-Team 2001
'URL: http://www.allapi.net/
'E-Mail: [email protected]
'Create console
If AllocConsole() Then
hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE)
If hConsoleOut = INVALID_HANDLE_VALUE Then MsgBox "Unable to get STDOUT"
hConsoleIn = GetStdHandle(STD_INPUT_HANDLE)
If hConsoleOut = INVALID_HANDLE_VALUE Then MsgBox "Unable to get STDIN"
Else
MsgBox "Couldn't allocate console"
End If
'Set the caption of the console window
SetConsoleTitle "The KPD-Team 2001"
'Set the background color of the text in the console to bright YELLOW text
'on a BLUE background
SetConsoleTextAttribute hConsoleOut, FOREGROUND_RED Or FOREGROUND_GREEN Or FOREGROUND_INTENSITY Or BACKGROUND_BLUE
'Write something in the console
ConsoleWriteLine "Hello World!"
ConsoleWrite "Please enter your name: "
'Ask for user input and show it in the caption
Me.Caption = "Your name: " + ConsoleReadLine()
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Delete console
CloseHandle hConsoleOut
CloseHandle hConsoleIn
FreeConsole
End Sub
Sub ConsoleWriteLine(sInput As String)
ConsoleWrite sInput + vbCrLf
End Sub
Sub ConsoleWrite(sInput As String)
Dim cWritten As Long
WriteConsole hConsoleOut, ByVal sInput, Len(sInput), cWritten, ByVal 0&
End Sub
Function ConsoleReadLine() As String
Dim ZeroPos As Long
'Create a buffer
ConsoleReadLine = String(10, 0)
'Read the input
ReadConsole hConsoleIn, ConsoleReadLine, Len(ConsoleReadLine), vbNull, vbNull
'Strip off trailing vbCrLf and Chr$(0)'s
ZeroPos = InStr(ConsoleReadLine, Chr$(0))
If ZeroPos > 0 Then ConsoleReadLine = Left$(ConsoleReadLine, ZeroPos - 3)
End Function
|
|
|
|
|
|
#3 |
|
Member
Iscritto dal: Apr 2001
Messaggi: 17
|
grazie per avermi risposto
in pratica cosa posso fare con il codice che mi hai fornito ? scusa l'ignoanza. ciao.
__________________
Notebook ASUS LD3824 Pentium 4 1800 Mhz - ATI Mobility Readon 7500 32 MB DDR - Hard Disk 40 Gb - 512 MB DDR |
|
|
|
|
|
#4 |
|
Senior Member
Iscritto dal: Apr 2000
Città: Vicino a Montecatini(Pistoia) Moto:Kawasaki Ninja ZX-9R Scudetti: 29
Messaggi: 53971
|
Provalo
Comunque puoi fare un programma che fa input e output in testo, ma che non può essere usato sotto DOS puro... |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 23:14.



















