Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem using RegSetValueEx writing REG_DWORD's

Status
Not open for further replies.

finsys

Programmer
Jan 31, 2002
56
GB
I'm currently adapating one of our programs so that rather than printing to hardcopy, some reports will be saved as PDF documents.

I have succesfully used RegSetValueEx in ADVAPI32.DLL to write out the string value (type REG_SZ in the registry) of the document name prior to PDF'ing, but I also need to set and unset another flag in the registry used by the PDF driver.

However, when I try to write out the flag setting (1 or 0),the registry ends up with silly numbers like 5f000031! I'm missing something critical with respect to writing out a REG_DWORD type but hours of Googling and searching on here later I'm still none the wiser. :(

Sample code for reference:
Code:
PUBLIC RESULT,DISPLAY
RESULT=0
DISPLAY=0
#DEFINE HKEY_CURRENT_USER 2147483649   && (HKEY) 0x80000001
#DEFINE SECURITY_ACCESS_MASK 983103     && SAM value KEY_ALL_ACCESS
#DEFINE REG_SZ 1 
#DEFINE REG_DWORD 4 

DECLARE RegCreateKeyEx IN ADVAPI32.DLL;
INTEGER,STRING,INTEGER,STRING,INTEGER,INTEGER,INTEGER,INTEGER @, INTEGER @
DECLARE RegSetValueEx IN ADVAPI32.DLL;
INTEGER,STRING,INTEGER,INTEGER,STRING,INTEGER

RegCreateKeyEx(HKEY_CURRENT_USER,"SOFTWARE\VERYPDF\PDFCAMP",0,"REG_SZ",;
0,SECURITY_ACCESS_MASK,0,@RESULT,@DISPLAY)  && Returns .T. if successful

OutputFile="c:\test4.pdf"
FileLen=LEN(OutputFile)+1
RegSetValueEx(RESULT,"AutomaticDirectory",0,REG_SZ,OutputFile,FileLen)

lnBit= "1"  && tried adding CHR(0) also but no help.
RegSetValueEx(RESULT,"AutomaticOutput",0,REG_DWORD,lnBit,4)

If I try to re-declare the RegSetValueEx call to define the data as an Integer, the call returns a success code, but no data changes in the registry.

Any help, gratefully appreciated!!
Ric
 
Sorry, spotted some unclear text....

When I say "silly numbers", I am expecting 0x00000001 as the DWORD value, but I'm getting a huge number like 0x5f000031. Even wirting out 0 comes back as 0x5f470030 instead of 0x00000000.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top