Solved

information about Library file

Posted on 2004-04-14
11
209 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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
 

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 42
mixString challenge 36 121
Replacement selected text 2 61
Modbus - whats the maximum I can store in one register? 4 79
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

770 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