Skip to content

Commit 518fee0

Browse files
nxtnRon Petrusha
authored andcommitted
Fix PinvokeLib.dll examples (#769)
* Enforce coding styles * Specify calling convention * Fix data marshaling
1 parent f6c9de2 commit 518fee0

File tree

16 files changed

+352
-317
lines changed

16 files changed

+352
-317
lines changed

snippets/visualbasic/VS_Snippets_CLR/conceptual.interop.marshaling/vb/activedir.vb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Imports System
33
Imports System.Runtime.InteropServices
44

55
'<snippet34>
6-
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> _
6+
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
77
Public Structure DsBrowseInfo
88
Public Const MAX_PATH As Integer = 256
99

@@ -26,8 +26,8 @@ End Structure
2626

2727
Public Class LibWrap
2828
' Declares a managed prototype for the unmanaged function.
29-
Declare Unicode Function DsBrowseForContainerW Lib "dsuiext.dll" ( _
30-
ByRef info As DSBrowseInfo ) As Integer
29+
Declare Unicode Function DsBrowseForContainerW Lib "dsuiext.dll" (
30+
ByRef info As DsBrowseInfo) As Integer
3131

3232
Public Const DSBI_ENTIREDIRECTORY As Integer = &H90000
3333
Public Const ADS_FORMAT_WINDOWS As Integer = 1
@@ -44,7 +44,7 @@ Public Class App
4444
' Must be marked as STA because the default is MTA.
4545
' DsBrowseForContainerW calls CoInitialize, which initializes the
4646
' COM library as STA.
47-
<STAThread> _
47+
<STAThread>
4848
Public Shared Sub Main()
4949
Dim dsbi As New DsBrowseInfo()
5050

@@ -55,11 +55,11 @@ Public Class App
5555
dsbi.ReturnFormat = LibWrap.ADS_FORMAT_WINDOWS
5656
dsbi.Flags = LibWrap.DSBI_ENTIREDIRECTORY
5757
dsbi.Root = "LDAP:"
58-
dsbi.Path = New String(New Char(DsBrowseInfo.MAX_PATH){})
59-
' Initialize remaining members...
58+
dsbi.Path = New String(New Char(DsBrowseInfo.MAX_PATH) {})
6059

60+
' Initialize remaining members...
6161
Dim status As Integer = LibWrap.DsBrowseForContainerW(dsbi)
62-
if CType(status, LibWrap.BrowseStatus) = LibWrap.BrowseStatus.BrowseOk Then
62+
If CType(status, LibWrap.BrowseStatus) = LibWrap.BrowseStatus.BrowseOk Then
6363
Console.WriteLine(dsbi.Path)
6464
Else
6565
Console.WriteLine("No path returned.")

0 commit comments

Comments
 (0)