forked from clayreimann/CodeHelp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmPublic.bas
More file actions
79 lines (62 loc) · 2.03 KB
/
mPublic.bas
File metadata and controls
79 lines (62 loc) · 2.03 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Attribute VB_Name = "mPublic"
Option Explicit
Public Enum enWinVersion
enWin95 = 1
enWinNT = 2
enWin98 = 3
enWin2000 = 4
enWinXP = 5
End Enum
Function LowWord(lDWord As Long) As Integer
If lDWord And &H8000& Then
LowWord = lDWord Or &HFFFF0000
Else
LowWord = lDWord And &HFFFF&
End If
End Function
Function HiWord(lDWord As Long) As Integer
HiWord = (lDWord And &HFFFF0000) \ &H10000
End Function
Function GetWinText(hWnd As Long, Optional className As Boolean = False) As String
'some static vars to speed up things, this func will be called many times
Static sBuffer As String * 128& 'is it safe to use 128 bytes? should be enough..
Static textLength As Long
If className Then
textLength = A_GetClassName(hWnd, sBuffer, 129&)
Else
textLength = A_GetWindowText(hWnd, sBuffer, 129&)
End If
If textLength > 0 Then
GetWinText = Left$(sBuffer, textLength)
End If
End Function
Function GetOSVersion() As enWinVersion
'Get Windows version
Dim tOS As A_OSVERSIONINFO
tOS.dwOSVersionInfoSize = Len(tOS)
A_GetVersionEx tOS
If tOS.dwMajorVersion > 4& Then
If tOS.dwMinorVersion > 0& Then
GetOSVersion = enWinXP
ElseIf tOS.dwMinorVersion = 0& Then
GetOSVersion = enWin2000
End If
Else
If tOS.dwPlatformId = 1& Then
If tOS.dwMinorVersion > 0& Then
GetOSVersion = enWin98
Else
GetOSVersion = enWin95
End If
ElseIf tOS.dwPlatformId = 2& Then
GetOSVersion = enWinNT 'Should be check for NT 3.5 but we're not going that far
End If
End If
End Function
Public Function MakeDWord(ByVal LowWord As Integer, ByVal HiWord As Integer) As Long
' by Karl E. Peterson, http://www.mvps.org/vb, 20001207
' High word is coerced to Long to allow it to
' overflow limits of multiplication which shifts
' it left.
MakeDWord = (CLng(HiWord) * &H10000) Or (LowWord And &HFFFF&)
End Function