[程序设计]程序菜鸟求救,s=String(Tlong,chr(0)) 运行时为什么显示“string是一个类

楼主:jj2901 时间:2009-11-22 13:04:00 湖南 点击:34 回复:0
脱水 打赏 看楼主 设置

字体:

边距:

背景:

还原:

Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
  Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
  运行环境,VB.NET 2005
  Private Sub Command1_Click()
  Dim Tlong as long,s as String
  Tlong=GetWindowTextLength(hwnd)+1
  s=String$(Tlong,chr(0)) '必须要的
  GetWindowText hwnd,s,Tlong
  Msgbox s
  End Sub
  hwnd是你获得的窗体句柄,s就是你要的窗体标题了

打赏

0 点赞

主帖获得的天涯分:0
举报 | 楼主 | 埋红包
楼主发言:1次 发图:0张 | 添加到话题 |
发表回复

请遵守天涯社区公约言论规则,不得违反国家法律法规