Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何声明QueryFullProcessImageName()API C#(Windows 7 x64)_C#_Winapi_Declaration_Windows 7 X64 - Fatal编程技术网

如何声明QueryFullProcessImageName()API C#(Windows 7 x64)

如何声明QueryFullProcessImageName()API C#(Windows 7 x64),c#,winapi,declaration,windows-7-x64,C#,Winapi,Declaration,Windows 7 X64,我需要使用它,但在pinvoke中,我无法获得该API的声明 所以。。。有办法申报吗 如果你有一个例子可以使用,那将是完美的,因为这是我第一次使用这个api using System; using System.Runtime.InteropServices; using System.Text; //... [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] static extern bool

我需要使用它,但在pinvoke中,我无法获得该API的声明

所以。。。有办法申报吗

如果你有一个例子可以使用,那将是完美的,因为这是我第一次使用这个api

using System;
using System.Runtime.InteropServices;
using System.Text;

//...

[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern bool QueryFullProcessImageName(IntPtr hProcess, uint dwFlags,
    [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpExeName,
    ref uint lpdwSize);

对于用法,.

谢谢!。我会测试它,但是。。。但是我想知道一些事情。。。你是怎么做到的?。。。有手册什么的吗?@Krahne:我学过C:)我建议你也这么做,没那么难,但当你这么做的时候,你会看到发生了什么。:)你花了多少时间学习C。。你知道有什么特别的书吗?如果你知道一本西班牙语的书,我会非常感激,因为我不会说太多英语。感谢您所做的一切,我仍在测试API。在我的LINQPad中,“Marshallas(UnmanagedType.LPTStr)”部分会导致结果中出现奇怪的中文字母,删除该属性会生成正确的带有拉丁字母的路径。你知道为什么会发生这种错误吗?LINQPad是32位的,在64位Win7下运行,但这不重要。@RolandPihlakas:Hmm我忘了你是否需要
CharSet=CharSet.Auto
,试着把它放在
DllImport
?不要使用这个,WMI也可以用更少的痛苦和对Vista+的依赖来获取这些信息。使用WMI Code Creator,它可以让您试验并生成所需的C#代码。