|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
求助各位老师帮忙看看代码,为什么老是乱码,应该怎么解决呢
- Private Declare PtrSafe Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
- Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
- Private Declare PtrSafe Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As LongLong, lParam As Long) As Long
- Public Const WM_CHAR = &H102 '
- Type Org
- tag As String
- End Type
- Sub ?o?e????yX()
- Dim hwnd As Long
- Dim TitleName As String, s As String
-
- shell "CMD.EXE"
- Application.Wait (Now + TimeValue("00:00:02"))
- TitleName = "C:\Windows\SYSTEM32\CMD.EXE"
- hwnd = FindWindow(vbNullString, TitleName)
-
- '方法1:
- s = "我"
- PostMessage hwnd, WM_SYSCHAR, Asc(s), ByVal 0&
-
- '方法2:
- Dim str As Org
- str.tag = s
- PostMessage hwnd, WM_SYSCHAR, Asc(str.tag), ByVal 0&
- End Sub
复制代码
|
|