- UID
- 18608
- 积分
- 2508
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-12-4
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 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.
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.
|
|