这里非常有问题。
我正在Visual Studio中制作一个不打开控制台的应用程序。但是,我想将一个事件链接到一个按钮来打开控制台并开始输出数据。
谢谢!
答案 0 :(得分:1)
在VB网中:
Imports System.Runtime.InteropServices
Public Class Form1
Public Class Win32
<DllImport("kernel32.dll")> Public Shared Function AllocConsole() As Boolean
End Function
<DllImport("kernel32.dll")> Public Shared Function FreeConsole() As Boolean
End Function
End Class
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Win32.AllocConsole()
Console.WriteLine("Hey, I opened the console!")
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Win32.FreeConsole()
End Sub
End Class