[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

information about Library file

Posted on 2004-04-14
11
Medium Priority
?
220 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 200 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

656 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