af0ec05690
- migliorie varie.
107 lines
4.6 KiB
VB.net
107 lines
4.6 KiB
VB.net
Imports System.Runtime.InteropServices
|
|
Imports System.Text
|
|
|
|
Public Class GenInterface
|
|
|
|
'-------------------------------- IniFile --------------------------------------------------------
|
|
<DllImport("kernel32.dll", CharSet:=CharSet.Unicode)>
|
|
Private Shared Function GetPrivateProfileString(
|
|
ByVal lpAppName As String,
|
|
ByVal lpKeyName As String,
|
|
ByVal lpDefault As String,
|
|
ByVal lpReturnedString As StringBuilder,
|
|
ByVal nSize As Integer,
|
|
ByVal lpFileName As String) As Integer
|
|
End Function
|
|
Public Shared Function GetPrivateProfileString(
|
|
ByVal lpAppName As String,
|
|
ByVal lpKeyName As String,
|
|
ByVal lpDefault As String,
|
|
ByRef lpString As String,
|
|
ByVal lpFileName As String) As Integer
|
|
Dim sb As New StringBuilder(512)
|
|
Dim nRet As Integer = GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, sb, sb.Capacity, lpFileName)
|
|
lpString = sb.ToString
|
|
Return nRet
|
|
End Function
|
|
|
|
Public Shared Function GetPrivateProfileColor(
|
|
ByVal lpAppName As String,
|
|
ByVal lpKeyName As String,
|
|
ByRef nRed As Integer,
|
|
ByRef nGreen As Integer,
|
|
ByRef nBlue As Integer,
|
|
ByVal lpFileName As String) As Boolean
|
|
Dim sVal As String = String.Empty
|
|
GetPrivateProfileString(lpAppName, lpKeyName, "", sVal, lpFileName)
|
|
Dim sItems() As String = sVal.Split(",".ToCharArray)
|
|
If sItems.Count() >= 3 Then
|
|
nRed = Int(sItems(0))
|
|
nGreen = Int(sItems(1))
|
|
nBlue = Int(sItems(2))
|
|
Return True
|
|
End If
|
|
Return False
|
|
End Function
|
|
|
|
Public Shared Function GetPrivateProfileWinPos(
|
|
ByVal lpAppName As String,
|
|
ByVal lpKeyName As String,
|
|
ByRef nFlag As Integer,
|
|
ByRef nLeft As Integer,
|
|
ByRef nTop As Integer,
|
|
ByRef nWidth As Integer,
|
|
ByRef nHeight As Integer,
|
|
ByVal lpFileName As String) As Boolean
|
|
Dim sVal As String = String.Empty
|
|
GetPrivateProfileString(lpAppName, lpKeyName, "", sVal, lpFileName)
|
|
Dim sItems() As String = sVal.Split(",".ToCharArray)
|
|
If sItems.Count() >= 5 Then
|
|
nFlag = Int(sItems(0))
|
|
nLeft = Int(sItems(1))
|
|
nTop = Int(sItems(2))
|
|
nWidth = Int(sItems(3))
|
|
nHeight = Int(sItems(4))
|
|
Return True
|
|
End If
|
|
Return False
|
|
End Function
|
|
|
|
<DllImport("kernel32.dll", CharSet:=CharSet.Unicode)>
|
|
Public Shared Function WritePrivateProfileString(
|
|
ByVal lpAppName As String,
|
|
ByVal lpKeyName As String,
|
|
ByVal lpString As String,
|
|
ByVal lpFileName As String) As Boolean
|
|
End Function
|
|
|
|
Public Shared Function WritePrivateProfileWinPos(
|
|
ByVal lpAppName As String,
|
|
ByVal lpKeyName As String,
|
|
ByVal nFlag As Integer,
|
|
ByVal nLeft As Integer,
|
|
ByVal nTop As Integer,
|
|
ByVal nWidth As Integer,
|
|
ByVal nHeight As Integer,
|
|
ByVal lpFileName As String) As Boolean
|
|
Dim sVal As String
|
|
sVal = nFlag.ToString & "," & nLeft.ToString & "," & nTop.ToString & "," & nWidth.ToString & "," & nHeight.ToString
|
|
Return WritePrivateProfileString(lpAppName, lpKeyName, sVal, lpFileName)
|
|
End Function
|
|
|
|
|
|
'-------------------------------- System Menu ----------------------------------------------------
|
|
<DllImport("user32.dll")>
|
|
Public Shared Function GetSystemMenu(ByVal hWnd As IntPtr, ByVal bRevert As Boolean) As IntPtr
|
|
End Function
|
|
<DllImport("user32.dll", CharSet:=CharSet.Auto)>
|
|
Public Shared Function AppendMenu(ByVal hMenu As IntPtr, ByVal uFlags As Integer,
|
|
ByVal uIDNewItem As Integer, ByVal lpNewItem As String) As Boolean
|
|
End Function
|
|
Public Const MF_STRING As UInt32 = &H0
|
|
Public Const MF_SEPARATOR As UInt32 = &H800
|
|
Public Const WM_SYSCOMMAND As UInt32 = &H112
|
|
Public Const IDM_ABOUTBOX As UInt32 = &H10
|
|
|
|
End Class
|