zoukankan      html  css  js  c++  java
  • dll,lib及引用源码


    Lib库

    LibA.h

    #pragma once
    class LibA
    {
    public:
    	LibA(void);
    	~LibA(void);
    	void show();
    };

    LibA.cpp

    #include "StdAfx.h"
    #include "LibA.h"
    #include <iostream>
    using namespace std;
    
    LibA::LibA(void)
    {
    }
    
    LibA::~LibA(void)
    {
    }
    
    void LibA::show()
    {
    	cout<<"LibA show"<<endl;
    }


    DLL库(静态引用)

    dll.h

    #ifndef _DLL_H_
    #define _DLL_H_
    
    #ifdef BUILDING_DLL
    # define DLLIMPORT __declspec (dllexport)
    #else /* Not BUILDING_DLL */
    # define DLLIMPORT __declspec (dllimport)
    #endif /* Not BUILDING_DLL */
    
    DLLIMPORT void FuncA(void);
    
    class DLLIMPORT DllClass
    {
    public:
    	DllClass();
    	virtual ~DllClass(void);
    	void show();
    private:
    
    };
    #endif /* _DLL_H_ */



    dllmain.cpp

    # define BUILDING_DLL
    #include "dll.h"
    #include <windows.h>
    #include <iostream>
    using namespace std;
    
    
    
    DllClass::DllClass()
    {
    
    }
    
    
    DllClass::~DllClass ()
    {
    
    }
    void DllClass::show()
    {
    	cout<<" Class DLLClass show"<<endl;
    }
    
    DLLIMPORT void FuncA(void)
    {
    	cout<<"FuncA show"<<endl;
    }
    
    BOOL APIENTRY DllMain (HINSTANCE hInst     /* Library instance handle. */ ,
    	DWORD reason        /* Reason this function is being called. */ ,
    	LPVOID reserved     /* Not used. */ )
    {
    	switch (reason)
    	{
    	case DLL_PROCESS_ATTACH:
    		break;
    
    	case DLL_PROCESS_DETACH:
    		break;
    
    	case DLL_THREAD_ATTACH:
    		break;
    
    	case DLL_THREAD_DETACH:
    		break;
    	}
    
    	/* Returns TRUE on success, FALSE on failure */
    	return TRUE;
    }


    控制台引用代码

    Tmain.cpp

    #include "stdafx.h"
    #include "LibA.h"
    #include "dll.h"
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	LibA liba;
    	liba.show();
    
    	DllClass dll;
    	dll.show();
    	
    	FuncA();
    
    	return 0;
    }


  • 相关阅读:
    1349:【例4-10】最优布线问题
    1348:【例4-9】城市公交网建设问题
    P2024 [NOI2001]食物链
    $P2573 [SCOI2012]滑雪$
    $P1991 无线通讯网$
    $P2872 [USACO07DEC]道路建设Building Roads$
    $P1547 Out of Hay$
    hdu 3468 Treasure Hunting
    hungary HK 多重匹配
    Hdu匹配题集
  • 原文地址:https://www.cnblogs.com/nafio/p/9137711.html
Copyright © 2011-2022 走看看