2011/01/05

office2010 Win32API GetWindowText/SetWindowText

#If VBA7 Then
Declare PtrSafe Function SetWindowText Lib "user32" _
                                Alias "SetWindowTextW" ( _
                                ByVal Hwnd As LongPtr, _
                                ByVal lpString As LongPtr _
                                ) As Long

Declare PtrSafe Function GetWindowText Lib "user32" _
                                Alias "GetWindowTextW" ( _
                                ByVal Hwnd As LongPtr, _
                                ByVal lpString As LongPtr, _
                                ByVal cch As Long _
                                ) As Long
#Else
Declare Function SetWindowText Lib "user32" _
                                Alias "SetWindowTextW" ( _
                                ByVal hwnd As Long, _
                                ByVal lpString As Long _
                                ) As Long

Declare Function GetWindowText Lib "user32" _
                                Alias "GetWindowTextW" ( _
                                ByVal Hwnd As Long, _
                                ByVal lpString As Long, _
                                ByVal cch As Long _
                                ) As Long
#End If

'textLength = GetWindowText(Hwnd, StrPtr(buffer), Len(buffer))
'成功:終端Null除く文字数 / 失敗:0 / cch超える分は切り捨て

'result = SetWindowText(Hwnd, StrPtr(Strings))
'成功:0 / 失敗:0以外

0 件のコメント: