I call "GetCommandLine" & copy result (a port number) in a buffer.Then i need to pass this number to "htons" function. ?How?

I know "GetDlgItemInt" but i have the value in a buffer ...

Posted on 2002-01-25 14:11:27 by elmenda
I don't know if this will help you or not but i been learning how to use buffers and it seem like it take a little trick to make it work....Once I put a notepad path in a buffer and tried to execute it but it did not work... So I strlen it into another buffer and than it executed....Than i got really intrested in buffers...

The funny thing was when i look at what was in each buffer with a messagebox they both had the full path in it....

So your lenght is impotant and must be tight....

Do a write to file just to make sure that everything is coming up right. Don't totally relie on what you see in a MESSAGE BOX. That buffer might have more than you want in it and that box may not show you...

See Buffer Hell post and you might get a darn good idea where the problem lay...and where i'm coming from....

I am trying to put an values like a Color value and what not to make stuff available for quick use....Hav'nt got to it just yet...

Hope this give you some kind of idea...
But im not really that good yet....and may be all wrong...
Posted on 2002-01-25 16:49:46 by cmax
The dwtoa function in the masmlib will convert an ascii string to a dword value.

You need to pass a pointer to the first digit of the number to the function. The string need to be null terminated also.
Posted on 2002-01-25 17:01:19 by Eóin
;;;Verify below two line:

invoke GetCommandLine
invoke MesageBox, NULL, eax, NULL, NULL

;; messageBox shows like this,
;;if your app is "abc" and arg is "123"
;;"abc 123" -> appname and is arg1, arg2...

;; your first code may be such like this

invoke GetCL, 1, addr buffer ;;;internally call GetCommandLine
invoke SetDlgitemText, hDlg, nIDDlg, addr buffer, maxbuffsize

;;; After this you can "invoke GetDlgItemInt" and get right value.
Posted on 2002-01-25 19:56:06 by muzidowa
I dont use a window or dialog ... i cant call "SetDlgitemText" and then "GetDlgItemInt" ....
Posted on 2002-01-26 04:34:11 by elmenda
C:\myprogram 60234


invoke GetCommandLine

buffer db 6 dup(?) <- contains "60234"


Then i need to pass "60234" to "htons" function (winsock related).
Posted on 2002-01-26 04:37:35 by elmenda
I'm sorry, I told you to use the dwtoa function, actually that converts dword to an ascii string. I should have told you to use atodw.

To use it you'll need to include the Masm32 Library:

include \masm32\include\masm32.inc
includelib \masm32\lib\masm32.lib

Then you'll need to ensure the string in buffer is null terminated. Since the buffer is of length 6 and your string is only 5 digits then it probably already is nulll terminated. But just in case its not, it is very easy to fix:

mov buffer[5],0

With that all you'll need to do is call atodw and then eax will contain 60234.

invoke atodw,addr buffer

You can the store the value for use later, or pass it directly to a function, eg:

invoke htons,blah,blah,eax,blah

P.S I haven't read up on the htons functions so I just guessed the parameters there ;)
Posted on 2002-01-26 07:17:50 by Eóin
invoke atodw, ADDR buffer <- WORK
invoke a2dw, ADDR buffer <- DOESNT WORK

It is this normal? i think two functions make the same, but Iczelion`s one doesnt work ...

Posted on 2002-01-26 14:24:08 by elmenda