Article View: borland.public.cppbuilder.nativeapi
Article #8908Re: Getting 'Internal Name' from a DLL
From: Pere Mateu
Date: Tue, 31 Aug 2004 17:47
Date: Tue, 31 Aug 2004 17:47
56 lines
2962 bytes
2962 bytes
> In the Properties for a DLL there is an item named "Internal Name". In
> Windows XP this is shown on the Version Tab of the Properties dialog box.
> Is there an API to get this string from a DLL?
Hope this code helps:
//--------------------------------------------------------------------------
-
// Summary:
// Get file information.
// Arguments:
// FileName - File to check version
// Property - Name of the requested file information string.
// The Win32 API contains the following predefined version
// information strings:
// - CompanyName
// - FileDescription
// - FileVersion
// - InternalName
// - LegalCopyright
// - OriginalFilename
// - ProductName
// - ProductVersion
// Return Value:
// String containing the desired file information string.
//--------------------------------------------------------------------------
-
AnsiString __fastcall GetFileInfo(AnsiString FileName, AnsiString Property)
{
if (!FileExists(FileName)) return("");
if (Property=="") return("");
DWORD handle; AnsiString s="";
int size=GetFileVersionInfoSize(FileName.c_str(),&handle);
if (size==0) return("");
char *buffer=new char [size] ;
bool status=GetFileVersionInfo(FileName.c_str(),0,size,buffer) ;
if (!status) { delete[] buffer; return(""); }
UINT datasize ;
struct {
unsigned short language ;
unsigned short character_set ;
} *translation ;
status=VerQueryValue(buffer,"\\VarFileInfo\\Translation",(void
**)&translation,&datasize);
AnsiString key="\\StringFileInfo\\"+IntToHex(translation
[0].language,4)+
IntToHex(translation [0].character_set,4)+"\\"+Property;
char *data ;
status=VerQueryValue(buffer,key.c_str(),(void**)&data,&datasize);
if (status) s=AnsiString(data);
delete[] buffer ;
return(s);
}
Technical Details
Message-ID:
<4134b9a6@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<4127a15d$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,d824276a38c6a5be X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Pere Mateu" <pmateu@siam.es> Newsgroups: borland.public.cppbuilder.nativeapi References: <4127a15d$1@newsgroups.borland.com> Subject: Re: Getting 'Internal Name' from a DLL Date: Tue, 31 Aug 2004 19:47:52 +0200 Lines: 58 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 81.203.227.181 Message-ID: <4134b9a6@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1093974438 81.203.227.181 (31 Aug 2004 10:47:18 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail