⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 res.cpp

📁 This software performs code conversion of Chinese characters, including GB2312/GBK and BIG5. It a
💻 CPP
📖 第 1 页 / 共 2 页
字号:
int TranslateVersionInfo ( const FILEVERSION *pFileVersion ) {

   int nMajor = pFileVersion->wMajor ;
   int nMinor = pFileVersion->wMinor ;

   if ( nMinor > 99 ) nMinor = 99 ;

   return  nMajor * 100 + nMinor ;
}



////////////////////////////////////////
//      僶乕僕儑儞儕僜乕僗乮楍嫇乯    //
////////////////////////////////////////



// 僐乕儖僶僢僋娭悢偑 0 傪曉偟偨傜丄楍嫇傪掆巭
//                    0 埲奜傪曉偟偨傜丄楍嫇傪宲懕
// szKey 偑 NULL 側傜 pValue 偵偼 32價僢僩偺惍悢偑擖傞
//     偦偆偱側偄側傜 pValue 偵偼 Unicode 暥帤楍 傑偨偼 NULL 偑擖傞
static int EnumVsTable ( int nLevel, const VS_TABLE *pVsTable, int ( CALLBACK *Callback ) ( int nLevel, const wchar_t *szKey, const wchar_t *szValue, const long *pValue, size_t nLength, LPARAM lParam ), LPARAM lParam ) {

   if ( pVsTable->wType ) {
      if ( ! Callback ( nLevel, pVsTable->szKey, (const wchar_t*) GetVsValue ( pVsTable ), NULL, pVsTable->wValueLength, lParam ) ) return 0 ;
   }
   else {
      if ( ! Callback ( nLevel, pVsTable->szKey, NULL, (const long*) GetVsValue ( pVsTable ), ( pVsTable->wValueLength / sizeof(long) ), lParam ) ) return 0 ;
   }

   const VS_TABLE *pChildStart = GetVsChildren ( pVsTable ) ;
   const VS_TABLE *pChildEnd = GetVsEnd ( pVsTable ) ;

   for ( const VS_TABLE *pChild = pChildStart ; pChild < pChildEnd ; pChild = GetVsNext ( pChild ) ) {
      if ( ! EnumVsTable ( nLevel + 1, pChild, Callback, lParam ) ) return 0 ;
   }

   return 1 ;
}



// 僶乕僕儑儞忣曬傪楍嫇
// 惉岟偟偨傜 0 傪丄幐攕偟偨傜 0 埲奜傪曉偡
int EnumVersionInfo ( int ( CALLBACK *Callback ) ( int nLevel, const wchar_t *szKey, const wchar_t *szValue, const long *pValue, size_t nLength, LPARAM lParam ), LPARAM lParam ) {

   const VS_TABLE *pVsVersionInfo = GetVersionInfo () ;
   if ( ! pVsVersionInfo ) return 1 ;

   EnumVsTable ( 0, pVsVersionInfo, Callback, lParam ) ;

   return 0 ;
}



#if ! defined NOCRT
////////////////////////////////////////
//   僶乕僕儑儞儕僜乕僗乮挊嶌尃昞帵乯 //
////////////////////////////////////////



static void __cdecl CopyrightExitProc ( void ) ;
static volatile long IsCopyrightExitProcRegistered ;
static char *szCopyrightA ;



// 儕僜乕僗拞偺挊嶌尃昞帵傪庢摼偡傞乮ANSI斉乯
// 暋悢偺尵岅偺忣曬偑偁傟偽丄嵟弶偺尵岅偺忣曬傪曉偡
// 儕僜乕僗偑尒偮偐傜側偗傟偽丄挿偝僛儘偺暥帤楍傪曉偡
// 彂偒崬傑傟偨暥帤楍偼師偵偙偺娭悢偑屇偽傟傞傑偱桳岠丄嵞擖晄壜
const char *GetVersionCopyrightA ( void ) {

   free ( szCopyrightA ) ;
   szCopyrightA = NULL ;

   const wchar_t *szString = GetVersionCopyrightW () ;

   int nLength ;

   if ( ! ( nLength = WideCharToMultiByte ( CP_ACP, 0, szString, -1, NULL, 0, NULL, NULL ) ) ) return "" ;
   if ( ! ( szCopyrightA = (char*) malloc ( nLength * sizeof(char) ) ) ) return "" ;
   if ( ! InterlockedExchange ( & IsCopyrightExitProcRegistered, TRUE ) ) atexit ( CopyrightExitProc ) ;
   if ( ! ( nLength = WideCharToMultiByte ( CP_ACP, 0, szString, -1, szCopyrightA, nLength, NULL, NULL ) ) ) return "" ;

   return szCopyrightA ;
}



static void __cdecl CopyrightExitProc ( void ) {
   free ( szCopyrightA ) ;
}



typedef struct {
   int IsStringFileInfo ;
   const wchar_t *szResult ;
} SEARCH_COPYRIGHT_INFO ;



static int CALLBACK CallbackSearchCopyRight ( int nLevel, const wchar_t *szKey, const wchar_t *szValue, const long *pValue, size_t nLength, LPARAM lParam ) {

   SEARCH_COPYRIGHT_INFO *pSearchCopyrightInfo = (SEARCH_COPYRIGHT_INFO*) lParam ;

   if ( ! szKey ) return 1 ;

   if ( nLevel == 1 ) {
      if ( ! wcscmp ( szKey, L"StringFileInfo" ) ) pSearchCopyrightInfo->IsStringFileInfo = 1 ;
      else                                         pSearchCopyrightInfo->IsStringFileInfo = 0 ;
   }

   if ( nLevel == 3 ) {
      if ( pSearchCopyrightInfo->IsStringFileInfo && ! wcscmp ( szKey, L"LegalCopyright" ) ) {
         pSearchCopyrightInfo->szResult = (const wchar_t*) szValue ;
         return 0 ;
      }
   }

   return 1 ;
}



// 儕僜乕僗拞偺挊嶌尃昞帵傪庢摼偡傞乮UNICODE斉乯
// 暋悢偺尵岅偺忣曬偑偁傟偽丄嵟弶偺尵岅偺忣曬傪曉偡
// 儕僜乕僗偑尒偮偐傜側偗傟偽丄挿偝僛儘偺暥帤楍傪曉偡
// Win95/98/Me 偱傕巊梡壜
const wchar_t *GetVersionCopyrightW ( void ) {

   SEARCH_COPYRIGHT_INFO SearchCopyrightInfo = { 0 } ;
   EnumVersionInfo ( CallbackSearchCopyRight, (LPARAM) & SearchCopyrightInfo ) ;
   if ( ! SearchCopyrightInfo.szResult ) return L"" ;

   return SearchCopyrightInfo.szResult ;
}



#endif // ! defined NOCRT



#if ( ! defined _CONSOLE && ! defined _USRDLL || defined LOAD_USER32_DLL ) && ! defined NOCRT
////////////////////////////////////////
//          僀儊乕僕儕僜乕僗          //
////////////////////////////////////////



// 僀儊乕僕傪曉偡
// 幐攕偟偨傜 NULL 傪曉偡
HANDLE LoadImageEx ( int nId, int nType, int nX, int nY, unsigned long dwMode ) {

   if ( ! hInstance ) InitResourceInstance () ;

   if ( hSatelliteInstance ) {
      HANDLE hImage ;
      if ( IsNT () ) hImage = LoadImageW ( hSatelliteInstance, MAKEINTRESOURCEW ( nId ), nType, nX, nY, dwMode ) ;
      else           hImage = LoadImageA ( hSatelliteInstance, MAKEINTRESOURCEA ( nId ), nType, nX, nY, dwMode ) ;
      if ( hImage ) return hImage ;
   }

   if ( IsNT () ) return LoadImageW ( hInstance, MAKEINTRESOURCEW ( nId ), nType, nX, nY, dwMode ) ;
   else           return LoadImageA ( hInstance, MAKEINTRESOURCEA ( nId ), nType, nX, nY, dwMode ) ;
}



// 僔僗僥儉僀儊乕僕傪曉偡
// 幐攕偟偨傜 NULL 傪曉偡
HANDLE LoadSystemImage ( const void *nId, int nType, int nX, int nY, unsigned long dwMode ) {

   if ( (uintptr_t) nId > 0xFFFF ) return NULL ;

   if ( IsNT () ) return LoadImageW ( NULL, MAKEINTRESOURCEW ( nId ), nType, nX, nY, dwMode ) ;
   else           return LoadImageA ( NULL, MAKEINTRESOURCEA ( nId ), nType, nX, nY, dwMode ) ;
}



////////////////////////////////////////
//          傾僀僐儞儕僜乕僗          //
////////////////////////////////////////



// 傾僀僐儞傪曉偡
// 僔僗僥儉婛掕偺僒僀僘偺傒
// 幐攕偟偨傜 NULL 傪曉偡
HICON LoadIconEx ( int nId ) {
   return (HICON) LoadImageEx ( nId, IMAGE_ICON, 0, 0, LR_SHARED | LR_DEFAULTSIZE ) ;
}



// 僔僗僥儉傾僀僐儞傪曉偡
// 僔僗僥儉婛掕偺僒僀僘偺傒
// 幐攕偟偨傜 NULL 傪曉偡
HICON LoadSystemIcon ( const void *nId ) {
   return (HICON) LoadSystemImage ( nId, IMAGE_ICON, 0, 0, LR_SHARED | LR_DEFAULTSIZE ) ;
}



////////////////////////////////////////
//         僟僀傾儘僌儕僜乕僗         //
////////////////////////////////////////



#pragma pack(2)
typedef struct {
   unsigned short dlgVer ;
   unsigned short signature ;
   unsigned long helpID ;
   unsigned long exStyle ;
   unsigned long style ;
   unsigned short cDlgItems ;
   short x ;
   short y ;
   short cx ;
   short cy ;
   // 埲壓徣棯
} DLGTEMPLATEEX ;
#pragma pack()



// GetDialog 偺壓惪偗娭悢
// 惉岟偟偨傜 0 傪曉偟丄寢壥傪 ppDlg 偵奿擺偡傞
// 幐攕偟偨傜 0 埲奜傪曉偡
static int GetDialogSub ( int nTemplate, const DLGTEMPLATE **ppDlg, HINSTANCE hCurrentInstance, int nLangId ) {

   HRSRC hRsrc ;
   HGLOBAL hGlobal = NULL ;
   const DLGTEMPLATE *pDlg = NULL ;

   if ( IsNT () ) hRsrc = FindResourceExW ( hCurrentInstance, MAKEINTRESOURCEW ( RT_DIALOG ), MAKEINTRESOURCEW ( nTemplate ), (LANGID) nLangId ) ;
   else           hRsrc = FindResourceExA ( hCurrentInstance, MAKEINTRESOURCEA ( RT_DIALOG ), MAKEINTRESOURCEA ( nTemplate ), (LANGID) nLangId ) ;

   if ( hRsrc ) hGlobal = LoadResource ( hCurrentInstance, hRsrc ) ;
   if ( hGlobal ) pDlg = (const DLGTEMPLATE*) LockResource ( hGlobal ) ;

   *ppDlg = pDlg ;

   if ( pDlg ) return 0 ;
   else        return 1 ;
}



// 儕僜乕僗撪偺僟僀傾儘僌僥儞僾儗乕僩偺傾僪儗僗傪庢摼偡傞
// 僟僀傾儘僌偑尒偮偐傜側偗傟偽 NULL 傪曉偡
static const DLGTEMPLATE *GetDialog ( int nTemplate ) {

   const DLGTEMPLATE *pDlg ;

   if ( ! hInstance ) InitResourceInstance () ;

   if ( hSatelliteInstance                && ! GetDialogSub ( nTemplate, & pDlg, hSatelliteInstance, nResourceLangId ) ) return pDlg ;
   if ( 1                                 && ! GetDialogSub ( nTemplate, & pDlg, hInstance, nResourceLangId ) ) return pDlg ;
   if ( nResourceLangId != LANGID_ENGLISH && ! GetDialogSub ( nTemplate, & pDlg, hInstance, LANGID_ENGLISH ) ) return pDlg ;
   if ( nResourceLangId != LANGID_NEUTRAL && ! GetDialogSub ( nTemplate, & pDlg, hInstance, LANGID_NEUTRAL ) ) return pDlg ;

   return NULL ;
}



// 僟僀傾儘僌偺僥儞僾儗乕僩偐傜僼僅儞僩忣曬偺傾僪儗僗傪庢摼偡傞
// 惉岟偟偨傜 0 傪丄幐攕偟偨傜 0 埲奜傪曉偡
static int GetDialogFontInfo ( int nTemplate, int *pFontSize, const wchar_t **pFontName ) {

   const wchar_t *szMenu ;
   const wchar_t *szClass ;
   const wchar_t *szTitle ;
   const wchar_t *szFontSize ;

   const DLGTEMPLATE *pDlg = GetDialog ( nTemplate ) ;
   if ( pDlg == NULL ) return 1 ;

   const DLGTEMPLATEEX *pDlgEx = (const DLGTEMPLATEEX*) pDlg ;
   if ( pDlgEx->signature != 0xFFFF ) pDlgEx = NULL ;

   if ( pDlgEx ) {
      if ( ! ( pDlgEx->style & DS_SETFONT ) ) return 1 ;
      szMenu = (const wchar_t*) ( pDlgEx + 1 ) ;
   }
   else {
      if ( ! ( pDlg->style & DS_SETFONT ) ) return 1 ;
      szMenu = (const wchar_t*) ( pDlg + 1 ) ;
   }

   if ( *szMenu == 0xFFFF ) szClass = szMenu + 2 ;
   else                     szClass = wcsend ( szMenu ) + 1 ;

   if ( *szClass == 0xFFFF ) szTitle = szClass + 2 ;
   else                      szTitle = wcsend ( szClass ) + 1 ;

   szFontSize = wcsend ( szTitle ) + 1 ;

   if ( pFontSize ) *pFontSize = *szFontSize ;
   if ( pFontName ) *pFontName = szFontSize + ( pDlgEx ? 3 : 1 ) ;

   return 0 ;
}



// 僟僀傾儘僌偺僥儞僾儗乕僩偐傜僼僅儞僩柤傪庢摼偡傞乮ANSI斉乯
// 惉岟偟偨傜僼僅儞僩僒僀僘傪丄幐攕偟偨傜 0 傪曉偡
int GetDialogFontA ( int nTemplate, char *szFontName, int nBufferSize ) {

   if ( szFontName && nBufferSize ) *szFontName = 0 ;

   int nSize ;
   const wchar_t *szString ;
   if ( GetDialogFontInfo ( nTemplate, & nSize, & szString ) ) return 0 ;

   if ( szFontName && nBufferSize ) {

      size_t STRING_LENGTH = wcslen ( szString ) ;
      int nLength = ( STRING_LENGTH >= LF_FACESIZE ) ? LF_FACESIZE - 1 : (int) STRING_LENGTH ;

      int nResult = WideCharToMultiByte ( CP_ACP, 0, szString, nLength, NULL, 0, NULL, NULL ) ;
      int nCopyLength = ( nResult < nBufferSize ) ? nResult : nBufferSize - 1 ;
      memzero ( szFontName, ( nCopyLength + 1 ) * sizeof(char) ) ;
      WideCharToMultiByte ( CP_ACP, 0, szString, nLength, szFontName, nCopyLength, NULL, NULL ) ;
   }

   return nSize ;
}



// 僟僀傾儘僌偺僥儞僾儗乕僩偐傜僼僅儞僩柤傪庢摼偡傞乮UNICODE斉乯
// 惉岟偟偨傜僼僅儞僩僒僀僘傪丄幐攕偟偨傜 0 傪曉偡
int GetDialogFontW ( int nTemplate, wchar_t *szFontName, int nBufferSize ) {

   if ( szFontName && nBufferSize ) *szFontName = 0 ;

   int nSize ;
   const wchar_t *szString ;
   if ( GetDialogFontInfo ( nTemplate, & nSize, & szString ) ) return 0 ;

   if ( szFontName && nBufferSize ) {

      size_t STRING_LENGTH = wcslen ( szString ) ;
      int nLength = ( STRING_LENGTH >= LF_FACESIZE ) ? LF_FACESIZE - 1 : (int) STRING_LENGTH ;

      int nCopyLength = ( nLength < nBufferSize ) ? nLength : nBufferSize - 1 ;
      memmove ( szFontName, szString, nCopyLength * sizeof(wchar_t) ) ;
      szFontName [ nCopyLength ] = 0 ;
   }

   return nSize ;
}



// 僟僀傾儘僌偺僼僅儞僩偺崅偝傪庢摼偡傞
// 惉岟偟偨傜僼僅儞僩僒僀僘傪丄幐攕偟偨傜 0 傪曉偡
int GetDialogFontHeight ( int nTemplate ) {

   int nSize ;
   if ( GetDialogFontInfo ( nTemplate, & nSize, NULL ) ) return 0 ;

   return nSize ;
}



////////////////////////////////////////
//          僟僀傾儘僌偺婲摦          //
////////////////////////////////////////



// 儘働乕儖偵墳偠偰僟僀傾儘僌傪婲摦偡傞乮ANSI斉乯
// 幐攕偟偨傜晧悢傪曉偡
INT_PTR DialogBoxParamExA ( int nTemplate, HWND hWnd, DLGPROC pDialogProc, LPARAM lParam ) {

   const DLGTEMPLATE *pDlg = GetDialog ( nTemplate ) ;
   if ( ! pDlg ) return -1 ;

   return DialogBoxIndirectParamA ( hInstance, pDlg, hWnd, pDialogProc, lParam ) ;
}



// 儘働乕儖偵墳偠偰僟僀傾儘僌傪婲摦偡傞乮UNICODE斉乯
// 幐攕偟偨傜晧悢傪曉偡
INT_PTR DialogBoxParamExW ( int nTemplate, HWND hWnd, DLGPROC pDialogProc, LPARAM lParam ) {

   const DLGTEMPLATE *pDlg = GetDialog ( nTemplate ) ;
   if ( ! pDlg ) return -1 ;

   return DialogBoxIndirectParamW ( hInstance, pDlg, hWnd, pDialogProc, lParam ) ;
}



// 儘働乕儖偵墳偠偰儌乕僪儗僗僟僀傾儘僌傪婲摦偡傞乮ANSI斉乯
// 幐攕偟偨傜 NULL 傪曉偡
HWND CreateDialogParamExA ( int nTemplate, HWND hParent, DLGPROC pDialogProc, LPARAM lParam ) {

   const DLGTEMPLATE *pDlg = GetDialog ( nTemplate ) ;
   if ( ! pDlg ) return NULL ;

   return CreateDialogIndirectParamA ( hInstance, pDlg, hParent, pDialogProc, lParam ) ;
}



// 儘働乕儖偵墳偠偰儌乕僪儗僗僟僀傾儘僌傪婲摦偡傞乮UNICODE斉乯
// 幐攕偟偨傜 NULL 傪曉偡
HWND CreateDialogParamExW ( int nTemplate, HWND hParent, DLGPROC pDialogProc, LPARAM lParam ) {

   const DLGTEMPLATE *pDlg = GetDialog ( nTemplate ) ;
   if ( ! pDlg ) return NULL ;

   return CreateDialogIndirectParamW ( hInstance, pDlg, hParent, pDialogProc, lParam ) ;
}



#endif // ( ! defined _CONSOLE && ! defined _USRDLL || defined LOAD_USER32_DLL ) && ! defined NOCRT



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -