Changeset 1538


Ignore:
Timestamp:
2000-09-12T11:06:36+12:00 (24 years ago)
Author:
sjboddie
Message:

got 16 bit part compiling on VC++ and gcc

Location:
trunk/gsinstaller
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsinstaller/Makefile

    r1536 r1538  
    33LINK = $(CXX) $(LDFLAGS) -o $@
    44LIBS = -lcomctl32 -lgdi32 -lole32 -lcomdlg32 -luuid
    5 CXXFLAGS = -fvtable-thunks
     5CXXFLAGS = -Wall -fvtable-thunks
    66
    77GSSETUP_OBJS = uninstall.o launchapp.o gsmanifest.o copyprogress.o \
     
    1111               gsprofile.o dirent.o
    1212
    13 all: gssetup.exe
     13SETUP_OBJS = gs16bit.o
     14
     15all: gssetup.exe setup.exe
    1416
    1517gssetup.exe: $(GSSETUP_OBJS)
    1618    $(LINK) $(GSSETUP_OBJS) $(LIBS)
    1719
     20setup.exe: $(SETUP_OBJS)
     21    $(LINK) $(SETUP_OBJS)
     22
    1823$(GSSETUP_OBJS): %.o: %.cpp
     24
     25$(SETUP_OBJS): %.o: %.cpp
    1926
    2027clean:
    2128    del *.o
    2229    del gssetup.exe
     30    del setup.exe
  • trunk/gsinstaller/gs16bit.cpp

    r1397 r1538  
    1313#ifdef _WIN32
    1414int GetWinFlags()
    15 { return 0;
     15{
     16  return 0;
    1617}
    1718#endif
    1819
    19 HWND                app_window;
    20 HINSTANCE   app_instance;
    21 char *  app_cmdLine;
     20HWND app_window;
     21HINSTANCE app_instance;
     22char *app_cmdLine;
    2223
    2324typedef void (* splashfn) (HINSTANCE a, unsigned int time);
     
    2526
    2627typedef struct
    27 {   BYTE    majorVersion;
    28     BYTE    minorVersion;
    29   WORD  buildNumber;
    30   BOOL  debug;
     28{   
     29  BYTE majorVersion;
     30  BYTE minorVersion;
     31  WORD buildNumber;
     32  BOOL debug;
    3133} win32sInfo, FAR * lpWin32sInfo;
    3234
    3335typedef enum
    34 { Windows2x, Windows3_0x, Windows3_1x, Windows9x, WindowsNT
    35 }   gs16PlatformId;
     36{
     37  Windows2x, Windows3_0x, Windows3_1x, Windows9x, WindowsNT
     38} gs16PlatformId;
    3639
    3740typedef struct
    38 {   gs16PlatformId  platform;
    39     bool                        win32s;
    40 }   gs16PlatformInfo;
    41 
    42 typedef int FAR PASCAL (* win32sInfoFn)(lpWin32sInfo);
     41{   
     42  gs16PlatformId platform;
     43  bool win32s;
     44} gs16PlatformInfo;
     45
     46//typedef int FAR PASCAL (* win32sInfoFn)(lpWin32sInfo);
     47typedef int (FAR PASCAL * win32sInfoFn)(lpWin32sInfo);
    4348
    4449bool GS16bit_checkForWin32s()
    45 {   HANDLE              w32sHandle;
    46     win32sInfoFn    infoFnPtr;
    47     win32sInfo      w32sInfo;
    48   bool                  reply = false;
    49 
    50     // try to get a handle onto the win32s library
    51     w32sHandle  = LoadLibrary("W32SYS.DLL");
    52 
    53   if (w32sHandle > HINSTANCE_ERROR)
    54   { // now get the address of the GetWin32sInfo function
    55     infoFnPtr   = (win32sInfoFn) GetProcAddress(w32sHandle, "GETWIN32SINFO");
     50{
     51  //  HANDLE w32sHandle;
     52  HINSTANCE w32sHandle;
     53  win32sInfoFn infoFnPtr;
     54  win32sInfo w32sInfo;
     55  bool reply = false;
     56
     57  // try to get a handle onto the win32s library
     58  w32sHandle = LoadLibrary("W32SYS.DLL");
     59
     60  //  if (w32sHandle > HINSTANCE_ERROR)
     61  if (w32sHandle != NULL)
     62  {
     63    // now get the address of the GetWin32sInfo function
     64    infoFnPtr = (win32sInfoFn) GetProcAddress(w32sHandle, "GETWIN32SINFO");
    5665
    5766    // if the function exists, we've got win32s1.1 or later
    58     if (infoFnPtr != NULL)
    59     { if ((*infoFnPtr)((lpWin32sInfo) &w32sInfo) == 0) // no error state
    60         {   reply   = true;
    61       }
    62       else  // error - call didn't work; assume that we have a non-functional
    63                 // win32s
    64       { reply = false;
    65       }
     67    if (infoFnPtr != NULL)
     68    {
     69      if ((*infoFnPtr)((lpWin32sInfo) &w32sInfo) == 0) // no error state
     70        {
     71      reply = true;
     72    }
     73      else 
     74    // error - call didn't work; assume that we have a non-functional
     75    // win32s
     76    {   
     77      reply = false;
     78    }
    6679    }
    6780    // else we've got win32s 1.0.  TODO: We need to check if it's actually up and
    6881    // running;
    6982    else
    70     {   reply = true;
    71     }
     83      {
     84    reply = true;
     85      }
    7286
    7387    // we need to free the library before finishing this function
     
    7690  // no win32s at all
    7791  else
    78   { reply = false;
     92  {
     93    reply = false;
    7994  }
    8095
     
    8398
    8499void GS16bit_getPlatformInfo(gs16PlatformInfo &info)
    85 {   DWORD version = GetVersion();
     100{
     101  DWORD version = GetVersion();
    86102
    87103  /**
     
    98114  BYTE majorVersion = LOBYTE(LOWORD(version));
    99115  BYTE minorVersion = HIBYTE(LOWORD(version));
    100   BYTE dosVersion       = HIBYTE(HIWORD(version));
     116  BYTE dosVersion = HIBYTE(HIWORD(version));
    101117
    102118  if (majorVersion < 3)
    103   { info.platform   = Windows2x;
    104   }
    105   else if (majorVersion == 3 && minorVersion >= 95) // it's Windows 95 from the
    106                                                                                                     // minor version; I guess that
    107                                                     // 98 may have minor version == 98,
    108                                                     // but I don't know!  Hence the
    109                                                     // cautious check
    110   { info.platform   = Windows9x;
     119  {
     120    info.platform = Windows2x;
     121  }
     122  else if (majorVersion == 3 && minorVersion >= 95)
     123    // it's Windows 95 from the
     124    // minor version; I guess that
     125    // 98 may have minor version == 98,
     126    // but I don't know!  Hence the
     127    // cautious check
     128  {
     129    info.platform = Windows9x;
    111130  }
    112131  else // we're running in "some sort" of Windows 3.x environment
    113   { if (minorVersion == 10 && dosVersion == 5)          // it could be running under WOW
    114                                                         // (16-bit Windows emulation in
    115                                                         //  Windows NT)
    116     {   if ((GetWinFlags() & WF_WINNT) == WF_WINNT)     // check for NT in emulation mode
    117         { info.platform = WindowsNT;
    118       }
    119       else
    120       { info.platform   = Windows3_1x;
    121       }
    122     }
    123     else if (minorVersion >= 10) // perhaps Windows 3.11
    124     {   info.platform = Windows3_1x;
    125     }
     132  {
     133    if (minorVersion == 10 && dosVersion == 5)
     134      // it could be running under WOW
     135      // (16-bit Windows emulation in
     136      //  Windows NT)
     137      {
     138    if ((GetWinFlags() & WF_WINNT) == WF_WINNT) // check for NT in emulation mode
     139      {
     140        info.platform = WindowsNT;
     141      }
     142    else
     143      {
     144        info.platform = Windows3_1x;
     145      }
     146      }
     147    else if (minorVersion >= 10) // perhaps Windows 3.11
     148      {
     149    info.platform = Windows3_1x;
     150      }
    126151    else
    127     { info.platform = Windows3_0x;
    128     }
     152      {
     153    info.platform = Windows3_0x;
     154      }
    129155  }
    130156
    131157  if (info.platform == Windows3_1x)
    132   { info.win32s = GS16bit_checkForWin32s();
    133   }
     158    {
     159      info.win32s = GS16bit_checkForWin32s();
     160    }
    134161  else
    135   { info.win32s = false;
    136   }
     162    {   
     163      info.win32s = false;
     164    }
    137165}
    138166
    139167void GS16bit_checkWindowsVersion()
    140 {   gs16PlatformInfo    platformInfo;
    141 
    142     GS16bit_getPlatformInfo(platformInfo);
     168{   
     169  gs16PlatformInfo platformInfo;
     170
     171  GS16bit_getPlatformInfo(platformInfo);
    143172  if (platformInfo.platform == Windows3_0x ||
    144         platformInfo.platform == Windows2x)
    145   { MessageBox(app_window,
    146                             "Greenstone cannot be installed on this computer.  It requires "
    147                 "Windows 3.10 or later",
    148                 "Greenstone Installer",
    149                 MB_OK);
    150   }
    151   else if ( platformInfo.platform == Windows3_1x &&
    152             platformInfo.win32s == false)
    153   { MessageBox(app_window,
    154                             "Greenstone requires 32 bit Windows.  Win32s will now be installed "
    155                 "on your computer to provide this, before continuing with the main "
    156                 "installation.",
    157                 "Greenstone Installer",
    158                 MB_OK);
    159   }
     173      platformInfo.platform == Windows2x)
     174    {   
     175      MessageBox(app_window,
     176         "Greenstone cannot be installed on this computer.  It requires "
     177         "Windows 3.10 or later",
     178         "Greenstone Installer",
     179         MB_OK);
     180    }
     181  else if (platformInfo.platform == Windows3_1x &&
     182       platformInfo.win32s == false)
     183    {
     184      MessageBox(app_window,
     185         "Greenstone requires 32 bit Windows.  Win32s will now be installed "
     186         "on your computer to provide this, before continuing with the main "
     187         "installation.",
     188         "Greenstone Installer",
     189         MB_OK);
     190    }
    160191  else
    161   { char buffer[20];
    162     int result;
    163 /*      MessageBox(app_window,
    164                             "Greenstone will now install", "Greenstone Installer", MB_OK);*/
    165     result = WinExec("gssetup.exe", SW_SHOWNORMAL);
    166   }
    167 }
    168 
    169 long FAR PASCAL GS16bitWindProc(HWND            Window,
    170                                                                     WORD            Message,
    171                                                                     WPARAM      wParameter,
    172                                                                     LPARAM      lParameter)
    173 { long reply = 0;
     192    {
     193      char buffer[20];
     194      int result;
     195      /*    MessageBox(app_window,
     196        "Greenstone will now install", "Greenstone Installer", MB_OK);*/
     197      result = WinExec("gssetup.exe", SW_SHOWNORMAL);
     198    }
     199}
     200
     201long FAR PASCAL GS16bitWindProc(HWND Window,
     202                WORD Message,
     203                WPARAM wParameter,
     204                LPARAM lParameter)
     205{
     206  long reply = 0;
    174207
    175208  switch(Message)
    176     { case WM_CREATE:
    177     {
    178     }
    179     break;
    180 
    181     case WM_COMMAND:
    182         break;
    183 
    184         case WM_CLOSE:
    185             DestroyWindow(Window);
    186         return 0L;
    187 
    188         case WM_DESTROY:
    189         { PostQuitMessage(0);
    190         }
    191         break;
    192 
    193         default:
    194             return(DefWindowProc(Window, Message, wParameter, lParameter));
    195     }
     209    {
     210    case WM_CREATE:
     211      {
     212      }
     213      break;
     214
     215    case WM_COMMAND:
     216      break;
     217
     218    case WM_CLOSE:
     219      DestroyWindow(Window);
     220      return 0L;
     221
     222    case WM_DESTROY:
     223      {
     224    PostQuitMessage(0);
     225      }
     226      break;
     227
     228    default:
     229      return(DefWindowProc(Window, Message, wParameter, lParameter));
     230    }
    196231  return reply;
    197232}
    198233
    199234void GS16bit_init(HINSTANCE instance, int Show)
    200 { FARPROC showsplash;
    201     FARPROC loadbmp;
    202   HDC           dc;
     235{
     236  FARPROC showsplash;
     237  FARPROC loadbmp;
     238  HDC dc;
    203239  char buffer[20];
    204240
    205 /*
    206   dc    = GetDC(GetDesktopWindow());
    207   bmpUtil_loadBitmap(dc, "C:\\gs.bmp");
    208   ReleaseDC(GetDesktopWindow(), dc);
    209 */
    210 //  showsplash = MakeProcInstance((FARPROC) splash_show, instance);
    211 //  (*(splashfn) showsplash)(instance, 3000);
     241  /*
     242    dc = GetDC(GetDesktopWindow());
     243    bmpUtil loadBitmap(dc, "C:\\gs.bmp");
     244    ReleaseDC(GetDesktopWindow(), dc);
     245  */
     246  //    showsplash = MakeProcInstance((FARPROC) splash_show, instance);
     247  //    (*(splashfn) showsplash)(instance, 3000);
    212248
    213249  GS16bit_checkWindowsVersion();
    214250
    215     app_window = CreateWindow("GS16bit:Main", "GreenStone Installer",
    216                                                             WS_OVERLAPPEDWINDOW | WS_MINIMIZE | CS_DBLCLKS,
    217                                                             CW_USEDEFAULT,
    218                                                             0,
    219                                                             CW_USEDEFAULT,
    220                                                             0,
    221                                                             NULL,
    222                                                             NULL,
    223                                                             app_instance,
    224                                                             NULL);
    225 
    226     ShowWindow(app_window, Show);
    227 
     251  app_window = CreateWindow("GS16bit:Main", "GreenStone Installer",
     252                WS_OVERLAPPEDWINDOW | WS_MINIMIZE | CS_DBLCLKS,
     253                CW_USEDEFAULT,
     254                0,
     255                CW_USEDEFAULT,
     256                0,
     257                NULL,
     258                NULL,
     259                app_instance,
     260                NULL);
     261
     262  ShowWindow(app_window, Show);
     263 
    228264  PostQuitMessage(0);
    229265}
    230266
    231267void WinClassInit(void)
    232 { WNDCLASS  Class;
    233 
    234     Class.lpszClassName = "GS16bit:Main";
    235     Class.hInstance     = app_instance;
    236     Class.lpfnWndProc       = (WNDPROC) GS16bitWindProc;
    237     Class.hCursor               = LoadCursor(NULL, IDC_ARROW);
    238     Class.hIcon                 = NULL; //LoadIcon(app_instance, "GSInstall");
    239     Class.lpszMenuName  = NULL;
    240     Class.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE+1);
    241     Class.style                 = NULL;
    242     Class.cbClsExtra        = 0;
    243     Class.cbWndExtra        = 0;
    244     RegisterClass(&Class);
     268{
     269  WNDCLASS Class;
     270
     271  Class.lpszClassName = "GS16bit:Main";
     272  Class.hInstance = app_instance;
     273  Class.lpfnWndProc = (WNDPROC) GS16bitWindProc;
     274  Class.hCursor = LoadCursor(NULL, IDC_ARROW);
     275  Class.hIcon = NULL; //LoadIcon(app_instance, "GSInstall");
     276  Class.lpszMenuName = NULL;
     277  Class.hbrBackground = (HBRUSH) (COLOR_APPWORKSPACE+1);
     278  //  Class.style = NULL;
     279  Class.style = 0;
     280  Class.cbClsExtra = 0;
     281  Class.cbWndExtra = 0;
     282  RegisterClass(&Class);
    245283}
    246284
    247285int PASCAL WinMain(HINSTANCE Current,
    248                                         HINSTANCE Previous,
    249                                         LPSTR CmdLine,
    250                                         int CmdShow)
    251 { MSG msg;
    252 
    253     app_cmdLine = (char *) LocalAlloc(LMEM_FIXED, lstrlen(CmdLine) + 1);
    254     lstrcpy(app_cmdLine, CmdLine);
    255 
    256     app_instance = Current;
    257     /* -- init application */
    258     if (!Previous)
    259     { WinClassInit();
    260     }
    261 
    262     /* -- init instance */
     286           HINSTANCE Previous,
     287           LPSTR CmdLine,
     288           int CmdShow)
     289{
     290  MSG msg;
     291
     292  app_cmdLine = (char *) LocalAlloc(LMEM_FIXED, lstrlen(CmdLine) + 1);
     293  lstrcpy(app_cmdLine, CmdLine);
     294 
     295  app_instance = Current;
     296  /* -- init application */
     297  if (!Previous)
     298    {
     299      WinClassInit();
     300    }
     301
     302  /* -- init instance */
    263303  GS16bit_init(Current, CmdShow);
    264304
    265     while (GetMessage(&msg, NULL, 0, 0))
    266     { TranslateMessage(&msg);
    267         DispatchMessage(&msg);
    268     }
    269     return (int) msg.wParam;
    270 }
     305  while (GetMessage(&msg, NULL, 0, 0))
     306    {
     307      TranslateMessage(&msg);
     308      DispatchMessage(&msg);
     309    }
     310  return (int) msg.wParam;
     311}
Note: See TracChangeset for help on using the changeset viewer.