Error 997 occurred when using LsaOpenPolicy

Joined
Mar 16, 2006
Messages
1
Reaction score
0
Hi, all
I got the error 997 (Overlapped I/O operation is in progress.) when using LsaOpenPolicy.
Would someone be kind to help me figure it out?

-----
Here are the declarations
-----
<StructLayout(LayoutKind.Sequential, _
CharSet:=CharSet.Unicode)> _
Public Structure LSA_UNICODE_STRING
Dim Length As Integer
Dim MaximumLength As Integer
Dim Buffer As IntPtr
End Structure
<StructLayout(LayoutKind.Sequential, _
CharSet:=CharSet.Unicode)> _
Public Structure LSA_OBJECT_ATTRIBUTES
Dim Length As Integer
Dim RootDirectory As IntPtr
Dim ObjectName As LSA_UNICODE_STRING
Dim Attributes As Integer
Dim SecurityDescriptor As IntPtr
Dim SecurityQualityOfService As IntPtr
End Structure
<DllImport("Advapi32.dll", _
CharSet:=CharSet.Unicode, _
SetLastError:=True)> _
Public Shared Function LsaOpenPolicy( _
<[In]()> ByRef SystemName As LSA_UNICODE_STRING, _
<[In]()> ByRef ObjectAttributes As LSA_OBJECT_ATTRIBUTES, _
<[In]()> ByVal DesiredAccess As Integer, _
<[In](), Out()> ByRef PolicyHandle As IntPtr) As Integer
End Function
-----
and the calling part
-----
Dim ret As Integer
Dim SystemName As LSA_UNICODE_STRING
Dim ObjectAttr As New LSA_OBJECT_ATTRIBUTES
Dim Access As Integer = POLICY_ALL_ACCESS
Dim Policy As IntPtr
ObjectAttr.Length = 0
ret = LsaOpenPolicy( _
SystemName, _
ObjectAttr, _
Access, _
Policy)
If (ret <> 0) Then
Console.WriteLine(Marshal.GetLastWin32Error())
End If
-----
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top