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

📄 bcamapisampledll.cpp

📁 BCAM 1394 Driver
💻 CPP
字号:
//-----------------------------------------------------------------------------
//  (c) 2002 by Basler Vision Technologies
//  Section:  Vision Components
//  Project:  BCAM
//  $Header: BcamApiSampleDll.cpp, 2, 07.01.2003 14:37:06, Happe, A.$
//-----------------------------------------------------------------------------
/**
  \file     BcamApiSampleDll.cpp
  \brief    A dll using the Bcam API

  This dynamic link library serves as an example using the Bcam high level interface
  within a dynamic link library. 
  The library exports two functions: 
  * Test() prints the name of the first Bcam device to stdout
  * PrepareUnload() Calls the CBcam::CleanUp() method.
*/

#include "stdafx.h"
#include "BcamApiSampleDll.h"

using namespace Bcam;

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
	switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
	case DLL_PROCESS_DETACH:
    // Do never call CBcam::CleanUp() from DllMain() !! 
		break;
	}
    return TRUE;
}

//------------------------------------------------------------------------------
// void Test()
//------------------------------------------------------------------------------
/**
* 
* \brief Print the name of the first Bcam device.
*
* \return void
*
*/
//------------------------------------------------------------------------------
void Test()
{
  CString result;

  try
  {
    std::list<CString> devices = CBcam::DeviceNames(); 
    if ( devices.size() == 0 )
      result = "<No device connected>";
    else
    {
      CBcam bcam;
      bcam.Open( *devices.begin() );
      result = bcam.Info.ModelName();
    }
  }
  catch ( BcamException &e )
  {
    result.FormatMessage("Exception occured: %d (%s)", e.Error(), e.Description());
  }
  printf("%s\n", (LPCTSTR) result);
}

//------------------------------------------------------------------------------
// BOOL PrepareUnload()
//------------------------------------------------------------------------------
/**
* 
* \brief Perform the clean up operations of the BcamApi. 
* This method should be called before unloading the dll.
* Remember, the Bcam API clean up code must not be called from the dll's DllMain()
* function.
*
* \return TRUE if the function succeeds, FALSE otherwise. Retrieve more information with GetLastError()
*
*/
//------------------------------------------------------------------------------
BOOL PrepareUnload()
{
  BOOL result = TRUE;
  try
  {
    // Invoke the Bcam clean up method 
    CBcam::CleanUp();
  }
  catch ( BcamException& e)
  {
    // an error occured, set the last-error code to the exeption's error number
    SetLastError( e.Error() );
    result = FALSE;
  }
  return result;
}

⌨️ 快捷键说明

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