Linux 本地方法(windows接口)
Tofloor
poster avatar
野山菌
deepin
2016-08-26 08:10
Author
internal static class NativeMethods
{
[DllImport("User32.dll", CharSet=CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DragDetect(IntPtr hWnd, Point pt);

[DllImport("User32.dll", CharSet=CharSet.Auto)]
public static extern IntPtr GetFocus();

[DllImport("User32.dll", CharSet=CharSet.Auto)]
public static extern IntPtr SetFocus(IntPtr hWnd);

[DllImport("User32.dll", CharSet=CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool PostMessage(IntPtr hWnd, int Msg, uint wParam, uint lParam);

[DllImport("User32.dll", CharSet=CharSet.Auto)]
public static extern uint SendMessage(IntPtr hWnd, int Msg, uint wParam, uint lParam);

[DllImport("User32.dll", CharSet=CharSet.Auto)]
public static extern int ShowWindow(IntPtr hWnd, short cmdShow);

[DllImport("User32.dll", CharSet=CharSet.Auto)]
public static extern int SetWindowPos(IntPtr hWnd, IntPtr hWndAfter, int X, int Y, int Width, int Height, FlagsSetWindowPos flags);

[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int GetWindowLong(IntPtr hWnd, int Index);

[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SetWindowLong(IntPtr hWnd, int Index, int Value);

[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int ShowScrollBar(IntPtr hWnd, int wBar, int bShow);

[DllImport("user32.dll", CharSet=CharSet.Auto)]
//*********************************
// FxCop bug, suppress the message
//*********************************
[SuppressMessage("Microsoft.Portability", "CA1901InvokeDeclarationsShouldBePortable", MessageId = "0")]
public static extern IntPtr WindowFromPoint(Point point);

[DllImport("Kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetCurrentThreadId();

public delegate IntPtr HookProc(int code, IntPtr wParam, IntPtr lParam);

[DllImport("user32.dll")]
public static extern IntPtr SetWindowsHookEx(Win32.HookType code, HookProc func, IntPtr hInstance, int threadID);

[DllImport("user32.dll")]
public static extern int UnhookWindowsHookEx(IntPtr hhook);

[DllImport("user32.dll")]
public static extern IntPtr CallNextHookEx(IntPtr hhook, int code, IntPtr wParam, IntPtr lParam);
    }
}
上面面这段代码是c#写的用来调用windows本地代码的,谁会linux编程,帮我看下,这些在linux分别对应什么,帮我翻译成linux的,谢谢,有一个别人的工具拿到deepin来用,发现调用不到!能直接有linux接口吗
Reply Favorite View the author
All Replies
avatar
xiewei
deepin
2016-08-26 17:11
#1
你这是想编译一个Linux版本还是只是想将那个工具跑起来的
你可以将这个工具用CrossOver安装看看是否能正常使用
Reply View the author
avatar
chatop
deepin
2016-08-26 17:51
#2
Windows 下C#写的,在Linux下用mono进行编译,但是Windows特有的东西 在Mono下是没有的,有些代码需要改造 ,如system.windows.form 这种空间,在Linux下是没有的.
Reply View the author
avatar
justforlxz
deepin
2016-08-26 18:46
#3
没办法,调用的是win32API,这部分代码需要完全重写成linux版的。
Reply View the author
avatar
野山菌
deepin
2016-08-27 00:21
#4
本帖最后由 chaloongjir 于 2016-8-26 16:23 编辑
https://bbs.deepin.org/post/42741
你这是想编译一个Linux版本还是只是想将那个工具跑起来的
你可以将这个工具用CrossOver安装看看是否能正常 ...

不是编译版本,他这个东西是c#做的,我下下来用mono编译过了运行的时候发现本地调用有这些windows的东西,而我又不会Linux编程,我就只是想让他跑起来,但是右键可执行文件用crossover打开没有反应,所以看看能不能把这些接口改成调用Linux本地的
Reply View the author
avatar
野山菌
deepin
2016-08-27 00:25
#5
https://bbs.deepin.org/post/42741
Windows 下C#写的,在Linux下用mono进行编译,但是Windows特有的东西 在Mono下是没有的,有些代码需要改造 ,如 ...

我现在的情况是,编译过了,也运行出来东西,但是当调到这部分的时候报异常,所以出来的界面都是空白的
Reply View the author
avatar
野山菌
deepin
2016-08-27 00:28
#6
https://bbs.deepin.org/post/42741
没办法,调用的是win32API,这部分代码需要完全重写成linux版的。

我也是这么想,只是不熟悉Linux的接口
Reply View the author
avatar
xiewei
deepin
2016-08-29 18:02
#7
https://bbs.deepin.org/post/42741
不是编译版本,他这个东西是c#做的,我下下来用mono编译过了运行的时候发现本地调用有这些windows的东西, ...

右键CrossOver打开可能是反应慢了,可以试下下面的方法打开看看
1、点击运行命令
2、选择执行文件
3、最好也选择创建日志文件,如果运行有问题可以把日志发过来看看
Reply View the author
Comments
chaloongjir
2016-08-29 19:47
好的,我试试看