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

📄 version.c

📁 CC386 is a general-purpose 32-bit C compiler. It is not an optimizing compiler but given that the co
💻 C
字号:
/* 
   Copyright 2002-2003 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
   02111-1307, USA.  

   You may contact the author at:

   mailto::camille@bluegrass.net

   or by snail mail at:

   David Lindauer
   850 Washburn Ave Apt 99
   Louisville, KY 40222
*/
#include <windows.h>

/*
 * This basically pulls one of the version strings out of the stringtable block
 * of the version resource.
 *
 * We are doing it out the long way for compatibility with wdosx
 */
static int strsize(short *str)
{
   int count = 0 ;
   while (*str++) count++ ;
   return count ;
}
int VersionString(char *buf, short *key, short *lang)
{
   int rv = 0 ;
   HMODULE handle = GetModuleHandle(0) ;
   HRSRC rsrc = FindResource(handle,(LPCTSTR)1,RT_VERSION) ;
   DWORD size = SizeofResource(handle,rsrc) ;
   HGLOBAL global = LoadResource(handle,rsrc) ;
   if (global) {
      char *s = LockResource(global) ;
      if (s) {
         if (!memcmp(s+6,L"VS_VERSION_INFO",32)) {
            char *block = s + 0x5c ;
            if (!memcmp(block + 6,L"StringFileInfo",30)) {
               int xsize ;
               block = block + 0x24 ;
               while (memcmp(block+6,lang,strsize(lang)*2 + 2)) {
                  block = block + *(short *) block ;
                  if (block >= s+size)
                     goto done ;
               }
               xsize = *(short *)block - 0x24;
               block = block + strsize(lang) * 2 + 2 + 6 ;
               while (xsize>0 && memcmp(block+6,key,strsize(key)*2)) {
                  int len = *(short *)block ;
                  if (len %4) len += 2 ;
                  xsize -= len ;
                  block = block + len ;
               }
               if (xsize) {
                  short *aa ;
                  int len = *(short *)(block+2) ;
                  int len1 = 6 + strsize(key)*2 + 2;
                  if (len1 %4) len1 += 2 ;
                  aa = block +len1;
                  while (len--)  {
                     *buf++ = *aa ++ ;
                  }
                  *buf = 0 ;
                  rv = 1 ;

               }
            }
         }
done:
      }
      FreeResource(global) ;
   }
   return rv ;
}

⌨️ 快捷键说明

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