[Migrated content. Thread originally posted on 27 February 2004]
In my program I want to get the version number of a specific DLL (in this case AcuODBC.DLL) because I need diferent behaviors in function of that.
I've developed, entirely in AcuCOBOL, an interface to manage DSN's accessing the windows registry (user-friendly and support for more than 64 Alias)
I want to know what version of AcuODBC has the client installed programatically. This will allow me creating DSN's in the correct fashion for each version.
Is there anyway of doing this?
P.D. Sorry about my poor english.
[Migrated content. Thread originally posted on 27 February 2004]
In my program I want to get the version number of a specific DLL (in this case AcuODBC.DLL) because I need diferent behaviors in function of that.
I've developed, entirely in AcuCOBOL, an interface to manage DSN's accessing the windows registry (user-friendly and support for more than 64 Alias)
I want to know what version of AcuODBC has the client installed programatically. This will allow me creating DSN's in the correct fashion for each version.
Is there anyway of doing this?
P.D. Sorry about my poor english.
Yes, there is a way to inquire for a DLLs version, you should look up the GetFileVersionInfo function in the version.dll.
Be careful to read instructions, in particular the sequence about GetFileVersionInfoSize. Eventuallt VerQueryValue.
It is a bit tricky, but give it a try!
[Migrated content. Thread originally posted on 27 February 2004]
In my program I want to get the version number of a specific DLL (in this case AcuODBC.DLL) because I need diferent behaviors in function of that.
I've developed, entirely in AcuCOBOL, an interface to manage DSN's accessing the windows registry (user-friendly and support for more than 64 Alias)
I want to know what version of AcuODBC has the client installed programatically. This will allow me creating DSN's in the correct fashion for each version.
Is there anyway of doing this?
P.D. Sorry about my poor english.
Sorry, but I'm newbie in windows programming.
I think I'm in the way...
First (of course) loading of library:
SET ENVIRONMENT "DLL-CONVENTION" TO 1.
CALL "version.dll".Once loaded, obtain size of version information:
CALL "GetFileVersionInfoSizeA" USING
Dll_Path, Status
RETURNING Lenght.Next, getting of information block:
CALL "GetFileVersionInfoA" USING
Dll_Path, Void, BY VALUE Lenght, Buffer.and now, query block:
CALL "VerQueryValueA" USING
Buffer, String_to_Query, PTR_STRUCT, Struct_Lenght. Here is my problem:
The routine "VerQueryValue" returns a
pointer to a "VS_FIXEDFILEINFO" struct. How can I access this region of memory from COBOL ?
Really a bit tricky.
[Migrated content. Thread originally posted on 27 February 2004]
In my program I want to get the version number of a specific DLL (in this case AcuODBC.DLL) because I need diferent behaviors in function of that.
I've developed, entirely in AcuCOBOL, an interface to manage DSN's accessing the windows registry (user-friendly and support for more than 64 Alias)
I want to know what version of AcuODBC has the client installed programatically. This will allow me creating DSN's in the correct fashion for each version.
Is there anyway of doing this?
P.D. Sorry about my poor english.
Originally posted by kaitwo
Sorry, but I'm newbie in windows programming.
I think I'm in the way...
You indeed are. A few clues:
First, remember the BY VALUE and BY REFERENCE phrases that may be applied to CALL statements.
When passing strings (PIC X(..)), you always pass BY REFERENCE, when passing groups (structs in C) you pass BY REFERENCE as well.
The steps you will have to conclude is:
Use the length returned to create a dynamic memory size. This dynamic memory is then the pointer you will pass on.
Perhaps this could be a useful sample for the June class of the advanced Windows API and ActiveX/ COM training...
[Migrated content. Thread originally posted on 27 February 2004]
In my program I want to get the version number of a specific DLL (in this case AcuODBC.DLL) because I need diferent behaviors in function of that.
I've developed, entirely in AcuCOBOL, an interface to manage DSN's accessing the windows registry (user-friendly and support for more than 64 Alias)
I want to know what version of AcuODBC has the client installed programatically. This will allow me creating DSN's in the correct fashion for each version.
Is there anyway of doing this?
P.D. Sorry about my poor english.
Originally posted by kaitwo
Sorry, but I'm newbie in windows programming.
I think I'm in the way...
You indeed are. A few clues:
First, remember the BY VALUE and BY REFERENCE phrases that may be applied to CALL statements.
When passing strings (PIC X(..)), you always pass BY REFERENCE, when passing groups (structs in C) you pass BY REFERENCE as well.
The steps you will have to conclude is:
Use the length returned to create a dynamic memory size. This dynamic memory is then the pointer you will pass on.
Perhaps this could be a useful sample for the June class of the advanced Windows API and ActiveX/ COM training...
[Migrated content. Thread originally posted on 27 February 2004]
In my program I want to get the version number of a specific DLL (in this case AcuODBC.DLL) because I need diferent behaviors in function of that.
I've developed, entirely in AcuCOBOL, an interface to manage DSN's accessing the windows registry (user-friendly and support for more than 64 Alias)
I want to know what version of AcuODBC has the client installed programatically. This will allow me creating DSN's in the correct fashion for each version.
Is there anyway of doing this?
P.D. Sorry about my poor english.
Originally posted by kaitwo
Sorry, but I'm newbie in windows programming.
I think I'm in the way...
You indeed are. A few clues:
First, remember the BY VALUE and BY REFERENCE phrases that may be applied to CALL statements.
When passing strings (PIC X(..)), you always pass BY REFERENCE, when passing groups (structs in C) you pass BY REFERENCE as well.
The steps you will have to conclude is:
Use the length returned to create a dynamic memory size. This dynamic memory is then the pointer you will pass on.
Perhaps this could be a useful sample for the June class of the advanced Windows API and ActiveX/ COM training...
[Migrated content. Thread originally posted on 27 February 2004]
In my program I want to get the version number of a specific DLL (in this case AcuODBC.DLL) because I need diferent behaviors in function of that.
I've developed, entirely in AcuCOBOL, an interface to manage DSN's accessing the windows registry (user-friendly and support for more than 64 Alias)
I want to know what version of AcuODBC has the client installed programatically. This will allow me creating DSN's in the correct fashion for each version.
Is there anyway of doing this?
P.D. Sorry about my poor english.
I'm still trying... but unsuccessfully.
API-DLL-VERSION.
* Windows API Convention (Pascal).
SET ENVIRONMENT "DLL-CONVENTION" TO 1.
* Load Library.
CALL "version.dll".
* Get Raw Buffer Size.
MOVE "C:\\Acucorp\\Acucbl61\\bin\\AcuODBC.DLL" TO DLL-PATH.
INSPECT DLL-PATH REPLACING TRAILING SPACES BY X"00".
CALL "GetFileVersionInfoSizeA" USING
BY REFERENCE DLL-PATH
BY REFERENCE VOID
RETURNING RAW-LENGHT.
* Get Raw Info.
CALL "GetFileVersionInfoA" USING
BY REFERENCE DLL-PATH
BY VALUE VOID
BY VALUE RAW-LENGHT
BY REFERENCE RAW-BUFFER
RETURNING STATUS.
[b]* Create version info buffer.
CALL "M$ALLOC" USING 1024 STRUCT-POINTER.[/b]
* Get Fixed info.
MOVE "\\ " TO QUERY-STRING.
MOVE X"00" TO QUERY-STRING(2:1).
CALL "VerQueryValueA" USING
BY REFERENCE RAW-BUFFER
BY REFERENCE QUERY-STRING
[b]BY REFERENCE STRUCT-POINTER[/b]
[B]BY REFERENCE STRUCT-LENGHT[/B]
RETURNING STATUS.
[b]* Move memory to destination item.
CALL "M$GET" USING STRUCT-POINTER DEST-ITEM STRUCT-LENGHT.[/b]
* Free version info buffer.
CALL "M$FREE" USING W-PTR-STRUCT.
* Unload library.
CANCEL "version.dll".
* Cobol default convention (C).
SET ENVIRONMENT "DLL-CONVENTION" TO 0.
X-API-DLL-VERSION.
EXIT.
- All three API CALLs are performed correctly. OK.
- VerQueryValueA returns 52 for STRUCT-LENGHT. OK.
- STRUCT-POINTER is not NULL. OK
- DEST-ITEM doesn't changes (perhaps pointer problem ?, failure at M$GET ?, I'm confused...:confused: )Regards and help
[Migrated content. Thread originally posted on 27 February 2004]
In my program I want to get the version number of a specific DLL (in this case AcuODBC.DLL) because I need diferent behaviors in function of that.
I've developed, entirely in AcuCOBOL, an interface to manage DSN's accessing the windows registry (user-friendly and support for more than 64 Alias)
I want to know what version of AcuODBC has the client installed programatically. This will allow me creating DSN's in the correct fashion for each version.
Is there anyway of doing this?
P.D. Sorry about my poor english.
Originally posted by kaitwo
I'm still trying... but unsuccessfully.
Regards and help
This really isn't the best sample to learn to deal with the Windows API, it is a bit complex.
Here is a working example:
IDENTIFICATION DIVISION.
PROGRAM-ID. DLLVersion.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
WORKING-STORAGE SECTION.
77 BufSize PIC S9(9) COMP-5.
77 MEM-PTR PIC S9(9) COMP-5.
77 QRY-PTR PIC S9(9) COMP-5.
77 WS-STATUS PIC S9(9) COMP-5.
77 WS-DUMMY PIC X(4) COMP-N.
77 QRY-STR PIC X(64).
77 Vis-MS-Maj PIC ZZZ9.
77 Vis-MS-Min PIC 9(4).
77 Vis-LS-Maj PIC 9(4).
77 Vis-LS-Min PIC 9(4).
01 VS-FIXFILEINFO.
03 dwSignature PIC X(4) COMP-N.
03 dwStrucVersion PIC X(4) COMP-N.
03 dwFileVersionMS PIC X(4) COMP-N.
03 VersionMS-Hack redefines dwFileVersionMS.
05 FileMSLowVer pic x(2) COMP-N.
05 FileMSHghVer pic x(2) COMP-N.
03 dwFileVersionLS PIC X(4) COMP-N.
03 VersionLS-Hack redefines dwFileVersionLS.
05 FileLSLowVer pic x(2) COMP-N.
05 FileLSHghVer pic x(2) COMP-N.
03 dwProductVersionMS PIC X(4) COMP-N.
03 dwProductVersionLS PIC X(4) COMP-N.
03 dwFileFlagsMask PIC X(4) COMP-N.
03 dwFileFlags PIC X(4) COMP-N.
03 dwFileOS PIC X(4) COMP-N.
03 dwFileType PIC X(4) COMP-N.
03 dwFileSubtype PIC X(4) COMP-N.
03 dwFileDateMS PIC X(4) COMP-N.
03 dwFileDateLS PIC X(4) COMP-N.
PROCEDURE DIVISION.
MAIN-LOGIC.
INITIALIZE VS-FIXFILEINFO
QRY-PTR.
SET ENVIRONMENT "DLL-CONVENTION" TO 1.
CALL "VERSION.DLL".
STRING "USER32.DLL"
LOW-VALUES DELIMITED BY SIZE
INTO QRY-STR.
CALL "GetFileVersionInfoSizeA" USING
BY REFERENCE QRY-STR
BY REFERENCE WS-DUMMY
RETURNING BufSize.
CALL "M$ALLOC" USING
BufSize
MEM-PTR.
CALL "GetFileVersionInfoA" USING
BY REFERENCE QRY-STR
BY VALUE NULL
BY VALUE BufSize
BY VALUE MEM-PTR
RETURNING WS-STATUS.
STRING "\\"
LOW-VALUES DELIMITED BY SIZE INTO QRY-STR.
CALL "VerQueryValueA" USING
BY VALUE MEM-PTR
BY REFERENCE QRY-STR
BY REFERENCE QRY-PTR
BY REFERENCE WS-DUMMY
RETURNING WS-STATUS.
CALL "C$MEMCPY" USING
BY REFERENCE VS-FIXFILEINFO
BY VALUE QRY-PTR
BY VALUE 52. | (13 * 4 bytes)
MOVE FileMSHghVer TO Vis-MS-Maj.
MOVE FileMSLowVer TO Vis-MS-Min.
MOVE FileLSHghVer TO Vis-LS-Maj.
MOVE FileLSLowVer TO Vis-LS-Min.
DISPLAY "USER32.DLL File version info is:"
Vis-MS-Maj "." Vis-MS-Min "."
Vis-LS-Maj "." Vis-LS-min.
ACCEPT OMITTED.
CALL "M$FREE" USING MEM-PTR.
CANCEL "VERSION.DLL".
SET ENVIRONMENT "DLL-CONVENTION" TO 0.
STOP RUN.
I forgot to tell, there is in fact a single function you may call as well, DLLGetVersion(), it pretty much gives you all you need without all the hassle, the single catch with this is that it will not work with Win95, WinNT 3.51, Win 3.x. But hey, who uses those these days.
Enjoy.
Gisle
[Migrated content. Thread originally posted on 27 February 2004]
In my program I want to get the version number of a specific DLL (in this case AcuODBC.DLL) because I need diferent behaviors in function of that.
I've developed, entirely in AcuCOBOL, an interface to manage DSN's accessing the windows registry (user-friendly and support for more than 64 Alias)
I want to know what version of AcuODBC has the client installed programatically. This will allow me creating DSN's in the correct fashion for each version.
Is there anyway of doing this?
P.D. Sorry about my poor english.
I've got it !
[B]* Move memory to destination item (wrong).
CALL "M$GET" USING STRUCT-POINTER DEST-ITEM STRUCT-LENGHT.[/B]
has to be:
[B]* Move memory to destination item (right).
CALL "C$MEMCPY" USING
BY REFERENCE DEST-ITEM
BY VALUE STRUCT-POINTER
BY VALUE STRUCT-LENGHT.[/B]
I'll try
DLLGetVersion() although, nowadays, there are a few people still using such operating systems :mad:.
Thanks a lot Gisle.
[Migrated content. Thread originally posted on 27 February 2004]
In my program I want to get the version number of a specific DLL (in this case AcuODBC.DLL) because I need diferent behaviors in function of that.
I've developed, entirely in AcuCOBOL, an interface to manage DSN's accessing the windows registry (user-friendly and support for more than 64 Alias)
I want to know what version of AcuODBC has the client installed programatically. This will allow me creating DSN's in the correct fashion for each version.
Is there anyway of doing this?
P.D. Sorry about my poor english.
I've got it !
[B]* Move memory to destination item (wrong).
CALL "M$GET" USING STRUCT-POINTER DEST-ITEM STRUCT-LENGHT.[/B]
has to be:
[B]* Move memory to destination item (right).
CALL "C$MEMCPY" USING
BY REFERENCE DEST-ITEM
BY VALUE STRUCT-POINTER
BY VALUE STRUCT-LENGHT.[/B]
I'll try
DLLGetVersion() although, nowadays, there are a few people still using such operating systems :mad:.
Thanks a lot Gisle.
[Migrated content. Thread originally posted on 27 February 2004]
In my program I want to get the version number of a specific DLL (in this case AcuODBC.DLL) because I need diferent behaviors in function of that.
I've developed, entirely in AcuCOBOL, an interface to manage DSN's accessing the windows registry (user-friendly and support for more than 64 Alias)
I want to know what version of AcuODBC has the client installed programatically. This will allow me creating DSN's in the correct fashion for each version.
Is there anyway of doing this?
P.D. Sorry about my poor english.
I've got it !
[B]* Move memory to destination item (wrong).
CALL "M$GET" USING STRUCT-POINTER DEST-ITEM STRUCT-LENGHT.[/B]
has to be:
[B]* Move memory to destination item (right).
CALL "C$MEMCPY" USING
BY REFERENCE DEST-ITEM
BY VALUE STRUCT-POINTER
BY VALUE STRUCT-LENGHT.[/B]
I'll try
DLLGetVersion() although, nowadays, there are a few people still using such operating systems :mad:.
Thanks a lot Gisle.