AutoHotkey Community

It is currently May 26th, 2012, 11:43 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: RegRead in Vista 64
PostPosted: November 13th, 2008, 11:50 pm 
Offline

Joined: August 4th, 2007, 10:39 pm
Posts: 44
Hi, I'm trying to do something really simple: read a value in the Registry. I'm running Vista Business 64 bit. In XP 32, I can simply add a string value and read it by using something like the following:

RegRead, OutputVar, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion, MyTest
MsgBox, The value of MyTest is %OutputVar%

This works fine in XP 32, where a dialog box returns the value of "MyTest". However when I go to the registry in Vista 64, add "MyTest", fill a value and run the above script, I get a blank value. Out of curiosity, I even changed the value of an existing registry entry, yet it returns the previous value (before I changed it). It's like it's reading from some other location and not the registry I'm editing!! Do you have any idea of what's going on? I even rebooted just to make sure...same problem.

Thanks for your help.

EDIT: The problem seems to be with the "SOFTWARE" key. If I add a string value in any of the subfolders within SOFTWARE, I cannot read them. Other locations outside of SOFTWARE work just fine

_________________
Regards,
Dave B.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2008, 4:27 pm 
Offline

Joined: August 4th, 2007, 10:39 pm
Posts: 44
No comments?

_________________
Regards,
Dave B.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2008, 5:57 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
not many people have vista64 to test with.

i seem to remember that win32 apps can only read a 32 bit section of registry (there are two registry trees)

I still don't understand why anyone runs 64 bit OS anyway. It's the chicken in a chicken and egg problem.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2008, 8:10 pm 
Offline

Joined: August 4th, 2007, 10:39 pm
Posts: 44
Thanks for your reply.

As to the 64-bit OS, we are testing right now. I work at an Architectural firm and we deal with large building models. The 3GB limitation hits certain projects hard. Software that we use daily is finally available in 64 bit, which means we can use larger amounts of RAM and that's why a LOT of others in the industry are rapidly moving in this direction.

As to reading the registry, I seem to be able to do everything as usual (reading/writing) except anything under the SOFTWARE key. It's very weird.

_________________
Regards,
Dave B.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 18th, 2008, 2:02 am 
Offline

Joined: November 6th, 2007, 7:24 pm
Posts: 24
Well Dave the news is not so bright...http://www.autohotkey.com/forum/viewtop ... ht=regread

Why do you need to know where it's installed? Can't you just standardize the location?

And engunneer, we use 64 in most of our office with a minimum of 6gb of ram, we use a very ram intensive program :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 18th, 2008, 10:54 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
Quote:
Source: MSDN: Registry Redirector (Windows)

Redirection is enabled for the following registry keys:
  • HKEY_LOCAL_MACHINE\Software
  • HKEY_USERS\*\Software\Classes
  • HKEY_USERS\*_Classes

I believe the solution is documented at the link below, but I do not have a 64-bit OS to test on.
MSDN: Accessing an Alternate Registry View (Windows)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 18th, 2008, 7:01 pm 
Offline

Joined: November 6th, 2007, 7:24 pm
Posts: 24
Here's the official response from Chris.... http://www.autohotkey.com/forum/viewtop ... wow6464key


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 12:35 am 
Thanks guys! I'll read through this info. soon. I wasn't getting notified of replies to this thread.

David, we do have a standardized install location but I was just trying to make the script more "universal" so that if anyone using it has a different install location, it would find it in the registry. For some reason %A_Programfiles% in Vista 64 does not return the Program Files folder but Program Files (x86). I can just omit using that and just type in the string.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 12:37 am 
Offline

Joined: August 4th, 2007, 10:39 pm
Posts: 44
Oh, that was me by the way....switching machines really bites when you don't realize you're not logged in ;)

_________________
Regards,
Dave B.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 12:56 am 
Offline

Joined: November 6th, 2007, 7:24 pm
Posts: 24
I figured as much, I tried to do the same and just gave up. As for the program files issue, I have come up with this to get around it. Simply checks if the OS is 64 or 32, sets the RevitProgramFiles variable appropriately, if it's 64 but 64 revit isn't installed it sets it back to x86, or if they have less than 4gb of ram, I've found 64 revit actually runs slower than 32 if they don't have more than 4gb

Code:
VarSetCapacity( MEMORYSTATUSEX,64,0 ), NumPut( 64,MEMORYSTATUSEX )
DllCall( "GlobalMemoryStatusEx", UInt,&MEMORYSTATUSEX )
TotalPhys := NumGet( MEMORYSTATUSEX,8,"Int64"),   VarSetCapacity( PhysMem,16,0 )
DllCall( "shlwapi.dll\StrFormatByteSize64A", Int64,TotalPhys, Str,PhysMem, UInt,16 )
StringTrimRight PhysMem, PhysMem, 3

ThisProcess := DllCall("GetCurrentProcess")
; If IsWow64Process() fails or can not be found,
; assume this process is not running under wow64.
; Otherwise, use the value returned in IsWow64Process.
If !DllCall("IsWow64Process", "uint", ThisProcess, "int*", IsWow64Process)
   IsWow64Process := false

If IsWow64Process
   BIT = 64
else
   BIT = 32

If (VERSION = "2008" or BIT = "32" or 4 = "32")
   {
      RevitProgramFiles = %ProgramFiles%
      GoSub APPLICATIONPATH
   }
If (BIT = "64" and PhysMem > 4)
   {
      RevitProgramFiles = %ProgramFiles%
      StringTrimRight RevitProgramFiles, RevitProgramFiles, 6
      {
         IfNotExist %RevitProgramFiles%\Revit %Discipline% %VERSION%\Program\Revit.exe
         {
            RevitProgramFiles = %ProgramFiles%
            {
               FileAppend,
                  (
                  %Username%`t %ComputerName%`t Revit %Discipline% %Version% 64 Bit is not installed`t %TimeString% `n
                  ), \\nevada\drawings\revit\RevitInstall.log
            }
         }
         GoSub APPLICATIONPATH
      }
   }
If (BIT = "64" and PhysMem <= 4)
   {
      RevitProgramFiles = %ProgramFiles%
      GoSub APPLICATIONPATH
   }
APPLICATIONPATH:
AppPath = %RevitProgramFiles%\Revit %Discipline% %VERSION%\Program\
DataPath = %RevitProgramFiles%\Revit %Discipline% %VERSION%\Data\
JournPath = %RevitProgramFiles%\Revit %Discipline% %VERSION%\Journals\


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 4:24 am 
Offline

Joined: August 4th, 2007, 10:39 pm
Posts: 44
Thanks David. I might use your approach.

Lexicos, do you know if it's possible to use the KEY_WOW64_64KEY flag with RegRead? I cannot find an example of how to use that flag. Thanks!

_________________
Regards,
Dave B.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 9:02 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
No.
Chris wrote:
Currently, I think the only way to access entries that exist only in the 64-bit section of the registry is by calling a function like RegOpenKeyEx() via DllCall and passing to it the KEY_WOW64_64KEY flag.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 4:28 pm 
Offline

Joined: August 4th, 2007, 10:39 pm
Posts: 44
I'm trying to use dllcall with Advapi32.dll to read the registry instead of RegRead, but I'm not being successful. I'm messing up the syntax. Below is my test code. I added a value "InstallLocation" under "SYSTEM" just to experiment retrieving its value using this method but I get a blank. I can read it with RegRead (since it's NOT in the SOFTWARE subkey). Can anyone point out what's wrong with the code below? Thanks!

Code:
myhKey:= HKEY_LOCAL_MACHINE
sKeyName:= SYSTEM
sValueName:= InstallLocation

DllCall("Advapi32.dll\RegOpenKeyEx", myhKey, sKeyName, 0, KEY_QUERY_VALUE, hKey)
DllCall("Advapi32.dll\QueryValueEx", hKey, sValueName, vValue)
MsgBox, %vValue%

_________________
Regards,
Dave B.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 10:36 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
You are missing type parameters.
DllCall wrote:
Result := DllCall("[DllFile\]Function" [, Type1, Arg1, Type2, Arg2, "Cdecl ReturnType"])


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2008, 11:07 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Example : Retrieving the ValueType of a Registry Key

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Yahoo [Bot] and 26 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