找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1527|回复: 1

[分享] Demand Loading a LISP File

[复制链接]
发表于 2013-8-18 22:38:08 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
本帖最后由 Free-Lancer 于 2013-8-18 22:39 编辑

Demand Loading a LISP File                                                                              

The registry demand loading feature in AutoCAD and Bricscad is a great method for loading ObjectARX and BRX modules automatically at startup, and it's relatively easy to create the demand loading settings from an installation program or MSI file at install time. Unfortunately it only works for ARX or BRX files (and also with .NET dlls in AutoCAD 2006 and later). Some years ago, I created a small ObjectARX module called VLXLoad. The purpose of this module was to work as a stub to load an associated .vlx file of the same base name in the same folder. I've since renamed this small utility to LspLoad and expanded it so that it can load any type of LISP file. The idea is to rename the LspLoad.*.* file to the name of the associated .lsp/.vlx/.fas file (i.e. MyApp.18.arx will look for and load MyApp.vlx in the same directory), then create demand load registry settings to load the renamed LspLoad module. Voila, the associated LISP file gets loaded as if it was being demand loaded from the registry.
The LspLoad source code demonstrates an important technique that I often see questions about in Autodesk's ObjectARX discussion group: how to get the full path to the ARX file from code within the file. The secret is to use the Windows API function GetModuleFileName(), passing as its first argument the current module instance handle, which is available in an ObjectARX module as _hdllInstance (note that it's _hd, two lower case L's, then followed by an upper case I for Instance).
I've uploaded here the complete source code along with a solution file for Visual Studio 2010. The solution requires environment variables defined as described here. You'll need to have Daffodil for Visual Studio installed, and you'll need the target version of Visual Studio installed to build the various projects targeting different platforms. If you just want the fully built modules, download the latest versions from my Freebies page.
Download: LspLoadSource.zip (28k)
Version 3.4 uploaded 2012-10-30
If you look at the source code, you'll notice that these modules define a lisp callable function named (GetPathOf<basefilename>) that returns the directory from where the LspLoad module loaded. This also demonstrates another technique: defining an ADS (Lisp callable) function by "calculating" the function name at runtime.

论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-9-24 12:22 , Processed in 0.164330 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表