 |
|
 |
Good Job, Saved me time.....
|
|
|
|
 |
|
 |
Thanks a ton for this I'm using a modded version of how you pull the version info for a project I'm working on now. My other method was about 3 times the size in code compared to yours. Was looking around for a better method.
- Wiccaan
|
|
|
|
 |
|
 |
good article
-----------------
conglt
|
|
|
|
 |
|
 |
It's just was I was looking for, and it works great for my (humble) needs
|
|
|
|
 |
|
 |
it gave me the direction to my solution.
thanks!
Ohad
my photography exhibition:
www.pbase.com/ohadr
|
|
|
|
 |
|
 |
Hi there
How can I (using VC6 / MFC) load ALL strings from a stringtable, one-by-one, getting the IDS value as well as the actual text, for all strings in my program's stringtable?
Thanks
Alex
|
|
|
|
 |
|
 |
Call EnumResourceNames function with RT_STRING as its res. type, and in the callback you'll get the resource name, which is a res. ID if IS_INTRESOURCE is true, then you can call LoadString (the max str. len. is 1024 if i am not mistaken).
#define __ARMEN_H__
|
|
|
|
 |
|
 |
Knowledge Base article Q150448 says:
"The actual maximum length of a string resource for the resource compiler included with the Win32 SDK is 4097 characters."
And elsewhere on MSDN it says:
"LoadString(), the function for retrieving strings from string tables, doesn't automatically tell you how large your string buffer needs to be. The maximum length of a Win32 string resource is 4k characters (8k bytes), though some tools limit strings to a maximum of 256 bytes. Allocating a buffer using the system constant LARGE_SIZE should accommodate the longest string in your resource file, as in this example:"
|
|
|
|
 |
|
 |
Hi,
I would like to retrieve the default name that is applied when a new Shortcut file is created. I found out from your previous messages that this can be done. The value is present in String Table -> 1896 of the shell32.dll. I am using c# for my development. I am not sure how to get it to work with c#. It would be great if you guys can give me snippet of how to get this done.
Thank You.
--
Vinod
|
|
|
|
 |
|
 |
LoadString( GetModuleHandle( shell32.dll ), 1896, buffer, bufferLen );
#define __ARMEN_H__
|
|
|
|
 |
|
 |
Is there any method to read the attributes of a file, e.g. from what application it generated...just like information show on the advanced tabpage when U right-click for the file properities
|
|
|
|
 |
|
|
 |
|
 |
Dear,
I write a class that get file version too, but it 's not funtionly with a file store in server.
I use FileVersionInfo in C#
Althought C# # C++ but, may be you can help me.???
my email: germanrose_germanrose@yahoo.com
Thanks regards,
|
|
|
|
 |
|
 |
At last, a code that is well written adn convenient to use. Thanks for that, Armen!
|
|
|
|
 |
|
 |
The code looks neat but I hate to say this - it's not pratical.
I think most people use a class like this to display version info in "About" dialog box, and how many apps uses format like 1,0,0,1?? most applications display these numbers in a user friendly way: version 2.01 or something like that. This class is no use at all when it comes to that - you still need to call api to do it yourself.
|
|
|
|
 |
|
 |
You would like it to display your company name and telephone number ?
#define __ARMEN_H__
|
|
|
|
 |
|
 |
Then again, maybe this class can be of use for the ones who want to learn how to read and mess with version resources .. when I had to learn it myself with no example took a bit of time, if I had this at the time it would've made it much easier.
Most of the code posted on this site is here in the spirit to learn from what others are doing, not (or not only) to provide you with the exact class you need to copy&paste and save your time.. teach to fish, better than handing a fish and leave.
Just my thought.
|
|
|
|
 |
|
 |
I just found this piece of code and its exactly what I needed for a utility for our support... thanks man..
And for the creator of this thread... come on, if you need it in that format, then you just have to do a sprintf, right...
After all, if I would continue on that line, then I would say something like, come on guys, when you do your samples, cant you just do my job by asking me how I want it???
As someone else on this site said, the code is here for us to use AND CHANGE for our needs, not anything else, right?
Thanks man, you saved my day today... lol
|
|
|
|
 |
|
 |
This is perfectly good code! It is hardly reasonable to criticise a programmer because his example doesn't exactly fit your requirements: just modify it to suit your application.
|
|
|
|
 |
|
 |
Oh my god, it was so unpractical. I had to add ALL of the following lines of code by myself (to my app) !!
#include "FileVersionInfo.h"
void CPChamberDlg::setApplicationVersion()
{
CString sVersion;
CUtilsPackage::Version_u Version( 0 );
CFileVersionInfo VerInfo;
VerInfo.Open( AfxGetInstanceHandle() );
Version.nMajor = VerInfo.GetFileVersionMajor();
Version.nMinor = VerInfo.GetFileVersionMinor();
Version.nSub = VerInfo.GetFileVersionBuild();
Version.nPatch = VerInfo.GetFileVersionQFE();
sVersion.Format( "%d.%d.%d.%d",
Version.nMajor,
Version.nMinor,
Version.nSub,
Version.nPatch );
CUtilsPackage::setVersion( Version, m_AppCrypter.encrypt( sVersion ) );
}
Honestly, I am very pleased with this implementation. Very good and absolutly practical. Saved me a lot of boring time reading msdn.
Thanks a a lot for that
-- modified at 19:35 Tuesday 4th July, 2006
|
|
|
|
 |
|
 |
#pragma comment(lib, "Version.lib")
#define BUFFSIZE 65535
#ifdef UNICODE
#define ito_u _itow
#else
#define ito_u itoa
#endif
void GetFileVersionNumber(IN TCHAR* filename, OUT TCHAR* buffer)
{
LPBYTE m_lpbyVIB; // Pointer to version info block (VIB)
BOOL m_bValid; // Version info is loaded
VS_FIXEDFILEINFO m_vsffi; // Fixed File Info (FFI)
::ZeroMemory( &m_vsffi, sizeof( VS_FIXEDFILEINFO ) );
DWORD dwDummy = 0;
DWORD dwSize = ::GetFileVersionInfoSize(
const_cast< LPTSTR >( filename ), &dwDummy // Set to 0
);
if ( dwSize > 0 )
{
m_lpbyVIB = (LPBYTE)malloc( dwSize );
if ( m_lpbyVIB != NULL &&
::GetFileVersionInfo( const_cast< LPTSTR >( filename ),
0, dwSize, m_lpbyVIB ) )
{
UINT uLen = 0;
LPVOID lpVSFFI = NULL;
if ( ::VerQueryValue( m_lpbyVIB, _T( "\\" ), (LPVOID*)&lpVSFFI, &uLen ) )
{
::CopyMemory( &m_vsffi, lpVSFFI, sizeof( VS_FIXEDFILEINFO ) );
m_bValid = ( m_vsffi.dwSignature == VS_FFI_SIGNATURE );
}
}
WORD FileVersionMajor = HIWORD( m_vsffi.dwFileVersionMS );
WORD FileVersionMinor = LOWORD( m_vsffi.dwFileVersionMS );
WORD FileVersionBuild = HIWORD( m_vsffi.dwFileVersionLS );
WORD FileVersionQFE = LOWORD( m_vsffi.dwFileVersionLS );
TCHAR* tmp;
tmp = new TCHAR[10];
ito_u(FileVersionMajor, tmp, 10);
_tcscpy(buffer, tmp);
_tcsncat(buffer, _T("."), BUFFSIZE);
ito_u(FileVersionMinor, tmp, 10);
_tcsncat(buffer, tmp, BUFFSIZE);
_tcsncat(buffer, _T("."), BUFFSIZE);
ito_u(FileVersionBuild, tmp, 10);
_tcsncat(buffer, tmp, BUFFSIZE);
_tcsncat(buffer, _T("."), BUFFSIZE);
ito_u(FileVersionQFE, tmp, 10);
_tcsncat(buffer, tmp, BUFFSIZE);
delete[] tmp;
::ZeroMemory( &m_vsffi, sizeof( VS_FIXEDFILEINFO ) );
free( m_lpbyVIB );
}
};
Using:
TCHAR* tmp;
tmp = new TCHAR[100];
GetFileVersionNumber(_T("C:\\example\\example.exe"), tmp);
::SetWindowText(GetDlgItem(IDC_VERSION), tmp);
delete[] tmp;
|
|
|
|
 |
|
 |
I Think, a call like
CString string;
GetVersionInfo(string);
should crash (?)
maybe, i'm wrong, i avoid to use any code containing const_cast<>'s because its spoiling code too much...
therefore, i haven't testes it...
BOOL CFileVersionInfo::GetVersionInfo( IN LPCTSTR lpszFileName )
{
DWORD dwDummy = 0;
DWORD dwSize = ::GetFileVersionInfoSize(
const_cast< LPTSTR >( lpszFileName ), &dwDummy // Set to 0
...
|
|
|
|
 |
|
 |
Thanks!
|
|
|
|
 |
|
 |
very nice. I found no flaws in your program and it worked like it was supposed to THX.
[It is possible to represent everything in this universe by using 0 and 1]
I'm going to live forever or die trying.
|
|
|
|
 |