Visual LISP, AutoLISP and General Customization

Reply
Mentor
aqdam1978
Posts: 265
Registered: ‎11-05-2008
Message 1 of 18 (460 Views)
Accepted Solution

Windows is 32 or 64?

460 Views, 17 Replies
02-03-2013 12:49 PM

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,

 

 

*Expert Elite*
hmsilva
Posts: 2,700
Registered: ‎12-17-2004
Message 2 of 18 (456 Views)

Re: Windows is 32 or 64?

02-03-2013 01:06 PM in reply to: aqdam1978

aqdam1978

try

 

(getvar "PLATFORM")

 

Henrique

*Expert Elite*
hmsilva
Posts: 2,700
Registered: ‎12-17-2004
Message 3 of 18 (448 Views)

Re: Windows is 32 or 64?

02-03-2013 01:40 PM 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

Mentor
aqdam1978
Posts: 265
Registered: ‎11-05-2008
Message 4 of 18 (445 Views)

Re: Windows is 32 or 64?

02-03-2013 01:58 PM 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

 

*Expert Elite*
hmsilva
Posts: 2,700
Registered: ‎12-17-2004
Message 5 of 18 (442 Views)

Re: Windows is 32 or 64?

02-03-2013 02:03 PM in reply to: aqdam1978

You're welcome, aqdam1978
glad you got a solution

 

Henrique

*Expert Elite*
hmsilva
Posts: 2,700
Registered: ‎12-17-2004
Message 6 of 18 (434 Views)

Re: Windows is 32 or 64?

02-03-2013 02:56 PM 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

Mentor
aqdam1978
Posts: 265
Registered: ‎11-05-2008
Message 7 of 18 (429 Views)

Re: Windows is 32 or 64?

02-03-2013 04:56 PM 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

 

 

*Expert Elite*
hmsilva
Posts: 2,700
Registered: ‎12-17-2004
Message 8 of 18 (402 Views)

Re: Windows is 32 or 64?

02-04-2013 01:07 AM in reply to: aqdam1978

Glad I could help

 

Henrique

*Expert Elite*
dgorsman
Posts: 5,134
Registered: ‎10-12-2006
Message 9 of 18 (390 Views)

Re: Windows is 32 or 64?

02-04-2013 07:32 AM 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.
Adopt. Adapt. Overcome. Or be overcome.
A good question will be halfway to a good answer.


Mentor
aqdam1978
Posts: 265
Registered: ‎11-05-2008
Message 10 of 18 (354 Views)

Re: Windows is 32 or 64?

02-17-2013 02:14 PM 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community