4个回答
展开全部
The GetWindowText function copies the text of the specified window's title bar (if it has one) into a buffer. If the specified window is a control, the text of the control is copied. However, GetWindowText cannot retrieve the text of a control in another application.
int GetWindowText(
HWND hWnd, // handle to window or control
LPTSTR lpString, // text buffer
int nMaxCount // maximum number of characters to copy
);
int GetWindowText(
HWND hWnd, // handle to window or control
LPTSTR lpString, // text buffer
int nMaxCount // maximum number of characters to copy
);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
主要代码:
char buf[MAX_PATH];
HWND hwnd = GetForegroundWindow();
GetWindowText(hwnd, buf, MAX_PATH);
char buf[MAX_PATH];
HWND hwnd = GetForegroundWindow();
GetWindowText(hwnd, buf, MAX_PATH);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这需要用到系统的API
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
using System;
using System.Text;
using System.Runtime.InteropServices;
class Program
{
[DllImport("user32.dll")]
public extern static int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
[DllImport("user32.dll")]
public extern static IntPtr GetForegroundWindow();
static void Main(string[] args)
{
StringBuilder str = new StringBuilder(512);
GetWindowText(GetForegroundWindow(), str, str.Capacity);
Console.WriteLine(str.ToString());
Console.ReadKey();
}
}
using System.Text;
using System.Runtime.InteropServices;
class Program
{
[DllImport("user32.dll")]
public extern static int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
[DllImport("user32.dll")]
public extern static IntPtr GetForegroundWindow();
static void Main(string[] args)
{
StringBuilder str = new StringBuilder(512);
GetWindowText(GetForegroundWindow(), str, str.Capacity);
Console.WriteLine(str.ToString());
Console.ReadKey();
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询