findwindow function winuser h
番茄系统家园 · 2021-08-29 01:16:21

,
,,?,,'stitleshowdifferentindifferentOS.
Hereismytestforyou:
[DllImport(user32.dll,SetLastError=true)]
staticexternIntPtrFindWindow(stringlpClassName,stringlpWindowName);
[DllImport(user32.dll,EntryPoint=FindWindow,SetLastError=true)]
staticexternIntPtrFindWindowByCaption(IntPtrZeroOnly,stringlpWindowName);
privatevoidbutton1_Click(objectsender,EventArgse)
{
IntPtrhandle=FindWindowByCaption(IntPtr.Zero,Untitled-Notepad);
Console.WriteLine(handle.ToString());
}
privatevoidbutton2_Click(objectsender,EventArgse)
{
IntPtrhandle=FindWindow(null,Untitled-Notepad);
Console.WriteLine(handle.ToString());
}
IcanuseeitherofthemtocatchthenotepadwhichIopeninmycomputer.Also,hereisthelinkabouthowtoinvoketheFindWindowmethodandFindWindowByCaptionmethodinC#:
http://www.pinvoke.net/default.aspx/user32/FindWindow.html
Ifanyunderstanding,pleasefeelfreeletmeknow.Thanks.
VinJin[MSFT]
MSDNCommunitySupport|Feedbacktous
GetorRequestCodeSamplefromMicrosoft
Pleaseremembertomarktherepliesasanswersiftheyhelpandunmarkthemiftheyprovidenohelp.
免责声明: 凡标注转载/编译字样内容并非本站原创,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如果你觉得本文好,欢迎推荐给朋友阅读;本文链接: https://m.nndssk.com/post/52116.html。
