Author Topic: How to detect autocad 32 /64 bits  (Read 10814 times)

0 Members and 1 Guest are viewing this topic.

MvdP

  • Guest
How to detect autocad 32 /64 bits
« on: April 20, 2010, 02:36:06 AM »
We are in the proces of upgrading to x64 workstations.
Now is on all 32 bits stations doslib loaded in startup suite.(becasue all the same.)
Now i want to detect somehow if a workstation is running autocad 32 or 64 and load the correct arx.
« Last Edit: April 20, 2010, 06:28:04 AM by MvdP »

Patrick_35

  • Guest
Re: How to detect 32 /64 bits
« Reply #1 on: April 20, 2010, 04:23:54 AM »
Hi

You should find your happiness

Code: [Select]
(defun c:info(/ item meth1 meth2 process wmi)
  (defun lister(val / it)
    (vlax-for it val
      (princ (strcat "\n" (vlax-get it 'name) " : "))
      (if (vlax-get it 'value)
        (princ (vlax-get it 'value))
        (princ "Nil")
      )
    )
  )

  (vl-load-com)
  (setq WMI (vlax-create-object "WbemScripting.SWbemLocator")
        meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil))
  (foreach process (list "BIOS" "Processor" "VideoController" "SoundDevice" "CDROMDrive" "OperatingSystem" "ComputerSystem" "PhysicalMemory" "DiskDrive")
    (setq meth2 (vlax-invoke meth1 'ExecQuery (strcat "Select * from Win32_" Process)))
    (princ (strcat "\nCaractéristiques " process " :"))
    (vlax-for item meth2
      (lister (vlax-get item 'Properties_))
      (lister (vlax-get item 'Qualifiers_))
      (getkword "\nAppuyez sur entrée pour continuer...")
    )
  )
  (mapcar 'vlax-release-object (list meth1 meth2 wmi))
  (princ)
)

@+

MvdP

  • Guest
Re: How to detect autocad 32 /64 bits
« Reply #2 on: April 20, 2010, 06:29:59 AM »
Thanks Patrick, but sorry for the misunderstanding.I modified my guestion..

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: How to detect autocad 32 /64 bits
« Reply #3 on: April 20, 2010, 06:40:05 AM »
Patrick,

Regarding your code, if you wanted to retrieve the OS Bit width directly, could you just use this:

Code: [Select]
(defun c:info (/ WMI Serv OSArch item prop)

  (vl-load-com)
  (setq WMI    (vlax-create-object "WbemScripting.SWbemLocator")
        Serv   (vlax-invoke WMI  'ConnectServer nil nil nil nil nil nil nil nil)
        OSArch (vlax-invoke Serv 'ExecQuery "Select OSArchitecture from Win32_OperatingSystem"))

  (vlax-for item OSArch
    (vlax-for prop (vlax-get item 'Properties_)
      (princ (vlax-get prop 'Value))
    )
  )

  (mapcar 'vlax-release-object (list OSArch Serv wmi))
  (princ))

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: How to detect autocad 32 /64 bits
« Reply #4 on: April 20, 2010, 06:42:49 AM »
Or, would this be enough?

Code: [Select]
(vl-string-search "X64" (strcase (getvar 'PLATFORM)))

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: How to detect autocad 32 /64 bits
« Reply #5 on: April 20, 2010, 08:06:39 AM »
(getenv "PROCESSOR_ARCHITECTURE")

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to detect autocad 32 /64 bits
« Reply #6 on: April 20, 2010, 08:14:07 AM »

Doslib is demand loaded ... just drag it into the app when setting up ... don't jump through unnecessary hoops.

There are several add-ons that come in several versions .. personally I'd rely on my initial setup/install to make sure ONLY the correct versions are available. 
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Patrick_35

  • Guest
Re: How to detect autocad 32 /64 bits
« Reply #7 on: April 20, 2010, 08:20:09 AM »
Patrick,

Regarding your code, if you wanted to retrieve the OS Bit width directly, could you just use this:

Code: [Select]
(defun c:info (/ WMI Serv OSArch item prop)

  (vl-load-com)
  (setq WMI    (vlax-create-object "WbemScripting.SWbemLocator")
        Serv   (vlax-invoke WMI  'ConnectServer nil nil nil nil nil nil nil nil)
        OSArch (vlax-invoke Serv 'ExecQuery "Select OSArchitecture from Win32_OperatingSystem"))

  (vlax-for item OSArch
    (vlax-for prop (vlax-get item 'Properties_)
      (princ (vlax-get prop 'Value))
    )
  )

  (mapcar 'vlax-release-object (list OSArch Serv wmi))
  (princ))
Thanks Lee

But I would also like to provide further information because it is not always easy to find

@+

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: How to detect autocad 32 /64 bits
« Reply #8 on: April 20, 2010, 08:20:17 AM »
(getenv "PROCESSOR_ARCHITECTURE")

I knew there had to be something easier...   :-)

Are there only certain registry keys that can be obtained using getenv? And which are they?

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: How to detect autocad 32 /64 bits
« Reply #9 on: April 20, 2010, 08:21:02 AM »
Patrick,

Regarding your code, if you wanted to retrieve the OS Bit width directly, could you just use this:

Code: [Select]
(defun c:info (/ WMI Serv OSArch item prop)

  (vl-load-com)
  (setq WMI    (vlax-create-object "WbemScripting.SWbemLocator")
        Serv   (vlax-invoke WMI  'ConnectServer nil nil nil nil nil nil nil nil)
        OSArch (vlax-invoke Serv 'ExecQuery "Select OSArchitecture from Win32_OperatingSystem"))

  (vlax-for item OSArch
    (vlax-for prop (vlax-get item 'Properties_)
      (princ (vlax-get prop 'Value))
    )
  )

  (mapcar 'vlax-release-object (list OSArch Serv wmi))
  (princ))
Thanks Lee

But I would also like to provide further information because it is not always easy to find

@+

I was just trying to understand the code you posted - I have never used the WMI before  :|

Patrick_35

  • Guest
Re: How to detect autocad 32 /64 bits
« Reply #10 on: April 20, 2010, 08:31:22 AM »
Patrick,

Regarding your code, if you wanted to retrieve the OS Bit width directly, could you just use this:

Code: [Select]
(defun c:info (/ WMI Serv OSArch item prop)

  (vl-load-com)
  (setq WMI    (vlax-create-object "WbemScripting.SWbemLocator")
        Serv   (vlax-invoke WMI  'ConnectServer nil nil nil nil nil nil nil nil)
        OSArch (vlax-invoke Serv 'ExecQuery "Select OSArchitecture from Win32_OperatingSystem"))

  (vlax-for item OSArch
    (vlax-for prop (vlax-get item 'Properties_)
      (princ (vlax-get prop 'Value))
    )
  )

  (mapcar 'vlax-release-object (list OSArch Serv wmi))
  (princ))
Thanks Lee

But I would also like to provide further information because it is not always easy to find

@+

I was just trying to understand the code you posted - I have never used the WMI before  :|
To protect a lisp, I was asked as a question of finding the ID of the processor.
This is the method I found. And as I was, I took the opportunity to identify any.
Like this, no need to seek :D

Quote
(getenv "PROCESSOR_ARCHITECTURE")
Great, I do not know.
How to see all the "getenv" ?

@+

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: How to detect autocad 32 /64 bits
« Reply #11 on: April 20, 2010, 09:16:19 AM »
I'll share with you what I have collected for GetEnv :
Quote
;; Shows how to use expanding environment strings
;; Usage: (ExpEnvStr "%TEMP%\\MYDATA")
;; Results of sample: "C:\\DOCUME~1\\Lee\\LOCALS~1\\Temp\\MYDATA"
(defun ExpEnvStr ( strVal / wshShell)
  (vl-load-com)

  (setq wshShell (vlax-create-object "WScript.Shell"))
  (vlax-invoke-method wshShell 'ExpandEnvironmentStrings strVal)
)

;; Retreive the value of the environment variable
;; Usage: (GetEnvStr "SYSTEM" "USERID")
(defun GetEnvStr ( strVarType strVarName / wshShell envVars)
  (vl-load-com)

  (setq wshShell (vlax-create-object "WScript.Shell"))
  (setq envVars (vlax-get-property wshShell 'Environment strVarType))
  (vlax-get-property envVars 'Item strVarName)
)

;; Set the value to an environment variable
;; Usage: (SetEnvStr "SYSTEM" "USERID" "L123")
(defun SetEnvStr ( strVarType strVarName strVarVal / wshShell envVars)
  (vl-load-com)

  (setq wshShell (vlax-create-object "WScript.Shell"))
  (setq envVars (vlax-get-property wshShell 'Environment strVarType))
  (vlax-put-property envVars 'Item strVarName strVarVal)
)



 Lee, although you shell object is obviously more powerful, I have found that
 you can use (getenv) to return environment variables (at least the ones you can
 access through the DOS [SET] command).

For example: (strcat (getenv "temp") "\\MYDATA")

So for simply retreiving the %temp% directory, the ComputerName, the UserDomain,
etc. - (getenv) should work.

Quote
Posted by: R.K. McSwain | Friday, December 09, 2005 at 07:42 AM

GETENV does work for getting the variables, but the problem is that even though
there is a SETENV function; it can't be used to update OS environment variables.
It instead is wired to specific locations under the AutoCAD registry keys.

So if I have a variable called ALLDOCS that is defined in as a System Variable
for the OS and use SETENV to update it, SETENV writes to the Fixed Profile >>
General location under HKEY_CURRENT_USER >> Software >> Autodesk >> AutoCAD >>
(Release) >> (ProdID).

So it is for this reason that I like to use FSO for everything. From what I have
seen, there is no slow down in performance getting a variable value this way.
Now setting one is a slightly different story.


Code: [Select]
Environment Variables Listing.
Compiled and kindly donated by Stig Madsen.

Remember that environment variables are dependent on .. well, the environment, so each may or may not apply to a certain setup.
Some are almost described, some are definitely not. The first are OS dependent, the rest are AutoCAD dependent.



--------------------------------------------------------------------------------

System related

(getenv "Path") ;string System search paths

(getenv "COMSPEC") ;string Cmd.exe path

(getenv "UserName");string User logon name

(getenv "Temp") ;string Temp path

(getenv "TMP") ;string Temp path

(getenv "ComputerName");string Computer name

(getenv "Windir") ;string Windows path

(getenv "OS") ;string Operating system

(getenv "UserProfile");string Current user profile path

(getenv "Pathext") ;string Exec extensions

(getenv "SystemDrive");string System drive

(getenv "SystemRoot");string System root path

(getenv "MaxArray");integer


--------------------------------------------------------------------------------

General

(getenv "ACAD") ;string Support search paths

(getenv "ANSIHatch");string Pattern file for ANSI setup 1)

(getenv "ANSILinetype");string Linetype file for ANSI setup 1)

(getenv "ISOHatch");string Pattern file for ISO setup 1)

(getenv "ISOLinetype");string Linetype file for ISO setup 1)

(getenv "StartUpType");string Current default for StartUp dialog

(getenv "acet-MenuLoad");string Loading of Express Tools menu

(getenv "Measureinit");string MEASUREINIT

(getenv "InsertUnitsDefSource");integer INSUNITSDEFSOURCE

(getenv "InsertUnitsDefTarget");integer INSUNITSDEFTARGET

(getenv "acet-Enable");string

(getenv "LastTemplate");string Last DWT used

(getenv "AcetRText:type");string Current default for RTEXT "Diesel"

(getenv "Pickstyle");integer

(getenv "Coords") ;integer

(getenv "ShowProxyDialog");integer

(getenv "Osmode") ;integer

(getenv "EdgeMode");integer

(getenv "PAPERUPDATE");integer

(getenv "ACADPLCMD");string Plotter command string

(getenv "ImageHighlight");integer

(getenv "Attdia") ;integer

(getenv "Attreq") ;integer

(getenv "Delobj") ;integer

(getenv "Dragmode");integer

(getenv "UseMRUConfig");integer

(getenv "PLSPOOLALERT");integer

(getenv "PLOTLEGACY");integer

(getenv "PSTYLEPOLICY");integer

(getenv "OLEQUALITY");integer

(getenv "Anyport") ;integer

(getenv "Validation Policy");integer

(getenv "Validation Strategy");integer

(getenv "CommandDialogs");integer CMDDIA

(getenv "TempDirectory");string Temp dir

(getenv "PlotSpoolerDirectory");string Spooler dir

(getenv "DefaultLoginName");string Default login

(getenv "MenuFile");string Default menu path

(getenv "NetLocation");string Default URL

(getenv "ACADDRV") ;string Driver path

(getenv "ACADHELP");string Help path

(getenv "PrinterConfigDir");string Plotter path

(getenv "PrinterStyleSheetDir");string Plot styles path

(getenv "PrinterDescDir");string Plotter driver path

(getenv "NewStyleSheet");string Default .stb/.ctb file

(getenv "DefaultFormatForSave");integer Default saveas

(getenv "DefaultConfig");string Default pc3

(getenv "LastModifiedConfig");string Last pc3

(getenv "MRUConfig");string pc3?

(getenv "ACADLOGFILE");string Logfile

(getenv "MaxDwg") ;integer

(getenv "AVEMAPS") ;string Texture files path

(getenv "TemplatePath");string Templates path

(getenv "DatabaseWorkSpacePath");string Data Links path

(getenv "DefaultPlotStyle");string e.g. "ByLayer"

(getenv "DefaultLayerZeroPlotStyle");string e.g."Normal"

(getenv "LineWeightUnits");integer

(getenv "LWDEFAULT");integer Default lineweight

(getenv "CustomColors");integer

(getenv "Blipmode");integer

(getenv "ToolTips");string

1) used by MEASUREINIT and MEASUREMENT sysvars


--------------------------------------------------------------------------------

Editor Configuration

(getenv "SDF_AttributeExtractTemplateFile");string ??

(getenv "AutoSnapPolarAng");string POLARANG

(getenv "AutoSnapPolarDistance");string POLARDIST

(getenv "AutoSnapPolarAddAng");string POLARADDANG

(getenv "AutoSnapControl");integer AUTOSNAP

(getenv "AutoSnapTrackPath");integer TRACKPATH

(getenv "PickBox") ;integer PICKBOX

(getenv "AutoSnapSize");integer

(getenv "PickFirst");integer PICKFIRST

(getenv "PickAuto");integer PICKAUTO

(getenv "MenuOptionFlags");integer MENUCTL

(getenv "FontMappingFile");string

(getenv "LogFilePath");string

(getenv "PSOUT_PrologFileName");string

(getenv "MainDictionary");string

(getenv "CustomDictionary");string

(getenv "MTextEditor");string

(getenv "XrefLoadPath");string

(getenv "SaveFilePath");string

(getenv "AcadLspAsDoc");string


--------------------------------------------------------------------------------

Drawing Window

(getenv "Background");integer Background color

(getenv "Layout background");integer PS Background color

(getenv "XhairPickboxEtc");integer Crosshair color

(getenv "LayoutXhairPickboxEtc");integer PS Crosshair color

(getenv "Autotracking vector");integer Autotracking vector color

(getenv "MonoVectors");integer

(getenv "FontFace");string Screen Menu

(getenv "FontHeight");integer

(getenv "FontWeight");integer

(getenv "FontItalic");integer

(getenv "FontPitchAndFamily");integer

(getenv "CursorSize");integer

(getenv "HideWarningDialogs");integer:00000008 <- hit

(getenv "ScreenMenu") ; interger, 1 turns it on;

(getenv "SDIMode") ;integer:00000000 <- hit


--------------------------------------------------------------------------------

Command Line Windows

(getenv "CmdLine.ForeColor");integer

(getenv "CmdLine.BackColor");integer

(getenv "TextWindow.ForeColor");integert

(getenv "TextWindow.BackColor");integer

(getenv "CmdLine.FontFace");string

(getenv "CmdLine.FontHeight");integer

(getenv "CmdLine.FontWeight");integer

(getenv "CmdLine.FontItalic");integer

(getenv "CmdLine.FontPitchAndFamily");integer

(getenv "TextWindow.FontFace");string

(getenv "TextWindow.FontHeight");integer

(getenv "TextWindow.FontWeight");integer

(getenv "TextWindow.FontItalic");integer

(getenv "TextWindow.FontPitchAndFamily");integer
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: How to detect autocad 32 /64 bits
« Reply #12 on: April 20, 2010, 09:20:59 AM »
Thanks Alan, appreciated.  :-)

MvdP

  • Guest
Re: How to detect autocad 32 /64 bits
« Reply #13 on: April 20, 2010, 09:27:34 AM »
Found this on the Autodesk discussion groups.

Code: [Select]
(defun ISX64 (/ proc_arch)
(and
(setq proc_arch (getenv "PROCESSOR_ARCHITECTURE"))
(< 1 (strlen proc_arch))
(eq "64" (substr proc_arch (1- (strlen proc_arch))))
)
)

;; determine whether appropriate version of DOSLib is already loaded.
;; if not, try to load it.
(setvar "cmdecho" 0)
(setq CADver (substr (getvar "acadver") 1 2)) ;; i.e., "17", "18", etc.
(setq arxlist (arx))
(if (isX64)
(setq DOSLibname (strcat "doslib" CADver "x64.arx"))
(setq DOSLibname (strcat "doslib" CADver ".arx"))
)
(foreach a arxlist (if (equal a DOSLibname) (setq loadedAtStartup T) ))
(if (not loadedAtStartup)

(vl-cmdf "._arx" "_load" (findfile DOSLibname))
)

;; verify that load was successful.
;; if not, quit.
(setq arxlist (arx))
(foreach a arxlist (if (equal a DOSLibname) (setq loadedAtRuntime T) ))
(if (not loadedAtRuntime)
(progn
(prompt "Sorry - DOSLib is not loaded and cannot be found in the
AutoCAD search path.")
(vlr-beep-reaction)
(quit)
  (setvar "cmdecho" 1)
)
)

http://discussion.autodesk.com/forums/thread.jspa?messageID=6347941&#6347941

Patrick_35

  • Guest
Re: How to detect autocad 32 /64 bits
« Reply #14 on: April 20, 2010, 10:52:37 AM »
Thanks Cab  :-)

@+

VVA

  • Newt
  • Posts: 166
Re: How to detect autocad 32 /64 bits
« Reply #15 on: April 23, 2010, 11:05:51 AM »
My 5 cents
Quote
vlax-get-acad-object in 64-bit return a longer object ID number than in the 32-bit so the function Acad64Bit-version will return T if AutoCAD is a 64-bit version.
Code: [Select]
(defun Acad64Bit-version ()
;;; Get from http://forum.dwg.ru/showthread.php?t=31568
;;;vlax-get-acad-object in 64-bit return a longer object ID number
;;;than in the 32-bit so the function Acad64Bit-version
;;; will return T if AutoCAD is a 64-bit version.
  (vl-load-com)
  (> (strlen (vl-prin1-to-string (vlax-get-acad-object))) 40)
)

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to detect autocad 32 /64 bits
« Reply #16 on: April 23, 2010, 11:35:25 AM »
Just to add to what others and I have already provided ...

These should work in theory, but as I'm not running 64 bit here -- no can test. Would be great if some 64 bit folks could test and report success/fail. Thanks in advance.

*Not better <hard to improve upon (getenv "PROCESSOR_ARCHITECTURE")>, just another way to skin the cat.*

Code: [Select]
(defun _Is64Bit ( / wmiLocater wmiService queryResult result )

    ;;========================================================================
    ;;
    ;;  2010/04/23 | Quick & Dirty | Michael Puckett
    ;;
    ;;========================================================================

    (vl-catch-all-apply
       '(lambda ( )
            (vlax-for item
                (setq queryResult
                    (vlax-invoke
                        (setq
                            wmiLocater (vlax-create-object "WbemScripting.SWbemLocator")
                            wmiService (vlax-invoke wmiLocater 'ConnectServer "." "root\\cimv2")
                        )
                       'ExecQuery
                        (strcat
                            "Select * "
                            "from   Win32_Processor "
                        )
                    )
                )
                (setq result (vlax-get item 'Description))
            )
        )
    )

    (if queryResult (vlax-release-object queryResult))
    (if wmiService (vlax-release-object wmiService))
    (if wmiLocater (vlax-release-object wmiLocater))

    (if result (wcmatch result "*64*"))

)

Code: [Select]
(defun _Is64Bit ( / wmiLocater wmiService queryResult result )

    ;;========================================================================
    ;;
    ;;  2010/04/23 | Quick & Dirty | Michael Puckett
    ;;
    ;;========================================================================

    (vl-catch-all-apply
       '(lambda ( )
            (vlax-for item
                (setq queryResult
                    (vlax-invoke
                        (setq
                            wmiLocater (vlax-create-object "WbemScripting.SWbemLocator")
                            wmiService (vlax-invoke wmiLocater 'ConnectServer "." "root\\cimv2")
                        )
                       'ExecQuery
                        (strcat
                            "Select * "
                            "from   Win32_Processor "
                        )
                    )
                )
                (setq result (vlax-get item 'Architecture))
            )
        )
    )

    (if queryResult (vlax-release-object queryResult))
    (if wmiService (vlax-release-object wmiService))
    (if wmiLocater (vlax-release-object wmiLocater))

    (if result (eq 9 result))

)

Edit: Fixed glaring typo.
« Last Edit: April 23, 2010, 12:45:17 PM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: How to detect autocad 32 /64 bits
« Reply #17 on: April 23, 2010, 12:35:11 PM »
All I have time for right now; have a meeting this afternoon.

Windows 7 x64
AutoCAD MEP 208 x32

Quote
Command:
Command: (getenv "PROCESSOR_ARCHITECTURE")
"x86"

Command: (defun _Is64Bit ( / wmiLocater wmiService queryResult result )
(_>
(_>     
;;========================================================================
(_>     ;;
(_>     ;;  2010/04/23 | Quick & Dirty | Michael Puckett
(_>     ;;
(_>     
;;========================================================================
(_>
(_>     (vl-catch-all-apply
((_>        '(lambda ( )
(('(_>             (vlax-for item
(('((_>                 (setq queryResult
(('(((_>                     (vlax-invoke
(('((((_>                         (setq
(('(((((_>                             wmiLocater (vlax-create-object
"WbemScripting.SWbemLocator")
(('(((((_>                             wmiService (vlax-invoke wmiLocater
'ConnectServer "." "root\\cimv2")
(('(((((_>                         )
(('((((_>                        'ExecQuery
(('((((_>                         (strcat
(('(((((_>                             "Select * "
(('(((((_>                             "from   Win32_Processor "
(('(((((_>                         )
(('((((_>                     )
(('(((_>                 )
(('((_>                 (setq result (vlax-get item 'Description))
(('((_>             )
(('(_>         )
((_>     )
(_>
(_>     (if queryResult (vlax-release-object queryResult))
(_>     (if wmiService (vlax-release-object wmiService))
(_>     (if wmiLocater (vlax-release-object wmiLocater))
(_>
(_>     (if result (wcmatch result "*64*"))
(_>
(_> )
_IS64BIT

Command: (_is64bit)
T


Command: (defun _Is64Bit ( / wmiLocater wmiService queryResult result )
(_>
(_>     
;;========================================================================
(_>     ;;
(_>     ;;  2010/04/23 | Quick & Dirty | Michael Puckett
(_>     ;;
(_>     
;;========================================================================
(_>
(_>     (vl-catch-all-apply
((_>        '(lambda ( )
(('(_>             (vlax-for item
(('((_>                 (setq queryResult
(('(((_>                     (vlax-invoke
(('((((_>                         (setq
(('(((((_>                             wmiLocater (vlax-create-object
"WbemScripting.SWbemLocator")
(('(((((_>                             wmiService (vlax-invoke wmiLocater
'ConnectServer "." "root\\cimv2")
(('(((((_>                         )
(('((((_>                        'ExecQuery
(('((((_>                         (strcat
(('(((((_>                             "Select * "
(('(((((_>                             "from   Win32_Processor "
(('(((((_>                         )
(('((((_>                     )
(('(((_>                 )
(('((_>                 (setq result (vlax-get item 'Architure))
(('((_>             )
(('(_>         )
((_>     )
(_>
(_>     (if queryResult (vlax-release-object queryResult))
(_>     (if wmiService (vlax-release-object wmiService))
(_>     (if wmiLocater (vlax-release-object wmiLocater))
(_>
(_>     (if result (eq 9 result))
(_>
(_> )
_IS64BIT

Command: (_is64bit)
nil
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to detect autocad 32 /64 bits
« Reply #18 on: April 23, 2010, 12:44:34 PM »
GAAA. F*****G LAME TYPING SKILLS.

The property should be 'Architecture, not 'Architure (epic facepalm).

Try this --

Code: [Select]
(defun _Is64Bit ( / wmiLocater wmiService queryResult result )

    ;;========================================================================
    ;;
    ;;  2010/04/23 | Quick & Dirty | Michael Puckett
    ;;
    ;;========================================================================

    (vl-catch-all-apply
       '(lambda ( )
            (vlax-for item
                (setq queryResult
                    (vlax-invoke
                        (setq
                            wmiLocater (vlax-create-object "WbemScripting.SWbemLocator")
                            wmiService (vlax-invoke wmiLocater 'ConnectServer "." "root\\cimv2")
                        )
                       'ExecQuery
                        (strcat
                            "Select * "
                            "from   Win32_Processor "
                        )
                    )
                )
                (setq result (vlax-get item 'Architecture))
            )
        )
    )

    (if queryResult (vlax-release-object queryResult))
    (if wmiService (vlax-release-object wmiService))
    (if wmiLocater (vlax-release-object wmiLocater))

    (if result (eq 9 result))

)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

hmspe

  • Bull Frog
  • Posts: 362
Re: How to detect autocad 32 /64 bits
« Reply #19 on: April 23, 2010, 04:29:09 PM »
Both _Is64Bit functions return T on my 64 bit Win 7 computer.  I added a function that ran (Print (_Is64Bit)) on each.  It took almost 3 seconds to run on an Intel E8400 at 3GHz.   (getenv "PROCESSOR_ARCHITECTURE") returns "AMD64".
"Science is the belief in the ignorance of experts." - Richard Feynman

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to detect autocad 32 /64 bits
« Reply #20 on: April 23, 2010, 05:25:46 PM »
3 seconds to execute (_Is64Bit)? Good gief that's horrible. Subtitle: Aside from possible academic value what I posted is worthless. DO NOT USE!

Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to detect autocad 32 /64 bits
« Reply #21 on: April 23, 2010, 05:28:40 PM »
PS: thx for trying. :)

PS2: forgive 'gief' typo in preceding post - no can edit from blackberry.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: How to detect autocad 32 /64 bits
« Reply #22 on: April 28, 2010, 02:04:56 PM »
The operating system isn't something that changes on a day-to-day basis, so if the value is needed a simple set and forget user registry entry could be used to store the value.  The registry entry can then be checked when the 32/64 bit value is needed and if missing, query the user via a dialog or silently via other settings (even if it takes several seconds its a one-time deal).
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How to detect autocad 32 /64 bits
« Reply #23 on: April 28, 2010, 06:45:21 PM »
PS2: forgive 'gief' typo in preceding post - no can edit from blackberry.
Eehhh Phone is not so smart as it thinks it is?  Or is is the operator?  :evil: :roll:
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

Andrea

  • Water Moccasin
  • Posts: 2372
Re: How to detect autocad 32 /64 bits
« Reply #24 on: April 29, 2010, 11:33:23 AM »
just putting some info...

Code: [Select]
(vl-registry-descendents "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node")
Keep smile...

MvdP

  • Guest
Re: How to detect autocad 32 /64 bits
« Reply #25 on: April 29, 2010, 01:28:30 PM »
Doslib is not the only arx i want to load .Is it possible to add

Idwgtab
Periscope
Quikpik
to this code.?



Code: [Select]
(defun ISX64 (/ proc_arch)
(and
(setq proc_arch (getenv "PROCESSOR_ARCHITECTURE"))
(< 1 (strlen proc_arch))
(eq "64" (substr proc_arch (1- (strlen proc_arch))))
)
)

;; determine whether appropriate version of DOSLib is already loaded.
;; if not, try to load it.
(setvar "cmdecho" 0)
(setq CADver (substr (getvar "acadver") 1 2)) ;; i.e., "17", "18", etc.
(setq arxlist (arx))
(if (isX64)
(setq DOSLibname (strcat "doslib" CADver "x64.arx"))
(setq DOSLibname (strcat "doslib" CADver ".arx"))
)
(foreach a arxlist (if (equal a DOSLibname) (setq loadedAtStartup T) ))
(if (not loadedAtStartup)

(vl-cmdf "._arx" "_load" (findfile DOSLibname))
)

;; verify that load was successful.
;; if not, quit.
(setq arxlist (arx))
(foreach a arxlist (if (equal a DOSLibname) (setq loadedAtRuntime T) ))
(if (not loadedAtRuntime)
(progn
(prompt "Sorry - DOSLib is not loaded and cannot be found in the
AutoCAD search path.")
(vlr-beep-reaction)
(quit)
  (setvar "cmdecho" 1)
)
)