⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dllsampleexplicit.cpp

📁 BCAM 1394 Driver
💻 CPP
字号:
//-----------------------------------------------------------------------------
//  (c) 2002 by Basler Vision Technologies
//  Section:  Vision Components
//  Project:  BCAM
//  $Header: DllSampleExplicit.cpp, 2, 07.01.2003 16:58:22, Happe, A.$
//-----------------------------------------------------------------------------
/**
  \file     DllSampleExplicit.cpp
  \brief    Console application using the BcamApiSampleDll (explicit linkage)

  This console application demonstrates explicit linking against a dynamic library using the Bcam high level interface.
  Before unloading the dll, the clean up code provided by the BcamApi will be processed by calling the dll's 
  PrepareUnloadProc() function. 
  
  In general it is highly recommended to invoke the CBcam::CleanUp() method before unloading
  a dll using the Bcam API.

*/
#include "stdafx.h"
#include "BcamApiSampleDll.h"


#ifdef _DEBUG
#define LIBNAME "..\\..\\lib\\BcamApiSampleDlld.dll"
#else
#define LIBNAME "..\\..\\lib\\BcamApiSampleDll.dll"
#endif

int _tmain(int argc, _TCHAR* argv[])
{
  typedef void (*TestProc)();
  typedef BOOL (*PrepareUnloadProc)();

  HMODULE hInst;   // handle to the library

  // load the dll
  hInst = LoadLibrary(LIBNAME);

  if ( hInst != NULL )
  {
    // get pointer to the exported functions
    TestProc Test = ( TestProc) GetProcAddress(hInst, "Test");
    if ( Test == NULL )
    {
      fprintf(stderr, "Could not retrieve pointer to exported function Test()");
    }
    else
    {
      // call the Test() function
      Test();
    }

    PrepareUnloadProc PrepareUnload = (PrepareUnloadProc) GetProcAddress(hInst, "PrepareUnload");
    if ( PrepareUnload == NULL )
    {
      fprintf(stderr, "Could not retrieve pointer to exported function PrepareUnload()");
    }
    else
    {
      // Before unloading the dll do the clean up
      BOOL res = PrepareUnload();
      if ( ! res )
      {
        fprintf(stderr, "Call to PrepareUnloadProc() failed. GetLastError() = %d\n", GetLastError());
      }
    } 

    // Now unload the dll
    if ( ! FreeLibrary(hInst) )
    {
      fprintf(stderr, "Unloading dll failed. GetLastError() = %d\n", GetLastError());
    }
  }
  else
  {
    fprintf(stderr, "Cannot load library %s\n", LIBNAME);
  }

  return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -