[Migrated content. Thread originally posted on 07 July 2009]
I want to receive the installed Software from registry.current state of my source is this:
identification division.
program-id. registry.
*************************************************************
* *
* Registry auslesen - installierte Software *
* *
*************************************************************
author. David Neidinger.
date-written. Juli-2009.
environment division.
configuration section.
special-names.
decimal-point is comma.
input-output section.
***********************************************************
file-control.
data division.
file section.
***********************************************************
working-storage section.
78 newline value x"0A".
77 reg-ndx pic 9(3) value zeroes.
77 reg-subkey-n pic x(255) value spaces.
77 reg-subkey-s pic 9(4) value 255.
77 reg-status pic s9(4) value zeroes.
77 reg-handle-k usage is unsigned-long.
77 reg-handle-q usage is unsigned-long.
77 reg-size-q usage is unsigned-long.
77 reg-qname pic x(255) value spaces.
77 reg-qversion pic x(255) value spaces.
77 reg-qcomments pic x(255) value spaces.
77 reg-qdate pic x(255) value spaces.
77 reg-qpublisher pic x(255) value spaces.
78 reg-uninstall value
"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall".
copy "acugui.def".
***********************************************************
procedure division.
declaratives.
end declaratives.
***********************************************************
main section.
move zeroes to reg-ndx.
*** open uninstall path
call "REG_OPEN_KEY" using HKEY_LOCAL_MACHINE,
reg-uninstall,
reg-handle-k,
giving reg-status.
if reg-status not = zeroes
display message box "error open " reg-status
go to main-finish
end-if.
main-loop.
compute reg-ndx = reg-ndx 1 end-compute.
*** Get # key-name from uninstall path
call "REG_ENUM_KEY" using reg-handle-k,
reg-ndx,
reg-subkey-n,
reg-subkey-s,
giving reg-status.
if reg-status not = zeroes
display message box "error enum " reg-status
" " reg-subkey-n
" " reg-subkey-s
go to main-finish
end-if.
*** Open Subkey ***
call "REG_OPEN_KEY" using reg-handle-k,
reg-subkey-n,
reg-handle-q
giving reg-status.
if reg-status not = zeroes
display message box "error open subkey " reg-status
go to main-finish
end-if.
*** Get DisplayName
call "REG_QUERY_VALUE_EX" using reg-handle-q,
"DisplayName",
"REG_SZ",
reg-qname,
reg-size-q,
giving reg-status.
if reg-status not = zeroes
move "Error" to reg-qname
move reg-status to reg-qname(6:)
end-if.
*** Get DisplayVersion
call "REG_QUERY_VALUE_EX" using reg-handle-q,
"DisplayVersion",
"REG_SZ",
reg-qversion,
reg-size-q,
giving reg-status.
if reg-status not = zeroes
move "Error" to reg-qversion
move reg-status to reg-qversion(6:)
end-if.
*** Get Comments
call "REG_QUERY_VALUE_EX" using reg-handle-q,
"Comments",
"REG_SZ",
reg-qcomments,
reg-size-q,
giving reg-status.
if reg-status not = zeroes
move "Error" to reg-qcomments
move reg-status to reg-qcomments(6:)
end-if.
*** Get InstallDate
call "REG_QUERY_VALUE_EX" using reg-handle-q,
"InstallDate",
"REG_SZ",
reg-qdate,
reg-size-q,
giving reg-status.
if reg-status not = zeroes
move "Error" to reg-qdate
move reg-status to reg-qdate(6:)
end-if.
*** Get Publisher
call "REG_QUERY_VALUE_EX" using reg-handle-q,
"Publisher",
"REG_SZ",
reg-qpublisher,
reg-size-q,
giving reg-status.
if reg-status not = zeroes
move "Error" to reg-qpublisher
move reg-status to reg-qpublisher(6:)
end-if.
call "REG_CLOSE_KEY" using reg-handle-q.
display message box "Name: " reg-qname
newline "Version: " reg-qversion
newline "Comment: " reg-qcomments
newline "Date: " reg-qdate
newline "Publisher: " reg-qpublisher
title reg-subkey-n.
go to main-loop.
main-finish.
call "REG_CLOSE_KEY" using reg-handle-k.
stop run.
main-ende.
exit.
main-e.
***********************************************************
My Problem is at the moment that i get sometime the error 234 in the Status code when i use "REG_QUERY_VALUE_EX", but not always.
In the description from the Library Routines is the error 234 declared
A return status of `234' indicates that the size of the data to be returned in VALUE-DATA exceeds the buffer size specified by the DATA-SIZE parameter.
When i understand this i have the wrong parameter in reg-size-q specified. I moved several values in this field, but i never solved the problem.
- The value-data is always pic x(255) so i moved 255 (bytes) to req-size-q or i am wrong?
David



