 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
dbaldacchino
Joined: 04 Aug 2007 Posts: 44
|
Posted: Thu Nov 13, 2008 10:50 pm Post subject: RegRead in Vista 64 |
|
|
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. |
|
| Back to top |
|
 |
dbaldacchino
Joined: 04 Aug 2007 Posts: 44
|
Posted: Fri Nov 14, 2008 3:27 pm Post subject: |
|
|
No comments? _________________ Regards,
Dave B. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 8255 Location: Maywood, IL
|
Posted: Fri Nov 14, 2008 4:57 pm Post subject: |
|
|
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. _________________
(Common Answers) |
|
| Back to top |
|
 |
dbaldacchino
Joined: 04 Aug 2007 Posts: 44
|
Posted: Fri Nov 14, 2008 7:10 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
david.kingham
Joined: 06 Nov 2007 Posts: 24
|
Posted: Tue Nov 18, 2008 1:02 am Post subject: |
|
|
Well Dave the news is not so bright...http://www.autohotkey.com/forum/viewtopic.php?t=23501&highlight=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  |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7295 Location: Australia
|
|
| Back to top |
|
 |
david.kingham
Joined: 06 Nov 2007 Posts: 24
|
|
| Back to top |
|
 |
Guest
|
Posted: Tue Nov 18, 2008 11:35 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
dbaldacchino
Joined: 04 Aug 2007 Posts: 44
|
Posted: Tue Nov 18, 2008 11:37 pm Post subject: |
|
|
Oh, that was me by the way....switching machines really bites when you don't realize you're not logged in  _________________ Regards,
Dave B. |
|
| Back to top |
|
 |
david.kingham
Joined: 06 Nov 2007 Posts: 24
|
Posted: Tue Nov 18, 2008 11:56 pm Post subject: |
|
|
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\ |
|
|
| Back to top |
|
 |
dbaldacchino
Joined: 04 Aug 2007 Posts: 44
|
Posted: Wed Nov 19, 2008 3:24 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7295 Location: Australia
|
Posted: Wed Nov 19, 2008 8:02 am Post subject: |
|
|
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. |
|
|
| Back to top |
|
 |
dbaldacchino
Joined: 04 Aug 2007 Posts: 44
|
Posted: Wed Nov 19, 2008 3:28 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7295 Location: Australia
|
Posted: Wed Nov 19, 2008 9:36 pm Post subject: |
|
|
You are missing type parameters.
| DllCall wrote: | | Result := DllCall("[DllFile\]Function" [, Type1, Arg1, Type2, Arg2, "Cdecl ReturnType"]) |
|
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|