简体   繁体   English

谁能帮助我使用Windows API NetApi32?

[英]Can anyone help me with the Windows API NetApi32?

I am trying to get a list of shares on a specific machine. 我正在尝试获取特定计算机上的共享列表。 So I decided to use the Windows API NetApi32.dll. 因此,我决定使用Windows API NetApi32.dll。 Here is my code snippet: 这是我的代码段:

Dim svr As String = Environment.MachineName
Dim level As Integer = 2
Dim sharesRead As Integer, totalEntries As Integer, nRet As Integer, hResume As Integer = 0
Dim pBuffer As IntPtr = IntPtr.Zero

nRet = NetApi32.NetShareEnum(svr, level, pBuffer, -1, sharesRead, totalEntries, hResume)

I'm getting a return code of 1231, but can't seem to find what that equates to. 我得到的返回码为1231,但似乎找不到等于什么的代码。 Can anyone point me in the correct direction on how to do this if it an incorrect way? 如果这是不正确的方法,谁能指出正确的方向呢?

http://msdn.microsoft.com/en-us/library/ms681383(VS.85).aspx http://msdn.microsoft.com/zh-CN/library/ms681383(VS.85).aspx

ERROR_NETWORK_UNREACHABLE 1231 (0x4CF) ERROR_NETWORK_UNREACHABLE 1231(0x4CF)

The network location cannot be reached. 无法到达网络位置。

Are you sure that your NetShareEnum definition valid? 您确定您的NetShareEnum定义有效吗? I am not very familar with VB.NET, but I have worked with netapi32 in c# in the past, and in general without problems. 我对VB.NET不太熟悉,但是过去我曾在C#中使用过netapi32,并且通常没有问题。

But anyway, if you want to enumerate all shares on your computer, you can do it another way. 但是无论如何,如果您想枚举计算机上的所有份额,则可以采用另一种方式。 In the following registry key you can find all current computer shares: 在以下注册表项中,您可以找到所有当前的计算机共享:

HKLM\\System\\CurrentControlSet\\Services\\LanmanServer\\Shares HKLM \\ System \\ CurrentControlSet \\ Services \\ LanmanServer \\ Shares

There is one key-value pair per share. 每股有一对键值对。 Value is REG_MULTI_SZ type, that looks like simple ini. 值是REG_MULTI_SZ类型,看起来像简单的ini。 Check for "type=0" (file share), and read path. 检查“ type = 0”(文件共享),并读取路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 谁能帮我在 C# 中为 CRC64 编写反向算法函数? - Can anyone help me to code Reverse algo function for CRC64 in C#? 任何人都可以为我简化这个算法吗? - Can anyone simplify this Algorithm for me? 任何人都可以帮助我获得math.round()以获得以下输出 - Can anyone help me to get math.round() to get the following output 即使将debug设置为true,asp.net mvc应用程序在生产中也会超时。 谁可以帮我这个事 - asp.net mvc application timeouts in production even when debug is set to true. Can anyone help me on this 我在 Windows 窗体应用程序中遇到以下错误? 任何人都可以帮助解决它 - I am facing with the following error in Windows Form Application ? Can anyone help to resolve it 谁能向我解释这个浮点怪异现象? - Can anyone explain this floating point weirdness to me? 在Windows API InsertMenuItem中需要帮助 - need help in windows API InsertMenuItem 任何人都可以给我一些关于InsertOnSubmit和InsertAllOnSubmit的解释性示例 - Can anyone give me a little explanatory example about InsertOnSubmit and InsertAllOnSubmit 此C#代码是什么意思? 有人可以替我介绍吗? - What this C# code mean? can anyone decribe it for me? 任何人都可以给我看一个MethodImplOptions.ForwardRef的例子 - Can anyone show me an example of MethodImplOptions.ForwardRef
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM