Hi,
here it is
<StructLayout(LayoutKind.Sequential, Pack:=1)> _
Structure LSA_UNICODE_STRING
Dim Length As Integer
Dim MaximumLength As Integer
Dim Buffer As Long
End Structure
<StructLayout(LayoutKind.Sequential, Pack:=1)> _
Structure LSA_Object_Attributes
Dim Length As Long
Dim RootDirectory As Long
Dim ObjectName As Long
Dim Attributes As Long
Dim SecurityDescriptor As Long
Dim SecurityQualityOfService As Long
End Structure
Private Declare Function LsaOpenPolicy Lib "ADVAPI32.dll" ( _
ByRef SystemName As LSA_UNICODE_STRING, _
ByRef ObjectAttributes As
LSA_Object_Attributes, _
ByVal DesiredAccess As Long, _
ByRef PolicyHandle As IntPtr) As Long
Public Function OpenHandle() As String
Dim LsaObjectAttribs As New LSA_Object_Attributes
Dim LsaHandle As IntPtr
Dim computer As New LSA_UNICODE_STRING
Dim Access As Long = &HFFFF
computer.Length = 0
LsaObjectAttribs.Length = 0
If Not LsaOpenPolicy(computer, LsaObjectAttribs, Access, LsaHandle)
= 0 Then Exit Function
End Function
"Herfried K. Wagner [MVP]" wrote:
"AndyL" <An***@discussions.microsoft.com> schrieb: I receive always a NullReferenceError WHY?
CU Andy
Dim LsaObjectAttribs As New LSA_Object_Attributes
Dim LsaHandle As IntPtr
Dim computer As New LSA_UNICODE_STRING
Dim Access As Long = &HFFFF
=> 'As Int32'.
computer.Length = 0
LsaObjectAttribs.Length = 0
If Not LsaOpenPolicy(computer, LsaObjectAttribs, Access, LsaHandle) = 0
Then
Post your declarations of 'LSA_UNICODE_STRING' and 'LSA_OBJECT_ATTRIBUTES'.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>