Hey, I've been having trouble with the RegQueryValueEx API...I keep getting an error saying "The system could not find the specified file". I'm assuming that lpszValueName parameter must be incorrect. I can open the key just fine, but I can't seem to read it. Does anyone know of any *good* registry tutorials, or have any advice for me about specifing regisrty paths??? Until then... *unknown*
Posted on 2001-04-15 14:46:00 by *unknown*
I answered some questions on writing and deleteing from registry, you can aply this to getting a value too, check this out and if it doesnt help post or drop me a line. Watching for Windows Start hope it helps :) -brad
Posted on 2001-04-15 16:03:00 by Rage9
.....yeah, I'm still having trouble with this. Here's the portion of my code. ------------------------------------------------ .386 .model flat, stdcall option casemap:none include C:\masm32\include\windows.inc include C:\masm32\include\kernel32.inc includelib C:\masm32\lib\kernel32.lib include C:\masm32\include\user32.inc includelib C:\masm32\lib\user32.lib include C:\masm32\include\comdlg32.inc includelib C:\masm32\lib\comdlg32.lib include C:\masm32\include\shell32.inc includelib C:\masm32\lib\shell32.lib include C:\masm32\include\advapi32.inc includelib C:\masm32\lib\advapi32.lib GetError PROTO :DWORD, :DWORD .data ... Reg_Key db "txtfile\shell\open\command\",0 Key_Name db "(Default)",0 QueryVal db "RegQueryValueEx",0 OpenKey db "RegOpenKeyEx",0 KeySize dd 200 .data? ... hKey dd ? Key_Value dd ? Key_Type dd ? Error dd ? .code start: ... invoke RegOpenKeyEx, HKEY_CLASSES_ROOT, ADDR Reg_Key, 0, KEY_ALL_ACCESS, ADDR hKey .IF EAX==ERROR_SUCCESS invoke RegQueryValueEx, HKEY_CLASSES_ROOT, ADDR Key_Name, NULL, ADDR Key_Type, ADDR Key_Value, ADDR KeySize .IF EAX==ERROR_SUCCESS blah blah .ELSE invoke GetError, ADDR QueryVal, EAX .ENDIF .ELSE invoke GetError, ADDR OpenKey, EAX .ENDIF invoke RegCloseKey, hKey .ENDIF .ENDIF invoke ExitProcess, EAX GetError PROC MsgTitle:DWORD, ErrorVal:DWORD invoke FormatMessage, FORMAT_MESSAGE_FROM_SYSTEM, NULL, ErrorVal, LANG_NEUTRAL, ADDR Error, 512, NULL invoke MessageBox, NULL, ADDR Error, MsgTitle, MB_OK + MB_ICONERROR ret GetError endp end start -------------------------------------------------- .......it says that it "can't find the specified file", which I believe it's refering to the Key_Name value. I'm stuck :-( *unknown* This message was edited by *unknown*, on 4/16/2001 6:24:09 PM
Posted on 2001-04-16 18:20:00 by *unknown*

;------------------------------------------------

.386
.model flat, stdcall
option casemap:none

include C:\masm32\include\windows.inc
include C:\masm32\include\kernel32.inc
includelib C:\masm32\lib\kernel32.lib
include C:\masm32\include\user32.inc
includelib C:\masm32\lib\user32.lib
include C:\masm32\include\comdlg32.inc
includelib C:\masm32\lib\comdlg32.lib
include C:\masm32\include\shell32.inc
includelib C:\masm32\lib\shell32.lib
include C:\masm32\include\advapi32.inc
includelib C:\masm32\lib\advapi32.lib

GetError PROTO WORD, WORD

.data
...
Reg_Key db "txtfile\shell\open\command\",0
Key_Name db "(Default)",0
QueryVal db "RegQueryValueEx",0
OpenKey db "RegOpenKeyEx",0
KeySize dd 200

.data?
...
Key_Value dd ?
Key_Type dd ?
Error dd ?

.code
start:
LOCAL hKey:DWORD
...
invoke RegOpenKeyEx, HKEY_CLASSES_ROOT, ADDR Reg_Key,0, KEY_ALL_ACCESS, ADDR hKey
.IF EAX==ERROR_SUCCESS
invoke RegQueryValueEx, hkey, ADDR Key_Name, NULL, ADDR Key_Type, ADDR Key_Value, sizeof Key_Value
.IF EAX==ERROR_SUCCESS
blah blah
.ELSE
invoke GetError, ADDR QueryVal, EAX
.ENDIF
.ELSE
invoke GetError, ADDR OpenKey, EAX
.ENDIF
invoke RegCloseKey, hKey
.ENDIF
.ENDIF
invoke ExitProcess, EAX

GetError PROC MsgTitleWORD, ErrorValWORD
invoke FormatMessage, FORMAT_MESSAGE_FROM_SYSTEM, NULL, ErrorVal, LANG_NEUTRAL, ADDR Error, 512, NULL
invoke MessageBox, NULL, ADDR Error, MsgTitle, MB_OK + MB_ICONERROR
ret
GetError endp

end start

;--------------------------------------------------
havent tested it dont know if it will work.... are you sure "can't find the specified file" isnt one of your librarys or somthin? -brad
Posted on 2001-04-16 20:37:00 by Rage9
hey unknown, i guess brad is right, you have to include crypt32.inc/lib i'm not sure about it but it should work, because i had the same thing Hope that helps, Olli
Posted on 2001-04-16 22:16:00 by Typhoon
..........thanx for the advice, but still no go :-( I threw in the crypt32.inc/.lib and it made no difference. I kinda figured that because all the registry API's are in advapi32.inc/.lib........also, you cannot use SIZEOF, it is "an incorrect parameter". Do I have to RegQueryInfoKey before I can RegQueryValueEx? Still stuck, *unknown* This message was edited by *unknown*, on 4/17/2001 12:18:26 PM
Posted on 2001-04-17 01:05:00 by *unknown*