- UID
- 17409
- 积分
- 183
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-11-27
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
1. Create a dll in MS Dev studio just as you normally would. Make sure that
all your exported functions are declared as extern "C", this will prevent
name mangling. In your MDL modules you will need to include function
prototypes for the dll functions. They should be defined as nativeCode.
i.e. nativeCode int catdll_MTOAddComp ( void );
2. Create a dls (dynamic link specification) file in your mdl project. This
file helps the mdl linker resolve imported functions. Here is an example:
catdll.dls:
%Version 0x551
%ModuleName catdll
%Functions
catdll_MTOAddComp ( _catdll_MTOAddComp )
catdll_MTOEnd ( _catdll_MTOEnd )
%EndFunctions
%Variables
%EndVariables
%End
As you can see this file imports two functions from a dll called catdll.dll.
Take note of the _ preceding the function name inside the parentheses. This
is because the project settings (in C++ Builder) for this particular dll has
"Calling Convention" set to "C". If it were set to "Standard Call" then the _
preceding the function name would not be necessary. i.e.
catdll_MTOAddComp ( catdll_MTOAddComp )
3. You must compile the dls file into a dlo file, this is done in your mdl
project make file, the line would look like this:
#---------------------------------------------
# Compile the Dynamic Load Specification
#---------------------------------------------
$(mdlLibs)catdll.dlo : $(baseDir)catdll.dls
4. Link the dlo file with your other object files, you can do this by simply
adding the dlo to the list of project object files in your make file. Like
this:
#----------------------------------------------------------------------
# Define macros for files included in our link and resource merge
#----------------------------------------------------------------------
isoskObjs = \
$(o)isosk.mo \
$(o)mto.mo \
$(o)symconfg.mo \
$(mdlLibs)catdll.dlo \
$(mdlLibs)pwvar.dlo \
$(mdlLibs)liclib.dlo \
$(mdlLibs)bitwyse.dlo
For more information on dlm's see the "Advanced Concepts" section (chapter
20) of the MDL Programmers Guide (go to the table of contents in the on-line
help, also, be sure you are looking at the MDE help file and not the general
MicroStation help file).
Thats it, DLM's in 4 steps.
--------------------------------------------------------------------------------------------------------------------
我按上述步骤测试了一下,编译没有问题
但是进入MS载入ma是提示如下:
Unable to resolve ******* from lib kernel32 for '*****'
可是我已经把kernel32.dll文件复制到我的ma文件目录了
而且我所调用的API在VB中试过使用没有任何问题
而且还没有进入ma的debug界面就出现此错误了,再次调入ma,MS的错误信息窗口就关闭了,除非重启MS就再也无法进入这个界面了
那位大侠帮帮忙? |
|