Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Windows is 32 or 64?

17 REPLIES 17
SOLVED
Reply
Message 1 of 18
aqdam1978
1025 Views, 17 Replies

Windows is 32 or 64?

Hi,

 

I have my own acaddoc.lsp file, I need to load some arx file depends on Windows version:

 

acaddoc.lsp:

 

;if AutoCAD is 32bit:
(arxload "DOSLib19.arx")

 

;if AutoCAD is 64bit:
(arxload "DOSLib19x64.arx")

 

So, how can I find out the OS version and implement this lisp file?

 

Thanks,

 

 

17 REPLIES 17
Message 2 of 18
hmsilva
in reply to: aqdam1978

aqdam1978

try

 

(getvar "PLATFORM")

 

Henrique

EESignature

Message 3 of 18
hmsilva
in reply to: aqdam1978

aqdam1978,

with the

 

(getvar "PLATFORM");;for Windows 7 I get

 

"Microsoft Windows NT Version 6.1 (x86)"

 

for 32bit and

 

"Microsoft Windows NT Version 6.1 (x64)"

 

for 32bit, so to implement your arxload, using your previous code, perhaps something like

 

(setq str (getvar "PLATFORM"))
(setq pos (vl-string-position (ascii "(") str))
(setq osver (substr str (+ pos 2)))
(if (= osver "x86)")
  (arxload "DOSLib19.arx")
  (arxload "DOSLib19x64.arx")
);; if

 

perhaps not the most elegant way to do it, but will do the trick.

 

hope that helps

Henrique

EESignature

Message 4 of 18
aqdam1978
in reply to: hmsilva

Hi hmsilva,

 

Thank you for your code,

I just change the 3rd and 4th line:

 

;;----- gets OS version x86 or x64 ---------------------
(setq str (getvar "PLATFORM"))
(setq pos (vl-string-position (ascii "(") str))
(setq osver (substr str (+ pos 2) 3))
(if (= osver "x86")
  (arxload "DOSLib19.arx")
  (arxload "DOSLib19x64.arx")
);; if

 

Message 5 of 18
hmsilva
in reply to: aqdam1978

You're welcome, aqdam1978
glad you got a solution

 

Henrique

EESignature

Message 6 of 18
hmsilva
in reply to: aqdam1978

aqdam1978,
just another way to load the arx files, or other file types, is first to be sure that the file exists,
and then load it, in this way there will be no error related to the load, and canceling the rest of your code,
in the example below,  the file to load is in a suport directory, if not, we have to provide the full path,

 

(if (and (= osver "x86")
	 (findfile "DOSLib19.arx"));; if osver is 32bit and the arx file is found then
  (arxload "DOSLib19")
  );; if
(if (and (= osver "x64")
	 (findfile "DOSLib19x64.arx"));; if osver is 64bit and the arx file is found then
  (arxload "DOSLib19x64")
);; if

 

or another way

 

(cond
  ((and (= osver "x86") (findfile "DOSLib19.arx"));; if osver is 32bit and the arx file is found then
   (arxload "DOSLib19")
  )
  ((and (= osver "x64") (findfile "DOSLib19x64.arx"));; if osver is 64bit and the arx file is found then
   (arxload "DOSLib19x64")
  )
);; cond

 

hope that helps

Henrique

EESignature

Message 7 of 18
aqdam1978
in reply to: hmsilva

Hi Henrique,

 

Thanks for your ideas,

I change the program to:

;;----- LOAD your app depends on OS version (x86 or x64) -----------
(defun C:app_load_by_OS(/ str pos OSVer x86app x64app)
(setq 
  str (getvar "PLATFORM")
  pos (vl-string-position (ascii "(") str)
  osver (substr str (+ pos 2) 3)
;------ Your app in both version (x86 or x64) ---------------------
  x86app "DOSLib19.arx"
  x64app "DOSLib19x64.arx"
);;setq

(if (= osver "x86")
    (progn
		(if (findfile x86app) (arxload x86app)
		(alert (strcat "Error:\nfile: " x86app "\nNot found!")))
    );;progn
;;else if
	(if (= osver "x64")
		(progn
			(if (findfile x64app) (arxload x64app)
			(alert (strcat "Error:\nfile: " x64app "\nNot found!")))
		);;progn
	;;else
		(alert "Error:\nYour system not supported!")
	);;if x64
);;if x86
)

 Thanks,

 

Abbas

 

 

Message 8 of 18
hmsilva
in reply to: aqdam1978

Glad I could help

 

Henrique

EESignature

Message 9 of 18
dgorsman
in reply to: aqdam1978

Operating systems don't change day to day, week to week, or even month-to-month.  Create your own registry key and set it once with "x32" or "x64" (or "x128" - future compatibility...), then read it when checking using (vl-registry-read...).  You can also use it for other applications.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 10 of 18
aqdam1978
in reply to: hmsilva

Hi Hmsilva,

 

(getvar "PLATFORM") did not work on some windows OS's.

it is better to use this code:

 

(defun c:GetOSArchitecture  (/ WMI meth1 meth2 result)
  (vl-load-com)
  (cond ((and (setq WMI (vlax-create-object "WbemScripting.SWbemLocator"))
              (setq meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil))
              (setq meth2 (vlax-invoke meth1 'ExecQuery (strcat "Select * from Win32_" "OperatingSystem")))
              (vlax-for itm  (vlax-get (vlax-invoke meth2 'ItemIndex 0) 'Properties_)
                (if (eq (vlax-get itm 'name) "OSArchitecture")
                  (setq result (vlax-get itm 'value)))))))
  (mapcar 'vlax-release-object (list meth1 meth2 wmi))
  result
)

 

Abbas

Message 11 of 18
hmsilva
in reply to: aqdam1978

Hi Abbas,

glad you got a solution

 

Henrique

EESignature

Message 12 of 18
Alexander.Rivilis
in reply to: hmsilva

What about many years known function:

(defun is64 ()
 (vl-load-com)
 (> (strlen (vl-prin1-to-string (vlax-get-acad-object))) 40)
) 

P.S.: Version of Windows (i.e.. x86 or x64) and version of AutoCAD can be different. For example AutoCAD 2007 x86 can be installed and work on Windows x64 (XP/Vista/Win7). Version of arx-files dependent of AutoCAD version and not of Windows version.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 13 of 18
hmsilva
in reply to: Alexander.Rivilis

Alexander.Rivilis wrote:
What about many years known function:
...

Alexander. thank you, "many years known function"
but I did not know ...

 

Henrique

EESignature

Message 14 of 18
Alexander.Rivilis
in reply to: hmsilva


Alexander. thank you, "many years known function"

but I did not know ...


This is because you do not use Search. Smiley Wink

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 15 of 18
hmsilva
in reply to: Alexander.Rivilis

Alexander.Rivilis wrote:
This is because you do not use Search.
...

not correct, I often use "search" is a very good tool and is my first choice... Smiley Wink

Henrique

EESignature

Message 16 of 18

what is you opinion about reading from registry?

 

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE

 

Message 17 of 18
owenwengerd
in reply to: aqdam1978

Inspecting (getvar "PLATFORM") will not work, as you have found. You must use (getenv "PROCESSOR_ARCHITECTURE") for inspecting the architecture of the running AutoCAD. See ISX64.LSP here:

http://www.manusoft.com/software/freebies/lisp.html

--
Owen Wengerd
ManuSoft
Message 18 of 18


@aqdam1978 wrote:

what is you opinion about reading from registry?

 

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE

 


PROCESSOR_ARCHITECTURE allow check Windows architecture (x86/x64) but not a AutoCAD architecture. As I wrote above this is not the same thing.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost