[VB.net]원인을 몰라서 이렇게 질문해요!
개랑
Private Declare Function RegSetKeySecurity Lib advapi32.dll (ByVal hKey As Long, ByVal SecurityInformation As Long, pSecurityDescriptor As SECURITY_DESCRIPTOR) As Long
Private Declare Function RegCloseKey Lib advapi32.dll (ByVal hKey As Long) As Long
Private Declare Function RegOpenKey Lib advapi32.dll Alias RegOpenKeyA (ByVal hKey As Long, ByVal lpSubKey As String, ByRef phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib advapi32 Alias RegSetValueExA (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As String, ByVal cbData As Long) As Long
Private Declare Function RegCreateKey Lib advapi32.dll Alias RegCreateKeyA (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegOpenKeyEx Lib advapi32.dll Alias RegOpenKeyExA (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Public Declare Function RegQueryValueEx Lib advapi32.dll Alias RegQueryValueExA (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As String, lpcbData As Long) As Long
Private Declare Function InitializeSecurityDescriptor Lib advapi32.dll (ByRef pSecurityDescriptor As SECURITY_DESCRIPTOR, ByVal dwRevision As Long) As Long
Private Declare Function InitializeAcl Lib advapi32.dll (ByRef pAcl As ACL, ByVal nAclLength As Long, ByVal dwAclRevision As Long) As Long
Private Declare Function SetSecurityDescriptorDacl Lib advapi32.dll (ByRef pSecurityDescriptor As SECURITY_DESCRIPTOR, ByVal bDaclPresent As Long, ByRef pDacl As Object, ByVal bDaclDefaulted As Long) As Long
Private Structure SECURITY_DESCRIPTOR Dim Revision As Byte Dim Sbz1 As Byte Dim Control As Long Dim Owner As Long Dim Group As Long Dim Sacl As ACL Dim Dacl As ACL End Structure
Private Structure ACL Dim AclRevision As Byte Dim Sbz1 As Byte Dim AclSize As Integer Dim AceCount As Integer Dim Sbz2 As Integer End Structure
Private Const DACL_SECURITY_INFORMATION As Long = &H4& Private Const SECURITY_DESCRIPTOR_REVISION As Long = 1 Private Const ACL_REVISION As Long = 2 Private Const HKEY_LOCAL_MACHINE = &H80000002 Private Const REG_SZ = 1 Private Const STANDARD_RIGHTS_ALL = &H1F0000 Private Const KEY_QUERY_VALUE = &H1 Private Const KEY_ENUMERATE_SUB_KEYS = &H8 Private Const KEY_SET_VALUE = &H2 Private Const KEY_CREATE_SUB_KEY = &H4 Private Const KEY_NOTIFY = &H10 Private Const KEY_CREATE_LINK = &H20 Private Const SYNCHRONIZE = &H100000 Private Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE)) Private Const ERROR_SUCCESS = 0&
Dim SD As SECURITY_DESCRIPTOR Dim ACL_ As ACL Dim KeyResult As Long Dim ILen As Integer/steger Dim KeyHandle As Long Dim lRetVal As Long Dim dType As Long Dim Buffer As String Dim lBufferSize As Long Dim lSubKey As Long
Public Sub r_aclON(Path As String) On Error Resume Next
InitializeSecurityDescriptor(SD, SECURITY_DESCRIPTOR_REVISION) - 이 지점 InitializeAcl(ACL_, Len(ACL_), ACL_REVISION) SetSecurityDescriptorDacl(SD, True, ACL_, True) RegSetKeySecurity(GetregHandle(Path), DACL_SECURITY_INFORMATION, SD) End Sub
Public Sub r_aclOFF(Path As String) On Error Resume Next
InitializeSecurityDescriptor(SD, SECURITY_DESCRIPTOR_REVISION) - 이 지점 SetSecurityDescriptorDacl(SD, True, 0&, True) RegSetKeySecurity(GetregHandle(Path), DACL_SECURITY_INFORMATION, SD) End Sub
해당 지점에서 이런 오류가 발생해요.
...무슨 오류인지 못알아먹겠어요.VB6.0 은 잘되는게 VB.net 에서는 다르게 작용하나봐요.여기에 맞는 해결책 아시는분 답변 해주시면 감사하겠습니다..