• <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)

            搜索

            •  

            積分與排名

            • 積分 - 175917
            • 排名 - 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 閱讀(4316) 評論(0)  編輯 收藏 引用 所屬分類: MFC
            国产成人综合久久综合| 亚洲伊人久久精品影院| 久久天天躁狠狠躁夜夜avapp| 丁香色欲久久久久久综合网| 久久婷婷国产综合精品| 久久线看观看精品香蕉国产| 国产精品午夜久久| 无码人妻久久一区二区三区蜜桃| 久久99久国产麻精品66| 欧美日韩中文字幕久久伊人| 久久久久久久久久久免费精品| 99久久国产亚洲综合精品| 精品国产乱码久久久久久郑州公司| 99久久精品国产一区二区蜜芽| 思思久久好好热精品国产| 青青草原1769久久免费播放| 一本久道久久综合狠狠躁AV| 久久中文娱乐网| 97精品伊人久久久大香线蕉| 国产激情久久久久影院| 久久精品中文字幕无码绿巨人 | 亚洲国产成人久久综合一区77| 99久久做夜夜爱天天做精品| 久久福利片| 久久久久夜夜夜精品国产| 一本久久a久久精品亚洲| 欧美与黑人午夜性猛交久久久| 久久亚洲AV成人无码国产| 国产精品99久久久精品无码| 色诱久久av| 久久精品国产亚洲Aⅴ蜜臀色欲| 久久99国产精一区二区三区| 色欲综合久久中文字幕网| 伊人色综合九久久天天蜜桃| 久久国产香蕉一区精品| 99久久国产综合精品网成人影院 | 亚洲精品无码久久久| 97久久精品人人做人人爽| 青青青国产精品国产精品久久久久| 99国产欧美精品久久久蜜芽| 久久亚洲精精品中文字幕|