需要把server_address定义为STRING的类型,代码如下:
private Const GWL_ID = (-12)Dim nID As Long
Dim server_address As String * 256
nID = GetWindowLong(Text1.hwnd, GWL_ID)
Call GetDlgItemText(Form2.hwnd, nID, server_address, 256)
MsgBox server_address

解决方案 »

  1.   

    以下代码测试通过
    Dim server_address As StringDim nID As Long
    Dim nLen  As Long
    Dim strTmp As String * 256
    nID = GetWindowLong(Text1.hwnd, GWL_ID)
    nLen = GetDlgItemText(Me.hwnd, nID, strTmp, 256)
    server_address = Left(strTmp, nLen)
    MsgBox server_address
      

  2.   

    你的贴子发错了地方,这里是Visual C++;
    不过个GetDlgItemText(hWnd,nID,pString,strMaxLength);
    应该是对的
      

  3.   

    Dim strTmp As String * 256
    debug一下,传入参数值对吗?GetDlgItemText执行后,返回值,strTmp 变量值正确吗?