;==============================================
; Пример чтения значения заданного параметра
; в заданной секции ini-файла
;==============================================
format PE

include "include\win32ax.inc"
include "include\const.inc"

x_size		= 340
y_size		= 150
x_coord 	= 100
y_coord 	= 100

EventID_Ctrl3		= 13

  start:
	; Читаем наш ini-файл в буффер
	mov	esi,ini_file_name
	mov	edi,ini_buff
	mov	eax,8
	int	0x90


	call	Redraw
      Wait_Event:
	call	[WaitMessage]
	call	[StdHandler]

	cmp	bx,(EventID_Ctrl3 shl 8) + 1
	jne	no_pressbutton

	mov esi,ini_buff      ; буффер ini-файла
	mov edi,ini_section   ; имя секции в ASCIIZ формате
	mov ebp,ini_param     ; имя параметра в ASCIIZ формате
	mov edx,ini_value     ; буффер для полученного значения параметра
	call	[ReadIniFile] ; Читаем значение параметра

	call	draw_info

      no_pressbutton:

	jmp	Wait_Event

Redraw:
	invoke	Draw_StdWindow, x_coord*65536+y_coord,x_size*65536+y_size,"INI demo",00111b
	mov [WinID],eax
	invoke	Write_Text,15,0x16+10,1,4,"Пример чтения ini-файла",[WinID]
	invoke	Write_Text,15,0x16+10+16,1,4,"Секция: ",[WinID]
	invoke	Write_Text,15,0x16+10+16*2,1,4,"Параметр:   ",[WinID]
	invoke	Write_Text,15,0x16+10+16*3,1,4,"Значение:   ",[WinID]

	invoke	Write_Text,15+100,0x16+10+16,0x0000FF,4,ini_section,[WinID]
	invoke	Write_Text,15+100,0x16+10+16*2,0x0000FF,4,ini_param,[WinID]
	invoke	Create_StdButton, 10*65536+100,50*65536+20,"Читать",1,10b
;        call draw_info
	ret

draw_info:
	invoke	Begin_xDraw, [WinID]
	invoke	Write_Text,15+100,0x16+10+16*3,0x0000FF,4,ini_value,[WinID]
	call	[End_of_redraw]
	ret

data import
;
; Import functions:
;

  library mx32,'mx32.dll'

  import mx32,\
	 WaitMessage,'WaitMessage',\
	 Write_Text,'Write_Text',\
	 Draw_StdWindow,'Draw_StdWindow',\
	 StdHandler,'StdHandler',\
	 End_of_redraw,'End_of_redraw',\
	 Begin_xDraw,'Begin_xDraw',\
	 ReadIniFile,'ReadIniFile',\
	 Create_StdButton,'Create_StdButton'
end data

section '.data' data readable writeable
WinID  dd 0

ini_file_name:
db 'test.ini',0

ini_section:
db 'MYTESTSECTION'
;rb 255
db 0
ini_param:
db 'MYTESTPARAMETER'
;rb 255
db 0
ini_value:
rb 255
db 0

ini_buff:
