怎么我看见几个人的代码都不同啊~
到底哪个是正确的??
1、
strWinText:array[0..255] of char;
GetWindowText(ShellWindow, strWinText, 255);
--------------------------------------------
2、
szText: array[0..254] of char;
GetWindowText(hCurrentWindow, @szText, 255);
--------------------------------------------请问第二个参数为PChar类型,到底怎么写啊??
上面两种写法我都执行不了~

解决方案 »

  1.   

    声明了的啊~
    windows单元文件自动就use过了的~
    出现的问题是array与integer类型不匹配~
      

  2.   

    int GetWindowText(
      HWND hWnd,        // handle to window or control with text
      LPTSTR lpString,  // address of buffer for text
      int nMaxCount     // maximum number of characters to copy
    );szText: array[0..255] of char; // 需要255
    GetWindowText(hCurrentWindow, @szText, 255);
    // c/c++中 数组名就是首地址 delphi比较奇怪 需要再取地址...
      

  3.   

    哎~~晕倒~`
    就是,GetWindowText(hCurrentWindow, @szText, 255);
    是对的~
    我错是因为其他原因~
    谢谢~
      

  4.   

    都可以正确的~~var
      strWinText: array[0..255] of Char;
    begin
      GetWindowText(Handle, strWinText, 255);
      ListBox1.Items.Add(strWinText);
      GetWindowText(Handle, @strWinText, 255);
      ListBox1.Items.Add(strWinText);
      if @strWinText = @strWinText[0] then
        ShowMessage('True');
    end;