• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Welcome to ErranLi's Blog!

              C++博客 :: 首頁 :: 聯系 :: 聚合  :: 管理
              106 Posts :: 1 Stories :: 97 Comments :: 0 Trackbacks

            常用鏈接

            留言簿(12)

            搜索

            •  

            積分與排名

            • 積分 - 174947
            • 排名 - 151

            最新評論

            閱讀排行榜


            __declspec(dllexport)與.def文件


            在VC++中,如果生成DLL可以不使用.def文件。只需要在VC++的函數定義前要加__declspec(dllexport)修飾就可以了。但是使用__declspec(dllexport)和使用.def文件是有區別的。如果DLL是提供給VC++用戶使用的,只需要把編譯DLL時產生的.lib提供給用戶,它可以很輕松地調用你的DLL。但是如果DLL是供VB、PB、Delphi用戶使用的,那么會產生一個小麻煩。因為VC++對于__declspec(dllexport)聲明的函數會進行名稱轉換,如下面的函數:
                __declspec(dllexport) int __stdcall IsWinNT()
                會轉換為IsWinNT@0,這樣你在VB中必須這樣聲明:
                Declare Function IsWinNT Lib "my.dll" Alias "IsWinNT@0" () As Long
                @的后面的數由于參數類型不同而可能不同。這顯然不太方便。所以如果要想避免這種轉換,就要使用.def文件方式。
                EXPORTS后面的數可以不給,系統會自動分配一個數。對于VB、PB、Delphi用戶,通常使用按名稱進行調用的方式,這個數關系不大,但是對于使用.lib鏈接的VC程序來說,不是按名稱進行調用,而是按照這個數進行調用的,所以最好給出。如:
            EXPORTS 
            test @1 

              vc的dll,delphi調用的方法:

            ////K9RtExpr.h
            extern "C" __DECDLL
            unsigned int _stdcall K9RtSysInterrupt(int nInterruptTag);

            extern "C" __DECDLL
            unsigned int _stdcall K9RtSysExprm(unsigned int nModuleTag,
                       float fTimeout,  
                       void * pTestPar, 
                       void * pResultPar 
                       );

            // K9RtExpr.cpp
            #include "K9RtExpr.h"
            #include "RtCtrl.h"
            extern "C" __DECDLL
            unsigned int _stdcall K9RtSysInterrupt(int nInterruptTag)
            {
             return CRelayTestControl::Instance()->InterruptTest(nInterruptTag);
            }
            extern "C" __DECDLL
            unsigned int _stdcall K9RtSysExprm(unsigned int nModuleTag,
                       float fTimeout,   
                       void * pTestPar, 
                       void * pResultPar 
                       )
            {
             return CRelayTestControl::Instance()->RelayTest(
                  nModuleTag, fTimeout, pTestPar, pResultPar);
            }

            ///K9RtExpr.def
            LIBRARY      "K9RtExpr"
            DESCRIPTION  K9RtExpr Windows Dynamic Link Library'

            EXPORTS
            K9RtSysInterrupt
            K9RtSysExprm
                ; Explicit exports can go here


            //delphi   調用文件
            unit InterfaceFunc;

            interface

            uses
               UnitData,Types;
              
            function K9RtSysExprm(nModuleTag:integer  ;
                                    uTimeout:integer;
                                    pTestPar:Pointer;
                                    pResultPar:Pointer) : Integer; stdcall;

            function K9RtSysInterrupt(nInterruptType:Integer) : Integer; stdcall;

            implementation
            const DLLPATH  = 'RtBsExpr.dll';
            function K9RtSysExprm; external DLLPATH  name  'ExperimentRelayTest';
            function K9RtSysInterrupt; external DLLPATH  name 'InterruptRelayTest';

            end.

            posted on 2007-10-13 17:01 erran 閱讀(4309) 評論(0)  編輯 收藏 引用 所屬分類: MFC
            亚洲欧美日韩精品久久亚洲区 | 久久超乳爆乳中文字幕| 亚洲日韩中文无码久久| 午夜精品久久久久久毛片| 久久99热只有频精品8| 久久国产精品99久久久久久老狼 | 久久国产热精品波多野结衣AV| 国内精品伊人久久久久AV影院| 伊人热人久久中文字幕| 久久中文字幕人妻熟av女| 久久99精品综合国产首页| 麻豆精品久久精品色综合| 香蕉久久永久视频| 亚洲欧美伊人久久综合一区二区| 久久国产乱子精品免费女| 久久伊人五月丁香狠狠色| yellow中文字幕久久网| 久久综合香蕉国产蜜臀AV| 久久国产成人午夜aⅴ影院 | 国产91色综合久久免费分享| 久久人人爽人人爽人人av东京热 | 人人狠狠综合久久88成人| 蜜臀久久99精品久久久久久| 久久精品国产一区| 久久精品国产亚洲AV麻豆网站| 久久久久久久久66精品片| 久久91这里精品国产2020| 久久久一本精品99久久精品66| 777久久精品一区二区三区无码| 一本一本久久a久久综合精品蜜桃| 日批日出水久久亚洲精品tv| 精品99久久aaa一级毛片| 久久国产精品99久久久久久老狼| 99久久精品免费看国产一区二区三区| 久久精品99无色码中文字幕| 久久久久久久99精品免费观看| 亚洲va中文字幕无码久久| 久久久久久国产a免费观看黄色大片 | 亚洲女久久久噜噜噜熟女| 久久久久亚洲av成人网人人软件| 亚洲AV伊人久久青青草原|