[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 225
  • Last Modified:

information about Library file

Hi
How can I get the information about a library file, like its version, author name etc.Please give some cool like related to this topic if possible. or give me sample code.
0
nclgaurav
Asked:
nclgaurav
  • 3
  • 3
  • 2
  • +1
1 Solution
 
caner_elciCommented:
You can find my comment on http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_20953905.html#10825006

You can use that function to get version of any exe, dll, ocx, lib etc. file...
0
 
nclgauravAuthor Commented:
I don't get tthe answer form there.In that function nothing is clear.They are using a object of a class.nothing clear about that class.And I am also not clear about the property setting.
I am using VC++(MFC).
0
 
nclgauravAuthor Commented:
I don't have the code of library. I have only a lib file. I want to know about that lib file.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
bkfirebirdCommented:
use the LIB tool which comes with visual studio
its usually in the \Microsoft Visual Studio\VC98\Bin directory

do something like LIB /LIST mylib.lib
0
 
nclgauravAuthor Commented:
C:\Program Files\Microsoft Visual Studio\VC98\Bin>lib \list D:\Gaurav\Work\Proje
ct\Help\kidsfull\Login Manager\New Login (MFC)\LOGIN\cryptlib.lib
Microsoft (R) Library Manager Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

LIB : fatal error LNK1181: cannot open input file "\list"
this error i get after follow your given suggestion.Here I  ALSO try without \list. again get error

C:\Program Files\Microsoft Visual Studio\VC98\Bin>lib D:\Gaurav\Work\Project\Hel
p\kidsfull\Login Manager\New Login (MFC)\LOGIN\cryptlib.lib
Microsoft (R) Library Manager Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

LIB : fatal error LNK1181: cannot open input file "D:\Gaurav\Work\Project\Help\k
idsfull\Login"

After that I copy the library file in Bin folder And run this command

C:\Program Files\Microsoft Visual Studio\VC98\Bin>lib cryptlib.lib

output:---------
Microsoft (R) Library Manager Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

But this also not give the version number.

One more thing, I try to run this command with different lib file,It is making a file but automtically delete it also.I can't view that file.How can I view that file.
0
 
akalmaniCommented:
Using dos command prompt go to the bin directory where visual studio is installed. Run the vcvars32.bat which sets the environment variables for that command prompt and also sets the required paths.

Then you can type in Dumpbin /all  "Specify the *.lib file here" > file.txt

That's it you have all the information about *.lib file in a file.txt which is created in the bin directory.

If you want to programmatically retrieve the version info then use GetFileVersionInfo() API. Refer to MSDN for more help.
0
 
akalmaniCommented:
//You can pass FILE_VERSION to this function. You may modify this to accept file name as parameter too..its left to you.

BOOL GetVerInfo(UINT nFlags)
{
LPVOID lpData;
LPVOID lpBuffer;
LPTSTR lpSubBlock = _T("\\");
DWORD  dwSize;
DWORD  dwHandle;
UINT   nLen;
UINT   nRet;

//Get the size of the version information in bytes
dwSize = GetFileVersionInfoSize("C:\\Winnt\\Crypt.lib", &dwHandle);

//if the size is zero return failure
if(dwSize != 0)
{
      //Allocate memory for the version information
      lpData = LocalAlloc(LMEM_ZEROINIT, dwSize);

      //if memory could not be allocated, return failure
      if(NULL != lpData)
      {
            //Retrieve the version information for the specified file
            nRet = GetFileVersionInfo("C:\\Winnt\\Crypt.lib", 0, dwSize, lpData);

            //If the function call fails, return failure
            if(nRet == 0)
            {
                  //Free the allocated memory
                  LocalFree(lpData);
                  return FALSE;
            }

            //Retrieve the specified version information from the specified
            //version information resource
            nRet = VerQueryValue(lpData, lpSubBlock, &lpBuffer, &nLen);

            //If the function call fails, return failure
            if(nRet == 0)
            {
                  //Free the allocated memory
                  LocalFree(lpData);
                  return FALSE;
            }

            //Check whether the request is for file version info or product version info
            switch(nFlags)
            {
                  case FILE_VERSION:
                        ConvertVerToStr(*((DWORD *)lpBuffer + 2), *((DWORD *)lpBuffer + 3), lpVersion);
                        break;

                  case PROD_VERSION:
                        ConvertVerToStr(*((DWORD *)lpBuffer + 4), *((DWORD *)lpBuffer + 5), lpVersion);
                        break;

                  default:
                        //Free the allocated memory and return failure
                        LocalFree(lpData);
                        return FALSE;
            }

            //Free the allocated memory
            LocalFree(lpData);
            //Return success
            return TRUE;
      }
 }
}
0
 
akalmaniCommented:
//Sorry I missed my function ConvertVerToStr

ConvertVerToStr(DWORD dwMajVer, DWORD dwMinVer, LPTSTR *lpVersion)
{
      _TCHAR Version[20];

      //Allocate memory to store the version information
      *lpVersion = (LPTSTR) new _TCHAR[50];

      //Convert the MSW of the major version number to string format
      _itot((dwMajVer & 0x0FFFF0000) >> 16, Version, 10);

      //Copy it into the allocated buffer
      _tcscpy(*lpVersion, Version);

      //Append a dot to the contents of the buffer
      _tcscat(*lpVersion,_T("."));

      //Convert the LSW of the major version number to string format
      _itot((dwMajVer & 0x0000FFFF), Version, 10);

      //Append it to the contents of the buffer
      _tcscat(*lpVersion, Version);

      //Append a dot to the contents of the buffer
      _tcscat(*lpVersion,_T("."));

      //Convert the MSW of the minor version number to string format
      _itot((dwMinVer & 0xFFFF0000) >> 16, Version, 10);

      //Append it to the contents of the buffer
      _tcscat(*lpVersion, Version);

      //Append a dot to the contents of the buffer
      _tcscat(*lpVersion,_T("."));

      //Convert the LSW of the minor version number to string format
      _itot((dwMinVer & 0x0000FFFF), Version, 10);

      //Append it to the contents of the buffer
      _tcscat(*lpVersion, Version);

      //Append a dot to the contents of the buffer
      _tcscat(*lpVersion,_T("."));

      return;
}//End of ConvertVerToStr()


One more change to GetVerInfo(UINT nFlags, LPTSTR *lpVersion)

Make sure you delete the lpVersion after use.
0
 
bkfirebirdCommented:
lib \list D:\Gaurav\Work\Project\Help\kidsfull\Login Manager\New Login (MFC)\LOGIN\cryptlib.lib

change this to

lib /list D:\Gaurav\Work\Project\Help\kidsfull\Login Manager\New Login (MFC)\LOGIN\cryptlib.lib
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now