home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / fonts / cw_src / altexe / init.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-19  |  2.2 KB  |  92 lines

  1. #define        no_Protect_
  2. #define        no_DEMO_
  3. #define        NOVIRTUALKEYCODES
  4. #include    "c:\windev\include\windows.h"
  5. #include    "hello.h"
  6.  
  7. extern char    szAppName[];
  8. long FAR PASCAL HelloWndProc();
  9. void FAR PASCAL LTable(LPSTR);
  10.  
  11. #define        KTABLESIZE    (72*4)
  12. extern char     kTable[];
  13. extern char    l_name[13];
  14. extern char    de[];
  15. extern    int legal_use;
  16. extern    int Chk (void);
  17.  
  18. extern    int nSwitch;
  19. extern    int CurrentFont;
  20.  
  21. char    szSwitch[]= "switch";
  22. char    szFont[]= "font";
  23.  
  24. init        (hInstance)
  25. HANDLE        hInstance;
  26. {
  27.     WNDCLASS    WndClass;
  28.     short        flabel;
  29.     char        s_name[132];
  30.     char        section[10];
  31.     char        deftable[13];
  32.  
  33.     GetWindowsDirectory (s_name, sizeof s_name);
  34. #ifdef    _Protect_
  35.     if (GetDriveType (s_name [0]- ('A'+ 1)) != DRIVE_REMOTE)
  36.         {
  37.         legal_use= Chk ();
  38.         }
  39. //    else
  40. //        {
  41. //        legal_use= TRUE;
  42. //        }
  43. #else
  44.     legal_use = TRUE;
  45. #endif
  46.  
  47. #ifdef    _DEMO_
  48.     legal_use = FALSE;
  49. #endif
  50.  
  51.     LoadString(hInstance, ERR_SECTION, section, sizeof section);
  52.     LoadString(hInstance, ERR_DEFTABLE, deftable, sizeof deftable);
  53.  
  54.     if (GetProfileString(szAppName, section, deftable, l_name, 13) != 13) {
  55.         WriteProfileString(szAppName, section, deftable);
  56.     }
  57.  
  58.     AddExt(l_name, de);
  59.  
  60.     flabel= GetWindowsDirectory(s_name, sizeof s_name);
  61.     if (s_name[flabel] != '\\') { s_name[flabel]= '\\'; s_name[flabel+1]= '\0'; }
  62.     lstrcat(s_name, l_name);
  63.     if ((flabel= _lopen(s_name, OF_READ)) < 0) {
  64.         _lclose(_lcreat(s_name, 0));
  65.         flabel= _lopen(s_name, OF_WRITE);
  66.         _lwrite(flabel, kTable, KTABLESIZE);
  67.     }    else {
  68.         _lread(flabel, kTable, KTABLESIZE);
  69.     }
  70.     _lclose(flabel);
  71.     LTable(kTable);
  72.  
  73.     nSwitch= (GetProfileInt (szAppName, szSwitch, 1)); nSwitch--;
  74.     CurrentFont= (GetProfileInt (szAppName, szFont, 1)); CurrentFont--;
  75.  
  76.         WndClass.hCursor       = LoadCursor (NULL, IDC_ARROW);
  77.         WndClass.hIcon         = NULL;
  78.         WndClass.cbClsExtra    = 0;
  79.         WndClass.cbWndExtra    = 0;
  80.         WndClass.lpszMenuName  = NULL;
  81.         WndClass.lpszClassName = (LPSTR) szAppName;
  82.         WndClass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
  83.         WndClass.hInstance     = hInstance;
  84.         WndClass.style         = NULL;
  85.         WndClass.lpfnWndProc   = HelloWndProc;
  86.  
  87.         if (!RegisterClass ((LPWNDCLASS) &WndClass)) {
  88.                return FALSE;
  89.         }
  90.         return TRUE;
  91. }
  92.