Thanks a lot!!! I trying to learn how to read WinRegistry, only your one video helps me. < 3
@ezzeldin1012 жыл бұрын
This is an awesome tutorial, Please keep it on!!
@samkani12773 жыл бұрын
Thanks. The video was helpful😃😃
@josales35702 жыл бұрын
Ty for your video. Helped me a lot.
@__Paul__3 жыл бұрын
This is all great, as long as you only want to write to the HKCU Registry hive. If you need to write keys and values to HKLM hive, then you either have to use a completely different language other than Python, or you have to use some other API other than "winreg", as winreg has a major defect that severely limits what you can do in the Registry, that most other languages have no problem with.
@canadiancoding3 жыл бұрын
Interesting, my work with the registry is relatively limited. So does python just fail to make the changes to the HKLM key outright, or are they just non-persistent?
@__Paul__3 жыл бұрын
@@canadiancoding It just fails to make them. It also throws a WinError 5, "access denied", but that is misleading and will only lead you down a dark alley. You can even configure your account not only as local admin, but full-on "god mode", elevating your account further to system level access, run as part of the operating system, etc., and still no love. IF it is "permissions", then it is solely in the calls internally to winreg, and / or security flag options that must be passed in -- NOT your actual account permissions or any special environment configuration settings. However, I have tried every combination (winreg.REG_WRITE / winreg.WIN_ALL_ACCESS / winreg.WIN64, etc), but nothing works when pointed to HKLM hive. Writing to HKCU is just fine. Meanwhile, I can manually modify Registy settings in HKLM, or do it with C# and .NET Framework classes, OR C# with dark, unmanaged C# with direct access to Win32 (advapi32.dll), no problem.
@canadiancoding3 жыл бұрын
@@__Paul__ Thanks for letting me know, that's good for future reference. I guess Microsoft just happens to be more friendly with their own languages :)
@danielfridman83173 жыл бұрын
Hi. Very helpful video!! Question: Is the - Tell other processes to update their environment - is completely necessary? What might happen if I won't do that? Thanks!
@canadiancoding3 жыл бұрын
If you opt not to include the other part of the code the registry can become out of sync. What happens is the same thing that happens if a database is out of sync, sometimes you will get the updated value and sometimes you will get the old one.
@simonvonkleist65903 жыл бұрын
Is that sublime as an editor or another one? Is there anything to be set up additionally to have the context information displayed?
@canadiancoding3 жыл бұрын
This is visual studio code, and to get the intelisense to show up you would need to install the pylance extension
@markanthadon2 жыл бұрын
Any updates on mentioned issues with writing to HKLM using winreg?
@canadiancoding2 жыл бұрын
Unfortunately not, I have not modified any of this code for a long time after searching for more information for a while
@LorhanSohaky Жыл бұрын
What is the reserved parameter? I'm noob with the winreg
@canadiancoding Жыл бұрын
I did quite a lot of digging, and found something that *might* be true about this. To understand this you need to know a few things Python in general is written in C/C++, in C/C++ header files (.h files) are used to tell you about functions. There are a few common windows ones like windows.h. Looking into the source code for winreg it seems to be using windows.h, but it seems to also be using a function defined in another .h file called RegOpenKeyExW() (learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyexw), I do not know enough about the intricacies of C/C++ or windows to be able to confirm this, but it seems like this is what's being called by python (python actually runs C code and passes your variables to the C code under the hood) In the python source code only 1 place specifies the value can be something non-zero: github.com/python/cpython/blob/main/PC/winreg.c#L1731-L1771 and this is because it's replaced by a zero here github.com/python/cpython/blob/main/PC/winreg.c#L1793 Reading the documentation for RegOpenKeyExW() here: learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyexw#:~:text=%5Bin%5D%20ulOptions,when%20absolutely%20necessary. It states that the value being passed as "reserved" is 0 for a regular link or set to the constant REG_OPTION_OPEN_LINK to make it a symbolic link. (with the warning "Registry symbolic links should only be used when absolutely necessary"). I am not as familiar with the registry, but a symbolic link in general is basically a "file" or "file-like" object that points to another (like a shortcut). It seems like this is the only other possible value, but they don't want you to do this in python (or C) because I would assume like normal symbolic links if the thing you're linking to is deleted, everything linking to it breaks as well! I apologize I couldn't be more precise in my response. As I said this is largely speculative, and my best guess. I would not act on this information until there is something more obvious to confirm this info, but I suspect this is what's happening. For time being, listen to the comments and leave it on 0