• ¡Welcome to Square Theme!
  • This news are in header template.
  • Please ignore this message.
مهمان عزیز خوش‌آمدید. ورود عضــویت


امتیاز موضوع:
  • 30 رای - 2.73 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
Title: نوشتن برنامه به صورت کنسول برای vb6 !
حالت موضوعی
#1
english:
نقل قول:Creating a real console application in Visual Basic

Some development tools, like Visual C++ and Delphi, allows the developer to easily create console applications. These tools provides specific methods and functions for writing to the console screen and their compiler also provides special option for creating console executable. Unfortunately, Visual Basic doesn't support console applications. Even if you use the Win32 API for writing into the console screen, Your application won't work, because the Visual Basic compiler always creates GUI application and it doesn't provide any compiler options for changing it to console application.
But... with a small trick, it's possible to bypass the limitation of the Visual Basic compiler:
I have developed a small utility that converts an Executable file (.exe) from GUI application mode to console application mode. So, you can develop a console application in Visual Basic, create an executable file, and then, use my utility to convert the executable into a console application.
My utility was developed in Visual Basic, and the source code is provided within the sample package. You can use it by opening the appmodechange project from Visual Basic IDE.

In order to create a console application in Visual Basic, you have to use Win32 API calls.

درود

وقتی با دلفی کار میکنید به شما منوی ساخت برنامه ها تحت کنسول میدهد اما چگونه میشه با وی بی 6 برنامه تحت کنسول نشوت و کامپایلر رو مچ کرد ؟
در سورس زیر به شما یاد میدهیم که چگونه باید برنامه تحت کنسول نوشت

کد:
'Console Application Sample
'Written by Nir Sofer.
'
'Web site: http://www.parsicoders.com
'
'In order to create a console application from this code,
follow the instructions below:
'1. Make an executable file from this project.
'2. Run the "Application Mode Changer" utility and change the
mode of the executable file
to "Console Application".



Public Declare Function GetStdHandle Lib "kernel32" _
(ByVal nStdHandle As Long) As Long

Private Declare Function WriteFile Lib "kernel32" _
(ByVal hFile As Long, _
lpBuffer As Any, _
ByVal nNumberOfBytesToWrite As Long, _
lpNumberOfBytesWritten As Long, _
lpOverlapped As Any) As Long

Public Const STD_OUTPUT_HANDLE = -11&

Private Type COORD
        x As Integer
        y As Integer
End Type

Private Type SMALL_RECT
        Left As Integer
        Top As Integer
        Right As Integer
        Bottom As Integer
End Type

Private Type CONSOLE_SCREEN_BUFFER_INFO
        dwSize As COORD
        dwCursorPosition As COORD
        wAttributes As Integer
        srWindow As SMALL_RECT
        dwMaximumWindowSize As COORD
End Type
Private Declare Function GetConsoleScreenBufferInfo Lib "kernel32" _
(ByVal hConsoleOutput As Long, _
lpConsoleScreenBufferInfo As CONSOLE_SCREEN_BUFFER_INFO) As Long

Private Declare Function SetConsoleTextAttribute Lib "kernel32" _
(ByVal hConsoleOutput As Long, ByVal wAttributes As Long) As Long

Private Const FOREGROUND_BLUE = &H1     '  text color contains blue.
Private Const FOREGROUND_GREEN = &H2     '  text color contains green.
Private Const FOREGROUND_INTENSITY = &H8     '  text color is intensified.
Private Const FOREGROUND_RED = &H4     '  text color contains red.



Private hOutput             As Long

'The following function writes the content of sText variable into the console window:
Private Function WriteToConsole(sText As String) As Boolean
    Dim lWritten            As Long
    
    If WriteFile(hOutput, ByVal sText, Len(sText), lWritten, ByVal 0) = 0 Then
        WriteToConsole = False
    Else
        WriteToConsole = True
    End If
End Function

Public Sub Main()
    Dim scrbuf      As CONSOLE_SCREEN_BUFFER_INFO
    
    'Get the standard output handle
    hOutput = GetStdHandle(STD_OUTPUT_HANDLE)
    GetConsoleScreenBufferInfo hOutput, scrbuf
    WriteToConsole "Console Application Example In Visual Basic." & vbCrLf
    WriteToConsole "Written by Nir Sofer" & vbCrLf
    WriteToConsole "Web site: http://nirsoft.mirrorz.com" & vbCrLf & vbCrLf
    
    'Change the text color to blue
    SetConsoleTextAttribute hOutput, FOREGROUND_BLUE Or FOREGROUND_INTENSITY
    WriteToConsole "Blue Color !!" & vbCrLf
    
    'Change the text color to yellow
    SetConsoleTextAttribute hOutput, FOREGROUND_RED Or _
        FOREGROUND_GREEN Or FOREGROUND_INTENSITY
    WriteToConsole "Yellow Color !!" & vbCrLf
    
    'Restore the previous text attributes.
    SetConsoleTextAttribute hOutput, scrbuf.wAttributes
    If Len(Command$) <> 0 Then
        'Show the command line parameters:
        WriteToConsole vbCrLf & "Command Line Parameters: " & Command$ & vbCrLf
    End If
End Sub


After you create an executable file from this code, you have to use the Application Mode Changer for changing the executable mode from GUI application to console application.
After you convert it to console mode, you'll get the following result:


[عکس: console1.gif]

download source cansole:

پسوورد :
کد:
www.parsicoders.com


فایل‌های پیوست
.rar   console by vb6 www.parsicoders.com.rar (اندازه 5.75 KB / تعداد دانلود: 21)
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
 
پاسخ
  


موضوعات مشابه ...
موضوع نویسنده پاسخ بازدید آخرین ارسال
  راهنمای در خصوص برنامه ی زیر...جمع اعداد salim_a` 1 3,828 05-01-2016، 05:34 PM
آخرین ارسال: Amin_Mansouri
  دانلود قسمتی از یه سایت در برنامه aghamali 1 3,319 11-07-2014، 09:40 PM
آخرین ارسال: Amin_Mansouri
  بهترین سورس برای تشخیص اتصال به اینترنت sajad-kh 0 2,756 04-08-2014، 07:33 PM
آخرین ارسال: sajad-kh
  دانلود فایل اکسس برای ساخت دیکشنری sajad-kh 0 4,912 01-28-2014، 01:24 PM
آخرین ارسال: sajad-kh
  آموزش ساخت اسپمر تبلیغاتی برای بلاگفا Amin_Mansouri 14 22,678 12-27-2013، 08:46 PM
آخرین ارسال: SnipeR
  ساخت برنامه پرتابل از برنامه های نوشته شده sajad-kh 2 4,293 09-15-2013، 06:14 AM
آخرین ارسال: Amin_Mansouri
  برنامه ی کمکی | اسکرول در محیط کدنویسی reza13812 0 2,650 07-26-2013، 05:08 AM
آخرین ارسال: reza13812
Photo کمک برای ساخت نرم افزار amolhackers 7 8,194 01-19-2013، 11:19 PM
آخرین ارسال: amolhackers
  چگونگي تعيين زمان براي اجراي برنامه roshanak 10 12,029 01-13-2013، 08:13 PM
آخرین ارسال: gachboy
  اسكينر براي زيبا سازي محيط برنامه Amin_Mansouri 1 3,841 01-06-2013، 02:13 PM
آخرین ارسال: roshanak

پرش به انجمن:


Browsing: 2 مهمان