对于自定义的dll,一bai般放在plugins文件夹中
http://blog.csdn.net/ycl295644/article/details/40659189
对于window中中本身dll,可以直接引用,不用把dll放在文件夹中
引用命名空间 using System.Runtime.InteropServices;
[DllImport("User32.dll", EntryPoint = "GetWindowText")]
private static extern int GetWindowText(IntPtr hwnd, StringBuilder text, int MaxLen);
//获得当前激活窗口
[DllImport("user32")]
protected static extern IntPtr GetActiveWindow();
//发送窗口消息
[DllImport("User32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(
IntPtr hWnd, // handle to destination window
int Msg, // message
int wParam, // first message parameter
int lParam // second message parameter
);
public struct COPYDATASTRUCT
{
public IntPtr dwData;
public int cData;
[MarshalAs(UnmanagedType.LPStr)]
public string lpData;
}
[DllImport("User32.dll")]
public static extern int SendMessage(IntPtr hwnd, int msg, int wParam, ref COPYDATASTRUCT IParam);
unity3D使用User32.dll
最新推荐文章于 2026-04-23 09:26:23 发布
本文介绍了如何在C#中通过DllImport属性调用Windows API中的DLL文件实现窗口操作功能,包括获取活动窗口标题及发送窗口消息等。
6012

被折叠的 条评论
为什么被折叠?



