2a6909497e
- aggiunto controllo debug attivo su versione release mediante funzione CheckRemoteDebuggerPresent.
198 lines
8.2 KiB
VB.net
198 lines
8.2 KiB
VB.net
Imports System.Runtime.InteropServices
|
|
Imports System.Text
|
|
Imports TestEIn.EgtInterface
|
|
Imports System.Globalization
|
|
|
|
Public Module GenInterface
|
|
|
|
'-------------------------------- IniFile : Get --------------------------------------------------
|
|
<DllImport("kernel32.dll", CharSet:=CharSet.Unicode)>
|
|
Public Function GetPrivateProfileInt(
|
|
lpAppName As String,
|
|
lpKeyName As String,
|
|
nDefault As Integer,
|
|
lpFileName As String) As Integer
|
|
End Function
|
|
|
|
Public Function GetPrivateProfileDouble(
|
|
lpAppName As String,
|
|
lpKeyName As String,
|
|
dDefault As Double,
|
|
lpFileName As String) As Double
|
|
Dim sValue As String = String.Empty
|
|
GetPrivateProfileString(lpAppName, lpKeyName, dDefault.ToString(), sValue, lpFileName)
|
|
Dim nPos As Integer = sValue.IndexOf(";")
|
|
If nPos >= 0 Then
|
|
sValue = sValue.Remove(nPos)
|
|
End If
|
|
Dim dValue As Double
|
|
If Not Double.TryParse(sValue, NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, dValue) Then
|
|
dValue = dDefault
|
|
End If
|
|
Return dValue
|
|
End Function
|
|
|
|
<DllImport("kernel32.dll", CharSet:=CharSet.Unicode)>
|
|
Private Function GetPrivateProfileString(
|
|
lpAppName As String,
|
|
lpKeyName As String,
|
|
lpDefault As String,
|
|
lpReturnedString As StringBuilder,
|
|
nSize As Integer,
|
|
lpFileName As String) As Integer
|
|
End Function
|
|
Public Function GetPrivateProfileString(
|
|
lpAppName As String,
|
|
lpKeyName As String,
|
|
lpDefault As String,
|
|
ByRef lpString As String,
|
|
lpFileName As String) As Integer
|
|
Dim sb As New StringBuilder(1024)
|
|
Dim nRet As Integer = GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, sb, sb.Capacity, lpFileName)
|
|
lpString = sb.ToString
|
|
Return nRet
|
|
End Function
|
|
|
|
Public Function GetPrivateProfileColor(
|
|
lpAppName As String,
|
|
lpKeyName As String,
|
|
ByRef Col As Color3d,
|
|
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
|
|
Col.R = Int(sItems(0))
|
|
Col.G = Int(sItems(1))
|
|
Col.B = Int(sItems(2))
|
|
If sItems.Count() >= 4 Then
|
|
Col.A = Int(sItems(3))
|
|
End If
|
|
Return True
|
|
End If
|
|
Return False
|
|
End Function
|
|
|
|
Public Function GetPrivateProfileZoomWin(
|
|
lpAppName As String,
|
|
lpKeyName As String,
|
|
ByRef bOutline As Boolean,
|
|
ByRef Col As Color3d,
|
|
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
|
|
bOutline = (Int(sItems(0)) <> 0)
|
|
Col.R = Int(sItems(1))
|
|
Col.G = Int(sItems(2))
|
|
Col.B = Int(sItems(3))
|
|
Col.A = Int(sItems(4))
|
|
Return True
|
|
End If
|
|
Return False
|
|
End Function
|
|
|
|
Public Function GetPrivateProfileWinPos(
|
|
lpAppName As String,
|
|
lpKeyName As String,
|
|
ByRef nFlag As Integer,
|
|
ByRef nLeft As Integer,
|
|
ByRef nTop As Integer,
|
|
ByRef nWidth As Integer,
|
|
ByRef nHeight As Integer,
|
|
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
|
|
|
|
|
|
'-------------------------------- IniFile : Write ------------------------------------------------
|
|
<DllImport("kernel32.dll", CharSet:=CharSet.Unicode)>
|
|
Public Function WritePrivateProfileString(
|
|
lpAppName As String,
|
|
lpKeyName As String,
|
|
lpString As String,
|
|
lpFileName As String) As Boolean
|
|
End Function
|
|
|
|
Public Function WritePrivateProfileWinPos(
|
|
lpAppName As String,
|
|
lpKeyName As String,
|
|
nFlag As Integer,
|
|
nLeft As Integer,
|
|
nTop As Integer,
|
|
nWidth As Integer,
|
|
nHeight As Integer,
|
|
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 Function GetSystemMenu(hWnd As IntPtr, bRevert As Boolean) As IntPtr
|
|
End Function
|
|
<DllImport("user32.dll", CharSet:=CharSet.Auto)>
|
|
Public Function AppendMenu(hMenu As IntPtr, uFlags As Integer,
|
|
uIDNewItem As Integer, 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
|
|
|
|
'-------------------------------- Windows --------------------------------------------------------
|
|
<DllImport("user32.dll")>
|
|
Public Function ShowWindow(hWnd As IntPtr, nCmdShow As Integer) As Boolean
|
|
End Function
|
|
Public Enum SW As Integer
|
|
HIDE = 0
|
|
SHOWMAXIMIZED = 3
|
|
RESTORE = 9
|
|
End Enum
|
|
<DllImport("user32.dll", SetLastError:=True)>
|
|
Public Function GetWindowLong(hWnd As IntPtr, nIndex As Integer) As Integer
|
|
End Function
|
|
<DllImport("user32.dll")>
|
|
Public Function SetWindowLong(hWnd As IntPtr, nIndex As Integer, dwNewLong As Integer) As Integer
|
|
End Function
|
|
Public Const GWL_STYLE As Integer = -16
|
|
Public Const WS_SYSMENU As Integer = &H80000
|
|
|
|
'-------------------------------- File Path ------------------------------------------------------
|
|
' Truncates a path to fit within a certain number of characters by replacing path components with ellipses.
|
|
' pszOut = The address of the string that has been altered.
|
|
' pszSrc = A pointer to a null-terminated string of length MAX_PATH that contains the path to be altered.
|
|
' cchMax = The maximum number of characters to be contained in the new string, including the terminating null.
|
|
' reserved = Reserved
|
|
' Returns TRUE if successful, or FALSE otherwise.
|
|
<DllImport("shlwapi.dll", EntryPoint:="PathCompactPathExW", SetLastError:=True, CharSet:=CharSet.Unicode)>
|
|
Public Function PathCompactPathEx(
|
|
<MarshalAs(UnmanagedType.LPTStr)> pszOut As System.Text.StringBuilder,
|
|
<MarshalAs(UnmanagedType.LPTStr)> pszSrc As String,
|
|
cchMax As UInteger,
|
|
reserved As Integer
|
|
) As <MarshalAs(UnmanagedType.Bool)> Boolean
|
|
End Function
|
|
|
|
'-------------------------------- Check Debugger ----------------------------------------------------
|
|
<DllImport("kernel32.dll", SetLastError:=True, CharSet:=CharSet.Unicode)>
|
|
Public Function CheckRemoteDebuggerPresent(hProcess As IntPtr, ByRef fResult As Boolean) As Boolean
|
|
End Function
|
|
|
|
|
|
End Module
|