AutoHotkey Community

It is currently May 27th, 2012, 12:25 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 29 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: May 20th, 2010, 5:04 pm 
Offline

Joined: April 21st, 2007, 9:16 pm
Posts: 178
Thanks to you, tomte and fincs. You are doing a wonderful job in maintaining AutoHotkey alive and helping the newbies like me!

BTW, tomte, any chance to have a function to parse the x64 registry? ;-)

_________________
r0lZ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 20th, 2010, 5:10 pm 
Online
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
I've recently released (2 days ago) a native 64-bit build of AutoHotkey_L and registry loops might even work, the catch is that DllCall and RegisterCallback are not implemented at the moment.

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 20th, 2010, 5:20 pm 
Offline

Joined: April 21st, 2007, 9:16 pm
Posts: 178
I've noticed that. Great job! But I need to parse the registry for x64 AND x86 apps, so even if, with your AHK_L64, I can remove the two x64 function needed by the 32bit versions of AutoHotkey, I will need equivalent functions to read the registry in 32bit mode. So, currently, there is no solution, until your new version will support DLLcall.

But I've found the M$ doc of RegEnumKey(), and I'll try to implement it. With the numerous examples of DLLcalls in this forum and what's I've learned today, that should be possible.

Thanks again!

_________________
r0lZ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 20th, 2010, 5:49 pm 
Offline

Joined: April 21st, 2007, 9:16 pm
Posts: 178
I've somewhat expanded the RegRead64() function to (partially) implement the REG_QWORD registry data type.

You have to add this line at the end of the data types list:
Code:
    REG_QWORD            := 11


and this, in the cases list later in the original code:
Code:
    } Else If (sValueType == REG_QWORD) {
        VarSetCapacity(sValue, vValueSize:=8)
        DllCall("Advapi32.dll\RegQueryValueEx", "uint", hKey, "str", sValueName, "uint", 0, "uint", 0, "uint64*", sValue, "uint*", vValueSize)
Note the "uint64*" instead of the usual "uint*".

This code is for AHK_L. If you use the mainstream AHK, replace RegQueryValueEx by RegQueryValueExA.

That works well, but due to a AHK limitation (at least in non-64bit versions), the unsigned 64bit integers have to be treated as signed, so you have to take care if the returned value is negative.

_________________
r0lZ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2010, 2:17 am 
Offline

Joined: May 9th, 2006, 6:22 pm
Posts: 75
r0lZ wrote:
But I've found the M$ doc of RegEnumKey(), and I'll try to implement it. With the numerous examples of DLLcalls in this forum and what's I've learned today, that should be possible.

I've been meaning to post my RegEnumKey64(), It works for me but not a full replacement for the Reg loop.

Example code:
Code:
  Loop
  {
    If Not GDFGamePath := RegEnumKey64("HKEY_LOCAL_MACHINE", "SOFTWARE\Microsoft\Windows\CurrentVersion\GameUX" . RegPath, (A_Index - 1))
      Break
    GDFGamePath%GameNr% := RegRead64("HKEY_LOCAL_MACHINE", "SOFTWARE\Microsoft\Windows\CurrentVersion\GameUX" . RegPath . "" . GDFGamePath, GamePath)
  }

Hopefully this is useful, I'll add more info if needed, don't have time right now.
Code:
RegEnumKey64(sRootKey, sKeyName, sValueName = "", DataMaxSize=1024) {
   HKEY_CLASSES_ROOT   := 0x80000000   ; http://msdn.microsoft.com/en-us/library/aa393286.aspx
   HKEY_CURRENT_USER   := 0x80000001
   HKEY_LOCAL_MACHINE   := 0x80000002
   HKEY_USERS         := 0x80000003
   HKEY_CURRENT_CONFIG   := 0x80000005
   HKEY_DYN_DATA      := 0x80000006
   HKCR := HKEY_CLASSES_ROOT
   HKCU := HKEY_CURRENT_USER
   HKLM := HKEY_LOCAL_MACHINE
   HKU    := HKEY_USERS
   HKCC := HKEY_CURRENT_CONFIG

   REG_NONE             := 0   ; http://msdn.microsoft.com/en-us/library/ms724884.aspx
   REG_SZ                := 1
   REG_EXPAND_SZ         := 2
   REG_BINARY            := 3
   REG_DWORD            := 4
   REG_DWORD_BIG_ENDIAN   := 5
   REG_LINK            := 6
   REG_MULTI_SZ         := 7
   REG_RESOURCE_LIST      := 8

   KEY_QUERY_VALUE := 0x0001   ; http://msdn.microsoft.com/en-us/library/ms724878.aspx
   KEY_WOW64_64KEY := 0x0100   ; http://msdn.microsoft.com/en-gb/library/aa384129.aspx (do not redirect to Wow6432Node on 64-bit machines)
   KEY_SET_VALUE   := 0x0002
   KEY_WRITE      := 0x20006
   KEY_ENUMERATE_SUB_KEYS := 0x0008
  ERROR_MORE_DATA := 234
  ERROR_NO_MORE_ITEMS := 259
  ERROR_SUCCESS := 0

   myhKey := %sRootKey%      ; pick out value (0x8000000x) from list of HKEY_xx vars
   IfEqual,myhKey,, {      ; Error - Invalid root key
      ErrorLevel := 3
      return ""
   }

   RegAccessRight := KEY_QUERY_VALUE + KEY_WOW64_64KEY + KEY_ENUMERATE_SUB_KEYS

   DllCall("Advapi32.dll\RegOpenKeyExA", "uint", myhKey, "str", sKeyName, "uint", 0, "uint", RegAccessRight, "uint*", hKey)   ; open key

  VarSetCapacity(sValue, vValueSize := 64000)
  If DllCall("Advapi32.dll\RegEnumKeyExA", "uint", hKey, "uint", sValueName, "str", sValue, "uint*", vValueSize, "uint", 0, "uint", 0, "uint", 0, "uint", 0)      ; get value type
    sValue := ""
   DllCall("Advapi32.dll\RegCloseKey", "uint", hKey)
   return sValue
}


jonib


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 21st, 2010, 11:57 am 
Offline

Joined: April 21st, 2007, 9:16 pm
Posts: 178
I've written something very similar, but I use the AHK_L Object() to return more information in an array. Also, I've written another function to return the value names (and again more info in an array), using RegEnumValue().

With these two functions, it is easy to parse a whole branch of the registry, although it's not so easy than with the native AHK loop method.

Maybe I'll post my code here later, but it is not finished yet.

Thanks anyway for your help!

_________________
r0lZ


Report this post
Top
 Profile  
Reply with quote  
PostPosted: June 17th, 2010, 10:57 pm 
Offline

Joined: July 21st, 2009, 7:13 pm
Posts: 27
I am trying to write registry entries on a remote 64bit computer.
We are using this to add notices to users via the regkeys below.

Any ideas?

HKEY_LOCAL_MACHINE, Software\Microsoft\Windows NT\CurrentVersion\Winlogon, LegalNoticeCaption
and
HKEY_LOCAL_MACHINE, Software\Microsoft\Windows NT\CurrentVersion\Winlogon, LegalNoticeText


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2011, 10:08 am 
Offline

Joined: February 20th, 2008, 5:08 pm
Posts: 111
Nozavi wrote:
How about deleting a key?

Shouldn't it look like this?

Code:
DllCall("Advapi32.dll\RegOpenKeyExA", "uint", myhKey, "str", sKeyName, "uint", 0, "uint", RegAccessRight, "uint*", hKey)
DllCall("Advapi32.dll\RegDeleteKeyExA", "uint", hKey, "str", sKeyName, "uint", RegAccessRight , "uint", 0)


UP

_________________
My scripts: http://apps.nozavi.com


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 26th, 2011, 9:31 pm 
Offline

Joined: January 12th, 2011, 4:04 pm
Posts: 93
Location: Kansas City, USA
Hi, y'all! I have a problem here.
I want to write this key (onto 64bit windows 7)(I have AutoHotkey_L), but it writes to the WOW key anyway.

regwrite, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\Namespace\{21EC2020-3AEA-1069-A2DD-08002B30309D} ;Add Control Panel to My Computer (no keys)

So I tried regwrite64, but it didn't write to the right key either.

regwrite64("REG_SZ", "HKEY_LOCAL_MACHINE", "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\Namespace\{21EC2020-3AEA-1069-A2DD-08002B30309D}")

Am I missing something?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 26th, 2011, 9:52 pm 
Offline

Joined: April 21st, 2007, 9:16 pm
Posts: 178
I think you must use regwrite64 and AHK_L X64 and have administrator rights to write to the right key!

_________________
r0lZ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 26th, 2011, 9:57 pm 
Offline

Joined: January 12th, 2011, 4:04 pm
Posts: 93
Location: Kansas City, USA
AHK_L X64? I didn't know there was a 64bit version. That might help...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 26th, 2011, 10:00 pm 
Offline

Joined: January 12th, 2011, 4:04 pm
Posts: 93
Location: Kansas City, USA
I am using a 32bit system, but am provisioning a 64bit system, and don't want to install 64bit AHK. Is there a location where I can download just the 64bit AutoHotkey binary without any installer?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 26th, 2011, 10:17 pm 
Offline

Joined: April 21st, 2007, 9:16 pm
Posts: 178
I don't know, but installers are mainly ZIP archives with an executable program. You should be able to extract the binaries with a good archiver program such as 7-zip, without installing the package.

There are 3 versions of AHK_L: ANSI 32 bit, unicode 32 bit and unicode 64 bit.

Personally, I install the 3 AHK_L versions in the same folder, but I rename the binaries before installing the next version, to keep them all. Only Autohotkey.exe and AutoHotkeySC.bin are different in the different packages.

Of course, you cannot run the 64 bit version on a 32 bit computer, but you can compile a 64 bit version of your script, and test it on another computer.

_________________
r0lZ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 26th, 2011, 10:37 pm 
Offline

Joined: January 12th, 2011, 4:04 pm
Posts: 93
Location: Kansas City, USA
Yes, I know I can't run the 64bit version on my 32bit computer, but I can copy the 64bit one to the b4bit computer and use it there until I am finished with it.

It never occurred to me to unzip the installer! Now, I see 3 AutoHotkey.exe 's in there! I assume the 64bit version is the larger-sized one without any icon.

After I did that, hey, it works! Now, if only that reg64 script would work for binary values!

Thanks for your advice.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 29 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Bon, SKAN, Yahoo [Bot] and 5 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group