windows下C#如何调用so文件啊

xktder 2016-11-29 04:26:57
windows下C#如何调用so文件啊。
用户只提供了so文件。
请问有什么方法没,谢谢了。
...全文
742 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
so文件是用c代码编译的,直接拿c代码再编译成一个dll,给c#调用不是更方便么
  • 打赏
  • 举报
回复
这太狠了吧,提供一个*nix上的动态库。。。
快溜 2016-11-29
  • 打赏
  • 举报
回复
实现难度很大,估计没人这么干
本DEMO参考了https://download.csdn.net/download/abill425/10554049?tdsourcetag=s_pctim_aiomsg 资料; 非常感谢,如有侵权,请与本人联系; 与参考的资料相比,不同的是:参考资料是百度人脸SDK离线版本V1.0版本的; 而本DEMO是百度人脸SDK离线版本V1.1版本的; 本demo是x64的,封装成可供c#调用的dll是BaiduFaceDll.dll 使用步骤: 1.到百度AI开放平台 https://ai.baidu.com ,下载百度人脸离线SDK,(注意版本V1.1.0,修改日期:2018.08.31) 2.下载后,把sdk包里那个443 MB的face-resource目录,复制到本demo的BaiduFaceDll\x64目录下(就是BaiduFaceDll.dll所在目录的上级目录) 3.打开BaiduFaceDll\x64\\Release\LicenseTool.exe,输入试用序列号(在百度AI开放平台取得,有效期30天),完成激活。注意,激活时需要联网。或者将已有的license.ini和license.key文件拷贝至此目录,注意注册序列号是与硬件相关的; 4.将本demo的BaiduFaceDll\x64\Release路径,加到系统的path变量中。 5.运行本demo的BaiduFaceDll\x64\Release目录下的WindowsFormsApplication1.exe,可以测试封装的dll,输入两张图片;然后单击:图像对比,会显示对比结果; 在C#中的函数注册: //请将"BaiduFaceDll.dll"修改为实际路径,如@"d:\BaiduFaceDll\x64\Release\BaiduFaceDll.dll", 或者直接把该实际路径加到系统的path变量中。 [DllImport("BaiduFaceDll.dll")] public static extern void Init();//初始化 [DllImport("BaiduFaceDll.dll")] public static extern void UnInit();//销毁 [DllImport("BaiduFaceDll.dll")] public extern static int Track(string imgstr, ref StringBuilder res);//人脸检测,imgstr为图片的base64编码字符串 [DllImport("BaiduFaceDll.dll")] public static extern int User_Add(string user_id, string imgstr);//添加用户,imgstr为图片的base64编码字符串 [DllImport("BaiduFaceDll.dll")] public static extern int User_Delete(string user_id);//删除用户 [DllImport("BaiduFaceDll.dll")] public extern static void Identify(string imgstr, ref StringBuilder res);//人脸识别,imgstr为图片的base64编码字符串 [DllImport("BaiduFaceDll.dll")] public extern static void Match(string image1, int img_type1, string image2, int img_type2, ref StringBuilder res);//人脸1:1对比编码字符串 sdk调用流程: 初始化 -> 图片对比 -> 销毁 具体详细的windows-sdk使用说明,参见 http://ai.baidu.com/docs#/Face-Offline-SDK-Windows/top 源码: 本demo的BaiduFaceDll\BaiduFaceDll目录,是本封装dll的c++源码。VS版本为2015,Framework版本为4.0。 本DEMO只是封装了几个示例,其余封装,参考样式自行编写;
模拟鼠标和键盘 注意:不支持Windows 8 / 8.1。 Interceptor是Windows键盘驱动程序的包装器(包装http://oblita.com/Interception)。 使用驱动程序,Interceptor可以模拟按键和鼠标点击... 使用DirectX的游戏,通常不接受使用SendInput()的击键 Windows的受保护区域,如Windows登录屏幕或UAC调暗屏幕 任何应用程序 因为驱动程序模拟击键和鼠标单击,所以目标窗口必须处于活动状态(即,在发送击键和鼠标点击时,不能在另一个窗口上执行多任务)。 如何使用 下载并构建此项目并在项目中引用其DLL。 下载'interception.dll',这是一个由驱动程序作者编写的独立库。将它放在与可执行文件相同的目录中。这是必需的。 从作者的网页下载并安装“install-interception.exe”。安装后重新启动计算机。 在您的代码中,要加载驱动程序,请调用(阅读下面的代码注释;您必须设置过滤模式以捕获按键事件或发送按键操作!): Input input = new Input(); // Be sure to set your keyboard filter to be able to capture key presses and simulate key presses // KeyboardFilterMode.All captures all events; 'Down' only captures presses for non-special keys; 'Up' only captures releases for non-special keys; 'E0' and 'E1' capture presses/releases for special keys input.KeyboardFilterMode = KeyboardFilterMode.All; // You can set a MouseFilterMode as well, but you don't need to set a MouseFilterMode to simulate mouse clicks // Finally, load the driver input.Load(); 做你的东西。 input.MoveMouseTo(5, 5); // Please note this doesn't use the driver to move the mouse; it uses System.Windows.Forms.Cursor.Position input.MoveMouseBy(25, 25); // Same as above ^ input.SendLeftClick(); input.KeyDelay = 1; // See below for explanation; not necessary in non-game apps input.SendKeys(Keys.Enter); // Presses the ENTER key down and then up (this constitutes a key press) // Or you can do the same thing above using these two lines of code input.SendKeys(Keys.Enter, KeyState.Down); Thread.Sleep(1); // For use in games, be sure to sleep the thread so the game can capture all events. A lagging game cannot process input quickly, and you so you may have to adjust this to as much as 40 millisecond delay. Outside of a game, a delay of even 0 milliseconds can work (instant key presses). input.SendKeys(Keys.Enter, KeyState.Up); input.SendText("hello, I am typing!"); /* All these following characters / numbers / symbols work */ input.SendText("abcdefghijklmnopqrstuvwxyz"); input.SendText("1234567890"); input.SendText("!@#$%^&*()"); input.SendText("[]\\;',./"); input.SendText("{}|:\"?"); // And finally input.Unload(); 笔记: BadImageFormatException如果您没有为解决方案中的所有项目(包括此项目)使用正确的体系结构(x86或x64),则可能会获得。因此,您可能必须下载此项目的源代码才能将其重建为正确的体系结构。这应该很简单,构建过程应该没有错误。 您必须从http://oblita.com/Interception下载'interception.dll' 。 如果你已经完成了以上所有操作(正确安装了拦截驱动程序,将interception.dll放在你的项目文件夹中),你仍然无法发送击键: 驱动程序有一个限制,即它不能在不接收至少一次击键的情况下发送击键。这是因为驱动程序不知道键盘是哪个设备ID,因此它必须等待接收击键以从击键中推断出设备ID。 总之,在发送击键之前,请始终按键盘一次。点按任意键。然后你可以发送击键。这不适用于接收击键,因为通过接收击键,您当然已经按下了一个键。 MoveMouseTo()和MoveMouseBy()完全忽略键盘驱动程序。它使用System.Windows.Forms.Position来设置和获取游标的位置(它为下面的各个函数调用标准的Win32 API)。 原因是,在探索键盘驱动程序的鼠标移动功能时,我注意到它没有按像素单位移动光标,而是似乎通过加速移动光标。当我想将光标移动到某个位置时,这会不断产生不一致的值。因为Win32游标设置API通常不被游戏等阻止,所以我发现只需调用这些标准API即可,而无需使用驱动程序。请注意,这仅适用于设置光标位置。拦截光标仍然可以正常工作。例如,您可以使用Interceptor反转鼠标的x和y轴。

110,545

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧