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

📄 ltkwindowsutil.cpp

📁 An open source handwriting recongnition package!!!
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************
* Copyright (c) 2007 Hewlett-Packard Development Company, L.P.
* Permission is hereby granted, free of charge, to any person obtaining a copy 
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights 
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
* copies of the Software, and to permit persons to whom the Software is 
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or 
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
* SOFTWARE
******************************************************************************/
/************************************************************************
 * SVN MACROS
 *
 * $LastChangedDate: 2008-08-12 13:07:58 +0530 (Tue, 12 Aug 2008) $
 * $Revision: 607 $
 * $Author: sharmnid $
 *
 ************************************************************************/
/************************************************************************
 * FILE DESCR: 
 *
 * CONTENTS: 
 *
 * AUTHOR:     Nidhi Sharma
 *
 * DATE:       May 29, 2004
 * CHANGE HISTORY:
 * Author		Date			Description of change
 ************************************************************************/

#include "LTKWindowsUtil.h"
#include "LTKMacros.h"
#include "LTKLoggerUtil.h"

#include <windows.h>

/************************************************************************
 * AUTHOR		: Nidhi Sharma
 * DATE			: 29-05-2008
 * NAME			: LTKWindowsUtil
 * DESCRIPTION	: Default constructor		
 * ARGUMENTS      : 
 *
 * RETURNS		: 
 * NOTES			: 
 * CHANGE HISTROY
 * Author			Date				Description
 *****************************************************************************/
LTKWindowsUtil::LTKWindowsUtil()
{
    
}

/**************************************************************************
 * AUTHOR		: Nidhi Sharma
 * DATE			: 29-05-2008
 * NAME			: ~LTKWindowsUtil
 * DESCRIPTION	: Desstructor		
 * ARGUMENTS      : 
 *
 * RETURNS		: 
 * NOTES			: 
 * CHANGE HISTROY
 * Author			Date				Description
 ***************************************************************************/
LTKWindowsUtil::~LTKWindowsUtil()
{
    
}

/**************************************************************************
 * AUTHOR		: Nidhi Sharma
 * DATE			: 29-05-2008
 * NAME			: loadSharedLib
 * DESCRIPTION	: Loads dynamic library		
 * ARGUMENTS      : 
 *
 * RETURNS		: 
 * NOTES			: 
 * CHANGE HISTROY
 * Author			Date				Description
 ***************************************************************************/
int LTKWindowsUtil::loadSharedLib(const string & lipiRoot, 
                                 const string & sharedLibName, 
                                 void * * libHandle)
{    
    string sharedLibraryPath = "";
    
	//	construct the path for the recogniser DLL
    sharedLibraryPath = lipiRoot + "\\" + "lib" + "\\" + sharedLibName + ".dll";

    // Load the DLL
	*libHandle = (void*)LoadLibrary(sharedLibraryPath.c_str());

	if(*libHandle == NULL)
	{ 
		cout << GetLastError() << endl;
		return FAILURE; 
	}
    
    return SUCCESS;
}

/**************************************************************************
 * AUTHOR		: Nidhi Sharma
 * DATE			: 29-05-2008
 * NAME			: loadSharedLib
 * DESCRIPTION	: Loads dynamic library		
 * ARGUMENTS      : 
 *
 * RETURNS		: 
 * NOTES			: 
 * CHANGE HISTROY
 * Author			Date				Description
 ***************************************************************************/
int LTKWindowsUtil::unloadSharedLib(void * libHandle)
{
    
    if (libHandle != NULL)
    {
        int returnVal = FreeLibrary((HINSTANCE)(libHandle));

        // For FreeLibrary, If the function fails, the return value is zero
        if (returnVal == 0 )
        {            
            return FAILURE;
        }
    }
    else
    {
       
        return FAILURE;
    }

    return SUCCESS;
}

/**************************************************************************
 * AUTHOR		: Nidhi Sharma
 * DATE			: 29-05-2008
 * NAME			: getFunctionAddress
 * DESCRIPTION	: 
 * ARGUMENTS      : 
 *
 * RETURNS		: 
 * NOTES			: 
 * CHANGE HISTROY
 * Author			Date				Description
 ***************************************************************************/
int LTKWindowsUtil::getFunctionAddress(void * libHandle,
                                             const string& functionName,
                                             void** functionHandle)
{

    // validate parameters
    if (libHandle == NULL )
    {
        return FAILURE;
    }

    if (functionName.empty())
    {
        return FAILURE;
    }
    
    *functionHandle = GetProcAddress((HMODULE)libHandle, functionName.c_str());

    if ( *functionHandle == NULL )
    {
        return FAILURE;
    }

    return SUCCESS;
}

/**************************************************************************
 * AUTHOR		: Nidhi Sharma
 * DATE			: 26-06-2008
 * NAME			: getPlatformName
 * DESCRIPTION	: 
 * ARGUMENTS      : 
 *
 * RETURNS		: 
 * NOTES			: 
 * CHANGE HISTROY
 * Author			Date				Description
 ***************************************************************************/
int LTKWindowsUtil::getPlatformName(string& outStr)
{
    outStr = "Windows";
    return SUCCESS;

}

/**************************************************************************
 * AUTHOR		: Nidhi Sharma
 * DATE			: 26-06-2008
 * NAME			: getProcessorArchitechure
 * DESCRIPTION	: 
 * ARGUMENTS      : 
 *
 * RETURNS		: 
 * NOTES			: 
 * CHANGE HISTROY
 * Author			Date				Description
 ***************************************************************************/
int LTKWindowsUtil::getProcessorArchitechure(string& outStr)
{
    SYSTEM_INFO architechure;

    GetSystemInfo(&architechure);

    int arc = architechure.wProcessorArchitecture;

    switch (arc)
    {
        case 0 : outStr = "INTEL";
                 break;

        case 1 : outStr = "MIPS";
                 break;

        case 2 : outStr = "ALPHA";
                 break;

        case 3 : outStr = "PPC";
                 break;

        case 4 : outStr = "SHX";
                 break;

        case 5 : outStr = "ARM";
                 break;

        case 6 : outStr = "IA64";
                 break;

        case 7 : outStr = "ALPHA64";
                 break;

        default : outStr = "UNKNOWN";
                 break;
    }
        
    return SUCCESS;

}

/**************************************************************************
 * AUTHOR		: Nidhi Sharma
 * DATE			: 26-06-2008
 * NAME			: getOSInfo
 * DESCRIPTION	: 
 * ARGUMENTS      : 
 *
 * RETURNS		: 
 * NOTES			: 
 * CHANGE HISTROY
 * Author			Date				Description
 ***************************************************************************/
int LTKWindowsUtil::getOSInfo(string& outStr)
{
   outStr = "";

   OSVERSIONINFOEX osvi;
   BOOL bOsVersionInfoEx;

   ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
   osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

   if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
   {
      osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
      if (! GetVersionEx ((OSVERSIONINFO *) &osvi)) 
         return SUCCESS;
   }

   switch (osvi.dwPlatformId)

⌨️ 快捷键说明

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