C#?е???C++ DLL(P/Invoke)
???????????? ???????[ 2015/2/4 11:46:21 ] ????????C++ C# ???????
????DLL ?貧??char *????
[DllImport(“MyDLL.dll")]
// ?????
public static extern int mySum (StringBuilder abuf?? StringBuilder bbuf );
????//DLL??????
extern “C” __declspec(dllexport) int WINAPI mySum(char * astr??char * bstr)
{
//????char *?????astr??bstr -->abuf?? bbuf????????
return a+b;
}
????DLL ???????
????BOOL EnumWindows(WNDENUMPROC lpEnumFunc?? LPARAM lParam)
using System;
using System.Runtime.InteropServices;
public delegate bool CallBack(int hwnd?? int lParam); //??????к???????
public class EnumReportApp
{
[DllImport("user32")]
public static extern int EnumWindows(CallBack x?? int y);
public static void Main() {
CallBack myCallBack = new CallBack(EnumReportApp.Report); EnumWindows(myCallBack?? 0);
}
public static bool Report(int hwnd?? int lParam)
{
Console.Write("Window handle is ");
Console.WriteLine(hwnd); return true;
}
}
????DLL ????? ????????
????BOOL PtInRect(const RECT *lprc?? POINT pt);
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential)]
public struct Point {
public int x;
public int y;
}
[StructLayout(LayoutKind.Explicit)]
public struct Rect
{
[FieldOffset(0)] public int left;
[FieldOffset(4)] public int top;
[FieldOffset(8)] public int right;
[FieldOffset(12)] public int bottom;
}
Class XXXX {
[DllImport("User32.dll")]
public static extern bool PtInRect(ref Rect r?? Point p);
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11