PDA

View Full Version : دستورات API



ali800
دوشنبه 20 آبان 1392, 14:42 عصر
با سلام من میخواستم از دستورات aPi در سی شارپ استفاده کنم هرکاری میکنم نتیجه نمیگیرم اساتید محترم راهنمایی کنید .

تابع
findwindows - closewindows - destorywindows - flashwindows
کسی بلده یه مثال از این 4 تا بزنه

مثلا برای فایند ویندوز
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
و در یک دکمه اینو میزارم
FindWindow(Null,"computer)"
اما جواب نمیده ::D
<مثلا title پنجره کامپیوتر که title ما کامپیوتر هست را پیدا کنه و اونو ماکزیمم کنه یا نشونش بده که در حال اجر یا بازه>

CannibalCorpse
دوشنبه 20 آبان 1392, 15:54 عصر
Find and Close the Window
using Microsoft.Win32;

[DllImport("user32.dll")]
public static extern int FindWindow(string lpClassName,string lpWindowName);
[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam);

public const int WM_SYSCOMMAND = 0x0112;
public const int SC_CLOSE = 0xF060;

private void closeWindow()
{
// retrieve the handler of the window
int iHandle = FindWindow("Notepad", "Untitled - Notepad");
if (iHandle > 0)
{
// close the window using API
SendMessage(iHandle, WM_SYSCOMMAND, SC_CLOSE, 0);
}
}