I have found VB code which uses the user32 library and the RemoveMenu function to disable the [X] button.
Has anyone migrated code similar to the below to prevent someone from improperly closing a Clipper Migrated Harbour application running in CMD window (launched via a batch file)?
I need them to properly exit the application only using the method provided within the application.
The VB code I found:
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal _
wFlags As Long) As Long
Private Const MF_BYPOSITION = &H400
Private Sub Command1_Click()
Dim cmdHwnd As Long, SysMenu As Long, Res As Long
cmdHwnd = FindWindow(vbNullString, "C:\WINDOWS\system32\cmd.exe")
If cmdHwnd <> 0 Then
SysMenu = GetSystemMenu(cmdHwnd, 0)
Res = RemoveMenu(SysMenu, 6, MF_BYPOSITION)
SetForegroundWindow cmdHwnd
End If
End Sub
Any help in migrating this code would greatly be appreciated.