so thanks to everyone's help I can now enumerate users via MessageBoxW, and I can also populate a listbox, but I cannot seem to populate the listbox with the same data that I can display using MessageBoxW.  I have checked the api help files but it does not shed any light on this for me.

Here is a code fragment:

			mov esi,user_name
cmp ebx,entriesread
jae skip
mov eax,
mov tempstring,eax
invoke SendMessage,hInstance,LB_ADDSTRING,0,tempstring
invoke MessageBoxW,0,tempstring,0,0

Now, the MessageBoxW displays tempstring fine. But the SendMessage to the listbox only displays the first Character of the tempstring on each iteration.

Can someone point me in the right direction?

ps Don't suggest putting addr in front of tempstring in the SendMessage call, as it only displays gobbledegook that way.    :lol:
Posted on 2006-01-03 05:40:22 by WongDai
Maybe try SendMessageW. SendMessage by itself is treated as SendMessageA and therefore cuts off tempstring after the first 0 terminator, which is after the first letter. Unicode strings are double zero terminated.
Posted on 2006-01-03 06:55:57 by JimmyClif
Thanks Jimmy

That worked a treat.

I'm learning every day.  8)

Posted on 2006-01-03 07:52:15 by WongDai
WongDai, when dealing with unicode, you should use include files that are all-unicode... mixing is not good for your health :)
Posted on 2006-01-03 07:56:40 by f0dder
Thanks Fodder

So are you saying my includes should all end in W? 

So instead of
include netapi32.inc

it should be
include netapi32W.inc  ?

And does this go for the includelib as well?

Posted on 2006-01-03 18:54:39 by WongDai
OK, now I have a list of users appearing in my listbox.

Is this the correct way to retrieve the one a user has selected?

invoke SendMessage,hInstance,LB_GETCURSEL,0,0  ; hInstance is the handle of the listbox
mov tempstring,eax                                            ; I assume it returns the selectoin to eax
invoke MessageBox,hWin,tempstring,SADD("User"),MB_ICONINFORMATION

..and then it all falls over.  :sad:

Posted on 2006-01-04 06:50:55 by WongDai
LB_GETCURSEL only retrieves the index (number) of the item which is currently selected in your listbox. If you want the Text you might consider using LB_GETTEXT


And watch those Unicode Api's.
Posted on 2006-01-04 06:58:56 by JimmyClif
Thanks Jimmy

I still don't get which are unicode api's but I am persisting.
Posted on 2006-01-09 23:08:31 by WongDai

MessageBox equ <MessageBoxA>


So just use MessageBoxW for unicode and MessageBox for ansi. Other definitions of functions that work with strings also
follow that rule.
Posted on 2006-01-10 05:29:43 by k3Eahn
I'm b-a-a-a-ck!

(I got a bit depressed over the New Year that I wasn't getting anywhere, but am back now with renewed determination!)

Ok, take a look at the following code fragment plz.

user_string db '                                    ',0

push eax                                                                                    ; store away eax
invoke SendMessageW,hInstance,LB_GETCURSEL,0,0                        ; gets the current selection indexed into eax
invoke SendMessageW,hInstance,LB_GETTEXT,eax,addr user_string    ; retrieves the text in the listbox into user_string
invoke MessageBoxW,hWin,user_string,NULL,MB_ICONINFORMATION  ; display user_string in a message box
pop eax                                                                                      ; restore eax

Problem is the MessageBox displays nothing.  The GETCURSEL is working though.

What am I doing wrong (again)?

Posted on 2006-01-19 01:46:28 by WongDai
invoke MessageBoxW,hWin,addr user_string,NULL,MB_ICONINFORMATION
Posted on 2006-01-19 05:45:26 by JimmyClif
Thanks Jimmy

Tried that, but all I get is strange characters in the dialogue box.

Any other ideas?

Posted on 2006-01-19 18:47:17 by WongDai
Here is the defi for LB_GETTEXT:


wParam = (WPARAM) index;                // item index
lParam = (LPARAM) (LPCTSTR) lpszBuffer; // address of buffer

Perhaps I should be setting up user_string differently?

Posted on 2006-01-19 19:10:54 by WongDai

That was it!

I changed the user_string def to

user_string LPCTSTR <>

and it worked!

Can someone tell me what the <> means?  Is that just dynamic allocation of an array?

Posted on 2006-01-19 19:13:01 by WongDai