The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: skywalker on March 28, 2006, 09:42:09 PM

Title: undefined symbol error
Post by: skywalker on March 28, 2006, 09:42:09 PM
I am getting an undefined symbol for SHDeleteKey.
I did a google and altavista search for some help but couldn't find anything.

; SHdelete.asm   Delete a key and it's subkeys
;
    .386
    .model flat, stdcall
    option casemap :none   ; case sensitive

include     \masm32\include\windows.inc
include     \masm32\include\user32.inc
include     \masm32\include\kernel32.inc
include     \masm32\include\advapi32.inc

includelib  \masm32\lib\user32.lib
includelib  \masm32\lib\kernel32.lib
includelib  \masm32\lib\advapi32.lib
includelib  \masm32\lib\shlwapi.lib

.data

szKeyName       BYTE      "Software\MASM\Registry Test\",0

.code

start:

invoke SHDeleteKey,HKEY_LOCAL_MACHINE,ADDR szKeyName
invoke ExitProcess,NULL

end start
Title: Re: undefined symbol error
Post by: donkey on March 28, 2006, 09:53:07 PM
You have to include the .inc file for SHLWAPI as well as the lib file otherwise the PROTO is not defined.

include  \masm32\include\shlwapi.inc

if that doesn't work, it is a string function so try SHDeleteKeyA
Title: Re: undefined symbol error
Post by: skywalker on March 28, 2006, 11:13:48 PM
Quote from: donkey on March 28, 2006, 09:53:07 PM
You have to include the .inc file for SHLWAPI as well as the lib file otherwise the PROTO is not defined.

include  \masm32\include\shlwapi.inc

if that doesn't work, it is a string function so try SHDeleteKeyA

Thanks, it worked like a champ.

This is another question on some other code.
Is the fn a macro in the macros.asm file ?

I am having difficulty knowing when to use invoke and fn.
The code is working like I want.


fn WriteProfileString, Offset szname, ADDR key, ADDR value
fn GetProfileInt,Offset szname,ADDR key,0

;int 3           ; see if the value matches what should be there
.if EAX==45
;put your code here

invoke MessageBox, 0, ADDR valueOK, ADDR Sample,MB_ICONINFORMATION
Title: Re: undefined symbol error
Post by: MichaelW on March 29, 2006, 01:14:28 AM
The fn macro just adds quoted text support, so it is useful only when you are passing quoted strings. The rv macro adds quoted text support and returns eax, so you can use statements like this:

mov   hInstance, rv(GetModuleHandle, "test")


Title: Re: undefined symbol error
Post by: skywalker on March 29, 2006, 02:19:26 PM
Quote from: MichaelW on March 29, 2006, 01:14:28 AM
The fn macro just adds quoted text support, so it is useful only when you are passing quoted strings. The rv macro adds quoted text support and returns eax, so you can use statements like this:

mov   hInstance, rv(GetModuleHandle, "test")


Thanks, I'll study it.