Specify DLL version when using mc.exe, rc.exe and/or link.exe

Specify DLL version when using mc.exe, rc.exe and/or link.exe

Post by Tony Toew » Mon, 16 Aug 2010 12:39:27


Folks

I'm creating a single entry DLL for the OS application event log so
developers and admin types don't get that ugly message when looking at
errors in the event log.

I've got the following make file which is working but I see the dll
produced does not have a version property like most DLLs and EXEs.
Any ideas on how to do such? Any better newsgroups/forums to ask
this question?

del "test.dll"
"C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin\mc.exe" MsgFile.mc
"C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin\rc" -r -fo
MsgFile.res MsgFile.rc
del MSG00001.bin
del MsgFile.h
del MsgFile.rc
"C:\Program Files\Microsoft Visual Studio\VB98\link" /nologo /NOENTRY
/subsystem:windows /dll /machine:I386 /out:"test.dll" MsgFile.res
del msgfile.res

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.yqcomputer.com/
Tony's Microsoft Access Blog - http://www.yqcomputer.com/
For a convenient utility to keep your users FEs and other files
updated see http://www.yqcomputer.com/
 
 
 

Specify DLL version when using mc.exe, rc.exe and/or link.exe

Post by Tony Toew » Mon, 16 Aug 2010 14:38:09

On Sat, 14 Aug 2010 21:39:27 -0600, Tony Toews



That should be

creating a single entry message file DLL for


This page http://www.yqcomputer.com/
have a lot of what I need if I can figure it out. I'm sorta making
progress.

Tony

--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.yqcomputer.com/
Tony's Microsoft Access Blog - http://www.yqcomputer.com/
For a convenient utility to keep your users FEs and other files
updated see http://www.yqcomputer.com/

 
 
 

Specify DLL version when using mc.exe, rc.exe and/or link.exe

Post by Nobod » Tue, 17 Aug 2010 00:25:58

irst, in order to provide the DLL to Event Viewer so the messages look like
what you want, you need to add a subkey and values to HKLM, and a limited
user can't write to it, so this need to be added in an installer. Here is
the subkey that you need to add:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\AutoFEUpdater

And you need to add 2 values in the subkey above:

EventMessageFile(REG_SZ)=<Full path to DLL or EXE with MSG00001.bin added as
a resource>
TypesSupported(REG_DWORD)=7

"7" in TypesSupported means support for Error, Warning, and Information
types.

So to use a custom DLL, you need to add the values above first. Your users'
admins probably could do that if they use PsExec to run RegEdit silently and
remotely. They can also do it from RegEdit-->File-->Connect to Network
Registry, and specify the remote computer name to see its registry. You can
also do it in VB by calling RegConnectRegistry() and specify the computer
name. Randy Birch site has code to list computers in a domain, so it can be
done from your software, however, that function would return
ERROR_ACCESS_DENIED(5) if the user didn't use "Run as Administrator" to run
your program.

As for version information, you need to add the following to the RC file,
and change as needed:

////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", "My Company\0"
VALUE "FileDescription", "Auto FE Updater Event Log Messages\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "AutoFEUpdater\0"
VALUE "LegalCopyright", "\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "AutoFEUpdaterLog.dll\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "Auto FE Updater Event Log Messages\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END



Change FILEVERSION and PRODUCTVERSION, including in the block that lists
VALUE's to what you want. The way you are doing it is not the only way, you
can make the DLL in VB. Compile "mc" file into "bin" file as usual but
without the version resource, as VB adds that for you, then add MSG00001.bin
as a resource to your project using "Visual Basic 6 Resource Editor" Add-in.
You can add it to your EXE, but if Event Viewer is open, it maybe keeping
the file loaded, so it would be difficult to replace.

For those curious what the OP is talking about, when you use the following
line of code in VB:

App.LogEvent "Message from VB6.", vbLogEventTypeInformation

The event source in Event Viewer shows "VBRuntime", and here is what is
logged(The URL is also added by the VB runtime, and not by the OS):

=================

Event Type: Information
Event Source: VBRuntime
Event Category: None
Event ID: 1
Date: 8/15/2010
Time: 10:24:37 AM
User: N/A
Computer: MYPC
Description:
The VB Application identified by the event source logged this Application
Project1: Thread ID: 4
 
 
 

Specify DLL version when using mc.exe, rc.exe and/or link.exe

Post by Tony Toew » Tue, 17 Aug 2010 13:45:07

On Sun, 15 Aug 2010 11:25:58 -0400, "Nobody" < XXXX@XXXXX.COM >



Already done that. I've got Wix working quite nicely generating an
MSI file.


Interesting because in my testing you don't need the TypesSupported
registry key. You do need the EventMessageFile registry key.

Side note. The users don't need the above DLL or registry key to
record the entries. The folks, such as the developers or admins, who
view the event log do need the DLL and registry key.


I added what you specified and I still can't see the version info tab
when I right click on the DLL. I doubled checked the .res and the
.dll file produced using Notepad and the information specified was in
there

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.yqcomputer.com/
Tony's Microsoft Access Blog - http://www.yqcomputer.com/
For a convenient utility to keep your users FEs and other files
updated see http://www.yqcomputer.com/
 
 
 

Specify DLL version when using mc.exe, rc.exe and/or link.exe

Post by Nobod » Tue, 17 Aug 2010 20:34:05


If you have VC6, then remove the changes, and open the RC file, then go to
Insert-->Resource-->Version, and just type the information. Unfortunately,
you can't edit RC files in the express versions of VC. If you don't have
VC6, then try some of the software listed in this page:

http://www.yqcomputer.com/ %28Windows%29

Among the free ones, ResEdit and XN Resource Editor seem to be able to
import RC files.
 
 
 

Specify DLL version when using mc.exe, rc.exe and/or link.exe

Post by Tony Toew » Thu, 19 Aug 2010 13:08:29

On Mon, 16 Aug 2010 07:34:05 -0400, "Nobody" < XXXX@XXXXX.COM >



I do but not installed. I'll try installing it and see if that works


So I tried ResEdit. It put in a few slightly different lines/syntax
than you have along with all kinds of external variables. So I tried
importing the various .h files required from the SDK folder until it
complained about a file called sal.h. Which might be in the VC folder
that I'll install later.

So then I tried taking the ResEdit file it produced and replacing the
constants with the values from your file. Compiled cleanly but still
no version properties.

I then tried the XN Resource Editor which inserted the data directly
into into a RES file rather than the RC file. I then ran the Link
and still no version number when I right clicked the DLL.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.yqcomputer.com/
Tony's Microsoft Access Blog - http://www.yqcomputer.com/
For a convenient utility to keep your users FEs and other files
updated see http://www.yqcomputer.com/