Follow Us
Contribute
  • Register
Errorbase is a collaborative writing project, that aims to build the largest trouble-shooting guide about all kinds of error messages.

Categories

0 votes
One of the identifiers in your type library is not a valid C++ identifier. The type library is not available for use with #import.
requested by (170k points)
edited by

1 Solution

0 votes
#pragma once #ifdef LOGGER_EXPORTS #define LOGGERAPI __declspec(dllexport) #else #define LOGGERAPI __declspec(dllimport) #endif typedef enum LoggerType { LOGGER_SUCCESS, //Success Message LOGGER_FAILED, //Failed Message LOGGER_DEBUG, //Debugging Message LOGGER_WARNING, //Warning Message LOGGER_MESSAGE, //Message }; class ILogger { public: //virtual void getLogging(const char* logName)=0; virtual void WriteMsg(const std::string &Message )=0; virtual void FileSize(long lsize)=0 /*virtual void Warning(const std::string &war_message)=0; virtual void Error(const std::string &Err_message)=0; virtual void Debug(const std::string &dbg_message)=0;*/ virtual ~ILogger(){}; } LOGGERAPI ILogger* __stdcall CreateLogger(); LOGGERAPI void __stdcall ReleaseLogger(ILogger* Logger); ///////////////////////////////////////////////////////////////////////////////////////////////////////// //#include #include "LogInterFace.h" #ifndef MAX_STRING_LENGTH # define MAX_STRING_LENGTH 8192 #endif class Logger :public ILogger { private: std::string m_strFileName; HANDLE m_file; long m_lBufSize; PUCHAR m_pBuffer; long m_lBufPos; public: Logger(const std::string &FileName, long lSize = MAX_STRING_LENGTH )throw ( std::string ); ~Logger() virtual void getLogging(char* logName); virtual void WriteMsg(const std::string& Message); virtual void fileSize(long lsize); virtual void Warning(const string &war_message); virtual void Error(const string &Err_message); virtual void Debug(const string &dbg_message); // // }; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "Log.h" Logger::Logger( const std::string &FileName, long lSize ) : m_lBufSize( lSize ), m_lBufPos( 0 ) { m_file = CreateFile( FileName.c_str(), GENERIC_WRITE | SYNCHRONIZE, FILE_SHARE_WRITE | FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH, NULL ); if( m_file == INVALID_HANDLE_VALUE ) throw std::string( "Error Opening file" ); m_pBuffer = new UCHAR[m_lBufSize]; } Logger::~Logger( ) { if( m_file != INVALID_HANDLE_VALUE ) CloseHandle( m_file ); delete []m_pBuffer; } void Logger::WriteMsg(const std::string &Message) { DWORD tmpWrite = 0; long strLen = Message.length(); if( strLen >= m_lBufSize ) return WriteFile( m_file, Message.c_str(), strLen, &tmpWrite, NULL ); if( strLen+m_lBufPos >= m_lBufSize ) { //FlushData(); return WriteFile( m_file, Message.c_str(), strLen, &tmpWrite, NULL ); } memcpy( m_pBuffer + m_lBufPos, Message.c_str(), strLen ); m_lBufPos += strLen; return 0; } void Logger::fileSize(long lsize) { DWORD tmpWrite = 0; if( m_lBufPos > 0 ) WriteFile( m_file, m_pBuffer, m_lBufPos, &tmpWrite, NULL ); FlushFileBuffers( m_file ); m_lBufPos = 0; if( lSize == m_lBufSize ) return 0; delete []m_pBuffer; m_pBuffer = new UCHAR[ m_lBufSize = lSize ]; return 0; } //void Logger::Debug(const string &dbg_message) //{ // //} //void Logger::Error(const string &Err_message) //{ // //} //void Logger::Warning(const string &war_message) //{ // //} /***************************************************************************/ int main() { return 0; }
solved by
...