原形为
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
);
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
);
[DllImport("user32.dll", EntryPoint="GetWindowText")]
public static extern int GetWindowText (
int hwnd,
[Marshal(UnmanagedType.LPTStr)]StringBuilder lpString,
int cch
);
把Marshal改为MarshalAs
[Marshal(UnmanagedType.LPStr)]