RichTextBox1.Text = ""
RichTextBox1.Text = RichTextBox1.Text &"net use ipipc$ " &Chr(34) &" " &Chr(34) &" /user: " &Chr(34) &" " &Chr(34) &"建立IPC空链接" &vbCrLf
RichTextBox1.Text = RichTextBox1.Text &"net use ipipc$ " &Chr(34) &"密码" &Chr(34) &" /user:" &Chr(34) &"用户名" &Chr(34) &"建立IPC非空链接" &vbCrLf
'net use h: ipc$ "密码" /user:"用户名" 直接登陆后映射对方C:到本地为H:
'net use h: ipc$ 登陆后映射对方C:到本地为H:
'net use ipipc$ /del 删除IPC链接
'net use h: /del 删除映射对方到本地的为H:的映射
'net user 用户名 密码 /add 建立用户
'net user guest /active:yes 激活guest用户
'net user 查看有哪些用户
'net user 帐户名 查看帐户的属性
'net localgroup administrators 用户名 /add 把“用户”添加到管理员中使其具有管理员权限
End Sub
根据补充信息,修改如下:楼上几位的方法都会使Richtextbox格式发生变化。
我的做法是通过API来实现:
一、把下面代码放入模块中:
Option Explicit
Private Declare 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 Function SendMessageByNum Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function SendMessageByString Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Const EM_LINELENGTH = &HC1
Private Const EM_REPLACESEL = &HC2
Private Const EM_SETSEL = &HB1
Private Const EM_GETSEL = &HB0
Public Sub AddText(RichTextBoxName As Object, SendString As String, Optional Position As String)
Dim K As Long, Hwd As Long
Hwd = RichTextBoxName.hWnd
Select Case LCase(Position)
Case "top"
K = 0
Case "end"
K = Len(RichTextBoxName.Text)
Case Else
SendMessage Hwd, EM_GETSEL, 0, K
End Select
SendMessageByNum Hwd, EM_SETSEL, K, K
SendMessageByString Hwd, EM_REPLACESEL, 1, SendString
End Sub
二、调用举例:
AddText RichTextBox1, "11111", "top" '在文本头插入
AddText RichTextBox1, "2222", "end" '在文本尾追加
AddText RichTextBox1, "3333" '在当前位置插入
通过上述方法追加的文本不会影响原有的格式。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)