home *** CD-ROM | disk | FTP | other *** search
/ Troubleshooting Netware Systems / CSTRIAL0196.BIN / attach / msj / v10n04 / wqa0495.exe / STARTGRP.C < prev    next >
C/C++ Source or Header  |  1995-04-01  |  2KB  |  56 lines

  1. #include <windows.h>
  2.  
  3. BOOL GetStartupGroupName( LPSTR lpszBuffer, unsigned cBuffSize );
  4.  
  5. int PASCAL WinMain( HANDLE h, HANDLE hPrev, LPSTR lpszCmdLine, int nCmdShow )
  6. {
  7.     char szGroupName[260];
  8.     
  9.     if ( GetStartupGroupName( szGroupName, sizeof(szGroupName) ) )
  10.         MessageBox( 0, szGroupName, "The startup group name is...", MB_OK );
  11.     else
  12.         MessageBox( 0, "Startup group name not found", 0, MB_OK );
  13.     
  14.     return 0;
  15. }
  16.  
  17. BOOL GetStartupGroupName( LPSTR lpszBuffer, unsigned cBuffSize )
  18. {
  19.     char szShellName[260];
  20.     HMODULE hModShell;
  21.     char szShellIni[260];
  22.     char szDefGroupName[260];
  23.  
  24.     // Get the name of the shell EXE (typically PROGMAN.EXE)
  25.     // from the [BOOT] section of the SYSTEM.INI.  It might not
  26.     // be PROGMAN.EXE if running something like Norton Desktop
  27.     GetPrivateProfileString("boot", "shell", "",  szShellName,
  28.                             sizeof(szShellName), "system.ini" );
  29.                          
  30.     if ( !szShellName[0] )  // Verify that we got the shell name
  31.         return FALSE;
  32.  
  33.     // Get the module handle of the shell app so that we can use LoadString
  34.     hModShell = GetModuleHandle( szShellName );
  35.     if ( !hModShell )
  36.         return 0;
  37.  
  38.     // String resource #6 is the name of the shell's INI file
  39.     // (e.g., PROGMAN.INI)
  40.     if ( !LoadString( hModShell, 6, szShellIni, sizeof(szShellIni) ) )
  41.         return FALSE;
  42.  
  43.     // String resource #0x78 is the default name for the startup group.
  44.     if ( !LoadString(hModShell, 0x78, szDefGroupName, sizeof(szDefGroupName)))
  45.         return FALSE;
  46.  
  47.     // The startup group name can be overrided with a "startup=" entry
  48.     // in the "Settings" section of the shell's .INI file.  Go get that
  49.     // string if present.  Pass the default startup group name found
  50.     // in the previous step as the lpszDefault parameter.
  51.     GetPrivateProfileString("Settings", "startup", szDefGroupName, 
  52.                             lpszBuffer, cBuffSize, szShellIni );
  53.     return TRUE;
  54. }
  55.  
  56.