GEOSoft Posted January 20, 2008 Share Posted January 20, 2008 (edited) I'm witing a short registry script that must run on all architectures. I don't have a 64 bit box to test this on but I need to verify that this code is correct. If @ProcessorArch = "X86" Then $rHive = "HKLM" Else $rHive = "HKLM64" EndIf Thanks Edit: If you test this, please let me know which architecture you tested it on ( ClipPut(@ProcessorArch) ). Edited January 20, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
martin Posted January 20, 2008 Share Posted January 20, 2008 I'm witing a short registry script that must run on all architectures. I don't have a 64 bit box to test this on but I need to verify that this code is correct. If @ProcessorArch = "X86" Then $rHive = "HKLM" Else $rHive = "HKLM64" EndIf Thanks Just for my education, does a 64 bit processor necessarily have a 64 bit operating system? (I could check your code on my son's computer when he releases his girlfriend from his bedroom, but someone else will probably answer before that.) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
GEOSoft Posted January 20, 2008 Author Share Posted January 20, 2008 Just for my education, does a 64 bit processor necessarily have a 64 bit operating system? (I could check your code on my son's computer when he releases his girlfriend from his bedroom, but someone else will probably answer before that.)Not necessarily. You can still run a 32 bit OS or application on a 64 bit machine. You just don't get the advantages of running 64 bit. As for your sons current status "No comment." George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
martin Posted January 20, 2008 Share Posted January 20, 2008 (edited) Not necessarily. You can still run a 32 bit OS or application on a 64 bit machine. You just don't get the advantages of running 64 bit.So in that case detecting X64 or IA64 doesn't mean that HKLM64 will exist, so maybe you should be detecting something else which tells you that a 64-bit OS is installed. Like If FileExist('@SystemDir\ndfetw.dll') which is only found on 64 bit versions of windows. (Only found on Vista, I'm getting confused.)EDIT: Strike out rubbish. Edited January 20, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Emiel Wieldraaijer Posted January 20, 2008 Share Posted January 20, 2008 I use something like this $HKCU = "HKEY_CURRENT_USER" $HKLM = "HKEY_LOCAL_MACHINE" $HKU = "HKEY_USERS" $HKCU = "HKEY_CURRENT_USER" $HKCR = "HKEY_CLASSES_ROOT" $HKCC = "HKEY_CURRENT_CONFIG" If @ProcessorArch = "X64" Then $HKCU = "HKEY_CURRENT_USER64" $HKLM = "HKEY_LOCAL_MACHINE64" $HKU = "HKEY_USERS64" $HKCU = "HKEY_CURRENT_USER64" $HKCR = "HKEY_CLASSES_ROOT64" $HKCC = "HKEY_CURRENT_CONFIG64" EndIf maybe adding something like @OSType will cover everything Emiel Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
GEOSoft Posted January 21, 2008 Author Share Posted January 21, 2008 So in that case detecting X64 or IA64 doesn't mean that HKLM64 will exist, so maybe you should be detecting something else which tells you that a 64-bit OS is installed. Like If FileExist('@SystemDir\ndfetw.dll') which is only found on 64 bit versions of windows. (Only found on Vista, I'm getting confused.)EDIT: Strike out rubbish.I think you are correct. @ProcessorArch won't do it. On the other hand I don't think @OSVersion will either.I may have to do a RegRead() on a known 32 bit key and If @Error = 2 Then it's 64 bit. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GEOSoft Posted January 21, 2008 Author Share Posted January 21, 2008 I use something like this $HKCU = "HKEY_CURRENT_USER" $HKLM = "HKEY_LOCAL_MACHINE" $HKU = "HKEY_USERS" $HKCU = "HKEY_CURRENT_USER" $HKCR = "HKEY_CLASSES_ROOT" $HKCC = "HKEY_CURRENT_CONFIG" If @ProcessorArch = "X64" Then $HKCU = "HKEY_CURRENT_USER64" $HKLM = "HKEY_LOCAL_MACHINE64" $HKU = "HKEY_USERS64" $HKCU = "HKEY_CURRENT_USER64" $HKCR = "HKEY_CLASSES_ROOT64" $HKCC = "HKEY_CURRENT_CONFIG64" EndIf maybe adding something like @OSType will cover everything EmielThat's pretty much what I was doing but I only used the one key as an example. However as martin just pointed out the keys are based on the Windows version and @OSVersion will bot return anything special for 64 bit that I know of. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
martin Posted January 21, 2008 Share Posted January 21, 2008 (edited) That's pretty much what I was doing but I only used the one key as an example. However as martin just pointed out the keys are based on the Windows version and @OSVersion will bot return anything special for 64 bit that I know of. I think you need something like this ;IsOS64 returns true if OS is 64 bit ;IsWOW64Process function only exists on 64 bit windows Func IsOS64() Local $hUser32 = DllCall("kernel32.dll", "ptr", "LoadLibrary", "str", "user32.dll") Local $OS64 = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", $hUser32[0], "str", "IsWow64Process") return $OS64[0] <> 0 endfunc Edited January 21, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
GEOSoft Posted January 21, 2008 Author Share Posted January 21, 2008 I think you need something like this ;IsOS64 returns true if OS is 64 bit ;IsWOW64Process function only exists on 64 bit windows Func IsOS64() Local $hUser32 = DllCall("kernel32.dll", "ptr", "LoadLibrary", "str", "user32.dll") Local $OS64 = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", $hUser32[0], "str", "IsWow64Process") return $OS64[0] <> 0 endfuncThat's exactly what it needs martin. Thanks a lot. As a matter of fact I would suggest that this be posted on the Wiki and perhaps also included somewhere in the help file. Here is what I finally came up with Declare this with the other Global variables in your script Global $kCR, $kCU, $kLM, $kU, $kCC _Get_RegKeys() Add these functions in your script. Func _Get_RegKeys() If _64BitOS() Then $kCR = "HKCR64" $kCU = "HKCU64" $kLM = "HKLM64" $kU = "HKU64" $kCC = "HKCC64" Else $kCR = "HKCR" $kCU = "HKCU" $kLM = "HKLM" $kU = "HKU" $kCC = "HKCC" EndIf EndFunc Func _64BitOS();; Returns true if OS is 64 bit (credits go to martin) Local $hUser32 = DllCall("kernel32.dll", "ptr", "LoadLibrary", "str", "user32.dll") Local $OS64 = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", $hUser32[0], "str", "IsWow64Process") Return $OS64[0] <> 0 Endfunc George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
james3mg Posted January 21, 2008 Share Posted January 21, 2008 My computer is dual-64-bit processors, but I'm running Vista 32-bit (don't ask...I need access to old drivers). If I run MsgBox(0,"hi",@ProcessorArch)the message box displays X86. And yes, I'm quite sure my processors are 64-bit: I've installed many flavors of 64-bit OSes on it before. I think that @ProcessorArch actually checks the OS arch, not what the processor's capable of. So...problem solved, no? "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110 Link to comment Share on other sites More sharing options...
GEOSoft Posted January 21, 2008 Author Share Posted January 21, 2008 My computer is dual-64-bit processors, but I'm running Vista 32-bit (don't ask...I need access to old drivers). If I run MsgBox(0,"hi",@ProcessorArch)the message box displays X86. And yes, I'm quite sure my processors are 64-bit: I've installed many flavors of 64-bit OSes on it before. I think that @ProcessorArch actually checks the OS arch, not what the processor's capable of. So...problem solved, no?That could be, but I'm not sure that I would trust it as much as martins solution. I was using @ProcessorArch (see first post) but if that macro is doing what it is described as doing then it should be reporting 64 bit in your case. Your results would indicate to me that either the description for the macro is wrong or there is a bug in that code. Or there is the posibility that the macro is just named incorrectly and my original code is correct. I'll stay with martins solution until a dev can confirm what's happening here. Thanks for the insight james. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
martin Posted January 21, 2008 Share Posted January 21, 2008 That's exactly what it needs martin. Thanks a lot. As a matter of fact I would suggest that this be posted on the Wiki and perhaps also included somewhere in the help file. Here is what I finally came up with Declare this with the other Global variables in your script Global $kCR, $kCU, $kLM, $kU, $kCC _Get_RegKeys() Add these functions in your script. Func _Get_RegKeys() If _64BitOS() Then $kCR = "HKCR64" $kCU = "HKCU64" $kLM = "HKLM64" $kU = "HKU64" $kCC = "HKCC64" Else $kCR = "HKCR" $kCU = "HKCU" $kLM = "HKLM" $kU = "HKU" $kCC = "HKCC" EndIf EndFunc Func _64BitOS();; Returns true if OS is 64 bit (credits go to martin) Local $hUser32 = DllCall("kernel32.dll", "ptr", "LoadLibrary", "str", "user32.dll") Local $OS64 = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", $hUser32[0], "str", "IsWow64Process") Return $OS64[0] <> 0 Endfunc I''m glad you like that function GEOSoft, but when I said "something like this" that was my way of saying I haven't tried it. Do you know if it returns true on a 64 bit OS? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
GEOSoft Posted January 21, 2008 Author Share Posted January 21, 2008 I''m glad you like that function GEOSoft, but when I said "something like this" that was my way of saying I haven't tried it. Do you know if it returns true on a 64 bit OS?We need someone to try that but it looks to me like it should. I'll leave it as is until we find someone running a 64 bit OS that can state categorically that it doesn't. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Administrators Jon Posted January 21, 2008 Administrators Share Posted January 21, 2008 ProcessorArch returns X64 on my system (Vista 64bit). We were actually having a dev conversation about the bad naming of these macros. Edit: that is, ProcessorArch returns the OS type of 32/64bit nothing to do with the actual processor! Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
GEOSoft Posted January 21, 2008 Author Share Posted January 21, 2008 ProcessorArch returns X64 on my system (Vista 64bit). We were actually having a dev conversation about the bad naming of these macros.That would seem correct Jon. The issue seems to be more of what should it return when running a 32 bit OS on a machine with a 64 bit processor. That's not your average setup I grant you, but the return could be critical as in the case james3mp has pointed out. BTW could you please (since you have 64 bit) check the code posted by martin and see if it returns True for your system? Thanks George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Administrators Jon Posted January 21, 2008 Administrators Share Posted January 21, 2008 That would seem correct Jon. The issue seems to be more of what should it return when running a 32 bit OS on a machine with a 64 bit processor. That's not your average setup I grant you, but the return could be critical as in the case james3mp has pointed out. BTW could you please (since you have 64 bit) check the code posted by martin and see if it returns True for your system? Thanksx64 processor running x86 OS = x86. It should be called OSArch Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Emiel Wieldraaijer Posted January 21, 2008 Share Posted January 21, 2008 maybe a small documentation update which explains @ProcessorArch displays OS Architecture and not the true ProcessorArchitecture Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
Administrators Jon Posted January 21, 2008 Administrators Share Posted January 21, 2008 maybe a small documentation updatewhich explains @ProcessorArch displays OS Architecture and not the true ProcessorArchitectureI think we need a true processorarch as well. Which tells if the chip is x64 or not regardless of OS type. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
GEOSoft Posted January 21, 2008 Author Share Posted January 21, 2008 I think we need a true processorarch as well. Which tells if the chip is x64 or not regardless of OS type.I agree with this 100% but I can just hear the mumbles from Valik now. In the meantime I can switch the code back to @ProcessorArch but before I do that, did you test martins code with 64bit processor and 64 bit OS? it should return True. If it does then I'll leave my code as is so it doesn't get broken if you do change the macros. Assumably the existing @ProcessorArch would become @OSArch and a new @ProcessorArch developed. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Administrators Jon Posted January 21, 2008 Administrators Share Posted January 21, 2008 Martin's code returned "False" here. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now