问题标签 [pinvoke]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
3420 浏览

c# - 在 C# 中打开到文件描述符的管道连接

我有一个旧版应用程序,它从文件描述符 3 中的客户端程序读取消息。这是一个外部应用程序,所以我无法更改它。客户端是用 C# 编写的。我们如何在 C# 中打开与特定文件描述符的连接?我们可以使用像 AnonymousPipeClientStream() 这样的东西吗?但是我们如何指定要连接的文件描述符呢?

0 投票
7 回答
7798 浏览

.net - Hooking into Windows with C# to Produce Windows 7 New Feature

I just saw a really useful UI feature of the forthcoming Windows 7 ( visit http://www.gizmodo.com.au/2008/10/windows_7_walkthrough_boot_video_and_impressions-2.html and scroll down to the video entitled Super Scientific Video of New Window Resizing Feature)

In a nutshell you can drag a window by the title bar to the top of the screen to maximise it, drag it back down to restore and drag it to the left edge or the right edge of the screen to have it snap into position butted up against the edge you dragged it to, and resized to occupy half the screen.

Now I know there are a bunch of keyboard-based apps that do "similar" things but I've not seen a mouse-based program that does JUST the above, simple, useful and nothing more. If you know of one (or are smart enough to write one) please post the URL :)

Anyway, if I wanted to try and write a small app to do this I have a question:

If I wanted to try and write a small app to do this, could I write it as a .NET app? I guess hooking into Windows' window drag/drop handling is pretty low-level and maybe not something that could be done in C#.NET?

any smartypants here who can knock a small app like this out in their lunchbreak? ;) I'm sure anything mimicing Windows 7 features would prove very popular, at least pre Windows 7's launch.

Edit: The AeroSnap guys (http://www.aerosnap.de/index_eng.htm) have done a nice job of implementing this feature and judging by the number of downloads, it was a popular feature!

0 投票
19 回答
198605 浏览

c# - 在 WPF 中将窗口置于最前面

如何将我的 WPF 应用程序带到桌面的前面?到目前为止,我已经尝试过:

没有一个在做这项工作(Marshal.GetLastWin32Error()是说这些操作成功完成,并且每个定义的 P/Invoke 属性确实有SetLastError=true)。

如果我创建一个新的空白 WPF 应用程序并SwitchToThisWindow使用计时器调用,它会完全按预期工作,所以我不确定为什么它在我原来的情况下不起作用。

编辑:我正在与全局热键一起执行此操作。

0 投票
2 回答
1289 浏览

c# - 如何使用视觉样式绘制任务栏按钮?

我创建了一个 DeskBand 工具栏,我想在工具栏上显示一个按钮,该按钮具有作为任务栏按钮的样式视觉样式。

在 .NET 中,您可以使用 VisualStyleRenderer 来呈现任务栏背景,但也可以使用呈现按钮的方法。

是否有任何 Win32 API 可以用来使用视觉样式绘制按钮,而不是通过绘制路径或图像来模拟按钮的外观?

0 投票
4 回答
1663 浏览

pinvoke - 在 P/Invoking 时未找到 DLL 时,如何获取有关丢失的特定非托管 DLL 的消息?

当您链接到一个非托管库(例如“A.dll”),该库又链接到另一个库(“B.dll”),并且 B.dll 丢失时,您将收到有关加载失败的运行时错误消息'B.dll'。

但是,当您从托管代码中 P/Invoke 到“A.dll”时,您会得到这种形式的一般异常:

未处理的异常:System.DllNotFoundException:无法加载 DLL 'A.dll':找不到指定的模块。

从托管代码执行 p/invoking 时,如何获得指出无法加载的特定非托管 dll 文件的错误消息?

0 投票
2 回答
3268 浏览

c# - 如何使用从程序集中动态加载的接口并调用其成员

我有一些代码来加载程序集并获取所有类型,它们实现了某个接口,就像这样(假设 asm 是一个有效且已加载的程序集)。

现在我被困住了:我需要创建这些对象的实例并调用对象的方法和属性。而且我需要将创建的对象的引用存储在一个数组中以供以后使用。

0 投票
2 回答
4768 浏览

c# - c#中如何使用libFLAC读取FLAC标签

libFLAC 库是否有 .net c# 包装器?如果没有,我如何在 .net 框架 c# 应用程序中使用 libFLAC 读取 FLAC 标签?如果两者都没有,是否有其他开源库可以读取 c# 中的 flac 标签?

谢谢!

0 投票
3 回答
33973 浏览

c# - 如何在 C# 中使用 p/invoke 将指针传递给数组?

示例 C API 签名:

void Func(unsigned char* bytes);

在 C 中,当我想传递一个指向数组的指针时,我可以这样做:

如何将上述 API 转换为 P/Invoke,以便可以将指针传递给 C# 字节数组?

0 投票
1 回答
2364 浏览

c# - 如何在 C# 中使用 p/invoke 传递引用参数 (&)(不是指针)?

我有一个 C++ API 原型

如何在 C# 中将其翻译为 P/Invoke?

据我所知,如果我使用

,该函数将接收指向 int 而不是值的指针。

0 投票
4 回答
23923 浏览

dll - dllimport 无法找到 dll,即使它位于 PATH 中

我使用 [Dllimport("DllName.dll")] 我确定我的 dll 的路径存在于进程 PATH 环境变量中,但我仍然得到“找不到 DllName.dll”