Solved

information about Library file

Posted on 2004-04-14
11
206 Views
Last Modified: 2013-11-20
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
Comment
Question by:nclgaurav
  • 3
  • 3
  • 2
  • +1
11 Comments
 
LVL 4

Expert Comment

by:caner_elci
ID: 10825042
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
 

Author Comment

by:nclgaurav
ID: 10830179
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
 

Author Comment

by:nclgaurav
ID: 10830191
I don't have the code of library. I have only a lib file. I want to know about that lib file.
0
 
LVL 4

Expert Comment

by:bkfirebird
ID: 10830272
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:nclgaurav
ID: 10830716
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
 
LVL 3

Expert Comment

by:akalmani
ID: 10831283
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
 
LVL 3

Expert Comment

by:akalmani
ID: 10831347
//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
 
LVL 3

Accepted Solution

by:
akalmani earned 50 total points
ID: 10831395
//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
 
LVL 4

Expert Comment

by:bkfirebird
ID: 10833829
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now