1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| Imports System
Module Program
Private Const MF_BYCOMMAND As Integer = &H0
Private Const SC_MINIMIZE As Integer = &HF020
Private Const SC_MAXIMIZE As Integer = &HF030
Private Const SC_SIZE As Integer = &HF000
Private Const SC_CLOSE As Integer = &HF060
Private Const GWL_STYLE = (-16)
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
' Declaring references to external procedures that are in user32.dll.
Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Integer, ByVal uPosition As Integer, ByVal uFlags As Integer) As Boolean
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Integer, ByVal bRevert As Boolean) As IntPtr
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
' Declaring references to external procedures that are in kernel32.dll.
Private Declare Function GetConsoleWindow Lib "kernel32" Alias "GetConsoleWindow" () As IntPtr
Sub Main(args As String())
Dim hWnd As IntPtr = GetConsoleWindow()
' Obtain a handle to the console application system menu.
Dim hMenu As Integer = GetSystemMenu(hWnd, False)
SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) And Not WS_MAXIMIZEBOX)
SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) And Not WS_MINIMIZEBOX)
DeleteMenu(hMenu, SC_SIZE, MF_BYCOMMAND) 'Empêche l'utilisateur de retailler la console window
Console.WriteLine("Hello World!")
Console.ReadLine()
End Sub
End Module |
Partager