| | タイトル | : フォルダ共有のチェック |  | 記事No | : 14375 |  | 投稿日 | : 2010/01/15(Fri) 11:21 |  | 投稿者 | : るしーる | 
 フォルダが共有されているかをチェックしたいので色々探したのですが、VB.NETで書いた物しかみつかりませんでした。
 
 単にコピーして動かすとエラーするのですが、教えて頂けますでしょうか。
 Dim gchPath As GCHandle
 ユーザー定義型は定義されていません。
 
 
 '共有チェック
 Declare Function NetShareCheck Lib "netapi32.dll" _
 (ByVal servername As String, _
 ByVal device As Integer, _
 ByVal dwtype As Integer) As Integer
 Public Const STYPE_DISKTREE As Integer = 0
 Public Const NERR_Success As Integer = 0
 
 
 Sub MAIN()
 Dim lngWin32apiResultCode As Integer
 Dim strServerName As String
 Dim strDevice As Integer
 Dim lngType As Integer
 Dim gchPath As GCHandle
 ' サーバー名を設定(空文字の場合はローカルコンピュータ)
 strServerName = ""
 ' 選択されたデバイス名設定
 gchPath = GCHandle.Alloc("C:\tmp", GCHandleType.Pinned)
 strDevice = gchPath.AddrOfPinnedObject().ToInt32()
 
 ' デバイスが共有されているかどうかをチェック
 lngWin32apiResultCode = NetShareCheck(vbNullString, strDevice, lngType)
 ' 共有のチェックに成功したときは
 If lngWin32apiResultCode = NERR_Success Then
 MsgBox ("共有されています。")
 Else
 MsgBox ("共有されていません。")
 Call ShareDel
 End If
 End Sub
 
 |