Golang manipulating Windows Registry

Source: Internet
Author: User
This is a created article in which the information may have evolved or changed.

Golang this artifact, the operating system data should be the simplest, a friend in the group is asking such a question. He was in the operation of the prompt insufficient permission, I found in the following test the root cause of the problem

Package Mainimport ("FMT" "Log" Registry "Github.com/golang/sys/windows/registry") func main () {k, err: = registry. Openkey (registry. Local_machine, ' Sam\xiao ', registry. all_access) If err! = Nil {log. Fatal (Err)}defer k.close () s, _, Err: = K.getstringvalue ("x") if err! = Nil {log. Fatal (Err)}fmt. Printf ("%q\n", s)}
The code I tested above

If you say that there are no permissions in this registry, you will be prompted for insufficient permissions


But I'll give it a permission to assign a value below.


Specifically like the study of friends. You can try it yourself.

Below is what permissions, manual Click Jump This jump is need to turn over the wall


He's here to tell us. If you need detailed registry key security and access rights explanation you can go see the Microsoft side.

Click to jump Microsoft registration rights Introduction



By comparing the 16 binary values of the Golang constant, you know which is which.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.