Public Switch As Boolean ' 标识是否继续执行定时器代码 Private Declare PtrSafe Function SetTimer Lib "user32" ( _ByVal hWnd As LongPtr, ByVal nIDEvent As LongPtr, _ByVal uElapse As Long, ByVal lpTimerFunc As LongPtr) As LongPtr Private Declare PtrSafe Function KillTimer Lib "user32" ( _...
Public Msg As String Public Timeinterval Public Switch As Boolean ' 标识是否继续执行定时器代码 Private Declare PtrSafe Function SetTimer Lib "user32" ( _ ByVal hWnd As LongPtr, ByVal nIDEvent As LongPtr, _ ByVal uElapse As Long, ByVal lpTimerFunc As LongPtr) As LongPtr Private Declare ...
#If VBA7 And Win64 Then Private Declare PtrSafe Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long #Else Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long #End If Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim keycode...
VBA自定义函数代码如下: '声明#If Win64 ThenPrivateDeclarePtrSafeFunctionLCMapStringLib"kernel32"Alias"LCMapStringA"(ByValLocaleAsLong,ByValdwMapFlagsAsLong,ByVallpSrcStrAsString,ByValcchSrcAsLong,ByVallpDestStrAsString,ByValcchDestAsLong)AsLongPrivateDeclarePtrSafeFunctionlstrlenLib"kernel32"Alias"lstrlen...
Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal Milliseconds As Long) '下面两行要修改分辨率 Private Const SW = 2736 '这里写你电脑屏幕的分辨率 Private Const SH = 1864 '这里写你电脑屏幕的分辨率 Private Declare PtrSafe Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long ...
Declare Sub... #EndIf 示例1: #If VBA7 Then ' 64位 Private Declare PtrSafe Function apisndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long Private Declare PtrSafe Function apiPlaySound Lib "winmm.dll" Alias "PlaySoundA" (...
Public Declare PtrSafe Function FindWindowA_ Lib"user32"(ByVallpClassName As String,_ ByVal lpWindowName As String)As Long #Else Public Declare Function GetWindowLong _ Lib"user32"Alias"GetWindowLongA"(_ ByVal hWnd As Long,_ ByVal nIndex As Long)As Long ...
#If VBA7Then 'VBA7代表64位office,在64位office上声明函数,需要用到“PtrSafe”Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias 。。。#ElsePrivate Declare Function ShellExecute Lib"shell32.dll" Alias 。。。#End If这样,系统会自动判断是32位EXCEL,还是64位EXCEL,来执行不同的函数...
#If VBA7 Then Private Declare PtrSafe Function getFrequency Lib "kernel32" Alias _ "QueryPerformanceFrequency" (cyFrequency As Currency) As Long Private Declare PtrSafe Function getTickCount Lib "kernel32" Alias _ "QueryPerformanceCounter" (cyTickCount As Currency) As Long #ElsePrivateDeclareFunctionget...
Private Declare PtrSafe Function FindWindow Lib"user32"Alias"FindWindowA"(ByVal lpClassName As String,ByVal lpWindowName As String)As Long Private Declare PtrSafe Function SetWindowLong Lib"user32"Alias"SetWindowLongA"(ByVal hWnd As Long,ByVal nIndex As Long,ByVal dwNewLong As Long)As Long ...