본문 바로가기
VB.net

64Bit OS에서 32Bit App으로 레지 리디렉션 시키지 않고 쓰기

by 호야호잇 2018. 6. 11.

Public Function WriteRegKey_64(ByVal KeyString As String, ByVal KeyName As String, ByVal KeyValue As Object) As Boolean

        Dim key As RegistryKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)

        Try

            key.CreateSubKey(KeyString).SetValue(KeyName, KeyValue)

            key.Close()

            Return True

        Catch

            Return False

        End Try

    End Function


==========================================================


(예시)


 '============= 프로시저 사용하지 않고 64bit OS에서 32bit app에서 registry 쓰기 로직 =======================

        'Dim BG_img_reg_path As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI"

        'Dim key As RegistryKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)

        'key = key.OpenSubKey(BG_img_reg_path, True)

        'Dim val As String()

        'val = key.GetValueNames()

        'key.CreateSubKey("Background").SetValue("OEMBackground", 1, RegistryValueKind.DWord)

        'key.Close()


        '==================================================================================



        ''====   레지스트리에 윈도우 잠금화면 적용을 위한 Key값 생성 Logic  =====

            WriteRegKey_64(BG_img_reg_path, "OEMBackground", 1)

        ''===================================================