|
参照下述网址将代码改成64位用的了,一直没有成功,请坛子里面的高手帮忙看看,谢谢。
我怀疑是跟这句相关,但尝试了好几种方案也没有成功。
cds.cbData = Len(UserCMD)+1'cds.cbData = Len(UserCMD) 'cds.cbData = Len(UserCMD)*2 'cds.cbData =( Len(UserCMD)+1)*2
参考链接: https://stackoverflow.com/questi ... am-in-vba-for-excel
- Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
- Private Declare PtrSafe Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As LongPtr, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPtr
- Public Type CopyDataStruct
- dwData As LongPtr
- cbData As LongPtr
- lpData As LongPtr
- End Type
- Private Const WM_COPYDATA = &H4A
- Sub test()
- Dim newPath As String
- ThisFile = "D:\xxx\xxx.mhtml"
- newPath = ThisFile & "\:\n" & "\0"
- hwndTC = FindWindow("TTOTAL_CMD", vbNullString)
- result = SendMessage(hwndTC, 1075, 4001, 0) 'FocusLeft
- result = SendMessage(hwndTC, 1075, 3001, 0) 'NewTab
-
- Call TC_SetPath(hwndTC, newPath)
- End Sub
- Sub TC_SetPath(hwndTarget, UserCMD As String)
- Dim cds As CopyDataStruct
-
- cds.dwData = Asc("C") + 256 * Asc("D")
- cds.cbData = Len(UserCMD)+1
- cds.lpData = StrPtr(UserCMD)
-
- ' Send the WM_COPYDATA message
- result = SendMessage(hwndTarget, WM_COPYDATA, 0, cds)
- End Sub
复制代码
|
|