Okay, I have a program with two static controls (LTEXT) which is changed to display two different values.  Here is some of the code (partial):


.data
szKey      db "Hardware\Description\System\CentralProcessor\0", 0
szValue    db "ProcessorNameString", 0
unText    db "User Name: ", 0
cpuText    db "Processor: ", 0
TheDataS  DWORD 512
loginNameS DWORD 257

.data?
loginName  db 257 dup(?) ; UNLEN (256) + 1
TheData    byte 512 dup(?)
TheReturn  DWORD ?

.const
IDS_UN          equ 3004
IDS_CPU        equ 3005

.code
invoke RegOpenKeyEx, HKEY_LOCAL_MACHINE, addr szKey, 0, KEY_READ, addr TheReturn
.if eax==ERROR_SUCCESS
invoke RegQueryValueEx, TheReturn, addr szValue, 0, 0, addr TheData, addr TheDataS
.if eax==ERROR_SUCCESS
invoke lstrcat, addr cpuText, addr TheData
invoke SetDlgItemText, hWnd, IDS_CPU, addr cpuText
.endif
invoke RegCloseKey, TheReturn
.endif
invoke GetUserName, addr loginName, addr loginNameS
.if eax != 0
invoke lstrcat, addr unText, addr loginName
invoke SetDlgItemText, hWnd, IDS_UN, addr unText
.else

invoke lstrcat, addr unText, CTEXT("N/A")
invoke SetDlgItemText, hWnd, IDS_UN, addr unText
.endif


The snippet for the CPU string works, and the user name part worked before I added the CPU part.  So, I am thinking something funky is going on with my variables.  Any guesses?  If I invoke a MessageBox with loginNameS it partially contains the result from the previous registry part.  Hmm...?
Posted on 2006-07-31 21:14:24 by klassasin
Probably lstrcat is giving you problems:


LPTSTR lstrcat(

? ? LPTSTR lpString1, // address of buffer for concatenated strings
? ? LPCTSTR lpString2 // address of string to add to string1
?  );


In your upper code you add for example the UserName to unText which is overwriting the cpuText. All of your lstrcats need to be replaced with a variant of below code.


mov TheData[0],0
invoke lstrcat, addr TheData, addr unText
invoke lstrcat, addr TheData, addr loginName
invoke SetDlgItemText, hWnd, IDS_UN, addr TheData

Posted on 2006-07-31 21:24:34 by JimmyClif
That did it!  Thanks.  It also makes perfect sense to me now! :D
Posted on 2006-07-31 21:34:48 by klassasin