Parsi Coders

نسخه‌ی کامل: get ID and Pass of TeamViewer
شما در حال مشاهده نسخه آرشیو هستید. برای مشاهده نسخه کامل کلیک کنید.
سورس بدست اوردن ایدی و پسوورد نرم افزار teamviewer

کد:
// Find window by Caption only. Note you must pass IntPtr.Zero as the first parameter.
[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);

[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, IntPtr windowTitle);

[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);

[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, int wParam,StringBuilder lParam);

static void Main()
{
string[] strWindowsTitles = GetDesktopWindowsTitles();
string strTeamViewer = "";
foreach (string strTitle in strWindowsTitles)
{
if (strTitle.Contains("TeamViewer"))
{
if (strTitle == "TeamViewer")
{
strTeamViewer = strTitle;
break;
}
}
}

if (strTeamViewer != "")
{
IntPtr hWndTeamViewer = FindWindowByCaption(IntPtr.Zero, strTeamViewer);

IntPtr hWndID = FindWindowEx(hWndTeamViewer, IntPtr.Zero, "Edit", IntPtr.Zero);
IntPtr hWndPass = FindWindowEx(hWndTeamViewer, hWndID, "Edit", IntPtr.Zero);

IntPtr pLengthID = SendMessage(hWndID, WM_GETTEXTLENGTH, IntPtr.Zero, IntPtr.Zero);
IntPtr pLengthPass = SendMessage(hWndPass, WM_GETTEXTLENGTH, IntPtr.Zero, IntPtr.Zero);

StringBuilder strbID = new StringBuilder((int)pLengthID);
StringBuilder strbPass = new StringBuilder((int)pLengthPass);

IntPtr pID = SendMessage(hWndID, WM_GETTEXT, (int)pLengthID, strbID);
IntPtr pPass = SendMessage(hWndPass, WM_GETTEXT, (int)pLengthPass, strbPass);

Console.WriteLine(strbID.ToString());
Console.WriteLine(strbPass.ToString());
Console.ReadLine();
}
}