home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 …ember: Reference Library / Dev.CD Dec 00 RL Disk 2.toast / pc / technicalpublications / macosx / system / documentation / developer / developertools / projectbuilder / aboutbox / aboutbox.c next >
Encoding:
C/C++ Source or Header  |  2000-10-30  |  1.4 KB  |  37 lines

  1. #include <MacWindows.h>
  2. #include <Dialogs.h>
  3. #include <CoreFoundation/CFBundle.h>
  4. #include "AboutBox.h"
  5.  
  6. #define kAboutBox    200        /* Dialog resource for About box */
  7.  
  8. void DoAboutBox(void)
  9. {
  10.     CFBundleRef appBundle, fwBundle;
  11.     CFStringRef cfVersionString;
  12.     Str255 pascalVersionString;
  13.     short ierr, globalRefNum, localRefNum;
  14.  
  15.     /* Get the application's short version string. */
  16.     appBundle = CFBundleGetMainBundle();
  17.     cfVersionString = (CFStringRef) CFBundleGetValueForInfoDictionaryKey(
  18.        appBundle, CFSTR("CFBundleShortVersionString"));
  19.     if ((cfVersionString == CFSTR("")) || (cfVersionString == NULL))
  20.         cfVersionString = CFSTR("Nameless Application");
  21.     CFStringGetPascalString(cfVersionString, pascalVersionString, 256, 
  22.         CFStringGetSystemEncoding());
  23.    
  24.     /* Open the framework's resource fork. */
  25.     fwBundle = CFBundleGetBundleWithIdentifier( CFSTR("com.apple.tutorial.aboutbox" ));
  26.     ierr = CFBundleOpenBundleResourceFiles( fwBundle, &globalRefNum, &localRefNum ); 
  27.     
  28.     /* Display the about box (from the framework)
  29.        with the version string (from the application). */
  30.     ParamText(pascalVersionString,"\p","\p","\p");    
  31.     (void) Alert(kAboutBox, nil);
  32.     
  33.     /* Close the framework's resource fork. */
  34.     CFBundleCloseBundleResourceMap(fwBundle, globalRefNum);
  35.     CFBundleCloseBundleResourceMap(fwBundle, localRefNum);
  36. }
  37.