i would like to know how i would take the integer from an editbox and put it into a number. and then save the variable to a file?

this is my code so far but it doesnt work right

invoke GetDlgItemInt,hWin,IDC_EDT1,addr timer,TRUE

invoke CreateFile,ADDR _source,\

mov hFile, eax
invoke WriteFile,hFile,ADDR timer,4,ADDR SizeReadWrite,NULL
invoke CloseHandle,hFile

Posted on 2003-12-21 23:22:18 by njkt809
You are doing it wrongly

invoke GetDlgItemInt,hWin,IDC_EDT1,0,TRUE
push 0
push offset SizeReadWrite
push 4
push eax
invoke CreateFile,ADDR _source,\
push eax
push eax
call WriteFile
call CloseHandle
Posted on 2003-12-21 23:30:31 by roticv
err ok, the info from the edit box is user defined, will that still work?!?
Posted on 2003-12-21 23:32:25 by njkt809
GetDlgItemInt returns the int but WriteFile expecta a pointer to the data to be written to the file so the value in eax will be interpreted wrongly.
How do you want to save the intinger? As raw bytes or a text representation? If you want to save it as text use GetDlgItemText and call writeFile with the address of the buffer. If you want to save it as raw bytes then use GetDlgItemInt
Posted on 2003-12-21 23:43:27 by ENF
raw byte would work if i was to load the same file from a different program?
Posted on 2003-12-21 23:46:50 by njkt809
depends on the program. if you opend the file in notepad or any other text editor and the int was saved as raw bytes then it would not be displayed correctly, but it would be visible in a hex editor.
Posted on 2003-12-22 00:16:35 by ENF
err ok well this is what im doing,
i have this program that writes to a file and another program that reads the file and executes whatever is written in the file like if it was a timer it would start counting down from the time that is specified in the file.
Posted on 2003-12-22 00:18:33 by njkt809
I would use a SYSTEMTIME structure and write that to the file followed by the command line. The structure can be written in binary format and since it is a fixed length it would not be difficult to parse. This would allow you to use a DateTimePicker control and use the raw data that it returns when selecting a date and time.
Posted on 2003-12-22 00:30:41 by donkey
err that wont work, how i have my program set up is that it counts down the time then something happens, i need it to also be user defined (the timer's time, heh)
Posted on 2003-12-22 00:50:27 by njkt809
Yeah sorry, I just reread your post, I was thinking along the lines of a task scheduler.
Posted on 2003-12-22 01:13:06 by donkey
aeh, any ideas?
this is the only part thats stalling my application.
Posted on 2003-12-22 14:44:34 by njkt809
Well assuming that your timer is a dword in dwCountDown and your command line is a string in szCommand.


invoke WriteFile,hFile, dwCountDown, 4, ADDR cbWrite, NULL
invoke lstrlen,OFFSET szCommand
mov ecx,eax
invoke WriteFile, hFile, OFFSET szCommand, ecx, ADDR cbWrite, NULL
; you might like to write a 0 here to delimit the items
Posted on 2003-12-22 14:57:27 by donkey
Hmm? I think there is some confusion here. Maybe we could wait with the drinking until after Christmas :P
This is how it should be done:
push esi

xor esi,esi
invoke GetDlgItemInt,hWin,IDC_EDT1,esi,1
push eax
invoke CreateFile,ADDR _source,GENERIC_WRITE,\
mov ecx,esp
push eax
push esi
push offset SizeReadWrite
push 4
push ecx
push eax
call WriteFile
call CloseHandle
pop eax
pop esi
Posted on 2003-12-23 08:03:39 by Sephiroth3