如何获取当前的驱动器映射 [英] How to get current drive mapping

查看:77
本文介绍了如何获取当前的驱动器映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上是想从一个映射驱动器运行一个进程主模块的UNC路径

,我试图从服务中执行此操作。

ProcessModule类仅提供带有映射驱动器号的完整路径,

但驱动器号指的是启动用户的驱动器映射

进程,并且无法从LocalSystem下运行

的服务解析为UNC路径。

因此,我需要获取驱动器映射用户

与流程相关联的帐户,或者甚至可能是流程的

会话ID(我不清楚映射是针对每个用户还是每个会话)。可以

有谁给我一个关于我如何去做的线索?

-

Dave

I am actually trying to get the UNC path of the main module of a process
running from a mapped drive, and I am trying to do this from a service. The
ProcessModule class only provides the full path with the mapped drive letter,
but the drive letter refers to the drive mapping for the user that started
the process, and cannot be resolved to a UNC path from a service running
under LocalSystem.
Presumably, therefore, I need to get the drive mapping either for the user
account associated with the process, or possibly even for the process''s
session ID (I am not clear whether mappings are per user or per session). Can
anyone give me a clue as to how I go about this?
--
Dave

推荐答案

戴夫,


不幸的是,你在这里唯一的选择是让客户

流程做映射驱动器到UNC路径的分辨率。您可以使用WNetGetUniversalName API函数在客户端上执行

(您将通过P / Invoke层调用

)。


希望这会有所帮助。

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


" Dave" < Da ** @ discussion.microsoft.com写信息

新闻:5D ************************** ******** @ microsof t.com ...
Dave,

Unfortunately, the only option that you have here is to have the client
process do the resolution of the mapped drive to the UNC path. You can do
this on the client with the WNetGetUniversalName API function (you will have
to make the call through the P/Invoke layer).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dave" <Da**@discussions.microsoft.comwrote in message
news:5D**********************************@microsof t.com...

>我实际上是想获取进程主模块的UNC路径

从映射驱动器运行,我试图从服务中执行此操作。



ProcessModule类仅提供完整路径映射的驱动器

字母,

但驱动器号是指用户启动的驱动器映射过程中的
,并且无法解析来自在LocalSystem下运行

的服务的UNC路径。

因此,我需要为用户获取驱动器映射

与流程相关联的帐户,或者甚至可能是流程的

会话ID(我不清楚映射是针对每个用户还是每个会话)。

可以

有谁给我一个关于我如何去做的线索?

-

Dave
>I am actually trying to get the UNC path of the main module of a process
running from a mapped drive, and I am trying to do this from a service.
The
ProcessModule class only provides the full path with the mapped drive
letter,
but the drive letter refers to the drive mapping for the user that started
the process, and cannot be resolved to a UNC path from a service running
under LocalSystem.
Presumably, therefore, I need to get the drive mapping either for the user
account associated with the process, or possibly even for the process''s
session ID (I am not clear whether mappings are per user or per session).
Can
anyone give me a clue as to how I go about this?
--
Dave



谢谢Nicholas,但我觉得你有点误解了 - 我没有一个人/>
" client process" - 我正在获取当前正在运行的进程的列表和

试图找出它们的运行位置。

我看过WNetGetUniversalName但是它有相同的问题为

我正在使用的WNetGetConnection - 它只会解析当前登录会话的驱动器映射



Process.Mainmodule。 FullPath为我提供了位置,但(对于一些奇怪的

原因)驱动器号不是UNC。我可以找到

进程的用户帐户和sessionID,所以肯定必须能够找到该登录会话的当前

驱动器映射,从而找到UNC路径。 (当然,

映射可能已经改变了,因为这个过程开始了,但是我没有太多的b $ b我能做些什么)

-

Dave

Nicholas Paldino [.NET / C#MVP]"写道:
Thanks Nicholas, but I think you''ve slightly misunderstood - I don''t have a
"client process" - I am getting a list of the currently running processes and
trying to find out where they were run from.
I''ve looked at WNetGetUniversalName but it has the same problem as
WNetGetConnection which I am using now - it will only resolve drive mappings
for the current logon session.
The Process.Mainmodule.FullPath gives me the location, but (for some strange
reason) with a drive letter not a UNC. I can find the user account of the
process, and the sessionID, so surely it must be possible to find the current
drive mapping for that logon session and thus the UNC path. (Of course, the
mapping may have changed since the process was started, but there''s not much
I can do about that)
--
Dave
"Nicholas Paldino [.NET/C# MVP]" wrote:

戴夫,


不幸的是,你在这里唯一的选择是拥有客户

进程执行映射驱动器到UNC路径的解析。您可以使用WNetGetUniversalName API函数在客户端上执行

(您将通过P / Invoke层调用

)。


希望这会有所帮助。


-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com

" Dave" < Da ** @ discussion.microsoft.com写信息

新闻:5D ************************** ******** @ microsof t.com ...
Dave,

Unfortunately, the only option that you have here is to have the client
process do the resolution of the mapped drive to the UNC path. You can do
this on the client with the WNetGetUniversalName API function (you will have
to make the call through the P/Invoke layer).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dave" <Da**@discussions.microsoft.comwrote in message
news:5D**********************************@microsof t.com...

我实际上是想获取进程主模块的UNC路径

从映射驱动器运行,我试图从服务中执行此操作。



ProcessModule类仅提供映射的完整路径驱动器

字母,

但驱动器号是指用户启动

进程的驱动器映射,并且无法解析为来自在LocalSystem下运行的服务的UNC路径



因此,据推测,我需要为用户获取驱动器映射

帐户关联使用该过程,或者甚至可能是过程'

会话ID(我不清楚映射是针对每个用户还是每个会话)。

可以

有谁给我一个关于我怎么做的线索?

-

Dave
I am actually trying to get the UNC path of the main module of a process
running from a mapped drive, and I am trying to do this from a service.
The
ProcessModule class only provides the full path with the mapped drive
letter,
but the drive letter refers to the drive mapping for the user that started
the process, and cannot be resolved to a UNC path from a service running
under LocalSystem.
Presumably, therefore, I need to get the drive mapping either for the user
account associated with the process, or possibly even for the process''s
session ID (I am not clear whether mappings are per user or per session).
Can
anyone give me a clue as to how I go about this?
--
Dave






Nicholas

还有一件事。我在一个

驱动程序中使用PsSetCreateProcessNotifyRoutine实际捕获进程启动和停止。有什么方法我可以扩展驱动程序以获得进程的真正UNC路径吗?我现在通过司机功能打猎

但我还没找到任何东西。

-

Dave

Nicholas Paldino [.NET / C#MVP]"写道:
Nicholas
One more thing. I am using PsSetCreateProcessNotifyRoutine from within a
driver to actually trap processes starting and stopping. Is there any way I
can extend the driver to get the true UNC path of the process? I''m hunting
through driver functions now but I haven''t found anything yet.
--
Dave
"Nicholas Paldino [.NET/C# MVP]" wrote:

戴夫,


不幸的是,你在这里唯一的选择是拥有客户

进程执行映射驱动器到UNC路径的解析。您可以使用WNetGetUniversalName API函数在客户端上执行

(您将通过P / Invoke层调用

)。


希望这会有所帮助。


-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com

" Dave" < Da ** @ discussion.microsoft.com写信息

新闻:5D ************************** ******** @ microsof t.com ...
Dave,

Unfortunately, the only option that you have here is to have the client
process do the resolution of the mapped drive to the UNC path. You can do
this on the client with the WNetGetUniversalName API function (you will have
to make the call through the P/Invoke layer).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dave" <Da**@discussions.microsoft.comwrote in message
news:5D**********************************@microsof t.com...

我实际上是想获取进程主模块的UNC路径

从映射驱动器运行,我试图从服务中执行此操作。



ProcessModule类仅提供映射的完整路径驱动器

字母,

但驱动器号是指用户启动

进程的驱动器映射,并且无法解析为来自在LocalSystem下运行的服务的UNC路径



因此,据推测,我需要为用户获取驱动器映射

帐户关联使用该过程,或者甚至可能是过程'

会话ID(我不清楚映射是针对每个用户还是每个会话)。

可以

有谁给我一个关于我怎么做的线索?

-

Dave
I am actually trying to get the UNC path of the main module of a process
running from a mapped drive, and I am trying to do this from a service.
The
ProcessModule class only provides the full path with the mapped drive
letter,
but the drive letter refers to the drive mapping for the user that started
the process, and cannot be resolved to a UNC path from a service running
under LocalSystem.
Presumably, therefore, I need to get the drive mapping either for the user
account associated with the process, or possibly even for the process''s
session ID (I am not clear whether mappings are per user or per session).
Can
anyone give me a clue as to how I go about this?
--
Dave






这篇关于如何获取当前的驱动器映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆