PDA

View Full Version : محل نوشتن DllImport



NIMA_1981
یک شنبه 29 اسفند 1389, 19:32 عصر
سلام دوستان این خط کد باید کجای سور قرار بگیره هر جا که قرار میدم خطا میده



[DllImport("user32")]public static extern int GetCursorPos(ref POINTAPI lpPoint)

syntiberium
یک شنبه 29 اسفند 1389, 19:46 عصر
باید اینو اون اول بنویسی :
using System.Runtime.InteropServices;

NIMA_1981
یک شنبه 29 اسفند 1389, 20:08 عصر
میشه بگید این کد رو باید چه جوریش کنم که کار کنه


[DllImport("user32")] public static extern int GetCursorPos(ref POINTAPI lpPoint)
[DllImport("user32")] public static extern int SendMessage(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam As Integer)]
[DllImport("user32")] public static extern int WindowFromPoint(int xPoint, int yPoint)];
 
const object WM_GETTEXT = 13;
const object WM_GETTEXTLENGTH = 14;
POINTAPI P;
long lRet;
long hHandle;
string aText;
long lTextlen;
string aText;
lRet = GetCursorPos(P);
hHandle = WindowFromPoint(P.x, P.y);
lTextlen = SendMessage(hHandle, WM_GETTEXTLENGTH, 0, 0);
if (lTextlen)
{
if (lTextlen > 1024) lTextlen = 1024;
lTextlen += 1;
aText = Space(lTextlen);
lRet = SendMessage(hHandle, WM_GETTEXT, lTextlen, aText);
aText = aText.Substring(lRet);
}

syntiberium
یک شنبه 29 اسفند 1389, 21:23 عصر
خط دوم که به زبان vb.net نوشته شده . آخر خط سوم هم اون علامت [ اضافیه . بقیش هم به نظر میاد مشکلی نداشته باشه .

NIMA_1981
یک شنبه 29 اسفند 1389, 21:58 عصر
کدوم خط با وی بی نوشته شده ؟

syntiberium
یک شنبه 29 اسفند 1389, 22:17 عصر
این خط به دلیل داشتن عبارتی مثل As Integer با syntax زبان vb.net نوشته شده :
[DllImport("user32")] public static extern int SendMessage(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam As Integer)]

NIMA_1981
پنج شنبه 29 اردیبهشت 1390, 21:42 عصر
دوستام کسی میتونه کل این کد را به c# تبدیل کنه