---
title: "使用j-Interop查询共享目录"
author: "t42dw"
date: "2011-01-12T11:50:37Z"
tags: ["Blog", "J#", "SQL", "VB"]
categories: ["编程语言"]
slug: "j-interop"
draft: false
lastmod: "2011-01-12T12:05:48Z"
id: 869085
url: "https://t42dw.iteye.com/blog/869085"
---

这里主要使用WMI查询共享目录得到目录信息与相应的共享权限信息，j-Interop的jar请在[http://t42dw.iteye.com/blog/790855](/blog/790855)下载

 

VB代码

```
strComputer = "y55302b.china.huawei.com"
'strComputer = "10.69.30.152"
Set wbemServices = Getobject("winmgmts:\\" & strComputer)
'Set wbemObjectSet = wbemServices.get("Win32_LogicalShareSecuritySetting.Name='sql'") 

Set wbemObjectSetArray = wbemServices.ExecQuery("select * from Win32_LogicalShareSecuritySetting") 
 
For Each wbemObjectSet In wbemObjectSetArray

RetVal = wbemObjectSet.GetSecurityDescriptor(wmiSecurityDescriptor)
DACL =wmiSecurityDescriptor.DACL

WScript.Echo wbemObjectSet.Name

For Each daclValue In DACL
WScript.Echo daclValue.AceType
WScript.Echo daclValue.AccessMask

' Get Win32_Trustee object from ACE 
Set Trustee = daclValue.Trustee
    wscript.echo "Trustee Domain: "  & Trustee.Domain
    wscript.echo "Trustee Name: "    & Trustee.Name

' Get SID as array from Trustee
    SID = Trustee.SID 
    strsid = join(SID, ",") 
    wscript.echo "Trustee SID: {" & strsid & "}"

Next

Next
```

 

 

java代码请看附件!