Old fashion design for PC-104
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
1.9 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 05/11/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: LgReportSetupSettings.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of LgReportSetupSettings.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "LgReportSetupSettings.h"
  16. #ifdef _DEBUG
  17. #undef THIS_FILE
  18. static char THIS_FILE[]=__FILE__;
  19. #define new DEBUG_NEW
  20. #endif
  21. CLgReportSettings::CLgReportSettings()
  22. {
  23. m_Settings.bAccessEnable = FALSE;
  24. m_Settings.wAccessPort = 3000;
  25. _tcsncpy( m_Settings.pAccessName, _T("Local"), MAX_PATH );
  26. }
  27. BOOL CLgReportSettings::Load( LPCTSTR pFileName )
  28. {
  29. // delete old contents
  30. RemoveAll();
  31. FILE *pFile = _tfopen( pFileName, _T("rb") );
  32. if( !pFile )
  33. return FALSE;
  34. if( fread( &m_Settings, 1, sizeof(m_Settings), pFile ) != sizeof(m_Settings) )
  35. {
  36. fclose( pFile );
  37. return FALSE;
  38. }
  39. INT nCount = 0;
  40. if( fread( &nCount, 1, sizeof(INT), pFile ) != sizeof(INT) )
  41. {
  42. fclose( pFile );
  43. return FALSE;
  44. }
  45. for( INT i = 0; i < nCount; i++ )
  46. {
  47. CLgReportSiteInfo si;
  48. if( fread( &si, 1, sizeof(CLgReportSiteInfo), pFile ) != sizeof(CLgReportSiteInfo) )
  49. {
  50. fclose( pFile );
  51. return FALSE;
  52. }
  53. Add( si );
  54. }
  55. fclose( pFile );
  56. return TRUE;
  57. }
  58. BOOL CLgReportSettings::Store( LPCTSTR pFileName )
  59. {
  60. FILE *pFile = _tfopen( pFileName, _T("wb") );
  61. if( !pFile )
  62. return FALSE;
  63. fwrite( &m_Settings, 1, sizeof(m_Settings), pFile );
  64. INT nCount = GetCount();
  65. fwrite( &nCount, 1, sizeof(INT), pFile );
  66. for( INT i = 0; i < nCount; i++ )
  67. fwrite( &GetAt(i), 1, sizeof(CLgReportSiteInfo), pFile );
  68. fclose( pFile );
  69. return TRUE;
  70. }