im querying a certain registry entry. my query is successful because my messagebox appears. but the problem is that i get a square as the text for the messagebox. the registry entry contains a 3 as its setting. do i need to make some sort of conversion when after i do the querry?


        invoke RegOpenKeyEx,HKEY_CURRENT_USER,ADDR ValueLocation,0,KEY_QUERY_VALUE,addr hOpenKey
            .if eax == ERROR_SUCCESS
                invoke RegQueryValueEx,hOpenKey,addr ValueName,0,0,addr RegBuffer, addr MaxSize
                   .if eax == ERROR_SUCCESS
                       invoke MessageBox,hWin,addr RegBuffer,0,0
                   .endif
                invoke RegCloseKey,hOpenKey
            .endif
smurf
Posted on 2001-07-06 18:00:00 by smurf
Hi, no there''s no need to make any conversion, but I saw a mistake in your code which must cause the problem.:: you put : .......addr ValueName,0,0,addr ......... you shouldn''t put 0 (the second) because it''s where you set the value type (so a string here). you should put ''addr Type'' and before ''Type dd 0'' in data section and you set it : ''mov Type, REG_SZ'' This should work, if not, look at the code of a prog that I''ve made at www.vombonjour.fr.st (it''s called "Reg_en" if I remember correctly)
Posted on 2001-07-06 20:10:00 by Vom-bonjour:-()
here is my code. please test it for me and let me know if you find the problem. this will query your java settings in your registry. all i get is a message box that popups with a square where text should be.
.586
.model flat, stdcall
 option casemap :none
      
      include       /masm32/include/windows.inc
      include       /masm32/include/kernel32.inc
      include       /masm32/include/user32.inc
      includelib    /masm32/lib/kernel32.lib
      includelib    /masm32/lib/user32.lib
      includelib    /masm32/lib/Advapi32.lib
      include       /masm32/include/Advapi32.inc
      
      WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
      WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
      TopXY PROTO   :DWORD,:DWORD
      
.data
      ClassName         db "Starting Template",0
      CaptionText       db "Template",0
      ValueLocation     db "Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3",0
      ValueName         db "1402",0

      RegBuffer         db   256 dup (0)
      MaxSize           dd   256
      RegType           dd 0
       
.data?
      hWnd          HANDLE ?
      hInstance     HANDLE ?
      hOpenKey      HANDLE ?

.code
 start:
      invoke GetModuleHandle, NULL
      mov hInstance, eax
      invoke WinMain,hInstance,NULL,NULL,SW_SHOWDEFAULT
      invoke ExitProcess,eax

; ########################################################################

WinMain proc hInst     :DWORD,
             hPrevInst :DWORD,
             CmdLine   :DWORD,
             CmdShow   :DWORD

      ;====================
      ; Put LOCALs on stack
      ;====================

      LOCAL  wc   :WNDCLASSEX
      LOCAL  msg  :MSG
      LOCAL  Wwd  :DWORD
      LOCAL  Wht  :DWORD
      LOCAL  Wtx  :DWORD
      LOCAL  Wty  :DWORD

      ;==================================================
      ; Fill WNDCLASSEX structure with required variables
      ;==================================================

      mov    wc.cbSize,       SIZEOF WNDCLASSEX
	 mov    wc.style,        CS_HREDRAW + CS_VREDRAW
	 mov    wc.lpfnWndProc,  OFFSET WndProc
	 mov    wc.cbClsExtra,   NULL
	 mov    wc.cbWndExtra,   NULL
	 mov    eax,             hInstance
	 mov    wc.hInstance,    eax
     	 invoke LoadIcon,        NULL,IDI_APPLICATION
	 mov    wc.hIcon,        eax
	 mov    wc.hIconSm,      eax
	 invoke LoadCursor,      NULL,IDC_ARROW
	 mov    wc.hCursor,      eax
	 mov    wc.hbrBackground,COLOR_BTNFACE+1
	 mov    wc.lpszMenuName, NULL
	 mov    wc.lpszClassName,OFFSET ClassName


	 invoke RegisterClassEx, addr wc

      ;================================
      ; Centre window at following size
      ;================================

      mov    Wwd, 500
      mov    Wht, 350

      invoke GetSystemMetrics,SM_CXSCREEN
      invoke TopXY,Wwd,eax
      mov    Wtx, eax

      invoke GetSystemMetrics,SM_CYSCREEN
      invoke TopXY,Wht,eax
      mov    Wty, eax

      invoke CreateWindowEx,NULL,
     			     ADDR ClassName,
     			     ADDR CaptionText,
     			     WS_OVERLAPPEDWINDOW,
     			     Wtx,Wty,Wwd,Wht,
     			     NULL,
     			     NULL,
     			     hInst,
     			     NULL
      mov    hWnd,eax

      invoke ShowWindow,hWnd,SW_SHOWNORMAL
      invoke UpdateWindow,hWnd

      ;===================================
      ; Loop until PostQuitMessage is sent
      ;===================================

    StartLoop:
      invoke GetMessage,ADDR msg,NULL,0,0
      cmp eax, 0
      je ExitLoop
      invoke TranslateMessage, ADDR msg
      invoke DispatchMessage,  ADDR msg
      jmp StartLoop
    ExitLoop:

	mov     eax,msg.wParam
	ret

WinMain endp

; ########################################################################

WndProc proc hWin    :HWND,
			      uMsg    :UINT,
             wParam  :WPARAM,
             lParam  :LPARAM

     .IF uMsg==WM_DESTROY
		invoke PostQuitMessage,NULL

    .ELSEIF uMsg == WM_CREATE
        invoke RegOpenKeyEx,HKEY_CURRENT_USER,ADDR ValueLocati
Posted on 2001-07-07 00:05:00 by smurf
Make the following changes and it should work. fmat3 db ''%1d'',0 lpcbData dd ? Test4 dd ? Change from: invoke RegQueryValueEx,hOpenKey,addr ValueName,0,addr RegType,addr RegBuffer, addr MaxSize To: mov lpcbData, 4 invoke RegQueryValueEx,hOpenKey,addr ValueName,0,addr RegType,addr Test4, addr lpcbData .if eax == ERROR_SUCCESS INVOKE wsprintf, addr RegBuffer, addr fmat3, Test4 invoke MessageBox,0,addr RegBuffer,0,0 My 1402 shows a 0, but 1004 and 1201 shows a 3, Ewayne
Posted on 2001-07-07 01:58:00 by Ewayne
thank you ewayne that works perfectly. smurf
Posted on 2001-07-07 02:19:00 by smurf
Ewayne i have a minor problem. i cant figure out why this doesnt work.
.if eax == ERROR_SUCCESS
    INVOKE wsprintf, addr RegBuffer, addr fmat3, Test4
    mov eax,offset RegBuffer
        .if eax == 3
            invoke MessageBox,0,0,0,0
        .endif
why is it that when i check eax for 3 that my messagebox isnt invoked? using the code i posted i was able to invoke my messagebox and it displays 3. what could i be missing here? smurf
Posted on 2001-07-07 02:56:00 by smurf

mov eax,offset RegBuffer
.if eax == 3
  invoke MessageBox,0,0,0,0
.endif
Because you are comparing the offset of the RegBuffer with 3. You should check the first byte of RegBuffer for the string value 3: "3".

mov eax, offset RegBuffer
.if byte ptr =="3"
 invoke ...
.endif
But wouldn''t it be easier to just check the Test4 variable?

.if Test4==3
 invoke ...
.endif
Thomas
Posted on 2001-07-07 04:32:00 by Thomas
thanks thomas i had already figured it out the easy way as you had mensioned. now i have another problem im tring to figure out as i write this. im tring to query a registry entry that contains a string. my query is successful but im having problems checking to see whether or not the string queried matches the proper string. so basically i querry the string and try to compare it to itself (what it should be). how would i do this check with a string? hope this is clear. thanks smurf
Posted on 2001-07-07 04:56:00 by smurf
Just use a string compare function like lstrcmp(i) or one from the m32lib. Set one parameter to the offset of your buffer for the query (where the string is put by the query function), the other parameter to the offset of your string (what it should be) in the data section. Thomas
Posted on 2001-07-07 06:22:00 by Thomas