You are on page 1of 338

#RequireAdmin

#Region Includes
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const
Global Const

$color_aqua = 65535
$color_black = 0
$color_blue = 255
$color_cream = 16776176
$color_fuchsia = 16711935
$color_gray = 8421504
$color_green = 32768
$color_lime = 65280
$color_maroon = 9116770
$color_medblue = 708
$color_medgray = 10526884
$color_moneygreen = 12639424
$color_navy = 128
$color_olive = 8421376
$color_purple = 8388736
$color_red = 16711680
$color_silver = 12632256
$color_skyblue = 10930928
$color_teal = 32896
$color_white = 16777215
$color_yellow = 16776960
$clr_none = -1
$clr_default = -16777216
$clr_aqua = 16776960
$clr_black = 0
$clr_blue = 16711680
$clr_cream = 15793151
$clr_fuchsia = 16711935
$clr_gray = 8421504
$clr_green = 32768
$clr_lime = 65280
$clr_maroon = 6429835
$clr_medblue = 12845568
$clr_medgray = 10789024
$clr_moneygreen = 12639424
$clr_navy = 8388608
$clr_olive = 32896
$clr_purple = 8388736
$clr_red = 255
$clr_silver = 12632256
$clr_skyblue = 15780518
$clr_teal = 8421376
$clr_white = 16777215
$clr_yellow = 65535
$cc_anycolor = 256
$cc_fullopen = 2
$cc_rgbinit = 1
$bs_groupbox = 7
$bs_bottom = 2048
$bs_center = 768
$bs_defpushbutton = 1
$bs_left = 256
$bs_multiline = 8192
$bs_pushbox = 10
$bs_pushlike = 4096
$bs_right = 512
$bs_rightbutton = 32
$bs_top = 1024

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$bs_vcenter = 3072
$bs_flat = 32768
$bs_icon = 64
$bs_bitmap = 128
$bs_notify = 16384
$bs_splitbutton = 12
$bs_defsplitbutton = 13
$bs_commandlink = 14
$bs_defcommandlink = 15
$bcsif_glyph = 1
$bcsif_image = 2
$bcsif_style = 4
$bcsif_size = 8
$bcss_nosplit = 1
$bcss_stretch = 2
$bcss_alignleft = 4
$bcss_image = 8
$button_imagelist_align_left = 0
$button_imagelist_align_right = 1
$button_imagelist_align_top = 2
$button_imagelist_align_bottom = 3
$button_imagelist_align_center = 4
$bs_3state = 5
$bs_auto3state = 6
$bs_autocheckbox = 3
$bs_checkbox = 2
$bs_radiobutton = 4
$bs_autoradiobutton = 9
$bs_ownerdraw = 11
$gui_ss_default_button = 0
$gui_ss_default_checkbox = 0
$gui_ss_default_group = 0
$gui_ss_default_radio = 0
$bcm_first = 5632
$bcm_getidealsize = ($bcm_first + 1)
$bcm_getimagelist = ($bcm_first + 3)
$bcm_getnote = ($bcm_first + 10)
$bcm_getnotelength = ($bcm_first + 11)
$bcm_getsplitinfo = ($bcm_first + 8)
$bcm_gettextmargin = ($bcm_first + 5)
$bcm_setdropdownstate = ($bcm_first + 6)
$bcm_setimagelist = ($bcm_first + 2)
$bcm_setnote = ($bcm_first + 9)
$bcm_setshield = ($bcm_first + 12)
$bcm_setsplitinfo = ($bcm_first + 7)
$bcm_settextmargin = ($bcm_first + 4)
$bm_click = 245
$bm_getcheck = 240
$bm_getimage = 246
$bm_getstate = 242
$bm_setcheck = 241
$bm_setdontclick = 248
$bm_setimage = 247
$bm_setstate = 243
$bm_setstyle = 244
$bcn_first = -1250
$bcn_dropdown = ($bcn_first + 2)
$bcn_hotitemchange = ($bcn_first + 1)
$bn_clicked = 0
$bn_paint = 1

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$bn_hilite = 2
$bn_unhilite = 3
$bn_disable = 4
$bn_doubleclicked = 5
$bn_setfocus = 6
$bn_killfocus = 7
$bn_pushed = $bn_hilite
$bn_unpushed = $bn_unhilite
$bn_dblclk = $bn_doubleclicked
$bst_checked = 1
$bst_indeterminate = 2
$bst_unchecked = 0
$bst_focus = 8
$bst_pushed = 4
$bst_dontclick = 128
$cb_err = -1
$cb_errattribute = -3
$cb_errrequired = -4
$cb_errspace = -2
$cb_okay = 0
$state_system_invisible = 32768
$state_system_pressed = 8
$cbs_autohscroll = 64
$cbs_disablenoscroll = 2048
$cbs_dropdown = 2
$cbs_dropdownlist = 3
$cbs_hasstrings = 512
$cbs_lowercase = 16384
$cbs_nointegralheight = 1024
$cbs_oemconvert = 128
$cbs_ownerdrawfixed = 16
$cbs_ownerdrawvariable = 32
$cbs_simple = 1
$cbs_sort = 256
$cbs_uppercase = 8192
$cbm_first = 5888
$cb_addstring = 323
$cb_deletestring = 324
$cb_dir = 325
$cb_findstring = 332
$cb_findstringexact = 344
$cb_getcomboboxinfo = 356
$cb_getcount = 326
$cb_getcuebanner = ($cbm_first + 4)
$cb_getcursel = 327
$cb_getdroppedcontrolrect = 338
$cb_getdroppedstate = 343
$cb_getdroppedwidth = 351
$cb_geteditsel = 320
$cb_getextendedui = 342
$cb_gethorizontalextent = 349
$cb_getitemdata = 336
$cb_getitemheight = 340
$cb_getlbtext = 328
$cb_getlbtextlen = 329
$cb_getlocale = 346
$cb_getminvisible = 5890
$cb_gettopindex = 347
$cb_initstorage = 353
$cb_limittext = 321

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$cb_resetcontent = 331
$cb_insertstring = 330
$cb_selectstring = 333
$cb_setcuebanner = ($cbm_first + 3)
$cb_setcursel = 334
$cb_setdroppedwidth = 352
$cb_seteditsel = 322
$cb_setextendedui = 341
$cb_sethorizontalextent = 350
$cb_setitemdata = 337
$cb_setitemheight = 339
$cb_setlocale = 345
$cb_setminvisible = 5889
$cb_settopindex = 348
$cb_showdropdown = 335
$cbn_closeup = 8
$cbn_dblclk = 2
$cbn_dropdown = 7
$cbn_editchange = 5
$cbn_editupdate = 6
$cbn_errspace = (-1)
$cbn_killfocus = 4
$cbn_selchange = 1
$cbn_selendcancel = 10
$cbn_selendok = 9
$cbn_setfocus = 3
$cbes_ex_casesensitive = 16
$cbes_ex_noeditimage = 1
$cbes_ex_noeditimageindent = 2
$cbes_ex_nosizelimit = 8
$__comboboxconstant_wm_user = 1024
$cbem_deleteitem = $cb_deletestring
$cbem_getcombocontrol = ($__comboboxconstant_wm_user + 6)
$cbem_geteditcontrol = ($__comboboxconstant_wm_user + 7)
$cbem_getexstyle = ($__comboboxconstant_wm_user + 9)
$cbem_getextendedstyle = ($__comboboxconstant_wm_user + 9)
$cbem_getimagelist = ($__comboboxconstant_wm_user + 3)
$cbem_getitema = ($__comboboxconstant_wm_user + 4)
$cbem_getitemw = ($__comboboxconstant_wm_user + 13)
$cbem_getunicodeformat = 8192 + 6
$cbem_haseditchanged = ($__comboboxconstant_wm_user + 10)
$cbem_insertitema = ($__comboboxconstant_wm_user + 1)
$cbem_insertitemw = ($__comboboxconstant_wm_user + 11)
$cbem_setexstyle = ($__comboboxconstant_wm_user + 8)
$cbem_setextendedstyle = ($__comboboxconstant_wm_user + 14)
$cbem_setimagelist = ($__comboboxconstant_wm_user + 2)
$cbem_setitema = ($__comboboxconstant_wm_user + 5)
$cbem_setitemw = ($__comboboxconstant_wm_user + 12)
$cbem_setunicodeformat = 8192 + 5
$cbem_setwindowtheme = 8192 + 11
$cben_first = (-800)
$cben_last = (-830)
$cben_beginedit = ($cben_first - 4)
$cben_deleteitem = ($cben_first - 2)
$cben_dragbegina = ($cben_first - 8)
$cben_dragbeginw = ($cben_first - 9)
$cben_endedita = ($cben_first - 5)
$cben_endeditw = ($cben_first - 6)
$cben_getdispinfo = ($cben_first + 0)
$cben_getdispinfoa = ($cben_first + 0)

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$cben_getdispinfow = ($cben_first - 7)
$cben_insertitem = ($cben_first - 1)
$cbeif_di_setitem = 268435456
$cbeif_image = 2
$cbeif_indent = 16
$cbeif_lparam = 32
$cbeif_overlay = 8
$cbeif_selectedimage = 4
$cbeif_text = 1
$gui_ss_default_combo = 2097218
$es_left = 0
$es_center = 1
$es_right = 2
$es_multiline = 4
$es_uppercase = 8
$es_lowercase = 16
$es_password = 32
$es_autovscroll = 64
$es_autohscroll = 128
$es_nohidesel = 256
$es_oemconvert = 1024
$es_readonly = 2048
$es_wantreturn = 4096
$es_number = 8192
$ec_err = -1
$ecm_first = 5376
$em_canundo = 198
$em_charfrompos = 215
$em_emptyundobuffer = 205
$em_fmtlines = 200
$em_getcuebanner = ($ecm_first + 2)
$em_getfirstvisibleline = 206
$em_gethandle = 189
$em_getimestatus = 217
$em_getlimittext = 213
$em_getline = 196
$em_getlinecount = 186
$em_getmargins = 212
$em_getmodify = 184
$em_getpasswordchar = 210
$em_getrect = 178
$em_getsel = 176
$em_getthumb = 190
$em_getwordbreakproc = 209
$em_hideballoontip = ($ecm_first + 4)
$em_limittext = 197
$em_linefromchar = 201
$em_lineindex = 187
$em_linelength = 193
$em_linescroll = 182
$em_posfromchar = 214
$em_replacesel = 194
$em_scroll = 181
$em_scrollcaret = 183
$em_setcuebanner = ($ecm_first + 1)
$em_sethandle = 188
$em_setimestatus = 216
$em_setlimittext = $em_limittext
$em_setmargins = 211
$em_setmodify = 185

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$em_setpasswordchar = 204
$em_setreadonly = 207
$em_setrect = 179
$em_setrectnp = 180
$em_setsel = 177
$em_settabstops = 203
$em_setwordbreakproc = 208
$em_showballoontip = ($ecm_first + 3)
$em_undo = 199
$ec_leftmargin = 1
$ec_rightmargin = 2
$ec_usefontinfo = 65535
$emsis_compositionstring = 1
$eimes_getcompstratonce = 1
$eimes_cancelcompstrinfocus = 2
$eimes_completecompstrkillfocus = 4
$en_align_ltr_ec = 1792
$en_align_rtl_ec = 1793
$en_change = 768
$en_errspace = 1280
$en_hscroll = 1537
$en_killfocus = 512
$en_maxtext = 1281
$en_setfocus = 256
$en_update = 1024
$en_vscroll = 1538
$gui_ss_default_edit = 3150016
$gui_ss_default_input = 128
$gui_event_single = 0
$gui_event_array = 1
$gui_event_none = 0
$gui_event_close = -3
$gui_event_minimize = -4
$gui_event_restore = -5
$gui_event_maximize = -6
$gui_event_primarydown = -7
$gui_event_primaryup = -8
$gui_event_secondarydown = -9
$gui_event_secondaryup = -10
$gui_event_mousemove = -11
$gui_event_resized = -12
$gui_event_dropped = -13
$gui_rundefmsg = "GUI_RUNDEFMSG"
$gui_avistop = 0
$gui_avistart = 1
$gui_aviclose = 2
$gui_checked = 1
$gui_indeterminate = 2
$gui_unchecked = 4
$gui_dropaccepted = 8
$gui_nodropaccepted = 4096
$gui_acceptfiles = $gui_dropaccepted
$gui_show = 16
$gui_hide = 32
$gui_enable = 64
$gui_disable = 128
$gui_focus = 256
$gui_nofocus = 8192
$gui_defbutton = 512
$gui_expand = 1024

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$gui_ontop = 2048
$gui_fontnormal = 0
$gui_fontitalic = 2
$gui_fontunder = 4
$gui_fontstrike = 8
$gui_dockauto = 1
$gui_dockleft = 2
$gui_dockright = 4
$gui_dockhcenter = 8
$gui_docktop = 32
$gui_dockbottom = 64
$gui_dockvcenter = 128
$gui_dockwidth = 256
$gui_dockheight = 512
$gui_docksize = 768
$gui_dockmenubar = 544
$gui_dockstatebar = 576
$gui_dockall = 802
$gui_dockborders = 102
$gui_gr_close = 1
$gui_gr_line = 2
$gui_gr_bezier = 4
$gui_gr_move = 6
$gui_gr_color = 8
$gui_gr_rect = 10
$gui_gr_ellipse = 12
$gui_gr_pie = 14
$gui_gr_dot = 16
$gui_gr_pixel = 18
$gui_gr_hint = 20
$gui_gr_refresh = 22
$gui_gr_pensize = 24
$gui_gr_nobkcolor = -2
$gui_bkcolor_default = -1
$gui_bkcolor_transparent = -2
$gui_bkcolor_lv_alternate = -33554432
$gui_read_default = 0
$gui_read_extended = 1
$gui_cursor_nooverride = 0
$gui_cursor_override = 1
$gui_ws_ex_parentdrag = 1048576
$lvgs_normal = 0
$lvgs_collapsed = 1
$lvgs_hidden = 2
$lvgs_noheader = 4
$lvgs_collapsible = 8
$lvgs_focused = 16
$lvgs_selected = 32
$lvgs_subseted = 64
$lvgs_subsetlinkfocused = 128
$lvggr_group = 0
$lvggr_header = 1
$lvggr_label = 2
$lvggr_subsetlink = 3
$lv_err = -1
$lvbkif_source_none = 0
$lvbkif_source_hbitmap = 1
$lvbkif_source_url = 2
$lvbkif_source_mask = 3
$lvbkif_style_normal = 0

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
fmt_fill)
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$lvbkif_style_tile = 16
$lvbkif_style_mask = 16
$lvbkif_flag_tileoffset = 256
$lvbkif_type_watermark = 268435456
$lv_view_details = 1
$lv_view_icon = 0
$lv_view_list = 3
$lv_view_smallicon = 2
$lv_view_tile = 4
$lva_alignleft = 1
$lva_aligntop = 2
$lva_default = 0
$lva_snaptogrid = 5
$lvcdi_item = 0
$lvcdi_group = 1
$lvcf_alldata = 63
$lvcf_fmt = 1
$lvcf_image = 16
$lvcfmt_justifymask = 3
$lvcf_text = 4
$lvcf_width = 2
$lvcfmt_bitmap_on_right = 4096
$lvcfmt_center = 2
$lvcfmt_col_has_images = 32768
$lvcfmt_image = 2048
$lvcfmt_left = 0
$lvcfmt_right = 1
$lvcfmt_line_break = 1048576
$lvcfmt_fill = 2097152
$lvcfmt_wrap = 4194304
$lvcfmt_no_title = 8388608
$lvcfmt_tile_placementmask = BitOR($lvcfmt_line_break, $lvc

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$lvfi_nearestxy = 64
$lvfi_param = 1
$lvfi_partial = 8
$lvfi_string = 2
$lvfi_substring = 4
$lvfi_wrap = 32
$lvga_footer_left = 8
$lvga_footer_center = 16
$lvga_footer_right = 32
$lvga_header_left = 1
$lvga_header_center = 2
$lvga_header_right = 4
$lvgf_align = 8
$lvgf_descriptiontop = 1024
$lvgf_descriptionbottom = 2048
$lvgf_extendedimage = 8192
$lvgf_footer = 2
$lvgf_groupid = 16
$lvgf_header = 1
$lvgf_items = 16384
$lvgf_none = 0
$lvgf_state = 4
$lvgf_subset = 32768
$lvgf_subsetitems = 65536
$lvgf_subtitle = 256
$lvgf_task = 512
$lvgf_titleimage = 4096

Global Const $lvht_above = 8


Global Const $lvht_below = 16
Global Const $lvht_nowhere = 1
Global Const $lvht_onitemicon = 2
Global Const $lvht_onitemlabel = 4
Global Const $lvht_onitemstateicon = 8
Global Const $lvht_toleft = 64
Global Const $lvht_toright = 32
Global Const $lvht_onitem = BitOR($lvht_onitemicon, $lvht_onitemlabel, $
lvht_onitemstateicon)
Global Const $lvht_ex_group_header = 268435456
Global Const $lvht_ex_group_footer = 536870912
Global Const $lvht_ex_group_collapse = 1073741824
Global Const $lvht_ex_group_background = -2147483648
Global Const $lvht_ex_group_stateicon = 16777216
Global Const $lvht_ex_group_subsetlink = 33554432
Global Const $lvht_ex_group = BitOR($lvht_ex_group_background, $lvht_ex_
group_collapse, $lvht_ex_group_footer, $lvht_ex_group_header, $lvht_ex_group_sta
teicon, $lvht_ex_group_subsetlink)
Global Const $lvht_ex_oncontents = 67108864
Global Const $lvht_ex_footer = 134217728
Global Const $lvif_colfmt = 65536
Global Const $lvif_columns = 512
Global Const $lvif_groupid = 256
Global Const $lvif_image = 2
Global Const $lvif_indent = 16
Global Const $lvif_norecompute = 2048
Global Const $lvif_param = 4
Global Const $lvif_state = 8
Global Const $lvif_text = 1
Global Const $lvim_after = 1
Global Const $lvir_bounds = 0
Global Const $lvir_icon = 1
Global Const $lvir_label = 2
Global Const $lvir_selectbounds = 3
Global Const $lvis_cut = 4
Global Const $lvis_drophilited = 8
Global Const $lvis_focused = 1
Global Const $lvis_overlaymask = 3840
Global Const $lvis_selected = 2
Global Const $lvis_stateimagemask = 61440
Global Const $lvs_alignleft = 2048
Global Const $lvs_alignmask = 3072
Global Const $lvs_aligntop = 0
Global Const $lvs_autoarrange = 256
Global Const $lvs_default = 13
Global Const $lvs_editlabels = 512
Global Const $lvs_icon = 0
Global Const $lvs_list = 3
Global Const $lvs_nocolumnheader = 16384
Global Const $lvs_nolabelwrap = 128
Global Const $lvs_noscroll = 8192
Global Const $lvs_nosortheader = 32768
Global Const $lvs_ownerdata = 4096
Global Const $lvs_ownerdrawfixed = 1024
Global Const $lvs_report = 1
Global Const $lvs_shareimagelists = 64
Global Const $lvs_showselalways = 8
Global Const $lvs_singlesel = 4
Global Const $lvs_smallicon = 2

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
inglesel)
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$lvs_sortascending = 16
$lvs_sortdescending = 32
$lvs_typemask = 3
$lvs_typestylemask = 64512
$lvs_ex_autoautoarrange = 16777216
$lvs_ex_autocheckselect = 134217728
$lvs_ex_autosizecolumns = 268435456
$lvs_ex_borderselect = 32768
$lvs_ex_checkboxes = 4
$lvs_ex_columnoverflow = -2147483648
$lvs_ex_columnsnappoints = 1073741824
$lvs_ex_doublebuffer = 65536
$lvs_ex_flatsb = 256
$lvs_ex_fullrowselect = 32
$lvs_ex_gridlines = 1
$lvs_ex_headerdragdrop = 16
$lvs_ex_headerinallviews = 33554432
$lvs_ex_hidelabels = 131072
$lvs_ex_infotip = 1024
$lvs_ex_justifycolumns = 2097152
$lvs_ex_labeltip = 16384
$lvs_ex_multiworkareas = 8192
$lvs_ex_oneclickactivate = 64
$lvs_ex_regional = 512
$lvs_ex_simpleselect = 1048576
$lvs_ex_snaptogrid = 524288
$lvs_ex_subitemimages = 2
$lvs_ex_trackselect = 8
$lvs_ex_transparentbkgnd = 4194304
$lvs_ex_transparentshadowtext = 8388608
$lvs_ex_twoclickactivate = 128
$lvs_ex_underlinecold = 4096
$lvs_ex_underlinehot = 2048
$gui_ss_default_listview = BitOR($lvs_showselalways, $lvs_s

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$lvm_first = 4096
$lvm_approximateviewrect = ($lvm_first + 64)
$lvm_arrange = ($lvm_first + 22)
$lvm_canceleditlabel = ($lvm_first + 179)
$lvm_createdragimage = ($lvm_first + 33)
$lvm_deleteallitems = ($lvm_first + 9)
$lvm_deletecolumn = ($lvm_first + 28)
$lvm_deleteitem = ($lvm_first + 8)
$lvm_editlabela = ($lvm_first + 23)
$lvm_editlabelw = ($lvm_first + 118)
$lvm_editlabel = $lvm_editlabela
$lvm_enablegroupview = ($lvm_first + 157)
$lvm_ensurevisible = ($lvm_first + 19)
$lvm_finditem = ($lvm_first + 13)
$lvm_getbkcolor = ($lvm_first + 0)
$lvm_getbkimagea = ($lvm_first + 69)
$lvm_getbkimagew = ($lvm_first + 139)
$lvm_getcallbackmask = ($lvm_first + 10)
$lvm_getcolumna = ($lvm_first + 25)
$lvm_getcolumnw = ($lvm_first + 95)
$lvm_getcolumnorderarray = ($lvm_first + 59)
$lvm_getcolumnwidth = ($lvm_first + 29)
$lvm_getcountperpage = ($lvm_first + 40)
$lvm_geteditcontrol = ($lvm_first + 24)
$lvm_getemptytext = ($lvm_first + 204)

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$lvm_getextendedlistviewstyle = ($lvm_first + 55)


$lvm_getfocusedgroup = ($lvm_first + 93)
$lvm_getfooterinfo = ($lvm_first + 206)
$lvm_getfooteritem = ($lvm_first + 208)
$lvm_getfooteritemrect = ($lvm_first + 207)
$lvm_getfooterrect = ($lvm_first + 205)
$lvm_getgroupcount = ($lvm_first + 152)
$lvm_getgroupinfo = ($lvm_first + 149)
$lvm_getgroupinfobyindex = ($lvm_first + 153)
$lvm_getgroupmetrics = ($lvm_first + 156)
$lvm_getgrouprect = ($lvm_first + 98)
$lvm_getgroupstate = ($lvm_first + 92)
$lvm_getheader = ($lvm_first + 31)
$lvm_gethotcursor = ($lvm_first + 63)
$lvm_gethotitem = ($lvm_first + 61)
$lvm_gethovertime = ($lvm_first + 72)
$lvm_getimagelist = ($lvm_first + 2)
$lvm_getinsertmark = ($lvm_first + 167)
$lvm_getinsertmarkcolor = ($lvm_first + 171)
$lvm_getinsertmarkrect = ($lvm_first + 169)
$lvm_getisearchstringa = ($lvm_first + 52)
$lvm_getisearchstringw = ($lvm_first + 117)
$lvm_getitema = ($lvm_first + 5)
$lvm_getitemw = ($lvm_first + 75)
$lvm_getitemcount = ($lvm_first + 4)
$lvm_getitemindexrect = ($lvm_first + 209)
$lvm_getitemposition = ($lvm_first + 16)
$lvm_getitemrect = ($lvm_first + 14)
$lvm_getitemspacing = ($lvm_first + 51)
$lvm_getitemstate = ($lvm_first + 44)
$lvm_getitemtexta = ($lvm_first + 45)
$lvm_getitemtextw = ($lvm_first + 115)
$lvm_getnextitem = ($lvm_first + 12)
$lvm_getnextitemindex = ($lvm_first + 211)
$lvm_getnumberofworkareas = ($lvm_first + 73)
$lvm_getorigin = ($lvm_first + 41)
$lvm_getoutlinecolor = ($lvm_first + 176)
$lvm_getselectedcolumn = ($lvm_first + 174)
$lvm_getselectedcount = ($lvm_first + 50)
$lvm_getselectionmark = ($lvm_first + 66)
$lvm_getstringwidtha = ($lvm_first + 17)
$lvm_getstringwidthw = ($lvm_first + 87)
$lvm_getsubitemrect = ($lvm_first + 56)
$lvm_gettextbkcolor = ($lvm_first + 37)
$lvm_gettextcolor = ($lvm_first + 35)
$lvm_gettileinfo = ($lvm_first + 165)
$lvm_gettileviewinfo = ($lvm_first + 163)
$lvm_gettooltips = ($lvm_first + 78)
$lvm_gettopindex = ($lvm_first + 39)
$lvm_getunicodeformat = 8192 + 6
$lvm_getview = ($lvm_first + 143)
$lvm_getviewrect = ($lvm_first + 34)
$lvm_getworkareas = ($lvm_first + 70)
$lvm_hasgroup = ($lvm_first + 161)
$lvm_hittest = ($lvm_first + 18)
$lvm_insertcolumna = ($lvm_first + 27)
$lvm_insertcolumnw = ($lvm_first + 97)
$lvm_insertgroup = ($lvm_first + 145)
$lvm_insertgroupsorted = ($lvm_first + 159)
$lvm_insertitema = ($lvm_first + 7)

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$lvm_insertitemw = ($lvm_first + 77)


$lvm_insertmarkhittest = ($lvm_first + 168)
$lvm_isgroupviewenabled = ($lvm_first + 175)
$lvm_isitemvisible = ($lvm_first + 182)
$lvm_mapidtoindex = ($lvm_first + 181)
$lvm_mapindextoid = ($lvm_first + 180)
$lvm_movegroup = ($lvm_first + 151)
$lvm_redrawitems = ($lvm_first + 21)
$lvm_removeallgroups = ($lvm_first + 160)
$lvm_removegroup = ($lvm_first + 150)
$lvm_scroll = ($lvm_first + 20)
$lvm_setbkcolor = ($lvm_first + 1)
$lvm_setbkimagea = ($lvm_first + 68)
$lvm_setbkimagew = ($lvm_first + 138)
$lvm_setcallbackmask = ($lvm_first + 11)
$lvm_setcolumna = ($lvm_first + 26)
$lvm_setcolumnw = ($lvm_first + 96)
$lvm_setcolumnorderarray = ($lvm_first + 58)
$lvm_setcolumnwidth = ($lvm_first + 30)
$lvm_setextendedlistviewstyle = ($lvm_first + 54)
$lvm_setgroupinfo = ($lvm_first + 147)
$lvm_setgroupmetrics = ($lvm_first + 155)
$lvm_sethotcursor = ($lvm_first + 62)
$lvm_sethotitem = ($lvm_first + 60)
$lvm_sethovertime = ($lvm_first + 71)
$lvm_seticonspacing = ($lvm_first + 53)
$lvm_setimagelist = ($lvm_first + 3)
$lvm_setinfotip = ($lvm_first + 173)
$lvm_setinsertmark = ($lvm_first + 166)
$lvm_setinsertmarkcolor = ($lvm_first + 170)
$lvm_setitema = ($lvm_first + 6)
$lvm_setitemw = ($lvm_first + 76)
$lvm_setitemcount = ($lvm_first + 47)
$lvm_setitemindexstate = ($lvm_first + 210)
$lvm_setitemposition = ($lvm_first + 15)
$lvm_setitemposition32 = ($lvm_first + 49)
$lvm_setitemstate = ($lvm_first + 43)
$lvm_setitemtexta = ($lvm_first + 46)
$lvm_setitemtextw = ($lvm_first + 116)
$lvm_setoutlinecolor = ($lvm_first + 177)
$lvm_setselectedcolumn = ($lvm_first + 140)
$lvm_setselectionmark = ($lvm_first + 67)
$lvm_settextbkcolor = ($lvm_first + 38)
$lvm_settextcolor = ($lvm_first + 36)
$lvm_settileinfo = ($lvm_first + 164)
$lvm_settileviewinfo = ($lvm_first + 162)
$lvm_settilewidth = ($lvm_first + 141)
$lvm_settooltips = ($lvm_first + 74)
$lvm_setunicodeformat = 8192 + 5
$lvm_setview = ($lvm_first + 142)
$lvm_setworkareas = ($lvm_first + 65)
$lvm_sortgroups = ($lvm_first + 158)
$lvm_sortitems = ($lvm_first + 48)
$lvm_sortitemsex = ($lvm_first + 81)
$lvm_subitemhittest = ($lvm_first + 57)
$lvm_update = ($lvm_first + 42)
$lvn_first = -100
$lvn_last = -199
$lvn_begindrag = ($lvn_first - 9)
$lvn_beginlabeledita = ($lvn_first - 5)

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$lvn_beginlabeleditw = ($lvn_first - 75)


$lvn_beginrdrag = ($lvn_first - 11)
$lvn_beginscroll = ($lvn_first - 80)
$lvn_columnclick = ($lvn_first - 8)
$lvn_columndropdown = ($lvn_first - 64)
$lvn_columnoverflowclick = ($lvn_first - 66)
$lvn_deleteallitems = ($lvn_first - 4)
$lvn_deleteitem = ($lvn_first - 3)
$lvn_endlabeledita = ($lvn_first - 6)
$lvn_endlabeleditw = ($lvn_first - 76)
$lvn_endscroll = ($lvn_first - 81)
$lvn_getdispinfoa = ($lvn_first - 50)
$lvn_getdispinfow = ($lvn_first - 77)
$lvn_getdispinfo = $lvn_getdispinfoa
$lvn_getemptymarkup = ($lvn_first - 87)
$lvn_getinfotipa = ($lvn_first - 57)
$lvn_getinfotipw = ($lvn_first - 58)
$lvn_hottrack = ($lvn_first - 21)
$lvn_incrementalsearcha = ($lvn_first - 62)
$lvn_incrementalsearchw = ($lvn_first - 63)
$lvn_insertitem = ($lvn_first - 2)
$lvn_itemactivate = ($lvn_first - 14)
$lvn_itemchanged = ($lvn_first - 1)
$lvn_itemchanging = ($lvn_first + 0)
$lvn_keydown = ($lvn_first - 55)
$lvn_linkclick = ($lvn_first - 84)
$lvn_marqueebegin = ($lvn_first - 56)
$lvn_odcachehint = ($lvn_first - 13)
$lvn_odfinditema = ($lvn_first - 52)
$lvn_odfinditemw = ($lvn_first - 79)
$lvn_odfinditem = $lvn_odfinditema
$lvn_odstatechanged = ($lvn_first - 15)
$lvn_setdispinfoa = ($lvn_first - 51)
$lvn_setdispinfow = ($lvn_first - 78)
$lvni_above = 256
$lvni_below = 512
$lvni_toleft = 1024
$lvni_toright = 2048
$lvni_all = 0
$lvni_cut = 4
$lvni_drophilited = 8
$lvni_focused = 1
$lvni_selected = 2
$lvscw_autosize = -1
$lvscw_autosize_useheader = -2
$lvsicf_noinvalidateall = 1
$lvsicf_noscroll = 2
$lvsil_normal = 0
$lvsil_small = 1
$lvsil_state = 2
$ss_left = 0
$ss_center = 1
$ss_right = 2
$ss_icon = 3
$ss_blackrect = 4
$ss_grayrect = 5
$ss_whiterect = 6
$ss_blackframe = 7
$ss_grayframe = 8
$ss_whiteframe = 9

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$ss_simple = 11
$ss_leftnowordwrap = 12
$ss_bitmap = 14
$ss_enhmetafile = 15
$ss_etchedhorz = 16
$ss_etchedvert = 17
$ss_etchedframe = 18
$ss_realsizecontrol = 64
$ss_noprefix = 128
$ss_notify = 256
$ss_centerimage = 512
$ss_rightjust = 1024
$ss_sunken = 4096
$gui_ss_default_label = 0
$gui_ss_default_graphic = 0
$gui_ss_default_icon = $ss_notify
$gui_ss_default_pic = $ss_notify
$stm_seticon = 368
$stm_geticon = 369
$stm_setimage = 370
$stm_getimage = 371
$sbars_sizegrip = 256
$sbt_tooltips = 2048
$sbars_tooltips = 2048
$sbt_sunken = 0
$sbt_noborders = 256
$sbt_popout = 512
$sbt_rtlreading = 1024
$sbt_notabparsing = 2048
$sbt_ownerdraw = 4096
$__statusbarconstant_wm_user = 1024
$sb_getborders = ($__statusbarconstant_wm_user + 7)
$sb_geticon = ($__statusbarconstant_wm_user + 20)
$sb_getparts = ($__statusbarconstant_wm_user + 6)
$sb_getrect = ($__statusbarconstant_wm_user + 10)
$sb_gettexta = ($__statusbarconstant_wm_user + 2)
$sb_gettextw = ($__statusbarconstant_wm_user + 13)
$sb_gettext = $sb_gettexta
$sb_gettextlengtha = ($__statusbarconstant_wm_user + 3)
$sb_gettextlengthw = ($__statusbarconstant_wm_user + 12)
$sb_gettextlength = $sb_gettextlengtha
$sb_gettiptexta = ($__statusbarconstant_wm_user + 18)
$sb_gettiptextw = ($__statusbarconstant_wm_user + 19)
$sb_getunicodeformat = 8192 + 6
$sb_issimple = ($__statusbarconstant_wm_user + 14)
$sb_setbkcolor = 8192 + 1
$sb_seticon = ($__statusbarconstant_wm_user + 15)
$sb_setminheight = ($__statusbarconstant_wm_user + 8)
$sb_setparts = ($__statusbarconstant_wm_user + 4)
$sb_settexta = ($__statusbarconstant_wm_user + 1)
$sb_settextw = ($__statusbarconstant_wm_user + 11)
$sb_settext = $sb_settexta
$sb_settiptexta = ($__statusbarconstant_wm_user + 16)
$sb_settiptextw = ($__statusbarconstant_wm_user + 17)
$sb_setunicodeformat = 8192 + 5
$sb_simple = ($__statusbarconstant_wm_user + 9)
$sb_simpleid = 255
$sbn_first = -880
$sbn_simplemodechange = $sbn_first + 0
$tcs_ex_flatseparators = 1

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$tcs_ex_registerdrop = 2
$tcht_nowhere = 1
$tcht_onitemicon = 2
$tcht_onitemlabel = 4
$tcht_onitem = 6
$tcif_text = 1
$tcif_image = 2
$tcif_rtlreading = 4
$tcif_param = 8
$tcif_state = 16
$tcif_alldata = 27
$tcis_buttonpressed = 1
$tcis_highlighted = 2
$tc_err = -1
$tcs_bottom = 2
$tcs_buttons = 256
$tcs_fixedwidth = 1024
$tcs_flatbuttons = 8
$tcs_focusnever = 32768
$tcs_focusonbuttondown = 4096
$tcs_forceiconleft = 16
$tcs_forcelabelleft = 32
$tcs_hottrack = 64
$tcs_multiline = 512
$tcs_multiselect = 4
$tcs_ownerdrawfixed = 8192
$tcs_raggedright = 2048
$tcs_right = 2
$tcs_rightjustify = 0
$tcs_scrollopposite = 1
$tcs_singleline = 0
$tcs_tabs = 0
$tcs_tooltips = 16384
$tcs_vertical = 128
$gui_ss_default_tab = 0
$tcm_first = 4864
$tccm_first = 8192
$tcm_adjustrect = ($tcm_first + 40)
$tcm_deleteallitems = ($tcm_first + 9)
$tcm_deleteitem = ($tcm_first + 8)
$tcm_deselectall = ($tcm_first + 50)
$tcm_getcurfocus = ($tcm_first + 47)
$tcm_getcursel = ($tcm_first + 11)
$tcm_getextendedstyle = ($tcm_first + 53)
$tcm_getimagelist = ($tcm_first + 2)
$tcm_getitema = ($tcm_first + 5)
$tcm_getitemw = ($tcm_first + 60)
$tcm_getitemcount = ($tcm_first + 4)
$tcm_getitemrect = ($tcm_first + 10)
$tcm_getrowcount = ($tcm_first + 44)
$tcm_gettooltips = ($tcm_first + 45)
$tccm_getunicodeformat = ($tccm_first + 6)
$tcm_getunicodeformat = $tccm_getunicodeformat
$tcm_highlightitem = ($tcm_first + 51)
$tcm_hittest = ($tcm_first + 13)
$tcm_insertitema = ($tcm_first + 7)
$tcm_insertitemw = ($tcm_first + 62)
$tcm_removeimage = ($tcm_first + 42)
$tcm_setitema = ($tcm_first + 6)
$tcm_setitemw = ($tcm_first + 61)

Global Const $tcm_setitemextra = ($tcm_first + 14)


Global Const $tcm_setitemsize = $tcm_first + 41
Global Const $tcm_setcurfocus = ($tcm_first + 48)
Global Const $tcm_setcursel = ($tcm_first + 12)
Global Const $tcm_setextendedstyle = ($tcm_first + 52)
Global Const $tcm_setimagelist = $tcm_first + 3
Global Const $tcm_setmintabwidth = ($tcm_first + 49)
Global Const $tcm_setpadding = ($tcm_first + 43)
Global Const $tcm_settooltips = ($tcm_first + 46)
Global Const $tccm_setunicodeformat = ($tccm_first + 5)
Global Const $tcm_setunicodeformat = $tccm_setunicodeformat
Global Const $tcn_first = -550
Global Const $tcn_focuschange = ($tcn_first - 4)
Global Const $tcn_getobject = ($tcn_first - 3)
Global Const $tcn_keydown = ($tcn_first + 0)
Global Const $tcn_selchange = ($tcn_first - 1)
Global Const $tcn_selchanging = ($tcn_first - 2)
Global Const $wc_animate = "SysAnimate32"
Global Const $wc_button = "Button"
Global Const $wc_combobox = "ComboBox"
Global Const $wc_comboboxex = "ComboBoxEx32"
Global Const $wc_datetimepick = "SysDateTimePick32"
Global Const $wc_edit = "Edit"
Global Const $wc_header = "SysHeader32"
Global Const $wc_hotkey = "msctls_hotkey32"
Global Const $wc_ipaddress = "SysIPAddress32"
Global Const $wc_link = "SysLink"
Global Const $wc_listbox = "ListBox"
Global Const $wc_listview = "SysListView32"
Global Const $wc_monthcal = "SysMonthCal32"
Global Const $wc_nativefontctl = "NativeFontCtl"
Global Const $wc_pagescroller = "SysPager"
Global Const $wc_progress = "msctls_progress32"
Global Const $wc_rebar = "ReBarWindow32"
Global Const $wc_scrollbar = "ScrollBar"
Global Const $wc_static = "Static"
Global Const $wc_statusbar = "msctls_statusbar32"
Global Const $wc_tabcontrol = "SysTabControl32"
Global Const $wc_toolbar = "ToolbarWindow32"
Global Const $wc_tooltips = "tooltips_class32"
Global Const $wc_trackbar = "msctls_trackbar32"
Global Const $wc_treeview = "SysTreeView32"
Global Const $wc_updown = "msctls_updown32"
Global Const $ws_overlapped = 0
Global Const $ws_tiled = $ws_overlapped
Global Const $ws_maximizebox = 65536
Global Const $ws_minimizebox = 131072
Global Const $ws_tabstop = 65536
Global Const $ws_group = 131072
Global Const $ws_sizebox = 262144
Global Const $ws_thickframe = $ws_sizebox
Global Const $ws_sysmenu = 524288
Global Const $ws_hscroll = 1048576
Global Const $ws_vscroll = 2097152
Global Const $ws_dlgframe = 4194304
Global Const $ws_border = 8388608
Global Const $ws_caption = 12582912
Global Const $ws_overlappedwindow = BitOR($ws_caption, $ws_maximizebox,
$ws_minimizebox, $ws_overlapped, $ws_sysmenu, $ws_thickframe)
Global Const $ws_tiledwindow = $ws_overlappedwindow

Global Const $ws_maximize = 16777216


Global Const $ws_clipchildren = 33554432
Global Const $ws_clipsiblings = 67108864
Global Const $ws_disabled = 134217728
Global Const $ws_visible = 268435456
Global Const $ws_minimize = 536870912
Global Const $ws_iconic = $ws_minimize
Global Const $ws_child = 1073741824
Global Const $ws_childwindow = $ws_child
Global Const $ws_popup = -2147483648
Global Const $ws_popupwindow = -2138570752
Global Const $ds_3dlook = 4
Global Const $ds_absalign = 1
Global Const $ds_center = 2048
Global Const $ds_centermouse = 4096
Global Const $ds_contexthelp = 8192
Global Const $ds_control = 1024
Global Const $ds_fixedsys = 8
Global Const $ds_localedit = 32
Global Const $ds_modalframe = 128
Global Const $ds_nofailcreate = 16
Global Const $ds_noidlemsg = 256
Global Const $ds_setfont = 64
Global Const $ds_setforeground = 512
Global Const $ds_shellfont = BitOR($ds_fixedsys, $ds_setfont)
Global Const $ds_sysmodal = 2
Global Const $ws_ex_acceptfiles = 16
Global Const $ws_ex_appwindow = 262144
Global Const $ws_ex_composited = 33554432
Global Const $ws_ex_controlparent = 65536
Global Const $ws_ex_clientedge = 512
Global Const $ws_ex_contexthelp = 1024
Global Const $ws_ex_dlgmodalframe = 1
Global Const $ws_ex_layered = 524288
Global Const $ws_ex_layoutrtl = 4194304
Global Const $ws_ex_left = 0
Global Const $ws_ex_leftscrollbar = 16384
Global Const $ws_ex_ltrreading = 0
Global Const $ws_ex_mdichild = 64
Global Const $ws_ex_noactivate = 134217728
Global Const $ws_ex_noinheritlayout = 1048576
Global Const $ws_ex_noparentnotify = 4
Global Const $ws_ex_right = 4096
Global Const $ws_ex_rightscrollbar = 0
Global Const $ws_ex_rtlreading = 8192
Global Const $ws_ex_staticedge = 131072
Global Const $ws_ex_toolwindow = 128
Global Const $ws_ex_topmost = 8
Global Const $ws_ex_transparent = 32
Global Const $ws_ex_windowedge = 256
Global Const $ws_ex_overlappedwindow = BitOR($ws_ex_clientedge, $ws_ex_w
indowedge)
Global Const $ws_ex_palettewindow = BitOR($ws_ex_toolwindow, $ws_ex_topm
ost, $ws_ex_windowedge)
Global Const $wm_null = 0
Global Const $wm_create = 1
Global Const $wm_destroy = 2
Global Const $wm_move = 3
Global Const $wm_sizewait = 4
Global Const $wm_size = 5

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$wm_activate = 6
$wm_setfocus = 7
$wm_killfocus = 8
$wm_setvisible = 9
$wm_enable = 10
$wm_setredraw = 11
$wm_settext = 12
$wm_gettext = 13
$wm_gettextlength = 14
$wm_paint = 15
$wm_close = 16
$wm_queryendsession = 17
$wm_quit = 18
$wm_erasebkgnd = 20
$wm_queryopen = 19
$wm_syscolorchange = 21
$wm_endsession = 22
$wm_systemerror = 23
$wm_showwindow = 24
$wm_ctlcolor = 25
$wm_settingchange = 26
$wm_wininichange = 26
$wm_devmodechange = 27
$wm_activateapp = 28
$wm_fontchange = 29
$wm_timechange = 30
$wm_cancelmode = 31
$wm_setcursor = 32
$wm_mouseactivate = 33
$wm_childactivate = 34
$wm_queuesync = 35
$wm_getminmaxinfo = 36
$wm_logoff = 37
$wm_painticon = 38
$wm_iconerasebkgnd = 39
$wm_nextdlgctl = 40
$wm_alttabactive = 41
$wm_spoolerstatus = 42
$wm_drawitem = 43
$wm_measureitem = 44
$wm_deleteitem = 45
$wm_vkeytoitem = 46
$wm_chartoitem = 47
$wm_setfont = 48
$wm_getfont = 49
$wm_sethotkey = 50
$wm_gethotkey = 51
$wm_filesyschange = 52
$wm_isactiveicon = 53
$wm_queryparkicon = 54
$wm_querydragicon = 55
$wm_winhelp = 56
$wm_compareitem = 57
$wm_fullscreen = 58
$wm_clientshutdown = 59
$wm_ddemlevent = 60
$wm_getobject = 61
$wm_calcscroll = 63
$wm_testing = 64
$wm_compacting = 65

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$wm_otherwindowcreated = 66
$wm_otherwindowdestroyed = 67
$wm_commnotify = 68
$wm_mediastatuschange = 69
$wm_windowposchanging = 70
$wm_windowposchanged = 71
$wm_power = 72
$wm_copyglobaldata = 73
$wm_copydata = 74
$wm_canceljournal = 75
$wm_logonnotify = 76
$wm_keyf1 = 77
$wm_notify = 78
$wm_access_window = 79
$wm_inputlangchangerequest = 80
$wm_inputlangchange = 81
$wm_tcard = 82
$wm_help = 83
$wm_userchanged = 84
$wm_notifyformat = 85
$wm_qm_activate = 96
$wm_hook_do_callback = 97
$wm_syscopydata = 98
$wm_finaldestroy = 112
$wm_measureitem_clientdata = 113
$wm_contextmenu = 123
$wm_stylechanging = 124
$wm_stylechanged = 125
$wm_displaychange = 126
$wm_geticon = 127
$wm_seticon = 128
$wm_nccreate = 129
$wm_ncdestroy = 130
$wm_nccalcsize = 131
$wm_nchittest = 132
$wm_ncpaint = 133
$wm_ncactivate = 134
$wm_getdlgcode = 135
$wm_syncpaint = 136
$wm_synctask = 137
$wm_kludgeminrect = 139
$wm_lpkdrawswitchwnd = 140
$wm_uahdestroywindow = 144
$wm_uahdrawmenu = 145
$wm_uahdrawmenuitem = 146
$wm_uahinitmenu = 147
$wm_uahmeasuremenuitem = 148
$wm_uahncpaintmenupopup = 149
$wm_ncmousemove = 160
$wm_nclbuttondown = 161
$wm_nclbuttonup = 162
$wm_nclbuttondblclk = 163
$wm_ncrbuttondown = 164
$wm_ncrbuttonup = 165
$wm_ncrbuttondblclk = 166
$wm_ncmbuttondown = 167
$wm_ncmbuttonup = 168
$wm_ncmbuttondblclk = 169
$wm_ncxbuttondown = 171
$wm_ncxbuttonup = 172

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$wm_ncxbuttondblclk = 173
$wm_ncuahdrawcaption = 174
$wm_ncuahdrawframe = 175
$wm_input_device_change = 254
$wm_input = 255
$wm_keydown = 256
$wm_keyfirst = 256
$wm_keyup = 257
$wm_char = 258
$wm_deadchar = 259
$wm_syskeydown = 260
$wm_syskeyup = 261
$wm_syschar = 262
$wm_sysdeadchar = 263
$wm_yomichar = 264
$wm_keylast = 265
$wm_unichar = 265
$wm_convertrequest = 266
$wm_convertresult = 267
$wm_im_info = 268
$wm_ime_startcomposition = 269
$wm_ime_endcomposition = 270
$wm_ime_composition = 271
$wm_ime_keylast = 271
$wm_initdialog = 272
$wm_command = 273
$wm_syscommand = 274
$wm_timer = 275
$wm_hscroll = 276
$wm_vscroll = 277
$wm_initmenu = 278
$wm_initmenupopup = 279
$wm_systimer = 280
$wm_gesture = 281
$wm_gesturenotify = 282
$wm_gestureinput = 283
$wm_gesturenotified = 284
$wm_menuselect = 287
$wm_menuchar = 288
$wm_enteridle = 289
$wm_menurbuttonup = 290
$wm_menudrag = 291
$wm_menugetobject = 292
$wm_uninitmenupopup = 293
$wm_menucommand = 294
$wm_changeuistate = 295
$wm_updateuistate = 296
$wm_queryuistate = 297
$wm_lbtrackpoint = 305
$wm_ctlcolormsgbox = 306
$wm_ctlcoloredit = 307
$wm_ctlcolorlistbox = 308
$wm_ctlcolorbtn = 309
$wm_ctlcolordlg = 310
$wm_ctlcolorscrollbar = 311
$wm_ctlcolorstatic = 312
$mn_gethmenu = 481
$wm_parentnotify = 528
$wm_entermenuloop = 529
$wm_exitmenuloop = 530

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$wm_nextmenu = 531
$wm_sizing = 532
$wm_capturechanged = 533
$wm_moving = 534
$wm_powerbroadcast = 536
$wm_devicechange = 537
$wm_mdicreate = 544
$wm_mdidestroy = 545
$wm_mdiactivate = 546
$wm_mdirestore = 547
$wm_mdinext = 548
$wm_mdimaximize = 549
$wm_mditile = 550
$wm_mdicascade = 551
$wm_mdiiconarrange = 552
$wm_mdigetactive = 553
$wm_dropobject = 554
$wm_querydropobject = 555
$wm_begindrag = 556
$wm_dragloop = 557
$wm_dragselect = 558
$wm_dragmove = 559
$wm_mdisetmenu = 560
$wm_entersizemove = 561
$wm_exitsizemove = 562
$wm_dropfiles = 563
$wm_mdirefreshmenu = 564
$wm_touch = 576
$wm_ime_setcontext = 641
$wm_ime_notify = 642
$wm_ime_control = 643
$wm_ime_compositionfull = 644
$wm_ime_select = 645
$wm_ime_char = 646
$wm_ime_system = 647
$wm_ime_request = 648
$wm_ime_keydown = 656
$wm_ime_keyup = 657
$wm_ncmousehover = 672
$wm_mousehover = 673
$wm_ncmouseleave = 674
$wm_mouseleave = 675
$wm_wtssession_change = 689
$wm_tablet_first = 704
$wm_tablet_last = 735
$wm_cut = 768
$wm_copy = 769
$wm_paste = 770
$wm_clear = 771
$wm_undo = 772
$wm_paletteischanging = 784
$wm_hotkey = 786
$wm_palettechanged = 785
$wm_sysmenu = 787
$wm_hookmsg = 788
$wm_exitprocess = 789
$wm_wakethread = 790
$wm_print = 791
$wm_printclient = 792
$wm_appcommand = 793

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$wm_querynewpalette = 783
$wm_themechanged = 794
$wm_uahinit = 795
$wm_desktopnotify = 796
$wm_clipboardupdate = 797
$wm_dwmcompositionchanged = 798
$wm_dwmncrenderingchanged = 799
$wm_dwmcolorizationcolorchanged = 800
$wm_dwmwindowmaximizedchange = 801
$wm_dwmexileframe = 802
$wm_dwmsendiconicthumbnail = 803
$wm_magnification_started = 804
$wm_magnification_ended = 805
$wm_dwmsendiconiclivepreviewbitmap = 806
$wm_dwmthumbnailsizechanged = 807
$wm_magnification_output = 808
$wm_measurecontrol = 816
$wm_getactiontext = 817
$wm_forwardkeydown = 819
$wm_forwardkeyup = 820
$wm_gettitlebarinfoex = 831
$wm_notifywow = 832
$wm_handheldfirst = 856
$wm_handheldlast = 863
$wm_afxfirst = 864
$wm_afxlast = 895
$wm_penwinfirst = 896
$wm_penwinlast = 911
$wm_dde_initiate = 992
$wm_dde_terminate = 993
$wm_dde_advise = 994
$wm_dde_unadvise = 995
$wm_dde_ack = 996
$wm_dde_data = 997
$wm_dde_request = 998
$wm_dde_poke = 999
$wm_dde_execute = 1000
$wm_dbnotification = 1021
$wm_netconnect = 1022
$wm_hibernate = 1023
$wm_user = 1024
$wm_app = 32768
$nm_first = 0
$nm_outofmemory = $nm_first - 1
$nm_click = $nm_first - 2
$nm_dblclk = $nm_first - 3
$nm_return = $nm_first - 4
$nm_rclick = $nm_first - 5
$nm_rdblclk = $nm_first - 6
$nm_setfocus = $nm_first - 7
$nm_killfocus = $nm_first - 8
$nm_customdraw = $nm_first - 12
$nm_hover = $nm_first - 13
$nm_nchittest = $nm_first - 14
$nm_keydown = $nm_first - 15
$nm_releasedcapture = $nm_first - 16
$nm_setcursor = $nm_first - 17
$nm_char = $nm_first - 18
$nm_tooltipscreated = $nm_first - 19
$nm_ldown = $nm_first - 20

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$nm_rdown = $nm_first - 21
$nm_themechanged = $nm_first - 22
$wm_mousefirst = 512
$wm_mousemove = 512
$wm_lbuttondown = 513
$wm_lbuttonup = 514
$wm_lbuttondblclk = 515
$wm_rbuttondown = 516
$wm_rbuttonup = 517
$wm_rbuttondblclk = 518
$wm_mbuttondown = 519
$wm_mbuttonup = 520
$wm_mbuttondblclk = 521
$wm_mousewheel = 522
$wm_xbuttondown = 523
$wm_xbuttonup = 524
$wm_xbuttondblclk = 525
$wm_mousehwheel = 526
$ps_solid = 0
$ps_dash = 1
$ps_dot = 2
$ps_dashdot = 3
$ps_dashdotdot = 4
$ps_null = 5
$ps_insideframe = 6
$ps_userstyle = 7
$ps_alternate = 8
$ps_endcap_round = 0
$ps_endcap_square = 256
$ps_endcap_flat = 512
$ps_join_bevel = 4096
$ps_join_miter = 8192
$ps_join_round = 0
$ps_geometric = 65536
$ps_cosmetic = 0
$lwa_alpha = 2
$lwa_colorkey = 1
$rgn_and = 1
$rgn_or = 2
$rgn_xor = 3
$rgn_diff = 4
$rgn_copy = 5
$errorregion = 0
$nullregion = 1
$simpleregion = 2
$complexregion = 3
$transparent = 1
$opaque = 2
$ccm_first = 8192
$ccm_getunicodeformat = ($ccm_first + 6)
$ccm_setunicodeformat = ($ccm_first + 5)
$ccm_setbkcolor = $ccm_first + 1
$ccm_setcolorscheme = $ccm_first + 2
$ccm_getcolorscheme = $ccm_first + 3
$ccm_getdroptarget = $ccm_first + 4
$ccm_setwindowtheme = $ccm_first + 11
$ga_parent = 1
$ga_root = 2
$ga_rootowner = 3
$sm_cxscreen = 0

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$sm_cyscreen = 1
$sm_cxvscroll = 2
$sm_cyhscroll = 3
$sm_cycaption = 4
$sm_cxborder = 5
$sm_cyborder = 6
$sm_cxdlgframe = 7
$sm_cydlgframe = 8
$sm_cyvthumb = 9
$sm_cxhthumb = 10
$sm_cxicon = 11
$sm_cyicon = 12
$sm_cxcursor = 13
$sm_cycursor = 14
$sm_cymenu = 15
$sm_cxfullscreen = 16
$sm_cyfullscreen = 17
$sm_cykanjiwindow = 18
$sm_mousepresent = 19
$sm_cyvscroll = 20
$sm_cxhscroll = 21
$sm_debug = 22
$sm_swapbutton = 23
$sm_reserved1 = 24
$sm_reserved2 = 25
$sm_reserved3 = 26
$sm_reserved4 = 27
$sm_cxmin = 28
$sm_cymin = 29
$sm_cxsize = 30
$sm_cysize = 31
$sm_cxframe = 32
$sm_cyframe = 33
$sm_cxmintrack = 34
$sm_cymintrack = 35
$sm_cxdoubleclk = 36
$sm_cydoubleclk = 37
$sm_cxiconspacing = 38
$sm_cyiconspacing = 39
$sm_menudropalignment = 40
$sm_penwindows = 41
$sm_dbcsenabled = 42
$sm_cmousebuttons = 43
$sm_secure = 44
$sm_cxedge = 45
$sm_cyedge = 46
$sm_cxminspacing = 47
$sm_cyminspacing = 48
$sm_cxsmicon = 49
$sm_cysmicon = 50
$sm_cysmcaption = 51
$sm_cxsmsize = 52
$sm_cysmsize = 53
$sm_cxmenusize = 54
$sm_cymenusize = 55
$sm_arrange = 56
$sm_cxminimized = 57
$sm_cyminimized = 58
$sm_cxmaxtrack = 59
$sm_cymaxtrack = 60

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$sm_cxmaximized = 61
$sm_cymaximized = 62
$sm_network = 63
$sm_cleanboot = 67
$sm_cxdrag = 68
$sm_cydrag = 69
$sm_showsounds = 70
$sm_cxmenucheck = 71
$sm_cymenucheck = 72
$sm_slowmachine = 73
$sm_mideastenabled = 74
$sm_mousewheelpresent = 75
$sm_xvirtualscreen = 76
$sm_yvirtualscreen = 77
$sm_cxvirtualscreen = 78
$sm_cyvirtualscreen = 79
$sm_cmonitors = 80
$sm_samedisplayformat = 81
$sm_immenabled = 82
$sm_cxfocusborder = 83
$sm_cyfocusborder = 84
$sm_tabletpc = 86
$sm_mediacenter = 87
$sm_starter = 88
$sm_serverr2 = 89
$sm_cmetrics = 90
$sm_remotesession = 4096
$sm_shuttingdown = 8192
$sm_remotecontrol = 8193
$sm_caretblinkingenabled = 8194
$blackness = 66
$captureblt = 1073741824
$dstinvert = 5570569
$mergecopy = 12583114
$mergepaint = 12255782
$nomirrorbitmap = -2147483648
$notsrccopy = 3342344
$notsrcerase = 1114278
$patcopy = 15728673
$patinvert = 5898313
$patpaint = 16452105
$srcand = 8913094
$srccopy = 13369376
$srcerase = 4457256
$srcinvert = 6684742
$srcpaint = 15597702
$whiteness = 16711778
$dt_bottom = 8
$dt_calcrect = 1024
$dt_center = 1
$dt_editcontrol = 8192
$dt_end_ellipsis = 32768
$dt_expandtabs = 64
$dt_externalleading = 512
$dt_hideprefix = 1048576
$dt_internal = 4096
$dt_left = 0
$dt_modifystring = 65536
$dt_noclip = 256
$dt_nofullwidthcharbreak = 524288

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$dt_noprefix = 2048
$dt_path_ellipsis = 16384
$dt_prefixonly = 2097152
$dt_right = 2
$dt_rtlreading = 131072
$dt_singleline = 32
$dt_tabstop = 128
$dt_top = 0
$dt_vcenter = 4
$dt_wordbreak = 16
$dt_word_ellipsis = 262144
$rdw_erase = 4
$rdw_frame = 1024
$rdw_internalpaint = 2
$rdw_invalidate = 1
$rdw_noerase = 32
$rdw_noframe = 2048
$rdw_nointernalpaint = 16
$rdw_validate = 8
$rdw_erasenow = 512
$rdw_updatenow = 256
$rdw_allchildren = 128
$rdw_nochildren = 64
$wm_renderformat = 773
$wm_renderallformats = 774
$wm_destroyclipboard = 775
$wm_drawclipboard = 776
$wm_paintclipboard = 777
$wm_vscrollclipboard = 778
$wm_sizeclipboard = 779
$wm_askcbformatname = 780
$wm_changecbchain = 781
$wm_hscrollclipboard = 782
$hterror = -2
$httransparent = -1
$htnowhere = 0
$htclient = 1
$htcaption = 2
$htsysmenu = 3
$htgrowbox = 4
$htsize = $htgrowbox
$htmenu = 5
$hthscroll = 6
$htvscroll = 7
$htminbutton = 8
$htmaxbutton = 9
$htleft = 10
$htright = 11
$httop = 12
$httopleft = 13
$httopright = 14
$htbottom = 15
$htbottomleft = 16
$htbottomright = 17
$htborder = 18
$htreduce = $htminbutton
$htzoom = $htmaxbutton
$htsizefirst = $htleft
$htsizelast = $htbottomright
$htobject = 19

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$htclose = 20
$hthelp = 21
$color_scrollbar = 0
$color_background = 1
$color_activecaption = 2
$color_inactivecaption = 3
$color_menu = 4
$color_window = 5
$color_windowframe = 6
$color_menutext = 7
$color_windowtext = 8
$color_captiontext = 9
$color_activeborder = 10
$color_inactiveborder = 11
$color_appworkspace = 12
$color_highlight = 13
$color_highlighttext = 14
$color_btnface = 15
$color_btnshadow = 16
$color_graytext = 17
$color_btntext = 18
$color_inactivecaptiontext = 19
$color_btnhighlight = 20
$color_3ddkshadow = 21
$color_3dlight = 22
$color_infotext = 23
$color_infobk = 24
$color_hotlight = 26
$color_gradientactivecaption = 27
$color_gradientinactivecaption = 28
$color_menuhilight = 29
$color_menubar = 30
$color_desktop = 1
$color_3dface = 15
$color_3dshadow = 16
$color_3dhighlight = 20
$color_3dhilight = 20
$color_btnhilight = 20
$hinst_commctrl = -1
$idb_std_small_color = 0
$idb_std_large_color = 1
$idb_view_small_color = 4
$idb_view_large_color = 5
$idb_hist_small_color = 8
$idb_hist_large_color = 9
$startf_forceofffeedback = 128
$startf_forceonfeedback = 64
$startf_preventpinning = 8192
$startf_runfullscreen = 32
$startf_titleisappid = 4096
$startf_titleislinkname = 2048
$startf_usecountchars = 8
$startf_usefillattribute = 16
$startf_usehotkey = 512
$startf_useposition = 4
$startf_useshowwindow = 1
$startf_usesize = 2
$startf_usestdhandles = 256
$cdds_prepaint = 1
$cdds_postpaint = 2

Global Const $cdds_preerase = 3


Global Const $cdds_posterase = 4
Global Const $cdds_item = 65536
Global Const $cdds_itemprepaint = 65537
Global Const $cdds_itempostpaint = 65538
Global Const $cdds_itempreerase = 65539
Global Const $cdds_itemposterase = 65540
Global Const $cdds_subitem = 131072
Global Const $cdis_selected = 1
Global Const $cdis_grayed = 2
Global Const $cdis_disabled = 4
Global Const $cdis_checked = 8
Global Const $cdis_focus = 16
Global Const $cdis_default = 32
Global Const $cdis_hot = 64
Global Const $cdis_marked = 128
Global Const $cdis_indeterminate = 256
Global Const $cdis_showkeyboardcues = 512
Global Const $cdis_nearhot = 1024
Global Const $cdis_othersidehot = 2048
Global Const $cdis_drophilited = 4096
Global Const $cdrf_dodefault = 0
Global Const $cdrf_newfont = 2
Global Const $cdrf_skipdefault = 4
Global Const $cdrf_notifypostpaint = 16
Global Const $cdrf_notifyitemdraw = 32
Global Const $cdrf_notifysubitemdraw = 32
Global Const $cdrf_notifyposterase = 64
Global Const $cdrf_doerase = 8
Global Const $cdrf_skippostpaint = 256
Global Const $gui_ss_default_gui = BitOR($ws_minimizebox, $ws_caption, $
ws_popup, $ws_sysmenu)
Global Const $gmem_fixed = 0
Global Const $gmem_moveable = 2
Global Const $gmem_nocompact = 16
Global Const $gmem_nodiscard = 32
Global Const $gmem_zeroinit = 64
Global Const $gmem_modify = 128
Global Const $gmem_discardable = 256
Global Const $gmem_not_banked = 4096
Global Const $gmem_share = 8192
Global Const $gmem_ddeshare = 8192
Global Const $gmem_notify = 16384
Global Const $gmem_lower = 4096
Global Const $gmem_valid_flags = 32626
Global Const $gmem_invalid_handle = 32768
Global Const $gptr = BitOR($gmem_fixed, $gmem_zeroinit)
Global Const $ghnd = BitOR($gmem_moveable, $gmem_zeroinit)
Global Const $mem_commit = 4096
Global Const $mem_reserve = 8192
Global Const $mem_top_down = 1048576
Global Const $mem_shared = 134217728
Global Const $page_noaccess = 1
Global Const $page_readonly = 2
Global Const $page_readwrite = 4
Global Const $page_execute = 16
Global Const $page_execute_read = 32
Global Const $page_execute_readwrite = 64
Global Const $page_execute_writecopy = 128
Global Const $page_guard = 256

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$page_nocache = 512
$page_writecombine = 1024
$page_writecopy = 8
$mem_decommit = 16384
$mem_release = 32768
$process_terminate = 1
$process_create_thread = 2
$process_set_sessionid = 4
$process_vm_operation = 8
$process_vm_read = 16
$process_vm_write = 32
$process_dup_handle = 64
$process_create_process = 128
$process_set_quota = 256
$process_set_information = 512
$process_query_information = 1024
$process_query_limited_information = 4096
$process_suspend_resume = 2048
$process_all_access = 2035711
$se_assignprimarytoken_name = "SeAssignPrimaryTokenPrivileg

Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const

$se_audit_name = "SeAuditPrivilege"
$se_backup_name = "SeBackupPrivilege"
$se_change_notify_name = "SeChangeNotifyPrivilege"
$se_create_global_name = "SeCreateGlobalPrivilege"
$se_create_pagefile_name = "SeCreatePagefilePrivilege"
$se_create_permanent_name = "SeCreatePermanentPrivilege"
$se_create_symbolic_link_name = "SeCreateSymbolicLinkPrivil

Global
Global
Global
Global
Global

Const
Const
Const
Const
Const

$se_create_token_name = "SeCreateTokenPrivilege"
$se_debug_name = "SeDebugPrivilege"
$se_enable_delegation_name = "SeEnableDelegationPrivilege"
$se_impersonate_name = "SeImpersonatePrivilege"
$se_inc_base_priority_name = "SeIncreaseBasePriorityPrivile

Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const

$se_inc_working_set_name = "SeIncreaseWorkingSetPrivilege"
$se_increase_quota_name = "SeIncreaseQuotaPrivilege"
$se_load_driver_name = "SeLoadDriverPrivilege"
$se_lock_memory_name = "SeLockMemoryPrivilege"
$se_machine_account_name = "SeMachineAccountPrivilege"
$se_manage_volume_name = "SeManageVolumePrivilege"
$se_prof_single_process_name = "SeProfileSingleProcessPrivi

Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const

$se_relabel_name = "SeRelabelPrivilege"
$se_remote_shutdown_name = "SeRemoteShutdownPrivilege"
$se_restore_name = "SeRestorePrivilege"
$se_security_name = "SeSecurityPrivilege"
$se_shutdown_name = "SeShutdownPrivilege"
$se_sync_agent_name = "SeSyncAgentPrivilege"
$se_system_environment_name = "SeSystemEnvironmentPrivilege

Global
Global
Global
Global
Global
Global
ivilege"
Global
Global

Const
Const
Const
Const
Const
Const

$se_system_profile_name = "SeSystemProfilePrivilege"
$se_systemtime_name = "SeSystemtimePrivilege"
$se_take_ownership_name = "SeTakeOwnershipPrivilege"
$se_tcb_name = "SeTcbPrivilege"
$se_time_zone_name = "SeTimeZonePrivilege"
$se_trusted_credman_access_name = "SeTrustedCredManAccessPr

e"

ege"

ge"

lege"

"

Const $se_unsolicited_input_name = "SeUnsolicitedInputPrivilege"


Const $se_undock_name = "SeUndockPrivilege"

Global Const $se_privilege_enabled_by_default = 1


Global Const $se_privilege_enabled = 2
Global Const $se_privilege_removed = 4
Global Const $se_privilege_used_for_access = -2147483648
Global Const $se_group_mandatory = 1
Global Const $se_group_enabled_by_default = 2
Global Const $se_group_enabled = 4
Global Const $se_group_owner = 8
Global Const $se_group_use_for_deny_only = 16
Global Const $se_group_integrity = 32
Global Const $se_group_integrity_enabled = 64
Global Const $se_group_resource = 536870912
Global Const $se_group_logon_id = -1073741824
Global Enum $tokenprimary = 1, $tokenimpersonation
Global Enum $securityanonymous = 0, $securityidentification, $securityim
personation, $securitydelegation
Global Enum $tokenuser = 1, $tokengroups, $tokenprivileges, $tokenowner,
$tokenprimarygroup, $tokendefaultdacl, $tokensource, $tokentype, $tokenimperson
ationlevel, $tokenstatistics, $tokenrestrictedsids, $tokensessionid, $tokengroup
sandprivileges, $tokensessionreference, $tokensandboxinert, $tokenauditpolicy, $
tokenorigin, $tokenelevationtype, $tokenlinkedtoken, $tokenelevation, $tokenhasr
estrictions, $tokenaccessinformation, $tokenvirtualizationallowed, $tokenvirtual
izationenabled, $tokenintegritylevel, $tokenuiaccess, $tokenmandatorypolicy, $to
kenlogonsid
Global Const $token_assign_primary = 1
Global Const $token_duplicate = 2
Global Const $token_impersonate = 4
Global Const $token_query = 8
Global Const $token_query_source = 16
Global Const $token_adjust_privileges = 32
Global Const $token_adjust_groups = 64
Global Const $token_adjust_default = 128
Global Const $token_adjust_sessionid = 256
Global Const $token_all_access = 983551
Global Const $token_read = 131080
Global Const $token_write = 131296
Global Const $token_execute = 131072
Global Const $token_has_traverse_privilege = 1
Global Const $token_has_backup_privilege = 2
Global Const $token_has_restore_privilege = 4
Global Const $token_has_admin_group = 8
Global Const $token_is_restricted = 16
Global Const $token_session_not_referenced = 32
Global Const $token_sandbox_inert = 64
Global Const $token_has_impersonate_privilege = 128
Global Const $rights_delete = 65536
Global Const $read_control = 131072
Global Const $write_dac = 262144
Global Const $write_owner = 524288
Global Const $synchronize = 1048576
Global Const $access_system_security = 16777216
Global Const $standard_rights_required = 983040
Global Const $standard_rights_read = $read_control
Global Const $standard_rights_write = $read_control
Global Const $standard_rights_execute = $read_control
Global Const $standard_rights_all = 2031616
Global Const $specific_rights_all = 65535
Global Enum $not_used_access = 0, $grant_access, $set_access, $deny_acce
ss, $revoke_access, $set_audit_success, $set_audit_failure
Global Enum $trustee_is_unknown = 0, $trustee_is_user, $trustee_is_group

, $trustee_is_domain, $trustee_is_alias, $trustee_is_well_known_group, $trustee_


is_deleted, $trustee_is_invalid, $trustee_is_computer
Global Const $logon_with_profile = 1
Global Const $logon_netcredentials_only = 2
Global Enum $sidtypeuser = 1, $sidtypegroup, $sidtypedomain, $sidtypeali
as, $sidtypewellknowngroup, $sidtypedeletedaccount, $sidtypeinvalid, $sidtypeunk
nown, $sidtypecomputer, $sidtypelabel
Global Const $sid_administrators = "S-1-5-32-544"
Global Const $sid_users = "S-1-5-32-545"
Global Const $sid_guests = "S-1-5-32-546"
Global Const $sid_account_operators = "S-1-5-32-548"
Global Const $sid_server_operators = "S-1-5-32-549"
Global Const $sid_print_operators = "S-1-5-32-550"
Global Const $sid_backup_operators = "S-1-5-32-551"
Global Const $sid_replicator = "S-1-5-32-552"
Global Const $sid_owner = "S-1-3-0"
Global Const $sid_everyone = "S-1-1-0"
Global Const $sid_network = "S-1-5-2"
Global Const $sid_interactive = "S-1-5-4"
Global Const $sid_system = "S-1-5-18"
Global Const $sid_authenticated_users = "S-1-5-11"
Global Const $sid_schannel_authentication = "S-1-5-64-14"
Global Const $sid_digest_authentication = "S-1-5-64-21"
Global Const $sid_nt_service = "S-1-5-80"
Global Const $sid_untrusted_mandatory_level = "S-1-16-0"
Global Const $sid_low_mandatory_level = "S-1-16-4096"
Global Const $sid_medium_mandatory_level = "S-1-16-8192"
Global Const $sid_medium_plus_mandatory_level = "S-1-16-8448"
Global Const $sid_high_mandatory_level = "S-1-16-12288"
Global Const $sid_system_mandatory_level = "S-1-16-16384"
Global Const $sid_protected_process_mandatory_level = "S-1-16-20480"
Global Const $sid_secure_process_mandatory_level = "S-1-16-28672"
Global Const $sid_all_services = "S-1-5-80-0"
Func _winapi_getlasterror(Const $_icurrenterror = @error, Const $_icurre
ntextended = @extended)
Local $aresult = DllCall("kernel32.dll", "dword", "GetLastError"
)
Return SetError($_icurrenterror, $_icurrentextended, $aresult[0]
)
EndFunc
Func _winapi_setlasterror($ierrorcode, Const $_icurrenterror = @error, C
onst $_icurrentextended = @extended)
DllCall("kernel32.dll", "none", "SetLastError", "dword", $ierror
code)
Return SetError($_icurrenterror, $_icurrentextended, NULL )
EndFunc
Func __comerrorformating($ocomerror, $sprefix = @TAB)
Local Const $str_striptrailing = 2
Local $serror = "COM Error encountered in " & @ScriptName & " ("
& $ocomerror.scriptline & ") :" & @CRLF & $sprefix & "Number
" & @TAB &
"= 0x" & Hex($ocomerror.number, 8) & " (" & $ocomerror.number & ")" & @CRLF & $s
prefix & "WinDescription" & @TAB & "= " & StringStripWS($ocomerror.windescriptio
n, $str_striptrailing) & @CRLF & $sprefix & "Description " & @TAB & "= " & Str
ingStripWS($ocomerror.description, $str_striptrailing) & @CRLF & $sprefix & "Sou
rce
" & @TAB & "= " & $ocomerror.source & @CRLF & $sprefix & "HelpFile
" & @TAB & "= " & $ocomerror.helpfile & @CRLF & $sprefix & "HelpContext " &
@TAB & "= " & $ocomerror.helpcontext & @CRLF & $sprefix & "LastDllError " & @T

AB & "= " & $ocomerror.lastdllerror & @CRLF & $sprefix & "Retcode
& "= 0x" & Hex($ocomerror.retcode)
Return $serror
EndFunc

" & @TAB

Func _security__adjusttokenprivileges($htoken, $bdisableall, $tnewstate,


$ibufferlen, $tprevstate = 0, $prequired = 0)
Local $acall = DllCall("advapi32.dll", "bool", "AdjustTokenPrivi
leges", "handle", $htoken, "bool", $bdisableall, "struct*", $tnewstate, "dword",
$ibufferlen, "struct*", $tprevstate, "struct*", $prequired)
If @error Then Return SetError(@error, @extended, False)
Return NOT ($acall[0] = 0)
EndFunc
Func _security__createprocesswithtoken($htoken, $ilogonflags, $scommandl
ine, $icreationflags, $scurdir, $tstartupinfo, $tprocess_information)
Local $acall = DllCall("advapi32.dll", "bool", "CreateProcessWit
hTokenW", "handle", $htoken, "dword", $ilogonflags, "ptr", 0, "wstr", $scommandl
ine, "dword", $icreationflags, "struct*", 0, "wstr", $scurdir, "struct*", $tstar
tupinfo, "struct*", $tprocess_information)
If @error OR NOT $acall[0] Then Return SetError(@error, @extende
d, False)
Return True
EndFunc
Func _security__duplicatetokenex($hexistingtoken, $idesiredaccess, $iimp
ersonationlevel, $itokentype)
Local $acall = DllCall("advapi32.dll", "bool", "DuplicateTokenEx
", "handle", $hexistingtoken, "dword", $idesiredaccess, "struct*", 0, "int", $ii
mpersonationlevel, "int", $itokentype, "handle*", 0)
If @error OR NOT $acall[0] Then Return SetError(@error, @extende
d, 0)
Return $acall[6]
EndFunc

0])

Func _security__getaccountsid($saccount, $ssystem = "")


Local $aacct = _security__lookupaccountname($saccount, $ssystem)
If @error Then Return SetError(@error, @extended, 0)
If IsArray($aacct) Then Return _security__stringsidtosid($aacct[
EndFunc

Return ""

Func _security__getlengthsid($psid)
If NOT _security__isvalidsid($psid) Then Return SetError(@error
+ 10, @extended, 0)
Local $acall = DllCall("advapi32.dll", "dword", "GetLengthSid",
"struct*", $psid)
If @error Then Return SetError(@error, @extended, 0)
Return $acall[0]
EndFunc
Func _security__gettokeninformation($htoken, $iclass)
Local $acall = DllCall("advapi32.dll", "bool", "GetTokenInformat
ion", "handle", $htoken, "int", $iclass, "struct*", 0, "dword", 0, "dword*", 0)
If @error OR NOT $acall[5] Then Return SetError(@error + 10, @ex
tended, 0)
Local $ilen = $acall[5]
Local $tbuffer = DllStructCreate("byte[" & $ilen & "]")
$acall = DllCall("advapi32.dll", "bool", "GetTokenInformation",

"handle", $htoken, "int", $iclass, "struct*", $tbuffer, "dword", DllStructGetSiz


e($tbuffer), "dword*", 0)
If @error OR NOT $acall[0] Then Return SetError(@error, @extende
d, 0)
Return $tbuffer
EndFunc
Func _security__impersonateself($ilevel = $securityimpersonation)
Local $acall = DllCall("advapi32.dll", "bool", "ImpersonateSelf"
, "int", $ilevel)
If @error Then Return SetError(@error, @extended, False)
Return NOT ($acall[0] = 0)
EndFunc
Func _security__isvalidsid($psid)
Local $acall = DllCall("advapi32.dll", "bool", "IsValidSid", "st
ruct*", $psid)
If @error Then Return SetError(@error, @extended, False)
Return NOT ($acall[0] = 0)
EndFunc
Func _security__lookupaccountname($saccount, $ssystem = "")
Local $tdata = DllStructCreate("byte SID[256]")
Local $acall = DllCall("advapi32.dll", "bool", "LookupAccountNam
eW", "wstr", $ssystem, "wstr", $saccount, "struct*", $tdata, "dword*", DllStruct
GetSize($tdata), "wstr", "", "dword*", DllStructGetSize($tdata), "int*", 0)
If @error OR NOT $acall[0] Then Return SetError(@error, @extende
d, 0)
Local $aacct[3]
$aacct[0] = _security__sidtostringsid(DllStructGetPtr($tdata, "S
ID"))
$aacct[1] = $acall[5]
$aacct[2] = $acall[7]
Return $aacct
EndFunc
Func _security__lookupaccountsid($vsid, $ssystem = "")
Local $psid, $aacct[3]
If IsString($vsid) Then
$psid = _security__stringsidtosid($vsid)
Else
$psid = $vsid
EndIf
If NOT _security__isvalidsid($psid) Then Return SetError(@error
+ 10, @extended, 0)
Local $stypesystem = "ptr"
If $ssystem Then $stypesystem = "wstr"
Local $acall = DllCall("advapi32.dll", "bool", "LookupAccountSid
W", $stypesystem, $ssystem, "struct*", $psid, "wstr", "", "dword*", 65536, "wstr
", "", "dword*", 65536, "int*", 0)
If @error OR NOT $acall[0] Then Return SetError(@error, @extende
d, 0)
Local $aacct[3]
$aacct[0] = $acall[3]
$aacct[1] = $acall[5]
$aacct[2] = $acall[7]
Return $aacct
EndFunc
Func _security__lookupprivilegevalue($ssystem, $sname)

Local $acall = DllCall("advapi32.dll", "bool", "LookupPrivilegeV


alueW", "wstr", $ssystem, "wstr", $sname, "int64*", 0)
If @error OR NOT $acall[0] Then Return SetError(@error, @extende
d, 0)
Return $acall[3]
EndFunc
Func _security__openprocesstoken($hprocess, $iaccess)
Local $acall = DllCall("advapi32.dll", "bool", "OpenProcessToken
", "handle", $hprocess, "dword", $iaccess, "handle*", 0)
If @error OR NOT $acall[0] Then Return SetError(@error, @extende
d, 0)
Return $acall[3]
EndFunc
alse)

Func _security__openthreadtoken($iaccess, $hthread = 0, $bopenasself = F

urrentThread")

If $hthread = 0 Then
Local $aresult = DllCall("kernel32.dll", "handle", "GetC
If @error Then Return SetError(@error + 10, @extended, 0

$hthread = $aresult[0]
EndIf
Local $acall = DllCall("advapi32.dll", "bool", "OpenThreadToken"
, "handle", $hthread, "dword", $iaccess, "bool", $bopenasself, "handle*", 0)
If @error OR NOT $acall[0] Then Return SetError(@error, @extende
d, 0)
Return $acall[4]
EndFunc
False)

Func _security__openthreadtokenex($iaccess, $hthread = 0, $bopenasself =

bopenasself)

Local $htoken = _security__openthreadtoken($iaccess, $hthread, $

If $htoken = 0 Then
Local Const $error_no_token = 1008
If _winapi_getlasterror() <> $error_no_token Then Return
SetError(20, _winapi_getlasterror(), 0)
If NOT _security__impersonateself() Then Return SetError
(@error + 10, _winapi_getlasterror(), 0)
$htoken = _security__openthreadtoken($iaccess, $hthread,
$bopenasself)
If $htoken = 0 Then Return SetError(@error, _winapi_getl
asterror(), 0)
EndIf
Return $htoken
EndFunc

Func _security__setprivilege($htoken, $sprivilege, $benable)


Local $iluid = _security__lookupprivilegevalue("", $sprivilege)
If $iluid = 0 Then Return SetError(@error + 10, @extended, False

Local
ID;dword Attributes"
Local
Local
Local
Local
Local

Const $tagtoken_privileges = "dword Count;align 4;int64 LU


$tcurrstate = DllStructCreate($tagtoken_privileges)
$icurrstate = DllStructGetSize($tcurrstate)
$tprevstate = DllStructCreate($tagtoken_privileges)
$iprevstate = DllStructGetSize($tprevstate)
$trequired = DllStructCreate("int Data")

DllStructSetData($tcurrstate, "Count", 1)
DllStructSetData($tcurrstate, "LUID", $iluid)
If NOT _security__adjusttokenprivileges($htoken, False, $tcurrst
ate, $icurrstate, $tprevstate, $trequired) Then Return SetError(2, @error, False
)
DllStructSetData($tprevstate, "Count", 1)
DllStructSetData($tprevstate, "LUID", $iluid)
Local $iattributes = DllStructGetData($tprevstate, "Attributes")
If $benable Then
$iattributes = BitOR($iattributes, $se_privilege_enabled
)
Else
$iattributes = BitAND($iattributes, BitNOT($se_privilege
_enabled))
EndIf
DllStructSetData($tprevstate, "Attributes", $iattributes)
If NOT _security__adjusttokenprivileges($htoken, False, $tprevst
ate, $iprevstate, $tcurrstate, $trequired) Then Return SetError(3, @error, False
)
Return True
EndFunc
Func _security__settokeninformation($htoken, $itokeninformation, $vtoken
information, $itokeninformationlength)
Local $acall = DllCall("advapi32.dll", "bool", "SetTokenInformat
ion", "handle", $htoken, "int", $itokeninformation, "struct*", $vtokeninformatio
n, "dword", $itokeninformationlength)
If @error OR NOT $acall[0] Then Return SetError(@error, @extende
d, False)
Return True
EndFunc
Func _security__sidtostringsid($psid)
If NOT _security__isvalidsid($psid) Then Return SetError(@error
+ 10, 0, "")
Local $acall = DllCall("advapi32.dll", "bool", "ConvertSidToStri
ngSidW", "struct*", $psid, "ptr*", 0)
If @error OR NOT $acall[0] Then Return SetError(@error, @extende
d, "")
Local $pstringsid = $acall[2]
Local $alen = DllCall("kernel32.dll", "int", "lstrlenW", "struct
*", $pstringsid)
Local $ssid = DllStructGetData(DllStructCreate("wchar Text[" & $
alen[0] + 1 & "]", $pstringsid), "Text")
DllCall("kernel32.dll", "handle", "LocalFree", "handle", $pstrin
gsid)
Return $ssid
EndFunc
Func _security__sidtypestr($itype)
Switch $itype
Case $sidtypeuser
Return "User"
Case $sidtypegroup
Return "Group"
Case $sidtypedomain
Return "Domain"
Case $sidtypealias
Return "Alias"
Case $sidtypewellknowngroup

EndFunc

Return "Well Known Group"


Case $sidtypedeletedaccount
Return "Deleted Account"
Case $sidtypeinvalid
Return "Invalid"
Case $sidtypeunknown
Return "Unknown Type"
Case $sidtypecomputer
Return "Computer"
Case $sidtypelabel
Return "A mandatory integrity label SID"
Case Else
Return "Unknown SID Type"
EndSwitch

Func _security__stringsidtosid($ssid)
Local $acall = DllCall("advapi32.dll", "bool", "ConvertStringSid
ToSidW", "wstr", $ssid, "ptr*", 0)
If @error OR NOT $acall[0] Then Return SetError(@error, @extende
d, 0)
Local $psid = $acall[2]
Local $tbuffer = DllStructCreate("byte Data[" & _security__getle
ngthsid($psid) & "]", $psid)
Local $tsid = DllStructCreate("byte Data[" & DllStructGetSize($t
buffer) & "]")
DllStructSetData($tsid, "Data", DllStructGetData($tbuffer, "Data
"))
DllCall("kernel32.dll", "handle", "LocalFree", "handle", $psid)
Return $tsid
EndFunc
Global Const $tagpoint = "struct;long X;long Y;endstruct"
Global Const $tagrect = "struct;long Left;long Top;long Right;long Botto
m;endstruct"
Global Const $tagsize = "struct;long X;long Y;endstruct"
Global Const $tagmargins = "int cxLeftWidth;int cxRightWidth;int cyTopHe
ight;int cyBottomHeight"
Global Const $tagfiletime = "struct;dword Lo;dword Hi;endstruct"
Global Const $tagsystemtime = "struct;word Year;word Month;word Dow;word
Day;word Hour;word Minute;word Second;word MSeconds;endstruct"
Global Const $tagtime_zone_information = "struct;long Bias;wchar StdName
[32];word StdDate[8];long StdBias;wchar DayName[32];word DayDate[8];long DayBias
;endstruct"
Global Const $tagnmhdr = "struct;hwnd hWndFrom;uint_ptr IDFrom;INT Code;
endstruct"
Global Const $tagcomboboxexitem = "uint Mask;int_ptr Item;ptr Text;int T
extMax;int Image;int SelectedImage;int OverlayImage;" & "int Indent;lparam Param
"
Global Const $tagnmcbedragbegin = $tagnmhdr & ";int ItemID;wchar szText[
260]"
Global Const $tagnmcbeendedit = $tagnmhdr & ";bool fChanged;int NewSelec
tion;wchar szText[260];int Why"
Global Const $tagnmcomboboxex = $tagnmhdr & ";uint Mask;int_ptr Item;ptr
Text;int TextMax;int Image;" & "int SelectedImage;int OverlayImage;int Indent;l
param Param"
Global Const $tagdtprange = "word MinYear;word MinMonth;word MinDOW;word
MinDay;word MinHour;word MinMinute;" & "word MinSecond;word MinMSecond;word Max
Year;word MaxMonth;word MaxDOW;word MaxDay;word MaxHour;" & "word MaxMinute;word
MaxSecond;word MaxMSecond;bool MinValid;bool MaxValid"

temtime

Global Const $tagnmdatetimechange = $tagnmhdr & ";dword Flag;" & $tagsys

Global Const $tagnmdatetimeformat = $tagnmhdr & ";ptr Format;" & $tagsys


temtime & ";ptr pDisplay;wchar Display[64]"
Global Const $tagnmdatetimeformatquery = $tagnmhdr & ";ptr Format;struct
;long SizeX;long SizeY;endstruct"
Global Const $tagnmdatetimekeydown = $tagnmhdr & ";int VirtKey;ptr Forma
t;" & $tagsystemtime
Global Const $tagnmdatetimestring = $tagnmhdr & ";ptr UserString;" & $ta
gsystemtime & ";dword Flags"
Global Const $tageventlogrecord = "dword Length;dword Reserved;dword Rec
ordNumber;dword TimeGenerated;dword TimeWritten;dword EventID;" & "word EventTyp
e;word NumStrings;word EventCategory;word ReservedFlags;dword ClosingRecordNumbe
r;dword StringOffset;" & "dword UserSidLength;dword UserSidOffset;dword DataLeng
th;dword DataOffset"
Global Const $taggdip_effectparams_blur = "float Radius; bool ExpandEdge
"
Global Const $taggdip_effectparams_brightnesscontrast = "int BrightnessL
evel; int ContrastLevel"
Global Const $taggdip_effectparams_colorbalance = "int CyanRed; int Mage
ntaGreen; int YellowBlue"
Global Const $taggdip_effectparams_colorcurve = "int Adjustment; int Cha
nnel; int AdjustValue"
Global Const $taggdip_effectparams_colorlut = "byte LutB[256]; byte LutG
[256]; byte LutR[256]; byte LutA[256]"
Global Const $taggdip_effectparams_huesaturationlightness = "int HueLeve
l; int SaturationLevel; int LightnessLevel"
Global Const $taggdip_effectparams_levels = "int Highlight; int Midtone;
int Shadow"
Global Const $taggdip_effectparams_redeyecorrection = "uint NumberOfArea
s; ptr Areas"
Global Const $taggdip_effectparams_sharpen = "float Radius; float Amount
"
Global Const $taggdip_effectparams_tint = "int Hue; int Amount"
Global Const $taggdipbitmapdata = "uint Width;uint Height;int Stride;int
Format;ptr Scan0;uint_ptr Reserved"
Global Const $taggdipcolormatrix = "float m[25]"
Global Const $taggdipencoderparam = "struct;byte GUID[16];ulong NumberOf
Values;ulong Type;ptr Values;endstruct"
Global Const $taggdipencoderparams = "uint Count;" & $taggdipencoderpara
m
Global Const $taggdiprectf = "struct;float X;float Y;float Width;float H
eight;endstruct"
Global Const $taggdipstartupinput = "uint Version;ptr Callback;bool NoTh
read;bool NoCodecs"
Global Const $taggdipstartupoutput = "ptr HookProc;ptr UnhookProc"
Global Const $taggdipimagecodecinfo = "byte CLSID[16];byte FormatID[16];
ptr CodecName;ptr DllName;ptr FormatDesc;ptr FileExt;" & "ptr MimeType;dword Fla
gs;dword Version;dword SigCount;dword SigSize;ptr SigPattern;ptr SigMask"
Global Const $taggdippencoderparams = "uint Count;byte Params[1]"
Global Const $taghditem = "uint Mask;int XY;ptr Text;handle hBMP;int Tex
tMax;int Fmt;lparam Param;int Image;int Order;uint Type;ptr pFilter;uint State"
Global Const $tagnmhddispinfo = $tagnmhdr & ";int Item;uint Mask;ptr Tex
t;int TextMax;int Image;lparam lParam"
Global Const $tagnmhdfilterbtnclick = $tagnmhdr & ";int Item;" & $tagrec
t
Global Const $tagnmheader = $tagnmhdr & ";int Item;int Button;ptr pItem"
Global Const $taggetipaddress = "byte Field4;byte Field3;byte Field2;byt
e Field1"
Global Const $tagnmipaddress = $tagnmhdr & ";int Field;int Value"

Global Const $taglvfindinfo = "struct;uint Flags;ptr Text;lparam Param;"


& $tagpoint & ";uint Direction;endstruct"
Global Const $taglvhittestinfo = $tagpoint & ";uint Flags;int Item;int S
ubItem;int iGroup"
Global Const $taglvitem = "struct;uint Mask;int Item;int SubItem;uint St
ate;uint StateMask;ptr Text;int TextMax;int Image;lparam Param;" & "int Indent;i
nt GroupID;uint Columns;ptr pColumns;ptr piColFmt;int iGroup;endstruct"
Global Const $tagnmlistview = $tagnmhdr & ";int Item;int SubItem;uint Ne
wState;uint OldState;uint Changed;" & "struct;long ActionX;long ActionY;endstruc
t;lparam Param"
Global Const $tagnmlvcustomdraw = "struct;" & $tagnmhdr & ";dword dwDraw
Stage;handle hdc;" & $tagrect & ";dword_ptr dwItemSpec;uint uItemState;lparam lI
temlParam;endstruct" & ";dword clrText;dword clrTextBk;int iSubItem;dword dwItem
Type;dword clrFace;int iIconEffect;" & "int iIconPhase;int iPartID;int iStateID;
struct;long TextLeft;long TextTop;long TextRight;long TextBottom;endstruct;uint
uAlign"
Global Const $tagnmlvdispinfo = $tagnmhdr & ";" & $taglvitem
Global Const $tagnmlvfinditem = $tagnmhdr & ";int Start;" & $taglvfindin
fo
Global Const $tagnmlvgetinfotip = $tagnmhdr & ";dword Flags;ptr Text;int
TextMax;int Item;int SubItem;lparam lParam"
Global Const $tagnmitemactivate = $tagnmhdr & ";int Index;int SubItem;ui
nt NewState;uint OldState;uint Changed;" & $tagpoint & ";lparam lParam;uint KeyF
lags"
Global Const $tagnmlvkeydown = "align 1;" & $tagnmhdr & ";word VKey;uint
Flags"
Global Const $tagnmlvscroll = $tagnmhdr & ";int DX;int DY"
Global Const $tagmchittestinfo = "uint Size;" & $tagpoint & ";uint Hit;"
& $tagsystemtime & ";" & $tagrect & ";int iOffset;int iRow;int iCol"
Global Const $tagmcmonthrange = "word MinYear;word MinMonth;word MinDOW;
word MinDay;word MinHour;word MinMinute;word MinSecond;" & "word MinMSeconds;wor
d MaxYear;word MaxMonth;word MaxDOW;word MaxDay;word MaxHour;word MaxMinute;word
MaxSecond;" & "word MaxMSeconds;short Span"
Global Const $tagmcrange = "word MinYear;word MinMonth;word MinDOW;word
MinDay;word MinHour;word MinMinute;word MinSecond;" & "word MinMSeconds;word Max
Year;word MaxMonth;word MaxDOW;word MaxDay;word MaxHour;word MaxMinute;word MaxS
econd;" & "word MaxMSeconds;short MinSet;short MaxSet"
Global Const $tagmcselrange = "word MinYear;word MinMonth;word MinDOW;wo
rd MinDay;word MinHour;word MinMinute;word MinSecond;" & "word MinMSeconds;word
MaxYear;word MaxMonth;word MaxDOW;word MaxDay;word MaxHour;word MaxMinute;word M
axSecond;" & "word MaxMSeconds"
Global Const $tagnmdaystate = $tagnmhdr & ";" & $tagsystemtime & ";int D
ayState;ptr pDayState"
Global Const $tagnmselchange = $tagnmhdr & ";struct;word BegYear;word Be
gMonth;word BegDOW;word BegDay;word BegHour;word BegMinute;word BegSecond;word B
egMSeconds;endstruct;" & "struct;word EndYear;word EndMonth;word EndDOW;word End
Day;word EndHour;word EndMinute;word EndSecond;word EndMSeconds;endstruct"
Global Const $tagnmobjectnotify = $tagnmhdr & ";int Item;ptr piid;ptr pO
bject;long Result;dword dwFlags"
Global Const $tagnmtckeydown = "align 1;" & $tagnmhdr & ";word VKey;uint
Flags"
Global Const $tagtvitem = "struct;uint Mask;handle hItem;uint State;uint
StateMask;ptr Text;int TextMax;int Image;int SelectedImage;" & "int Children;lp
aram Param;endstruct"
Global Const $tagtvitemex = "struct;" & $tagtvitem & ";int Integral;uint
uStateEx;hwnd hwnd;int iExpandedImage;int iReserved;endstruct"
Global Const $tagnmtreeview = $tagnmhdr & ";uint Action;" & "struct;uint
OldMask;handle OldhItem;uint OldState;uint OldStateMask;" & "ptr OldText;int Ol
dTextMax;int OldImage;int OldSelectedImage;int OldChildren;lparam OldParam;endst
ruct;" & "struct;uint NewMask;handle NewhItem;uint NewState;uint NewStateMask;"

& "ptr NewText;int NewTextMax;int NewImage;int NewSelectedImage;int NewChildren;


lparam NewParam;endstruct;" & "struct;long PointX;long PointY;endstruct"
Global Const $tagnmtvcustomdraw = "struct;" & $tagnmhdr & ";dword DrawSt
age;handle HDC;" & $tagrect & ";dword_ptr ItemSpec;uint ItemState;lparam ItemPar
am;endstruct" & ";dword ClrText;dword ClrTextBk;int Level"
Global Const $tagnmtvdispinfo = $tagnmhdr & ";" & $tagtvitem
Global Const $tagnmtvgetinfotip = $tagnmhdr & ";ptr Text;int TextMax;han
dle hItem;lparam lParam"
Global Const $tagnmtvitemchange = $tagnmhdr & ";uint Changed;handle hIte
m;uint StateNew;uint StateOld;lparam lParam;"
Global Const $tagtvhittestinfo = $tagpoint & ";uint Flags;handle Item"
Global Const $tagnmtvkeydown = "align 1;" & $tagnmhdr & ";word VKey;uint
Flags"
Global Const $tagnmmouse = $tagnmhdr & ";dword_ptr ItemSpec;dword_ptr It
emData;" & $tagpoint & ";lparam HitInfo"
Global Const $tagtoken_privileges = "dword Count;align 4;int64 LUID;dwor
d Attributes"
Global Const $tagimageinfo = "handle hBitmap;handle hMask;int Unused1;in
t Unused2;" & $tagrect
Global Const $tagmenuinfo = "dword Size;INT Mask;dword Style;uint YMax;h
andle hBack;dword ContextHelpID;ulong_ptr MenuData"
Global Const $tagmenuiteminfo = "uint Size;uint Mask;uint Type;uint Stat
e;uint ID;handle SubMenu;handle BmpChecked;handle BmpUnchecked;" & "ulong_ptr It
emData;ptr TypeData;uint CCH;handle BmpItem"
Global Const $tagrebarbandinfo = "uint cbSize;uint fMask;uint fStyle;dwo
rd clrFore;dword clrBack;ptr lpText;uint cch;" & "int iImage;hwnd hwndChild;uint
cxMinChild;uint cyMinChild;uint cx;handle hbmBack;uint wID;uint cyChild;uint cy
MaxChild;" & "uint cyIntegral;uint cxIdeal;lparam lParam;uint cxHeader" & ((@OSV
ersion = "WIN_XP") ? "" : ";" & $tagrect & ";uint uChevronState")
Global Const $tagnmrebarautobreak = $tagnmhdr & ";uint uBand;uint wID;lp
aram lParam;uint uMsg;uint fStyleCurrent;bool fAutoBreak"
Global Const $tagnmrbautosize = $tagnmhdr & ";bool fChanged;" & "struct;
long TargetLeft;long TargetTop;long TargetRight;long TargetBottom;endstruct;" &
"struct;long ActualLeft;long ActualTop;long ActualRight;long ActualBottom;endstr
uct"
Global Const $tagnmrebar = $tagnmhdr & ";dword dwMask;uint uBand;uint fS
tyle;uint wID;lparam lParam"
Global Const $tagnmrebarchevron = $tagnmhdr & ";uint uBand;uint wID;lpar
am lParam;" & $tagrect & ";lparam lParamNM"
Global Const $tagnmrebarchildsize = $tagnmhdr & ";uint uBand;uint wID;"
& "struct;long CLeft;long CTop;long CRight;long CBottom;endstruct;" & "struct;lo
ng BLeft;long BTop;long BRight;long BBottom;endstruct"
Global Const $tagcolorscheme = "dword Size;dword BtnHighlight;dword BtnS
hadow"
Global Const $tagnmtoolbar = $tagnmhdr & ";int iItem;" & "struct;int iBi
tmap;int idCommand;byte fsState;byte fsStyle;dword_ptr dwData;int_ptr iString;en
dstruct" & ";int cchText;ptr pszText;" & $tagrect
Global Const $tagnmtbhotitem = $tagnmhdr & ";int idOld;int idNew;dword d
wFlags"
Global Const $tagtbbutton = "int Bitmap;int Command;byte State;byte Styl
e;dword_ptr Param;int_ptr String"
Global Const $tagtbbuttoninfo = "uint Size;dword Mask;int Command;int Im
age;byte State;byte Style;word CX;dword_ptr Param;ptr Text;int TextMax"
Global Const $tagnetresource = "dword Scope;dword Type;dword DisplayType
;dword Usage;ptr LocalName;ptr RemoteName;ptr Comment;ptr Provider"
Global Const $tagoverlapped = "ulong_ptr Internal;ulong_ptr InternalHigh
;struct;dword Offset;dword OffsetHigh;endstruct;handle hEvent"
Global Const $tagopenfilename = "dword StructSize;hwnd hwndOwner;handle
hInstance;ptr lpstrFilter;ptr lpstrCustomFilter;" & "dword nMaxCustFilter;dword
nFilterIndex;ptr lpstrFile;dword nMaxFile;ptr lpstrFileTitle;dword nMaxFileTitle

;" & "ptr lpstrInitialDir;ptr lpstrTitle;dword Flags;word nFileOffset;word nFile


Extension;ptr lpstrDefExt;lparam lCustData;" & "ptr lpfnHook;ptr lpTemplateName;
ptr pvReserved;dword dwReserved;dword FlagsEx"
Global Const $tagbitmapinfoheader = "struct;dword biSize;long biWidth;lo
ng biHeight;word biPlanes;word biBitCount;" & "dword biCompression;dword biSizeI
mage;long biXPelsPerMeter;long biYPelsPerMeter;dword biClrUsed;dword biClrImport
ant;endstruct"
Global Const $tagbitmapinfo = $tagbitmapinfoheader & ";dword biRGBQuad[1
]"
Global Const $tagblendfunction = "byte Op;byte Flags;byte Alpha;byte For
mat"
Global Const $tagguid = "struct;ulong Data1;ushort Data2;ushort Data3;by
te Data4[8];endstruct"
Global Const $tagwindowplacement = "uint length;uint flags;uint showCmd;
long ptMinPosition[2];long ptMaxPosition[2];long rcNormalPosition[4]"
Global Const $tagwindowpos = "hwnd hWnd;hwnd InsertAfter;int X;int Y;int
CX;int CY;uint Flags"
Global Const $tagscrollinfo = "uint cbSize;uint fMask;int nMin;int nMax;
uint nPage;int nPos;int nTrackPos"
Global Const $tagscrollbarinfo = "dword cbSize;" & $tagrect & ";int dxyL
ineButton;int xyThumbTop;" & "int xyThumbBottom;int reserved;dword rgstate[6]"
Global Const $taglogfont = "struct;long Height;long Width;long Escapemen
t;long Orientation;long Weight;byte Italic;byte Underline;" & "byte Strikeout;by
te CharSet;byte OutPrecision;byte ClipPrecision;byte Quality;byte PitchAndFamily
;wchar FaceName[32];endstruct"
Global Const $tagkbdllhookstruct = "dword vkCode;dword scanCode;dword fl
ags;dword time;ulong_ptr dwExtraInfo"
Global Const $tagprocess_information = "handle hProcess;handle hThread;d
word ProcessID;dword ThreadID"
Global Const $tagstartupinfo = "dword Size;ptr Reserved1;ptr Desktop;ptr
Title;dword X;dword Y;dword XSize;dword YSize;dword XCountChars;" & "dword YCou
ntChars;dword FillAttribute;dword Flags;word ShowWindow;word Reserved2;ptr Reser
ved3;handle StdInput;" & "handle StdOutput;handle StdError"
Global Const $tagsecurity_attributes = "dword Length;ptr Descriptor;bool
InheritHandle"
Global Const $tagwin32_find_data = "dword dwFileAttributes;dword ftCreat
ionTime[2];dword ftLastAccessTime[2];dword ftLastWriteTime[2];dword nFileSizeHig
h;dword nFileSizeLow;dword dwReserved0;dword dwReserved1;wchar cFileName[260];wc
har cAlternateFileName[14]"
Global Const $tagtextmetric = "long tmHeight;long tmAscent;long tmDescen
t;long tmInternalLeading;long tmExternalLeading;" & "long tmAveCharWidth;long tm
MaxCharWidth;long tmWeight;long tmOverhang;long tmDigitizedAspectX;long tmDigiti
zedAspectY;" & "wchar tmFirstChar;wchar tmLastChar;wchar tmDefaultChar;wchar tmB
reakChar;byte tmItalic;byte tmUnderlined;byte tmStruckOut;" & "byte tmPitchAndFa
mily;byte tmCharSet"
Global Const $tagmemmap = "handle hProc;ulong_ptr Size;ptr Mem"
Func _memfree(ByRef $tmemmap)
Local $pmemory = DllStructGetData($tmemmap, "Mem")
Local $hprocess = DllStructGetData($tmemmap, "hProc")
Local $bresult = _memvirtualfreeex($hprocess, $pmemory, 0, $mem_
release)
DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hproce
ss)
If @error Then Return SetError(@error, @extended, False)
Return $bresult
EndFunc
Func _memglobalalloc($ibytes, $iflags = 0)
Local $aresult = DllCall("kernel32.dll", "handle", "GlobalAlloc"

, "uint", $iflags, "ulong_ptr", $ibytes)


If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _memglobalfree($hmemory)
Local $aresult = DllCall("kernel32.dll", "ptr", "GlobalFree", "h
andle", $hmemory)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _memgloballock($hmemory)
Local $aresult = DllCall("kernel32.dll", "ptr", "GlobalLock", "h
andle", $hmemory)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _memglobalsize($hmemory)
Local $aresult = DllCall("kernel32.dll", "ulong_ptr", "GlobalSiz
e", "handle", $hmemory)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _memglobalunlock($hmemory)
Local $aresult = DllCall("kernel32.dll", "bool", "GlobalUnlock",
"handle", $hmemory)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _meminit($hwnd, $isize, ByRef $tmemmap)
Local $aresult = DllCall("user32.dll", "dword", "GetWindowThread
ProcessId", "hwnd", $hwnd, "dword*", 0)
If @error Then Return SetError(@error + 10, @extended, 0)
Local $iprocessid = $aresult[2]
If $iprocessid = 0 Then Return SetError(1, 0, 0)
Local $iaccess = BitOR($process_vm_operation, $process_vm_read,
$process_vm_write)
Local $hprocess = __mem_openprocess($iaccess, False, $iprocessid
, True)
Local $ialloc = BitOR($mem_reserve, $mem_commit)
Local $pmemory = _memvirtualallocex($hprocess, 0, $isize, $iallo
c, $page_readwrite)
If $pmemory = 0 Then Return SetError(2, 0, 0)
$tmemmap = DllStructCreate($tagmemmap)
DllStructSetData($tmemmap, "hProc", $hprocess)
DllStructSetData($tmemmap, "Size", $isize)
DllStructSetData($tmemmap, "Mem", $pmemory)
Return $pmemory
EndFunc
Func _memmovememory($psource, $pdest, $ilength)
DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pde
st, "struct*", $psource, "ulong_ptr", $ilength)
If @error Then Return SetError(@error, @extended)
EndFunc

Func _memread(ByRef $tmemmap, $psrce, $pdest, $isize)


Local $aresult = DllCall("kernel32.dll", "bool", "ReadProcessMem
ory", "handle", DllStructGetData($tmemmap, "hProc"), "ptr", $psrce, "struct*", $
pdest, "ulong_ptr", $isize, "ulong_ptr*", 0)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _memwrite(ByRef $tmemmap, $psrce, $pdest = 0, $isize = 0, $ssrce =
"struct*")
If $pdest = 0 Then $pdest = DllStructGetData($tmemmap, "Mem")
If $isize = 0 Then $isize = DllStructGetData($tmemmap, "Size")
Local $aresult = DllCall("kernel32.dll", "bool", "WriteProcessMe
mory", "handle", DllStructGetData($tmemmap, "hProc"), "ptr", $pdest, $ssrce, $ps
rce, "ulong_ptr", $isize, "ulong_ptr*", 0)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _memvirtualalloc($paddress, $isize, $iallocation, $iprotect)
Local $aresult = DllCall("kernel32.dll", "ptr", "VirtualAlloc",
"ptr", $paddress, "ulong_ptr", $isize, "dword", $iallocation, "dword", $iprotect
)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
otect)

Func _memvirtualallocex($hprocess, $paddress, $isize, $iallocation, $ipr

Local $aresult = DllCall("kernel32.dll", "ptr", "VirtualAllocEx"


, "handle", $hprocess, "ptr", $paddress, "ulong_ptr", $isize, "dword", $iallocat
ion, "dword", $iprotect)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _memvirtualfree($paddress, $isize, $ifreetype)
Local $aresult = DllCall("kernel32.dll", "bool", "VirtualFree",
"ptr", $paddress, "ulong_ptr", $isize, "dword", $ifreetype)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _memvirtualfreeex($hprocess, $paddress, $isize, $ifreetype)
Local $aresult = DllCall("kernel32.dll", "bool", "VirtualFreeEx"
, "handle", $hprocess, "ptr", $paddress, "ulong_ptr", $isize, "dword", $ifreetyp
e)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
alse)

Func __mem_openprocess($iaccess, $binherit, $iprocessid, $bdebugpriv = F

Local $aresult = DllCall("kernel32.dll", "handle", "OpenProcess"


, "dword", $iaccess, "bool", $binherit, "dword", $iprocessid)
If @error Then Return SetError(@error + 10, @extended, 0)
If $aresult[0] Then Return $aresult[0]
If NOT $bdebugpriv Then Return 0
Local $htoken = _security__openthreadtokenex(BitOR($token_adjust
_privileges, $token_query))

If @error Then Return SetError(@error + 20, @extended, 0)


_security__setprivilege($htoken, "SeDebugPrivilege", True)
Local $ierror = @error
Local $ilasterror = @extended
Local $iret = 0
If NOT @error Then
$aresult = DllCall("kernel32.dll", "handle", "OpenProces
s", "dword", $iaccess, "bool", $binherit, "dword", $iprocessid)
$ierror = @error
$ilasterror = @extended
If $aresult[0] Then $iret = $aresult[0]
_security__setprivilege($htoken, "SeDebugPrivilege", Fal
se)
If @error Then
$ierror = @error + 30
$ilasterror = @extended
EndIf
Else
$ierror = @error + 40
EndIf
DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $htoken
)
Return SetError($ierror, $ilasterror, $iret)
EndFunc
Func _sendmessage($hwnd, $imsg, $wparam = 0, $lparam = 0, $ireturn = 0,
$wparamtype = "wparam", $lparamtype = "lparam", $sreturntype = "lresult")
Local $aresult = DllCall("user32.dll", $sreturntype, "SendMessag
eW", "hwnd", $hwnd, "uint", $imsg, $wparamtype, $wparam, $lparamtype, $lparam)
If @error Then Return SetError(@error, @extended, "")
If $ireturn >= 0 AND $ireturn <= 4 Then Return $aresult[$ireturn
]
Return $aresult
EndFunc
Func _sendmessagea($hwnd, $imsg, $wparam = 0, $lparam = 0, $ireturn = 0,
$wparamtype = "wparam", $lparamtype = "lparam", $sreturntype = "lresult")
Local $aresult = DllCall("user32.dll", $sreturntype, "SendMessag
eA", "hwnd", $hwnd, "uint", $imsg, $wparamtype, $wparam, $lparamtype, $lparam)
If @error Then Return SetError(@error, @extended, "")
If $ireturn >= 0 AND $ireturn <= 4 Then Return $aresult[$ireturn
]
Return $aresult
EndFunc
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$opt_coordsrelative = 0
$opt_coordsabsolute = 1
$opt_coordsclient = 2
$opt_errorsilent = 0
$opt_errorfatal = 1
$opt_capsnostore = 0
$opt_capsstore = 1
$opt_matchstart = 1
$opt_matchany = 2
$opt_matchexact = 3
$opt_matchadvanced = 4
$ccs_top = 1
$ccs_nomovey = 2
$ccs_bottom = 3
$ccs_noresize = 4

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$ccs_noparentalign = 8
$ccs_nohilite = 16
$ccs_adjustable = 32
$ccs_nodivider = 64
$ccs_vert = 128
$ccs_left = 129
$ccs_nomovex = 130
$ccs_right = 131
$dt_drivetype = 1
$dt_ssdstatus = 2
$dt_bustype = 3
$proxy_ie = 0
$proxy_none = 1
$proxy_specified = 2
$objid_window = 0
$objid_titlebar = -2
$objid_sizegrip = -7
$objid_caret = -8
$objid_cursor = -9
$objid_alert = -10
$objid_sound = -11
$dlg_centerontop = 0
$dlg_notitle = 1
$dlg_notontop = 2
$dlg_textleft = 4
$dlg_textright = 8
$dlg_moveable = 16
$dlg_textvcenter = 32
$idc_unknown = 0
$idc_appstarting = 1
$idc_arrow = 2
$idc_cross = 3
$idc_hand = 32649
$idc_help = 4
$idc_ibeam = 5
$idc_icon = 6
$idc_no = 7
$idc_size = 8
$idc_sizeall = 9
$idc_sizenesw = 10
$idc_sizens = 11
$idc_sizenwse = 12
$idc_sizewe = 13
$idc_uparrow = 14
$idc_wait = 15
$idi_application = 32512
$idi_asterisk = 32516
$idi_exclamation = 32515
$idi_hand = 32513
$idi_question = 32514
$idi_winlogo = 32517
$idi_shield = 32518
$idi_error = $idi_hand
$idi_information = $idi_asterisk
$idi_warning = $idi_exclamation
$sd_logoff = 0
$sd_shutdown = 1
$sd_reboot = 2
$sd_force = 4
$sd_powerdown = 8

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$sd_forcehung = 16
$sd_standby = 32
$sd_hibernate = 64
$stdin_child = 1
$stdout_child = 2
$stderr_child = 4
$stderr_merged = 8
$stdio_inherit_parent = 16
$run_create_new_console = 65536
$ubound_dimensions = 0
$ubound_rows = 1
$ubound_columns = 2
$mouseeventf_absolute = 32768
$mouseeventf_move = 1
$mouseeventf_leftdown = 2
$mouseeventf_leftup = 4
$mouseeventf_rightdown = 8
$mouseeventf_rightup = 16
$mouseeventf_middledown = 32
$mouseeventf_middleup = 64
$mouseeventf_wheel = 2048
$mouseeventf_xdown = 128
$mouseeventf_xup = 256
$reg_none = 0
$reg_sz = 1
$reg_expand_sz = 2
$reg_binary = 3
$reg_dword = 4
$reg_dword_little_endian = 4
$reg_dword_big_endian = 5
$reg_link = 6
$reg_multi_sz = 7
$reg_resource_list = 8
$reg_full_resource_descriptor = 9
$reg_resource_requirements_list = 10
$reg_qword = 11
$reg_qword_little_endian = 11
$hwnd_bottom = 1
$hwnd_notopmost = -2
$hwnd_top = 0
$hwnd_topmost = -1
$swp_nosize = 1
$swp_nomove = 2
$swp_nozorder = 4
$swp_noredraw = 8
$swp_noactivate = 16
$swp_framechanged = 32
$swp_drawframe = 32
$swp_showwindow = 64
$swp_hidewindow = 128
$swp_nocopybits = 256
$swp_noownerzorder = 512
$swp_noreposition = 512
$swp_nosendchanging = 1024
$swp_defererase = 8192
$swp_asyncwindowpos = 16384
$keyword_default = 1
$keyword_null = 2
$declared_local = -1
$declared_unknown = 0

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$declared_global = 1
$assign_create = 0
$assign_forcelocal = 1
$assign_forceglobal = 2
$assign_existfail = 4
$bi_enable = 0
$bi_disable = 1
$break_enable = 1
$break_disable = 0
$cdtray_open = "open"
$cdtray_closed = "closed"
$send_default = 0
$send_raw = 1
$dir_default = 0
$dir_extended = 1
$dir_norecurse = 2
$dir_remove = 1
$dt_all = "ALL"
$dt_cdrom = "CDROM"
$dt_removable = "REMOVABLE"
$dt_fixed = "FIXED"
$dt_network = "NETWORK"
$dt_ramdisk = "RAMDISK"
$dt_unknown = "UNKNOWN"
$dt_undefined = 1
$dt_fat = "FAT"
$dt_fat32 = "FAT32"
$dt_exfat = "exFAT"
$dt_ntfs = "NTFS"
$dt_nwfs = "NWFS"
$dt_cdfs = "CDFS"
$dt_udf = "UDF"
$dma_default = 0
$dma_persistent = 1
$dma_authentication = 8
$ds_unknown = "UNKNOWN"
$ds_ready = "READY"
$ds_notready = "NOTREADY"
$ds_invalid = "INVALID"
$mouse_click_left = "left"
$mouse_click_right = "right"
$mouse_click_middle = "middle"
$mouse_click_main = "main"
$mouse_click_menu = "menu"
$mouse_click_primary = "primary"
$mouse_click_secondary = "secondary"
$mouse_wheel_up = "up"
$mouse_wheel_down = "down"
$number_auto = 0
$number_32bit = 1
$number_64bit = 2
$number_double = 3
$obj_name = 1
$obj_string = 2
$obj_progid = 3
$obj_file = 4
$obj_module = 5
$obj_clsid = 6
$obj_iid = 7
$exitclose_normal = 0

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$exitclose_byexit = 1
$exitclose_byclick = 2
$exitclose_bylogoff = 3
$exitclose_bysutdown = 4
$process_stats_memory = 0
$process_stats_io = 1
$process_low = 0
$process_belownormal = 1
$process_normal = 2
$process_abovenormal = 3
$process_high = 4
$process_realtime = 5
$run_logon_noprofile = 0
$run_logon_profile = 1
$run_logon_network = 2
$run_logon_inherit = 4
$sound_nowait = 0
$sound_wait = 1
$shex_open = "open"
$shex_edit = "edit"
$shex_print = "print"
$shex_properties = "properties"
$tcp_data_default = 0
$tcp_data_binary = 1
$udp_open_default = 0
$udp_open_broadcast = 1
$udp_data_default = 0
$udp_data_binary = 1
$udp_data_array = 2
$tip_noicon = 0
$tip_infoicon = 1
$tip_warningicon = 2
$tip_erroricon = 3
$tip_balloon = 1
$tip_center = 2
$tip_forcevisible = 4
$windows_noontop = 0
$windows_ontop = 1
$fc_nooverwrite = 0
$fc_overwrite = 1
$fc_createpath = 8
$ft_modified = 0
$ft_created = 1
$ft_accessed = 2
$ft_array = 0
$ft_string = 1
$fsf_createbutton = 1
$fsf_newdialog = 2
$fsf_editcontrol = 4
$ft_nonrecursive = 0
$ft_recursive = 1
$fo_read = 0
$fo_append = 1
$fo_overwrite = 2
$fo_createpath = 8
$fo_binary = 16
$fo_unicode = 32
$fo_utf16_le = 32
$fo_utf16_be = 64
$fo_utf8 = 128

_write)

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$fo_utf8_nobom = 256
$fo_ansi = 512
$fo_utf16_le_nobom = 1024
$fo_utf16_be_nobom = 2048
$fo_utf8_full = 16384
$fo_fullfile_detect = 16384
$eof = -1
$fd_filemustexist = 1
$fd_pathmustexist = 2
$fd_multiselect = 4
$fd_promptcreatenew = 8
$fd_promptoverwrite = 16
$create_new = 1
$create_always = 2
$open_existing = 3
$open_always = 4
$truncate_existing = 5
$invalid_set_file_pointer = -1
$file_begin = 0
$file_current = 1
$file_end = 2
$file_attribute_readonly = 1
$file_attribute_hidden = 2
$file_attribute_system = 4
$file_attribute_directory = 16
$file_attribute_archive = 32
$file_attribute_device = 64
$file_attribute_normal = 128
$file_attribute_temporary = 256
$file_attribute_sparse_file = 512
$file_attribute_reparse_point = 1024
$file_attribute_compressed = 2048
$file_attribute_offline = 4096
$file_attribute_not_content_indexed = 8192
$file_attribute_encrypted = 16384
$file_share_read = 1
$file_share_write = 2
$file_share_delete = 4
$file_share_readwrite = BitOR($file_share_read, $file_share

Global Const $file_share_any = BitOR($file_share_read, $file_share_write


, $file_share_delete)
Global Const $generic_all = 268435456
Global Const $generic_execute = 536870912
Global Const $generic_write = 1073741824
Global Const $generic_read = -2147483648
Global Const $generic_readwrite = BitOR($generic_read, $generic_write)
Global Const $file_encoding_utf16le = 32
Global Const $fe_entire_utf8 = 1
Global Const $fe_partialfirst_utf8 = 2
Global Const $fn_fullpath = 0
Global Const $fn_relativepath = 1
Global Const $fv_comments = "Comments"
Global Const $fv_companyname = "CompanyName"
Global Const $fv_filedescription = "FileDescription"
Global Const $fv_fileversion = "FileVersion"
Global Const $fv_internalname = "InternalName"
Global Const $fv_legalcopyright = "LegalCopyright"
Global Const $fv_legaltrademarks = "LegalTrademarks"
Global Const $fv_originalfilename = "OriginalFilename"

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$fv_productname = "ProductName"
$fv_productversion = "ProductVersion"
$fv_privatebuild = "PrivateBuild"
$fv_specialbuild = "SpecialBuild"
$frta_nocount = 0
$frta_count = 1
$frta_intarrays = 2
$frta_entiresplit = 4
$flta_filesfolders = 0
$flta_files = 1
$flta_folders = 2
$fltar_filesfolders = 0
$fltar_files = 1
$fltar_folders = 2
$fltar_nohidden = 4
$fltar_nosystem = 8
$fltar_nolink = 16
$fltar_norecur = 0
$fltar_recur = 1
$fltar_nosort = 0
$fltar_sort = 1
$fltar_fastsort = 2
$fltar_nopath = 0
$fltar_relpath = 1
$fltar_fullpath = 2
$mb_ok = 0
$mb_okcancel = 1
$mb_abortretryignore = 2
$mb_yesnocancel = 3
$mb_yesno = 4
$mb_retrycancel = 5
$mb_canceltrycontinue = 6
$mb_help = 16384
$mb_iconstop = 16
$mb_iconerror = 16
$mb_iconhand = 16
$mb_iconquestion = 32
$mb_iconexclamation = 48
$mb_iconwarning = 48
$mb_iconinformation = 64
$mb_iconasterisk = 64
$mb_usericon = 128
$mb_defbutton1 = 0
$mb_defbutton2 = 256
$mb_defbutton3 = 512
$mb_defbutton4 = 768
$mb_applmodal = 0
$mb_systemmodal = 4096
$mb_taskmodal = 8192
$mb_default_desktop_only = 131072
$mb_right = 524288
$mb_rtlreading = 1048576
$mb_setforeground = 65536
$mb_topmost = 262144
$mb_service_notification = 2097152
$mb_rightjustified = $mb_right
$idtimeout = -1
$idok = 1
$idcancel = 2
$idabort = 3

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$idretry = 4
$idignore = 5
$idyes = 6
$idno = 7
$idclose = 8
$idhelp = 9
$idtryagain = 10
$idcontinue = 11
$str_nocasesense = 0
$str_casesense = 1
$str_nocasesensebasic = 2
$str_stripleading = 1
$str_striptrailing = 2
$str_stripspaces = 4
$str_stripall = 8
$str_chrsplit = 0
$str_entiresplit = 1
$str_nocount = 2
$str_regexpmatch = 0
$str_regexparraymatch = 1
$str_regexparrayfullmatch = 2
$str_regexparrayglobalmatch = 3
$str_regexparrayglobalfullmatch = 4
$str_endisstart = 0
$str_endnotstart = 1
$sb_ansi = 1
$sb_utf16le = 2
$sb_utf16be = 3
$sb_utf8 = 4
$se_utf16 = 0
$se_ansi = 1
$se_utf8 = 2
$str_utf16 = 0
$str_ucs2 = 1
$hgdi_error = Ptr(-1)
$invalid_handle_value = Ptr(-1)
$clr_invalid = -1
$null_brush = 5
$null_pen = 8
$black_brush = 4
$dkgray_brush = 3
$dc_brush = 18
$gray_brush = 2
$hollow_brush = $null_brush
$ltgray_brush = 1
$white_brush = 0
$black_pen = 7
$dc_pen = 19
$white_pen = 6
$ansi_fixed_font = 11
$ansi_var_font = 12
$device_default_font = 14
$default_gui_font = 17
$oem_fixed_font = 10
$system_font = 13
$system_fixed_font = 16
$default_palette = 15
$mb_precomposed = 1
$mb_composite = 2
$mb_useglyphchars = 4

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$ulw_alpha = 2
$ulw_colorkey = 1
$ulw_opaque = 4
$ulw_ex_noresize = 8
$wh_callwndproc = 4
$wh_callwndprocret = 12
$wh_cbt = 5
$wh_debug = 9
$wh_foregroundidle = 11
$wh_getmessage = 3
$wh_journalplayback = 1
$wh_journalrecord = 0
$wh_keyboard = 2
$wh_keyboard_ll = 13
$wh_mouse = 7
$wh_mouse_ll = 14
$wh_msgfilter = -1
$wh_shell = 10
$wh_sysmsgfilter = 6
$wpf_asyncwindowplacement = 4
$wpf_restoretomaximized = 2
$wpf_setminposition = 1
$kf_extended = 256
$kf_altdown = 8192
$kf_up = 32768
$llkhf_extended = BitShift($kf_extended, 8)
$llkhf_injected = 16
$llkhf_altdown = BitShift($kf_altdown, 8)
$llkhf_up = BitShift($kf_up, 8)
$ofn_allowmultiselect = 512
$ofn_createprompt = 8192
$ofn_dontaddtorecent = 33554432
$ofn_enablehook = 32
$ofn_enableincludenotify = 4194304
$ofn_enablesizing = 8388608
$ofn_enabletemplate = 64
$ofn_enabletemplatehandle = 128
$ofn_explorer = 524288
$ofn_extensiondifferent = 1024
$ofn_filemustexist = 4096
$ofn_forceshowhidden = 268435456
$ofn_hidereadonly = 4
$ofn_longnames = 2097152
$ofn_nochangedir = 8
$ofn_nodereferencelinks = 1048576
$ofn_nolongnames = 262144
$ofn_nonetworkbutton = 131072
$ofn_noreadonlyreturn = 32768
$ofn_notestfilecreate = 65536
$ofn_novalidate = 256
$ofn_overwriteprompt = 2
$ofn_pathmustexist = 2048
$ofn_readonly = 1
$ofn_shareaware = 16384
$ofn_showhelp = 16
$ofn_ex_noplacesbar = 1
$tmpf_fixed_pitch = 1
$tmpf_vector = 2
$tmpf_truetype = 4
$tmpf_device = 8

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$duplicate_close_source = 1
$duplicate_same_access = 2
$di_mask = 1
$di_image = 2
$di_normal = 3
$di_compat = 4
$di_defaultsize = 8
$di_nomirror = 16
$display_device_attached_to_desktop = 1
$display_device_multi_driver = 2
$display_device_primary_device = 4
$display_device_mirroring_driver = 8
$display_device_vga_compatible = 16
$display_device_removable = 32
$display_device_disconnect = 33554432
$display_device_remote = 67108864
$display_device_modespruned = 134217728
$flashw_caption = 1
$flashw_tray = 2
$flashw_timer = 4
$flashw_timernofg = 12
$format_message_allocate_buffer = 256
$format_message_ignore_inserts = 512
$format_message_from_string = 1024
$format_message_from_hmodule = 2048
$format_message_from_system = 4096
$format_message_argument_array = 8192
$gw_hwndfirst = 0
$gw_hwndlast = 1
$gw_hwndnext = 2
$gw_hwndprev = 3
$gw_owner = 4
$gw_child = 5
$gw_enabledpopup = 6
$gwl_wndproc = -4
$gwl_hinstance = -6
$gwl_hwndparent = -8
$gwl_id = -12
$gwl_style = -16
$gwl_exstyle = -20
$gwl_userdata = -21
$std_cut = 0
$std_copy = 1
$std_paste = 2
$std_undo = 3
$std_redow = 4
$std_delete = 5
$std_filenew = 6
$std_fileopen = 7
$std_filesave = 8
$std_printpre = 9
$std_properties = 10
$std_help = 11
$std_find = 12
$std_replace = 13
$std_print = 14
$image_bitmap = 0
$image_icon = 1
$image_cursor = 2
$image_enhmetafile = 3

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$kb_sendspecial = 0
$kb_sendraw = 1
$kb_capsoff = 0
$kb_capson = 1
$dont_resolve_dll_references = 1
$load_library_as_datafile = 2
$load_with_altered_search_path = 8
$load_ignore_code_authz_level = 16
$load_library_as_datafile_exclusive = 64
$load_library_as_image_resource = 32
$load_library_search_application_dir = 512
$load_library_search_default_dirs = 4096
$load_library_search_dll_load_dir = 256
$load_library_search_system32 = 2048
$load_library_search_user_dirs = 1024
$s_ok = 0
$e_abort = -2147467260
$e_accessdenied = -2147024891
$e_fail = -2147467259
$e_handle = -2147024890
$e_invalidarg = -2147024809
$e_nointerface = -2147467262
$e_notimpl = -2147467263
$e_outofmemory = -2147024882
$e_pointer = -2147467261
$e_unexpected = -2147418113
$lr_defaultcolor = 0
$lr_monochrome = 1
$lr_color = 2
$lr_copyreturnorg = 4
$lr_copydeleteorg = 8
$lr_loadfromfile = 16
$lr_loadtransparent = 32
$lr_defaultsize = 64
$lr_vgacolor = 128
$lr_loadmap3dcolors = 4096
$lr_createdibsection = 8192
$lr_copyfromresource = 16384
$lr_shared = 32768
$obm_trtype = 32732
$obm_lfarrowi = 32734
$obm_rgarrowi = 32735
$obm_dnarrowi = 32736
$obm_uparrowi = 32737
$obm_combo = 32738
$obm_mnarrow = 32739
$obm_lfarrowd = 32740
$obm_rgarrowd = 32741
$obm_dnarrowd = 32742
$obm_uparrowd = 32743
$obm_restored = 32744
$obm_zoomd = 32745
$obm_reduced = 32746
$obm_restore = 32747
$obm_zoom = 32748
$obm_reduce = 32749
$obm_lfarrow = 32750
$obm_rgarrow = 32751
$obm_dnarrow = 32752
$obm_uparrow = 32753

Global Const $obm_close = 32754


Global Const $obm_old_restore = 32755
Global Const $obm_old_zoom = 32756
Global Const $obm_old_reduce = 32757
Global Const $obm_btncorners = 32758
Global Const $obm_checkboxes = 32759
Global Const $obm_check = 32760
Global Const $obm_btsize = 32761
Global Const $obm_old_lfarrow = 32762
Global Const $obm_old_rgarrow = 32763
Global Const $obm_old_dnarrow = 32764
Global Const $obm_old_uparrow = 32765
Global Const $obm_size = 32766
Global Const $obm_old_close = 32767
Global Const $oic_sample = 32512
Global Const $oic_hand = 32513
Global Const $oic_ques = 32514
Global Const $oic_bang = 32515
Global Const $oic_note = 32516
Global Const $oic_winlogo = 32517
Global Const $oic_warning = $oic_bang
Global Const $oic_error = $oic_hand
Global Const $oic_information = $oic_note
Global $__g_ainprocess_winapi[64][2] = [[0, 0]]
Global $__g_awinlist_winapi[64][2] = [[0, 0]]
Global Const $__winapiconstant_wm_setfont = 48
Global Const $__winapiconstant_fw_normal = 400
Global Const $__winapiconstant_default_charset = 1
Global Const $__winapiconstant_out_default_precis = 0
Global Const $__winapiconstant_clip_default_precis = 0
Global Const $__winapiconstant_default_quality = 0
Global Const $__winapiconstant_logpixelsx = 88
Global Const $__winapiconstant_logpixelsy = 90
Global Const $tagcursorinfo = "dword Size;dword Flags;handle hCursor;" &
$tagpoint
Global Const $tagdisplay_device = "dword Size;wchar Name[32];wchar Strin
g[128];dword Flags;wchar ID[128];wchar Key[128]"
Global Const $tagflashwinfo = "uint Size;hwnd hWnd;dword Flags;uint Coun
t;dword TimeOut"
Global Const $tagiconinfo = "bool Icon;dword XHotSpot;dword YHotSpot;han
dle hMask;handle hColor"
Global Const $tagmemorystatusex = "dword Length;dword MemoryLoad;" & "ui
nt64 TotalPhys;uint64 AvailPhys;uint64 TotalPageFile;uint64 AvailPageFile;" & "u
int64 TotalVirtual;uint64 AvailVirtual;uint64 AvailExtendedVirtual"
Func _winapi_attachconsole($ipid = -1)
Local $aresult = DllCall("kernel32.dll", "bool", "AttachConsole"
, "dword", $ipid)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_attachthreadinput($iattach, $iattachto, $battach)
Local $aresult = DllCall("user32.dll", "bool", "AttachThreadInpu
t", "dword", $iattach, "dword", $iattachto, "bool", $battach)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_beep($ifreq = 500, $iduration = 1000)

Local $aresult = DllCall("kernel32.dll", "bool", "Beep", "dword"


, $ifreq, "dword", $iduration)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_bitblt($hdestdc, $ixdest, $iydest, $iwidth, $iheight, $hsrc
dc, $ixsrc, $iysrc, $irop)
Local $aresult = DllCall("gdi32.dll", "bool", "BitBlt", "handle"
, $hdestdc, "int", $ixdest, "int", $iydest, "int", $iwidth, "int", $iheight, "ha
ndle", $hsrcdc, "int", $ixsrc, "int", $iysrc, "dword", $irop)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_callnexthookex($hhook, $icode, $wparam, $lparam)
Local $aresult = DllCall("user32.dll", "lresult", "CallNextHookE
x", "handle", $hhook, "int", $icode, "wparam", $wparam, "lparam", $lparam)
If @error Then Return SetError(@error, @extended, -1)
Return $aresult[0]
EndFunc
m)

Func _winapi_callwindowproc($pprevwndfunc, $hwnd, $imsg, $wparam, $lpara

Local $aresult = DllCall("user32.dll", "lresult", "CallWindowPro


c", "ptr", $pprevwndfunc, "hwnd", $hwnd, "uint", $imsg, "wparam", $wparam, "lpar
am", $lparam)
If @error Then Return SetError(@error, @extended, -1)
Return $aresult[0]
EndFunc
Func _winapi_clienttoscreen($hwnd, ByRef $tpoint)
Local $aret = DllCall("user32.dll", "bool", "ClientToScreen", "h
wnd", $hwnd, "struct*", $tpoint)
If @error OR NOT $aret[0] Then Return SetError(@error + 10, @ext
ended, 0)
Return $tpoint
EndFunc
Func _winapi_closehandle($hobject)
Local $aresult = DllCall("kernel32.dll", "bool", "CloseHandle",
"handle", $hobject)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_combinergn($hrgndest, $hrgnsrc1, $hrgnsrc2, $icombinemode)
Local $aresult = DllCall("gdi32.dll", "int", "CombineRgn", "hand
le", $hrgndest, "handle", $hrgnsrc1, "handle", $hrgnsrc2, "int", $icombinemode)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_commdlgextendederror()
Local Const $cderr_dialogfailure = 65535
Local Const $cderr_findresfailure = 6
Local Const $cderr_initialization = 2
Local Const $cderr_loadresfailure = 7
Local Const $cderr_loadstrfailure = 5
Local Const $cderr_lockresfailure = 8

edError")

Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local

Const $cderr_memallocfailure = 9
Const $cderr_memlockfailure = 10
Const $cderr_nohinstance = 4
Const $cderr_nohook = 11
Const $cderr_notemplate = 3
Const $cderr_registermsgfail = 12
Const $cderr_structsize = 1
Const $fnerr_buffertoosmall = 12291
Const $fnerr_invalidfilename = 12290
Const $fnerr_subclassfailure = 12289
$aresult = DllCall("comdlg32.dll", "dword", "CommDlgExtend

If NOT @error Then


Switch $aresult[0]
Case $cderr_dialogfailure
Return SetError($aresult[0], 0, "The dia
log box could not be created." & @LF & "The common dialog box function's call to
the DialogBox function failed." & @LF & "For example, this error occurs if the
common dialog box call specifies an invalid window handle.")
Case $cderr_findresfailure
Return SetError($aresult[0], 0, "The com
mon dialog box function failed to find a specified resource.")
Case $cderr_initialization
Return SetError($aresult[0], 0, "The com
mon dialog box function failed during initialization." & @LF & "This error often
occurs when sufficient memory is not available.")
Case $cderr_loadresfailure
Return SetError($aresult[0], 0, "The com
mon dialog box function failed to load a specified resource.")
Case $cderr_loadstrfailure
Return SetError($aresult[0], 0, "The com
mon dialog box function failed to load a specified string.")
Case $cderr_lockresfailure
Return SetError($aresult[0], 0, "The com
mon dialog box function failed to lock a specified resource.")
Case $cderr_memallocfailure
Return SetError($aresult[0], 0, "The com
mon dialog box function was unable to allocate memory for internal structures.")
Case $cderr_memlockfailure
Return SetError($aresult[0], 0, "The com
mon dialog box function was unable to lock the memory associated with a handle."
)
Case $cderr_nohinstance
Return SetError($aresult[0], 0, "The ENA
BLETEMPLATE flag was set in the Flags member of the initialization structure for
the corresponding common dialog box," & @LF & "but you failed to provide a corr
esponding instance handle.")
Case $cderr_nohook
Return SetError($aresult[0], 0, "The ENA
BLEHOOK flag was set in the Flags member of the initialization structure for the
corresponding common dialog box," & @LF & "but you failed to provide a pointer
to a corresponding hook procedure.")
Case $cderr_notemplate
Return SetError($aresult[0], 0, "The ENA
BLETEMPLATE flag was set in the Flags member of the initialization structure for
the corresponding common dialog box," & @LF & "but you failed to provide a corr
esponding template.")
Case $cderr_registermsgfail
Return SetError($aresult[0], 0, "The Reg
isterWindowMessage function returned an error code when it was called by the com

mon dialog box function.")

Case $cderr_structsize
Return SetError($aresult[0], 0, "The lSt
ructSize member of the initialization structure for the corresponding common dia
log box is invalid")
Case $fnerr_buffertoosmall
Return SetError($aresult[0], 0, "The buf
fer pointed to by the lpstrFile member of the OPENFILENAME structure is too smal
l for the file name specified by the user." & @LF & "The first two bytes of the
lpstrFile buffer contain an integer value specifying the size, in TCHARs, requir
ed to receive the full name.")
Case $fnerr_invalidfilename
Return SetError($aresult[0], 0, "A file
name is invalid.")
Case $fnerr_subclassfailure
Return SetError($aresult[0], 0, "An atte
mpt to subclass a list box failed because sufficient memory was not available.")
EndSwitch
EndIf
Return SetError(@error, @extended, "0x" & Hex($aresult[0]))
EndFunc
Func _winapi_copyicon($hicon)
Local $aresult = DllCall("user32.dll", "handle", "CopyIcon", "ha
ndle", $hicon)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_createbitmap($iwidth, $iheight, $iplanes = 1, $ibitsperpel
= 1, $pbits = 0)
Local $aresult = DllCall("gdi32.dll", "handle", "CreateBitmap",
"int", $iwidth, "int", $iheight, "uint", $iplanes, "uint", $ibitsperpel, "struct
*", $pbits)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_createcompatiblebitmap($hdc, $iwidth, $iheight)
Local $aresult = DllCall("gdi32.dll", "handle", "CreateCompatibl
eBitmap", "handle", $hdc, "int", $iwidth, "int", $iheight)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_createcompatibledc($hdc)
Local $aresult = DllCall("gdi32.dll", "handle", "CreateCompatibl
eDC", "handle", $hdc)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_createevent($tattributes = 0, $bmanualreset = True, $biniti
alstate = True, $sname = "")
Local $snametype = "wstr"
If $sname = "" Then
$sname = 0
$snametype = "ptr"
EndIf
Local $aresult = DllCall("kernel32.dll", "handle", "CreateEventW

", "struct*", $tattributes, "bool", $bmanualreset, "bool", $binitialstate, $snam


etype, $sname)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_createfile($sfilename, $icreation, $iaccess = 4, $ishare =
0, $iattributes = 0, $tsecurity = 0)
Local $ida = 0, $ism = 0, $icd = 0, $ifa = 0
If BitAND($iaccess, 1) <> 0 Then $ida = BitOR($ida, $generic_exe
cute)
If BitAND($iaccess, 2) <> 0 Then $ida = BitOR($ida, $generic_rea
d)
If BitAND($iaccess, 4) <> 0 Then $ida = BitOR($ida, $generic_wri
te)
If BitAND($ishare, 1) <> 0 Then $ism = BitOR($ism, $file_share_d
elete)
If BitAND($ishare, 2) <> 0 Then $ism = BitOR($ism, $file_share_r
ead)
If BitAND($ishare, 4) <> 0 Then $ism = BitOR($ism, $file_share_w
rite)
Switch $icreation
Case 0
$icd = $create_new
Case 1
$icd = $create_always
Case 2
$icd = $open_existing
Case 3
$icd = $open_always
Case 4
$icd = $truncate_existing
EndSwitch
If BitAND($iattributes, 1) <> 0 Then $ifa = BitOR($ifa, $file_at
tribute_archive)
If BitAND($iattributes, 2) <> 0 Then $ifa = BitOR($ifa, $file_at
tribute_hidden)
If BitAND($iattributes, 4) <> 0 Then $ifa = BitOR($ifa, $file_at
tribute_readonly)
If BitAND($iattributes, 8) <> 0 Then $ifa = BitOR($ifa, $file_at
tribute_system)
Local $aresult = DllCall("kernel32.dll", "handle", "CreateFileW"
, "wstr", $sfilename, "dword", $ida, "dword", $ism, "struct*", $tsecurity, "dwor
d", $icd, "dword", $ifa, "ptr", 0)
If @error OR ($aresult[0] = $invalid_handle_value) Then Return S
etError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_createfont($iheight, $iwidth, $iescape = 0, $iorientn = 0,
$iweight = $__winapiconstant_fw_normal, $bitalic = False, $bunderline = False, $
bstrikeout = False, $icharset = $__winapiconstant_default_charset, $ioutputprec
= $__winapiconstant_out_default_precis, $iclipprec = $__winapiconstant_clip_defa
ult_precis, $iquality = $__winapiconstant_default_quality, $ipitch = 0, $sface =
"Arial")
Local $aresult = DllCall("gdi32.dll", "handle", "CreateFontW", "
int", $iheight, "int", $iwidth, "int", $iescape, "int", $iorientn, "int", $iweig
ht, "dword", $bitalic, "dword", $bunderline, "dword", $bstrikeout, "dword", $ich
arset, "dword", $ioutputprec, "dword", $iclipprec, "dword", $iquality, "dword",
$ipitch, "wstr", $sface)

EndFunc

If @error Then Return SetError(@error, @extended, 0)


Return $aresult[0]

Func _winapi_createfontindirect($tlogfont)
Local $aresult = DllCall("gdi32.dll", "handle", "CreateFontIndir
ectW", "struct*", $tlogfont)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_createpen($ipenstyle, $iwidth, $icolor)
Local $aresult = DllCall("gdi32.dll", "handle", "CreatePen", "in
t", $ipenstyle, "int", $iwidth, "INT", $icolor)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_createprocess($sappname, $scommand, $tsecurity, $tthread, $
binherit, $iflags, $penviron, $sdir, $tstartupinfo, $tprocess)
Local $tcommand = 0
Local $sappnametype = "wstr", $sdirtype = "wstr"
If $sappname = "" Then
$sappnametype = "ptr"
$sappname = 0
EndIf
If $scommand <> "" Then
$tcommand = DllStructCreate("wchar Text[" & 260 + 1 & "]
")
DllStructSetData($tcommand, "Text", $scommand)
EndIf
If $sdir = "" Then
$sdirtype = "ptr"
$sdir = 0
EndIf
Local $aresult = DllCall("kernel32.dll", "bool", "CreateProcessW
", $sappnametype, $sappname, "struct*", $tcommand, "struct*", $tsecurity, "struc
t*", $tthread, "bool", $binherit, "dword", $iflags, "struct*", $penviron, $sdirt
ype, $sdir, "struct*", $tstartupinfo, "struct*", $tprocess)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
ect)

Func _winapi_createrectrgn($ileftrect, $itoprect, $irightrect, $ibottomr

Local $aresult = DllCall("gdi32.dll", "handle", "CreateRectRgn",


"int", $ileftrect, "int", $itoprect, "int", $irightrect, "int", $ibottomrect)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc

Func _winapi_createroundrectrgn($ileftrect, $itoprect, $irightrect, $ibo


ttomrect, $iwidthellipse, $iheightellipse)
Local $aresult = DllCall("gdi32.dll", "handle", "CreateRoundRect
Rgn", "int", $ileftrect, "int", $itoprect, "int", $irightrect, "int", $ibottomre
ct, "int", $iwidthellipse, "int", $iheightellipse)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc

= 1)

Func _winapi_createsolidbitmap($hwnd, $icolor, $iwidth, $iheight, $brgb

iheight)

Local $hdc = _winapi_getdc($hwnd)


Local $hdestdc = _winapi_createcompatibledc($hdc)
Local $hbitmap = _winapi_createcompatiblebitmap($hdc, $iwidth, $

Local $hold = _winapi_selectobject($hdestdc, $hbitmap)


Local $trect = DllStructCreate($tagrect)
DllStructSetData($trect, 1, 0)
DllStructSetData($trect, 2, 0)
DllStructSetData($trect, 3, $iwidth)
DllStructSetData($trect, 4, $iheight)
If $brgb Then
$icolor = BitOR(BitAND($icolor, 65280), BitShift(BitAND(
$icolor, 255), -16), BitShift(BitAND($icolor, 16711680), 16))
EndIf
Local $hbrush = _winapi_createsolidbrush($icolor)
If NOT _winapi_fillrect($hdestdc, $trect, $hbrush) Then
_winapi_deleteobject($hbitmap)
$hbitmap = 0
EndIf
_winapi_deleteobject($hbrush)
_winapi_releasedc($hwnd, $hdc)
_winapi_selectobject($hdestdc, $hold)
_winapi_deletedc($hdestdc)
If NOT $hbitmap Then Return SetError(1, 0, 0)
Return $hbitmap
EndFunc
Func _winapi_createsolidbrush($icolor)
Local $aresult = DllCall("gdi32.dll", "handle", "CreateSolidBrus
h", "INT", $icolor)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_createwindowex($iexstyle, $sclass, $sname, $istyle, $ix, $i
y, $iwidth, $iheight, $hparent, $hmenu = 0, $hinstance = 0, $pparam = 0)
If $hinstance = 0 Then $hinstance = _winapi_getmodulehandle("")
Local $aresult = DllCall("user32.dll", "hwnd", "CreateWindowExW"
, "dword", $iexstyle, "wstr", $sclass, "wstr", $sname, "dword", $istyle, "int",
$ix, "int", $iy, "int", $iwidth, "int", $iheight, "hwnd", $hparent, "handle", $h
menu, "handle", $hinstance, "struct*", $pparam)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_defwindowproc($hwnd, $imsg, $wparam, $lparam)
Local $aresult = DllCall("user32.dll", "lresult", "DefWindowProc
", "hwnd", $hwnd, "uint", $imsg, "wparam", $wparam, "lparam", $lparam)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_deletedc($hdc)
Local $aresult = DllCall("gdi32.dll", "bool", "DeleteDC", "handl
e", $hdc)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc

Func _winapi_deleteobject($hobject)
Local $aresult = DllCall("gdi32.dll", "bool", "DeleteObject", "h
andle", $hobject)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_destroyicon($hicon)
Local $aresult = DllCall("user32.dll", "bool", "DestroyIcon", "h
andle", $hicon)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_destroywindow($hwnd)
Local $aresult = DllCall("user32.dll", "bool", "DestroyWindow",
"hwnd", $hwnd)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_drawedge($hdc, $trect, $iedgetype, $iflags)
Local $aresult = DllCall("user32.dll", "bool", "DrawEdge", "hand
le", $hdc, "struct*", $trect, "uint", $iedgetype, "uint", $iflags)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_drawframecontrol($hdc, $trect, $itype, $istate)
Local $aresult = DllCall("user32.dll", "bool", "DrawFrameControl
", "handle", $hdc, "struct*", $trect, "uint", $itype, "uint", $istate)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_drawicon($hdc, $ix, $iy, $hicon)
Local $aresult = DllCall("user32.dll", "bool", "DrawIcon", "hand
le", $hdc, "int", $ix, "int", $iy, "handle", $hicon)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_drawiconex($hdc, $ix, $iy, $hicon, $iwidth = 0, $iheight =
0, $istep = 0, $hbrush = 0, $iflags = 3)
Local $ioptions
Switch $iflags
Case 1
$ioptions = $di_mask
Case 2
$ioptions = $di_image
Case 3
$ioptions = $di_normal
Case 4
$ioptions = $di_compat
Case 5
$ioptions = $di_defaultsize
Case Else
$ioptions = $di_nomirror
EndSwitch

Local $aresult = DllCall("user32.dll", "bool", "DrawIconEx", "ha


ndle", $hdc, "int", $ix, "int", $iy, "handle", $hicon, "int", $iwidth, "int", $i
height, "uint", $istep, "handle", $hbrush, "uint", $ioptions)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_drawline($hdc, $ix1, $iy1, $ix2, $iy2)
_winapi_moveto($hdc, $ix1, $iy1)
If @error Then Return SetError(@error, @extended, False)
_winapi_lineto($hdc, $ix2, $iy2)
If @error Then Return SetError(@error + 10, @extended, False)
Return True
EndFunc
Func _winapi_drawtext($hdc, $stext, ByRef $trect, $iflags)
Local $aresult = DllCall("user32.dll", "int", "DrawTextW", "hand
le", $hdc, "wstr", $stext, "int", -1, "struct*", $trect, "uint", $iflags)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_duplicatehandle($hsourceprocesshandle, $hsourcehandle, $hta
rgetprocesshandle, $idesiredaccess, $iinherithandle, $ioptions)
Local $aresult = DllCall("kernel32.dll", "bool", "DuplicateHandl
e", "handle", $hsourceprocesshandle, "handle", $hsourcehandle, "handle", $htarge
tprocesshandle, "handle*", 0, "dword", $idesiredaccess, "bool", $iinherithandle,
"dword", $ioptions)
If @error OR NOT $aresult[0] Then Return SetError(@error, @exten
ded, 0)
Return $aresult[4]
EndFunc
Func _winapi_enablewindow($hwnd, $benable = True)
Local $aresult = DllCall("user32.dll", "bool", "EnableWindow", "
hwnd", $hwnd, "bool", $benable)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_enumdisplaydevices($sdevice, $idevnum)
Local $tname = 0, $iflags = 0, $adevice[5]
If $sdevice <> "" Then
$tname = DllStructCreate("wchar Text[" & StringLen($sdev
ice) + 1 & "]")
DllStructSetData($tname, "Text", $sdevice)
EndIf
Local $tdevice = DllStructCreate($tagdisplay_device)
Local $idevice = DllStructGetSize($tdevice)
DllStructSetData($tdevice, "Size", $idevice)
Local $aret = DllCall("user32.dll", "bool", "EnumDisplayDevicesW
", "struct*", $tname, "dword", $idevnum, "struct*", $tdevice, "dword", 1)
If @error OR NOT $aret[0] Then Return SetError(@error + 10, @ext
ended, 0)
Local $in = DllStructGetData($tdevice, "Flags")
If BitAND($in, $display_device_attached_to_desktop) <> 0 Then $i
flags = BitOR($iflags, 1)
If BitAND($in, $display_device_primary_device) <> 0 Then $iflags
= BitOR($iflags, 2)
If BitAND($in, $display_device_mirroring_driver) <> 0 Then $ifla

gs = BitOR($iflags, 4)
If BitAND($in, $display_device_vga_compatible) <> 0 Then $iflags
= BitOR($iflags, 8)
If BitAND($in, $display_device_removable) <> 0 Then $iflags = Bi
tOR($iflags, 16)
If BitAND($in, $display_device_modespruned) <> 0 Then $iflags =
BitOR($iflags, 32)
$adevice[0] = True
$adevice[1] = DllStructGetData($tdevice, "Name")
$adevice[2] = DllStructGetData($tdevice, "String")
$adevice[3] = $iflags
$adevice[4] = DllStructGetData($tdevice, "ID")
Return $adevice
EndFunc
Func _winapi_enumwindows($bvisible = True, $hwnd = Default)
__winapi_enumwindowsinit()
If $hwnd = Default Then $hwnd = _winapi_getdesktopwindow()
__winapi_enumwindowschild($hwnd, $bvisible)
Return $__g_awinlist_winapi
EndFunc
Func __winapi_enumwindowsadd($hwnd, $sclass = "")
If $sclass = "" Then $sclass = _winapi_getclassname($hwnd)
$__g_awinlist_winapi[0][0] += 1
Local $icount = $__g_awinlist_winapi[0][0]
If $icount >= $__g_awinlist_winapi[0][1] Then
ReDim $__g_awinlist_winapi[$icount + 64][2]
$__g_awinlist_winapi[0][1] += 64
EndIf
$__g_awinlist_winapi[$icount][0] = $hwnd
$__g_awinlist_winapi[$icount][1] = $sclass
EndFunc

Func __winapi_enumwindowschild($hwnd, $bvisible = True)


$hwnd = _winapi_getwindow($hwnd, $gw_child)
While $hwnd <> 0
If (NOT $bvisible) OR _winapi_iswindowvisible($hwnd) The
__winapi_enumwindowsadd($hwnd)
__winapi_enumwindowschild($hwnd, $bvisible)

EndFunc

WEnd

EndIf
$hwnd = _winapi_getwindow($hwnd, $gw_hwndnext)

Func __winapi_enumwindowsinit()
ReDim $__g_awinlist_winapi[64][2]
$__g_awinlist_winapi[0][0] = 0
$__g_awinlist_winapi[0][1] = 64
EndFunc

child)

Func _winapi_enumwindowspopup()
__winapi_enumwindowsinit()
Local $hwnd = _winapi_getwindow(_winapi_getdesktopwindow(), $gw_
Local $sclass
While $hwnd <> 0
If _winapi_iswindowvisible($hwnd) Then
$sclass = _winapi_getclassname($hwnd)

If $sclass = "#32768" Then


__winapi_enumwindowsadd($hwnd)
ElseIf $sclass = "ToolbarWindow32" Then
__winapi_enumwindowsadd($hwnd)
ElseIf $sclass = "ToolTips_Class32" Then
__winapi_enumwindowsadd($hwnd)
ElseIf $sclass = "BaseBar" Then
__winapi_enumwindowschild($hwnd)
EndIf

EndIf
$hwnd = _winapi_getwindow($hwnd, $gw_hwndnext)

EndFunc

child)

WEnd
Return $__g_awinlist_winapi

Func _winapi_enumwindowstop()
__winapi_enumwindowsinit()
Local $hwnd = _winapi_getwindow(_winapi_getdesktopwindow(), $gw_

owsadd($hwnd)

EndFunc

While $hwnd <> 0


If _winapi_iswindowvisible($hwnd) Then __winapi_enumwind
$hwnd = _winapi_getwindow($hwnd, $gw_hwndnext)
WEnd
Return $__g_awinlist_winapi

Func _winapi_expandenvironmentstrings($sstring)
Local $aresult = DllCall("kernel32.dll", "dword", "ExpandEnviron
mentStringsW", "wstr", $sstring, "wstr", "", "dword", 4096)
If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @
extended, "")
Return $aresult[2]
EndFunc
ons)

Func _winapi_extracticonex($sfilepath, $iindex, $palarge, $pasmall, $iic

Local $aresult = DllCall("shell32.dll", "uint", "ExtractIconExW"


, "wstr", $sfilepath, "int", $iindex, "struct*", $palarge, "struct*", $pasmall,
"uint", $iicons)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_fatalappexit($smessage)
DllCall("kernel32.dll", "none", "FatalAppExitW", "uint", 0, "wst
r", $smessage)
If @error Then Return SetError(@error, @extended)
EndFunc
Func _winapi_fillrect($hdc, $trect, $hbrush)
Local $aresult
If IsPtr($hbrush) Then
$aresult = DllCall("user32.dll", "int", "FillRect", "han
dle", $hdc, "struct*", $trect, "handle", $hbrush)
Else
$aresult = DllCall("user32.dll", "int", "FillRect", "han
dle", $hdc, "struct*", $trect, "dword_ptr", $hbrush)
EndIf
If @error Then Return SetError(@error, @extended, False)

EndFunc

Return $aresult[0]

Func _winapi_findexecutable($sfilename, $sdirectory = "")


Local $aresult = DllCall("shell32.dll", "INT", "FindExecutableW"
, "wstr", $sfilename, "wstr", $sdirectory, "wstr", "")
If @error Then Return SetError(@error, @extended, "")
If $aresult[0] <= 32 Then Return SetError(10, $aresult[0], "")
Return SetExtended($aresult[0], $aresult[3])
EndFunc
Func _winapi_findwindow($sclassname, $swindowname)
Local $aresult = DllCall("user32.dll", "hwnd", "FindWindowW", "w
str", $sclassname, "wstr", $swindowname)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_flashwindow($hwnd, $binvert = True)
Local $aresult = DllCall("user32.dll", "bool", "FlashWindow", "h
wnd", $hwnd, "bool", $binvert)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
0)

Func _winapi_flashwindowex($hwnd, $iflags = 3, $icount = 3, $itimeout =


Local $tflash = DllStructCreate($tagflashwinfo)
Local $iflash = DllStructGetSize($tflash)
Local $imode = 0
If BitAND($iflags, 1) <> 0 Then $imode = BitOR($imode, $flashw_c

aption)

If BitAND($iflags, 2) <> 0 Then $imode = BitOR($imode, $flashw_t

ray)

If BitAND($iflags, 4) <> 0 Then $imode = BitOR($imode, $flashw_t

imer)
imernofg)

If BitAND($iflags, 8) <> 0 Then $imode = BitOR($imode, $flashw_t

DllStructSetData($tflash, "Size", $iflash)


DllStructSetData($tflash, "hWnd", $hwnd)
DllStructSetData($tflash, "Flags", $imode)
DllStructSetData($tflash, "Count", $icount)
DllStructSetData($tflash, "Timeout", $itimeout)
Local $aresult = DllCall("user32.dll", "bool", "FlashWindowEx",
"struct*", $tflash)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_floattoint($nfloat)
Local $tfloat = DllStructCreate("float")
Local $tint = DllStructCreate("int", DllStructGetPtr($tfloat))
DllStructSetData($tfloat, 1, $nfloat)
Return DllStructGetData($tint, 1)
EndFunc
Func _winapi_flushfilebuffers($hfile)
Local $aresult = DllCall("kernel32.dll", "bool", "FlushFileBuffe
rs", "handle", $hfile)
If @error Then Return SetError(@error, @extended, False)

EndFunc

Return $aresult[0]

Func _winapi_formatmessage($iflags, $psource, $imessageid, $ilanguageid,


ByRef $pbuffer, $isize, $varguments)
Local $sbuffertype = "struct*"
If IsString($pbuffer) Then $sbuffertype = "wstr"
Local $aresult = DllCall("kernel32.dll", "dword", "FormatMessage
W", "dword", $iflags, "struct*", $psource, "dword", $imessageid, "dword", $ilang
uageid, $sbuffertype, $pbuffer, "dword", $isize, "ptr", $varguments)
If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @
extended, 0)
If $sbuffertype = "wstr" Then $pbuffer = $aresult[5]
Return $aresult[0]
EndFunc
Func _winapi_framerect($hdc, $trect, $hbrush)
Local $aresult = DllCall("user32.dll", "int", "FrameRect", "hand
le", $hdc, "struct*", $trect, "handle", $hbrush)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_freelibrary($hmodule)
Local $aresult = DllCall("kernel32.dll", "bool", "FreeLibrary",
"handle", $hmodule)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_getancestor($hwnd, $iflags = 1)
Local $aresult = DllCall("user32.dll", "hwnd", "GetAncestor", "h
wnd", $hwnd, "uint", $iflags)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_getasynckeystate($ikey)
Local $aresult = DllCall("user32.dll", "short", "GetAsyncKeyStat
e", "int", $ikey)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_getbkmode($hdc)
Local $aresult = DllCall("gdi32.dll", "int", "GetBkMode", "handl
e", $hdc)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_getclassname($hwnd)
If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
Local $aresult = DllCall("user32.dll", "int", "GetClassNameW", "
hwnd", $hwnd, "wstr", "", "int", 4096)
If @error OR NOT $aresult[0] Then Return SetError(@error, @exten
ded, "")
Return SetExtended($aresult[0], $aresult[2])
EndFunc

Func _winapi_getclientheight($hwnd)
Local $trect = _winapi_getclientrect($hwnd)
If @error Then Return SetError(@error, @extended, 0)
Return DllStructGetData($trect, "Bottom") - DllStructGetData($tr
ect, "Top")
EndFunc
Func _winapi_getclientwidth($hwnd)
Local $trect = _winapi_getclientrect($hwnd)
If @error Then Return SetError(@error, @extended, 0)
Return DllStructGetData($trect, "Right") - DllStructGetData($tre
ct, "Left")
EndFunc
Func _winapi_getclientrect($hwnd)
Local $trect = DllStructCreate($tagrect)
Local $aret = DllCall("user32.dll", "bool", "GetClientRect", "hw
nd", $hwnd, "struct*", $trect)
If @error OR NOT $aret[0] Then Return SetError(@error + 10, @ext
ended, 0)
Return $trect
EndFunc

ocess")

Func _winapi_getcurrentprocess()
Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentPr

EndFunc

If @error Then Return SetError(@error, @extended, 0)


Return $aresult[0]

Func _winapi_getcurrentprocessid()
Local $aresult = DllCall("kernel32.dll", "dword", "GetCurrentPro
cessId")
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc

read")

Func _winapi_getcurrentthread()
Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentTh

EndFunc

eadId")

If @error Then Return SetError(@error, @extended, 0)


Return $aresult[0]

Func _winapi_getcurrentthreadid()
Local $aresult = DllCall("kernel32.dll", "dword", "GetCurrentThr

EndFunc

If @error Then Return SetError(@error, @extended, 0)


Return $aresult[0]

Func _winapi_getcursorinfo()
Local $tcursor = DllStructCreate($tagcursorinfo)
Local $icursor = DllStructGetSize($tcursor)
DllStructSetData($tcursor, "Size", $icursor)
Local $aret = DllCall("user32.dll", "bool", "GetCursorInfo", "st
ruct*", $tcursor)
If @error OR NOT $aret[0] Then Return SetError(@error + 10, @ext
ended, 0)
Local $acursor[5]

EndFunc

$acursor[0] = True
$acursor[1] = DllStructGetData($tcursor,
$acursor[2] = DllStructGetData($tcursor,
$acursor[3] = DllStructGetData($tcursor,
$acursor[4] = DllStructGetData($tcursor,
Return $acursor

"Flags") <> 0
"hCursor")
"X")
"Y")

Func _winapi_getdc($hwnd)
Local $aresult = DllCall("user32.dll", "handle", "GetDC", "hwnd"
, $hwnd)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc

")

Func _winapi_getdesktopwindow()
Local $aresult = DllCall("user32.dll", "hwnd", "GetDesktopWindow

EndFunc

If @error Then Return SetError(@error, @extended, 0)


Return $aresult[0]

Func _winapi_getdevicecaps($hdc, $iindex)


Local $aresult = DllCall("gdi32.dll", "int", "GetDeviceCaps", "h
andle", $hdc, "int", $iindex)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_getdibits($hdc, $hbitmap, $istartscan, $iscanlines, $pbits,
$tbi, $iusage)
Local $aresult = DllCall("gdi32.dll", "int", "GetDIBits", "handl
e", $hdc, "handle", $hbitmap, "uint", $istartscan, "uint", $iscanlines, "struct*
", $pbits, "struct*", $tbi, "uint", $iusage)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_getdlgctrlid($hwnd)
Local $aresult = DllCall("user32.dll", "int", "GetDlgCtrlID", "h
wnd", $hwnd)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_getdlgitem($hwnd, $iitemid)
Local $aresult = DllCall("user32.dll", "hwnd", "GetDlgItem", "hw
nd", $hwnd, "int", $iitemid)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_getfilesizeex($hfile)
Local $aresult = DllCall("kernel32.dll", "bool", "GetFileSizeEx"
, "handle", $hfile, "int64*", 0)
If @error OR NOT $aresult[0] Then Return SetError(@error, @exten
ded, -1)
Return $aresult[2]
EndFunc

Func _winapi_getfocus()
Local $aresult = DllCall("user32.dll", "hwnd", "GetFocus")
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc

dow")

Func _winapi_getforegroundwindow()
Local $aresult = DllCall("user32.dll", "hwnd", "GetForegroundWin

EndFunc

If @error Then Return SetError(@error, @extended, 0)


Return $aresult[0]

Func _winapi_getguiresources($iflag = 0, $hprocess = -1)


If $hprocess = -1 Then $hprocess = _winapi_getcurrentprocess()
Local $aresult = DllCall("user32.dll", "dword", "GetGuiResources
", "handle", $hprocess, "dword", $iflag)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_geticoninfo($hicon)
Local $tinfo = DllStructCreate($tagiconinfo)
Local $aret = DllCall("user32.dll", "bool", "GetIconInfo", "hand
le", $hicon, "struct*", $tinfo)
If @error OR NOT $aret[0] Then Return SetError(@error + 10, @ext
ended, 0)
Local $aicon[6]
$aicon[0] = True
$aicon[1] = DllStructGetData($tinfo, "Icon") <> 0
$aicon[2] = DllStructGetData($tinfo, "XHotSpot")
$aicon[3] = DllStructGetData($tinfo, "YHotSpot")
$aicon[4] = DllStructGetData($tinfo, "hMask")
$aicon[5] = DllStructGetData($tinfo, "hColor")
Return $aicon
EndFunc
Func _winapi_getlasterrormessage()
Local $ilasterror = _winapi_getlasterror()
Local $tbufferptr = DllStructCreate("ptr")
Local $ncount = _winapi_formatmessage(BitOR($format_message_allo
cate_buffer, $format_message_from_system), 0, $ilasterror, 0, $tbufferptr, 0, 0)
If @error Then Return SetError(@error, 0, "")
Local $stext = ""
Local $pbuffer = DllStructGetData($tbufferptr, 1)
If $pbuffer Then
If $ncount > 0 Then
Local $tbuffer = DllStructCreate("wchar[" & ($nc
ount + 1) & "]", $pbuffer)
$stext = DllStructGetData($tbuffer, 1)
If StringRight($stext, 2) = @CRLF Then $stext =
StringTrimRight($stext, 2)
EndIf
_winapi_localfree($pbuffer)
EndIf
Return $stext
EndFunc
Func _winapi_getlayeredwindowattributes($hwnd, ByRef $itranscolor, ByRef
$itransgui, $bcolorref = False)

$itranscolor = -1
$itransgui = -1
Local $aresult = DllCall("user32.dll", "bool", "GetLayeredWindow
Attributes", "hwnd", $hwnd, "INT*", $itranscolor, "byte*", $itransgui, "dword*",
0)
If @error OR NOT $aresult[0] Then Return SetError(@error, @exten
ded, 0)
If NOT $bcolorref Then
$aresult[2] = Int(BinaryMid($aresult[2], 3, 1) & BinaryM
id($aresult[2], 2, 1) & BinaryMid($aresult[2], 1, 1))
EndIf
$itranscolor = $aresult[2]
$itransgui = $aresult[3]
Return $aresult[4]
EndFunc
Func _winapi_getmodulehandle($smodulename)
Local $smodulenametype = "wstr"
If $smodulename = "" Then
$smodulename = 0
$smodulenametype = "ptr"
EndIf
Local $aresult = DllCall("kernel32.dll", "handle", "GetModuleHan
dleW", $smodulenametype, $smodulename)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_getmousepos($btoclient = False, $hwnd = 0)
Local $imode = Opt("MouseCoordMode", 1)
Local $apos = MouseGetPos()
Opt("MouseCoordMode", $imode)
Local $tpoint = DllStructCreate($tagpoint)
DllStructSetData($tpoint, "X", $apos[0])
DllStructSetData($tpoint, "Y", $apos[1])
If $btoclient AND NOT _winapi_screentoclient($hwnd, $tpoint) The
n Return SetError(@error + 20, @extended, 0)
Return $tpoint
EndFunc
Func _winapi_getmouseposx($btoclient = False, $hwnd = 0)
Local $tpoint = _winapi_getmousepos($btoclient, $hwnd)
If @error Then Return SetError(@error, @extended, 0)
Return DllStructGetData($tpoint, "X")
EndFunc
Func _winapi_getmouseposy($btoclient = False, $hwnd = 0)
Local $tpoint = _winapi_getmousepos($btoclient, $hwnd)
If @error Then Return SetError(@error, @extended, 0)
Return DllStructGetData($tpoint, "Y")
EndFunc
Func _winapi_getobject($hobject, $isize, $pobject)
Local $aresult = DllCall("gdi32.dll", "int", "GetObjectW", "hand
le", $hobject, "int", $isize, "struct*", $pobject)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_getopenfilename($stitle = "", $sfilter = "All files (*.*)",

$sinitaldir = ".", $sdefaultfile = "", $sdefaultext = "", $ifilterindex = 1, $i


flags = 0, $iflagsex = 0, $hwndowner = 0)
Local $ipathlen = 4096
Local $inulls = 0
Local $tofn = DllStructCreate($tagopenfilename)
Local $afiles[1] = [0]
Local $iflag = $iflags
Local $asflines = StringSplit($sfilter, "|")
Local $asfilter[$asflines[0] * 2 + 1]
Local $istart, $ifinal, $tagfilter
$asfilter[0] = $asflines[0] * 2
For $i = 1 To $asflines[0]
$istart = StringInStr($asflines[$i], "(", 0, 1)
$ifinal = StringInStr($asflines[$i], ")", 0, -1)
$asfilter[$i * 2 - 1] = StringStripWS(StringLeft($asflin
es[$i], $istart - 1), $str_stripleading + $str_striptrailing)
$asfilter[$i * 2] = StringStripWS(StringTrimRight(String
TrimLeft($asflines[$i], $istart), StringLen($asflines[$i]) - $ifinal + 1), $str_
stripleading + $str_striptrailing)
$tagfilter &= "wchar[" & StringLen($asfilter[$i * 2 - 1]
) + 1 & "];wchar[" & StringLen($asfilter[$i * 2]) + 1 & "];"
Next
Local $ttitle = DllStructCreate("wchar Title[" & StringLen($stit
le) + 1 & "]")
Local $tinitialdir = DllStructCreate("wchar InitDir[" & StringLe
n($sinitaldir) + 1 & "]")
Local $tfilter = DllStructCreate($tagfilter & "wchar")
Local $tpath = DllStructCreate("wchar Path[" & $ipathlen & "]")
Local $textn = DllStructCreate("wchar Extension[" & StringLen($s
defaultext) + 1 & "]")
For $i = 1 To $asfilter[0]
DllStructSetData($tfilter, $i, $asfilter[$i])
Next
DllStructSetData($ttitle, "Title", $stitle)
DllStructSetData($tinitialdir, "InitDir", $sinitaldir)
DllStructSetData($tpath, "Path", $sdefaultfile)
DllStructSetData($textn, "Extension", $sdefaultext)
DllStructSetData($tofn, "StructSize", DllStructGetSize($tofn))
DllStructSetData($tofn, "hwndOwner", $hwndowner)
DllStructSetData($tofn, "lpstrFilter", DllStructGetPtr($tfilter)
)
DllStructSetData($tofn, "nFilterIndex", $ifilterindex)
DllStructSetData($tofn, "lpstrFile", DllStructGetPtr($tpath))
DllStructSetData($tofn, "nMaxFile", $ipathlen)
DllStructSetData($tofn, "lpstrInitialDir", DllStructGetPtr($tini
tialdir))
DllStructSetData($tofn, "lpstrTitle", DllStructGetPtr($ttitle))
DllStructSetData($tofn, "Flags", $iflag)
DllStructSetData($tofn, "lpstrDefExt", DllStructGetPtr($textn))
DllStructSetData($tofn, "FlagsEx", $iflagsex)
Local $ares = DllCall("comdlg32.dll", "bool", "GetOpenFileNameW"
, "struct*", $tofn)
If @error OR NOT $ares[0] Then Return SetError(@error + 10, @ext
ended, $afiles)
If BitAND($iflags, $ofn_allowmultiselect) = $ofn_allowmultiselec
t AND BitAND($iflags, $ofn_explorer) = $ofn_explorer Then
For $x = 1 To $ipathlen
If DllStructGetData($tpath, "Path", $x) = Chr(0)
Then
DllStructSetData($tpath, "Path", "|", $x

)
Else

$inulls += 1

$inulls = 0
EndIf
If $inulls = 2 Then ExitLoop

"|")

Next
DllStructSetData($tpath, "Path", Chr(0), $x - 1)
$afiles = StringSplit(DllStructGetData($tpath, "Path"),

If $afiles[0] = 1 Then Return __winapi_parsefiledialogpa


th(DllStructGetData($tpath, "Path"))
Return StringSplit(DllStructGetData($tpath, "Path"), "|"
)
ElseIf BitAND($iflags, $ofn_allowmultiselect) = $ofn_allowmultis
elect Then
$afiles = StringSplit(DllStructGetData($tpath, "Path"),
" ")
If $afiles[0] = 1 Then Return __winapi_parsefiledialogpa
th(DllStructGetData($tpath, "Path"))
Return StringSplit(StringReplace(DllStructGetData($tpath
, "Path"), " ", "|"), "|")
Else
Return __winapi_parsefiledialogpath(DllStructGetData($tp
ath, "Path"))
EndIf
EndFunc
Func _winapi_getoverlappedresult($hfile, $toverlapped, ByRef $ibytes, $b
wait = False)
Local $aresult = DllCall("kernel32.dll", "bool", "GetOverlappedR
esult", "handle", $hfile, "struct*", $toverlapped, "dword*", 0, "bool", $bwait)
If @error OR NOT $aresult[0] Then Return SetError(@error, @exten
ded, False)
$ibytes = $aresult[3]
Return $aresult[0]
EndFunc
Func _winapi_getparent($hwnd)
Local $aresult = DllCall("user32.dll", "hwnd", "GetParent", "hwn
d", $hwnd)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_getprocaddress($hmodule, $vname)
Local $stype = "str"
If IsNumber($vname) Then $stype = "word"
Local $aresult = DllCall("kernel32.dll", "ptr", "GetProcAddress"
, "handle", $hmodule, $stype, $vname)
If @error OR NOT $aresult[0] Then Return SetError(@error, @exten
ded, 0)
Return $aresult[0]
EndFunc
Func _winapi_getprocessaffinitymask($hprocess)
Local $aresult = DllCall("kernel32.dll", "bool", "GetProcessAffi
nityMask", "handle", $hprocess, "dword_ptr*", 0, "dword_ptr*", 0)
If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @
extended, 0)

EndFunc

Local $amask[3]
$amask[0] = True
$amask[1] = $aresult[2]
$amask[2] = $aresult[3]
Return $amask

Func _winapi_getsavefilename($stitle = "", $sfilter = "All files (*.*)",


$sinitaldir = ".", $sdefaultfile = "", $sdefaultext = "", $ifilterindex = 1, $i
flags = 0, $iflagsex = 0, $hwndowner = 0)
Local $ipathlen = 4096
Local $tofn = DllStructCreate($tagopenfilename)
Local $afiles[1] = [0]
Local $iflag = $iflags
Local $asflines = StringSplit($sfilter, "|")
Local $asfilter[$asflines[0] * 2 + 1]
Local $istart, $ifinal, $tagfilter
$asfilter[0] = $asflines[0] * 2
For $i = 1 To $asflines[0]
$istart = StringInStr($asflines[$i], "(", 0, 1)
$ifinal = StringInStr($asflines[$i], ")", 0, -1)
$asfilter[$i * 2 - 1] = StringStripWS(StringLeft($asflin
es[$i], $istart - 1), $str_stripleading + $str_striptrailing)
$asfilter[$i * 2] = StringStripWS(StringTrimRight(String
TrimLeft($asflines[$i], $istart), StringLen($asflines[$i]) - $ifinal + 1), $str_
stripleading + $str_striptrailing)
$tagfilter &= "wchar[" & StringLen($asfilter[$i * 2 - 1]
) + 1 & "];wchar[" & StringLen($asfilter[$i * 2]) + 1 & "];"
Next
Local $ttitle = DllStructCreate("wchar Title[" & StringLen($stit
le) + 1 & "]")
Local $tinitialdir = DllStructCreate("wchar InitDir[" & StringLe
n($sinitaldir) + 1 & "]")
Local $tfilter = DllStructCreate($tagfilter & "wchar")
Local $tpath = DllStructCreate("wchar Path[" & $ipathlen & "]")
Local $textn = DllStructCreate("wchar Extension[" & StringLen($s
defaultext) + 1 & "]")
For $i = 1 To $asfilter[0]
DllStructSetData($tfilter, $i, $asfilter[$i])
Next
DllStructSetData($ttitle, "Title", $stitle)
DllStructSetData($tinitialdir, "InitDir", $sinitaldir)
DllStructSetData($tpath, "Path", $sdefaultfile)
DllStructSetData($textn, "Extension", $sdefaultext)
DllStructSetData($tofn, "StructSize", DllStructGetSize($tofn))
DllStructSetData($tofn, "hwndOwner", $hwndowner)
DllStructSetData($tofn, "lpstrFilter", DllStructGetPtr($tfilter)
)
DllStructSetData($tofn, "nFilterIndex", $ifilterindex)
DllStructSetData($tofn, "lpstrFile", DllStructGetPtr($tpath))
DllStructSetData($tofn, "nMaxFile", $ipathlen)
DllStructSetData($tofn, "lpstrInitialDir", DllStructGetPtr($tini
tialdir))
DllStructSetData($tofn, "lpstrTitle", DllStructGetPtr($ttitle))
DllStructSetData($tofn, "Flags", $iflag)
DllStructSetData($tofn, "lpstrDefExt", DllStructGetPtr($textn))
DllStructSetData($tofn, "FlagsEx", $iflagsex)
Local $ares = DllCall("comdlg32.dll", "bool", "GetSaveFileNameW"
, "struct*", $tofn)
If @error OR NOT $ares[0] Then Return SetError(@error + 10, @ext

ended, $afiles)
th"))

Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Pa

EndFunc

Func _winapi_getstockobject($iobject)
Local $aresult = DllCall("gdi32.dll", "handle", "GetStockObject"
, "int", $iobject)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc

-1)

Func _winapi_getstdhandle($istdhandle)
If $istdhandle < 0 OR $istdhandle > 2 Then Return SetError(2, 0,

Local Const $ahandle[3] = [-10, -11, -12]


Local $aresult = DllCall("kernel32.dll", "handle", "GetStdHandle
", "dword", $ahandle[$istdhandle])
If @error Then Return SetError(@error, @extended, -1)
Return $aresult[0]
EndFunc
Func _winapi_getsyscolor($iindex)
Local $aresult = DllCall("user32.dll", "INT", "GetSysColor", "in
t", $iindex)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_getsyscolorbrush($iindex)
Local $aresult = DllCall("user32.dll", "handle", "GetSysColorBru
sh", "int", $iindex)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_getsystemmetrics($iindex)
Local $aresult = DllCall("user32.dll", "int", "GetSystemMetrics"
, "int", $iindex)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_gettextextentpoint32($hdc, $stext)
Local $tsize = DllStructCreate($tagsize)
Local $isize = StringLen($stext)
Local $aret = DllCall("gdi32.dll", "bool", "GetTextExtentPoint32
W", "handle", $hdc, "wstr", $stext, "int", $isize, "struct*", $tsize)
If @error OR NOT $aret[0] Then Return SetError(@error + 10, @ext
ended, 0)
Return $tsize
EndFunc
Func _winapi_gettextmetrics($hdc)
Local $ttextmetric = DllStructCreate($tagtextmetric)
Local $aret = DllCall("gdi32.dll", "bool", "GetTextMetricsW", "h
andle", $hdc, "struct*", $ttextmetric)
If @error OR NOT $aret[0] Then Return SetError(@error + 10, @ext
ended, 0)
Return $ttextmetric

EndFunc
Func _winapi_getwindow($hwnd, $icmd)
Local $aresult = DllCall("user32.dll", "hwnd", "GetWindow", "hwn
d", $hwnd, "uint", $icmd)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_getwindowdc($hwnd)
Local $aresult = DllCall("user32.dll", "handle", "GetWindowDC",
"hwnd", $hwnd)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_getwindowheight($hwnd)
Local $trect = _winapi_getwindowrect($hwnd)
If @error Then Return SetError(@error, @extended, 0)
Return DllStructGetData($trect, "Bottom") - DllStructGetData($tr
ect, "Top")
EndFunc
Func _winapi_getwindowlong($hwnd, $iindex)
Local $sfuncname = "GetWindowLongW"
If @AutoItX64 Then $sfuncname = "GetWindowLongPtrW"
Local $aresult = DllCall("user32.dll", "long_ptr", $sfuncname, "
hwnd", $hwnd, "int", $iindex)
If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @
extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_getwindowplacement($hwnd)
Local $twindowplacement = DllStructCreate($tagwindowplacement)
DllStructSetData($twindowplacement, "length", DllStructGetSize($
twindowplacement))
Local $aret = DllCall("user32.dll", "bool", "GetWindowPlacement"
, "hwnd", $hwnd, "struct*", $twindowplacement)
If @error OR NOT $aret[0] Then Return SetError(@error + 10, @ext
ended, 0)
Return $twindowplacement
EndFunc
Func _winapi_getwindowrect($hwnd)
Local $trect = DllStructCreate($tagrect)
Local $aret = DllCall("user32.dll", "bool", "GetWindowRect", "hw
nd", $hwnd, "struct*", $trect)
If @error OR NOT $aret[0] Then Return SetError(@error + 10, @ext
ended, 0)
Return $trect
EndFunc
Func _winapi_getwindowrgn($hwnd, $hrgn)
Local $aresult = DllCall("user32.dll", "int", "GetWindowRgn", "h
wnd", $hwnd, "handle", $hrgn)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc

Func _winapi_getwindowtext($hwnd)
Local $aresult = DllCall("user32.dll", "int", "GetWindowTextW",
"hwnd", $hwnd, "wstr", "", "int", 4096)
If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @
extended, "")
Return SetExtended($aresult[0], $aresult[2])
EndFunc
Func _winapi_getwindowthreadprocessid($hwnd, ByRef $ipid)
Local $aresult = DllCall("user32.dll", "dword", "GetWindowThread
ProcessId", "hwnd", $hwnd, "dword*", 0)
If @error Then Return SetError(@error, @extended, 0)
$ipid = $aresult[2]
Return $aresult[0]
EndFunc
Func _winapi_getwindowwidth($hwnd)
Local $trect = _winapi_getwindowrect($hwnd)
If @error Then Return SetError(@error, @extended, 0)
Return DllStructGetData($trect, "Right") - DllStructGetData($tre
ct, "Left")
EndFunc
Func _winapi_getxyfrompoint(ByRef $tpoint, ByRef $ix, ByRef $iy)
$ix = DllStructGetData($tpoint, "X")
$iy = DllStructGetData($tpoint, "Y")
EndFunc
Func _winapi_globalmemorystatus()
Local $tmem = DllStructCreate($tagmemorystatusex)
DllStructSetData($tmem, 1, DllStructGetSize($tmem))
Local $aret = DllCall("kernel32.dll", "bool", "GlobalMemoryStatu
sEx", "struct*", $tmem)
If @error OR NOT $aret[0] Then Return SetError(@error + 10, @ext
ended, 0)
Local $amem[7]
$amem[0] = DllStructGetData($tmem, 2)
$amem[1] = DllStructGetData($tmem, 3)
$amem[2] = DllStructGetData($tmem, 4)
$amem[3] = DllStructGetData($tmem, 5)
$amem[4] = DllStructGetData($tmem, 6)
$amem[5] = DllStructGetData($tmem, 7)
$amem[6] = DllStructGetData($tmem, 8)
Return $amem
EndFunc
Func _winapi_guidfromstring($sguid)
Local $tguid = DllStructCreate($tagguid)
_winapi_guidfromstringex($sguid, $tguid)
If @error Then Return SetError(@error + 10, @extended, 0)
Return $tguid
EndFunc
Func _winapi_guidfromstringex($sguid, $tguid)
Local $aresult = DllCall("ole32.dll", "long", "CLSIDFromString",
"wstr", $sguid, "struct*", $tguid)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc

Func _winapi_hiword($ilong)
Return BitShift($ilong, 16)
EndFunc
Func _winapi_inprocess($hwnd, ByRef $hlastwnd)
If $hwnd = $hlastwnd Then Return True
For $ii = $__g_ainprocess_winapi[0][0] To 1 Step -1
If $hwnd = $__g_ainprocess_winapi[$ii][0] Then
If $__g_ainprocess_winapi[$ii][1] Then
$hlastwnd = $hwnd
Return True
Else
Return False
EndIf
EndIf
Next
Local $ipid
_winapi_getwindowthreadprocessid($hwnd, $ipid)
Local $icount = $__g_ainprocess_winapi[0][0] + 1
If $icount >= 64 Then $icount = 1
$__g_ainprocess_winapi[0][0] = $icount
$__g_ainprocess_winapi[$icount][0] = $hwnd
$__g_ainprocess_winapi[$icount][1] = ($ipid = @AutoItPID)
Return $__g_ainprocess_winapi[$icount][1]
EndFunc
Func _winapi_inttofloat($iint)
Local $tint = DllStructCreate("int")
Local $tfloat = DllStructCreate("float", DllStructGetPtr($tint))
DllStructSetData($tint, 1, $iint)
Return DllStructGetData($tfloat, 1)
EndFunc
Func _winapi_isclassname($hwnd, $sclassname)
Local $sseparator = Opt("GUIDataSeparatorChar")
Local $aclassname = StringSplit($sclassname, $sseparator)
If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
Local $sclasscheck = _winapi_getclassname($hwnd)
For $x = 1 To UBound($aclassname) - 1
If StringUpper(StringMid($sclasscheck, 1, StringLen($acl
assname[$x]))) = StringUpper($aclassname[$x]) Then Return True
Next
Return False
EndFunc
Func _winapi_iswindow($hwnd)
Local $aresult = DllCall("user32.dll", "bool", "IsWindow", "hwnd
", $hwnd)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_iswindowvisible($hwnd)
Local $aresult = DllCall("user32.dll", "bool", "IsWindowVisible"
, "hwnd", $hwnd)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_invalidaterect($hwnd, $trect = 0, $berase = True)

Local $aresult = DllCall("user32.dll", "bool", "InvalidateRect",


"hwnd", $hwnd, "struct*", $trect, "bool", $berase)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_lineto($hdc, $ix, $iy)
Local $aresult = DllCall("gdi32.dll", "bool", "LineTo", "handle"
, $hdc, "int", $ix, "int", $iy)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_loadbitmap($hinstance, $sbitmap)
Local $sbitmaptype = "int"
If IsString($sbitmap) Then $sbitmaptype = "wstr"
Local $aresult = DllCall("user32.dll", "handle", "LoadBitmapW",
"handle", $hinstance, $sbitmaptype, $sbitmap)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_loadimage($hinstance, $simage, $itype, $ixdesired, $iydesir
ed, $iload)
Local $aresult, $simagetype = "int"
If IsString($simage) Then $simagetype = "wstr"
$aresult = DllCall("user32.dll", "handle", "LoadImageW", "handle
", $hinstance, $simagetype, $simage, "uint", $itype, "int", $ixdesired, "int", $
iydesired, "uint", $iload)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_loadlibrary($sfilename)
Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryW
", "wstr", $sfilename)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_loadlibraryex($sfilename, $iflags = 0)
Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryE
xW", "wstr", $sfilename, "ptr", 0, "dword", $iflags)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_loadshell32icon($iiconid)
Local $ticons = DllStructCreate("ptr Data")
Local $iicons = _winapi_extracticonex("shell32.dll", $iiconid, 0
, $ticons, 1)
If @error Then Return SetError(@error, @extended, 0)
If $iicons <= 0 Then Return SetError(10, 0, 0)
Return DllStructGetData($ticons, "Data")
EndFunc
Func _winapi_loadstring($hinstance, $istringid)
Local $aresult = DllCall("user32.dll", "int", "LoadStringW", "ha
ndle", $hinstance, "uint", $istringid, "wstr", "", "int", 4096)
If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @

extended, "")
EndFunc

Return SetExtended($aresult[0], $aresult[3])

Func _winapi_localfree($hmemory)
Local $aresult = DllCall("kernel32.dll", "handle", "LocalFree",
"handle", $hmemory)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_loword($ilong)
Return BitAND($ilong, 65535)
EndFunc
Func _winapi_makelangid($ilngidprimary, $ilngidsub)
Return BitOR(BitShift($ilngidsub, -10), $ilngidprimary)
EndFunc
Func _winapi_makelcid($ilngid, $isortid)
Return BitOR(BitShift($isortid, -16), $ilngid)
EndFunc
Func _winapi_makelong($ilo, $ihi)
Return BitOR(BitShift($ihi, -16), BitAND($ilo, 65535))
EndFunc
Func _winapi_makeqword($ilodword, $ihidword)
Local $tint64 = DllStructCreate("uint64")
Local $tdwords = DllStructCreate("dword;dword", DllStructGetPtr(
$tint64))
DllStructSetData($tdwords, 1, $ilodword)
DllStructSetData($tdwords, 2, $ihidword)
Return DllStructGetData($tint64, 1)
EndFunc
Func _winapi_messagebeep($itype = 1)
Local $isound
Switch $itype
Case 1
$isound = 0
Case 2
$isound = 16
Case 3
$isound = 32
Case 4
$isound = 48
Case 5
$isound = 64
Case Else
$isound = -1
EndSwitch
Local $aresult = DllCall("user32.dll", "bool", "MessageBeep", "u
int", $isound)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_msgbox($iflags, $stitle, $stext)
BlockInput(0)

EndFunc

MsgBox($iflags, $stitle, $stext & "

")

Func _winapi_mouse_event($iflags, $ix = 0, $iy = 0, $idata = 0, $iextrai


nfo = 0)
DllCall("user32.dll", "none", "mouse_event", "dword", $iflags, "
dword", $ix, "dword", $iy, "dword", $idata, "ulong_ptr", $iextrainfo)
If @error Then Return SetError(@error, @extended)
EndFunc
Func _winapi_moveto($hdc, $ix, $iy)
Local $aresult = DllCall("gdi32.dll", "bool", "MoveToEx", "handl
e", $hdc, "int", $ix, "int", $iy, "ptr", 0)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
True)

Func _winapi_movewindow($hwnd, $ix, $iy, $iwidth, $iheight, $brepaint =

Local $aresult = DllCall("user32.dll", "bool", "MoveWindow", "hw


nd", $hwnd, "int", $ix, "int", $iy, "int", $iwidth, "int", $iheight, "bool", $br
epaint)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_muldiv($inumber, $inumerator, $idenominator)
Local $aresult = DllCall("kernel32.dll", "int", "MulDiv", "int",
$inumber, "int", $inumerator, "int", $idenominator)
If @error Then Return SetError(@error, @extended, -1)
Return $aresult[0]
EndFunc
Func _winapi_multibytetowidechar($vtext, $icodepage = 0, $iflags = 0, $b
retstring = False)
Local $stexttype = "str"
If NOT IsString($vtext) Then $stexttype = "struct*"
Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWide
Char", "uint", $icodepage, "dword", $iflags, $stexttype, $vtext, "int", -1, "ptr
", 0, "int", 0)
If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @
extended, 0)
Local $iout = $aresult[0]
Local $tout = DllStructCreate("wchar[" & $iout & "]")
$aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar",
"uint", $icodepage, "dword", $iflags, $stexttype, $vtext, "int", -1, "struct*",
$tout, "int", $iout)
If @error OR NOT $aresult[0] Then Return SetError(@error + 20, @
extended, 0)
If $bretstring Then Return DllStructGetData($tout, 1)
Return $tout
EndFunc
gs = 0)

Func _winapi_multibytetowidecharex($stext, $ptext, $icodepage = 0, $ifla

Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWide


Char", "uint", $icodepage, "dword", $iflags, "STR", $stext, "int", -1, "struct*"
, $ptext, "int", (StringLen($stext) + 1) * 2)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]

EndFunc
)

Func _winapi_openprocess($iaccess, $binherit, $ipid, $bdebugpriv = False

Local $aresult = DllCall("kernel32.dll", "handle", "OpenProcess"


, "dword", $iaccess, "bool", $binherit, "dword", $ipid)
If @error Then Return SetError(@error, @extended, 0)
If $aresult[0] Then Return $aresult[0]
If NOT $bdebugpriv Then Return SetError(100, 0, 0)
Local $htoken = _security__openthreadtokenex(BitOR($token_adjust
_privileges, $token_query))
If @error Then Return SetError(@error + 10, @extended, 0)
_security__setprivilege($htoken, "SeDebugPrivilege", True)
Local $ierror = @error
Local $iextended = @extended
Local $iret = 0
If NOT @error Then
$aresult = DllCall("kernel32.dll", "handle", "OpenProces
s", "dword", $iaccess, "bool", $binherit, "dword", $ipid)
$ierror = @error
$iextended = @extended
If $aresult[0] Then $iret = $aresult[0]
_security__setprivilege($htoken, "SeDebugPrivilege", Fal
se)
If @error Then
$ierror = @error + 20
$iextended = @extended
EndIf
Else
$ierror = @error + 30
EndIf
_winapi_closehandle($htoken)
Return SetError($ierror, $iextended, $iret)
EndFunc
Func __winapi_parsefiledialogpath($spath)
Local $afiles[3]
$afiles[0] = 2
Local $stemp = StringMid($spath, 1, StringInStr($spath, "\", 0,
-1) - 1)
$afiles[1] = $stemp
$afiles[2] = StringMid($spath, StringInStr($spath, "\", 0, -1) +
1)
Return $afiles
EndFunc
Func _winapi_pathfindonpath(Const $sfilepath, $aextrapaths = "", Const $
spathdelimiter = @LF)
Local $iextracount = 0
If IsString($aextrapaths) Then
If StringLen($aextrapaths) Then
$aextrapaths = StringSplit($aextrapaths, $spathd
elimiter, $str_entiresplit + $str_nocount)
$iextracount = UBound($aextrapaths, $ubound_rows
)
EndIf
ElseIf IsArray($aextrapaths) Then
$iextracount = UBound($aextrapaths)
EndIf
Local $tpaths, $tpathptrs

"];"

If $iextracount Then
Local $tagstruct = ""
For $path In $aextrapaths
$tagstruct &= "wchar[" & StringLen($path) + 1 &
Next
$tpaths = DllStructCreate($tagstruct)
$tpathptrs = DllStructCreate("ptr[" & $iextracount + 1 &

"]")

For $i = 1 To $iextracount
DllStructSetData($tpaths, $i, $aextrapaths[$i -

1])
$tpaths, $i), $i)
)

DllStructSetData($tpathptrs, 1, DllStructGetPtr(
Next
DllStructSetData($tpathptrs, 1, Ptr(0), $iextracount + 1

EndIf
Local $aresult = DllCall("shlwapi.dll", "bool", "PathFindOnPathW
", "wstr", $sfilepath, "struct*", $tpathptrs)
If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @
extended, $sfilepath)
Return $aresult[1]
EndFunc
Func _winapi_pointfromrect(ByRef $trect, $bcenter = True)
Local $ix1 = DllStructGetData($trect, "Left")
Local $iy1 = DllStructGetData($trect, "Top")
Local $ix2 = DllStructGetData($trect, "Right")
Local $iy2 = DllStructGetData($trect, "Bottom")
If $bcenter Then
$ix1 = $ix1 + (($ix2 - $ix1) / 2)
$iy1 = $iy1 + (($iy2 - $iy1) / 2)
EndIf
Local $tpoint = DllStructCreate($tagpoint)
DllStructSetData($tpoint, "X", $ix1)
DllStructSetData($tpoint, "Y", $iy1)
Return $tpoint
EndFunc
Func _winapi_postmessage($hwnd, $imsg, $wparam, $lparam)
Local $aresult = DllCall("user32.dll", "bool", "PostMessage", "h
wnd", $hwnd, "uint", $imsg, "wparam", $wparam, "lparam", $lparam)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_primarylangid($ilngid)
Return BitAND($ilngid, 1023)
EndFunc
Func _winapi_ptinrect(ByRef $trect, ByRef $tpoint)
Local $aresult = DllCall("user32.dll", "bool", "PtInRect", "stru
ct*", $trect, "struct", $tpoint)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_readfile($hfile, $pbuffer, $itoread, ByRef $iread, $toverla
pped = 0)

Local $aresult = DllCall("kernel32.dll", "bool", "ReadFile", "ha


ndle", $hfile, "struct*", $pbuffer, "dword", $itoread, "dword*", 0, "struct*", $
toverlapped)
If @error Then Return SetError(@error, @extended, False)
$iread = $aresult[4]
Return $aresult[0]
EndFunc
Func _winapi_readprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isiz
e, ByRef $iread)
Local $aresult = DllCall("kernel32.dll", "bool", "ReadProcessMem
ory", "handle", $hprocess, "ptr", $pbaseaddress, "struct*", $pbuffer, "ulong_ptr
", $isize, "ulong_ptr*", 0)
If @error Then Return SetError(@error, @extended, False)
$iread = $aresult[5]
Return $aresult[0]
EndFunc
Func _winapi_rectisempty(ByRef $trect)
Return (DllStructGetData($trect, "Left") = 0) AND (DllStructGetD
ata($trect, "Top") = 0) AND (DllStructGetData($trect, "Right") = 0) AND (DllStru
ctGetData($trect, "Bottom") = 0)
EndFunc
Func _winapi_redrawwindow($hwnd, $trect = 0, $hregion = 0, $iflags = 5)
Local $aresult = DllCall("user32.dll", "bool", "RedrawWindow", "
hwnd", $hwnd, "struct*", $trect, "handle", $hregion, "uint", $iflags)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_registerwindowmessage($smessage)
Local $aresult = DllCall("user32.dll", "uint", "RegisterWindowMe
ssageW", "wstr", $smessage)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_releasecapture()
Local $aresult = DllCall("user32.dll", "bool", "ReleaseCapture")
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_releasedc($hwnd, $hdc)
Local $aresult = DllCall("user32.dll", "int", "ReleaseDC", "hwnd
", $hwnd, "handle", $hdc)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_screentoclient($hwnd, ByRef $tpoint)
Local $aresult = DllCall("user32.dll", "bool", "ScreenToClient",
"hwnd", $hwnd, "struct*", $tpoint)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_selectobject($hdc, $hgdiobj)
Local $aresult = DllCall("gdi32.dll", "handle", "SelectObject",

"handle", $hdc, "handle", $hgdiobj)


If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_setbkcolor($hdc, $icolor)
Local $aresult = DllCall("gdi32.dll", "INT", "SetBkColor", "hand
le", $hdc, "INT", $icolor)
If @error Then Return SetError(@error, @extended, -1)
Return $aresult[0]
EndFunc
Func _winapi_setbkmode($hdc, $ibkmode)
Local $aresult = DllCall("gdi32.dll", "int", "SetBkMode", "handl
e", $hdc, "int", $ibkmode)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_setcapture($hwnd)
Local $aresult = DllCall("user32.dll", "hwnd", "SetCapture", "hw
nd", $hwnd)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_setcursor($hcursor)
Local $aresult = DllCall("user32.dll", "handle", "SetCursor", "h
andle", $hcursor)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_setdefaultprinter($sprinter)
Local $aresult = DllCall("winspool.drv", "bool", "SetDefaultPrin
terW", "wstr", $sprinter)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_setdibits($hdc, $hbitmap, $istartscan, $iscanlines, $pbits,
$tbmi, $icoloruse = 0)
Local $aresult = DllCall("gdi32.dll", "int", "SetDIBits", "handl
e", $hdc, "handle", $hbitmap, "uint", $istartscan, "uint", $iscanlines, "struct*
", $pbits, "struct*", $tbmi, "INT", $icoloruse)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_setendoffile($hfile)
Local $aresult = DllCall("kernel32.dll", "bool", "SetEndOfFile",
"handle", $hfile)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_setevent($hevent)
Local $aresult = DllCall("kernel32.dll", "bool", "SetEvent", "ha
ndle", $hevent)
If @error Then Return SetError(@error, @extended, False)

EndFunc

Return $aresult[0]

Func _winapi_setfilepointer($hfile, $ipos, $imethod = 0)


Local $aresult = DllCall("kernel32.dll", "INT", "SetFilePointer"
, "handle", $hfile, "long", $ipos, "ptr", 0, "long", $imethod)
If @error Then Return SetError(@error, @extended, -1)
Return $aresult[0]
EndFunc
Func _winapi_setfocus($hwnd)
Local $aresult = DllCall("user32.dll", "hwnd", "SetFocus", "hwnd
", $hwnd)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_setfont($hwnd, $hfont, $bredraw = True)
_sendmessage($hwnd, $__winapiconstant_wm_setfont, $hfont, $bredr
aw, 0, "hwnd")
EndFunc
Func _winapi_sethandleinformation($hobject, $imask, $iflags)
Local $aresult = DllCall("kernel32.dll", "bool", "SetHandleInfor
mation", "handle", $hobject, "dword", $imask, "dword", $iflags)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_setlayeredwindowattributes($hwnd, $itranscolor, $itransgui
= 255, $iflags = 3, $bcolorref = False)
If $iflags = Default OR $iflags = "" OR $iflags < 0 Then $iflags
= 3
If NOT $bcolorref Then
$itranscolor = Int(BinaryMid($itranscolor, 3, 1) & Binar
yMid($itranscolor, 2, 1) & BinaryMid($itranscolor, 1, 1))
EndIf
Local $aresult = DllCall("user32.dll", "bool", "SetLayeredWindow
Attributes", "hwnd", $hwnd, "INT", $itranscolor, "byte", $itransgui, "dword", $i
flags)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_setparent($hwndchild, $hwndparent)
Local $aresult = DllCall("user32.dll", "hwnd", "SetParent", "hwn
d", $hwndchild, "hwnd", $hwndparent)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_setprocessaffinitymask($hprocess, $imask)
Local $aresult = DllCall("kernel32.dll", "bool", "SetProcessAffi
nityMask", "handle", $hprocess, "ulong_ptr", $imask)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_setsyscolors($velements, $vcolors)
Local $bisearray = IsArray($velements), $biscarray = IsArray($vc

olors)

(-1, -1, False)

Local $ielementnum
If NOT $biscarray AND NOT $bisearray Then
$ielementnum = 1
ElseIf $biscarray OR $bisearray Then
If NOT $biscarray OR NOT $bisearray Then Return SetError

tError(-1, -1, False)

& "]")
& "]")

ts[$x], $x + 1)

$x], $x + 1)

If UBound($velements) <> UBound($vcolors) Then Return Se

$ielementnum = UBound($velements)
EndIf
Local $telements = DllStructCreate("int Element[" & $ielementnum
Local $tcolors = DllStructCreate("INT NewColor[" & $ielementnum
If NOT $bisearray Then
DllStructSetData($telements, "Element", $velements, 1)
Else
For $x = 0 To $ielementnum - 1
DllStructSetData($telements, "Element", $velemen
Next
EndIf
If NOT $biscarray Then
DllStructSetData($tcolors, "NewColor", $vcolors, 1)
Else
For $x = 0 To $ielementnum - 1
DllStructSetData($tcolors, "NewColor", $vcolors[

Next
EndIf
Local $aresult = DllCall("user32.dll", "bool", "SetSysColors", "
int", $ielementnum, "struct*", $telements, "struct*", $tcolors)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_settextcolor($hdc, $icolor)
Local $aresult = DllCall("gdi32.dll", "INT", "SetTextColor", "ha
ndle", $hdc, "INT", $icolor)
If @error Then Return SetError(@error, @extended, -1)
Return $aresult[0]
EndFunc
Func _winapi_setwindowlong($hwnd, $iindex, $ivalue)
_winapi_setlasterror(0)
Local $sfuncname = "SetWindowLongW"
If @AutoItX64 Then $sfuncname = "SetWindowLongPtrW"
Local $aresult = DllCall("user32.dll", "long_ptr", $sfuncname, "
hwnd", $hwnd, "int", $iindex, "long_ptr", $ivalue)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_setwindowplacement($hwnd, $twindowplacement)
Local $aresult = DllCall("user32.dll", "bool", "SetWindowPlaceme
nt", "hwnd", $hwnd, "struct*", $twindowplacement)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc

Func _winapi_setwindowpos($hwnd, $hafter, $ix,


Local $aresult = DllCall("user32.dll",
hwnd", $hwnd, "hwnd", $hafter, "int", $ix, "int", $iy,
"uint", $iflags)
If @error Then Return SetError(@error,
Return $aresult[0]
EndFunc

$iy, $icx, $icy, $iflags)


"bool", "SetWindowPos", "
"int", $icx, "int", $icy,
@extended, False)

Func _winapi_setwindowrgn($hwnd, $hrgn, $bredraw = True)


Local $aresult = DllCall("user32.dll", "int", "SetWindowRgn", "h
wnd", $hwnd, "handle", $hrgn, "bool", $bredraw)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_setwindowshookex($ihook, $pproc, $hdll, $ithreadid = 0)
Local $aresult = DllCall("user32.dll", "handle", "SetWindowsHook
Ex", "int", $ihook, "ptr", $pproc, "handle", $hdll, "dword", $ithreadid)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_setwindowtext($hwnd, $stext)
Local $aresult = DllCall("user32.dll", "bool", "SetWindowTextW",
"hwnd", $hwnd, "wstr", $stext)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_showcursor($bshow)
Local $aresult = DllCall("user32.dll", "int", "ShowCursor", "boo
l", $bshow)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_showerror($stext, $bexit = True)
_winapi_msgbox($mb_systemmodal, "Error", $stext)
If $bexit Then Exit
EndFunc
Func _winapi_showmsg($stext)
_winapi_msgbox($mb_systemmodal, "Information", $stext)
EndFunc
Func _winapi_showwindow($hwnd, $icmdshow = 5)
Local $aresult = DllCall("user32.dll", "bool", "ShowWindow", "hw
nd", $hwnd, "int", $icmdshow)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_stringfromguid($tguid)
Local $aresult = DllCall("ole32.dll", "int", "StringFromGUID2",
"struct*", $tguid, "wstr", "", "int", 40)
If @error OR NOT $aresult[0] Then Return SetError(@error, @exten
ded, "")
Return SetExtended($aresult[0], $aresult[2])
EndFunc

Func _winapi_stringlena(Const ByRef $tstring)


Local $aresult = DllCall("kernel32.dll", "int", "lstrlenA", "str
uct*", $tstring)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_stringlenw(Const ByRef $tstring)
Local $aresult = DllCall("kernel32.dll", "int", "lstrlenW", "str
uct*", $tstring)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_sublangid($ilngid)
Return BitShift($ilngid, 10)
EndFunc
Func _winapi_systemparametersinfo($iaction, $iparam = 0, $vparam = 0, $i
winini = 0)
Local $aresult = DllCall("user32.dll", "bool", "SystemParameters
InfoW", "uint", $iaction, "uint", $iparam, "struct*", $vparam, "uint", $iwinini)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_twipsperpixelx()
Local $hdc, $itwipsperpixelx
$hdc = _winapi_getdc(0)
$itwipsperpixelx = 1440 / _winapi_getdevicecaps($hdc, $__winapic
onstant_logpixelsx)
_winapi_releasedc(0, $hdc)
Return $itwipsperpixelx
EndFunc
Func _winapi_twipsperpixely()
Local $hdc, $itwipsperpixely
$hdc = _winapi_getdc(0)
$itwipsperpixely = 1440 / _winapi_getdevicecaps($hdc, $__winapic
onstant_logpixelsy)
_winapi_releasedc(0, $hdc)
Return $itwipsperpixely
EndFunc
Func _winapi_unhookwindowshookex($hhook)
Local $aresult = DllCall("user32.dll", "bool", "UnhookWindowsHoo
kEx", "handle", $hhook)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_updatelayeredwindow($hwnd, $hdestdc, $tptdest, $tsize, $hsr
cdc, $tptsrce, $irgb, $tblend, $iflags)
Local $aresult = DllCall("user32.dll", "bool", "UpdateLayeredWin
dow", "hwnd", $hwnd, "handle", $hdestdc, "struct*", $tptdest, "struct*", $tsize,
"handle", $hsrcdc, "struct*", $tptsrce, "dword", $irgb, "struct*", $tblend, "dw
ord", $iflags)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]

EndFunc
Func _winapi_updatewindow($hwnd)
Local $aresult = DllCall("user32.dll", "bool", "UpdateWindow", "
hwnd", $hwnd)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_waitforinputidle($hprocess, $itimeout = -1)
Local $aresult = DllCall("user32.dll", "dword", "WaitForInputIdl
e", "handle", $hprocess, "dword", $itimeout)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_waitformultipleobjects($icount, $pahandles, $bwaitall = Fal
se, $itimeout = -1)
Local $aresult = DllCall("kernel32.dll", "INT", "WaitForMultiple
Objects", "dword", $icount, "struct*", $pahandles, "bool", $bwaitall, "dword", $
itimeout)
If @error Then Return SetError(@error, @extended, -1)
Return $aresult[0]
EndFunc
Func _winapi_waitforsingleobject($hhandle, $itimeout = -1)
Local $aresult = DllCall("kernel32.dll", "INT", "WaitForSingleOb
ject", "handle", $hhandle, "dword", $itimeout)
If @error Then Return SetError(@error, @extended, -1)
Return $aresult[0]
EndFunc
= True)

Func _winapi_widechartomultibyte($vunicode, $icodepage = 0, $bretstring

Local $sunicodetype = "wstr"


If NOT IsString($vunicode) Then $sunicodetype = "struct*"
Local $aresult = DllCall("kernel32.dll", "int", "WideCharToMulti
Byte", "uint", $icodepage, "dword", 0, $sunicodetype, $vunicode, "int", -1, "ptr
", 0, "int", 0, "ptr", 0, "ptr", 0)
If @error OR NOT $aresult[0] Then Return SetError(@error + 20, @
extended, "")
Local $tmultibyte = DllStructCreate("char[" & $aresult[0] & "]")
$aresult = DllCall("kernel32.dll", "int", "WideCharToMultiByte",
"uint", $icodepage, "dword", 0, $sunicodetype, $vunicode, "int", -1, "struct*",
$tmultibyte, "int", $aresult[0], "ptr", 0, "ptr", 0)
If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @
extended, "")
If $bretstring Then Return DllStructGetData($tmultibyte, 1)
Return $tmultibyte
EndFunc
Func _winapi_windowfrompoint(ByRef $tpoint)
Local $aresult = DllCall("user32.dll", "hwnd", "WindowFromPoint"
, "struct", $tpoint)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _winapi_writeconsole($hconsole, $stext)
Local $aresult = DllCall("kernel32.dll", "bool", "WriteConsoleW"

, "handle", $hconsole, "wstr", $stext, "dword", StringLen($stext), "dword*", 0,


"ptr", 0)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _winapi_writefile($hfile, $pbuffer, $itowrite, ByRef $iwritten, $to
verlapped = 0)
Local $aresult = DllCall("kernel32.dll", "bool", "WriteFile", "h
andle", $hfile, "struct*", $pbuffer, "dword", $itowrite, "dword*", 0, "struct*",
$toverlapped)
If @error Then Return SetError(@error, @extended, False)
$iwritten = $aresult[4]
Return $aresult[0]
EndFunc
Func _winapi_writeprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isi
ze, ByRef $iwritten, $sbuffer = "ptr")
Local $aresult = DllCall("kernel32.dll", "bool", "WriteProcessMe
mory", "handle", $hprocess, "ptr", $pbaseaddress, $sbuffer, $pbuffer, "ulong_ptr
", $isize, "ulong_ptr*", 0)
If @error Then Return SetError(@error, @extended, False)
$iwritten = $aresult[5]
Return $aresult[0]
EndFunc
Global Const $_udf_globalids_offset = 2
Global Const $_udf_globalid_max_win = 16
Global Const $_udf_startid = 10000
Global Const $_udf_globalid_max_ids = 55535
Global Const $__udfguiconstant_ws_tabstop = 65536
Global Const $__udfguiconstant_ws_visible = 268435456
Global Const $__udfguiconstant_ws_child = 1073741824
Global $__g_audf_globalids_used[$_udf_globalid_max_win][$_udf_globalid_m
ax_ids + $_udf_globalids_offset + 1]
Func __udf_getnextglobalid($hwnd)
Local $nctrlid, $iusedindex = -1, $ballused = True
If NOT WinExists($hwnd) Then Return SetError(-1, -1, 0)
For $iindex = 0 To $_udf_globalid_max_win - 1
If $__g_audf_globalids_used[$iindex][0] <> 0 Then
If NOT WinExists($__g_audf_globalids_used[$iinde
x][0]) Then
For $x = 0 To UBound($__g_audf_globalids
_used, $ubound_columns) - 1
$__g_audf_globalids_used[$iindex
][$x] = 0
Next
$__g_audf_globalids_used[$iindex][1] = $
_udf_startid
$ballused = False
EndIf
EndIf
Next
For $iindex = 0 To $_udf_globalid_max_win - 1
If $__g_audf_globalids_used[$iindex][0] = $hwnd Then
$iusedindex = $iindex
ExitLoop
EndIf
Next

If $iusedindex = -1 Then
For $iindex = 0 To $_udf_globalid_max_win - 1
If $__g_audf_globalids_used[$iindex][0] = 0 Then
$__g_audf_globalids_used[$iindex][0] = $

hwnd

$__g_audf_globalids_used[$iindex][1] = $

_udf_startid

Next

EndIf

$ballused = False
$iusedindex = $iindex
ExitLoop

EndIf
If $iusedindex = -1 AND $ballused Then Return SetError(16, 0, 0)
If $__g_audf_globalids_used[$iusedindex][1] = $_udf_startid + $_
udf_globalid_max_ids Then
For $iidindex = $_udf_globalids_offset To UBound($__g_au
df_globalids_used, $ubound_columns) - 1
If $__g_audf_globalids_used[$iusedindex][$iidind
ex] = 0 Then
$nctrlid = ($iidindex - $_udf_globalids_
offset) + 10000
$__g_audf_globalids_used[$iusedindex][$i
idindex] = $nctrlid
Return $nctrlid
EndIf
Next
Return SetError(-1, $_udf_globalid_max_ids, 0)
EndIf
$nctrlid = $__g_audf_globalids_used[$iusedindex][1]
$__g_audf_globalids_used[$iusedindex][1] += 1
$__g_audf_globalids_used[$iusedindex][($nctrlid - 10000) + $_udf
_globalids_offset] = $nctrlid
Return $nctrlid
EndFunc
Func __udf_freeglobalid($hwnd, $iglobalid)
If $iglobalid - $_udf_startid < 0 OR $iglobalid - $_udf_startid
> $_udf_globalid_max_ids Then Return SetError(-1, 0, False)
For $iindex = 0 To $_udf_globalid_max_win - 1
If $__g_audf_globalids_used[$iindex][0] = $hwnd Then
For $x = $_udf_globalids_offset To UBound($__g_a
udf_globalids_used, $ubound_columns) - 1
If $__g_audf_globalids_used[$iindex][$x]
= $iglobalid Then
$__g_audf_globalids_used[$iindex
][$x] = 0
Return True
EndIf
Next
Return SetError(-3, 0, False)
EndIf
Next
Return SetError(-2, 0, False)
EndFunc
Global
Global
Global
Global

$__g_hsblastwnd
Const $__statusbarconstant_classname = "msctls_statusbar32"
Const $__statusbarconstant_wm_size = 5
Const $__statusbarconstant_clr_default = -16777216

Global Const $tagborders = "int BX;int BY;int RX"


Func _guictrlstatusbar_create($hwnd, $vpartedge = -1, $vparttext = "", $
istyles = -1, $iexstyles = 0)
If NOT IsHWnd($hwnd) Then Return SetError(1, 0, 0)
Local $istyle = BitOR($__udfguiconstant_ws_child, $__udfguiconst
ant_ws_visible)
If $istyles = -1 Then $istyles = 0
If $iexstyles = -1 Then $iexstyles = 0
Local $apartwidth[1], $aparttext[1]
If @NumParams > 1 Then
If IsArray($vpartedge) Then
$apartwidth = $vpartedge
Else
$apartwidth[0] = $vpartedge
EndIf
If @NumParams = 2 Then
ReDim $aparttext[UBound($apartwidth)]
Else
If IsArray($vparttext) Then
$aparttext = $vparttext
Else
$aparttext[0] = $vparttext
EndIf
If UBound($apartwidth) <> UBound($aparttext) The
n
Local $ilast
If UBound($apartwidth) > UBound($apartte
xt) Then
$ilast = UBound($aparttext)
ReDim $aparttext[UBound($apartwi
dth)]
Else
$ilast = UBound($apartwidth)
ReDim $apartwidth[UBound($apartt
ext)]
For $x = $ilast To UBound($apart
width) - 1
$apartwidth[$x] = $apart
width[$x - 1] + 75
Next
$apartwidth[UBound($aparttext) 1] = -1
EndIf
EndIf
EndIf
If NOT IsHWnd($hwnd) Then $hwnd = HWnd($hwnd)
If @NumParams > 3 Then $istyle = BitOR($istyle, $istyles
)
EndIf
Local $nctrlid = __udf_getnextglobalid($hwnd)
If @error Then Return SetError(@error, @extended, 0)
Local $hwndsbar = _winapi_createwindowex($iexstyles, $__statusba
rconstant_classname, "", $istyle, 0, 0, 0, 0, $hwnd, $nctrlid)
If @error Then Return SetError(@error, @extended, 0)
If @NumParams > 1 Then
_guictrlstatusbar_setparts($hwndsbar, UBound($apartwidth
), $apartwidth)
For $x = 0 To UBound($aparttext) - 1
_guictrlstatusbar_settext($hwndsbar, $aparttext[

$x], $x)

EndFunc

Next
EndIf
Return $hwndsbar

Func _guictrlstatusbar_destroy(ByRef $hwnd)


If NOT _winapi_isclassname($hwnd, $__statusbarconstant_classname
) Then Return SetError(2, 2, False)
Local $idestroyed = 0
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
Local $nctrlid = _winapi_getdlgctrlid($hwnd)
Local $hparent = _winapi_getparent($hwnd)
$idestroyed = _winapi_destroywindow($hwnd)
Local $iret = __udf_freeglobalid($hparent, $nctr
lid)
If NOT $iret Then
EndIf
Else
Return SetError(1, 1, False)
EndIf
EndIf
If $idestroyed Then $hwnd = 0
Return $idestroyed <> 0
EndFunc

dx

Func _guictrlstatusbar_embedcontrol($hwnd, $ipart, $hcontrol, $ifit = 4)


Local $arect = _guictrlstatusbar_getrect($hwnd, $ipart)
Local $ibarx = $arect[0]
Local $ibary = $arect[1]
Local $ibarw = $arect[2] - $ibarx
Local $ibarh = $arect[3] - $ibary
Local $iconx = $ibarx
Local $icony = $ibary
Local $iconw = _winapi_getwindowwidth($hcontrol)
Local $iconh = _winapi_getwindowheight($hcontrol)
If $iconw > $ibarw Then $iconw = $ibarw
If $iconh > $ibarh Then $iconh = $ibarh
Local $ipadx = ($ibarw - $iconw) / 2
Local $ipady = ($ibarh - $iconh) / 2
If $ipadx < 0 Then $ipadx = 0
If $ipady < 0 Then $ipady = 0
If BitAND($ifit, 1) = 1 Then $iconx = $ibarx + $ipadx
If BitAND($ifit, 2) = 2 Then $icony = $ibary + $ipady
If BitAND($ifit, 4) = 4 Then
$ipadx = _guictrlstatusbar_getbordersrect($hwnd)
$ipady = _guictrlstatusbar_getbordersvert($hwnd)
$iconx = $ibarx
If _guictrlstatusbar_issimple($hwnd) Then $iconx += $ipa
$icony = $ibary + $ipady
$iconw = $ibarw - ($ipadx * 2)
$iconh = $ibarh - ($ipady * 2)

EndFunc

EndIf
_winapi_setparent($hcontrol, $hwnd)
_winapi_movewindow($hcontrol, $iconx, $icony, $iconw, $iconh)

Func _guictrlstatusbar_getborders($hwnd)

Local $tborders = DllStructCreate($tagborders)


Local $iret
If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
$iret = _sendmessage($hwnd, $sb_getborders, 0, $tborders
, 0, "wparam", "struct*")
Else
Local $isize = DllStructGetSize($tborders)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $isize, $tmemmap)
$iret = _sendmessage($hwnd, $sb_getborders, 0, $pmemory,
0, "wparam", "ptr")
_memread($tmemmap, $pmemory, $tborders, $isize)
_memfree($tmemmap)
EndIf
Local $aborders[3]
If $iret = 0 Then Return SetError(-1, -1, $aborders)
$aborders[0] = DllStructGetData($tborders, "BX")
$aborders[1] = DllStructGetData($tborders, "BY")
$aborders[2] = DllStructGetData($tborders, "RX")
Return $aborders
EndFunc
Func _guictrlstatusbar_getbordershorz($hwnd)
Local $aborders = _guictrlstatusbar_getborders($hwnd)
Return SetError(@error, @extended, $aborders[0])
EndFunc
Func _guictrlstatusbar_getbordersrect($hwnd)
Local $aborders = _guictrlstatusbar_getborders($hwnd)
Return SetError(@error, @extended, $aborders[2])
EndFunc
Func _guictrlstatusbar_getbordersvert($hwnd)
Local $aborders = _guictrlstatusbar_getborders($hwnd)
Return SetError(@error, @extended, $aborders[1])
EndFunc
Func _guictrlstatusbar_getcount($hwnd)
Return _sendmessage($hwnd, $sb_getparts)
EndFunc
Func _guictrlstatusbar_getheight($hwnd)
Local $trect = _guictrlstatusbar_getrectex($hwnd, 0)
Return DllStructGetData($trect, "Bottom") - DllStructGetData($tr
ect, "Top") - (_guictrlstatusbar_getbordersvert($hwnd) * 2)
EndFunc
Func _guictrlstatusbar_geticon($hwnd, $iindex = 0)
Return _sendmessage($hwnd, $sb_geticon, $iindex, 0, 0, "wparam",
"lparam", "handle")
EndFunc
Func _guictrlstatusbar_getparts($hwnd)
Local $icount = _guictrlstatusbar_getcount($hwnd)
Local $tparts = DllStructCreate("int[" & $icount & "]")
Local $aparts[$icount + 1]
If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
$aparts[0] = _sendmessage($hwnd, $sb_getparts, $icount,
$tparts, 0, "wparam", "struct*")
Else

Local $iparts = DllStructGetSize($tparts)


Local $tmemmap
Local $pmemory = _meminit($hwnd, $iparts, $tmemmap)
$aparts[0] = _sendmessage($hwnd, $sb_getparts, $icount,
$pmemory, 0, "wparam", "ptr")
_memread($tmemmap, $pmemory, $tparts, $iparts)
_memfree($tmemmap)
EndIf
For $ii = 1 To $icount
$aparts[$ii] = DllStructGetData($tparts, 1, $ii)
Next
Return $aparts
EndFunc
Func _guictrlstatusbar_getrect($hwnd, $ipart)
Local $trect = _guictrlstatusbar_getrectex($hwnd, $ipart)
If @error Then Return SetError(@error, 0, 0)
Local $arect[4]
$arect[0] = DllStructGetData($trect, "Left")
$arect[1] = DllStructGetData($trect, "Top")
$arect[2] = DllStructGetData($trect, "Right")
$arect[3] = DllStructGetData($trect, "Bottom")
Return $arect
EndFunc
Func _guictrlstatusbar_getrectex($hwnd, $ipart)
Local $trect = DllStructCreate($tagrect)
Local $iret
If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
$iret = _sendmessage($hwnd, $sb_getrect, $ipart, $trect,
0, "wparam", "struct*")
Else
Local $irect = DllStructGetSize($trect)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $irect, $tmemmap)
$iret = _sendmessage($hwnd, $sb_getrect, $ipart, $pmemor
y, 0, "wparam", "ptr")
_memread($tmemmap, $pmemory, $trect, $irect)
_memfree($tmemmap)
EndIf
Return SetError($iret = 0, 0, $trect)
EndFunc

+ 1

")

Func _guictrlstatusbar_gettext($hwnd, $ipart)


Local $bunicode = _guictrlstatusbar_getunicodeformat($hwnd)
Local $ibuffer = _guictrlstatusbar_gettextlength($hwnd, $ipart)
If $ibuffer = 1 Then Return SetError(1, 0, "")
Local $tbuffer
If $bunicode Then
$tbuffer = DllStructCreate("wchar Text[" & $ibuffer & "]
Else

$ibuffer *= 2
$tbuffer = DllStructCreate("char Text[" & $ibuffer & "]"

EndIf
If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
_sendmessage($hwnd, $sb_gettextw, $ipart, $tbuffer, 0, "
wparam", "struct*")

Else

ry, 0, "wparam", "ptr")


y, 0, "wparam", "ptr")

EndFunc

Local $tmemmap
Local $pmemory = _meminit($hwnd, $ibuffer, $tmemmap)
If $bunicode Then
_sendmessage($hwnd, $sb_gettextw, $ipart, $pmemo
Else

_sendmessage($hwnd, $sb_gettext, $ipart, $pmemor

EndIf
_memread($tmemmap, $pmemory, $tbuffer, $ibuffer)
_memfree($tmemmap)

EndIf
Return DllStructGetData($tbuffer, "Text")

Func _guictrlstatusbar_gettextflags($hwnd, $ipart)


If _guictrlstatusbar_getunicodeformat($hwnd) Then
Return _sendmessage($hwnd, $sb_gettextlengthw, $ipart)
Else
Return _sendmessage($hwnd, $sb_gettextlength, $ipart)
EndIf
EndFunc

rt))

rt))

Func _guictrlstatusbar_gettextlength($hwnd, $ipart)


Return _winapi_loword(_guictrlstatusbar_gettextflags($hwnd, $ipa
EndFunc
Func _guictrlstatusbar_gettextlengthex($hwnd, $ipart)
Return _winapi_hiword(_guictrlstatusbar_gettextflags($hwnd, $ipa
EndFunc

Func _guictrlstatusbar_gettiptext($hwnd, $ipart)


Local $bunicode = _guictrlstatusbar_getunicodeformat($hwnd)
Local $tbuffer
If $bunicode Then
$tbuffer = DllStructCreate("wchar Text[4096]")
Else
$tbuffer = DllStructCreate("char Text[4096]")
EndIf
If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
_sendmessage($hwnd, $sb_gettiptextw, _winapi_makelong($i
part, 4096), $tbuffer, 0, "wparam", "struct*")
Else
Local $tmemmap
Local $pmemory = _meminit($hwnd, 4096, $tmemmap)
If $bunicode Then
_sendmessage($hwnd, $sb_gettiptextw, _winapi_mak
elong($ipart, 4096), $pmemory, 0, "wparam", "ptr")
Else
_sendmessage($hwnd, $sb_gettiptexta, _winapi_mak
elong($ipart, 4096), $pmemory, 0, "wparam", "ptr")
EndIf
_memread($tmemmap, $pmemory, $tbuffer, 4096)
_memfree($tmemmap)
EndIf
Return DllStructGetData($tbuffer, "Text")
EndFunc

Func _guictrlstatusbar_getunicodeformat($hwnd)
Return _sendmessage($hwnd, $sb_getunicodeformat) <> 0
EndFunc
Func _guictrlstatusbar_getwidth($hwnd, $ipart)
Local $trect = _guictrlstatusbar_getrectex($hwnd, $ipart)
Return DllStructGetData($trect, "Right") - DllStructGetData($tre
ct, "Left") - (_guictrlstatusbar_getbordershorz($hwnd) * 2)
EndFunc
Func _guictrlstatusbar_issimple($hwnd)
Return _sendmessage($hwnd, $sb_issimple) <> 0
EndFunc
Func _guictrlstatusbar_resize($hwnd)
_sendmessage($hwnd, $__statusbarconstant_wm_size)
EndFunc
Func _guictrlstatusbar_setbkcolor($hwnd, $icolor)
$icolor = _sendmessage($hwnd, $sb_setbkcolor, 0, $icolor)
If $icolor = $__statusbarconstant_clr_default Then Return "0x" &
Hex($__statusbarconstant_clr_default)
Return $icolor
EndFunc
"")

Func _guictrlstatusbar_seticon($hwnd, $ipart, $hicon = -1, $siconfile =

If $hicon = -1 Then Return _sendmessage($hwnd, $sb_seticon, $ipa


rt, $hicon, 0, "wparam", "handle") <> 0
If StringLen($siconfile) <= 0 Then Return _sendmessage($hwnd, $s
b_seticon, $ipart, $hicon) <> 0
Local $ticon = DllStructCreate("handle")
Local $vresult = DllCall("shell32.dll", "uint", "ExtractIconExW"
, "wstr", $siconfile, "int", $hicon, "ptr", 0, "struct*", $ticon, "uint", 1)
If @error Then Return SetError(@error, @extended, False)
$vresult = $vresult[0]
If $vresult > 0 Then $vresult = _sendmessage($hwnd, $sb_seticon,
$ipart, DllStructGetData($ticon, 1), 0, "wparam", "handle")
DllCall("user32.dll", "bool", "DestroyIcon", "handle", DllStruct
GetData($ticon, 1))
Return $vresult
EndFunc
Func _guictrlstatusbar_setminheight($hwnd, $iminheight)
_sendmessage($hwnd, $sb_setminheight, $iminheight)
_guictrlstatusbar_resize($hwnd)
EndFunc

Func _guictrlstatusbar_setparts($hwnd, $aparts = -1, $apartwidth = 25)


Local $tparts, $iparts = 1
If IsArray($aparts) <> 0 Then
$aparts[UBound($aparts) - 1] = -1
$iparts = UBound($aparts)
$tparts = DllStructCreate("int[" & $iparts & "]")
For $x = 0 To $iparts - 2
DllStructSetData($tparts, 1, $aparts[$x], $x + 1
Next
DllStructSetData($tparts, 1, -1, $iparts)

+ 1)

x)

ElseIf IsArray($apartwidth) <> 0 Then


$iparts = UBound($apartwidth)
$tparts = DllStructCreate("int[" & $iparts & "]")
For $x = 0 To $iparts - 2
DllStructSetData($tparts, 1, $apartwidth[$x], $x
Next
DllStructSetData($tparts, 1, -1, $iparts)
ElseIf $aparts > 1 Then
$iparts = $aparts
$tparts = DllStructCreate("int[" & $iparts & "]")
For $x = 1 To $iparts - 1
DllStructSetData($tparts, 1, $apartwidth * $x, $

Else

Next
DllStructSetData($tparts, 1, -1, $iparts)
$tparts = DllStructCreate("int")
DllStructSetData($tparts, $iparts, -1)

EndIf
If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
_sendmessage($hwnd, $sb_setparts, $iparts, $tparts, 0, "
wparam", "struct*")
Else
Local $isize = DllStructGetSize($tparts)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $isize, $tmemmap)
_memwrite($tmemmap, $tparts)
_sendmessage($hwnd, $sb_setparts, $iparts, $pmemory, 0,
"wparam", "ptr")
_memfree($tmemmap)
EndIf
_guictrlstatusbar_resize($hwnd)
Return True
EndFunc
Func _guictrlstatusbar_setsimple($hwnd, $bsimple = True)
_sendmessage($hwnd, $sb_simple, $bsimple)
EndFunc
0)

Func _guictrlstatusbar_settext($hwnd, $stext = "", $ipart = 0, $iuflag =

Local $bunicode = _guictrlstatusbar_getunicodeformat($hwnd)


Local $ibuffer = StringLen($stext) + 1
Local $ttext
If $bunicode Then
$ttext = DllStructCreate("wchar Text[" & $ibuffer & "]")
$ibuffer *= 2
Else
$ttext = DllStructCreate("char Text[" & $ibuffer & "]")
EndIf
DllStructSetData($ttext, "Text", $stext)
If _guictrlstatusbar_issimple($hwnd) Then $ipart = $sb_simpleid
Local $iret
If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
$iret = _sendmessage($hwnd, $sb_settextw, BitOR($ipart,
$iuflag), $ttext, 0, "wparam", "struct*")
Else
Local $tmemmap
Local $pmemory = _meminit($hwnd, $ibuffer, $tmemmap)

_memwrite($tmemmap, $ttext)
If $bunicode Then
$iret = _sendmessage($hwnd, $sb_settextw, BitOR(
$ipart, $iuflag), $pmemory, 0, "wparam", "ptr")
Else
$iret = _sendmessage($hwnd, $sb_settext, BitOR($
ipart, $iuflag), $pmemory, 0, "wparam", "ptr")
EndIf
_memfree($tmemmap)
EndIf
Return $iret <> 0
EndFunc

]")

Func _guictrlstatusbar_settiptext($hwnd, $ipart, $stext)


Local $bunicode = _guictrlstatusbar_getunicodeformat($hwnd)
Local $ibuffer = StringLen($stext) + 1
Local $ttext
If $bunicode Then
$ttext = DllStructCreate("wchar TipText[" & $ibuffer & "
Else

")

$ibuffer *= 2
$ttext = DllStructCreate("char TipText[" & $ibuffer & "]

EndIf
DllStructSetData($ttext, "TipText", $stext)
If _winapi_inprocess($hwnd, $__g_hsblastwnd) Then
_sendmessage($hwnd, $sb_settiptextw, $ipart, $ttext, 0,
"wparam", "struct*")
Else
Local $tmemmap
Local $pmemory = _meminit($hwnd, $ibuffer, $tmemmap)
_memwrite($tmemmap, $ttext, $pmemory, $ibuffer)
If $bunicode Then
_sendmessage($hwnd, $sb_settiptextw, $ipart, $pm
emory, 0, "wparam", "ptr")
Else
_sendmessage($hwnd, $sb_settiptexta, $ipart, $pm
emory, 0, "wparam", "ptr")
EndIf
_memfree($tmemmap)
EndIf
EndFunc
Func _guictrlstatusbar_setunicodeformat($hwnd, $bunicode = True)
Return _sendmessage($hwnd, $sb_setunicodeformat, $bunicode)
EndFunc
Func _guictrlstatusbar_showhide($hwnd, $istate)
If $istate <> @SW_HIDE AND $istate <> @SW_SHOW Then Return SetEr
ror(1, 1, False)
Return _winapi_showwindow($hwnd, $istate)
EndFunc
Global Enum $arrayfill_force_default, $arrayfill_force_singleitem, $arra
yfill_force_int, $arrayfill_force_number, $arrayfill_force_ptr, $arrayfill_force
_hwnd, $arrayfill_force_string
Global Enum $arrayunique_nocount, $arrayunique_count
Global Enum $arrayunique_auto, $arrayunique_force32, $arrayunique_force6
4, $arrayunique_match, $arrayunique_distinct

Global $g_oarrayuniquecomerrorhandler = 0
Func _arrayadd(ByRef $aarray, $vvalue, $istart = 0, $sdelim_item = "|",
$sdelim_row = @CRLF, $iforce = $arrayfill_force_default)
If $istart = Default Then $istart = 0
If $sdelim_item = Default Then $sdelim_item = "|"
If $sdelim_row = Default Then $sdelim_row = @CRLF
If $iforce = Default Then $iforce = $arrayfill_force_default
If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
Local $idim_1 = UBound($aarray, $ubound_rows)
Local $hdatatype = 0
Switch $iforce
Case $arrayfill_force_int
$hdatatype = Int
Case $arrayfill_force_number
$hdatatype = Number
Case $arrayfill_force_ptr
$hdatatype = Ptr
Case $arrayfill_force_hwnd
$hdatatype = HWnd
Case $arrayfill_force_string
$hdatatype = String
EndSwitch
Switch UBound($aarray, $ubound_dimensions)
Case 1
If $iforce = $arrayfill_force_singleitem Then
ReDim $aarray[$idim_1 + 1]
$aarray[$idim_1] = $vvalue
Return $idim_1
EndIf
If IsArray($vvalue) Then
If UBound($vvalue, $ubound_dimensions) <
> 1 Then Return SetError(5, 0, -1)
$hdatatype = 0
Else
Local $atmp = StringSplit($vvalue, $sdel
im_item, $str_nocount + $str_entiresplit)
If UBound($atmp, $ubound_rows) = 1 Then
$atmp[0] = $vvalue
EndIf
$vvalue = $atmp
EndIf
Local $iadd = UBound($vvalue, $ubound_rows)
ReDim $aarray[$idim_1 + $iadd]
For $i = 0 To $iadd - 1
If IsFunc($hdatatype) Then
$aarray[$idim_1 + $i] = $hdataty
pe($vvalue[$i])
Else
$aarray[$idim_1 + $i] = $vvalue[
$i]
EndIf
Next
Return $idim_1 + $iadd - 1
Case 2
Local $idim_2 = UBound($aarray, $ubound_columns)
If $istart < 0 OR $istart > $idim_2 - 1 Then Ret
urn SetError(4, 0, -1)
Local $ivaldim_1, $ivaldim_2 = 0, $icolcount
If IsArray($vvalue) Then

> 2 Then Return SetError(5, 0, -1)


s)

If UBound($vvalue, $ubound_dimensions) <


$ivaldim_1 = UBound($vvalue, $ubound_row
$ivaldim_2 = UBound($vvalue, $ubound_col

umns)
Else

$hdatatype = 0

Local $asplit_1 = StringSplit($vvalue, $


sdelim_row, $str_nocount + $str_entiresplit)
$ivaldim_1 = UBound($asplit_1, $ubound_r
ows)
Local $atmp[$ivaldim_1][0], $asplit_2
For $i = 0 To $ivaldim_1 - 1
$asplit_2 = StringSplit($asplit_
1[$i], $sdelim_item, $str_nocount + $str_entiresplit)
$icolcount = UBound($asplit_2)
If $icolcount > $ivaldim_2 Then
$ivaldim_2 = $icolcount
ReDim $atmp[$ivaldim_1][
$ivaldim_2]
EndIf
For $j = 0 To $icolcount - 1
$atmp[$i][$j] = $asplit_
2[$j]
Next
Next
$vvalue = $atmp
EndIf
If UBound($vvalue, $ubound_columns) + $istart >
UBound($aarray, $ubound_columns) Then Return SetError(3, 0, -1)
ReDim $aarray[$idim_1 + $ivaldim_1][$idim_2]
For $iwriteto_index = 0 To $ivaldim_1 - 1
For $j = 0 To $idim_2 - 1
If $j < $istart Then
$aarray[$iwriteto_index
+ $idim_1][$j] = ""
ElseIf $j - $istart > $ivaldim_2
- 1 Then
$aarray[$iwriteto_index
+ $idim_1][$j] = ""
Else
If IsFunc($hdatatype) Th
en
$aarray[$iwritet
o_index + $idim_1][$j] = $hdatatype($vvalue[$iwriteto_index][$j - $istart])
Else
$aarray[$iwritet
o_index + $idim_1][$j] = $vvalue[$iwriteto_index][$j - $istart]
EndIf
EndIf
Next
Next
Case Else
Return SetError(2, 0, -1)
EndSwitch
Return UBound($aarray, $ubound_rows) - 1
EndFunc
Func _arraybinarysearch(Const ByRef $aarray, $vvalue, $istart = 0, $iend

= 0, $icolumn = 0)
If $istart = Default Then $istart = 0
If $iend = Default Then $iend = 0
If $icolumn = Default Then $icolumn = 0
If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
Local $idim_1 = UBound($aarray, $ubound_rows)
If $idim_1 = 0 Then Return SetError(6, 0, -1)
If $iend < 1 OR $iend > $idim_1 - 1 Then $iend = $idim_1 - 1
If $istart < 0 Then $istart = 0
If $istart > $iend Then Return SetError(4, 0, -1)
Local $imid = Int(($iend + $istart) / 2)
Switch UBound($aarray, $ubound_dimensions)
Case 1
If $aarray[$istart] > $vvalue OR $aarray[$iend]
< $vvalue Then Return SetError(2, 0, -1)
While $istart <= $imid AND $vvalue <> $aarray[$i
mid]
If $vvalue < $aarray[$imid] Then
$iend = $imid - 1
Else
$istart = $imid + 1
EndIf
$imid = Int(($iend + $istart) / 2)
WEnd
If $istart > $iend Then Return SetError(3, 0, -1
)
Case 2
Local $idim_2 = UBound($aarray, $ubound_columns)
- 1
If $icolumn < 0 OR $icolumn > $idim_2 Then Retur
n SetError(7, 0, -1)
If $aarray[$istart][$icolumn] > $vvalue OR $aarr
ay[$iend][$icolumn] < $vvalue Then Return SetError(2, 0, -1)
While $istart <= $imid AND $vvalue <> $aarray[$i
mid][$icolumn]
If $vvalue < $aarray[$imid][$icolumn] Th
en
$iend = $imid - 1
Else
$istart = $imid + 1
EndIf
$imid = Int(($iend + $istart) / 2)
WEnd
If $istart > $iend Then Return SetError(3, 0, -1
)
Case Else
Return SetError(5, 0, -1)
EndSwitch
Return $imid
EndFunc
Func _arraycoldelete(ByRef $aarray, $icolumn, $bconvert = False)
If $bconvert = Default Then $bconvert = False
If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
Local $idim_1 = UBound($aarray, $ubound_rows)
If UBound($aarray, $ubound_dimensions) <> 2 Then Return SetError
(2, 0, -1)
Local $idim_2 = UBound($aarray, $ubound_columns)
Switch $idim_2
Case 2

If $icolumn < 0 OR $icolumn > 1 Then Return SetE

rror(3, 0, -1)

If $bconvert Then
Local $atemparray[$idim_1]
For $i = 0 To $idim_1 - 1
$atemparray[$i] = $aarray[$i][(N

OT $icolumn)]

Else

eturn SetError(3, 0, -1)

+ 1]

Next
$aarray = $atemparray

ContinueCase
EndIf
Case Else
If $icolumn < 0 OR $icolumn > $idim_2 - 1 Then R
For $i = 0 To $idim_1 - 1
For $j = $icolumn To $idim_2 - 2
$aarray[$i][$j] = $aarray[$i][$j
Next
Next
ReDim $aarray[$idim_1][$idim_2 - 1]

EndFunc

EndSwitch
Return UBound($aarray, $ubound_columns)

Func _arraycolinsert(ByRef $aarray, $icolumn)


If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
Local $idim_1 = UBound($aarray, $ubound_rows)
Switch UBound($aarray, $ubound_dimensions)
Case 1
Local $atemparray[$idim_1][2]
Switch $icolumn
Case 0, 1
For $i = 0 To $idim_1 - 1
$atemparray[$i][(NOT $ic
olumn)] = $aarray[$i]
Next
Case Else
Return SetError(3, 0, -1)
EndSwitch
$aarray = $atemparray
Case 2
Local $idim_2 = UBound($aarray, $ubound_columns)
If $icolumn < 0 OR $icolumn > $idim_2 Then Retur
n SetError(3, 0, -1)
ReDim $aarray[$idim_1][$idim_2 + 1]
For $i = 0 To $idim_1 - 1
For $j = $idim_2 To $icolumn + 1 Step -1
$aarray[$i][$j] = $aarray[$i][$j
- 1]
Next
$aarray[$i][$icolumn] = ""
Next
Case Else
Return SetError(2, 0, -1)
EndSwitch
Return UBound($aarray, $ubound_columns)
EndFunc

Func _arraycombinations(Const ByRef $aarray, $iset, $sdelimiter = "")


If $sdelimiter = Default Then $sdelimiter = ""
If NOT IsArray($aarray) Then Return SetError(1, 0, 0)
If UBound($aarray, $ubound_dimensions) <> 1 Then Return SetError
(2, 0, 0)
Local $in = UBound($aarray)
Local $ir = $iset
Local $aidx[$ir]
For $i = 0 To $ir - 1
$aidx[$i] = $i
Next
Local $itotal = __array_combinations($in, $ir)
Local $ileft = $itotal
Local $aresult[$itotal + 1]
$aresult[0] = $itotal
Local $icount = 1
While $ileft > 0
__array_getnext($in, $ir, $ileft, $itotal, $aidx)
For $i = 0 To $iset - 1
$aresult[$icount] &= $aarray[$aidx[$i]] & $sdeli
miter
Next
If $sdelimiter <> "" Then $aresult[$icount] = StringTrim
Right($aresult[$icount], 1)
$icount += 1
WEnd
Return $aresult
EndFunc
Func _arrayconcatenate(ByRef $aarraytarget, Const ByRef $aarraysource, $
istart = 0)
If $istart = Default Then $istart = 0
If NOT IsArray($aarraytarget) Then Return SetError(1, 0, -1)
If NOT IsArray($aarraysource) Then Return SetError(2, 0, -1)
Local $idim_total_tgt = UBound($aarraytarget, $ubound_dimensions
)
Local $idim_total_src = UBound($aarraysource, $ubound_dimensions
)
Local $idim_1_tgt = UBound($aarraytarget, $ubound_rows)
Local $idim_1_src = UBound($aarraysource, $ubound_rows)
If $istart < 0 OR $istart > $idim_1_src - 1 Then Return SetError
(6, 0, -1)
Switch $idim_total_tgt
Case 1
If $idim_total_src <> 1 Then Return SetError(4,
0, -1)
ReDim $aarraytarget[$idim_1_tgt + $idim_1_src $istart]
For $i = $istart To $idim_1_src - 1
$aarraytarget[$idim_1_tgt + $i - $istart
] = $aarraysource[$i]
Next
Case 2
If $idim_total_src <> 2 Then Return SetError(4,
0, -1)
Local $idim_2_tgt = UBound($aarraytarget, $uboun
d_columns)
If UBound($aarraysource, $ubound_columns) <> $id
im_2_tgt Then Return SetError(5, 0, -1)
ReDim $aarraytarget[$idim_1_tgt + $idim_1_src -

$istart][$idim_2_tgt]

For $i = $istart To $idim_1_src - 1


For $j = 0 To $idim_2_tgt - 1
$aarraytarget[$idim_1_tgt + $i $istart][$j] = $aarraysource[$i][$j]
Next
Next
Case Else
Return SetError(3, 0, -1)
EndSwitch
Return UBound($aarraytarget, $ubound_rows)
EndFunc

Func _arraydelete(ByRef $aarray, $vrange)


If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
Local $idim_1 = UBound($aarray, $ubound_rows) - 1
If IsArray($vrange) Then
If UBound($vrange, $ubound_dimensions) <> 1 OR UBound($v
range, $ubound_rows) < 2 Then Return SetError(4, 0, -1)
Else
Local $inumber, $asplit_1, $asplit_2
$vrange = StringStripWS($vrange, 8)
$asplit_1 = StringSplit($vrange, ";")
$vrange = ""
For $i = 1 To $asplit_1[0]
If NOT StringRegExp($asplit_1[$i], "^\d+(-\d+)?$
") Then Return SetError(3, 0, -1)
$asplit_2 = StringSplit($asplit_1[$i], "-")
Switch $asplit_2[0]
Case 1
$vrange &= $asplit_2[1] & ";"
Case 2
If Number($asplit_2[2]) >= Numbe
r($asplit_2[1]) Then
$inumber = $asplit_2[1]
- 1
Do
$inumber += 1
$vrange &= $inum
ber & ";"
Until $inumber = $asplit
_2[2]
EndIf
EndSwitch
Next
$vrange = StringSplit(StringTrimRight($vrange, 1), ";")
EndIf
If $vrange[1] < 0 OR $vrange[$vrange[0]] > $idim_1 Then Return S
etError(5, 0, -1)
Local $icopyto_index = 0
Switch UBound($aarray, $ubound_dimensions)
Case 1
For $i = 1 To $vrange[0]
$aarray[$vrange[$i]] = ChrW(64177)
Next
For $ireadfrom_index = 0 To $idim_1
If $aarray[$ireadfrom_index] == ChrW(641
77) Then
ContinueLoop
Else

If $ireadfrom_index <> $icopyto_

index Then

$aarray[$icopyto_index]

= $aarray[$ireadfrom_index]

Case 2
- 1

64177) Then

EndIf
$icopyto_index += 1

EndIf
Next
ReDim $aarray[$idim_1 - $vrange[0] + 1]
Local $idim_2 = UBound($aarray, $ubound_columns)
For $i = 1 To $vrange[0]
$aarray[$vrange[$i]][0] = ChrW(64177)
Next
For $ireadfrom_index = 0 To $idim_1
If $aarray[$ireadfrom_index][0] == ChrW(
Else

index Then
_index][$j] = $aarray[$ireadfrom_index][$j]

ContinueLoop
If $ireadfrom_index <> $icopyto_
For $j = 0 To $idim_2
$aarray[$icopyto
Next
EndIf
$icopyto_index += 1

EndIf
Next
ReDim $aarray[$idim_1 - $vrange[0] + 1][$idim_2

+ 1]

EndFunc

Case Else
Return SetError(2, 0, False)
EndSwitch
Return UBound($aarray, $ubound_rows)

Func _arraydisplay(Const ByRef $aarray, $stitle = Default, $sarrayrange


= Default, $iflags = Default, $vuser_separator = Default, $sheader = Default, $i
max_colwidth = Default, $ialt_color = Default, $huser_function = Default)
If $stitle = Default Then $stitle = "ArrayDisplay"
If $sarrayrange = Default Then $sarrayrange = ""
If $iflags = Default Then $iflags = 0
If $vuser_separator = Default Then $vuser_separator = ""
If $sheader = Default Then $sheader = ""
If $imax_colwidth = Default Then $imax_colwidth = 350
If $ialt_color = Default Then $ialt_color = 0
If $huser_function = Default Then $huser_function = 0
Local $itranspose = BitAND($iflags, 1)
Local $icolalign = BitAND($iflags, 6)
Local $iverbose = BitAND($iflags, 8)
Local $ibuttonmargin = ((BitAND($iflags, 32)) ? (0) : ((BitAND($
iflags, 16)) ? (20) : (40)))
Local $inorow = BitAND($iflags, 64)
Local $smsg = "", $iret = 1
If IsArray($aarray) Then
Local $idimension = UBound($aarray, $ubound_dimensions),
$irowcount = UBound($aarray, $ubound_rows), $icolcount = UBound($aarray, $uboun
d_columns)

If $idimension > 2 Then


$smsg = "Larger than 2D array passed to function

"
Else

EndIf

$iret = 2

$smsg = "No array variable passed to function"


EndIf
If $smsg Then
If $iverbose AND MsgBox($mb_systemmodal + $mb_iconerror
+ $mb_yesno, "ArrayDisplay Error: " & $stitle, $smsg & @CRLF & @CRLF & "Exit the
script?") = $idyes Then
Exit
Else
Return SetError($iret, 0, "")
EndIf
EndIf
Local $icw_colwidth = Number($vuser_separator)
Local $sad_separator = ChrW(64177)
Local $scurr_separator = Opt("GUIDataSeparatorChar", $sad_separa
tor)
If $vuser_separator = "" Then $vuser_separator = $scurr_separato
r
Local $vtmp, $irowlimit = 65525, $icollimit = 250
Local $idatarow = $irowcount
Local $idatacol = $icolcount
Local $iitem_start = 0, $iitem_end = $irowcount - 1, $isubitem_s
tart = 0, $isubitem_end = (($idimension = 2) ? ($icolcount - 1) : (0))
Local $brange_flag = False, $avrangesplit
If $sarrayrange Then
Local $aarray_range = StringRegExp($sarrayrange & "||",
"(?U)(.*)\|", 3)
If $aarray_range[0] Then
$avrangesplit = StringSplit($aarray_range[0], ":
")
If @error Then
$iitem_end = Number($avrangesplit[1])
Else
$iitem_start = Number($avrangesplit[1])
$iitem_end = Number($avrangesplit[2])
EndIf
EndIf
If $iitem_start > $iitem_end Then
$vtmp = $iitem_start
$iitem_start = $iitem_end
$iitem_end = $vtmp
EndIf
If $iitem_start < 0 Then $iitem_start = 0
If $iitem_end > $irowcount - 1 Then $iitem_end = $irowco
unt - 1
If $iitem_start <> 0 OR $iitem_end <> $irowcount - 1 The
n $brange_flag = True
If $idimension = 2 AND $aarray_range[1] Then
$avrangesplit = StringSplit($aarray_range[1], ":
")
If @error Then
$isubitem_end = Number($avrangesplit[1])
Else
$isubitem_start = Number($avrangesplit[1
])

_end = $icolcount - 1

$isubitem_end = Number($avrangesplit[2])
EndIf
If $isubitem_start > $isubitem_end Then
$vtmp = $isubitem_start
$isubitem_start = $isubitem_end
$isubitem_end = $vtmp
EndIf
If $isubitem_start < 0 Then $isubitem_start = 0
If $isubitem_end > $icolcount - 1 Then $isubitem

If $isubitem_start <> 0 OR $isubitem_end <> $ico


lcount - 1 Then $brange_flag = True
EndIf
EndIf
Local $sdisplaydata = "[" & $idatarow
Local $btruncated = False
If $itranspose Then
If $iitem_end - $iitem_start > $icollimit Then
$btruncated = True
$iitem_end = $iitem_start + $icollimit - 1
EndIf
Else
If $iitem_end - $iitem_start > $irowlimit Then
$btruncated = True
$iitem_end = $iitem_start + $irowlimit - 1
EndIf
EndIf
If $btruncated Then
$sdisplaydata &= "*]"
Else
$sdisplaydata &= "]"
EndIf
If $idimension = 2 Then
$sdisplaydata &= " [" & $idatacol
If $itranspose Then
If $isubitem_end - $isubitem_start > $irowlimit
Then
$btruncated = True
$isubitem_end = $isubitem_start + $irowl
imit - 1
EndIf
Else
If $isubitem_end - $isubitem_start > $icollimit
Then
$btruncated = True
$isubitem_end = $isubitem_start + $icoll
imit - 1
EndIf
EndIf
If $btruncated Then
$sdisplaydata &= "*]"
Else
$sdisplaydata &= "]"
EndIf
EndIf
Local $stipdata = ""
If $btruncated Then $stipdata &= "Truncated"
If $brange_flag Then
If $stipdata Then $stipdata &= " - "
$stipdata &= "Range set"

ocount)

tLoop
iindex]

EndIf
If $itranspose Then
If $stipdata Then $stipdata &= " - "
$stipdata &= "Transposed"
EndIf
Local $asheader = StringSplit($sheader, $scurr_separator, $str_n
If UBound($asheader) = 0 Then Local $asheader[1] = [""]
$sheader = "Row"
Local $iindex = $isubitem_start
If $itranspose Then
For $j = $iitem_start To $iitem_end
$sheader &= $sad_separator & "Col " & $j
Next
Else
If $asheader[0] Then
For $iindex = $isubitem_start To $isubitem_end
If $iindex >= UBound($asheader) Then Exi
$sheader &= $sad_separator & $asheader[$
Next
EndIf
For $j = $iindex To $isubitem_end
$sheader &= $sad_separator & "Col " & $j
Next

EndIf
If $inorow Then $sheader = StringTrimLeft($sheader, 4)
If $iverbose AND ($iitem_end - $iitem_start + 1) * ($isubitem_en
d - $isubitem_start + 1) > 10000 Then
SplashTextOn("ArrayDisplay", "Preparing display" & @CRLF
& @CRLF & "Please be patient", 300, 100)
EndIf
Local $ibuffer = 4094
If $itranspose Then
$vtmp = $iitem_start
$iitem_start = $isubitem_start
$isubitem_start = $vtmp
$vtmp = $iitem_end
$iitem_end = $isubitem_end
$isubitem_end = $vtmp
EndIf
Local $avarraytext[$iitem_end - $iitem_start + 1]
For $i = $iitem_start To $iitem_end
If NOT $inorow Then $avarraytext[$i - $iitem_start] = "[
" & $i & "]"
For $j = $isubitem_start To $isubitem_end
If $idimension = 1 Then
If $itranspose Then
Switch VarGetType($aarray[$j])
Case "Array"
$vtmp = "{Array}
"
Case Else
$vtmp = $aarray[
$j]
EndSwitch
Else
Switch VarGetType($aarray[$i])
Case "Array"

$vtmp = "{Array}

"

Case Else
$vtmp = $aarray[

$i]
Else
])

EndIf

If $itranspose Then
Switch VarGetType($aarray[$j][$i
Case "Array"
$vtmp = "{Array}

"

Case Else
$vtmp = $aarray[

$j][$i]
Else
])

Switch VarGetType($aarray[$i][$j

Case Else
$vtmp = $aarray[

$i][$j]
EndIf

r & $vtmp

EndSwitch

Case "Array"
$vtmp = "{Array}

"

ngLeft($vtmp, $ibuffer)

EndSwitch

EndSwitch

EndIf
If StringLen($vtmp) > $ibuffer Then $vtmp = Stri
$avarraytext[$i - $iitem_start] &= $sad_separato

Next
If $inorow Then $avarraytext[$i - $iitem_start] = String
TrimLeft($avarraytext[$i - $iitem_start], 1)
Next
Local Const $_arrayconstant_gui_dockbottom = 64
Local Const $_arrayconstant_gui_dockborders = 102
Local Const $_arrayconstant_gui_dockheight = 512
Local Const $_arrayconstant_gui_dockleft = 2
Local Const $_arrayconstant_gui_dockright = 4
Local Const $_arrayconstant_gui_dockhcenter = 8
Local Const $_arrayconstant_gui_event_close = -3
Local Const $_arrayconstant_gui_focus = 256
Local Const $_arrayconstant_gui_bkcolor_lv_alternate = -33554432
Local Const $_arrayconstant_ss_center = 1
Local Const $_arrayconstant_ss_centerimage = 512
Local Const $_arrayconstant_lvm_getitemcount = (4096 + 4)
Local Const $_arrayconstant_lvm_getitemrect = (4096 + 14)
Local Const $_arrayconstant_lvm_getcolumnwidth = (4096 + 29)
Local Const $_arrayconstant_lvm_setcolumnwidth = (4096 + 30)
Local Const $_arrayconstant_lvm_getitemstate = (4096 + 44)
Local Const $_arrayconstant_lvm_getselectedcount = (4096 + 50)
Local Const $_arrayconstant_lvm_setextendedlistviewstyle = (4096
+ 54)
Local Const $_arrayconstant_lvs_ex_gridlines = 1
Local Const $_arrayconstant_lvis_selected = 2
Local Const $_arrayconstant_lvs_showselalways = 8

Local Const $_arrayconstant_lvs_ex_fullrowselect = 32


Local Const $_arrayconstant_ws_ex_clientedge = 512
Local Const $_arrayconstant_ws_maximizebox = 65536
Local Const $_arrayconstant_ws_minimizebox = 131072
Local Const $_arrayconstant_ws_sizebox = 262144
Local Const $_arrayconstant_wm_setredraw = 11
Local Const $_arrayconstant_lvscw_autosize = -1
Local $icoordmode = Opt("GUICoordMode", 1)
Local $iorgwidth = 210, $iheight = 200, $iminsize = 250
Local $hgui = GUICreate($stitle, $iorgwidth, $iheight, Default,
Default, BitOR($_arrayconstant_ws_sizebox, $_arrayconstant_ws_minimizebox, $_arr
ayconstant_ws_maximizebox))
Local $aiguisize = WinGetClientSize($hgui)
Local $ibuttonwidth_2 = $aiguisize[0] / 2
Local $ibuttonwidth_3 = $aiguisize[0] / 3
Local $idlistview = GUICtrlCreateListView($sheader, 0, 0, $aigui
size[0], $aiguisize[1] - $ibuttonmargin, $_arrayconstant_lvs_showselalways)
GUICtrlSetBkColor($idlistview, $_arrayconstant_gui_bkcolor_lv_al
ternate)
GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setextendedlistv
iewstyle, $_arrayconstant_lvs_ex_gridlines, $_arrayconstant_lvs_ex_gridlines)
GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setextendedlistv
iewstyle, $_arrayconstant_lvs_ex_fullrowselect, $_arrayconstant_lvs_ex_fullrowse
lect)
GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setextendedlistv
iewstyle, $_arrayconstant_ws_ex_clientedge, $_arrayconstant_ws_ex_clientedge)
Local $idcopy_id = 9999, $idcopy_data = 99999, $iddata_label = 9
9999, $iduser_func = 99999, $idexit_script = 99999
If $ibuttonmargin Then
$idcopy_id = GUICtrlCreateButton("Copy Data && Hdr/Row",
0, $aiguisize[1] - $ibuttonmargin, $ibuttonwidth_2, 20)
$idcopy_data = GUICtrlCreateButton("Copy Data Only", $ib
uttonwidth_2, $aiguisize[1] - $ibuttonmargin, $ibuttonwidth_2, 20)
If $ibuttonmargin = 40 Then
Local $ibuttonwidth_var = $ibuttonwidth_2
Local $ioffset = $ibuttonwidth_2
If IsFunc($huser_function) Then
$iduser_func = GUICtrlCreateButton("Run
User Func", $ibuttonwidth_3, $aiguisize[1] - 20, $ibuttonwidth_3, 20)
$ibuttonwidth_var = $ibuttonwidth_3
$ioffset = $ibuttonwidth_3 * 2
EndIf
$idexit_script = GUICtrlCreateButton("Exit Scrip
t", $ioffset, $aiguisize[1] - 20, $ibuttonwidth_var, 20)
$iddata_label = GUICtrlCreateLabel($sdisplaydata
, 0, $aiguisize[1] - 20, $ibuttonwidth_var, 18, BitOR($_arrayconstant_ss_center,
$_arrayconstant_ss_centerimage))
Select
Case $btruncated OR $itranspose OR $bran
ge_flag
GUICtrlSetColor($iddata_label, 1
6711680)
GUICtrlSetTip($iddata_label, $st
ipdata)
EndSelect
EndIf
EndIf
GUICtrlSetResizing($idlistview, $_arrayconstant_gui_dockborders)
GUICtrlSetResizing($idcopy_id, $_arrayconstant_gui_dockleft + $_
arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)

GUICtrlSetResizing($idcopy_data, $_arrayconstant_gui_dockright +
$_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
GUICtrlSetResizing($iddata_label, $_arrayconstant_gui_dockleft +
$_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
GUICtrlSetResizing($iduser_func, $_arrayconstant_gui_dockhcenter
+ $_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
GUICtrlSetResizing($idexit_script, $_arrayconstant_gui_dockright
+ $_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
GUICtrlSendMsg($idlistview, $_arrayconstant_wm_setredraw, 0, 0)
Local $iditem
For $i = 0 To UBound($avarraytext) - 1
$iditem = GUICtrlCreateListViewItem($avarraytext[$i], $i
dlistview)
If $ialt_color Then
GUICtrlSetBkColor($iditem, $ialt_color)
EndIf
Next
If $icolalign Then
Local Const $_arrayconstant_lvcf_fmt = 1
Local Const $_arrayconstant_lvm_setcolumnw = (4096 + 96)
Local $tcolumn = DllStructCreate("uint Mask;int Fmt;int
CX;ptr Text;int TextMax;int SubItem;int Image;int Order;int cxMin;int cxDefault;
int cxIdeal")
DllStructSetData($tcolumn, "Mask", $_arrayconstant_lvcf_
fmt)
DllStructSetData($tcolumn, "Fmt", $icolalign / 2)
Local $pcolumn = DllStructGetPtr($tcolumn)
For $i = 1 To $isubitem_end - $isubitem_start + 1
GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_
setcolumnw, $i, $pcolumn)
Next
EndIf
GUICtrlSendMsg($idlistview, $_arrayconstant_wm_setredraw, 1, 0)
Local $iborder = 45
If UBound($avarraytext) > 20 Then
$iborder += 20
EndIf
Local $iwidth = $iborder, $icolwidth = 0, $aicolwidth[$isubitem_
end - $isubitem_start + 2], $imin_colwidth = 55
For $i = 0 To $isubitem_end - $isubitem_start + 1
GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setcolum
nwidth, $i, $_arrayconstant_lvscw_autosize)
$icolwidth = GUICtrlSendMsg($idlistview, $_arrayconstant
_lvm_getcolumnwidth, $i, 0)
If $icolwidth < $imin_colwidth Then
GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_
setcolumnwidth, $i, $imin_colwidth)
$icolwidth = $imin_colwidth
EndIf
$iwidth += $icolwidth
$aicolwidth[$i] = $icolwidth
Next
If $inorow Then $iwidth -= 55
If $iwidth > @DesktopWidth - 100 Then
$iwidth = $iborder
For $i = 0 To $isubitem_end - $isubitem_start + 1
If $aicolwidth[$i] > $imax_colwidth Then
GUICtrlSendMsg($idlistview, $_arrayconst
ant_lvm_setcolumnwidth, $i, $imax_colwidth)
$iwidth += $imax_colwidth

Else
EndIf

$iwidth += $aicolwidth[$i]

Next
EndIf
If $iwidth > @DesktopWidth - 100 Then
$iwidth = @DesktopWidth - 100
ElseIf $iwidth < $iminsize Then
$iwidth = $iminsize
EndIf
Local $trect = DllStructCreate("struct; long Left;long Top;long
Right;long Bottom; endstruct")
DllCall("user32.dll", "struct*", "SendMessageW", "hwnd", GUICtrl
GetHandle($idlistview), "uint", $_arrayconstant_lvm_getitemrect, "wparam", 0, "s
truct*", $trect)
Local $aiwin_pos = WinGetPos($hgui)
Local $ailv_pos = ControlGetPos($hgui, "", $idlistview)
$iheight = ((UBound($avarraytext) + 2) * (DllStructGetData($trec
t, "Bottom") - DllStructGetData($trect, "Top"))) + $aiwin_pos[3] - $ailv_pos[3]
If $iheight > @DesktopHeight - 100 Then
$iheight = @DesktopHeight - 100
ElseIf $iheight < $iminsize Then
$iheight = $iminsize
EndIf
If $iverbose Then SplashOff()
GUISetState(@SW_HIDE, $hgui)
WinMove($hgui, "", (@DesktopWidth - $iwidth) / 2, (@DesktopHeigh
t - $iheight) / 2, $iwidth, $iheight)
GUISetState(@SW_SHOW, $hgui)
Local $ioneventmode = Opt("GUIOnEventMode", 0), $imsg
While 1
$imsg = GUIGetMsg()
Switch $imsg
Case $_arrayconstant_gui_event_close
ExitLoop
Case $idcopy_id, $idcopy_data
Local $isel_count = GUICtrlSendMsg($idli
stview, $_arrayconstant_lvm_getselectedcount, 0, 0)
If $iverbose AND (NOT $isel_count) AND (
$iitem_end - $iitem_start) * ($isubitem_end - $isubitem_start) > 10000 Then
SplashTextOn("ArrayDisplay", "Co
pying data" & @CRLF & @CRLF & "Please be patient", 300, 100)
EndIf
Local $sclip = "", $sitem, $asplit
For $i = 0 To $iitem_end - $iitem_start
If $isel_count AND NOT (GUICtrlS
endMsg($idlistview, $_arrayconstant_lvm_getitemstate, $i, $_arrayconstant_lvis_s
elected)) Then
ContinueLoop
EndIf
$sitem = $avarraytext[$i]
If $imsg = $idcopy_data Then
$sitem = StringRegExpRep
lace($sitem, "^\[\d+\].(.*)$", "$1")
EndIf
If $icw_colwidth Then
$asplit = StringSplit($s
item, $sad_separator)
$sitem = ""
For $j = 1 To $asplit[0]

$sitem &= String


Format("%-" & $icw_colwidth + 1 & "s", StringLeft($asplit[$j], $icw_colwidth))
Next
Else
$sitem = StringReplace($
sitem, $sad_separator, $vuser_separator)
EndIf
$sclip &= $sitem & @CRLF
Next
If $imsg = $idcopy_id Then
If $icw_colwidth Then
$asplit = StringSplit($s
header, $sad_separator)
$sitem = ""
For $j = 1 To $asplit[0]
$sitem &= String
Format("%-" & $icw_colwidth + 1 & "s", StringLeft($asplit[$j], $icw_colwidth))
Next
Else
$sitem = StringReplace($
sheader, $sad_separator, $vuser_separator)
EndIf
$sclip = $sitem & @CRLF & $sclip
EndIf
ClipPut($sclip)
SplashOff()
GUICtrlSetState($idlistview, $_arraycons
tant_gui_focus)
Case $iduser_func
Local $aiselitems[$irowlimit] = [0]
For $i = 0 To GUICtrlSendMsg($idlistview
, $_arrayconstant_lvm_getitemcount, 0, 0)
If GUICtrlSendMsg($idlistview, $
_arrayconstant_lvm_getitemstate, $i, $_arrayconstant_lvis_selected) Then
$aiselitems[0] += 1
$aiselitems[$aiselitems[
0]] = $i + $iitem_start
EndIf
Next
ReDim $aiselitems[$aiselitems[0] + 1]
$huser_function($aarray, $aiselitems)
GUICtrlSetState($idlistview, $_arraycons
tant_gui_focus)
Case $idexit_script
GUIDelete($hgui)
Exit
EndSwitch
WEnd
GUIDelete($hgui)
Opt("GUICoordMode", $icoordmode)
Opt("GUIOnEventMode", $ioneventmode)
Opt("GUIDataSeparatorChar", $scurr_separator)
Return 1
EndFunc
Func _arrayextract(Const ByRef $aarray, $istart_row = -1, $iend_row = -1
, $istart_col = -1, $iend_col = -1)
If $istart_row = Default Then $istart_row = -1
If $iend_row = Default Then $iend_row = -1
If $istart_col = Default Then $istart_col = -1

-1)
rror(3, 0, -1)

w]

If $iend_col = Default Then $iend_col = -1


If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
Local $idim_1 = UBound($aarray, $ubound_rows) - 1
If $iend_row = -1 Then $iend_row = $idim_1
If $istart_row = -1 Then $istart_row = 0
If $istart_row < -1 OR $iend_row < -1 Then Return SetError(3, 0,
If $istart_row > $idim_1 OR $iend_row > $idim_1 Then Return SetE
If $istart_row > $iend_row Then Return SetError(4, 0, -1)
Switch UBound($aarray, $ubound_dimensions)
Case 1
Local $aretarray[$iend_row - $istart_row + 1]
For $i = 0 To $iend_row - $istart_row
$aretarray[$i] = $aarray[$i + $istart_ro

Case 2
- 1

n SetError(5, 0, -1)
Then Return SetError(5, 0, -1)
6, 0, -1)
+ 1]

Next
Return $aretarray
Local $idim_2 = UBound($aarray, $ubound_columns)
If $iend_col = -1 Then $iend_col = $idim_2
If $istart_col = -1 Then $istart_col = 0
If $istart_col < -1 OR $iend_col < -1 Then Retur
If $istart_col > $idim_2 OR $iend_col > $idim_2
If $istart_col > $iend_col Then Return SetError(
If $istart_col = $iend_col Then
Local $aretarray[$iend_row - $istart_row
Else

Local $aretarray[$iend_row - $istart_row


+ 1][$iend_col - $istart_col + 1]
EndIf
For $i = 0 To $iend_row - $istart_row
For $j = 0 To $iend_col - $istart_col
If $istart_col = $iend_col Then
$aretarray[$i] = $aarray
[$i + $istart_row][$j + $istart_col]
Else
$aretarray[$i][$j] = $aa
rray[$i + $istart_row][$j + $istart_col]
EndIf
Next
Next
Return $aretarray
Case Else
Return SetError(2, 0, -1)
EndSwitch
Return 1
EndFunc
Func _arrayfindall(Const ByRef $aarray, $vvalue, $istart = 0, $iend = 0,
$icase = 0, $icompare = 0, $isubitem = 0, $brow = False)
If $istart = Default Then $istart = 0
If $iend = Default Then $iend = 0
If $icase = Default Then $icase = 0
If $icompare = Default Then $icompare = 0

If $isubitem = Default Then $isubitem = 0


If $brow = Default Then $brow = False
$istart = _arraysearch($aarray, $vvalue, $istart, $iend, $icase,
$icompare, 1, $isubitem, $brow)
If @error Then Return SetError(@error, 0, -1)
Local $iindex = 0, $avresult[UBound($aarray, ($brow ? $ubound_co
lumns : $ubound_rows))]
Do
$avresult[$iindex] = $istart
$iindex += 1
$istart = _arraysearch($aarray, $vvalue, $istart + 1, $i
end, $icase, $icompare, 1, $isubitem, $brow)
Until @error
ReDim $avresult[$iindex]
Return $avresult
EndFunc
Func _arrayinsert(ByRef $aarray, $vrange, $vvalue = "", $istart = 0, $sd
elim_item = "|", $sdelim_row = @CRLF, $iforce = $arrayfill_force_default)
If $vvalue = Default Then $vvalue = ""
If $istart = Default Then $istart = 0
If $sdelim_item = Default Then $sdelim_item = "|"
If $sdelim_row = Default Then $sdelim_row = @CRLF
If $iforce = Default Then $iforce = $arrayfill_force_default
If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
Local $idim_1 = UBound($aarray, $ubound_rows) - 1
Local $hdatatype = 0
Switch $iforce
Case $arrayfill_force_int
$hdatatype = Int
Case $arrayfill_force_number
$hdatatype = Number
Case $arrayfill_force_ptr
$hdatatype = Ptr
Case $arrayfill_force_hwnd
$hdatatype = HWnd
Case $arrayfill_force_string
$hdatatype = String
EndSwitch
Local $asplit_1, $asplit_2
If IsArray($vrange) Then
If UBound($vrange, $ubound_dimensions) <> 1 OR UBound($v
range, $ubound_rows) < 2 Then Return SetError(4, 0, -1)
Else
Local $inumber
$vrange = StringStripWS($vrange, 8)
$asplit_1 = StringSplit($vrange, ";")
$vrange = ""
For $i = 1 To $asplit_1[0]
If NOT StringRegExp($asplit_1[$i], "^\d+(-\d+)?$
") Then Return SetError(3, 0, -1)
$asplit_2 = StringSplit($asplit_1[$i], "-")
Switch $asplit_2[0]
Case 1
$vrange &= $asplit_2[1] & ";"
Case 2
If Number($asplit_2[2]) >= Numbe
r($asplit_2[1]) Then
$inumber = $asplit_2[1]
- 1

Do
ber & ";"

$inumber += 1
$vrange &= $inum

Until $inumber = $asplit

_2[2]
EndSwitch

EndIf

Next
$vrange = StringSplit(StringTrimRight($vrange, 1), ";")

EndIf
If $vrange[1] < 0 OR $vrange[$vrange[0]] > $idim_1 Then Return S
etError(5, 0, -1)
For $i = 2 To $vrange[0]
If $vrange[$i] < $vrange[$i - 1] Then Return SetError(3,
0, -1)
Next
Local $icopyto_index = $idim_1 + $vrange[0]
Local $iinsertpoint_index = $vrange[0]
Local $iinsert_index = $vrange[$iinsertpoint_index]
Switch UBound($aarray, $ubound_dimensions)
Case 1
If $iforce = $arrayfill_force_singleitem Then
ReDim $aarray[$idim_1 + $vrange[0] + 1]
For $ireadfromindex = $idim_1 To 0 Step
-1
$aarray[$icopyto_index] = $aarra
y[$ireadfromindex]
$icopyto_index -= 1
$iinsert_index = $vrange[$iinser
tpoint_index]
While $ireadfromindex = $iinsert
_index
$aarray[$icopyto_index]
= $vvalue
$icopyto_index -= 1
$iinsertpoint_index -= 1
If $iinsertpoint_index <
1 Then ExitLoop 2
$iinsert_index = $vrange
[$iinsertpoint_index]
WEnd
Next
Return $idim_1 + $vrange[0] + 1
EndIf
ReDim $aarray[$idim_1 + $vrange[0] + 1]
If IsArray($vvalue) Then
If UBound($vvalue, $ubound_dimensions) <
> 1 Then Return SetError(5, 0, -1)
$hdatatype = 0
Else
Local $atmp = StringSplit($vvalue, $sdel
im_item, $str_nocount + $str_entiresplit)
If UBound($atmp, $ubound_rows) = 1 Then
$atmp[0] = $vvalue
$hdatatype = 0
EndIf
$vvalue = $atmp
EndIf
For $ireadfromindex = $idim_1 To 0 Step -1

$aarray[$icopyto_index] = $aarray[$iread

fromindex]

$icopyto_index -= 1
$iinsert_index = $vrange[$iinsertpoint_i

ndex]

While $ireadfromindex = $iinsert_index


If $iinsertpoint_index <= UBound

($vvalue, $ubound_rows) Then

If IsFunc($hdatatype) Th

en
_index] = $hdatatype($vvalue[$iinsertpoint_index - 1])
_index] = $vvalue[$iinsertpoint_index - 1]
Else
= ""

Else

$aarray[$icopyto

EndIf
$aarray[$icopyto_index]

EndIf
$icopyto_index -= 1
$iinsertpoint_index -= 1
If $iinsertpoint_index = 0 Then

ExitLoop 2

$iinsert_index = $vrange[$iinser

tpoint_index]
Case 2
urn SetError(6, 0, -1)

$aarray[$icopyto

Next

WEnd

Local $idim_2 = UBound($aarray, $ubound_columns)


If $istart < 0 OR $istart > $idim_2 - 1 Then Ret

Local $ivaldim_1, $ivaldim_2


If IsArray($vvalue) Then
If UBound($vvalue, $ubound_dimensions) <
> 2 Then Return SetError(7, 0, -1)
$ivaldim_1 = UBound($vvalue, $ubound_row
s)
$ivaldim_2 = UBound($vvalue, $ubound_col
umns)
$hdatatype = 0
Else
$asplit_1 = StringSplit($vvalue, $sdelim
_row, $str_nocount + $str_entiresplit)
$ivaldim_1 = UBound($asplit_1, $ubound_r
ows)
StringReplace($asplit_1[0], $sdelim_item
, "")
$ivaldim_2 = @extended + 1
Local $atmp[$ivaldim_1][$ivaldim_2]
For $i = 0 To $ivaldim_1 - 1
$asplit_2 = StringSplit($asplit_
1[$i], $sdelim_item, $str_nocount + $str_entiresplit)
For $j = 0 To $ivaldim_2 - 1
$atmp[$i][$j] = $asplit_
2[$j]
Next
Next
$vvalue = $atmp
EndIf

If UBound($vvalue, $ubound_columns) + $istart >


UBound($aarray, $ubound_columns) Then Return SetError(8, 0, -1)
ReDim $aarray[$idim_1 + $vrange[0] + 1][$idim_2]
For $ireadfromindex = $idim_1 To 0 Step -1
For $j = 0 To $idim_2 - 1
$aarray[$icopyto_index][$j] = $a
array[$ireadfromindex][$j]
Next
$icopyto_index -= 1
$iinsert_index = $vrange[$iinsertpoint_i
ndex]
While $ireadfromindex = $iinsert_index
For $j = 0 To $idim_2 - 1
If $j < $istart Then
$aarray[$icopyto
_index][$j] = ""
ElseIf $j - $istart > $i
valdim_2 - 1 Then
$aarray[$icopyto
_index][$j] = ""
Else
If $iinsertpoint
_index - 1 < $ivaldim_1 Then
If IsFun
c($hdatatype) Then
$aarray[$icopyto_index][$j] = $hdatatype($vvalue[$iinsertpoint_index - 1][$j - $
istart])
Else
$aarray[$icopyto_index][$j] = $vvalue[$iinsertpoint_index - 1][$j - $istart]
EndIf
Else
$aarray[
$icopyto_index][$j] = ""
EndIf
EndIf
Next
$icopyto_index -= 1
$iinsertpoint_index -= 1
If $iinsertpoint_index = 0 Then
ExitLoop 2
$iinsert_index = $vrange[$iinser
tpoint_index]
WEnd
Next
Case Else
Return SetError(2, 0, -1)
EndSwitch
Return UBound($aarray, $ubound_rows)
EndFunc
Func _arraymax(Const ByRef $aarray, $icompnumeric = 0, $istart = -1, $ie
nd = -1, $isubitem = 0)
Local $iresult = _arraymaxindex($aarray, $icompnumeric, $istart,
$iend, $isubitem)
If @error Then Return SetError(@error, 0, "")
If UBound($aarray, $ubound_dimensions) = 1 Then
Return $aarray[$iresult]
Else

EndFunc

EndIf

Return $aarray[$iresult][$isubitem]

Func _arraymaxindex(Const ByRef $aarray, $icompnumeric = 0, $istart = -1


, $iend = -1, $isubitem = 0)
If $icompnumeric = Default Then $icompnumeric = 0
If $istart = Default Then $istart = -1
If $iend = Default Then $iend = -1
If $isubitem = Default Then $isubitem = 0
Local $iret = __array_minmaxindex($aarray, $icompnumeric, $istar
t, $iend, $isubitem, __array_greaterthan)
Return SetError(@error, 0, $iret)
EndFunc
Func _arraymin(Const ByRef $aarray, $icompnumeric = 0, $istart = -1, $ie
nd = -1, $isubitem = 0)
Local $iresult = _arrayminindex($aarray, $icompnumeric, $istart,
$iend, $isubitem)
If @error Then Return SetError(@error, 0, "")
If UBound($aarray, $ubound_dimensions) = 1 Then
Return $aarray[$iresult]
Else
Return $aarray[$iresult][$isubitem]
EndIf
EndFunc
Func _arrayminindex(Const ByRef $aarray, $icompnumeric = 0, $istart = -1
, $iend = -1, $isubitem = 0)
If $icompnumeric = Default Then $icompnumeric = 0
If $istart = Default Then $istart = -1
If $iend = Default Then $iend = -1
If $isubitem = Default Then $isubitem = 0
Local $iret = __array_minmaxindex($aarray, $icompnumeric, $istar
t, $iend, $isubitem, __array_lessthan)
Return SetError(@error, 0, $iret)
EndFunc
Func _arraypermute(ByRef $aarray, $sdelimiter = "")
If $sdelimiter = Default Then $sdelimiter = ""
If NOT IsArray($aarray) Then Return SetError(1, 0, 0)
If UBound($aarray, $ubound_dimensions) <> 1 Then Return SetError
(2, 0, 0)
Local $isize = UBound($aarray), $ifactorial = 1, $aidx[$isize],
$aresult[1], $icount = 1
If UBound($aarray) Then
For $i = 0 To $isize - 1
$aidx[$i] = $i
Next
For $i = $isize To 1 Step -1
$ifactorial *= $i
Next
ReDim $aresult[$ifactorial + 1]
$aresult[0] = $ifactorial
__array_exeterinternal($aarray, 0, $isize, $sdelimiter,
$aidx, $aresult, $icount)
Else
$aresult[0] = 0
EndIf
Return $aresult

EndFunc
Func _arraypop(ByRef $aarray)
If (NOT IsArray($aarray)) Then Return SetError(1, 0, "")
If UBound($aarray, $ubound_dimensions) <> 1 Then Return SetError
(2, 0, "")
Local $iubound = UBound($aarray) - 1
If $iubound = -1 Then Return SetError(3, 0, "")
Local $slastval = $aarray[$iubound]
If $iubound > -1 Then
ReDim $aarray[$iubound]
EndIf
Return $slastval
EndFunc
Func _arraypush(ByRef $aarray, $vvalue, $idirection = 0)
If $idirection = Default Then $idirection = 0
If (NOT IsArray($aarray)) Then Return SetError(1, 0, 0)
If UBound($aarray, $ubound_dimensions) <> 1 Then Return SetError
(3, 0, 0)
Local $iubound = UBound($aarray) - 1
If IsArray($vvalue) Then
Local $iubounds = UBound($vvalue)
If ($iubounds - 1) > $iubound Then Return SetError(2, 0,
0)
If $idirection Then
For $i = $iubound To $iubounds Step -1
$aarray[$i] = $aarray[$i - $iubounds]
Next
For $i = 0 To $iubounds - 1
$aarray[$i] = $vvalue[$i]
Next
Else
For $i = 0 To $iubound - $iubounds
$aarray[$i] = $aarray[$i + $iubounds]
Next
For $i = 0 To $iubounds - 1
$aarray[$i + $iubound - $iubounds + 1] =
$vvalue[$i]
Next
EndIf
Else
If $iubound > -1 Then
If $idirection Then
For $i = $iubound To 1 Step -1
$aarray[$i] = $aarray[$i - 1]
Next
$aarray[0] = $vvalue
Else
For $i = 0 To $iubound - 1
$aarray[$i] = $aarray[$i + 1]
Next
$aarray[$iubound] = $vvalue
EndIf
EndIf
EndIf
Return 1
EndFunc
Func _arrayreverse(ByRef $aarray, $istart = 0, $iend = 0)

(3, 0, 0)

EndFunc

If
If
If
If

$istart = Default Then $istart = 0


$iend = Default Then $iend = 0
NOT IsArray($aarray) Then Return SetError(1, 0, 0)
UBound($aarray, $ubound_dimensions) <> 1 Then Return SetError

If NOT UBound($aarray) Then Return SetError(4, 0, 0)


Local $vtmp, $iubound = UBound($aarray) - 1
If $iend < 1 OR $iend > $iubound Then $iend = $iubound
If $istart < 0 Then $istart = 0
If $istart > $iend Then Return SetError(2, 0, 0)
For $i = $istart To Int(($istart + $iend - 1) / 2)
$vtmp = $aarray[$i]
$aarray[$i] = $aarray[$iend]
$aarray[$iend] = $vtmp
$iend -= 1
Next
Return 1

Func _arraysearch(Const ByRef $aarray, $vvalue, $istart = 0, $iend = 0,


$icase = 0, $icompare = 0, $iforward = 1, $isubitem = -1, $brow = False)
If $istart = Default Then $istart = 0
If $iend = Default Then $iend = 0
If $icase = Default Then $icase = 0
If $icompare = Default Then $icompare = 0
If $iforward = Default Then $iforward = 1
If $isubitem = Default Then $isubitem = -1
If $brow = Default Then $brow = False
If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
Local $idim_1 = UBound($aarray) - 1
If $idim_1 = -1 Then Return SetError(3, 0, -1)
Local $idim_2 = UBound($aarray, $ubound_columns) - 1
Local $bcomptype = False
If $icompare = 2 Then
$icompare = 0
$bcomptype = True
EndIf
If $brow Then
If UBound($aarray, $ubound_dimensions) = 1 Then Return S
etError(5, 0, -1)
If $iend < 1 OR $iend > $idim_2 Then $iend = $idim_2
If $istart < 0 Then $istart = 0
If $istart > $iend Then Return SetError(4, 0, -1)
Else
If $iend < 1 OR $iend > $idim_1 Then $iend = $idim_1
If $istart < 0 Then $istart = 0
If $istart > $iend Then Return SetError(4, 0, -1)
EndIf
Local $istep = 1
If NOT $iforward Then
Local $itmp = $istart
$istart = $iend
$iend = $itmp
$istep = -1
EndIf
Switch UBound($aarray, $ubound_dimensions)
Case 1
If NOT $icompare Then
If NOT $icase Then
For $i = $istart To $iend Step $

istep

If $bcomptype AND VarGet


Type($aarray[$i]) <> VarGetType($vvalue) Then ContinueLoop
If $aarray[$i] = $vvalue
Then Return $i
Next
Else
For $i = $istart To $iend Step $
istep
If $bcomptype AND VarGet
Type($aarray[$i]) <> VarGetType($vvalue) Then ContinueLoop
If $aarray[$i] == $vvalu
e Then Return $i
Next
EndIf
Else
For $i = $istart To $iend Step $istep
If $icompare = 3 Then
If StringRegExp($aarray[
$i], $vvalue) Then Return $i
Else
If StringInStr($aarray[$
i], $vvalue, $icase) > 0 Then Return $i
EndIf
Next
EndIf
Case 2
Local $idim_sub
If $brow Then
$idim_sub = $idim_1
If $isubitem > $idim_sub Then $isubitem
= $idim_sub
If $isubitem < 0 Then
$isubitem = 0
Else
$idim_sub = $isubitem
EndIf
Else
$idim_sub = $idim_2
If $isubitem > $idim_sub Then $isubitem
= $idim_sub
If $isubitem < 0 Then
$isubitem = 0
Else
$idim_sub = $isubitem
EndIf
EndIf
For $j = $isubitem To $idim_sub
If NOT $icompare Then
If NOT $icase Then
For $i = $istart To $ien
d Step $istep
If $brow Then
If $bcom
ptype AND VarGetType($aarray[$j][$j]) <> VarGetType($vvalue) Then ContinueLoop
If $aarr
ay[$j][$i] = $vvalue Then Return $i
Else
If $bcom
ptype AND VarGetType($aarray[$i][$j]) <> VarGetType($vvalue) Then ContinueLoop

If $aarr

ay[$i][$j] = $vvalue Then Return $i


Else
d Step $istep

Next

EndIf

For $i = $istart To $ien

If $brow Then
If $bcom
ptype AND VarGetType($aarray[$j][$i]) <> VarGetType($vvalue) Then ContinueLoop
If $aarr
ay[$j][$i] == $vvalue Then Return $i
Else
If $bcom
ptype AND VarGetType($aarray[$i][$j]) <> VarGetType($vvalue) Then ContinueLoop
If $aarr
ay[$i][$j] == $vvalue Then Return $i
EndIf
Next
EndIf
Else
For $i = $istart To $iend Step $
istep
If $icompare = 3 Then
If $brow Then
If Strin
gRegExp($aarray[$j][$i], $vvalue) Then Return $i
Else
If Strin
gRegExp($aarray[$i][$j], $vvalue) Then Return $i
EndIf
Else
If $brow Then
If Strin
gInStr($aarray[$j][$i], $vvalue, $icase) > 0 Then Return $i
Else
If Strin
gInStr($aarray[$i][$j], $vvalue, $icase) > 0 Then Return $i
EndIf
EndIf
Next
EndIf
Next
Case Else
Return SetError(2, 0, -1)
EndSwitch
Return SetError(6, 0, -1)
EndFunc
= -1)

Func _arrayshuffle(ByRef $aarray, $istart_row = 0, $iend_row = 0, $icol

rror(3, 0, -1)

If $istart_row = Default Then $istart_row = 0


If $iend_row = Default Then $iend_row = 0
If $icol = Default Then $icol = -1
If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
Local $idim_1 = UBound($aarray, $ubound_rows)
If $iend_row = 0 Then $iend_row = $idim_1 - 1
If $istart_row < 0 OR $istart_row > $idim_1 - 1 Then Return SetE
If $iend_row < 1 OR $iend_row > $idim_1 - 1 Then Return SetError

(3, 0, -1)

If $istart_row > $iend_row Then Return SetError(4, 0, -1)


Local $vtmp, $irand
Switch UBound($aarray, $ubound_dimensions)
Case 1
For $i = $iend_row To $istart_row + 1 Step -1
$irand = Random($istart_row, $i, 1)
$vtmp = $aarray[$i]
$aarray[$i] = $aarray[$irand]
$aarray[$irand] = $vtmp
Next
Return 1
Case 2
Local $idim_2 = UBound($aarray, $ubound_columns)
If $icol < -1 OR $icol > $idim_2 - 1 Then Return
SetError(5, 0, -1)
Local $icol_start, $icol_end
If $icol = -1 Then
$icol_start = 0
$icol_end = $idim_2 - 1
Else
$icol_start = $icol
$icol_end = $icol
EndIf
For $i = $iend_row To $istart_row + 1 Step -1
$irand = Random($istart_row, $i, 1)
For $j = $icol_start To $icol_end
$vtmp = $aarray[$i][$j]
$aarray[$i][$j] = $aarray[$irand
][$j]
$aarray[$irand][$j] = $vtmp
Next
Next
Return 1
Case Else
Return SetError(2, 0, -1)
EndSwitch
EndFunc
Func _arraysort(ByRef $aarray, $idescending = 0, $istart = 0, $iend = 0,
$isubitem = 0, $ipivot = 0)
If $idescending = Default Then $idescending = 0
If $istart = Default Then $istart = 0
If $iend = Default Then $iend = 0
If $isubitem = Default Then $isubitem = 0
If $ipivot = Default Then $ipivot = 0
If NOT IsArray($aarray) Then Return SetError(1, 0, 0)
Local $iubound = UBound($aarray) - 1
If $iubound = -1 Then Return SetError(5, 0, 0)
If $iend = Default Then $iend = 0
If $iend < 1 OR $iend > $iubound OR $iend = Default Then $iend =
$iubound
If $istart < 0 OR $istart = Default Then $istart = 0
If $istart > $iend Then Return SetError(2, 0, 0)
If $idescending = Default Then $idescending = 0
If $ipivot = Default Then $ipivot = 0
If $isubitem = Default Then $isubitem = 0
Switch UBound($aarray, $ubound_dimensions)
Case 1
If $ipivot Then

__arraydualpivotsort($aarray, $istart, $

iend)

Else

nd)
art, $iend)

) - 1
0, 0)

__arrayquicksort1d($aarray, $istart, $ie

EndIf
If $idescending Then _arrayreverse($aarray, $ist
Case 2

If $ipivot Then Return SetError(6, 0, 0)


Local $isubmax = UBound($aarray, $ubound_columns
If $isubitem > $isubmax Then Return SetError(3,
If $idescending Then
$idescending = -1
Else
$idescending = 1
EndIf
__arrayquicksort2d($aarray, $idescending, $istar

t, $iend, $isubitem, $isubmax)


Case Else
Return SetError(4, 0, 0)
EndSwitch
Return 1
EndFunc
$iend)

Func __arrayquicksort1d(ByRef $aarray, Const ByRef $istart, Const ByRef

If $iend <= $istart Then Return


Local $vtmp
If ($iend - $istart) < 15 Then
Local $vcur
For $i = $istart + 1 To $iend
$vtmp = $aarray[$i]
If IsNumber($vtmp) Then
For $j = $i - 1 To $istart Step -1
$vcur = $aarray[$j]
If ($vtmp >= $vcur AND IsNumber(
$vcur)) OR (NOT IsNumber($vcur) AND StringCompare($vtmp, $vcur) >= 0) Then ExitL
oop
$aarray[$j + 1] = $vcur
Next
Else
For $j = $i - 1 To $istart Step -1
If (StringCompare($vtmp, $aarray
[$j]) >= 0) Then ExitLoop
$aarray[$j + 1] = $aarray[$j]
Next
EndIf
$aarray[$j + 1] = $vtmp
Next
Return
EndIf
Local $l = $istart, $r = $iend, $vpivot = $aarray[Int(($istart +
$iend) / 2)], $bnum = IsNumber($vpivot)
Do
If $bnum Then
While ($aarray[$l] < $vpivot AND IsNumber($aarra
y[$l])) OR (NOT IsNumber($aarray[$l]) AND StringCompare($aarray[$l], $vpivot) <

0)

$l += 1
WEnd
While ($aarray[$r] > $vpivot AND IsNumber($aarra
y[$r])) OR (NOT IsNumber($aarray[$r]) AND StringCompare($aarray[$r], $vpivot) >
0)
$r -= 1
WEnd
Else
While (StringCompare($aarray[$l], $vpivot) < 0)
$l += 1
WEnd
While (StringCompare($aarray[$r], $vpivot) > 0)
$r -= 1
WEnd
EndIf
If $l <= $r Then
$vtmp = $aarray[$l]
$aarray[$l] = $aarray[$r]
$aarray[$r] = $vtmp
$l += 1
$r -= 1
EndIf
Until $l > $r
__arrayquicksort1d($aarray, $istart, $r)
__arrayquicksort1d($aarray, $l, $iend)
EndFunc
Func __arrayquicksort2d(ByRef $aarray, Const ByRef $istep, Const ByRef $
istart, Const ByRef $iend, Const ByRef $isubitem, Const ByRef $isubmax)
If $iend <= $istart Then Return
Local $vtmp, $l = $istart, $r = $iend, $vpivot = $aarray[Int(($i
start + $iend) / 2)][$isubitem], $bnum = IsNumber($vpivot)
Do
If $bnum Then
While ($istep * ($aarray[$l][$isubitem] - $vpivo
t) < 0 AND IsNumber($aarray[$l][$isubitem])) OR (NOT IsNumber($aarray[$l][$isubi
tem]) AND $istep * StringCompare($aarray[$l][$isubitem], $vpivot) < 0)
$l += 1
WEnd
While ($istep * ($aarray[$r][$isubitem] - $vpivo
t) > 0 AND IsNumber($aarray[$r][$isubitem])) OR (NOT IsNumber($aarray[$r][$isubi
tem]) AND $istep * StringCompare($aarray[$r][$isubitem], $vpivot) > 0)
$r -= 1
WEnd
Else
While ($istep * StringCompare($aarray[$l][$isubi
tem], $vpivot) < 0)
$l += 1
WEnd
While ($istep * StringCompare($aarray[$r][$isubi
tem], $vpivot) > 0)
$r -= 1
WEnd
EndIf
If $l <= $r Then
For $i = 0 To $isubmax
$vtmp = $aarray[$l][$i]
$aarray[$l][$i] = $aarray[$r][$i]
$aarray[$r][$i] = $vtmp

Next
$l += 1
$r -= 1

EndIf
Until $l > $r
__arrayquicksort2d($aarray, $istep, $istart, $r, $isubitem, $isu

bmax)
ax)

__arrayquicksort2d($aarray, $istep, $l, $iend, $isubitem, $isubm


EndFunc

Func __arraydualpivotsort(ByRef $aarray, $ipivot_left, $ipivot_right, $b


leftmost = True)
If $ipivot_left > $ipivot_right Then Return
Local $ilength = $ipivot_right - $ipivot_left + 1
Local $i, $j, $k, $iai, $iak, $ia1, $ia2, $ilast
If $ilength < 45 Then
If $bleftmost Then
$i = $ipivot_left
While $i < $ipivot_right
$j = $i
$iai = $aarray[$i + 1]
While $iai < $aarray[$j]
$aarray[$j + 1] = $aarray[$j]
$j -= 1
If $j + 1 = $ipivot_left Then Ex
itLoop
WEnd
$aarray[$j + 1] = $iai
$i += 1
WEnd
Else
While 1
If $ipivot_left >= $ipivot_right Then Re
turn 1
$ipivot_left += 1
If $aarray[$ipivot_left] < $aarray[$ipiv
ot_left - 1] Then ExitLoop
WEnd
While 1
$k = $ipivot_left
$ipivot_left += 1
If $ipivot_left > $ipivot_right Then Exi
tLoop
$ia1 = $aarray[$k]
$ia2 = $aarray[$ipivot_left]
If $ia1 < $ia2 Then
$ia2 = $ia1
$ia1 = $aarray[$ipivot_left]
EndIf
$k -= 1
While $ia1 < $aarray[$k]
$aarray[$k + 2] = $aarray[$k]
$k -= 1
WEnd
$aarray[$k + 2] = $ia1
While $ia2 < $aarray[$k]
$aarray[$k + 1] = $aarray[$k]
$k -= 1
WEnd

$aarray[$k + 1] = $ia2
$ipivot_left += 1

WEnd
$ilast = $aarray[$ipivot_right]
$ipivot_right -= 1
While $ilast < $aarray[$ipivot_right]
$aarray[$ipivot_right + 1] = $aarray[$ip

ivot_right]

EndIf
Return 1

+ 1

$ipivot_right -= 1
WEnd
$aarray[$ipivot_right + 1] = $ilast

EndIf
Local $iseventh = BitShift($ilength, 3) + BitShift($ilength, 6)
Local $ie1, $ie2, $ie3, $ie4, $ie5, $t
$ie3 = Ceiling(($ipivot_left + $ipivot_right) / 2)
$ie2 = $ie3 - $iseventh
$ie1 = $ie2 - $iseventh
$ie4 = $ie3 + $iseventh
$ie5 = $ie4 + $iseventh
If $aarray[$ie2] < $aarray[$ie1] Then
$t = $aarray[$ie2]
$aarray[$ie2] = $aarray[$ie1]
$aarray[$ie1] = $t
EndIf
If $aarray[$ie3] < $aarray[$ie2] Then
$t = $aarray[$ie3]
$aarray[$ie3] = $aarray[$ie2]
$aarray[$ie2] = $t
If $t < $aarray[$ie1] Then
$aarray[$ie2] = $aarray[$ie1]
$aarray[$ie1] = $t
EndIf
EndIf
If $aarray[$ie4] < $aarray[$ie3] Then
$t = $aarray[$ie4]
$aarray[$ie4] = $aarray[$ie3]
$aarray[$ie3] = $t
If $t < $aarray[$ie2] Then
$aarray[$ie3] = $aarray[$ie2]
$aarray[$ie2] = $t
If $t < $aarray[$ie1] Then
$aarray[$ie2] = $aarray[$ie1]
$aarray[$ie1] = $t
EndIf
EndIf
EndIf
If $aarray[$ie5] < $aarray[$ie4] Then
$t = $aarray[$ie5]
$aarray[$ie5] = $aarray[$ie4]
$aarray[$ie4] = $t
If $t < $aarray[$ie3] Then
$aarray[$ie4] = $aarray[$ie3]
$aarray[$ie3] = $t
If $t < $aarray[$ie2] Then
$aarray[$ie3] = $aarray[$ie2]
$aarray[$ie2] = $t
If $t < $aarray[$ie1] Then

EndIf

EndIf

$aarray[$ie2] = $aarray[$ie1]
$aarray[$ie1] = $t

EndIf
EndIf
Local $iless = $ipivot_left
Local $igreater = $ipivot_right
If (($aarray[$ie1] <> $aarray[$ie2]) AND ($aarray[$ie2] <> $aarr
ay[$ie3]) AND ($aarray[$ie3] <> $aarray[$ie4]) AND ($aarray[$ie4] <> $aarray[$ie
5])) Then
Local $ipivot_1 = $aarray[$ie2]
Local $ipivot_2 = $aarray[$ie4]
$aarray[$ie2] = $aarray[$ipivot_left]
$aarray[$ie4] = $aarray[$ipivot_right]
Do
$iless += 1
Until $aarray[$iless] >= $ipivot_1
Do
$igreater -= 1
Until $aarray[$igreater] <= $ipivot_2
$k = $iless
While $k <= $igreater
$iak = $aarray[$k]
If $iak < $ipivot_1 Then
$aarray[$k] = $aarray[$iless]
$aarray[$iless] = $iak
$iless += 1
ElseIf $iak > $ipivot_2 Then
While $aarray[$igreater] > $ipivot_2
$igreater -= 1
If $igreater + 1 = $k Then ExitL
oop 2
WEnd
If $aarray[$igreater] < $ipivot_1 Then
$aarray[$k] = $aarray[$iless]
$aarray[$iless] = $aarray[$igrea
ter]
$iless += 1
Else
$aarray[$k] = $aarray[$igreater]
EndIf
$aarray[$igreater] = $iak
$igreater -= 1
EndIf
$k += 1
WEnd
$aarray[$ipivot_left] = $aarray[$iless - 1]
$aarray[$iless - 1] = $ipivot_1
$aarray[$ipivot_right] = $aarray[$igreater + 1]
$aarray[$igreater + 1] = $ipivot_2
__arraydualpivotsort($aarray, $ipivot_left, $iless - 2,
True)
__arraydualpivotsort($aarray, $igreater + 2, $ipivot_rig
ht, False)
If ($iless < $ie1) AND ($ie5 < $igreater) Then
While $aarray[$iless] = $ipivot_1
$iless += 1
WEnd
While $aarray[$igreater] = $ipivot_2

$igreater -= 1
WEnd
$k = $iless
While $k <= $igreater
$iak = $aarray[$k]
If $iak = $ipivot_1 Then
$aarray[$k] = $aarray[$iless]
$aarray[$iless] = $iak
$iless += 1
ElseIf $iak = $ipivot_2 Then
While $aarray[$igreater] = $ipiv

ot_2

$igreater -= 1
If $igreater + 1 = $k Th

en ExitLoop 2

WEnd
If $aarray[$igreater] = $ipivot_

1 Then

$aarray[$k] = $aarray[$i

less]

$aarray[$iless] = $ipivo

t_1
Else
greater]

EndIf
$k += 1

Else

ter]

$iless += 1
$aarray[$k] = $aarray[$i

EndIf
$aarray[$igreater] = $iak
$igreater -= 1

WEnd
EndIf
__arraydualpivotsort($aarray, $iless, $igreater, False)
Local $ipivot = $aarray[$ie3]
$k = $iless
While $k <= $igreater
If $aarray[$k] = $ipivot Then
$k += 1
ContinueLoop
EndIf
$iak = $aarray[$k]
If $iak < $ipivot Then
$aarray[$k] = $aarray[$iless]
$aarray[$iless] = $iak
$iless += 1
Else
While $aarray[$igreater] > $ipivot
$igreater -= 1
WEnd
If $aarray[$igreater] < $ipivot Then
$aarray[$k] = $aarray[$iless]
$aarray[$iless] = $aarray[$igrea
Else

$iless += 1

$aarray[$k] = $ipivot
EndIf
$aarray[$igreater] = $iak

EndIf
$k += 1

$igreater -= 1

WEnd
__arraydualpivotsort($aarray, $ipivot_left, $iless - 1,

True)
ht, False)
EndFunc

__arraydualpivotsort($aarray, $igreater + 1, $ipivot_rig


EndIf

Func _arrayswap(ByRef $aarray, $iindex_1, $iindex_2, $bcol = False, $ist


art = -1, $iend = -1)
If $bcol = Default Then $bcol = False
If $istart = Default Then $istart = -1
If $iend = Default Then $iend = -1
If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
Local $idim_1 = UBound($aarray, $ubound_rows) - 1
Local $idim_2 = UBound($aarray, $ubound_columns) - 1
If $idim_2 = -1 Then
$bcol = False
$istart = -1
$iend = -1
EndIf
If $istart > $iend Then Return SetError(5, 0, -1)
If $bcol Then
If $iindex_1 < 0 OR $iindex_2 > $idim_2 Then Return SetE
rror(3, 0, -1)
If $istart = -1 Then $istart = 0
If $iend = -1 Then $iend = $idim_1
Else
If $iindex_1 < 0 OR $iindex_2 > $idim_1 Then Return SetE
rror(3, 0, -1)
If $istart = -1 Then $istart = 0
If $iend = -1 Then $iend = $idim_2
EndIf
Local $vtmp
Switch UBound($aarray, $ubound_dimensions)
Case 1
$vtmp = $aarray[$iindex_1]
$aarray[$iindex_1] = $aarray[$iindex_2]
$aarray[$iindex_2] = $vtmp
Case 2
If $istart < -1 OR $iend < -1 Then Return SetErr
or(4, 0, -1)
If $bcol Then
If $istart > $idim_1 OR $iend > $idim_1
Then Return SetError(4, 0, -1)
For $j = $istart To $iend
$vtmp = $aarray[$j][$iindex_1]
$aarray[$j][$iindex_1] = $aarray
[$j][$iindex_2]
$aarray[$j][$iindex_2] = $vtmp
Next
Else
If $istart > $idim_2 OR $iend > $idim_2
Then Return SetError(4, 0, -1)
For $j = $istart To $iend
$vtmp = $aarray[$iindex_1][$j]
$aarray[$iindex_1][$j] = $aarray

[$iindex_2][$j]
Next

EndFunc

$aarray[$iindex_2][$j] = $vtmp

EndIf
Case Else
Return SetError(2, 0, -1)
EndSwitch
Return 1

Func _arraytoclip(Const ByRef $aarray, $sdelim_col = "|", $istart_row =


-1, $iend_row = -1, $sdelim_row = @CRLF, $istart_col = -1, $iend_col = -1)
Local $sresult = _arraytostring($aarray, $sdelim_col, $istart_ro
w, $iend_row, $sdelim_row, $istart_col, $iend_col)
If @error Then Return SetError(@error, 0, 0)
If ClipPut($sresult) Then Return 1
Return SetError(-1, 0, 0)
EndFunc
Func _arraytostring(Const ByRef $aarray, $sdelim_col = "|", $istart_row
= -1, $iend_row = -1, $sdelim_row = @CRLF, $istart_col = -1, $iend_col = -1)
If $sdelim_col = Default Then $sdelim_col = "|"
If $sdelim_row = Default Then $sdelim_row = @CRLF
If $istart_row = Default Then $istart_row = -1
If $iend_row = Default Then $iend_row = -1
If $istart_col = Default Then $istart_col = -1
If $iend_col = Default Then $iend_col = -1
If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
Local $idim_1 = UBound($aarray, $ubound_rows) - 1
If $istart_row = -1 Then $istart_row = 0
If $iend_row = -1 Then $iend_row = $idim_1
If $istart_row < -1 OR $iend_row < -1 Then Return SetError(3, 0,
-1)
If $istart_row > $idim_1 OR $iend_row > $idim_1 Then Return SetE
rror(3, 0, "")
If $istart_row > $iend_row Then Return SetError(4, 0, -1)
Local $sret = ""
Switch UBound($aarray, $ubound_dimensions)
Case 1
For $i = $istart_row To $iend_row
$sret &= $aarray[$i] & $sdelim_col
Next
Return StringTrimRight($sret, StringLen($sdelim_
col))
Case 2
Local $idim_2 = UBound($aarray, $ubound_columns)
- 1
If $istart_col = -1 Then $istart_col = 0
If $iend_col = -1 Then $iend_col = $idim_2
If $istart_col < -1 OR $iend_col < -1 Then Retur
n SetError(5, 0, -1)
If $istart_col > $idim_2 OR $iend_col > $idim_2
Then Return SetError(5, 0, -1)
If $istart_col > $iend_col Then Return SetError(
6, 0, -1)
For $i = $istart_row To $iend_row
For $j = $istart_col To $iend_col
$sret &= $aarray[$i][$j] & $sdel
im_col
Next

($sdelim_col)) & $sdelim_row


row))

EndFunc

$sret = StringTrimRight($sret, StringLen


Next
Return StringTrimRight($sret, StringLen($sdelim_

Case Else
Return SetError(2, 0, -1)
EndSwitch
Return 1

Func _arraytranspose(ByRef $aarray)


Switch UBound($aarray, 0)
Case 0
Return SetError(2, 0, 0)
Case 1
Local $atemp[1][UBound($aarray)]
For $i = 0 To UBound($aarray) - 1
$atemp[0][$i] = $aarray[$i]
Next
$aarray = $atemp
Case 2
Local $idim_1 = UBound($aarray, 1), $idim_2 = UB
ound($aarray, 2)
If $idim_1 <> $idim_2 Then
Local $atemp[$idim_2][$idim_1]
For $i = 0 To $idim_1 - 1
For $j = 0 To $idim_2 - 1
$atemp[$j][$i] = $aarray
[$i][$j]
Next
Next
$aarray = $atemp
Else
Local $velement
For $i = 0 To $idim_1 - 1
For $j = $i + 1 To $idim_2 - 1
$velement = $aarray[$i][
$j]
$aarray[$i][$j] = $aarra
y[$j][$i]
$aarray[$j][$i] = $velem
ent
Next
Next
EndIf
Case Else
Return SetError(1, 0, 0)
EndSwitch
Return 1
EndFunc
Func _arraytrim(ByRef $aarray, $itrimnum, $idirection = 0, $istart = 0,
$iend = 0, $isubitem = 0)
If $idirection = Default Then $idirection = 0
If $istart = Default Then $istart = 0
If $iend = Default Then $iend = 0
If $isubitem = Default Then $isubitem = 0
If NOT IsArray($aarray) Then Return SetError(1, 0, 0)
Local $idim_1 = UBound($aarray, $ubound_rows) - 1

0, -1)

If
If
If
If

$iend =
$istart
$istart
$istart

0
>
<
>

Then $iend
$iend Then
0 OR $iend
$idim_1 OR

= $idim_1
Return SetError(3, 0, -1)
< 0 Then Return SetError(3, 0, -1)
$iend > $idim_1 Then Return SetError(3,

If $istart > $iend Then Return SetError(4, 0, -1)


Switch UBound($aarray, $ubound_dimensions)
Case 1
If $idirection Then
For $i = $istart To $iend
$aarray[$i] = StringTrimRight($a
array[$i], $itrimnum)
Next
Else
For $i = $istart To $iend
$aarray[$i] = StringTrimLeft($aa
rray[$i], $itrimnum)
Next
EndIf
Case 2
Local $idim_2 = UBound($aarray, $ubound_columns)
- 1
If $isubitem < 0 OR $isubitem > $idim_2 Then Ret
urn SetError(5, 0, -1)
If $idirection Then
For $i = $istart To $iend
$aarray[$i][$isubitem] = StringT
rimRight($aarray[$i][$isubitem], $itrimnum)
Next
Else
For $i = $istart To $iend
$aarray[$i][$isubitem] = StringT
rimLeft($aarray[$i][$isubitem], $itrimnum)
Next
EndIf
Case Else
Return SetError(2, 0, 0)
EndSwitch
Return 1
EndFunc
Func _arrayunique(Const ByRef $aarray, $icolumn = 0, $ibase = 0, $icase
= 0, $icount = $arrayunique_count, $iinttype = $arrayunique_auto)
If $icolumn = Default Then $icolumn = 0
If $ibase = Default Then $ibase = 0
If $icase = Default Then $icase = 0
If $icount = Default Then $icount = $arrayunique_count
If UBound($aarray, $ubound_rows) = 0 Then Return SetError(1, 0,
0)
Local $idims = UBound($aarray, $ubound_dimensions), $inumcolumns
= UBound($aarray, $ubound_columns)
If $idims > 2 Then Return SetError(2, 0, 0)
If $ibase < 0 OR $ibase > 1 OR (NOT IsInt($ibase)) Then Return S
etError(3, 0, 0)
If $icase < 0 OR $icase > 1 OR (NOT IsInt($icase)) Then Return S
etError(3, 0, 0)
If $icount < 0 OR $icount > 1 OR (NOT IsInt($icount)) Then Retur
n SetError(4, 0, 0)
If $iinttype < 0 OR $iinttype > 4 OR (NOT IsInt($iinttype)) Then
Return SetError(5, 0, 0)

If $icolumn < 0 OR ($inumcolumns = 0 AND $icolumn > 0) OR ($inum


columns > 0 AND $icolumn >= $inumcolumns) Then Return SetError(6, 0, 0)
If $iinttype = $arrayunique_auto Then
If IsInt($aarray[$ibase]) Then
Switch VarGetType($aarray[$ibase])
Case "Int32"
$iinttype = $arrayunique_force32
Case "Int64"
$iinttype = $arrayunique_force64
EndSwitch
Else
$iinttype = $arrayunique_force32
EndIf
EndIf
Local $odictionary = ObjCreate("Scripting.Dictionary")
$odictionary.comparemode = Number(NOT $icase)
Local $velem, $stype, $vkey, $bcomerror = False
__arrayunique_autoerrregister()
For $i = $ibase To UBound($aarray) - 1
If $idims = 1 Then
$velem = $aarray[$i]
Else
$velem = $aarray[$i][$icolumn]
EndIf
Switch $iinttype
Case $arrayunique_force32
$odictionary.item($velem)
If @error Then
$bcomerror = True
ExitLoop
EndIf
Case $arrayunique_force64
$stype = VarGetType($velem)
If $stype = "Int32" Then
$bcomerror = True
ExitLoop
EndIf
$vkey = "#" & $stype & "#" & String($vel
em)
If NOT $odictionary.item($vkey) Then
$odictionary($vkey) = $velem
EndIf
Case $arrayunique_match
$stype = VarGetType($velem)
If StringLeft($stype, 3) = "Int" Then
$vkey = "#Int#" & String($velem)
Else
$vkey = "#" & $stype & "#" & Str
ing($velem)
EndIf
If NOT $odictionary.item($vkey) Then
$odictionary($vkey) = $velem
EndIf
Case $arrayunique_distinct
$vkey = "#" & VarGetType($velem) & "#" &
String($velem)
If NOT $odictionary.item($vkey) Then
$odictionary($vkey) = $velem
EndIf
EndSwitch

EndFunc

Next
__arrayunique_autoerrunregister()
Local $avalues, $j = 0
If $bcomerror Then
Return SetError(7, 0, 0)
ElseIf $iinttype <> $arrayunique_force32 Then
Local $avalues[$odictionary.count]
For $vkey In $odictionary.keys()
$avalues[$j] = $odictionary($vkey)
If StringLeft($vkey, 5) = "#Ptr#" Then
$avalues[$j] = Ptr($avalues[$j])
EndIf
$j += 1
Next
Else
$avalues = $odictionary.keys()
EndIf
If $icount Then
_arrayinsert($avalues, 0, $odictionary.count)
EndIf
Return $avalues

Func _array1dtohistogram($aarray, $isizing = 100)


If UBound($aarray, 0) > 1 Then Return SetError(1, 0, "")
$isizing = $isizing * 8
Local $t, $n, $imin = 0, $imax = 0, $ioffset = 0
For $i = 0 To UBound($aarray) - 1
$t = $aarray[$i]
$t = IsNumber($t) ? Round($t) : 0
If $t < $imin Then $imin = $t
If $t > $imax Then $imax = $t
Next
Local $irange = Int(Round(($imax - $imin) / 8)) * 8
Local $ispaceratio = 4
For $i = 0 To UBound($aarray) - 1
$t = $aarray[$i]
If $t Then
$n = Abs(Round(($isizing * $t) / $irange) / 8)
$aarray[$i] = ""
If $t > 0 Then
If $imin Then
$ioffset = Int(Abs(Round(($isizi
ng * $imin) / $irange) / 8) / 8 * $ispaceratio)
$aarray[$i] = __array_stringrepe
at(ChrW(32), $ioffset)
EndIf
Else
If $imin <> $t Then
$ioffset = Int(Abs(Round(($isizi
ng * ($t - $imin)) / $irange) / 8) / 8 * $ispaceratio)
$aarray[$i] = __array_stringrepe
at(ChrW(32), $ioffset)
EndIf
EndIf
$aarray[$i] &= __array_stringrepeat(ChrW(9608),
Int($n / 8))
$n = Mod($n, 8)
If $n > 0 Then $aarray[$i] &= ChrW(9608 + 8 - $n
)

Else
EndIf

EndFunc

$aarray[$i] &= " " & $t


$aarray[$i] = ""

Next
Return $aarray

Func __array_stringrepeat($sstring, $irepeatcount)


$irepeatcount = Int($irepeatcount)
If StringLen($sstring) < 1 OR $irepeatcount <= 0 Then Return Set
Error(1, 0, "")
Local $sresult = ""
While $irepeatcount > 1
If BitAND($irepeatcount, 1) Then $sresult &= $sstring
$sstring &= $sstring
$irepeatcount = BitShift($irepeatcount, 1)
WEnd
Return $sstring & $sresult
EndFunc
Func __array_exeterinternal(ByRef $aarray, $istart, $isize, $sdelimiter,
ByRef $aidx, ByRef $aresult, ByRef $icount)
If $istart == $isize - 1 Then
For $i = 0 To $isize - 1
$aresult[$icount] &= $aarray[$aidx[$i]] & $sdeli
miter
Next
If $sdelimiter <> "" Then $aresult[$icount] = StringTrim
Right($aresult[$icount], StringLen($sdelimiter))
$icount += 1
Else
Local $itemp
For $i = $istart To $isize - 1
$itemp = $aidx[$i]
$aidx[$i] = $aidx[$istart]
$aidx[$istart] = $itemp
__array_exeterinternal($aarray, $istart + 1, $is
ize, $sdelimiter, $aidx, $aresult, $icount)
$aidx[$istart] = $aidx[$i]
$aidx[$i] = $itemp
Next
EndIf
EndFunc
Func __array_combinations($in, $ir)
Local $i_total = 1
For $i = $ir To 1 Step -1
$i_total *= ($in / $i)
$in -= 1
Next
Return Round($i_total)
EndFunc
Func __array_getnext($in, $ir, ByRef $ileft, $itotal, ByRef $aidx)
If $ileft == $itotal Then
$ileft -= 1
Return
EndIf
Local $i = $ir - 1

EndFunc

While $aidx[$i] == $in - $ir + $i


$i -= 1
WEnd
$aidx[$i] += 1
For $j = $i + 1 To $ir - 1
$aidx[$j] = $aidx[$i] + $j - $i
Next
$ileft -= 1

Func __array_minmaxindex(Const ByRef $aarray, $icompnumeric, $istart, $i


end, $isubitem, $fucomparison)
If $icompnumeric = Default Then $icompnumeric = 0
If $icompnumeric <> 1 Then $icompnumeric = 0
If $istart = Default Then $istart = 0
If $iend = Default Then $iend = 0
If $isubitem = Default Then $isubitem = 0
If NOT IsArray($aarray) Then Return SetError(1, 0, -1)
Local $idim_1 = UBound($aarray, $ubound_rows) - 1
If $idim_1 < 0 Then Return SetError(1, 0, -1)
If $iend = -1 Then $iend = $idim_1
If $istart = -1 Then $istart = 0
If $istart < -1 OR $iend < -1 Then Return SetError(3, 0, -1)
If $istart > $idim_1 OR $iend > $idim_1 Then Return SetError(3,
0, -1)
If $istart > $iend Then Return SetError(4, 0, -1)
If $idim_1 < 0 Then Return SetError(5, 0, -1)
Local $imaxminindex = $istart
Switch UBound($aarray, $ubound_dimensions)
Case 1
If $icompnumeric Then
For $i = $istart To $iend
If $fucomparison(Number($aarray[
$i]), Number($aarray[$imaxminindex])) Then $imaxminindex = $i
Next
Else
For $i = $istart To $iend
If $fucomparison($aarray[$i], $a
array[$imaxminindex]) Then $imaxminindex = $i
Next
EndIf
Case 2
If $isubitem < 0 OR $isubitem > UBound($aarray,
$ubound_columns) - 1 Then Return SetError(6, 0, -1)
If $icompnumeric Then
For $i = $istart To $iend
If $fucomparison(Number($aarray[
$i][$isubitem]), Number($aarray[$imaxminindex][$isubitem])) Then $imaxminindex =
$i
Next
Else
For $i = $istart To $iend
If $fucomparison($aarray[$i][$is
ubitem], $aarray[$imaxminindex][$isubitem]) Then $imaxminindex = $i
Next
EndIf
Case Else
Return SetError(2, 0, -1)
EndSwitch
Return $imaxminindex

EndFunc
Func __array_greaterthan($vvalue1, $vvalue2)
Return $vvalue1 > $vvalue2
EndFunc
Func __array_lessthan($vvalue1, $vvalue2)
Return $vvalue1 < $vvalue2
EndFunc
Func __arrayunique_autoerrregister()
$g_oarrayuniquecomerrorhandler = ObjEvent("AutoIt.Error", "__Arr
ayUnique_AutoErrFunc")
EndFunc
Func __arrayunique_autoerrunregister()
$g_oarrayuniquecomerrorhandler = 0
EndFunc
Func __arrayunique_autoerrfunc()
EndFunc
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$hdf_left = 0
$hdf_right = 1
$hdf_center = 2
$hdf_justifymask = 3
$hdf_bitmap_on_right = 4096
$hdf_bitmap = 8192
$hdf_string = 16384
$hdf_ownerdraw = 32768
$hdf_displaymask = 61440
$hdf_rtlreading = 4
$hdf_sortdown = 512
$hdf_image = 2048
$hdf_sortup = 1024
$hdf_flagmask = 3588
$hdi_width = 1
$hdi_text = 2
$hdi_format = 4
$hdi_param = 8
$hdi_bitmap = 16
$hdi_image = 32
$hdi_di_setitem = 64
$hdi_order = 128
$hdi_filter = 256
$hht_nowhere = 1
$hht_onheader = 2
$hht_ondivider = 4
$hht_ondivopen = 8
$hht_onfilter = 16
$hht_onfilterbutton = 32
$hht_above = 256
$hht_below = 512
$hht_toright = 1024
$hht_toleft = 2048
$hdm_first = 4608
$hdm_clearfilter = $hdm_first + 24
$hdm_createdragimage = $hdm_first + 16
$hdm_deleteitem = $hdm_first + 2
$hdm_editfilter = $hdm_first + 23

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$hdm_getbitmapmargin = $hdm_first + 21
$hdm_getfocuseditem = $hdm_first + 27
$hdm_getimagelist = $hdm_first + 9
$hdm_getitema = $hdm_first + 3
$hdm_getitemw = $hdm_first + 11
$hdm_getitemcount = $hdm_first + 0
$hdm_getitemdropdownrect = $hdm_first + 25
$hdm_getitemrect = $hdm_first + 7
$hdm_getorderarray = $hdm_first + 17
$hdm_getoverflowrect = $hdm_first + 26
$hdm_getunicodeformat = 8192 + 6
$hdm_hittest = $hdm_first + 6
$hdm_insertitema = $hdm_first + 1
$hdm_insertitemw = $hdm_first + 10
$hdm_layout = $hdm_first + 5
$hdm_ordertoindex = $hdm_first + 15
$hdm_setbitmapmargin = $hdm_first + 20
$hdm_setfilterchangetimeout = $hdm_first + 22
$hdm_setfocuseditem = $hdm_first + 28
$hdm_sethotdivider = $hdm_first + 19
$hdm_setimagelist = $hdm_first + 8
$hdm_setitema = $hdm_first + 4
$hdm_setitemw = $hdm_first + 12
$hdm_setorderarray = $hdm_first + 18
$hdm_setunicodeformat = 8192 + 5
$hdn_first = -300
$hdn_begindrag = $hdn_first - 10
$hdn_begintrack = $hdn_first - 6
$hdn_dividerdblclick = $hdn_first - 5
$hdn_enddrag = $hdn_first - 11
$hdn_endtrack = $hdn_first - 7
$hdn_filterbtnclick = $hdn_first - 13
$hdn_filterchange = $hdn_first - 12
$hdn_getdispinfo = $hdn_first - 9
$hdn_itemchanged = $hdn_first - 1
$hdn_itemchanging = $hdn_first + 0
$hdn_itemclick = $hdn_first - 2
$hdn_itemdblclick = $hdn_first - 3
$hdn_track = $hdn_first - 8
$hdn_begintrackw = $hdn_first - 26
$hdn_dividerdblclickw = $hdn_first - 25
$hdn_endtrackw = $hdn_first - 27
$hdn_getdispinfow = $hdn_first - 29
$hdn_itemchangedw = $hdn_first - 21
$hdn_itemchangingw = $hdn_first - 20
$hdn_itemclickw = $hdn_first - 22
$hdn_itemdblclickw = $hdn_first - 23
$hdn_trackw = $hdn_first - 28
$hds_buttons = 2
$hds_checkboxes = 1024
$hds_dragdrop = 64
$hds_filterbar = 256
$hds_flat = 512
$hds_fulldrag = 128
$hds_hidden = 8
$hds_horz = 0
$hds_hottrack = 4
$hds_nosizing = 2048
$hds_overflow = 4096
$hds_default = 70

Global
Global
Global
Global
Global
Global
Global

$__g_hhdrlastwnd
Const $__headerconstant_classname = "SysHeader32"
Const $__headerconstant_default_gui_font = 17
Const $__headerconstant_swp_showwindow = 64
Const $taghdhittestinfo = $tagpoint & ";uint Flags;int Item"
Const $taghdlayout = "ptr Rect;ptr WindowPos"
Const $taghdtextfilter = "ptr Text;int TextMax"

Func _guictrlheader_additem($hwnd, $stext, $iwidth = 50, $ialign = 0, $i


image = -1, $bonright = False)
Return _guictrlheader_insertitem($hwnd, _guictrlheader_getitemco
unt($hwnd), $stext, $iwidth, $ialign, $iimage, $bonright)
EndFunc
Func _guictrlheader_clearfilter($hwnd, $iindex)
Return _sendmessage($hwnd, $hdm_clearfilter, $iindex) <> 0
EndFunc
Func _guictrlheader_clearfilterall($hwnd)
Return _sendmessage($hwnd, $hdm_clearfilter, -1) <> 0
EndFunc
Func _guictrlheader_create($hwnd, $istyle = 70)
$istyle = BitOR($istyle, $__udfguiconstant_ws_child, $__udfguico
nstant_ws_visible)
Local $nctrlid = __udf_getnextglobalid($hwnd)
If @error Then Return SetError(@error, @extended, 0)
Local $hheader = _winapi_createwindowex(0, $__headerconstant_cla
ssname, "", $istyle, 0, 0, 0, 0, $hwnd, $nctrlid)
Local $trect = _winapi_getclientrect($hwnd)
Local $twindowpos = _guictrlheader_layout($hheader, $trect)
Local $iflags = BitOR(DllStructGetData($twindowpos, "Flags"), $_
_headerconstant_swp_showwindow)
_winapi_setwindowpos($hheader, DllStructGetData($twindowpos, "In
sertAfter"), DllStructGetData($twindowpos, "X"), DllStructGetData($twindowpos, "
Y"), DllStructGetData($twindowpos, "CX"), DllStructGetData($twindowpos, "CY"), $
iflags)
_winapi_setfont($hheader, _winapi_getstockobject($__headerconsta
nt_default_gui_font))
Return $hheader
EndFunc
Func _guictrlheader_createdragimage($hwnd, $iindex)
Return Ptr(_sendmessage($hwnd, $hdm_createdragimage, $iindex))
EndFunc
Func _guictrlheader_deleteitem($hwnd, $iindex)
Return _sendmessage($hwnd, $hdm_deleteitem, $iindex) <> 0
EndFunc
Func _guictrlheader_destroy(ByRef $hwnd)
If NOT _winapi_isclassname($hwnd, $__headerconstant_classname) T
hen Return SetError(2, 2, False)
Local $idestroyed = 0
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hhdrlastwnd) Then
Local $nctrlid = _winapi_getdlgctrlid($hwnd)
Local $hparent = _winapi_getparent($hwnd)
$idestroyed = _winapi_destroywindow($hwnd)
Local $iret = __udf_freeglobalid($hparent, $nctr

lid)
Else
Else

EndFunc

<> 0

EndIf

If NOT $iret Then


EndIf
Return SetError(1, 1, False)

$idestroyed = GUICtrlDelete($hwnd)
EndIf
If $idestroyed Then $hwnd = 0
Return $idestroyed <> 0

Func _guictrlheader_editfilter($hwnd, $iindex, $bdiscard = True)


Return _sendmessage($hwnd, $hdm_editfilter, $iindex, $bdiscard)
EndFunc
Func _guictrlheader_getbitmapmargin($hwnd)
Return _sendmessage($hwnd, $hdm_getbitmapmargin)
EndFunc
Func _guictrlheader_getimagelist($hwnd)
Return Ptr(_sendmessage($hwnd, $hdm_getimagelist))
EndFunc

Func _guictrlheader_getitem($hwnd, $iindex, ByRef $titem)


Local $bunicode = _guictrlheader_getunicodeformat($hwnd)
Local $iret
If _winapi_inprocess($hwnd, $__g_hhdrlastwnd) Then
$iret = _sendmessage($hwnd, $hdm_getitemw, $iindex, $tit
em, 0, "wparam", "struct*")
Else
Local $iitem = DllStructGetSize($titem)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $iitem, $tmemmap)
_memwrite($tmemmap, $titem)
If $bunicode Then
$iret = _sendmessage($hwnd, $hdm_getitemw, $iind
ex, $pmemory, 0, "wparam", "ptr")
Else
$iret = _sendmessage($hwnd, $hdm_getitema, $iind
ex, $pmemory, 0, "wparam", "ptr")
EndIf
_memread($tmemmap, $pmemory, $titem, $iitem)
_memfree($tmemmap)
EndIf
Return $iret <> 0
EndFunc
Func _guictrlheader_getitemalign($hwnd, $iindex)
Switch BitAND(_guictrlheader_getitemformat($hwnd, $iindex), $hdf
_justifymask)
Case $hdf_left
Return 0
Case $hdf_right
Return 1
Case $hdf_center
Return 2
Case Else

EndFunc

EndSwitch

Return -1

Func _guictrlheader_getitembitmap($hwnd, $iindex)


Local $titem = DllStructCreate($taghditem)
DllStructSetData($titem, "Mask", $hdi_bitmap)
_guictrlheader_getitem($hwnd, $iindex, $titem)
Return DllStructGetData($titem, "hBmp")
EndFunc
Func _guictrlheader_getitemcount($hwnd)
Return _sendmessage($hwnd, $hdm_getitemcount)
EndFunc

1)

Func _guictrlheader_getitemdisplay($hwnd, $iindex)


Local $iret = 0
Local $iformat = _guictrlheader_getitemformat($hwnd, $iindex)
If BitAND($iformat, $hdf_bitmap) <> 0 Then $iret = BitOR($iret,

R($iret, 2)
t, 4)

If BitAND($iformat, $hdf_ownerdraw) <> 0 Then $iret = BitOR($ire


If BitAND($iformat, $hdf_string) <> 0 Then $iret = BitOR($iret,

8)
EndFunc

If BitAND($iformat, $hdf_bitmap_on_right) <> 0 Then $iret = BitO

Return $iret

Func _guictrlheader_getitemflags($hwnd, $iindex)


Local $iret = 0
Local $iformat = _guictrlheader_getitemformat($hwnd, $iindex)
If BitAND($iformat, $hdf_image) <> 0 Then $iret = BitOR($iret, 1
If BitAND($iformat, $hdf_rtlreading) <> 0 Then $iret = BitOR($ir

et, 2)

If BitAND($iformat, $hdf_sortdown) <> 0 Then $iret = BitOR($iret

, 4)

If BitAND($iformat, $hdf_sortup) <> 0 Then $iret = BitOR($iret,

8)
EndFunc

Return $iret

Func _guictrlheader_getitemformat($hwnd, $iindex)


Local $titem = DllStructCreate($taghditem)
DllStructSetData($titem, "Mask", $hdi_format)
_guictrlheader_getitem($hwnd, $iindex, $titem)
Return DllStructGetData($titem, "Fmt")
EndFunc
Func _guictrlheader_getitemimage($hwnd, $iindex)
Local $titem = DllStructCreate($taghditem)
DllStructSetData($titem, "Mask", $hdi_image)
_guictrlheader_getitem($hwnd, $iindex, $titem)
Return DllStructGetData($titem, "Image")
EndFunc
Func _guictrlheader_getitemorder($hwnd, $iindex)
Local $titem = DllStructCreate($taghditem)
DllStructSetData($titem, "Mask", $hdi_order)

EndFunc

_guictrlheader_getitem($hwnd, $iindex, $titem)


Return DllStructGetData($titem, "Order")

Func _guictrlheader_getitemparam($hwnd, $iindex)


Local $titem = DllStructCreate($taghditem)
DllStructSetData($titem, "Mask", $hdi_param)
_guictrlheader_getitem($hwnd, $iindex, $titem)
Return DllStructGetData($titem, "Param")
EndFunc
Func _guictrlheader_getitemrect($hwnd, $iindex)
Local $arect[4]
Local $trect = _guictrlheader_getitemrectex($hwnd, $iindex)
$arect[0] = DllStructGetData($trect, "Left")
$arect[1] = DllStructGetData($trect, "Top")
$arect[2] = DllStructGetData($trect, "Right")
$arect[3] = DllStructGetData($trect, "Bottom")
Return $arect
EndFunc
Func _guictrlheader_getitemrectex($hwnd, $iindex)
Local $trect = DllStructCreate($tagrect)
If _winapi_inprocess($hwnd, $__g_hhdrlastwnd) Then
_sendmessage($hwnd, $hdm_getitemrect, $iindex, $trect, 0
, "wparam", "struct*")
Else
Local $irect = DllStructGetSize($trect)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $irect, $tmemmap)
_memwrite($tmemmap, $trect)
_sendmessage($hwnd, $hdm_getitemrect, $iindex, $pmemory,
0, "wparam", "ptr")
_memread($tmemmap, $pmemory, $trect, $irect)
_memfree($tmemmap)
EndIf
Return $trect
EndFunc

r))

Func _guictrlheader_getitemtext($hwnd, $iindex)


Local $bunicode = _guictrlheader_getunicodeformat($hwnd)
Local $tbuffer
If $bunicode Then
$tbuffer = DllStructCreate("wchar Text[4096]")
Else
$tbuffer = DllStructCreate("char Text[4096]")
EndIf
Local $titem = DllStructCreate($taghditem)
DllStructSetData($titem, "Mask", $hdi_text)
DllStructSetData($titem, "TextMax", 4096)
If _winapi_inprocess($hwnd, $__g_hhdrlastwnd) Then
DllStructSetData($titem, "Text", DllStructGetPtr($tbuffe

wparam", "struct*")
Else

ze($tbuffer), $tmemmap)

_sendmessage($hwnd, $hdm_getitemw, $iindex, $titem, 0, "


Local $iitem = DllStructGetSize($titem)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $iitem + DllStructGetSi

Local $ptext = $pmemory + $iitem


DllStructSetData($titem, "Text", $ptext)
_memwrite($tmemmap, $titem, $pmemory, $iitem)
If $bunicode Then
_sendmessage($hwnd, $hdm_getitemw, $iindex, $pme
mory, 0, "wparam", "ptr")
Else
_sendmessage($hwnd, $hdm_getitema, $iindex, $pme
mory, 0, "wparam", "ptr")
EndIf
_memread($tmemmap, $ptext, $tbuffer, DllStructGetSize($t
buffer))
_memfree($tmemmap)
EndIf
Return DllStructGetData($tbuffer, "Text")
EndFunc
Func _guictrlheader_getitemwidth($hwnd, $iindex)
Local $titem = DllStructCreate($taghditem)
DllStructSetData($titem, "Mask", $hdi_width)
_guictrlheader_getitem($hwnd, $iindex, $titem)
Return DllStructGetData($titem, "XY")
EndFunc
Func _guictrlheader_getorderarray($hwnd)
Local $iitems = _guictrlheader_getitemcount($hwnd)
Local $tbuffer = DllStructCreate("int[" & $iitems & "]")
If _winapi_inprocess($hwnd, $__g_hhdrlastwnd) Then
_sendmessage($hwnd, $hdm_getorderarray, $iitems, $tbuffe
r, 0, "wparam", "struct*")
Else
Local $ibuffer = DllStructGetSize($tbuffer)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $ibuffer, $tmemmap)
_sendmessage($hwnd, $hdm_getorderarray, $iitems, $pmemor
y, 0, "wparam", "ptr")
_memread($tmemmap, $pmemory, $tbuffer, $ibuffer)
_memfree($tmemmap)
EndIf
Local $abuffer[$iitems + 1]
$abuffer[0] = $iitems
For $ii = 1 To $iitems
$abuffer[$ii] = DllStructGetData($tbuffer, 1, $ii)
Next
Return $abuffer
EndFunc
Func _guictrlheader_getunicodeformat($hwnd)
Return _sendmessage($hwnd, $hdm_getunicodeformat) <> 0
EndFunc
Func _guictrlheader_hittest($hwnd, $ix, $iy)
Local $ttest = DllStructCreate($taghdhittestinfo)
DllStructSetData($ttest, "X", $ix)
DllStructSetData($ttest, "Y", $iy)
Local $atest[11]
If _winapi_inprocess($hwnd, $__g_hhdrlastwnd) Then
$atest[0] = _sendmessage($hwnd, $hdm_hittest, 0, $ttest,
0, "wparam", "struct*")
Else

y, 0, "wparam", "ptr")

EndFunc

Local $itest = DllStructGetSize($ttest)


Local $tmemmap
Local $pmemory = _meminit($hwnd, $itest, $tmemmap)
_memwrite($tmemmap, $ttest)
$atest[0] = _sendmessage($hwnd, $hdm_hittest, 0, $pmemor
_memread($tmemmap, $pmemory, $ttest, $itest)
_memfree($tmemmap)

EndIf
Local $iflags = DllStructGetData($ttest, "Flags")
$atest[1] = BitAND($iflags, $hht_nowhere) <> 0
$atest[2] = BitAND($iflags, $hht_onheader) <> 0
$atest[3] = BitAND($iflags, $hht_ondivider) <> 0
$atest[4] = BitAND($iflags, $hht_ondivopen) <> 0
$atest[5] = BitAND($iflags, $hht_onfilter) <> 0
$atest[6] = BitAND($iflags, $hht_onfilterbutton) <> 0
$atest[7] = BitAND($iflags, $hht_above) <> 0
$atest[8] = BitAND($iflags, $hht_below) <> 0
$atest[9] = BitAND($iflags, $hht_toright) <> 0
$atest[10] = BitAND($iflags, $hht_toleft) <> 0
Return $atest

Func _guictrlheader_insertitem($hwnd, $iindex, $stext, $iwidth = 50, $ia


lign = 0, $iimage = -1, $bonright = False)
Local $aalign[3] = [$hdf_left, $hdf_right, $hdf_center]
Local $bunicode = _guictrlheader_getunicodeformat($hwnd)
Local $pbuffer, $ibuffer
If $stext <> -1 Then
$ibuffer = StringLen($stext) + 1
Local $tbuffer
If $bunicode Then
$tbuffer = DllStructCreate("wchar Text[" & $ibuf
fer & "]")
$ibuffer *= 2
Else
$tbuffer = DllStructCreate("char Text[" & $ibuff
er & "]")
EndIf
DllStructSetData($tbuffer, "Text", $stext)
$pbuffer = DllStructGetPtr($tbuffer)
Else
$ibuffer = 0
$pbuffer = -1
EndIf
Local $titem = DllStructCreate($taghditem)
Local $ifmt = $aalign[$ialign]
Local $imask = BitOR($hdi_width, $hdi_format)
If $stext <> "" Then
$imask = BitOR($imask, $hdi_text)
$ifmt = BitOR($ifmt, $hdf_string)
EndIf
If $iimage <> -1 Then
$imask = BitOR($imask, $hdi_image)
$ifmt = BitOR($ifmt, $hdf_image)
EndIf
If $bonright Then $ifmt = BitOR($ifmt, $hdf_bitmap_on_right)
DllStructSetData($titem, "Mask", $imask)
DllStructSetData($titem, "XY", $iwidth)
DllStructSetData($titem, "Fmt", $ifmt)

DllStructSetData($titem, "Image", $iimage)


Local $iret
If _winapi_inprocess($hwnd, $__g_hhdrlastwnd) Then
DllStructSetData($titem, "Text", $pbuffer)
$iret = _sendmessage($hwnd, $hdm_insertitemw, $iindex, $
titem, 0, "wparam", "struct*")
Else
Local $iitem = DllStructGetSize($titem)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $iitem + $ibuffer, $tme
mmap)
If $stext <> -1 Then
Local $ptext = $pmemory + $iitem
DllStructSetData($titem, "Text", $ptext)
_memwrite($tmemmap, $tbuffer, $ptext, $ibuffer)
Else
DllStructSetData($titem, "Text", -1)
EndIf
_memwrite($tmemmap, $titem, $pmemory, $iitem)
If $bunicode Then
$iret = _sendmessage($hwnd, $hdm_insertitemw, $i
index, $pmemory, 0, "wparam", "ptr")
Else
$iret = _sendmessage($hwnd, $hdm_insertitema, $i
index, $pmemory, 0, "wparam", "ptr")
EndIf
_memfree($tmemmap)
EndIf
Return $iret
EndFunc

t))

Func _guictrlheader_layout($hwnd, ByRef $trect)


Local $tlayout = DllStructCreate($taghdlayout)
Local $twindowpos = DllStructCreate($tagwindowpos)
If _winapi_inprocess($hwnd, $__g_hhdrlastwnd) Then
DllStructSetData($tlayout, "Rect", DllStructGetPtr($trec
DllStructSetData($tlayout, "WindowPos", DllStructGetPtr(

$twindowpos))
", "struct*")

_sendmessage($hwnd, $hdm_layout, 0, $tlayout, 0, "wparam


Else

indowpos, $tmemmap)
out + $irect)

Local
Local
Local
Local
Local

$ilayout = DllStructGetSize($tlayout)
$irect = DllStructGetSize($trect)
$iwindowpos = DllStructGetSize($twindowpos)
$tmemmap
$pmemory = _meminit($hwnd, $ilayout + $irect + $iw

DllStructSetData($tlayout, "Rect", $pmemory + $ilayout)


DllStructSetData($tlayout, "WindowPos", $pmemory + $ilay
_memwrite($tmemmap, $tlayout, $pmemory, $ilayout)
_memwrite($tmemmap, $trect, $pmemory + $ilayout, $irect)
_sendmessage($hwnd, $hdm_layout, 0, $pmemory, 0, "wparam

", "ptr")
wpos, $iwindowpos)

_memread($tmemmap, $pmemory + $ilayout + $irect, $twindo

_memfree($tmemmap)
EndIf
Return $twindowpos

EndFunc
Func _guictrlheader_ordertoindex($hwnd, $iorder)
Return _sendmessage($hwnd, $hdm_ordertoindex, $iorder)
EndFunc
Func _guictrlheader_setbitmapmargin($hwnd, $iwidth)
Return _sendmessage($hwnd, $hdm_setbitmapmargin, $iwidth)
EndFunc

eout)

lue)

Func _guictrlheader_setfilterchangetimeout($hwnd, $itimeout)


Return _sendmessage($hwnd, $hdm_setfilterchangetimeout, 0, $itim
EndFunc
Func _guictrlheader_sethotdivider($hwnd, $iflag, $iinputvalue)
Return _sendmessage($hwnd, $hdm_sethotdivider, $iflag, $iinputva
EndFunc

Func _guictrlheader_setimagelist($hwnd, $himage)


Return _sendmessage($hwnd, $hdm_setimagelist, 0, $himage, 0, "wp
aram", "handle", "handle")
EndFunc
Func _guictrlheader_setitem($hwnd, $iindex, ByRef $titem)
Local $bunicode = _guictrlheader_getunicodeformat($hwnd)
Local $iret
If _winapi_inprocess($hwnd, $__g_hhdrlastwnd) Then
$iret = _sendmessage($hwnd, $hdm_setitemw, $iindex, $tit
em, 0, "wparam", "struct*")
Else
Local $iitem = DllStructGetSize($titem)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $iitem, $tmemmap)
_memwrite($tmemmap, $titem)
If $bunicode Then
$iret = _sendmessage($hwnd, $hdm_setitemw, $iind
ex, $pmemory, 0, "wparam", "ptr")
Else
$iret = _sendmessage($hwnd, $hdm_setitema, $iind
ex, $pmemory, 0, "wparam", "ptr")
EndIf
_memfree($tmemmap)
EndIf
Return $iret <> 0
EndFunc
Func _guictrlheader_setitemalign($hwnd, $iindex, $ialign)
Local $aalign[3] = [$hdf_left, $hdf_right, $hdf_center]
Local $iformat = _guictrlheader_getitemformat($hwnd, $iindex)
$iformat = BitAND($iformat, BitNOT($hdf_justifymask))
$iformat = BitOR($iformat, $aalign[$ialign])
Return _guictrlheader_setitemformat($hwnd, $iindex, $iformat)
EndFunc

Func _guictrlheader_setitembitmap($hwnd, $iindex, $hbitmap)


Local $titem = DllStructCreate($taghditem)
DllStructSetData($titem, "Mask", BitOR($hdi_format, $hdi_bitmap)

EndFunc

DllStructSetData($titem, "Fmt", $hdf_bitmap)


DllStructSetData($titem, "hBMP", $hbitmap)
Return _guictrlheader_setitem($hwnd, $iindex, $titem)

Func _guictrlheader_setitemdisplay($hwnd, $iindex, $idisplay)


Local $iformat = BitAND(_guictrlheader_getitemformat($hwnd, $iin
dex), NOT $hdf_displaymask)
If BitAND($idisplay, 1) <> 0 Then $iformat = BitOR($iformat, $hd
f_bitmap)
If BitAND($idisplay, 2) <> 0 Then $iformat = BitOR($iformat, $hd
f_bitmap_on_right)
If BitAND($idisplay, 4) <> 0 Then $iformat = BitOR($iformat, $hd
f_ownerdraw)
If BitAND($idisplay, 8) <> 0 Then $iformat = BitOR($iformat, $hd
f_string)
Return _guictrlheader_setitemformat($hwnd, $iindex, $iformat)
EndFunc

image)

Func _guictrlheader_setitemflags($hwnd, $iindex, $iflags)


Local $iformat = _guictrlheader_getitemformat($hwnd, $iindex)
$iformat = BitAND($iformat, BitNOT($hdf_flagmask))
If BitAND($iflags, 1) <> 0 Then $iformat = BitOR($iformat, $hdf_

rtlreading)
sortdown)
sortup)
EndFunc

If BitAND($iflags, 2) <> 0 Then $iformat = BitOR($iformat, $hdf_


If BitAND($iflags, 4) <> 0 Then $iformat = BitOR($iformat, $hdf_
If BitAND($iflags, 8) <> 0 Then $iformat = BitOR($iformat, $hdf_
Return _guictrlheader_setitemformat($hwnd, $iindex, $iformat)

Func _guictrlheader_setitemformat($hwnd, $iindex, $iformat)


Local $titem = DllStructCreate($taghditem)
DllStructSetData($titem, "Mask", $hdi_format)
DllStructSetData($titem, "Fmt", $iformat)
Return _guictrlheader_setitem($hwnd, $iindex, $titem)
EndFunc
Func _guictrlheader_setitemimage($hwnd, $iindex, $iimage)
Local $titem = DllStructCreate($taghditem)
DllStructSetData($titem, "Mask", $hdi_image)
DllStructSetData($titem, "Image", $iimage)
Return _guictrlheader_setitem($hwnd, $iindex, $titem)
EndFunc
Func _guictrlheader_setitemorder($hwnd, $iindex, $iorder)
Local $titem = DllStructCreate($taghditem)
DllStructSetData($titem, "Mask", $hdi_order)
DllStructSetData($titem, "Order", $iorder)
Return _guictrlheader_setitem($hwnd, $iindex, $titem)
EndFunc
Func _guictrlheader_setitemparam($hwnd, $iindex, $iparam)
Local $titem = DllStructCreate($taghditem)
DllStructSetData($titem, "Mask", $hdi_param)
DllStructSetData($titem, "Param", $iparam)
Return _guictrlheader_setitem($hwnd, $iindex, $titem)
EndFunc

Func _guictrlheader_setitemtext($hwnd, $iindex, $stext)


Local $bunicode = _guictrlheader_getunicodeformat($hwnd)
Local $ibuffer, $pbuffer
If $stext <> -1 Then
$ibuffer = StringLen($stext) + 1
Local $tbuffer
If $bunicode Then
$tbuffer = DllStructCreate("wchar Text[" & $ibuf
fer & "]")
$ibuffer *= 2
Else
$tbuffer = DllStructCreate("char Text[" & $ibuff
er & "]")
EndIf
DllStructSetData($tbuffer, "Text", $stext)
$pbuffer = DllStructGetPtr($tbuffer)
Else
$ibuffer = 0
$pbuffer = -1
EndIf
Local $titem = DllStructCreate($taghditem)
DllStructSetData($titem, "Mask", $hdi_text)
DllStructSetData($titem, "TextMax", $ibuffer)
Local $iret
If _winapi_inprocess($hwnd, $__g_hhdrlastwnd) Then
DllStructSetData($titem, "Text", $pbuffer)
$iret = _sendmessage($hwnd, $hdm_setitemw, $iindex, $tit
em, 0, "wparam", "struct*")
Else
Local $iitem = DllStructGetSize($titem)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $iitem + $ibuffer, $tme
mmap)
If $stext <> -1 Then
Local $ptext = $pmemory + $iitem
DllStructSetData($titem, "Text", $ptext)
_memwrite($tmemmap, $tbuffer, $ptext, $ibuffer)
Else
DllStructSetData($titem, "Text", -1)
EndIf
_memwrite($tmemmap, $titem, $pmemory, $iitem)
If $bunicode Then
$iret = _sendmessage($hwnd, $hdm_setitemw, $iind
ex, $pmemory, 0, "wparam", "ptr")
Else
$iret = _sendmessage($hwnd, $hdm_setitema, $iind
ex, $pmemory, 0, "wparam", "ptr")
EndIf
_memfree($tmemmap)
EndIf
Return $iret <> 0
EndFunc
Func _guictrlheader_setitemwidth($hwnd, $iindex, $iwidth)
Local $titem = DllStructCreate($taghditem)
DllStructSetData($titem, "Mask", $hdi_width)
DllStructSetData($titem, "XY", $iwidth)
Return _guictrlheader_setitem($hwnd, $iindex, $titem)
EndFunc

Func _guictrlheader_setorderarray($hwnd, ByRef $aorder)


Local $tbuffer = DllStructCreate("int[" & $aorder[0] & "]")
For $ii = 1 To $aorder[0]
DllStructSetData($tbuffer, 1, $aorder[$ii], $ii)
Next
Local $iret
If _winapi_inprocess($hwnd, $__g_hhdrlastwnd) Then
$iret = _sendmessage($hwnd, $hdm_setorderarray, $aorder[
0], $tbuffer, 0, "wparam", "struct*")
Else
Local $ibuffer = DllStructGetSize($tbuffer)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $ibuffer, $tmemmap)
_memwrite($tmemmap, $tbuffer)
$iret = _sendmessage($hwnd, $hdm_setorderarray, $aorder[
0], $pmemory, 0, "wparam", "ptr")
_memfree($tmemmap)
EndIf
Return $iret <> 0
EndFunc
Func _guictrlheader_setunicodeformat($hwnd, $bunicode)
Return _sendmessage($hwnd, $hdm_setunicodeformat, $bunicode)
EndFunc
Global $__g_hlvlastwnd
Global $__g_illistviewsortinfosize = 11
Global $__g_alistviewsortinfo[1][$__g_illistviewsortinfosize]
Global Const $__listviewconstant_classname = "SysListView32"
Global Const $__listviewconstant_ws_maximizebox = 65536
Global Const $__listviewconstant_ws_minimizebox = 131072
Global Const $__listviewconstant_gui_rundefmsg = "GUI_RUNDEFMSG"
Global Const $__listviewconstant_wm_setredraw = 11
Global Const $__listviewconstant_wm_setfont = 48
Global Const $__listviewconstant_wm_notify = 78
Global Const $__listviewconstant_default_gui_font = 17
Global Const $__listviewconstant_ild_transparent = 1
Global Const $__listviewconstant_ild_blend25 = 2
Global Const $__listviewconstant_ild_blend50 = 4
Global Const $__listviewconstant_ild_mask = 16
Global Const $__listviewconstant_vk_down = 40
Global Const $__listviewconstant_vk_end = 35
Global Const $__listviewconstant_vk_home = 36
Global Const $__listviewconstant_vk_left = 37
Global Const $__listviewconstant_vk_next = 34
Global Const $__listviewconstant_vk_prior = 33
Global Const $__listviewconstant_vk_right = 39
Global Const $__listviewconstant_vk_up = 38
Global Const $taglvbkimage = "ulong Flags;hwnd hBmp;ptr Image;uint Image
Max;int XOffPercent;int YOffPercent"
Global Const $taglvcolumn = "uint Mask;int Fmt;int CX;ptr Text;int TextM
ax;int SubItem;int Image;int Order;int cxMin;int cxDefault;int cxIdeal"
Global Const $taglvgroup = "uint Size;uint Mask;ptr Header;int HeaderMax
;ptr Footer;int FooterMax;int GroupID;uint StateMask;uint State;uint Align;" & "
ptr pszSubtitle;uint cchSubtitle;ptr pszTask;uint cchTask;ptr pszDescriptionTop
;uint cchDescriptionTop;ptr pszDescriptionBottom;" & "uint cchDescriptionBottom;
int iTitleImage;int iExtendedImage;int iFirstItem;uint cItems;ptr pszSubsetTitle
;uint cchSubsetTitle"
Global Const $taglvinsertmark = "uint Size;dword Flags;int Item;dword Re

served"

Global Const $taglvsetinfotip = "uint Size;dword Flags;ptr Text;int Item


;int SubItem"
Func _guictrllistview_addarray($hwnd, ByRef $aitems)
Local $bunicode = _guictrllistview_getunicodeformat($hwnd)
Local $titem = DllStructCreate($taglvitem)
Local $tbuffer
If $bunicode Then
$tbuffer = DllStructCreate("wchar Text[4096]")
Else
$tbuffer = DllStructCreate("char Text[4096]")
EndIf
DllStructSetData($titem, "Mask", $lvif_text)
DllStructSetData($titem, "Text", DllStructGetPtr($tbuffer))
DllStructSetData($titem, "TextMax", 4096)
Local $ilastitem = _guictrllistview_getitemcount($hwnd)
_guictrllistview_beginupdate($hwnd)
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
For $ii = 0 To UBound($aitems) - 1
DllStructSetData($titem, "Item", $ii)
DllStructSetData($titem, "SubItem", 0)
DllStructSetData($tbuffer, "Text", $aite
ms[$ii][0])
_sendmessage($hwnd, $lvm_insertitemw, 0,
$titem, 0, "wparam", "struct*")
For $ij = 1 To UBound($aitems, $ubound_c
olumns) - 1
DllStructSetData($titem, "SubIte
m", $ij)
DllStructSetData($tbuffer, "Text
", $aitems[$ii][$ij])
_sendmessage($hwnd, $lvm_setitem
w, 0, $titem, 0, "wparam", "struct*")
Next
Next
Else
Local $ibuffer = DllStructGetSize($tbuffer)
Local $iitem = DllStructGetSize($titem)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $iitem + $ibuff
er, $tmemmap)
Local $ptext = $pmemory + $iitem
DllStructSetData($titem, "Text", $ptext)
For $ii = 0 To UBound($aitems) - 1
DllStructSetData($titem, "Item", $ii + $
ilastitem)
DllStructSetData($titem, "SubItem", 0)
DllStructSetData($tbuffer, "Text", $aite
ms[$ii][0])
_memwrite($tmemmap, $titem, $pmemory, $i
item)
_memwrite($tmemmap, $tbuffer, $ptext, $i
buffer)
If $bunicode Then
_sendmessage($hwnd, $lvm_inserti
temw, 0, $pmemory, 0, "wparam", "ptr")
Else
_sendmessage($hwnd, $lvm_inserti

tema, 0, $pmemory, 0, "wparam", "ptr")


olumns) - 1

EndIf
For $ij = 1 To UBound($aitems, $ubound_c
DllStructSetData($titem, "SubIte

m", $ij)

DllStructSetData($tbuffer, "Text

", $aitems[$ii][$ij])

_memwrite($tmemmap, $titem, $pme

mory, $iitem)

_memwrite($tmemmap, $tbuffer, $p

text, $ibuffer)
_setitemw, 0, $pmemory, 0, "wparam", "ptr")
_setitema, 0, $pmemory, 0, "wparam", "ptr")
Next

Else

m)

EndIf

If $bunicode Then
_sendmessage($hwnd, $lvm
Else

_sendmessage($hwnd, $lvm

EndIf

Next
_memfree($tmemmap)

Local $pitem = DllStructGetPtr($titem)


For $ii = 0 To UBound($aitems) - 1
DllStructSetData($titem, "Item", $ii + $ilastite
DllStructSetData($titem, "SubItem", 0)
DllStructSetData($tbuffer, "Text", $aitems[$ii][

0])
0, $pitem)
0, $pitem)
- 1

If $bunicode Then
GUICtrlSendMsg($hwnd, $lvm_insertitemw,
Else

EndIf
For $ij = 1 To UBound($aitems, $ubound_columns)
DllStructSetData($titem, "SubItem", $ij)
DllStructSetData($tbuffer, "Text", $aite

ms[$ii][$ij])

If $bunicode Then
GUICtrlSendMsg($hwnd, $lvm_setit

emw, 0, $pitem)

Else

ema, 0, $pitem)
Next

EndFunc

GUICtrlSendMsg($hwnd, $lvm_insertitema,

GUICtrlSendMsg($hwnd, $lvm_setit

EndIf

Next
EndIf
_guictrllistview_endupdate($hwnd)

Func _guictrllistview_addcolumn($hwnd, $stext, $iwidth = 50, $ialign = 1, $iimage = -1, $bonright = False)
Return _guictrllistview_insertcolumn($hwnd, _guictrllistview_get
columncount($hwnd), $stext, $iwidth, $ialign, $iimage, $bonright)

EndFunc

iparam)

Func _guictrllistview_additem($hwnd, $stext, $iimage = -1, $iparam = 0)


Return _guictrllistview_insertitem($hwnd, $stext, -1, $iimage, $
EndFunc

Func _guictrllistview_addsubitem($hwnd, $iindex, $stext, $isubitem, $iim


age = -1)
Local $bunicode = _guictrllistview_getunicodeformat($hwnd)
Local $ibuffer = StringLen($stext) + 1
Local $tbuffer
If $bunicode Then
$tbuffer = DllStructCreate("wchar Text[" & $ibuffer & "]
")
$ibuffer *= 2
Else
$tbuffer = DllStructCreate("char Text[" & $ibuffer & "]"
)
EndIf
Local $pbuffer = DllStructGetPtr($tbuffer)
Local $titem = DllStructCreate($taglvitem)
Local $imask = $lvif_text
If $iimage <> -1 Then $imask = BitOR($imask, $lvif_image)
DllStructSetData($tbuffer, "Text", $stext)
DllStructSetData($titem, "Mask", $imask)
DllStructSetData($titem, "Item", $iindex)
DllStructSetData($titem, "SubItem", $isubitem)
DllStructSetData($titem, "Image", $iimage)
Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
DllStructSetData($titem, "Text", $pbuffer)
$iret = _sendmessage($hwnd, $lvm_setitemw, 0, $t
item, 0, "wparam", "struct*")
Else
Local $iitem = DllStructGetSize($titem)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $iitem + $ibuff
er, $tmemmap)
Local $ptext = $pmemory + $iitem
DllStructSetData($titem, "Text", $ptext)
_memwrite($tmemmap, $titem, $pmemory, $iitem)
_memwrite($tmemmap, $tbuffer, $ptext, $ibuffer)
If $bunicode Then
$iret = _sendmessage($hwnd, $lvm_setitem
w, 0, $pmemory, 0, "wparam", "ptr")
Else
$iret = _sendmessage($hwnd, $lvm_setitem
a, 0, $pmemory, 0, "wparam", "ptr")
EndIf
_memfree($tmemmap)
EndIf
Else
Local $pitem = DllStructGetPtr($titem)
DllStructSetData($titem, "Text", $pbuffer)
If $bunicode Then
$iret = GUICtrlSendMsg($hwnd, $lvm_setitemw, 0,
$pitem)
Else

$iret = GUICtrlSendMsg($hwnd, $lvm_setitema, 0,

$pitem)

EndFunc

EndIf
EndIf
Return $iret <> 0

Func _guictrllistview_approximateviewheight($hwnd, $icount = -1, $icx =


-1, $icy = -1)
If IsHWnd($hwnd) Then
Return BitShift((_sendmessage($hwnd, $lvm_approximatevie
wrect, $icount, _winapi_makelong($icx, $icy))), 16)
Else
Return BitShift((GUICtrlSendMsg($hwnd, $lvm_approximatev
iewrect, $icount, _winapi_makelong($icx, $icy))), 16)
EndIf
EndFunc
Func _guictrllistview_approximateviewrect($hwnd, $icount = -1, $icx = -1
, $icy = -1)
Local $iview
If IsHWnd($hwnd) Then
$iview = _sendmessage($hwnd, $lvm_approximateviewrect, $
icount, _winapi_makelong($icx, $icy))
Else
$iview = GUICtrlSendMsg($hwnd, $lvm_approximateviewrect,
$icount, _winapi_makelong($icx, $icy))
EndIf
Local $aview[2]
$aview[0] = BitAND($iview, 65535)
$aview[1] = BitShift($iview, 16)
Return $aview
EndFunc
Func _guictrllistview_approximateviewwidth($hwnd, $icount = -1, $icx = 1, $icy = -1)
If IsHWnd($hwnd) Then
Return BitAND((_sendmessage($hwnd, $lvm_approximateviewr
ect, $icount, _winapi_makelong($icx, $icy))), 65535)
Else
Return BitAND((GUICtrlSendMsg($hwnd, $lvm_approximatevie
wrect, $icount, _winapi_makelong($icx, $icy))), 65535)
EndIf
EndFunc
Func _guictrllistview_arrange($hwnd, $iarrange = 0)
Local $aarrange[4] = [$lva_default, $lva_alignleft, $lva_alignto
p, $lva_snaptogrid]
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_arrange, $aarrange[$iarr
ange]) <> 0
Else
Return GUICtrlSendMsg($hwnd, $lvm_arrange, $aarrange[$ia
rrange], 0) <> 0
EndIf
EndFunc
Func __guictrllistview_arraydelete(ByRef $avarray, $ielement)
If NOT IsArray($avarray) Then Return SetError(1, 0, "")
Local $iupper = UBound($avarray)

If $iupper = 1 Then
SetError(2)
Return ""
EndIf
Local $avnewarray[$iupper - 1][$__g_illistviewsortinfosize]
$avnewarray[0][0] = $avarray[0][0]
If $ielement < 0 Then
$ielement = 0
EndIf
If $ielement > ($iupper - 1) Then
$ielement = ($iupper - 1)
EndIf
If $ielement > 0 Then
For $icntr = 0 To $ielement - 1
For $x = 1 To $__g_illistviewsortinfosize - 1
$avnewarray[$icntr][$x] = $avarray[$icnt

r][$x]

Next

icntr][$x]

EndIf
If $ielement < ($iupper - 1) Then
For $icntr = ($ielement + 1) To ($iupper - 1)
For $x = 1 To $__g_illistviewsortinfosize - 1
$avnewarray[$icntr - 1][$x] = $avarray[$
Next

EndFunc

se) = 0

Next

Next

EndIf
$avarray = $avnewarray
SetError(0)
Return 1

Func _guictrllistview_beginupdate($hwnd)
If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
Return _sendmessage($hwnd, $__listviewconstant_wm_setredraw, Fal
EndFunc
Func _guictrllistview_canceleditlabel($hwnd)
If IsHWnd($hwnd) Then
_sendmessage($hwnd, $lvm_canceleditlabel)
Else
GUICtrlSendMsg($hwnd, $lvm_canceleditlabel, 0, 0)
EndIf
EndFunc

Func _guictrllistview_clickitem($hwnd, $iindex, $sbutton = "left", $bmov


e = False, $iclicks = 1, $ispeed = 1)
If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
_guictrllistview_ensurevisible($hwnd, $iindex, False)
Local $trect = _guictrllistview_getitemrectex($hwnd, $iindex, $l
vir_label)
Local $tpoint = _winapi_pointfromrect($trect, True)
$tpoint = _winapi_clienttoscreen($hwnd, $tpoint)
Local $ix, $iy
_winapi_getxyfrompoint($tpoint, $ix, $iy)
Local $imode = Opt("MouseCoordMode", 1)
If NOT $bmove Then
Local $apos = MouseGetPos()

Else

EndFunc

_winapi_showcursor(False)
MouseClick($sbutton, $ix, $iy, $iclicks, $ispeed)
MouseMove($apos[0], $apos[1], 0)
_winapi_showcursor(True)

MouseClick($sbutton, $ix, $iy, $iclicks, $ispeed)


EndIf
Opt("MouseCoordMode", $imode)

Func _guictrllistview_copyitems($hwnd_source, $hwnd_destination, $bdelfl


ag = False)
Local $a_indices, $titem = DllStructCreate($taglvitem), $iindex
Local $icols = _guictrllistview_getcolumncount($hwnd_source)
Local $iitems = _guictrllistview_getitemcount($hwnd_source)
_guictrllistview_beginupdate($hwnd_source)
_guictrllistview_beginupdate($hwnd_destination)
If BitAND(_guictrllistview_getextendedlistviewstyle($hwnd_source
), $lvs_ex_checkboxes) == $lvs_ex_checkboxes Then
For $i = 0 To $iitems - 1
If (_guictrllistview_getitemchecked($hwnd_source
, $i)) Then
If IsArray($a_indices) Then
ReDim $a_indices[UBound($a_indic
es) + 1]
Else
Local $a_indices[2]
EndIf
$a_indices[0] = $a_indices[0] + 1
$a_indices[UBound($a_indices) - 1] = $i
EndIf
Next
If (IsArray($a_indices)) Then
For $i = 1 To $a_indices[0]
DllStructSetData($titem, "Mask", BitOR($
lvif_groupid, $lvif_image, $lvif_indent, $lvif_param, $lvif_state))
DllStructSetData($titem, "Item", $a_indi
ces[$i])
DllStructSetData($titem, "SubItem", 0)
DllStructSetData($titem, "StateMask", -1
)
_guictrllistview_getitemex($hwnd_source,
$titem)
$iindex = _guictrllistview_additem($hwnd
_destination, _guictrllistview_getitemtext($hwnd_source, $a_indices[$i], 0), Dll
StructGetData($titem, "Image"))
_guictrllistview_setitemchecked($hwnd_de
stination, $iindex)
For $x = 1 To $icols - 1
DllStructSetData($titem, "Item",
$a_indices[$i])
DllStructSetData($titem, "SubIte
m", $x)
_guictrllistview_getitemex($hwnd
_source, $titem)
_guictrllistview_addsubitem($hwn
d_destination, $iindex, _guictrllistview_getitemtext($hwnd_source, $a_indices[$i
], $x), $x, DllStructGetData($titem, "Image"))
Next
Next

d_source, $a_indices[$i])

If $bdelflag Then
For $i = $a_indices[0] To 1 Step -1
_guictrllistview_deleteitem($hwn
EndIf

ource, 1)

Next

EndIf
EndIf
If (_guictrllistview_getselectedcount($hwnd_source)) Then
$a_indices = _guictrllistview_getselectedindices($hwnd_s

For $i = 1 To $a_indices[0]
DllStructSetData($titem, "Mask", BitOR($lvif_gro
upid, $lvif_image, $lvif_indent, $lvif_param, $lvif_state))
DllStructSetData($titem, "Item", $a_indices[$i])
DllStructSetData($titem, "SubItem", 0)
DllStructSetData($titem, "StateMask", -1)
_guictrllistview_getitemex($hwnd_source, $titem)
$iindex = _guictrllistview_additem($hwnd_destina
tion, _guictrllistview_getitemtext($hwnd_source, $a_indices[$i], 0), DllStructGe
tData($titem, "Image"))
For $x = 1 To $icols - 1
DllStructSetData($titem, "Item", $a_indi
ces[$i])
DllStructSetData($titem, "SubItem", $x)
_guictrllistview_getitemex($hwnd_source,
$titem)
_guictrllistview_addsubitem($hwnd_destin
ation, $iindex, _guictrllistview_getitemtext($hwnd_source, $a_indices[$i], $x),
$x, DllStructGetData($titem, "Image"))
Next
Next
_guictrllistview_setitemselected($hwnd_source, -1, False
)
If $bdelflag Then
For $i = $a_indices[0] To 1 Step -1
_guictrllistview_deleteitem($hwnd_source
, $a_indices[$i])
Next
EndIf
EndIf
_guictrllistview_endupdate($hwnd_source)
_guictrllistview_endupdate($hwnd_destination)
EndFunc
Func _guictrllistview_create($hwnd, $sheadertext, $ix, $iy, $iwidth = 15
0, $iheight = 150, $istyle = 13, $iexstyle = 0, $bcoinit = False)
If NOT IsHWnd($hwnd) Then Return SetError(1, 0, 0)
If NOT IsString($sheadertext) Then Return SetError(2, 0, 0)
If $iwidth = -1 Then $iwidth = 150
If $iheight = -1 Then $iheight = 150
If $istyle = -1 Then $istyle = $lvs_default
If $iexstyle = -1 Then $iexstyle = 0
Local Const $s_ok = 0
Local Const $s_false = 1
Local Const $rpc_e_changed_mode = -2147417850
Local Const $e_invalidarg = -2147024809
Local Const $e_outofmemory = -2147024882
Local Const $e_unexpected = -2147418113
Local $sseparatorchar = Opt("GUIDataSeparatorChar")

aratorchar)

Local Const $coinit_apartmentthreaded = 2


Local $istr_len = StringLen($sheadertext)
If $istr_len Then $sheadertext = StringSplit($sheadertext, $ssep

$istyle = BitOR($__udfguiconstant_ws_child, $__udfguiconstant_ws


_visible, $istyle)
If $bcoinit Then
Local $aresult = DllCall("ole32.dll", "long", "CoInitial
izeEx", "ptr", 0, "dword", $coinit_apartmentthreaded)
If @error Then Return SetError(@error, @extended, 0)
Switch $aresult[0]
Case $s_ok
Case $s_false
Case $rpc_e_changed_mode
Case $e_invalidarg
Case $e_outofmemory
Case $e_unexpected
EndSwitch
EndIf
Local $nctrlid = __udf_getnextglobalid($hwnd)
If @error Then Return SetError(@error, @extended, 0)
Local $hlist = _winapi_createwindowex($iexstyle, $__listviewcons
tant_classname, "", $istyle, $ix, $iy, $iwidth, $iheight, $hwnd, $nctrlid)
_sendmessage($hlist, $__listviewconstant_wm_setfont, _winapi_get
stockobject($__listviewconstant_default_gui_font), True)
If $istr_len Then
For $x = 1 To $sheadertext[0]
_guictrllistview_insertcolumn($hlist, $x - 1, $s
headertext[$x], 75)
Next
EndIf
Return $hlist
EndFunc
Func _guictrllistview_createdragimage($hwnd, $iindex)
Local $adrag[3]
Local $tpoint = DllStructCreate($tagpoint)
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
$adrag[0] = _sendmessage($hwnd, $lvm_createdragi
mage, $iindex, $tpoint, 0, "wparam", "struct*", "handle")
Else
Local $ipoint = DllStructGetSize($tpoint)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $ipoint, $tmemm
ap)
$adrag[0] = _sendmessage($hwnd, $lvm_createdragi
mage, $iindex, $pmemory, 0, "wparam", "ptr", "handle")
_memread($tmemmap, $pmemory, $tpoint, $ipoint)
_memfree($tmemmap)
EndIf
Else
$adrag[0] = Ptr(GUICtrlSendMsg($hwnd, $lvm_createdragima
ge, $iindex, DllStructGetPtr($tpoint)))
EndIf
$adrag[1] = DllStructGetData($tpoint, "X")
$adrag[2] = DllStructGetData($tpoint, "Y")
Return $adrag
EndFunc

t)
ht)

Func _guictrllistview_createsolidbitmap($hwnd, $icolor, $iwidth, $iheigh


If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
Return _winapi_createsolidbitmap($hwnd, $icolor, $iwidth, $iheig
EndFunc

Func _guictrllistview_deleteallitems($hwnd)
If _guictrllistview_getitemcount($hwnd) = 0 Then Return True
Local $vcid = 0
If IsHWnd($hwnd) Then
$vcid = _winapi_getdlgctrlid($hwnd)
Else
$vcid = $hwnd
$hwnd = GUICtrlGetHandle($hwnd)
EndIf
If $vcid < $_udf_startid Then
Local $iparam = 0
For $iindex = _guictrllistview_getitemcount($hwnd) - 1 T
o 0 Step -1
$iparam = _guictrllistview_getitemparam($hwnd, $
iindex)
If GUICtrlGetState($iparam) > 0 AND GUICtrlGetHa
ndle($iparam) = 0 Then
GUICtrlDelete($iparam)
EndIf
Next
If _guictrllistview_getitemcount($hwnd) = 0 Then Return
True
EndIf
Return _sendmessage($hwnd, $lvm_deleteallitems) <> 0
EndFunc

Func _guictrllistview_deletecolumn($hwnd, $icol)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_deletecolumn, $icol) <>
Else

) <> 0
EndFunc

ndex)

Return GUICtrlSendMsg($hwnd, $lvm_deletecolumn, $icol, 0

EndIf

Func _guictrllistview_deleteitem($hwnd, $iindex)


Local $vcid = 0
If IsHWnd($hwnd) Then
$vcid = _winapi_getdlgctrlid($hwnd)
Else
$vcid = $hwnd
$hwnd = GUICtrlGetHandle($hwnd)
EndIf
If $vcid < $_udf_startid Then
Local $iparam = _guictrllistview_getitemparam($hwnd, $ii

aram) = 0 Then

If GUICtrlGetState($iparam) > 0 AND GUICtrlGetHandle($ip

EndIf

If GUICtrlDelete($iparam) Then
Return True
EndIf

EndFunc

EndIf
Return _sendmessage($hwnd, $lvm_deleteitem, $iindex) <> 0

Func _guictrllistview_deleteitemsselected($hwnd)
Local $iitemcount = _guictrllistview_getitemcount($hwnd)
If _guictrllistview_getselectedcount($hwnd) = $iitemcount Then
Return _guictrllistview_deleteallitems($hwnd)
Else
Local $aselected = _guictrllistview_getselectedindices($
hwnd, True)
If NOT IsArray($aselected) Then Return SetError($lv_err,
$lv_err, 0)
_guictrllistview_setitemselected($hwnd, -1, False)
Local $vcid = 0, $inative_delete, $iudf_delete
If IsHWnd($hwnd) Then
$vcid = _winapi_getdlgctrlid($hwnd)
Else
$vcid = $hwnd
$hwnd = GUICtrlGetHandle($hwnd)
EndIf
For $iindex = $aselected[0] To 1 Step -1
If $vcid < $_udf_startid Then
Local $iparam = _guictrllistview_getitem
param($hwnd, $aselected[$iindex])
If GUICtrlGetState($iparam) > 0 AND GUIC
trlGetHandle($iparam) = 0 Then
$inative_delete = GUICtrlDelete(
$iparam)
If $inative_delete Then Continue
Loop
EndIf
EndIf
$iudf_delete = _sendmessage($hwnd, $lvm_deleteit
em, $aselected[$iindex])
If $inative_delete + $iudf_delete = 0 Then
ExitLoop
EndIf
Next
Return NOT $iindex
EndIf
EndFunc
Func _guictrllistview_destroy(ByRef $hwnd)
If NOT _winapi_isclassname($hwnd, $__listviewconstant_classname)
Then Return SetError(2, 2, False)
Local $idestroyed = 0
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
Local $nctrlid = _winapi_getdlgctrlid($hwnd)
Local $hparent = _winapi_getparent($hwnd)
$idestroyed = _winapi_destroywindow($hwnd)
Local $iret = __udf_freeglobalid($hparent, $nctr
lid)
If NOT $iret Then
EndIf
Else
Return SetError(1, 1, False)
EndIf
Else

EndFunc

$idestroyed = GUICtrlDelete($hwnd)
EndIf
If $idestroyed Then $hwnd = 0
Return $idestroyed <> 0

Func __guictrllistview_draw($hwnd, $iindex, $hdc, $ix, $iy, $istyle = 0)


Local $iflags = 0
If BitAND($istyle, 1) <> 0 Then $iflags = BitOR($iflags, $__list
viewconstant_ild_transparent)
If BitAND($istyle, 2) <> 0 Then $iflags = BitOR($iflags, $__list
viewconstant_ild_blend25)
If BitAND($istyle, 4) <> 0 Then $iflags = BitOR($iflags, $__list
viewconstant_ild_blend50)
If BitAND($istyle, 8) <> 0 Then $iflags = BitOR($iflags, $__list
viewconstant_ild_mask)
Local $aresult = DllCall("comctl32.dll", "bool", "ImageList_Draw
", "handle", $hwnd, "int", $iindex, "handle", $hdc, "int", $ix, "int", $iy, "uin
t", $iflags)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _guictrllistview_drawdragimage(ByRef $hwnd, ByRef $adrag)
Local $hdc = _winapi_getwindowdc($hwnd)
Local $tpoint = _winapi_getmousepos(True, $hwnd)
_winapi_invalidaterect($hwnd)
__guictrllistview_draw($adrag[0], 0, $hdc, DllStructGetData($tpo
int, "X"), DllStructGetData($tpoint, "Y"))
_winapi_releasedc($hwnd, $hdc)
EndFunc
Func _guictrllistview_editlabel($hwnd, $iindex)
Local $bunicode = _guictrllistview_getunicodeformat($hwnd)
Local $aresult
If IsHWnd($hwnd) Then
$aresult = DllCall("user32.dll", "hwnd", "SetFocus", "hw
nd", $hwnd)
If @error Then Return SetError(@error, @extended, 0)
If $aresult = 0 Then Return 0
If $bunicode Then
Return _sendmessage($hwnd, $lvm_editlabelw, $iin
dex, 0, 0, "wparam", "lparam", "hwnd")
Else
Return _sendmessage($hwnd, $lvm_editlabel, $iind
ex, 0, 0, "wparam", "lparam", "hwnd")
EndIf
Else
$aresult = DllCall("user32.dll", "hwnd", "SetFocus", "hw
nd", GUICtrlGetHandle($hwnd))
If @error Then Return SetError(@error, @extended, 0)
If $aresult = 0 Then Return 0
If $bunicode Then
Return HWnd(GUICtrlSendMsg($hwnd, $lvm_editlabel
w, $iindex, 0))
Else
Return HWnd(GUICtrlSendMsg($hwnd, $lvm_editlabel
, $iindex, 0))
EndIf
EndIf

EndFunc

e)

Func _guictrllistview_enablegroupview($hwnd, $benable = True)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_enablegroupview, $benabl
Else

ble, 0)
EndFunc

e) = 0

Return GUICtrlSendMsg($hwnd, $lvm_enablegroupview, $bena

EndIf

Func _guictrllistview_endupdate($hwnd)
If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
Return _sendmessage($hwnd, $__listviewconstant_wm_setredraw, Tru
EndFunc

Func _guictrllistview_ensurevisible($hwnd, $iindex, $bpartialok = False)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_ensurevisible, $iindex,
$bpartialok)
Else
Return GUICtrlSendMsg($hwnd, $lvm_ensurevisible, $iindex
, $bpartialok)
EndIf
EndFunc
Func _guictrllistview_findintext($hwnd, $stext, $istart = -1, $bwrapok =
True, $breverse = False)
Local $icount = _guictrllistview_getitemcount($hwnd)
Local $icolumns = _guictrllistview_getcolumncount($hwnd)
If $icolumns = 0 Then $icolumns = 1
If $breverse AND $istart = -1 Then Return -1
Local $slist
If $breverse Then
For $ii = $istart - 1 To 0 Step -1
For $ij = 0 To $icolumns - 1
$slist = _guictrllistview_getitemtext($h
wnd, $ii, $ij)
If StringInStr($slist, $stext) Then Retu
rn $ii
Next
Next
Else
For $ii = $istart + 1 To $icount - 1
For $ij = 0 To $icolumns - 1
$slist = _guictrllistview_getitemtext($h
wnd, $ii, $ij)
If StringInStr($slist, $stext) Then Retu
rn $ii
Next
Next
EndIf
If (($istart = -1) OR NOT $bwrapok) AND NOT $breverse Then Retur
n -1
If $breverse AND $bwrapok Then
For $ii = $icount - 1 To $istart + 1 Step -1
For $ij = 0 To $icolumns - 1
$slist = _guictrllistview_getitemtext($h

wnd, $ii, $ij)

If StringInStr($slist, $stext) Then Retu

rn $ii
Else

wnd, $ii, $ij)

Next

For $ii = 0 To $istart - 1


For $ij = 0 To $icolumns - 1
$slist = _guictrllistview_getitemtext($h
If StringInStr($slist, $stext) Then Retu

rn $ii
Next

EndFunc
= "")

Next

Next

EndIf
Return -1

Func _guictrllistview_finditem($hwnd, $istart, ByRef $tfindinfo, $stext

Local $ibuffer = StringLen($stext) + 1


Local $tbuffer = DllStructCreate("char Text[" & $ibuffer & "]")
Local $pbuffer = DllStructGetPtr($tbuffer)
DllStructSetData($tbuffer, "Text", $stext)
Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
DllStructSetData($tfindinfo, "Text", $pbuffer)
$iret = _sendmessage($hwnd, $lvm_finditem, $ista
rt, $tfindinfo, 0, "wparam", "struct*")
Else
Local $ifindinfo = DllStructGetSize($tfindinfo)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $ifindinfo + $i
buffer, $tmemmap)
Local $ptext = $pmemory + $ifindinfo
DllStructSetData($tfindinfo, "Text", $ptext)
_memwrite($tmemmap, $tfindinfo, $pmemory, $ifind
info)
_memwrite($tmemmap, $tbuffer, $ptext, $ibuffer)
$iret = _sendmessage($hwnd, $lvm_finditem, $ista
rt, $pmemory, 0, "wparam", "ptr")
_memfree($tmemmap)
EndIf
Else
DllStructSetData($tfindinfo, "Text", $pbuffer)
$iret = GUICtrlSendMsg($hwnd, $lvm_finditem, $istart, Dl
lStructGetPtr($tfindinfo))
EndIf
Return $iret
EndFunc
Func _guictrllistview_findnearest($hwnd, $ix, $iy, $idir = 0, $istart =
-1, $bwrapok = True)
Local $adir[8] = [$__listviewconstant_vk_left, $__listviewconsta
nt_vk_right, $__listviewconstant_vk_up, $__listviewconstant_vk_down, $__listview
constant_vk_home, $__listviewconstant_vk_end, $__listviewconstant_vk_prior, $__l
istviewconstant_vk_next]
Local $tfindinfo = DllStructCreate($taglvfindinfo)
Local $iflags = $lvfi_nearestxy

EndFunc

If $bwrapok Then $iflags = BitOR($iflags, $lvfi_wrap)


DllStructSetData($tfindinfo, "Flags", $iflags)
DllStructSetData($tfindinfo, "X", $ix)
DllStructSetData($tfindinfo, "Y", $iy)
DllStructSetData($tfindinfo, "Direction", $adir[$idir])
Return _guictrllistview_finditem($hwnd, $istart, $tfindinfo)

Func _guictrllistview_findparam($hwnd, $iparam, $istart = -1)


Local $tfindinfo = DllStructCreate($taglvfindinfo)
DllStructSetData($tfindinfo, "Flags", $lvfi_param)
DllStructSetData($tfindinfo, "Param", $iparam)
Return _guictrllistview_finditem($hwnd, $istart, $tfindinfo)
EndFunc
Func _guictrllistview_findtext($hwnd, $stext, $istart = -1, $bpartialok
= True, $bwrapok = True)
Local $tfindinfo = DllStructCreate($taglvfindinfo)
Local $iflags = $lvfi_string
If $bpartialok Then $iflags = BitOR($iflags, $lvfi_partial)
If $bwrapok Then $iflags = BitOR($iflags, $lvfi_wrap)
DllStructSetData($tfindinfo, "Flags", $iflags)
Return _guictrllistview_finditem($hwnd, $istart, $tfindinfo, $st
ext)
EndFunc
Func _guictrllistview_getbkcolor($hwnd)
Local $i_color
If IsHWnd($hwnd) Then
$i_color = _sendmessage($hwnd, $lvm_getbkcolor)
Else
$i_color = GUICtrlSendMsg($hwnd, $lvm_getbkcolor, 0, 0)
EndIf
Return __guictrllistview_reversecolororder($i_color)
EndFunc
Func _guictrllistview_getbkimage($hwnd)
Local $bunicode = _guictrllistview_getunicodeformat($hwnd)
Local $tbuffer
If $bunicode Then
$tbuffer = DllStructCreate("wchar Text[4096]")
Else
$tbuffer = DllStructCreate("char Text[4096]")
EndIf
Local $pbuffer = DllStructGetPtr($tbuffer)
Local $timage = DllStructCreate($taglvbkimage)
DllStructSetData($timage, "ImageMax", 4096)
Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
DllStructSetData($timage, "Image", $pbuffer)
$iret = _sendmessage($hwnd, $lvm_getbkimagew, 0,
$timage, 0, "wparam", "struct*")
Else
Local $ibuffer = DllStructGetSize($tbuffer)
Local $iimage = DllStructGetSize($timage)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $iimage + $ibuf
fer, $tmemmap)
Local $ptext = $pmemory + $iimage

DllStructSetData($timage, "Image", $ptext)


_memwrite($tmemmap, $timage, $pmemory, $iimage)
If $bunicode Then
$iret = _sendmessage($hwnd, $lvm_getbkim
agew, 0, $pmemory, 0, "wparam", "ptr")
Else
$iret = _sendmessage($hwnd, $lvm_getbkim
agea, 0, $pmemory, 0, "wparam", "ptr")
EndIf
_memread($tmemmap, $pmemory, $timage, $iimage)
_memread($tmemmap, $ptext, $tbuffer, $ibuffer)
_memfree($tmemmap)
EndIf
Else
Local $pimage = DllStructGetPtr($timage)
DllStructSetData($timage, "Image", $pbuffer)
If $bunicode Then
$iret = GUICtrlSendMsg($hwnd, $lvm_getbkimagew,
0, $pimage)
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_getbkimagea,
0, $pimage)
EndIf
EndIf
Local $aimage[4]
Switch BitAND(DllStructGetData($timage, "Flags"), $lvbkif_source
_mask)
Case $lvbkif_source_hbitmap
$aimage[0] = 1
Case $lvbkif_source_url
$aimage[0] = 2
EndSwitch
$aimage[1] = DllStructGetData($tbuffer, "Text")
$aimage[2] = DllStructGetData($timage, "XOffPercent")
$aimage[3] = DllStructGetData($timage, "YOffPercent")
Return SetError($iret <> 0, 0, $aimage)
EndFunc

1)

Func _guictrllistview_getcallbackmask($hwnd)
Local $iflags = 0
Local $imask = _sendmessage($hwnd, $lvm_getcallbackmask)
If BitAND($imask, $lvis_cut) <> 0 Then $iflags = BitOR($iflags,

iflags, 2)
gs, 4)

If BitAND($imask, $lvis_drophilited) <> 0 Then $iflags = BitOR($


If BitAND($imask, $lvis_focused) <> 0 Then $iflags = BitOR($ifla
If BitAND($imask, $lvis_selected) <> 0 Then $iflags = BitOR($ifl

ags, 8)
iflags, 16)
R($iflags, 32)
EndFunc

If BitAND($imask, $lvis_overlaymask) <> 0 Then $iflags = BitOR($


If BitAND($imask, $lvis_stateimagemask) <> 0 Then $iflags = BitO
Return $iflags

Func _guictrllistview_getcolumn($hwnd, $iindex)


Local $bunicode = _guictrllistview_getunicodeformat($hwnd)
Local $tbuffer
If $bunicode Then

Else

$tbuffer = DllStructCreate("wchar Text[4096]")

$tbuffer = DllStructCreate("char Text[4096]")


EndIf
Local $pbuffer = DllStructGetPtr($tbuffer)
Local $tcolumn = DllStructCreate($taglvcolumn)
DllStructSetData($tcolumn, "Mask", $lvcf_alldata)
DllStructSetData($tcolumn, "TextMax", 4096)
Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
DllStructSetData($tcolumn, "Text", $pbuffer)
$iret = _sendmessage($hwnd, $lvm_getcolumnw, $ii
ndex, $tcolumn, 0, "wparam", "struct*")
Else
Local $ibuffer = DllStructGetSize($tbuffer)
Local $icolumn = DllStructGetSize($tcolumn)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $icolumn + $ibu
ffer, $tmemmap)
Local $ptext = $pmemory + $icolumn
DllStructSetData($tcolumn, "Text", $ptext)
_memwrite($tmemmap, $tcolumn, $pmemory, $icolumn
)
If $bunicode Then
$iret = _sendmessage($hwnd, $lvm_getcolu
mnw, $iindex, $pmemory, 0, "wparam", "ptr")
Else
$iret = _sendmessage($hwnd, $lvm_getcolu
mna, $iindex, $pmemory, 0, "wparam", "ptr")
EndIf
_memread($tmemmap, $pmemory, $tcolumn, $icolumn)
_memread($tmemmap, $ptext, $tbuffer, $ibuffer)
_memfree($tmemmap)
EndIf
Else
Local $pcolumn = DllStructGetPtr($tcolumn)
DllStructSetData($tcolumn, "Text", $pbuffer)
If $bunicode Then
$iret = GUICtrlSendMsg($hwnd, $lvm_getcolumnw, $
iindex, $pcolumn)
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_getcolumna, $
iindex, $pcolumn)
EndIf
EndIf
Local $acolumn[9]
Switch BitAND(DllStructGetData($tcolumn, "Fmt"), $lvcfmt_justify
mask)
Case $lvcfmt_right
$acolumn[0] = 1
Case $lvcfmt_center
$acolumn[0] = 2
Case Else
$acolumn[0] = 0
EndSwitch
$acolumn[1] = BitAND(DllStructGetData($tcolumn, "Fmt"), $lvcfmt_
image) <> 0
$acolumn[2] = BitAND(DllStructGetData($tcolumn, "Fmt"), $lvcfmt_
bitmap_on_right) <> 0

$acolumn[3] = BitAND(DllStructGetData($tcolumn, "Fmt"), $lvcfmt_


col_has_images) <> 0
$acolumn[4] = DllStructGetData($tcolumn, "CX")
$acolumn[5] = DllStructGetData($tbuffer, "Text")
$acolumn[6] = DllStructGetData($tcolumn, "SubItem")
$acolumn[7] = DllStructGetData($tcolumn, "Image")
$acolumn[8] = DllStructGetData($tcolumn, "Order")
Return SetError($iret = 0, 0, $acolumn)
EndFunc
Func _guictrllistview_getcolumncount($hwnd)
Return _sendmessage(_guictrllistview_getheader($hwnd), 4608)
EndFunc
Func _guictrllistview_getcolumnorder($hwnd)
Local $a_cols = _guictrllistview_getcolumnorderarray($hwnd), $s_
cols = ""
Local $sseparatorchar = Opt("GUIDataSeparatorChar")
For $i = 1 To $a_cols[0]
$s_cols &= $a_cols[$i] & $sseparatorchar
Next
$s_cols = StringTrimRight($s_cols, 1)
Return $s_cols
EndFunc
Func _guictrllistview_getcolumnorderarray($hwnd)
Local $icolumns = _guictrllistview_getcolumncount($hwnd)
Local $tbuffer = DllStructCreate("int[" & $icolumns & "]")
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
_sendmessage($hwnd, $lvm_getcolumnorderarray, $i
columns, $tbuffer, 0, "wparam", "struct*")
Else
Local $ibuffer = DllStructGetSize($tbuffer)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $ibuffer, $tmem
map)
_sendmessage($hwnd, $lvm_getcolumnorderarray, $i
columns, $pmemory, 0, "wparam", "ptr")
_memread($tmemmap, $pmemory, $tbuffer, $ibuffer)
_memfree($tmemmap)
EndIf
Else
GUICtrlSendMsg($hwnd, $lvm_getcolumnorderarray, $icolumn
s, DllStructGetPtr($tbuffer))
EndIf
Local $abuffer[$icolumns + 1]
$abuffer[0] = $icolumns
For $ii = 1 To $icolumns
$abuffer[$ii] = DllStructGetData($tbuffer, 1, $ii)
Next
Return $abuffer
EndFunc

0)

Func _guictrllistview_getcolumnwidth($hwnd, $icol)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_getcolumnwidth, $icol)
Else
Return GUICtrlSendMsg($hwnd, $lvm_getcolumnwidth, $icol,

EndFunc

EndIf

Func _guictrllistview_getcounterpage($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_getcountperpage)
Else
Return GUICtrlSendMsg($hwnd, $lvm_getcountperpage, 0, 0)
EndIf
EndFunc

, 0))

Func _guictrllistview_geteditcontrol($hwnd)
If IsHWnd($hwnd) Then
Return HWnd(_sendmessage($hwnd, $lvm_geteditcontrol))
Else
Return HWnd(GUICtrlSendMsg($hwnd, $lvm_geteditcontrol, 0
EndFunc

EndIf

Func _guictrllistview_getemptytext($hwnd)
Local $ttext = DllStructCreate("char[4096]")
Local $iret
If IsHWnd($hwnd) Then
Local $itext = DllStructGetSize($ttext)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $itext + 4096, $tmemmap
Local $ptext = $pmemory + $itext
DllStructSetData($ttext, "Text", $ptext)
_memwrite($tmemmap, $ptext, $pmemory, $itext)
$iret = _sendmessage($hwnd, $lvm_getemptytext, 4096, $pm

emory)

Else
llStructGetPtr($ttext))

EndFunc

EndIf

_memread($tmemmap, $ptext, $ttext, 4096)


_memfree($tmemmap)
If $iret = 0 Then Return SetError(-1, 0, "")
Return DllStructGetData($ttext, 1)
$iret = GUICtrlSendMsg($hwnd, $lvm_getemptytext, 4096, D
If $iret = 0 Then Return SetError(-1, 0, "")
Return DllStructGetData($ttext, 1)

Func _guictrllistview_getextendedlistviewstyle($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_getextendedlistviewstyle
Else

le, 0, 0)
EndFunc

Return GUICtrlSendMsg($hwnd, $lvm_getextendedlistviewsty

EndIf

Func _guictrllistview_getfocusedgroup($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_getfocusedgroup)
Else
Return GUICtrlSendMsg($hwnd, $lvm_getfocusedgroup, 0, 0)

EndFunc

EndIf

Func _guictrllistview_getgroupcount($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_getgroupcount)
Else
Return GUICtrlSendMsg($hwnd, $lvm_getgroupcount, 0, 0)
EndIf
EndFunc
Func _guictrllistview_getgroupinfo($hwnd, $igroupid)
Local $tgroup = __guictrllistview_getgroupinfoex($hwnd, $igroupi
d, BitOR($lvgf_header, $lvgf_align))
Local $ierr = @error
Local $agroup[2]
$agroup[0] = _winapi_widechartomultibyte(DllStructGetData($tgrou
p, "Header"))
Select
Case BitAND(DllStructGetData($tgroup, "Align"), $lvga_he
ader_center) <> 0
$agroup[1] = 1
Case BitAND(DllStructGetData($tgroup, "Align"), $lvga_he
ader_right) <> 0
$agroup[1] = 2
Case Else
$agroup[1] = 0
EndSelect
Return SetError($ierr, 0, $agroup)
EndFunc
Func __guictrllistview_getgroupinfoex($hwnd, $igroupid, $imask)
Local $tgroup = DllStructCreate($taglvgroup)
Local $igroup = DllStructGetSize($tgroup)
DllStructSetData($tgroup, "Size", $igroup)
DllStructSetData($tgroup, "Mask", $imask)
Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
$iret = _sendmessage($hwnd, $lvm_getgroupinfo, $
igroupid, $tgroup, 0, "wparam", "struct*")
Else
Local $tmemmap
Local $pmemory = _meminit($hwnd, $igroup, $tmemm
ap)
_memwrite($tmemmap, $tgroup, $pmemory, $igroup)
$iret = _sendmessage($hwnd, $lvm_getgroupinfo, $
igroupid, $pmemory, 0, "wparam", "ptr")
_memread($tmemmap, $pmemory, $tgroup, $igroup)
_memfree($tmemmap)
EndIf
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_getgroupinfo, $igroup
id, DllStructGetPtr($tgroup))
EndIf
Return SetError($iret <> $igroupid, 0, $tgroup)
EndFunc
Func _guictrllistview_getgroupinfobyindex($hwnd, $iindex)
Local $tgroup = DllStructCreate($taglvgroup)

Local $igroup = DllStructGetSize($tgroup)


DllStructSetData($tgroup, "Size", $igroup)
DllStructSetData($tgroup, "Mask", BitOR($lvgf_header, $lvgf_alig
n, $lvgf_groupid))
Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
$iret = _sendmessage($hwnd, $lvm_getgroupinfobyi
ndex, $iindex, $tgroup, 0, "wparam", "struct*")
Else
Local $tmemmap
Local $pmemory = _meminit($hwnd, $igroup, $tmemm
ap)
_memwrite($tmemmap, $tgroup, $pmemory, $igroup)
$iret = _sendmessage($hwnd, $lvm_getgroupinfobyi
ndex, $iindex, $pmemory, 0, "wparam", "ptr")
_memread($tmemmap, $pmemory, $tgroup, $igroup)
_memfree($tmemmap)
EndIf
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_getgroupinfobyindex,
$iindex, DllStructGetPtr($tgroup))
EndIf
Local $agroup[3]
$agroup[0] = _winapi_widechartomultibyte(DllStructGetData($tgrou
p, "Header"))
Select
Case BitAND(DllStructGetData($tgroup, "Align"), $lvga_he
ader_center) <> 0
$agroup[1] = 1
Case BitAND(DllStructGetData($tgroup, "Align"), $lvga_he
ader_right) <> 0
$agroup[1] = 2
Case Else
$agroup[1] = 0
EndSelect
$agroup[2] = DllStructGetData($tgroup, "GroupID")
Return SetError($iret = 0, 0, $agroup)
EndFunc
p)

Func _guictrllistview_getgrouprect($hwnd, $igroupid, $iget = $lvggr_grou

Local $tgroup = DllStructCreate($tagrect)


DllStructSetData($tgroup, "Top", $iget)
Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
$iret = _sendmessage($hwnd, $lvm_getgrouprect, $
igroupid, $tgroup, 0, "wparam", "struct*")
Else
Local $igroup = DllStructGetSize($tgroup)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $igroup, $tmemm
ap)
_memwrite($tmemmap, $tgroup, $pmemory, $igroup)
$iret = _sendmessage($hwnd, $lvm_getgrouprect, $
igroupid, $pmemory, 0, "wparam", "ptr")
_memread($tmemmap, $pmemory, $tgroup, $igroup)
_memfree($tmemmap)
EndIf

Else

$iret = GUICtrlSendMsg($hwnd, $lvm_getgrouprect, $igroup


id, DllStructGetPtr($tgroup))
EndIf
Local $agroup[4]
For $x = 0 To 3
$agroup[$x] = DllStructGetData($tgroup, $x + 1)
Next
Return SetError($iret = 0, 0, $agroup)
EndFunc
Func _guictrllistview_getgroupstate($hwnd, $igroupid, $imask)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_getgroupstate, $igroupid
, $imask)
Else
Return GUICtrlSendMsg($hwnd, $lvm_getgroupstate, $igroup
id, $imask)
EndIf
EndFunc
Func _guictrllistview_getgroupviewenabled($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_isgroupviewenabled) <> 0
Else
Return GUICtrlSendMsg($hwnd, $lvm_isgroupviewenabled, 0,
0) <> 0
EndIf
EndFunc
Func _guictrllistview_getheader($hwnd)
If IsHWnd($hwnd) Then
Return HWnd(_sendmessage($hwnd, $lvm_getheader))
Else
Return HWnd(GUICtrlSendMsg($hwnd, $lvm_getheader, 0, 0))
EndIf
EndFunc
Func _guictrllistview_gethotcursor($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_gethotcursor, 0, 0, 0, "
wparam", "lparam", "handle")
Else
Return Ptr(GUICtrlSendMsg($hwnd, $lvm_gethotcursor, 0, 0
))
EndIf
EndFunc
Func _guictrllistview_gethotitem($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_gethotitem)
Else
Return GUICtrlSendMsg($hwnd, $lvm_gethotitem, 0, 0)
EndIf
EndFunc
Func _guictrllistview_gethovertime($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_gethovertime)
Else

EndFunc

e]

EndIf

Return GUICtrlSendMsg($hwnd, $lvm_gethovertime, 0, 0)

Func _guictrllistview_getimagelist($hwnd, $iimagelist)


Local $aimagelist[3] = [$lvsil_normal, $lvsil_small, $lvsil_stat

If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_getimagelist, $aimagelis
t[$iimagelist], 0, 0, "wparam", "lparam", "handle")
Else
Return Ptr(GUICtrlSendMsg($hwnd, $lvm_getimagelist, $aim
agelist[$iimagelist], 0))
EndIf
EndFunc
Func _guictrllistview_getinsertmark($hwnd)
Local $tmark = DllStructCreate($taglvinsertmark)
Local $imark = DllStructGetSize($tmark)
DllStructSetData($tmark, "Size", $imark)
Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
$iret = _sendmessage($hwnd, $lvm_getinsertmark,
0, $tmark, 0, "wparam", "struct*")
Else
Local $tmemmap
Local $pmemory = _meminit($hwnd, $imark, $tmemma
p)
_memwrite($tmemmap, $tmark)
$iret = _sendmessage($hwnd, $lvm_getinsertmark,
0, $pmemory, 0, "wparam", "ptr")
_memread($tmemmap, $pmemory, $tmark, $imark)
_memfree($tmemmap)
EndIf
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_getinsertmark, 0, Dll
StructGetPtr($tmark))
EndIf
Local $amark[2]
$amark[0] = DllStructGetData($tmark, "Flags") = $lvim_after
$amark[1] = DllStructGetData($tmark, "Item")
Return SetError($iret = 0, 0, $amark)
EndFunc
Func _guictrllistview_getinsertmarkcolor($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_getinsertmarkcolor, $lvs
il_state)
Else
Return GUICtrlSendMsg($hwnd, $lvm_getinsertmarkcolor, $l
vsil_state, 0)
EndIf
EndFunc
Func _guictrllistview_getinsertmarkrect($hwnd)
Local $arect[5]
Local $trect = DllStructCreate($tagrect)
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then

$arect[0] = _sendmessage($hwnd, $lvm_getinsertma


rkrect, 0, $trect, 0, "wparam", "struct*") <> 0
Else
Local $irect = DllStructGetSize($trect)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $irect, $tmemma
p)
$arect[0] = _sendmessage($hwnd, $lvm_getinsertma
rkrect, 0, $pmemory, 0, "wparam", "ptr") <> 0
_memread($tmemmap, $pmemory, $trect, $irect)
_memfree($tmemmap)
EndIf
Else
$arect[0] = GUICtrlSendMsg($hwnd, $lvm_getinsertmarkrect
, 0, DllStructGetPtr($trect)) <> 0
EndIf
$arect[1] = DllStructGetData($trect, "Left")
$arect[2] = DllStructGetData($trect, "Top")
$arect[3] = DllStructGetData($trect, "Right")
$arect[4] = DllStructGetData($trect, "Bottom")
Return $arect
EndFunc
Func _guictrllistview_getisearchstring($hwnd)
Local $bunicode = _guictrllistview_getunicodeformat($hwnd)
Local $ibuffer
If IsHWnd($hwnd) Then
If $bunicode Then
$ibuffer = _sendmessage($hwnd, $lvm_getisearchst
ringw) + 1
Else
$ibuffer = _sendmessage($hwnd, $lvm_getisearchst
ringa) + 1
EndIf
Else
If $bunicode Then
$ibuffer = GUICtrlSendMsg($hwnd, $lvm_getisearch
stringw, 0, 0) + 1
Else
$ibuffer = GUICtrlSendMsg($hwnd, $lvm_getisearch
stringa, 0, 0) + 1
EndIf
EndIf
If $ibuffer = 1 Then Return ""
Local $tbuffer
If $bunicode Then
$tbuffer = DllStructCreate("wchar Text[" & $ibuffer & "]
")
$ibuffer *= 2
Else
$tbuffer = DllStructCreate("char Text[" & $ibuffer & "]"
)
EndIf
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
_sendmessage($hwnd, $lvm_getisearchstringw, 0, $
tbuffer, 0, "wparam", "struct*")
Else
Local $tmemmap
Local $pmemory = _meminit($hwnd, $ibuffer, $tmem

map)

If $bunicode Then
_sendmessage($hwnd, $lvm_getisearchstrin

gw, 0, $pmemory)

Else

ga, 0, $pmemory)

Else

$pbuffer)
$pbuffer)

EndFunc

EndIf

_sendmessage($hwnd, $lvm_getisearchstrin

EndIf
_memread($tmemmap, $pmemory, $tbuffer, $ibuffer)
_memfree($tmemmap)

Local $pbuffer = DllStructGetPtr($tbuffer)


If $bunicode Then
GUICtrlSendMsg($hwnd, $lvm_getisearchstringw, 0,
Else

GUICtrlSendMsg($hwnd, $lvm_getisearchstringa, 0,

EndIf
EndIf
Return DllStructGetData($tbuffer, "Text")

Func _guictrllistview_getitem($hwnd, $iindex, $isubitem = 0)


Local $aitem[8]
Local $titem = DllStructCreate($taglvitem)
DllStructSetData($titem, "Mask", BitOR($lvif_groupid, $lvif_imag
e, $lvif_indent, $lvif_param, $lvif_state))
DllStructSetData($titem, "Item", $iindex)
DllStructSetData($titem, "SubItem", $isubitem)
DllStructSetData($titem, "StateMask", -1)
_guictrllistview_getitemex($hwnd, $titem)
Local $istate = DllStructGetData($titem, "State")
If BitAND($istate, $lvis_cut) <> 0 Then $aitem[0] = BitOR($aitem
[0], 1)
If BitAND($istate, $lvis_drophilited) <> 0 Then $aitem[0] = BitO
R($aitem[0], 2)
If BitAND($istate, $lvis_focused) <> 0 Then $aitem[0] = BitOR($a
item[0], 4)
If BitAND($istate, $lvis_selected) <> 0 Then $aitem[0] = BitOR($
aitem[0], 8)
$aitem[1] = __guictrllistview_overlayimagemasktoindex($istate)
$aitem[2] = __guictrllistview_stateimagemasktoindex($istate)
$aitem[3] = _guictrllistview_getitemtext($hwnd, $iindex, $isubit
em)
$aitem[4] = DllStructGetData($titem, "Image")
$aitem[5] = DllStructGetData($titem, "Param")
$aitem[6] = DllStructGetData($titem, "Indent")
$aitem[7] = DllStructGetData($titem, "GroupID")
Return $aitem
EndFunc
Func _guictrllistview_getitemchecked($hwnd, $iindex)
Local $bunicode = _guictrllistview_getunicodeformat($hwnd)
Local $tlvitem = DllStructCreate($taglvitem)
Local $isize = DllStructGetSize($tlvitem)
If @error Then Return SetError($lv_err, $lv_err, False)
DllStructSetData($tlvitem, "Mask", $lvif_state)
DllStructSetData($tlvitem, "Item", $iindex)

DllStructSetData($tlvitem, "StateMask", 65535)


Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
$iret = _sendmessage($hwnd, $lvm_getitemw, 0, $t
lvitem, 0, "wparam", "struct*") <> 0
Else
Local $tmemmap
Local $pmemory = _meminit($hwnd, $isize, $tmemma
p)
_memwrite($tmemmap, $tlvitem)
If $bunicode Then
$iret = _sendmessage($hwnd, $lvm_getitem
w, 0, $pmemory, 0, "wparam", "ptr") <> 0
Else
$iret = _sendmessage($hwnd, $lvm_getitem
a, 0, $pmemory, 0, "wparam", "ptr") <> 0
EndIf
_memread($tmemmap, $pmemory, $tlvitem, $isize)
_memfree($tmemmap)
EndIf
Else
Local $pitem = DllStructGetPtr($tlvitem)
If $bunicode Then
$iret = GUICtrlSendMsg($hwnd, $lvm_getitemw, 0,
$pitem) <> 0
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_getitema, 0,
$pitem) <> 0
EndIf
EndIf
If NOT $iret Then Return SetError($lv_err, $lv_err, False)
Return BitAND(DllStructGetData($tlvitem, "State"), 8192) <> 0
EndFunc
Func _guictrllistview_getitemcount($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_getitemcount)
Else
Return GUICtrlSendMsg($hwnd, $lvm_getitemcount, 0, 0)
EndIf
EndFunc

<> 0

Func _guictrllistview_getitemcut($hwnd, $iindex)


Return _guictrllistview_getitemstate($hwnd, $iindex, $lvis_cut)
EndFunc

Func _guictrllistview_getitemdrophilited($hwnd, $iindex)


Return _guictrllistview_getitemstate($hwnd, $iindex, $lvis_droph
ilited) <> 0
EndFunc
Func _guictrllistview_getitemex($hwnd, ByRef $titem)
Local $bunicode = _guictrllistview_getunicodeformat($hwnd)
Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
$iret = _sendmessage($hwnd, $lvm_getitemw, 0, $t
item, 0, "wparam", "struct*")

Else

p)

memory, 0, "wparam", "ptr")


memory, 0, "wparam", "ptr")

Else

$pitem)

EndIf

EndFunc

_memwrite($tmemmap, $titem)
If $bunicode Then
_sendmessage($hwnd, $lvm_getitemw, 0, $p
Else

_sendmessage($hwnd, $lvm_getitema, 0, $p

EndIf
_memread($tmemmap, $pmemory, $titem, $iitem)
_memfree($tmemmap)

Local $pitem = DllStructGetPtr($titem)


If $bunicode Then
$iret = GUICtrlSendMsg($hwnd, $lvm_getitemw, 0,
Else

$pitem)

Local $iitem = DllStructGetSize($titem)


Local $tmemmap
Local $pmemory = _meminit($hwnd, $iitem, $tmemma

$iret = GUICtrlSendMsg($hwnd, $lvm_getitema, 0,

EndIf
EndIf
Return $iret <> 0

Func _guictrllistview_getitemfocused($hwnd, $iindex)


Return _guictrllistview_getitemstate($hwnd, $iindex, $lvis_focus
ed) <> 0
EndFunc
Func _guictrllistview_getitemgroupid($hwnd, $iindex)
Local $titem = DllStructCreate($taglvitem)
DllStructSetData($titem, "Mask", $lvif_groupid)
DllStructSetData($titem, "Item", $iindex)
_guictrllistview_getitemex($hwnd, $titem)
Return DllStructGetData($titem, "GroupID")
EndFunc
Func _guictrllistview_getitemimage($hwnd, $iindex, $isubitem = 0)
Local $titem = DllStructCreate($taglvitem)
DllStructSetData($titem, "Mask", $lvif_image)
DllStructSetData($titem, "Item", $iindex)
DllStructSetData($titem, "SubItem", $isubitem)
_guictrllistview_getitemex($hwnd, $titem)
Return DllStructGetData($titem, "Image")
EndFunc
Func _guictrllistview_getitemindent($hwnd, $iindex)
Local $titem = DllStructCreate($taglvitem)
DllStructSetData($titem, "Mask", $lvif_indent)
DllStructSetData($titem, "Item", $iindex)
_guictrllistview_getitemex($hwnd, $titem)
Return DllStructGetData($titem, "Indent")
EndFunc
Func __guictrllistview_getitemoverlayimage($hwnd, $iindex)

Return BitShift(_guictrllistview_getitemstate($hwnd, $iindex, $l


vis_overlaymask), 8)
EndFunc
Func _guictrllistview_getitemparam($hwnd, $iindex)
Local $titem = DllStructCreate($taglvitem)
DllStructSetData($titem, "Mask", $lvif_param)
DllStructSetData($titem, "Item", $iindex)
_guictrllistview_getitemex($hwnd, $titem)
Return DllStructGetData($titem, "Param")
EndFunc
Func _guictrllistview_getitemposition($hwnd, $iindex)
Local $apoint[2], $iret
Local $tpoint = DllStructCreate($tagpoint)
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
If NOT _sendmessage($hwnd, $lvm_getitemposition,
$iindex, $tpoint, 0, "wparam", "struct*") Then Return $apoint
Else
Local $ipoint = DllStructGetSize($tpoint)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $ipoint, $tmemm
ap)
If NOT _sendmessage($hwnd, $lvm_getitemposition,
$iindex, $pmemory, 0, "wparam", "ptr") Then Return $apoint
_memread($tmemmap, $pmemory, $tpoint, $ipoint)
_memfree($tmemmap)
EndIf
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_getitemposition, $iin
dex, DllStructGetPtr($tpoint))
If NOT $iret Then Return $apoint
EndIf
$apoint[0] = DllStructGetData($tpoint, "X")
$apoint[1] = DllStructGetData($tpoint, "Y")
Return $apoint
EndFunc
Func _guictrllistview_getitempositionx($hwnd, $iindex)
Local $apoint = _guictrllistview_getitemposition($hwnd, $iindex)
Return $apoint[0]
EndFunc
Func _guictrllistview_getitempositiony($hwnd, $iindex)
Local $apoint = _guictrllistview_getitemposition($hwnd, $iindex)
Return $apoint[1]
EndFunc

part)

Func _guictrllistview_getitemrect($hwnd, $iindex, $ipart = 3)


Local $trect = _guictrllistview_getitemrectex($hwnd, $iindex, $i

EndFunc

Local $arect[4]
$arect[0] = DllStructGetData($trect,
$arect[1] = DllStructGetData($trect,
$arect[2] = DllStructGetData($trect,
$arect[3] = DllStructGetData($trect,
Return $arect

"Left")
"Top")
"Right")
"Bottom")

Func _guictrllistview_getitemrectex($hwnd, $iindex, $ipart = 3)


Local $trect = DllStructCreate($tagrect)
DllStructSetData($trect, "Left", $ipart)
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
_sendmessage($hwnd, $lvm_getitemrect, $iindex, $
trect, 0, "wparam", "struct*")
Else
Local $irect = DllStructGetSize($trect)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $irect, $tmemma
p)
_memwrite($tmemmap, $trect, $pmemory, $irect)
_sendmessage($hwnd, $lvm_getitemrect, $iindex, $
pmemory, 0, "wparam", "ptr")
_memread($tmemmap, $pmemory, $trect, $irect)
_memfree($tmemmap)
EndIf
Else
GUICtrlSendMsg($hwnd, $lvm_getitemrect, $iindex, DllStru
ctGetPtr($trect))
EndIf
Return $trect
EndFunc
Func _guictrllistview_getitemselected($hwnd, $iindex)
Return _guictrllistview_getitemstate($hwnd, $iindex, $lvis_selec
ted) <> 0
EndFunc

ll)

Func _guictrllistview_getitemspacing($hwnd, $bsmall = False)


Local $ispace
If IsHWnd($hwnd) Then
$ispace = _sendmessage($hwnd, $lvm_getitemspacing, $bsma
Else

mall, 0)

EndFunc

$ispace = GUICtrlSendMsg($hwnd, $lvm_getitemspacing, $bs

EndIf
Local $aspace[2]
$aspace[0] = BitAND($ispace, 65535)
$aspace[1] = BitShift($ispace, 16)
Return $aspace

Func _guictrllistview_getitemspacingx($hwnd, $bsmall = False)


If IsHWnd($hwnd) Then
Return BitAND(_sendmessage($hwnd, $lvm_getitemspacing, $
bsmall, 0), 65535)
Else
Return BitAND(GUICtrlSendMsg($hwnd, $lvm_getitemspacing,
$bsmall, 0), 65535)
EndIf
EndFunc
Func _guictrllistview_getitemspacingy($hwnd, $bsmall = False)
If IsHWnd($hwnd) Then
Return BitShift(_sendmessage($hwnd, $lvm_getitemspacing,
$bsmall, 0), 16)
Else

g, $bsmall, 0), 16)


EndIf
EndFunc

imask)

Return BitShift(GUICtrlSendMsg($hwnd, $lvm_getitemspacin

Func _guictrllistview_getitemstate($hwnd, $iindex, $imask)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_getitemstate, $iindex, $
Else

$imask)
EndFunc

Return GUICtrlSendMsg($hwnd, $lvm_getitemstate, $iindex,

EndIf

Func _guictrllistview_getitemstateimage($hwnd, $iindex)


Return BitShift(_guictrllistview_getitemstate($hwnd, $iindex, $l
vis_stateimagemask), 12)
EndFunc
Func _guictrllistview_getitemtext($hwnd, $iindex, $isubitem = 0)
Local $bunicode = _guictrllistview_getunicodeformat($hwnd)
Local $tbuffer
If $bunicode Then
$tbuffer = DllStructCreate("wchar Text[4096]")
Else
$tbuffer = DllStructCreate("char Text[4096]")
EndIf
Local $pbuffer = DllStructGetPtr($tbuffer)
Local $titem = DllStructCreate($taglvitem)
DllStructSetData($titem, "SubItem", $isubitem)
DllStructSetData($titem, "TextMax", 4096)
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
DllStructSetData($titem, "Text", $pbuffer)
_sendmessage($hwnd, $lvm_getitemtextw, $iindex,
$titem, 0, "wparam", "struct*")
Else
Local $iitem = DllStructGetSize($titem)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $iitem + 4096,
$tmemmap)
Local $ptext = $pmemory + $iitem
DllStructSetData($titem, "Text", $ptext)
_memwrite($tmemmap, $titem, $pmemory, $iitem)
If $bunicode Then
_sendmessage($hwnd, $lvm_getitemtextw, $
iindex, $pmemory, 0, "wparam", "ptr")
Else
_sendmessage($hwnd, $lvm_getitemtexta, $
iindex, $pmemory, 0, "wparam", "ptr")
EndIf
_memread($tmemmap, $ptext, $tbuffer, 4096)
_memfree($tmemmap)
EndIf
Else
Local $pitem = DllStructGetPtr($titem)
DllStructSetData($titem, "Text", $pbuffer)
If $bunicode Then
GUICtrlSendMsg($hwnd, $lvm_getitemtextw, $iindex

, $pitem)
, $pitem)

EndFunc

Else

GUICtrlSendMsg($hwnd, $lvm_getitemtexta, $iindex

EndIf
EndIf
Return DllStructGetData($tbuffer, "Text")

Func _guictrllistview_getitemtextarray($hwnd, $iitem = -1)


Local $sitems = _guictrllistview_getitemtextstring($hwnd, $iitem

EndFunc

If $sitems = "" Then


Local $aitems[1] = [0]
Return SetError($lv_err, $lv_err, $aitems)
EndIf
Return StringSplit($sitems, Opt("GUIDataSeparatorChar"))

Func _guictrllistview_getitemtextstring($hwnd, $iitem = -1)


Local $srow = "", $sseparatorchar = Opt("GUIDataSeparatorChar"),
$iselected
If $iitem = -1 Then
$iselected = _guictrllistview_getnextitem($hwnd)
Else
$iselected = $iitem
EndIf
For $x = 0 To _guictrllistview_getcolumncount($hwnd) - 1
$srow &= _guictrllistview_getitemtext($hwnd, $iselected,
$x) & $sseparatorchar
Next
Return StringTrimRight($srow, 1)
EndFunc
Func _guictrllistview_getnextitem($hwnd, $istart = -1, $isearch = 0, $is
tate = 8)
Local $asearch[5] = [$lvni_all, $lvni_above, $lvni_below, $lvni_
toleft, $lvni_toright]
Local $iflags = $asearch[$isearch]
If BitAND($istate, 1) <> 0 Then $iflags = BitOR($iflags, $lvni_c
ut)
If BitAND($istate, 2) <> 0 Then $iflags = BitOR($iflags, $lvni_d
rophilited)
If BitAND($istate, 4) <> 0 Then $iflags = BitOR($iflags, $lvni_f
ocused)
If BitAND($istate, 8) <> 0 Then $iflags = BitOR($iflags, $lvni_s
elected)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_getnextitem, $istart, $i
flags)
Else
Return GUICtrlSendMsg($hwnd, $lvm_getnextitem, $istart,
$iflags)
EndIf
EndFunc
Func _guictrllistview_getnumberofworkareas($hwnd)
Local $tbuffer = DllStructCreate("int Data")
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then

_sendmessage($hwnd, $lvm_getnumberofworkareas, 0
, $tbuffer, 0, "wparam", "struct*")
Else
Local $ibuffer = DllStructGetSize($tbuffer)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $ibuffer, $tmem
map)
_sendmessage($hwnd, $lvm_getnumberofworkareas, 0
, $pmemory, 0, "wparam", "ptr")
_memread($tmemmap, $pmemory, $tbuffer, $ibuffer)
_memfree($tmemmap)
EndIf
Else
GUICtrlSendMsg($hwnd, $lvm_getnumberofworkareas, 0, DllS
tructGetPtr($tbuffer))
EndIf
Return DllStructGetData($tbuffer, "Data")
EndFunc
Func _guictrllistview_getorigin($hwnd)
Local $tpoint = DllStructCreate($tagpoint)
Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
$iret = _sendmessage($hwnd, $lvm_getorigin, 0, $
tpoint, 0, "wparam", "struct*")
Else
Local $ipoint = DllStructGetSize($tpoint)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $ipoint, $tmemm
ap)
$iret = _sendmessage($hwnd, $lvm_getorigin, 0, $
pmemory, 0, "wparam", "ptr")
_memread($tmemmap, $pmemory, $tpoint, $ipoint)
_memfree($tmemmap)
EndIf
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_getorigin, 0, DllStru
ctGetPtr($tpoint))
EndIf
Local $aorigin[2]
$aorigin[0] = DllStructGetData($tpoint, "X")
$aorigin[1] = DllStructGetData($tpoint, "Y")
Return SetError(@error, $iret = 1, $aorigin)
EndFunc
Func _guictrllistview_getoriginx($hwnd)
Local $aorigin = _guictrllistview_getorigin($hwnd)
Return $aorigin[0]
EndFunc
Func _guictrllistview_getoriginy($hwnd)
Local $aorigin = _guictrllistview_getorigin($hwnd)
Return $aorigin[1]
EndFunc
Func _guictrllistview_getoutlinecolor($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_getoutlinecolor)
Else

EndFunc

0)

Return GUICtrlSendMsg($hwnd, $lvm_getoutlinecolor, 0, 0)

Func _guictrllistview_getselectedcolumn($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_getselectedcolumn)
Else
Return GUICtrlSendMsg($hwnd, $lvm_getselectedcolumn, 0,
EndFunc

EndIf

EndIf

Func _guictrllistview_getselectedcount($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_getselectedcount)
Else
Return GUICtrlSendMsg($hwnd, $lvm_getselectedcount, 0, 0
EndFunc

EndIf

Func __guictrllistview_getcheckedindices($hwnd)
Local $icount = _guictrllistview_getitemcount($hwnd)
Local $aselected[$icount + 1] = [0]
For $i = 0 To $icount - 1
If _guictrllistview_getitemchecked($hwnd, $i) Then
$aselected[0] += 1
$aselected[$aselected[0]] = $i
EndIf
Next
ReDim $aselected[$aselected[0] + 1]
Return $aselected
EndFunc
Func _guictrllistview_getselectedindices($hwnd, $barray = False)
Local $sindices, $aindices[1] = [0]
Local $iret, $icount = _guictrllistview_getitemcount($hwnd)
For $iitem = 0 To $icount
If IsHWnd($hwnd) Then
$iret = _sendmessage($hwnd, $lvm_getitemstate, $
iitem, $lvis_selected)
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_getitemstate,
$iitem, $lvis_selected)
EndIf
If $iret Then
If (NOT $barray) Then
If StringLen($sindices) Then
$sindices &= "|" & $iitem
Else
$sindices = $iitem
EndIf
Else
ReDim $aindices[UBound($aindices) + 1]
$aindices[0] = UBound($aindices) - 1
$aindices[UBound($aindices) - 1] = $iite
m
EndIf
EndIf

EndFunc

Func _guictrllistview_getselectionmark($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_getselectionmark)
Else
Return GUICtrlSendMsg($hwnd, $lvm_getselectionmark, 0, 0
EndFunc

")

Next
If (NOT $barray) Then
Return String($sindices)
Else
Return $aindices
EndIf

EndIf

Func _guictrllistview_getstringwidth($hwnd, $sstring)


Local $bunicode = _guictrllistview_getunicodeformat($hwnd)
Local $ibuffer = StringLen($sstring) + 1
Local $tbuffer
If $bunicode Then
$tbuffer = DllStructCreate("wchar Text[" & $ibuffer & "]
Else

$ibuffer *= 2
$tbuffer = DllStructCreate("char Text[" & $ibuffer & "]"

EndIf
DllStructSetData($tbuffer, "Text", $sstring)
Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
$iret = _sendmessage($hwnd, $lvm_getstringwidthw
, 0, $tbuffer, 0, "wparam", "struct*")
Else
Local $tmemmap
Local $pmemory = _meminit($hwnd, $ibuffer, $tmem
map)
_memwrite($tmemmap, $tbuffer, $pmemory, $ibuffer
)
If $bunicode Then
$iret = _sendmessage($hwnd, $lvm_getstri
ngwidthw, 0, $pmemory, 0, "wparam", "ptr")
Else
$iret = _sendmessage($hwnd, $lvm_getstri
ngwidtha, 0, $pmemory, 0, "wparam", "ptr")
EndIf
_memread($tmemmap, $pmemory, $tbuffer, $ibuffer)
_memfree($tmemmap)
EndIf
Else
Local $pbuffer = DllStructGetPtr($tbuffer)
If $bunicode Then
$iret = GUICtrlSendMsg($hwnd, $lvm_getstringwidt
hw, 0, $pbuffer)
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_getstringwidt
ha, 0, $pbuffer)
EndIf

EndFunc
0)

EndIf
Return $iret

Func _guictrllistview_getsubitemrect($hwnd, $iindex, $isubitem, $ipart =

Local $apart[2] = [$lvir_bounds, $lvir_icon]


Local $trect = DllStructCreate($tagrect)
DllStructSetData($trect, "Top", $isubitem)
DllStructSetData($trect, "Left", $apart[$ipart])
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
_sendmessage($hwnd, $lvm_getsubitemrect, $iindex
, $trect, 0, "wparam", "struct*")
Else
Local $irect = DllStructGetSize($trect)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $irect, $tmemma
p)
_memwrite($tmemmap, $trect, $pmemory, $irect)
_sendmessage($hwnd, $lvm_getsubitemrect, $iindex
, $pmemory, 0, "wparam", "ptr")
_memread($tmemmap, $pmemory, $trect, $irect)
_memfree($tmemmap)
EndIf
Else
GUICtrlSendMsg($hwnd, $lvm_getsubitemrect, $iindex, DllS
tructGetPtr($trect))
EndIf
Local $arect[4]
$arect[0] = DllStructGetData($trect, "Left")
$arect[1] = DllStructGetData($trect, "Top")
$arect[2] = DllStructGetData($trect, "Right")
$arect[3] = DllStructGetData($trect, "Bottom")
Return $arect
EndFunc
Func _guictrllistview_gettextbkcolor($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_gettextbkcolor)
Else
Return GUICtrlSendMsg($hwnd, $lvm_gettextbkcolor, 0, 0)
EndIf
EndFunc
Func _guictrllistview_gettextcolor($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_gettextcolor)
Else
Return GUICtrlSendMsg($hwnd, $lvm_gettextcolor, 0, 0)
EndIf
EndFunc

))

Func _guictrllistview_gettooltips($hwnd)
If IsHWnd($hwnd) Then
Return HWnd(_sendmessage($hwnd, $lvm_gettooltips))
Else
Return HWnd(GUICtrlSendMsg($hwnd, $lvm_gettooltips, 0, 0
EndIf

EndFunc
Func _guictrllistview_gettopindex($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_gettopindex)
Else
Return GUICtrlSendMsg($hwnd, $lvm_gettopindex, 0, 0)
EndIf
EndFunc

) <> 0

Func _guictrllistview_getunicodeformat($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_getunicodeformat) <> 0
Else
Return GUICtrlSendMsg($hwnd, $lvm_getunicodeformat, 0, 0
EndFunc

EndIf

Func _guictrllistview_getview($hwnd)
Local $iview
If IsHWnd($hwnd) Then
$iview = _sendmessage($hwnd, $lvm_getview)
Else
$iview = GUICtrlSendMsg($hwnd, $lvm_getview, 0, 0)
EndIf
Switch $iview
Case $lv_view_icon
Return Int($lv_view_icon)
Case $lv_view_details
Return Int($lv_view_details)
Case $lv_view_list
Return Int($lv_view_list)
Case $lv_view_smallicon
Return Int($lv_view_smallicon)
Case $lv_view_tile
Return Int($lv_view_tile)
Case Else
Return -1
EndSwitch
EndFunc
Func _guictrllistview_getviewdetails($hwnd)
Return _guictrllistview_getview($hwnd) = $lv_view_details
EndFunc
Func _guictrllistview_getviewlarge($hwnd)
Return _guictrllistview_getview($hwnd) = $lv_view_icon
EndFunc
Func _guictrllistview_getviewlist($hwnd)
Return _guictrllistview_getview($hwnd) = $lv_view_list
EndFunc
Func _guictrllistview_getviewsmall($hwnd)
Return _guictrllistview_getview($hwnd) = $lv_view_smallicon
EndFunc
Func _guictrllistview_getviewtile($hwnd)
Return _guictrllistview_getview($hwnd) = $lv_view_tile

EndFunc
Func _guictrllistview_getviewrect($hwnd)
Local $arect[4] = [0, 0, 0, 0]
Local $iview = _guictrllistview_getview($hwnd)
If ($iview <> 1) AND ($iview <> 3) Then Return $arect
Local $trect = DllStructCreate($tagrect)
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
_sendmessage($hwnd, $lvm_getviewrect, 0, $trect,
0, "wparam", "struct*")
Else
Local $irect = DllStructGetSize($trect)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $irect, $tmemma
p)
_sendmessage($hwnd, $lvm_getviewrect, 0, $pmemor
y, 0, "wparam", "ptr")
_memread($tmemmap, $pmemory, $trect, $irect)
_memfree($tmemmap)
EndIf
Else
GUICtrlSendMsg($hwnd, $lvm_getviewrect, 0, DllStructGetP
tr($trect))
EndIf
$arect[0] = DllStructGetData($trect, "Left")
$arect[1] = DllStructGetData($trect, "Top")
$arect[2] = DllStructGetData($trect, "Right")
$arect[3] = DllStructGetData($trect, "Bottom")
Return $arect
EndFunc

> 0

Func _guictrllistview_hidecolumn($hwnd, $icol)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_setcolumnwidth, $icol) <
Else

0) <> 0
EndFunc

Return GUICtrlSendMsg($hwnd, $lvm_setcolumnwidth, $icol,

EndIf

Func _guictrllistview_hittest($hwnd, $ix = -1, $iy = -1)


Local $atest[10]
Local $imode = Opt("MouseCoordMode", 1)
Local $apos = MouseGetPos()
Opt("MouseCoordMode", $imode)
Local $tpoint = DllStructCreate($tagpoint)
DllStructSetData($tpoint, "X", $apos[0])
DllStructSetData($tpoint, "Y", $apos[1])
Local $aresult = DllCall("user32.dll", "bool", "ScreenToClient",
"hwnd", $hwnd, "struct*", $tpoint)
If @error Then Return SetError(@error, @extended, 0)
If $aresult[0] = 0 Then Return 0
If $ix = -1 Then $ix = DllStructGetData($tpoint, "X")
If $iy = -1 Then $iy = DllStructGetData($tpoint, "Y")
Local $ttest = DllStructCreate($taglvhittestinfo)
DllStructSetData($ttest, "X", $ix)
DllStructSetData($ttest, "Y", $iy)
If IsHWnd($hwnd) Then

If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then


$atest[0] = _sendmessage($hwnd, $lvm_hittest, 0,
$ttest, 0, "wparam", "struct*")
Else
Local $itest = DllStructGetSize($ttest)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $itest, $tmemma
p)
_memwrite($tmemmap, $ttest, $pmemory, $itest)
$atest[0] = _sendmessage($hwnd, $lvm_hittest, 0,
$pmemory, 0, "wparam", "ptr")
_memread($tmemmap, $pmemory, $ttest, $itest)
_memfree($tmemmap)
EndIf
Else
$atest[0] = GUICtrlSendMsg($hwnd, $lvm_hittest, 0, DllSt
ructGetPtr($ttest))
EndIf
Local $iflags = DllStructGetData($ttest, "Flags")
$atest[1] = BitAND($iflags, $lvht_nowhere) <> 0
$atest[2] = BitAND($iflags, $lvht_onitemicon) <> 0
$atest[3] = BitAND($iflags, $lvht_onitemlabel) <> 0
$atest[4] = BitAND($iflags, $lvht_onitemstateicon) <> 0
$atest[5] = BitAND($iflags, $lvht_onitem) <> 0
$atest[6] = BitAND($iflags, $lvht_above) <> 0
$atest[7] = BitAND($iflags, $lvht_below) <> 0
$atest[8] = BitAND($iflags, $lvht_toleft) <> 0
$atest[9] = BitAND($iflags, $lvht_toright) <> 0
Return $atest
EndFunc
Func __guictrllistview_indextooverlayimagemask($iindex)
Return BitShift($iindex, -8)
EndFunc
Func __guictrllistview_indextostateimagemask($iindex)
Return BitShift($iindex, -12)
EndFunc
Func _guictrllistview_insertcolumn($hwnd, $iindex, $stext, $iwidth = 50,
$ialign = -1, $iimage = -1, $bonright = False)
Local $aalign[3] = [$lvcfmt_left, $lvcfmt_right, $lvcfmt_center]
Local $bunicode = _guictrllistview_getunicodeformat($hwnd)
Local $ibuffer = StringLen($stext) + 1
Local $tbuffer
If $bunicode Then
$tbuffer = DllStructCreate("wchar Text[" & $ibuffer & "]
")
$ibuffer *= 2
Else
$tbuffer = DllStructCreate("char Text[" & $ibuffer & "]"
)
EndIf
Local $pbuffer = DllStructGetPtr($tbuffer)
Local $tcolumn = DllStructCreate($taglvcolumn)
Local $imask = BitOR($lvcf_fmt, $lvcf_width, $lvcf_text)
If $ialign < 0 OR $ialign > 2 Then $ialign = 0
Local $ifmt = $aalign[$ialign]
If $iimage <> -1 Then
$imask = BitOR($imask, $lvcf_image)

ge)

$ifmt = BitOR($ifmt, $lvcfmt_col_has_images, $lvcfmt_ima

EndIf
If $bonright Then $ifmt = BitOR($ifmt, $lvcfmt_bitmap_on_right)
DllStructSetData($tbuffer, "Text", $stext)
DllStructSetData($tcolumn, "Mask", $imask)
DllStructSetData($tcolumn, "Fmt", $ifmt)
DllStructSetData($tcolumn, "CX", $iwidth)
DllStructSetData($tcolumn, "TextMax", $ibuffer)
DllStructSetData($tcolumn, "Image", $iimage)
Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
DllStructSetData($tcolumn, "Text", $pbuffer)
$iret = _sendmessage($hwnd, $lvm_insertcolumnw,
$iindex, $tcolumn, 0, "wparam", "struct*")
Else
Local $icolumn = DllStructGetSize($tcolumn)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $icolumn + $ibu
ffer, $tmemmap)
Local $ptext = $pmemory + $icolumn
DllStructSetData($tcolumn, "Text", $ptext)
_memwrite($tmemmap, $tcolumn, $pmemory, $icolumn
)
_memwrite($tmemmap, $tbuffer, $ptext, $ibuffer)
If $bunicode Then
$iret = _sendmessage($hwnd, $lvm_insertc
olumnw, $iindex, $pmemory, 0, "wparam", "ptr")
Else
$iret = _sendmessage($hwnd, $lvm_insertc
olumna, $iindex, $pmemory, 0, "wparam", "ptr")
EndIf
_memfree($tmemmap)
EndIf
Else
Local $pcolumn = DllStructGetPtr($tcolumn)
DllStructSetData($tcolumn, "Text", $pbuffer)
If $bunicode Then
$iret = GUICtrlSendMsg($hwnd, $lvm_insertcolumnw
, $iindex, $pcolumn)
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_insertcolumna
, $iindex, $pcolumn)
EndIf
EndIf
If $ialign > 0 Then _guictrllistview_setcolumn($hwnd, $iret, $st
ext, $iwidth, $ialign, $iimage, $bonright)
Return $iret
EndFunc
Func _guictrllistview_insertgroup($hwnd, $iindex, $igroupid, $sheader, $
ialign = 0)
Local $aalign[3] = [$lvga_header_left, $lvga_header_center, $lvg
a_header_right]
If $ialign < 0 OR $ialign > 2 Then $ialign = 0
Local $theader = _winapi_multibytetowidechar($sheader)
Local $pheader = DllStructGetPtr($theader)
Local $iheader = StringLen($sheader)
Local $tgroup = DllStructCreate($taglvgroup)

Local $igroup = DllStructGetSize($tgroup)


Local $imask = BitOR($lvgf_header, $lvgf_align, $lvgf_groupid)
DllStructSetData($tgroup, "Size", $igroup)
DllStructSetData($tgroup, "Mask", $imask)
DllStructSetData($tgroup, "HeaderMax", $iheader)
DllStructSetData($tgroup, "GroupID", $igroupid)
DllStructSetData($tgroup, "Align", $aalign[$ialign])
Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
DllStructSetData($tgroup, "Header", $pheader)
$iret = _sendmessage($hwnd, $lvm_insertgroup, $i
index, $tgroup, 0, "wparam", "struct*")
Else
Local $tmemmap
Local $pmemory = _meminit($hwnd, $igroup + $ihea
der, $tmemmap)
Local $ptext = $pmemory + $igroup
DllStructSetData($tgroup, "Header", $ptext)
_memwrite($tmemmap, $tgroup, $pmemory, $igroup)
_memwrite($tmemmap, $theader, $ptext, $iheader)
$iret = _sendmessage($hwnd, $lvm_insertgroup, $i
index, $tgroup, 0, "wparam", "struct*")
_memfree($tmemmap)
EndIf
Else
DllStructSetData($tgroup, "Header", $pheader)
$iret = GUICtrlSendMsg($hwnd, $lvm_insertgroup, $iindex,
DllStructGetPtr($tgroup))
EndIf
Return $iret
EndFunc
Func _guictrllistview_insertitem($hwnd, $stext, $iindex = -1, $iimage =
-1, $iparam = 0)
Local $bunicode = _guictrllistview_getunicodeformat($hwnd)
Local $ibuffer, $tbuffer, $iret
If $iindex = -1 Then $iindex = 999999999
Local $titem = DllStructCreate($taglvitem)
DllStructSetData($titem, "Param", $iparam)
$ibuffer = StringLen($stext) + 1
If $bunicode Then
$tbuffer = DllStructCreate("wchar Text[" & $ibuffer & "]
")
$ibuffer *= 2
Else
$tbuffer = DllStructCreate("char Text[" & $ibuffer & "]"
)
EndIf
DllStructSetData($tbuffer, "Text", $stext)
DllStructSetData($titem, "Text", DllStructGetPtr($tbuffer))
DllStructSetData($titem, "TextMax", $ibuffer)
Local $imask = BitOR($lvif_text, $lvif_param)
If $iimage >= 0 Then $imask = BitOR($imask, $lvif_image)
DllStructSetData($titem, "Mask", $imask)
DllStructSetData($titem, "Item", $iindex)
DllStructSetData($titem, "Image", $iimage)
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) OR ($stext
= -1) Then

$titem, 0, "wparam", "struct*")


Else

er, $tmemmap)

$iret = _sendmessage($hwnd, $lvm_insertitemw, 0,


Local $iitem = DllStructGetSize($titem)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $iitem + $ibuff

Local $ptext = $pmemory + $iitem


DllStructSetData($titem, "Text", $ptext)
_memwrite($tmemmap, $titem, $pmemory, $iitem)
_memwrite($tmemmap, $tbuffer, $ptext, $ibuffer)
If $bunicode Then
$iret = _sendmessage($hwnd, $lvm_inserti
temw, 0, $pmemory, 0, "wparam", "ptr")
Else
$iret = _sendmessage($hwnd, $lvm_inserti
tema, 0, $pmemory, 0, "wparam", "ptr")
EndIf
_memfree($tmemmap)
EndIf
Else
Local $pitem = DllStructGetPtr($titem)
If $bunicode Then
$iret = GUICtrlSendMsg($hwnd, $lvm_insertitemw,
0, $pitem)
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_insertitema,
0, $pitem)
EndIf
EndIf
Return $iret
EndFunc
Func _guictrllistview_insertmarkhittest($hwnd, $ix = -1, $iy = -1)
Local $imode = Opt("MouseCoordMode", 1)
Local $apos = MouseGetPos()
Opt("MouseCoordMode", $imode)
Local $tpoint = DllStructCreate($tagpoint)
DllStructSetData($tpoint, "X", $apos[0])
DllStructSetData($tpoint, "Y", $apos[1])
Local $aresult = DllCall("user32.dll", "bool", "ScreenToClient",
"hwnd", $hwnd, "struct*", $tpoint)
If @error Then Return SetError(@error, @extended, 0)
If $aresult[0] = 0 Then Return 0
If $ix = -1 Then $ix = DllStructGetData($tpoint, "X")
If $iy = -1 Then $iy = DllStructGetData($tpoint, "Y")
Local $tmark = DllStructCreate($taglvinsertmark)
Local $imark = DllStructGetSize($tmark)
DllStructSetData($tpoint, "X", $ix)
DllStructSetData($tpoint, "Y", $iy)
DllStructSetData($tmark, "Size", $imark)
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
_sendmessage($hwnd, $lvm_insertmarkhittest, $tpo
int, $tmark, 0, "struct*", "struct*")
Else
Local $ipoint = DllStructGetSize($tpoint)
Local $tmemmap
Local $pmemm = _meminit($hwnd, $ipoint + $imark,
$tmemmap)

mp, $pmemm, 0, "wparam", "ptr")

Else

EndIf

Local $pmemp = $pmemm + $ipoint


_memwrite($tmemmap, $tmark, $pmemm, $imark)
_memwrite($tmemmap, $tpoint, $pmemp, $ipoint)
_sendmessage($hwnd, $lvm_insertmarkhittest, $pme
_memread($tmemmap, $pmemm, $tmark, $imark)
_memfree($tmemmap)

GUICtrlSendMsg($hwnd, $lvm_insertmarkhittest, DllStructG


etPtr($tpoint), DllStructGetPtr($tmark))
EndIf
Local $atest[2]
$atest[0] = DllStructGetData($tmark, "Flags") = $lvim_after
$atest[1] = DllStructGetData($tmark, "Item")
Return $atest
EndFunc

<> 0

Func _guictrllistview_isitemvisible($hwnd, $iindex)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_isitemvisible, $iindex)
Else

, 0) <> 0
EndFunc

Return GUICtrlSendMsg($hwnd, $lvm_isitemvisible, $iindex

EndIf

Func _guictrllistview_justifycolumn($hwnd, $iindex, $ialign = -1)


Local $aalign[3] = [$lvcfmt_left, $lvcfmt_right, $lvcfmt_center]
Local $bunicode = _guictrllistview_getunicodeformat($hwnd)
Local $tcolumn = DllStructCreate($taglvcolumn)
If $ialign < 0 OR $ialign > 2 Then $ialign = 0
Local $imask = $lvcf_fmt
Local $ifmt = $aalign[$ialign]
DllStructSetData($tcolumn, "Mask", $imask)
DllStructSetData($tcolumn, "Fmt", $ifmt)
Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
$iret = _sendmessage($hwnd, $lvm_setcolumnw, $ii
ndex, $tcolumn, 0, "wparam", "struct*")
Else
Local $icolumn = DllStructGetSize($tcolumn)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $icolumn, $tmem
map)
_memwrite($tmemmap, $tcolumn, $pmemory, $icolumn
)
If $bunicode Then
$iret = _sendmessage($hwnd, $lvm_setcolu
mnw, $iindex, $pmemory, 0, "wparam", "ptr")
Else
$iret = _sendmessage($hwnd, $lvm_setcolu
mna, $iindex, $pmemory, 0, "wparam", "ptr")
EndIf
_memfree($tmemmap)
EndIf
Else
Local $pcolumn = DllStructGetPtr($tcolumn)

iindex, $pcolumn)
iindex, $pcolumn)

EndFunc

If $bunicode Then
$iret = GUICtrlSendMsg($hwnd, $lvm_setcolumnw, $
Else

$iret = GUICtrlSendMsg($hwnd, $lvm_setcolumna, $

EndIf
EndIf
Return $iret <> 0

Func _guictrllistview_mapidtoindex($hwnd, $iid)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_mapidtoindex, $iid)
Else
Return GUICtrlSendMsg($hwnd, $lvm_mapidtoindex, $iid, 0)
EndIf
EndFunc

0)

Func _guictrllistview_mapindextoid($hwnd, $iindex)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_mapindextoid, $iindex)
Else
Return GUICtrlSendMsg($hwnd, $lvm_mapindextoid, $iindex,
EndFunc

index)

EndIf

Func _guictrllistview_movegroup($hwnd, $igroupid, $iindex = -1)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_movegroup, $igroupid, $i
Else

$iindex)
EndFunc

Return GUICtrlSendMsg($hwnd, $lvm_movegroup, $igroupid,

EndIf

Func __guictrllistview_overlayimagemasktoindex($imask)
Return BitShift(BitAND($lvis_overlaymask, $imask), 8)
EndFunc
Func _guictrllistview_redrawitems($hwnd, $ifirst, $ilast)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_redrawitems, $ifirst, $i
last) <> 0
Else
Return GUICtrlSendMsg($hwnd, $lvm_redrawitems, $ifirst,
$ilast) <> 0
EndIf
EndFunc
Func _guictrllistview_registersortcallback($hwnd, $bnumbers = True, $bar
rows = True)
If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
Local $hheader = _guictrllistview_getheader($hwnd)
ReDim $__g_alistviewsortinfo[UBound($__g_alistviewsortinfo) + 1]
[$__g_illistviewsortinfosize]
$__g_alistviewsortinfo[0][0] = UBound($__g_alistviewsortinfo) 1

Local $iindex = $__g_alistviewsortinfo[0][0]


$__g_alistviewsortinfo[$iindex][1] = $hwnd
$__g_alistviewsortinfo[$iindex][2] = DllCallbackRegister("__GUIC
trlListView_Sort", "int", "int;int;hwnd")
$__g_alistviewsortinfo[$iindex][3] = -1
$__g_alistviewsortinfo[$iindex][4] = -1
$__g_alistviewsortinfo[$iindex][5] = 1
$__g_alistviewsortinfo[$iindex][6] = -1
$__g_alistviewsortinfo[$iindex][7] = 0
$__g_alistviewsortinfo[$iindex][8] = $bnumbers
$__g_alistviewsortinfo[$iindex][9] = $barrows
$__g_alistviewsortinfo[$iindex][10] = $hheader
Return $__g_alistviewsortinfo[$iindex][2] <> 0
EndFunc
Func _guictrllistview_removeallgroups($hwnd)
If IsHWnd($hwnd) Then
_sendmessage($hwnd, $lvm_removeallgroups)
Else
GUICtrlSendMsg($hwnd, $lvm_removeallgroups, 0, 0)
EndIf
EndFunc

, 0)

Func _guictrllistview_removegroup($hwnd, $igroupid)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_removegroup, $igroupid)
Else
Return GUICtrlSendMsg($hwnd, $lvm_removegroup, $igroupid
EndFunc

EndIf

Func __guictrllistview_reversecolororder($icolor)
Local $sh = Hex(String($icolor), 6)
Return "0x" & StringMid($sh, 5, 2) & StringMid($sh, 3, 2) & Stri
ngMid($sh, 1, 2)
EndFunc

Func _guictrllistview_scroll($hwnd, $idx, $idy)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_scroll, $idx, $idy) <> 0
Else
Return GUICtrlSendMsg($hwnd, $lvm_scroll, $idx, $idy) <>
EndFunc

r)

EndIf

Func _guictrllistview_setbkcolor($hwnd, $icolor)


Local $iret
If IsHWnd($hwnd) Then
$iret = _sendmessage($hwnd, $lvm_setbkcolor, 0, $icolor)
_winapi_invalidaterect($hwnd)
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_setbkcolor, 0, $icolo

EndFunc

_winapi_invalidaterect(GUICtrlGetHandle($hwnd))
EndIf
Return $iret <> 0

Func _guictrllistview_setbkimage($hwnd, $surl = "", $istyle = 0, $ixoffs


et = 0, $iyoffset = 0)
Local $bunicode = _guictrllistview_getunicodeformat($hwnd)
If NOT IsHWnd($hwnd) Then Return SetError($lv_err, $lv_err, Fals
e)
Local $astyle[2] = [$lvbkif_style_normal, $lvbkif_style_tile]
Local $ibuffer = StringLen($surl) + 1
Local $tbuffer
If $bunicode Then
$tbuffer = DllStructCreate("wchar Text[" & $ibuffer & "]
")
$ibuffer *= 2
Else
$tbuffer = DllStructCreate("char Text[" & $ibuffer & "]"
)
EndIf
If @error Then Return SetError($lv_err, $lv_err, $lv_err)
Local $pbuffer = DllStructGetPtr($tbuffer)
Local $timage = DllStructCreate($taglvbkimage)
Local $iret = 0
If $surl <> "" Then $iret = $lvbkif_source_url
$iret = BitOR($iret, $astyle[$istyle])
DllStructSetData($tbuffer, "Text", $surl)
DllStructSetData($timage, "Flags", $iret)
DllStructSetData($timage, "XOffPercent", $ixoffset)
DllStructSetData($timage, "YOffPercent", $iyoffset)
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
DllStructSetData($timage, "Image", $pbuffer)
$iret = _sendmessage($hwnd, $lvm_setbkimagew, 0,
$timage, 0, "wparam", "struct*")
Else
Local $iimage = DllStructGetSize($timage)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $iimage + $ibuf
fer, $tmemmap)
Local $ptext = $pmemory + $iimage
DllStructSetData($timage, "Image", $ptext)
_memwrite($tmemmap, $timage, $pmemory, $iimage)
_memwrite($tmemmap, $tbuffer, $ptext, $ibuffer)
If $bunicode Then
$iret = _sendmessage($hwnd, $lvm_setbkim
agew, 0, $pmemory, 0, "wparam", "ptr")
Else
$iret = _sendmessage($hwnd, $lvm_setbkim
agea, 0, $pmemory, 0, "wparam", "ptr")
EndIf
_memfree($tmemmap)
EndIf
Else
Local $pimage = DllStructGetPtr($timage)
DllStructSetData($timage, "Image", $pbuffer)
If $bunicode Then
$iret = GUICtrlSendMsg($hwnd, $lvm_setbkimagew,
0, $pimage)
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_setbkimagea,
0, $pimage)
EndIf
EndIf

EndFunc

t)

Return $iret <> 0

Func _guictrllistview_setcallbackmask($hwnd, $imask)


Local $iflags = 0
If BitAND($imask, 1) <> 0 Then $iflags = BitOR($iflags, $lvis_cu

ophilited)
cused)

If BitAND($imask, 2) <> 0 Then $iflags = BitOR($iflags, $lvis_dr


If BitAND($imask, 4) <> 0 Then $iflags = BitOR($iflags, $lvis_fo
If BitAND($imask, 8) <> 0 Then $iflags = BitOR($iflags, $lvis_se

lected)
verlaymask)
tateimagemask)
) <> 0

If BitAND($imask, 16) <> 0 Then $iflags = BitOR($iflags, $lvis_o


If BitAND($imask, 32) <> 0 Then $iflags = BitOR($iflags, $lvis_s
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_setcallbackmask, $iflags
Else

gs, 0) <> 0
EndFunc

Return GUICtrlSendMsg($hwnd, $lvm_setcallbackmask, $ifla

EndIf

Func _guictrllistview_setcolumn($hwnd, $iindex, $stext, $iwidth = -1, $i


align = -1, $iimage = -1, $bonright = False)
Local $bunicode = _guictrllistview_getunicodeformat($hwnd)
Local $aalign[3] = [$lvcfmt_left, $lvcfmt_right, $lvcfmt_center]
Local $ibuffer = StringLen($stext) + 1
Local $tbuffer
If $bunicode Then
$tbuffer = DllStructCreate("wchar Text[" & $ibuffer & "]
")
$ibuffer *= 2
Else
$tbuffer = DllStructCreate("char Text[" & $ibuffer & "]"
)
EndIf
Local $pbuffer = DllStructGetPtr($tbuffer)
Local $tcolumn = DllStructCreate($taglvcolumn)
Local $imask = $lvcf_text
If $ialign < 0 OR $ialign > 2 Then $ialign = 0
$imask = BitOR($imask, $lvcf_fmt)
Local $ifmt = $aalign[$ialign]
If $iwidth <> -1 Then $imask = BitOR($imask, $lvcf_width)
If $iimage <> -1 Then
$imask = BitOR($imask, $lvcf_image)
$ifmt = BitOR($ifmt, $lvcfmt_col_has_images, $lvcfmt_ima
ge)
Else
$iimage = 0
EndIf
If $bonright Then $ifmt = BitOR($ifmt, $lvcfmt_bitmap_on_right)
DllStructSetData($tbuffer, "Text", $stext)
DllStructSetData($tcolumn, "Mask", $imask)
DllStructSetData($tcolumn, "Fmt", $ifmt)
DllStructSetData($tcolumn, "CX", $iwidth)
DllStructSetData($tcolumn, "TextMax", $ibuffer)

DllStructSetData($tcolumn, "Image", $iimage)


Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
DllStructSetData($tcolumn, "Text", $pbuffer)
$iret = _sendmessage($hwnd, $lvm_setcolumnw, $ii
ndex, $tcolumn, 0, "wparam", "struct*")
Else
Local $icolumn = DllStructGetSize($tcolumn)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $icolumn + $ibu
ffer, $tmemmap)
Local $ptext = $pmemory + $icolumn
DllStructSetData($tcolumn, "Text", $ptext)
_memwrite($tmemmap, $tcolumn, $pmemory, $icolumn
)
_memwrite($tmemmap, $tbuffer, $ptext, $ibuffer)
If $bunicode Then
$iret = _sendmessage($hwnd, $lvm_setcolu
mnw, $iindex, $pmemory, 0, "wparam", "ptr")
Else
$iret = _sendmessage($hwnd, $lvm_setcolu
mna, $iindex, $pmemory, 0, "wparam", "ptr")
EndIf
_memfree($tmemmap)
EndIf
Else
Local $pcolumn = DllStructGetPtr($tcolumn)
DllStructSetData($tcolumn, "Text", $pbuffer)
If $bunicode Then
$iret = GUICtrlSendMsg($hwnd, $lvm_setcolumnw, $
iindex, $pcolumn)
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_setcolumna, $
iindex, $pcolumn)
EndIf
EndIf
Return $iret <> 0
EndFunc
Func _guictrllistview_setcolumnorder($hwnd, $sorder)
Local $sseparatorchar = Opt("GUIDataSeparatorChar")
Return _guictrllistview_setcolumnorderarray($hwnd, StringSplit($
sorder, $sseparatorchar))
EndFunc
Func _guictrllistview_setcolumnorderarray($hwnd, $aorder)
Local $tbuffer = DllStructCreate("int[" & $aorder[0] & "]")
For $ii = 1 To $aorder[0]
DllStructSetData($tbuffer, 1, $aorder[$ii], $ii)
Next
Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
$iret = _sendmessage($hwnd, $lvm_setcolumnordera
rray, $aorder[0], $tbuffer, 0, "wparam", "struct*")
Else
Local $ibuffer = DllStructGetSize($tbuffer)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $ibuffer, $tmem

map)

_memwrite($tmemmap, $tbuffer, $pmemory, $ibuffer

$iret = _sendmessage($hwnd, $lvm_setcolumnordera


rray, $aorder[0], $pmemory, 0, "wparam", "ptr")
_memfree($tmemmap)
EndIf
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_setcolumnorderarray,
$aorder[0], DllStructGetPtr($tbuffer))
EndIf
Return $iret <> 0
EndFunc

iwidth)

Func _guictrllistview_setcolumnwidth($hwnd, $icol, $iwidth)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_setcolumnwidth, $icol, $
Else

$iwidth)
EndFunc
k = 0)

Return GUICtrlSendMsg($hwnd, $lvm_setcolumnwidth, $icol,

EndIf

Func _guictrllistview_setextendedlistviewstyle($hwnd, $iexstyle, $iexmas

Local $iret
If IsHWnd($hwnd) Then
$iret = _sendmessage($hwnd, $lvm_setextendedlistviewstyl
e, $iexmask, $iexstyle)
_winapi_invalidaterect($hwnd)
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_setextendedlistviewst
yle, $iexmask, $iexstyle)
_winapi_invalidaterect(GUICtrlGetHandle($hwnd))
EndIf
Return $iret
EndFunc
Func _guictrllistview_setgroupinfo($hwnd, $igroupid, $sheader, $ialign =
0, $istate = $lvgs_normal)
Local $tgroup = 0
If BitAND($istate, $lvgs_selected) Then
$tgroup = __guictrllistview_getgroupinfoex($hwnd, $igrou
pid, BitOR($lvgf_groupid, $lvgf_items))
If DllStructGetData($tgroup, "GroupId") <> $igroupid OR
DllStructGetData($tgroup, "cItems") = 0 Then Return False
EndIf
Local $aalign[3] = [$lvga_header_left, $lvga_header_center, $lvg
a_header_right]
If $ialign < 0 OR $ialign > 2 Then $ialign = 0
Local $theader = _winapi_multibytetowidechar($sheader)
Local $pheader = DllStructGetPtr($theader)
Local $iheader = StringLen($sheader)
$tgroup = DllStructCreate($taglvgroup)
Local $pgroup = DllStructGetPtr($tgroup)
Local $igroup = DllStructGetSize($tgroup)
Local $imask = BitOR($lvgf_header, $lvgf_align, $lvgf_state)
DllStructSetData($tgroup, "Size", $igroup)
DllStructSetData($tgroup, "Mask", $imask)

DllStructSetData($tgroup, "HeaderMax", $iheader)


DllStructSetData($tgroup, "Align", $aalign[$ialign])
DllStructSetData($tgroup, "State", $istate)
DllStructSetData($tgroup, "StateMask", $istate)
Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
DllStructSetData($tgroup, "Header", $pheader)
$iret = _sendmessage($hwnd, $lvm_setgroupinfo, $
igroupid, $pgroup)
DllStructSetData($tgroup, "Mask", $lvgf_groupid)
DllStructSetData($tgroup, "GroupID", $igroupid)
_sendmessage($hwnd, $lvm_setgroupinfo, 0, $pgrou
p)
Else
Local $tmemmap
Local $pmemory = _meminit($hwnd, $igroup + $ihea
der, $tmemmap)
Local $ptext = $pmemory + $igroup
DllStructSetData($tgroup, "Header", $ptext)
_memwrite($tmemmap, $tgroup, $pmemory, $igroup)
_memwrite($tmemmap, $theader, $ptext, $iheader)
$iret = _sendmessage($hwnd, $lvm_setgroupinfo, $
igroupid, $pmemory)
DllStructSetData($tgroup, "Mask", $lvgf_groupid)
DllStructSetData($tgroup, "GroupID", $igroupid)
_sendmessage($hwnd, $lvm_setgroupinfo, 0, $pmemo
ry)
_memfree($tmemmap)
EndIf
_winapi_invalidaterect($hwnd)
Else
DllStructSetData($tgroup, "Header", $pheader)
$iret = GUICtrlSendMsg($hwnd, $lvm_setgroupinfo, $igroup
id, $pgroup)
DllStructSetData($tgroup, "Mask", $lvgf_groupid)
DllStructSetData($tgroup, "GroupID", $igroupid)
GUICtrlSendMsg($hwnd, $lvm_setgroupinfo, 0, $pgroup)
_winapi_invalidaterect(GUICtrlGetHandle($hwnd))
EndIf
Return $iret <> 0
EndFunc
Func _guictrllistview_sethotcursor($hwnd, $hcursor)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_sethotcursor, 0, $hcurso
r, 0, "wparam", "handle", "handle")
Else
Return Ptr(GUICtrlSendMsg($hwnd, $lvm_sethotcursor, 0, $
hcursor))
EndIf
EndFunc

Func _guictrllistview_sethotitem($hwnd, $iindex)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_sethotitem, $iindex)
Else
Return GUICtrlSendMsg($hwnd, $lvm_sethotitem, $iindex, 0
EndIf

EndFunc

e)

Func _guictrllistview_sethovertime($hwnd, $itime)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_sethovertime, 0, $itime)
Else
Return GUICtrlSendMsg($hwnd, $lvm_sethovertime, 0, $itim
EndFunc

EndIf

Func _guictrllistview_seticonspacing($hwnd, $icx, $icy)


Local $iret, $apadding[2]
If IsHWnd($hwnd) Then
$iret = _sendmessage($hwnd, $lvm_seticonspacing, 0, _win
api_makelong($icx, $icy))
_winapi_invalidaterect($hwnd)
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_seticonspacing, 0, _w
inapi_makelong($icx, $icy))
_winapi_invalidaterect(GUICtrlGetHandle($hwnd))
EndIf
$apadding[0] = BitAND($iret, 65535)
$apadding[1] = BitShift($iret, 16)
Return $apadding
EndFunc
Func _guictrllistview_setimagelist($hwnd, $hhandle, $itype = 0)
Local $atype[3] = [$lvsil_normal, $lvsil_small, $lvsil_state]
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_setimagelist, $atype[$it
ype], $hhandle, 0, "wparam", "handle", "handle")
Else
Return Ptr(GUICtrlSendMsg($hwnd, $lvm_setimagelist, $aty
pe[$itype], $hhandle))
EndIf
EndFunc
Func _guictrllistview_setinfotip($hwnd, $iindex, $stext, $isubitem = 0)
Local $tbuffer = _winapi_multibytetowidechar($stext)
Local $pbuffer = DllStructGetPtr($tbuffer)
Local $ibuffer = StringLen($stext)
Local $tinfo = DllStructCreate($taglvsetinfotip)
Local $iinfo = DllStructGetSize($tinfo)
DllStructSetData($tinfo, "Size", $iinfo)
DllStructSetData($tinfo, "Item", $iindex)
DllStructSetData($tinfo, "SubItem", $isubitem)
Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
DllStructSetData($tinfo, "Text", $pbuffer)
$iret = _sendmessage($hwnd, $lvm_setinfotip, 0,
$tinfo, 0, "wparam", "struct*")
Else
Local $tmemmap
Local $pmemory = _meminit($hwnd, $iinfo + $ibuff
er, $tmemmap)
Local $ptext = $pmemory + $iinfo
DllStructSetData($tinfo, "Text", $ptext)
_memwrite($tmemmap, $tinfo, $pmemory, $iinfo)

$pmemory, 0, "wparam", "ptr")


Else

EndIf

_memwrite($tmemmap, $tbuffer, $ptext, $ibuffer)


$iret = _sendmessage($hwnd, $lvm_setinfotip, 0,
_memfree($tmemmap)

DllStructSetData($tinfo, "Text", $pbuffer)


$iret = GUICtrlSendMsg($hwnd, $lvm_setinfotip, 0, DllStr

uctGetPtr($tinfo))
EndIf
Return $iret <> 0
EndFunc

Func _guictrllistview_setinsertmark($hwnd, $iindex, $bafter = False)


Local $tmark = DllStructCreate($taglvinsertmark)
Local $imark = DllStructGetSize($tmark)
DllStructSetData($tmark, "Size", $imark)
If $bafter Then DllStructSetData($tmark, "Flags", $lvim_after)
DllStructSetData($tmark, "Item", $iindex)
DllStructSetData($tmark, "Reserved", 0)
Local $iret
If IsHWnd($hwnd) Then
Local $tmemmap
Local $pmemory = _meminit($hwnd, $imark, $tmemmap)
_memwrite($tmemmap, $tmark, $pmemory, $imark)
$iret = _sendmessage($hwnd, $lvm_setinsertmark, 0, $pmem
ory, 0, "wparam", "ptr")
_memfree($tmemmap)
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_setinsertmark, 0, Dll
StructGetPtr($tmark))
EndIf
Return $iret <> 0
EndFunc

icolor)

Func _guictrllistview_setinsertmarkcolor($hwnd, $icolor)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_setinsertmarkcolor, 0, $
Else

$icolor)
EndFunc

Return GUICtrlSendMsg($hwnd, $lvm_setinsertmarkcolor, 0,

EndIf

Func _guictrllistview_setitem($hwnd, $stext, $iindex = 0, $isubitem = 0,


$iimage = -1, $iparam = -1, $iindent = -1)
Local $pbuffer, $ibuffer
If $stext <> -1 Then
$ibuffer = StringLen($stext) + 1
Local $tbuffer
If _guictrllistview_getunicodeformat($hwnd) Then
$tbuffer = DllStructCreate("wchar Text[" & $ibuf
fer & "]")
Else
$tbuffer = DllStructCreate("char Text[" & $ibuff
er & "]")
EndIf
$pbuffer = DllStructGetPtr($tbuffer)
DllStructSetData($tbuffer, "Text", $stext)

Else

EndFunc

$ibuffer = 0
$pbuffer = -1

EndIf
Local $titem = DllStructCreate($taglvitem)
Local $imask = $lvif_text
If $iimage <> -1 Then $imask = BitOR($imask, $lvif_image)
If $iparam <> -1 Then $imask = BitOR($imask, $lvif_param)
If $iindent <> -1 Then $imask = BitOR($imask, $lvif_indent)
DllStructSetData($titem, "Mask", $imask)
DllStructSetData($titem, "Item", $iindex)
DllStructSetData($titem, "SubItem", $isubitem)
DllStructSetData($titem, "Text", $pbuffer)
DllStructSetData($titem, "TextMax", $ibuffer)
DllStructSetData($titem, "Image", $iimage)
DllStructSetData($titem, "Param", $iparam)
DllStructSetData($titem, "Indent", $iindent)
Return _guictrllistview_setitemex($hwnd, $titem)

Func _guictrllistview_setitemchecked($hwnd, $iindex, $bcheck = True)


Local $bunicode = _guictrllistview_getunicodeformat($hwnd)
Local $pmemory, $tmemmap, $iret
Local $titem = DllStructCreate($taglvitem)
Local $pitem = DllStructGetPtr($titem)
Local $iitem = DllStructGetSize($titem)
If @error Then Return SetError($lv_err, $lv_err, $lv_err)
If $iindex <> -1 Then
DllStructSetData($titem, "Mask", $lvif_state)
DllStructSetData($titem, "Item", $iindex)
If ($bcheck) Then
DllStructSetData($titem, "State", 8192)
Else
DllStructSetData($titem, "State", 4096)
EndIf
DllStructSetData($titem, "StateMask", 61440)
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) The

Return _sendmessage($hwnd, $lvm_setitemw


, 0, $titem, 0, "wparam", "struct*") <> 0
Else
$pmemory = _meminit($hwnd, $iitem, $tmem
map)
_memwrite($tmemmap, $titem)
If $bunicode Then
$iret = _sendmessage($hwnd, $lvm
_setitemw, 0, $pmemory, 0, "wparam", "ptr")
Else
$iret = _sendmessage($hwnd, $lvm
_setitema, 0, $pmemory, 0, "wparam", "ptr")
EndIf
_memfree($tmemmap)
Return $iret <> 0
EndIf
Else
If $bunicode Then
Return GUICtrlSendMsg($hwnd, $lvm_setite
mw, 0, $pitem) <> 0
Else

Return GUICtrlSendMsg($hwnd, $lvm_setite

ma, 0, $pitem) <> 0


Else

wnd) Then

EndIf

EndIf

For $x = 0 To _guictrllistview_getitemcount($hwnd) - 1
DllStructSetData($titem, "Mask", $lvif_state)
DllStructSetData($titem, "Item", $x)
If ($bcheck) Then
DllStructSetData($titem, "State", 8192)
Else
DllStructSetData($titem, "State", 4096)
EndIf
DllStructSetData($titem, "StateMask", 61440)
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlast

If NOT _sendmessage($hwnd, $lvm_


setitemw, 0, $titem, 0, "wparam", "struct*") <> 0 Then Return SetError($lv_err,
$lv_err, $lv_err)
Else
$pmemory = _meminit($hwnd, $iite
m, $tmemmap)
_memwrite($tmemmap, $titem)
If $bunicode Then
$iret = _sendmessage($hw
nd, $lvm_setitemw, 0, $pmemory, 0, "wparam", "ptr")
Else
$iret = _sendmessage($hw
nd, $lvm_setitema, 0, $pmemory, 0, "wparam", "ptr")
EndIf
_memfree($tmemmap)
If NOT $iret <> 0 Then Return Se
tError($lv_err, $lv_err, $lv_err)
EndIf
Else
If $bunicode Then
If NOT GUICtrlSendMsg($hwnd, $lv
m_setitemw, 0, $pitem) <> 0 Then Return SetError($lv_err, $lv_err, $lv_err)
Else
If NOT GUICtrlSendMsg($hwnd, $lv
m_setitema, 0, $pitem) <> 0 Then Return SetError($lv_err, $lv_err, $lv_err)
EndIf
EndIf
Next
Return True
EndIf
Return False
EndFunc
Func _guictrllistview_setitemcount($hwnd, $iitems)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_setitemcount, $iitems, B
itOR($lvsicf_noinvalidateall, $lvsicf_noscroll)) <> 0
Else
Return GUICtrlSendMsg($hwnd, $lvm_setitemcount, $iitems,
BitOR($lvsicf_noinvalidateall, $lvsicf_noscroll)) <> 0
EndIf
EndFunc

Func _guictrllistview_setitemcut($hwnd, $iindex, $benabled = True)


Local $istate = 0
If $benabled Then $istate = $lvis_cut
Return _guictrllistview_setitemstate($hwnd, $iindex, $istate, $l
vis_cut)
EndFunc
e)

Func _guictrllistview_setitemdrophilited($hwnd, $iindex, $benabled = Tru

Local $istate = 0
If $benabled Then $istate = $lvis_drophilited
Return _guictrllistview_setitemstate($hwnd, $iindex, $istate, $l
vis_drophilited)
EndFunc

mmap)

Func _guictrllistview_setitemex($hwnd, ByRef $titem)


Local $bunicode = _guictrllistview_getunicodeformat($hwnd)
Local $iret
If IsHWnd($hwnd) Then
Local $iitem = DllStructGetSize($titem)
Local $ibuffer = DllStructGetData($titem, "TextMax")
Local $pbuffer = DllStructGetData($titem, "Text")
If $bunicode Then $ibuffer *= 2
Local $tmemmap
Local $pmemory = _meminit($hwnd, $iitem + $ibuffer, $tme

xt, $ibuffer)

Local $ptext = $pmemory + $iitem


DllStructSetData($titem, "Text", $ptext)
_memwrite($tmemmap, $titem, $pmemory, $iitem)
If $pbuffer <> 0 Then _memwrite($tmemmap, $pbuffer, $pte

If $bunicode Then
$iret = _sendmessage($hwnd, $lvm_setitemw, 0, $p
memory, 0, "wparam", "ptr")
Else
$iret = _sendmessage($hwnd, $lvm_setitema, 0, $p
memory, 0, "wparam", "ptr")
EndIf
_memfree($tmemmap)
Else
Local $pitem = DllStructGetPtr($titem)
If $bunicode Then
$iret = GUICtrlSendMsg($hwnd, $lvm_setitemw, 0,
$pitem)
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_setitema, 0,
$pitem)
EndIf
EndIf
Return $iret <> 0
EndFunc
Func _guictrllistview_setitemfocused($hwnd, $iindex, $benabled = True)
Local $istate = 0
If $benabled Then $istate = $lvis_focused
Return _guictrllistview_setitemstate($hwnd, $iindex, $istate, $l
vis_focused)
EndFunc
Func _guictrllistview_setitemgroupid($hwnd, $iindex, $igroupid)

EndFunc
0)

Local $titem = DllStructCreate($taglvitem)


DllStructSetData($titem, "Mask", $lvif_groupid)
DllStructSetData($titem, "Item", $iindex)
DllStructSetData($titem, "GroupID", $igroupid)
_guictrllistview_setitemex($hwnd, $titem)

Func _guictrllistview_setitemimage($hwnd, $iindex, $iimage, $isubitem =

EndFunc

Local $titem = DllStructCreate($taglvitem)


DllStructSetData($titem, "Mask", $lvif_image)
DllStructSetData($titem, "Item", $iindex)
DllStructSetData($titem, "SubItem", $isubitem)
DllStructSetData($titem, "Image", $iimage)
Return _guictrllistview_setitemex($hwnd, $titem)

Func _guictrllistview_setitemindent($hwnd, $iindex, $iindent)


Local $titem = DllStructCreate($taglvitem)
DllStructSetData($titem, "Mask", $lvif_indent)
DllStructSetData($titem, "Item", $iindex)
DllStructSetData($titem, "Indent", $iindent)
Return _guictrllistview_setitemex($hwnd, $titem)
EndFunc
Func __guictrllistview_setitemoverlayimage($hwnd, $iindex, $iimage)
Return _guictrllistview_setitemstate($hwnd, $iindex, __guictrlli
stview_indextooverlayimagemask($iimage), $lvis_overlaymask)
EndFunc
Func _guictrllistview_setitemparam($hwnd, $iindex, $iparam)
Local $titem = DllStructCreate($taglvitem)
DllStructSetData($titem, "Mask", $lvif_param)
DllStructSetData($titem, "Item", $iindex)
DllStructSetData($titem, "Param", $iparam)
Return _guictrllistview_setitemex($hwnd, $titem)
EndFunc
Func _guictrllistview_setitemposition($hwnd, $iindex, $icx, $icy)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_setitemposition, $iindex
, _winapi_makelong($icx, $icy)) <> 0
Else
Return GUICtrlSendMsg($hwnd, $lvm_setitemposition, $iind
ex, _winapi_makelong($icx, $icy)) <> 0
EndIf
EndFunc
Func _guictrllistview_setitemposition32($hwnd, $iindex, $icx, $icy)
Local $tpoint = DllStructCreate($tagpoint)
DllStructSetData($tpoint, "X", $icx)
DllStructSetData($tpoint, "Y", $icy)
Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
$iret = _sendmessage($hwnd, $lvm_setitemposition
32, $iindex, $tpoint, 0, "wparam", "struct*")
Else
Local $ipoint = DllStructGetSize($tpoint)
Local $tmemmap

ap)

Local $pmemory = _meminit($hwnd, $ipoint, $tmemm

_memwrite($tmemmap, $tpoint)
$iret = _sendmessage($hwnd, $lvm_setitemposition
32, $iindex, $pmemory, 0, "wparam", "ptr")
_memfree($tmemmap)
EndIf
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_setitemposition32, $i
index, DllStructGetPtr($tpoint))
EndIf
Return $iret <> 0
EndFunc
Func _guictrllistview_setitemselected($hwnd, $iindex, $bselected = True,
$bfocused = False)
Local $tstruct = DllStructCreate($taglvitem)
Local $iret, $iselected = 0, $ifocused = 0, $isize, $tmemmap, $p
memory
If ($bselected = True) Then $iselected = $lvis_selected
If ($bfocused = True AND $iindex <> -1) Then $ifocused = $lvis_f
ocused
DllStructSetData($tstruct, "Mask", $lvif_state)
DllStructSetData($tstruct, "Item", $iindex)
DllStructSetData($tstruct, "State", BitOR($iselected, $ifocused)
)
DllStructSetData($tstruct, "StateMask", BitOR($lvis_selected, $i
focused))
$isize = DllStructGetSize($tstruct)
If IsHWnd($hwnd) Then
$pmemory = _meminit($hwnd, $isize, $tmemmap)
_memwrite($tmemmap, $tstruct, $pmemory, $isize)
$iret = _sendmessage($hwnd, $lvm_setitemstate, $iindex,
$pmemory)
_memfree($tmemmap)
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_setitemstate, $iindex
, DllStructGetPtr($tstruct))
EndIf
Return $iret <> 0
EndFunc
Func _guictrllistview_setitemstate($hwnd, $iindex, $istate, $istatemask)
Local $titem = DllStructCreate($taglvitem)
DllStructSetData($titem, "Mask", $lvif_state)
DllStructSetData($titem, "Item", $iindex)
DllStructSetData($titem, "State", $istate)
DllStructSetData($titem, "StateMask", $istatemask)
Return _guictrllistview_setitemex($hwnd, $titem) <> 0
EndFunc
Func _guictrllistview_setitemstateimage($hwnd, $iindex, $iimage)
Return _guictrllistview_setitemstate($hwnd, $iindex, BitShift($i
image, -12), $lvis_stateimagemask)
EndFunc
Func _guictrllistview_setitemtext($hwnd, $iindex, $stext, $isubitem = 0)
Local $bunicode = _guictrllistview_getunicodeformat($hwnd)
Local $iret
If $isubitem = -1 Then

Local $sseparatorchar = Opt("GUIDataSeparatorChar")


Local $i_cols = _guictrllistview_getcolumncount($hwnd)
Local $a_text = StringSplit($stext, $sseparatorchar)
If $i_cols > $a_text[0] Then $i_cols = $a_text[0]
For $i = 1 To $i_cols
$iret = _guictrllistview_setitemtext($hwnd, $iin
dex, $a_text[$i], $i - 1)
If NOT $iret Then ExitLoop
Next
Return $iret
EndIf
Local $ibuffer = StringLen($stext) + 1
Local $tbuffer
If $bunicode Then
$tbuffer = DllStructCreate("wchar Text[" & $ibuffer & "]
")
$ibuffer *= 2
Else
$tbuffer = DllStructCreate("char Text[" & $ibuffer & "]"
)
EndIf
Local $pbuffer = DllStructGetPtr($tbuffer)
Local $titem = DllStructCreate($taglvitem)
DllStructSetData($tbuffer, "Text", $stext)
DllStructSetData($titem, "Mask", $lvif_text)
DllStructSetData($titem, "item", $iindex)
DllStructSetData($titem, "SubItem", $isubitem)
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
DllStructSetData($titem, "Text", $pbuffer)
$iret = _sendmessage($hwnd, $lvm_setitemw, 0, $t
item, 0, "wparam", "struct*")
Else
Local $iitem = DllStructGetSize($titem)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $iitem + $ibuff
er, $tmemmap)
Local $ptext = $pmemory + $iitem
DllStructSetData($titem, "Text", $ptext)
_memwrite($tmemmap, $titem, $pmemory, $iitem)
_memwrite($tmemmap, $tbuffer, $ptext, $ibuffer)
If $bunicode Then
$iret = _sendmessage($hwnd, $lvm_setitem
w, 0, $pmemory, 0, "wparam", "ptr")
Else
$iret = _sendmessage($hwnd, $lvm_setitem
a, 0, $pmemory, 0, "wparam", "ptr")
EndIf
_memfree($tmemmap)
EndIf
Else
Local $pitem = DllStructGetPtr($titem)
DllStructSetData($titem, "Text", $pbuffer)
If $bunicode Then
$iret = GUICtrlSendMsg($hwnd, $lvm_setitemw, 0,
$pitem)
Else
$iret = GUICtrlSendMsg($hwnd, $lvm_setitema, 0,
$pitem)
EndIf

EndFunc

lor)

EndIf
Return $iret <> 0

Func _guictrllistview_setoutlinecolor($hwnd, $icolor)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_setoutlinecolor, 0, $ico
Else

color)
EndFunc

Return GUICtrlSendMsg($hwnd, $lvm_setoutlinecolor, 0, $i

EndIf

Func _guictrllistview_setselectedcolumn($hwnd, $icol)


If IsHWnd($hwnd) Then
_sendmessage($hwnd, $lvm_setselectedcolumn, $icol)
_winapi_invalidaterect($hwnd)
Else
GUICtrlSendMsg($hwnd, $lvm_setselectedcolumn, $icol, 0)
_winapi_invalidaterect(GUICtrlGetHandle($hwnd))
EndIf
EndFunc

ndex)

Func _guictrllistview_setselectionmark($hwnd, $iindex)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_setselectionmark, 0, $ii
Else

iindex)
EndFunc

Return GUICtrlSendMsg($hwnd, $lvm_setselectionmark, 0, $

EndIf

Func _guictrllistview_settextbkcolor($hwnd, $icolor)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_settextbkcolor, 0, $icol
or) <> 0
Else
Return GUICtrlSendMsg($hwnd, $lvm_settextbkcolor, 0, $ic
olor) <> 0
EndIf
EndFunc

r)

Func _guictrllistview_settextcolor($hwnd, $icolor)


Local $iret
If IsHWnd($hwnd) Then
$iret = _sendmessage($hwnd, $lvm_settextcolor, 0, $icolo
Else

lor)

EndFunc

_winapi_invalidaterect($hwnd)
$iret = GUICtrlSendMsg($hwnd, $lvm_settextcolor, 0, $ico

_winapi_invalidaterect(GUICtrlGetHandle($hwnd))
EndIf
Return $iret <> 0

Func _guictrllistview_settooltips($hwnd, $htooltip)


If IsHWnd($hwnd) Then

Return _sendmessage($hwnd, $lvm_settooltips, 0, $htoolti


p, 0, "wparam", "hwnd", "hwnd")
Else
Return HWnd(GUICtrlSendMsg($hwnd, $lvm_settooltips, 0, $
htooltip))
EndIf
EndFunc

ode)

Func _guictrllistview_setunicodeformat($hwnd, $bunicode)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_setunicodeformat, $bunic
Else

icode, 0)
EndFunc

Return GUICtrlSendMsg($hwnd, $lvm_setunicodeformat, $bun

EndIf

Func _guictrllistview_setview($hwnd, $iview)


Local $aview[5] = [$lv_view_icon, $lv_view_details, $lv_view_lis
t, $lv_view_smallicon, $lv_view_tile]
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $lvm_setview, $aview[$iview])
<> -1
Else
Return GUICtrlSendMsg($hwnd, $lvm_setview, $aview[$iview
], 0) <> -1
EndIf
EndFunc
om)

Func _guictrllistview_setworkareas($hwnd, $ileft, $itop, $iright, $ibott

Local $trect = DllStructCreate($tagrect)


DllStructSetData($trect, "Left", $ileft)
DllStructSetData($trect, "Top", $itop)
DllStructSetData($trect, "Right", $iright)
DllStructSetData($trect, "Bottom", $ibottom)
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
_sendmessage($hwnd, $lvm_setworkareas, 1, $trect
, 0, "wparam", "struct*")
Else
Local $irect = DllStructGetSize($trect)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $irect, $tmemma
p)
_memwrite($tmemmap, $trect, $pmemory, $irect)
_sendmessage($hwnd, $lvm_setworkareas, 1, $pmemo
ry, 0, "wparam", "ptr")
_memfree($tmemmap)
EndIf
Else
GUICtrlSendMsg($hwnd, $lvm_setworkareas, 1, DllStructGet
Ptr($trect))
EndIf
EndFunc
Func _guictrllistview_simplesort($hwnd, ByRef $vsortsense, $icol, $btogg
lesense = True)
Local $iitemcount = _guictrllistview_getitemcount($hwnd)

wnd)

If $iitemcount Then
Local $idescending = 0
If UBound($vsortsense) Then
$idescending = $vsortsense[$icol]
Else
$idescending = $vsortsense
EndIf
Local $vseparatorchar = Opt("GUIDataSeparatorChar")
Local $icolumncount = _guictrllistview_getcolumncount($h

Local Enum $iindexvalue = $icolumncount, $iitemparam


Local $alistviewitems[$iitemcount][$icolumncount + 2]
Local $aselecteditems = StringSplit(_guictrllistview_get
selectedindices($hwnd), $vseparatorchar)
Local $acheckeditems = __guictrllistview_getcheckedindic
es($hwnd)
Local $sitemtext, $ifocused = -1
For $i = 0 To $iitemcount - 1
If $ifocused = -1 Then
If _guictrllistview_getitemfocused($hwnd
, $i) Then $ifocused = $i
EndIf
_guictrllistview_setitemselected($hwnd, $i, Fals
e)
_guictrllistview_setitemchecked($hwnd, $i, False
)
For $j = 0 To $icolumncount - 1
$sitemtext = StringStripWS(_guictrllistv
iew_getitemtext($hwnd, $i, $j), $str_striptrailing)
If (StringIsFloat($sitemtext) OR StringI
sInt($sitemtext)) Then
$alistviewitems[$i][$j] = Number
($sitemtext)
Else
$alistviewitems[$i][$j] = $sitem
text
EndIf
Next
$alistviewitems[$i][$iindexvalue] = $i
$alistviewitems[$i][$iitemparam] = _guictrllistv
iew_getitemparam($hwnd, $i)
Next
_arraysort($alistviewitems, $idescending, 0, 0, $icol)
For $i = 0 To $iitemcount - 1
For $j = 0 To $icolumncount - 1
_guictrllistview_setitemtext($hwnd, $i,
$alistviewitems[$i][$j], $j)
Next
_guictrllistview_setitemparam($hwnd, $i, $alistv
iewitems[$i][$iitemparam])
For $j = 1 To $aselecteditems[0]
If $alistviewitems[$i][$iindexvalue] = $
aselecteditems[$j] Then
If $alistviewitems[$i][$iindexva
lue] = $ifocused Then
_guictrllistview_setitem
selected($hwnd, $i, True, True)
Else
_guictrllistview_setitem
selected($hwnd, $i, True)

EndIf
ExitLoop

acheckeditems[$j] Then

EndIf
Next
For $j = 1 To $acheckeditems[0]
If $alistviewitems[$i][$iindexvalue] = $
_guictrllistview_setitemchecked(

$hwnd, $i, True)


EndIf

EndFunc

EndIf

ExitLoop

Next
Next
If $btogglesense Then
If UBound($vsortsense) Then
$vsortsense[$icol] = NOT $idescending
Else
$vsortsense = NOT $idescending
EndIf
EndIf

Func __guictrllistview_sort($nitem1, $nitem2, $hwnd)


Local $iindex, $sval1, $sval2, $nresult
For $x = 1 To $__g_alistviewsortinfo[0][0]
If $hwnd = $__g_alistviewsortinfo[$x][1] Then
$iindex = $x
ExitLoop
EndIf
Next
If $__g_alistviewsortinfo[$iindex][3] = $__g_alistviewsortinfo[$
iindex][4] Then
If NOT $__g_alistviewsortinfo[$iindex][7] Then
$__g_alistviewsortinfo[$iindex][5] *= -1
$__g_alistviewsortinfo[$iindex][7] = 1
EndIf
Else
$__g_alistviewsortinfo[$iindex][7] = 1
EndIf
$__g_alistviewsortinfo[$iindex][6] = $__g_alistviewsortinfo[$iin
dex][3]
$sval1 = _guictrllistview_getitemtext($hwnd, $nitem1, $__g_alist
viewsortinfo[$iindex][3])
$sval2 = _guictrllistview_getitemtext($hwnd, $nitem2, $__g_alist
viewsortinfo[$iindex][3])
If $__g_alistviewsortinfo[$iindex][8] Then
If (StringIsFloat($sval1) OR StringIsInt($sval1)) Then $
sval1 = Number($sval1)
If (StringIsFloat($sval2) OR StringIsInt($sval2)) Then $
sval2 = Number($sval2)
EndIf
$nresult = 0
If $sval1 < $sval2 Then
$nresult = -1
ElseIf $sval1 > $sval2 Then
$nresult = 1
EndIf
$nresult = $nresult * $__g_alistviewsortinfo[$iindex][5]
Return $nresult

EndFunc

])

dex][6]

Func _guictrllistview_sortitems($hwnd, $icol)


Local $iret, $iindex, $pfunction, $hheader, $iformat
If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
For $x = 1 To $__g_alistviewsortinfo[0][0]
If $hwnd = $__g_alistviewsortinfo[$x][1] Then
$iindex = $x
ExitLoop
EndIf
Next
$pfunction = DllCallbackGetPtr($__g_alistviewsortinfo[$iindex][2
$__g_alistviewsortinfo[$iindex][3] = $icol
$__g_alistviewsortinfo[$iindex][7] = 0
$__g_alistviewsortinfo[$iindex][4] = $__g_alistviewsortinfo[$iin

$iret = _sendmessage($hwnd, $lvm_sortitemsex, $hwnd, $pfunction,


0, "hwnd", "ptr")
If $iret <> 0 Then
If $__g_alistviewsortinfo[$iindex][9] Then
$hheader = $__g_alistviewsortinfo[$iindex][10]
For $x = 0 To _guictrlheader_getitemcount($hhead
er) - 1
$iformat = _guictrlheader_getitemformat(
$hheader, $x)
If BitAND($iformat, $hdf_sortdown) Then
_guictrlheader_setitemformat($hh
eader, $x, BitXOR($iformat, $hdf_sortdown))
ElseIf BitAND($iformat, $hdf_sortup) The
n
_guictrlheader_setitemformat($hh
eader, $x, BitXOR($iformat, $hdf_sortup))
EndIf
Next
$iformat = _guictrlheader_getitemformat($hheader
, $icol)
If $__g_alistviewsortinfo[$iindex][5] = 1 Then
_guictrlheader_setitemformat($hheader, $
icol, BitOR($iformat, $hdf_sortup))
Else
_guictrlheader_setitemformat($hheader, $
icol, BitOR($iformat, $hdf_sortdown))
EndIf
EndIf
EndIf
Return $iret <> 0
EndFunc
Func __guictrllistview_stateimagemasktoindex($imask)
Return BitShift(BitAND($imask, $lvis_stateimagemask), 12)
EndFunc
Func _guictrllistview_subitemhittest($hwnd, $ix = -1, $iy = -1)
Local $itest, $ttest, $pmemory, $tmemmap, $iflags, $atest[11]
If $ix = -1 Then $ix = _winapi_getmouseposx(True, $hwnd)
If $iy = -1 Then $iy = _winapi_getmouseposy(True, $hwnd)
$ttest = DllStructCreate($taglvhittestinfo)
DllStructSetData($ttest, "X", $ix)
DllStructSetData($ttest, "Y", $iy)

If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_hlvlastwnd) Then
_sendmessage($hwnd, $lvm_subitemhittest, 0, $tte
st, 0, "wparam", "struct*")
Else
$itest = DllStructGetSize($ttest)
$pmemory = _meminit($hwnd, $itest, $tmemmap)
_memwrite($tmemmap, $ttest)
_sendmessage($hwnd, $lvm_subitemhittest, 0, $pme
mory, 0, "wparam", "ptr")
_memread($tmemmap, $pmemory, $ttest, $itest)
_memfree($tmemmap)
EndIf
Else
GUICtrlSendMsg($hwnd, $lvm_subitemhittest, 0, DllStructG
etPtr($ttest))
EndIf
$iflags = DllStructGetData($ttest, "Flags")
$atest[0] = DllStructGetData($ttest, "Item")
$atest[1] = DllStructGetData($ttest, "SubItem")
$atest[2] = BitAND($iflags, $lvht_nowhere) <> 0
$atest[3] = BitAND($iflags, $lvht_onitemicon) <> 0
$atest[4] = BitAND($iflags, $lvht_onitemlabel) <> 0
$atest[5] = BitAND($iflags, $lvht_onitemstateicon) <> 0
$atest[6] = BitAND($iflags, $lvht_onitem) <> 0
$atest[7] = BitAND($iflags, $lvht_above) <> 0
$atest[8] = BitAND($iflags, $lvht_below) <> 0
$atest[9] = BitAND($iflags, $lvht_toleft) <> 0
$atest[10] = BitAND($iflags, $lvht_toright) <> 0
Return $atest
EndFunc
Func _guictrllistview_unregistersortcallback($hwnd)
If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
For $x = 1 To $__g_alistviewsortinfo[0][0]
If $hwnd = $__g_alistviewsortinfo[$x][1] Then
DllCallbackFree($__g_alistviewsortinfo[$x][2])
__guictrllistview_arraydelete($__g_alistviewsort
info, $x)
$__g_alistviewsortinfo[0][0] -= 1
ExitLoop
EndIf
Next
EndFunc
Global $__g_htablastwnd
Global Const $__tabconstant_classname = "SysTabControl32"
Global Const $__tabconstant_ws_clipsiblings = 67108864
Global Const $__tabconstant_wm_notify = 78
Global Const $__tabconstant_default_gui_font = 17
Global Const $tagtcitem = "uint Mask;dword State;dword StateMask;ptr Tex
t;int TextMax;int Image;lparam Param"
Global Const $tagtchittestinfo = $tagpoint & ";uint Flags"
Func __guictrltab_adjustrect($hwnd, ByRef $trect, $blarger = False)
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_htablastwnd) Then
_sendmessage($hwnd, $tcm_adjustrect, $blarger, $
trect, 0, "wparam", "struct*")
Else

Local $irect = DllStructGetSize($trect)


Local $tmemmap
Local $pmemory = _meminit($hwnd, $irect, $tmemma

p)
pmemory, 0, "wparam", "ptr")

EndFunc

EndIf
EndIf
Return $trect

_memwrite($tmemmap, $trect)
_sendmessage($hwnd, $tcm_adjustrect, $blarger, $
_memread($tmemmap, $pmemory, $trect, $irect)
_memfree($tmemmap)

Func _guictrltab_activatetab($hwnd, $iindex)


Local $nindx
If $hwnd = -1 Then $hwnd = GUICtrlGetHandle(-1)
If IsHWnd($hwnd) Then
$nindx = _winapi_getdlgctrlid($hwnd)
Else
$nindx = $hwnd
$hwnd = GUICtrlGetHandle($hwnd)
EndIf
Local $hparent = _winapi_getparent($hwnd)
If @error Then Return SetError(1, 0, -1)
Local $tnmhdr = DllStructCreate($tagnmhdr)
DllStructSetData($tnmhdr, 1, $hwnd)
DllStructSetData($tnmhdr, 2, $nindx)
DllStructSetData($tnmhdr, 3, $tcn_selchanging)
_sendmessage($hparent, $__tabconstant_wm_notify, $nindx, $tnmhdr
, 0, "wparam", "struct*")
Local $iret = _guictrltab_setcursel($hwnd, $iindex)
DllStructSetData($tnmhdr, 3, $tcn_selchange)
_sendmessage($hparent, $__tabconstant_wm_notify, $nindx, $tnmhdr
, 0, "wparam", "struct*")
Return $iret
EndFunc
Func _guictrltab_clicktab($hwnd, $iindex, $sbutton = "left", $bmove = Fa
lse, $iclicks = 1, $ispeed = 1)
If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
Local $ix, $iy
If NOT $bmove Then
Local $hwinparent = _winapi_getparent($hwnd)
Local $avtabpos = _guictrltab_getitemrect($hwnd, $iindex
)
$ix = $avtabpos[0] + (($avtabpos[2] - $avtabpos[0]) / 2)
$iy = $avtabpos[1] + (($avtabpos[3] - $avtabpos[1]) / 2)
ControlClick($hwinparent, "", $hwnd, $sbutton, $iclicks,
$ix, $iy)
Else
Local $trect = _guictrltab_getitemrectex($hwnd, $iindex)
Local $tpoint = _winapi_pointfromrect($trect, True)
$tpoint = _winapi_clienttoscreen($hwnd, $tpoint)
_winapi_getxyfrompoint($tpoint, $ix, $iy)
Local $imode = Opt("MouseCoordMode", 1)
MouseClick($sbutton, $ix, $iy, $iclicks, $ispeed)
Opt("MouseCoordMode", $imode)
EndIf
EndFunc

Func _guictrltab_create($hwnd, $ix, $iy, $iwidth = 150, $iheight = 150,


$istyle = 64, $iexstyle = 0)
If NOT IsHWnd($hwnd) Then
Return SetError(1, 0, 0)
EndIf
If $iwidth = -1 Then $iwidth = 150
If $iheight = -1 Then $iheight = 150
If $istyle = -1 Then $istyle = $tcs_hottrack
If $iexstyle = -1 Then $iexstyle = 0
$istyle = BitOR($istyle, $__udfguiconstant_ws_child, $__tabconst
ant_ws_clipsiblings, $__udfguiconstant_ws_visible)
Local $nctrlid = __udf_getnextglobalid($hwnd)
If @error Then Return SetError(@error, @extended, 0)
Local $htab = _winapi_createwindowex($iexstyle, $__tabconstant_c
lassname, "", $istyle, $ix, $iy, $iwidth, $iheight, $hwnd, $nctrlid)
_winapi_setfont($htab, _winapi_getstockobject($__tabconstant_def
ault_gui_font))
Return $htab
EndFunc

<> 0

Func _guictrltab_deleteallitems($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $tcm_deleteallitems) <> 0
Else
Return GUICtrlSendMsg($hwnd, $tcm_deleteallitems, 0, 0)
EndFunc

EndIf

Func _guictrltab_deleteitem($hwnd, $iindex)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $tcm_deleteitem, $iindex) <>
Else

) <> 0
EndFunc

Return GUICtrlSendMsg($hwnd, $tcm_deleteitem, $iindex, 0

EndIf

Func _guictrltab_deselectall($hwnd, $bexclude = True)


If IsHWnd($hwnd) Then
_sendmessage($hwnd, $tcm_deselectall, $bexclude)
Else
GUICtrlSendMsg($hwnd, $tcm_deselectall, $bexclude, 0)
EndIf
EndFunc
Func _guictrltab_destroy(ByRef $hwnd)
If NOT _winapi_isclassname($hwnd, $__tabconstant_classname) Then
Return SetError(2, 2, False)
Local $idestroyed = 0
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_htablastwnd) Then
Local $nctrlid = _winapi_getdlgctrlid($hwnd)
Local $hparent = _winapi_getparent($hwnd)
$idestroyed = _winapi_destroywindow($hwnd)
Local $iret = __udf_freeglobalid($hparent, $nctr
lid)
If NOT $iret Then

Else
Else

EndFunc

n $ii

EndIf

EndIf
Return SetError(1, 1, False)

$idestroyed = GUICtrlDelete($hwnd)
EndIf
If $idestroyed Then $hwnd = 0
Return $idestroyed <> 0

Func _guictrltab_findtab($hwnd, $stext, $binstr = False, $istart = 0)


Local $stab
For $ii = $istart To _guictrltab_getitemcount($hwnd)
$stab = _guictrltab_getitemtext($hwnd, $ii)
Switch $binstr
Case False
If $stab = $stext Then Return $ii
Case True
If StringInStr($stab, $stext) Then Retur

EndFunc

EndSwitch
Next
Return -1

Func _guictrltab_getcurfocus($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $tcm_getcurfocus)
Else
Return GUICtrlSendMsg($hwnd, $tcm_getcurfocus, 0, 0)
EndIf
EndFunc
Func _guictrltab_getcursel($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $tcm_getcursel)
Else
Return GUICtrlSendMsg($hwnd, $tcm_getcursel, 0, 0)
EndIf
EndFunc
Func _guictrltab_getdisplayrect($hwnd)
Local $arect[4]
Local $trect = _guictrltab_getdisplayrectex($hwnd)
$arect[0] = DllStructGetData($trect, "Left")
$arect[1] = DllStructGetData($trect, "Top")
$arect[2] = DllStructGetData($trect, "Right")
$arect[3] = DllStructGetData($trect, "Bottom")
Return $arect
EndFunc
Func _guictrltab_getdisplayrectex($hwnd)
Local $trect = _winapi_getclientrect($hwnd)
Return __guictrltab_adjustrect($hwnd, $trect)
EndFunc
Func _guictrltab_getextendedstyle($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $tcm_getextendedstyle)

Else
)
EndFunc

))

Return GUICtrlSendMsg($hwnd, $tcm_getextendedstyle, 0, 0

EndIf

Func _guictrltab_getimagelist($hwnd)
If IsHWnd($hwnd) Then
Return Ptr(_sendmessage($hwnd, $tcm_getimagelist))
Else
Return Ptr(GUICtrlSendMsg($hwnd, $tcm_getimagelist, 0, 0
EndFunc

EndIf

Func _guictrltab_getitem($hwnd, $iindex)


If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
Local $bunicode = _guictrltab_getunicodeformat($hwnd)
Local $ibuffer = 4096
Local $tagtcitemex = $tagtcitem & ";ptr Filler"
Local $titem = DllStructCreate($tagtcitemex)
DllStructSetData($titem, "Mask", $tcif_alldata)
DllStructSetData($titem, "TextMax", $ibuffer)
DllStructSetData($titem, "StateMask", BitOR($tcis_highlighted, $
tcis_buttonpressed))
Local $iitem = DllStructGetSize($titem)
Local $tbuffer
If $bunicode Then
$tbuffer = DllStructCreate("wchar Text[" & $ibuffer & "]
")
$ibuffer *= 2
Else
$tbuffer = DllStructCreate("char Text[" & $ibuffer & "]"
)
EndIf
Local $tmemmap
Local $pmemory = _meminit($hwnd, $iitem + $ibuffer, $tmemmap)
Local $ptext = $pmemory + $iitem
DllStructSetData($titem, "Text", $ptext)
_memwrite($tmemmap, $titem, $pmemory, $iitem)
Local $iret
If $bunicode Then
$iret = _sendmessage($hwnd, $tcm_getitemw, $iindex, $pme
mory)
Else
$iret = _sendmessage($hwnd, $tcm_getitema, $iindex, $pme
mory)
EndIf
_memread($tmemmap, $pmemory, $titem, $iitem)
_memread($tmemmap, $ptext, $tbuffer, $ibuffer)
_memfree($tmemmap)
Local $aitem[4]
$aitem[0] = DllStructGetData($titem, "State")
$aitem[1] = DllStructGetData($tbuffer, "Text")
$aitem[2] = DllStructGetData($titem, "Image")
$aitem[3] = DllStructGetData($titem, "Param")
Return SetError($iret = 0, 0, $aitem)
EndFunc
Func _guictrltab_getitemcount($hwnd)

EndFunc

If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $tcm_getitemcount)
Else
Return GUICtrlSendMsg($hwnd, $tcm_getitemcount, 0, 0)
EndIf

Func _guictrltab_getitemimage($hwnd, $iindex)


Local $aitem = _guictrltab_getitem($hwnd, $iindex)
Return $aitem[2]
EndFunc
Func _guictrltab_getitemparam($hwnd, $iindex)
Local $aitem = _guictrltab_getitem($hwnd, $iindex)
Return $aitem[3]
EndFunc
Func _guictrltab_getitemrect($hwnd, $iindex)
Local $arect[4]
Local $trect = _guictrltab_getitemrectex($hwnd, $iindex)
$arect[0] = DllStructGetData($trect, "Left")
$arect[1] = DllStructGetData($trect, "Top")
$arect[2] = DllStructGetData($trect, "Right")
$arect[3] = DllStructGetData($trect, "Bottom")
Return $arect
EndFunc
Func _guictrltab_getitemrectex($hwnd, $iindex)
Local $trect = DllStructCreate($tagrect)
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_htablastwnd) Then
_sendmessage($hwnd, $tcm_getitemrect, $iindex, $
trect, 0, "wparam", "struct*")
Else
Local $irect = DllStructGetSize($trect)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $irect, $tmemma
p)
_sendmessage($hwnd, $tcm_getitemrect, $iindex, $
pmemory, 0, "wparam", "ptr")
_memread($tmemmap, $pmemory, $trect, $irect)
_memfree($tmemmap)
EndIf
Else
GUICtrlSendMsg($hwnd, $tcm_getitemrect, $iindex, DllStru
ctGetPtr($trect))
EndIf
Return $trect
EndFunc
Func _guictrltab_getitemstate($hwnd, $iindex)
Local $aitem = _guictrltab_getitem($hwnd, $iindex)
Return $aitem[0]
EndFunc
Func _guictrltab_getitemtext($hwnd, $iindex)
Local $aitem = _guictrltab_getitem($hwnd, $iindex)
Return $aitem[1]
EndFunc

Func _guictrltab_getrowcount($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $tcm_getrowcount)
Else
Return GUICtrlSendMsg($hwnd, $tcm_getrowcount, 0, 0)
EndIf
EndFunc

))

Func _guictrltab_gettooltips($hwnd)
If IsHWnd($hwnd) Then
Return HWnd(_sendmessage($hwnd, $tcm_gettooltips))
Else
Return HWnd(GUICtrlSendMsg($hwnd, $tcm_gettooltips, 0, 0
EndFunc

) <> 0

EndIf

Func _guictrltab_getunicodeformat($hwnd)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $tcm_getunicodeformat) <> 0
Else
Return GUICtrlSendMsg($hwnd, $tcm_getunicodeformat, 0, 0
EndFunc

EndIf

Func _guictrltab_highlightitem($hwnd, $iindex, $bhighlight = True)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $tcm_highlightitem, $iindex,
$bhighlight) <> 0
Else
Return GUICtrlSendMsg($hwnd, $tcm_highlightitem, $iindex
, $bhighlight) <> 0
EndIf
EndFunc
Func _guictrltab_hittest($hwnd, $ix, $iy)
Local $ahit[2] = [-1, 1]
Local $thit = DllStructCreate($tagtchittestinfo)
DllStructSetData($thit, "X", $ix)
DllStructSetData($thit, "Y", $iy)
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_htablastwnd) Then
$ahit[0] = _sendmessage($hwnd, $tcm_hittest, 0,
$thit, 0, "wparam", "struct*")
Else
Local $ihit = DllStructGetSize($thit)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $ihit, $tmemmap
)
_memwrite($tmemmap, $thit)
$ahit[0] = _sendmessage($hwnd, $tcm_hittest, 0,
$pmemory, 0, "wparam", "ptr")
_memread($tmemmap, $pmemory, $thit, $ihit)
_memfree($tmemmap)
EndIf
Else
$ahit[0] = GUICtrlSendMsg($hwnd, $tcm_hittest, 0, DllStr
uctGetPtr($thit))
EndIf

EndFunc
m = 0)

$ahit[1] = DllStructGetData($thit, "Flags")


Return $ahit

Func _guictrltab_insertitem($hwnd, $iindex, $stext, $iimage = -1, $ipara

")

Local $bunicode = _guictrltab_getunicodeformat($hwnd)


Local $ibuffer = StringLen($stext) + 1
Local $tbuffer
If $bunicode Then
$tbuffer = DllStructCreate("wchar Text[" & $ibuffer & "]
Else

$tcif_param))

$ibuffer *= 2
$tbuffer = DllStructCreate("char Text[" & $ibuffer & "]"

EndIf
Local $pbuffer = DllStructGetPtr($tbuffer)
Local $titem = DllStructCreate($tagtcitem)
DllStructSetData($tbuffer, "Text", $stext)
DllStructSetData($titem, "Mask", BitOR($tcif_text, $tcif_image,

DllStructSetData($titem, "TextMax", $ibuffer)


DllStructSetData($titem, "Image", $iimage)
DllStructSetData($titem, "Param", $iparam)
Local $iret
If IsHWnd($hwnd) Then
If _winapi_inprocess($hwnd, $__g_htablastwnd) Then
DllStructSetData($titem, "Text", $pbuffer)
$iret = _sendmessage($hwnd, $tcm_insertitemw, $i
index, $titem, 0, "wparam", "struct*")
Else
Local $iitem = DllStructGetSize($titem)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $iitem + $ibuff
er, $tmemmap)
Local $ptext = $pmemory + $iitem
DllStructSetData($titem, "Text", $ptext)
_memwrite($tmemmap, $titem, $pmemory, $iitem)
_memwrite($tmemmap, $tbuffer, $ptext, $ibuffer)
If $bunicode Then
$iret = _sendmessage($hwnd, $tcm_inserti
temw, $iindex, $pmemory, 0, "wparam", "ptr")
Else
$iret = _sendmessage($hwnd, $tcm_inserti
tema, $iindex, $pmemory, 0, "wparam", "ptr")
EndIf
_memfree($tmemmap)
EndIf
Else
Local $pitem = DllStructGetPtr($titem)
DllStructSetData($titem, "Text", $pbuffer)
If $bunicode Then
$iret = GUICtrlSendMsg($hwnd, $tcm_insertitemw,
$iindex, $pitem)
Else
$iret = GUICtrlSendMsg($hwnd, $tcm_insertitema,
$iindex, $pitem)
EndIf
EndIf

EndFunc

Return $iret

Func _guictrltab_removeimage($hwnd, $iindex)


If IsHWnd($hwnd) Then
_sendmessage($hwnd, $tcm_removeimage, $iindex)
_winapi_invalidaterect($hwnd)
Else
GUICtrlSendMsg($hwnd, $tcm_removeimage, $iindex, 0)
EndIf
EndFunc
Func _guictrltab_setcurfocus($hwnd, $iindex)
If IsHWnd($hwnd) Then
_sendmessage($hwnd, $tcm_setcurfocus, $iindex)
Else
GUICtrlSendMsg($hwnd, $tcm_setcurfocus, $iindex, 0)
EndIf
EndFunc
Func _guictrltab_setcursel($hwnd, $iindex)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $tcm_setcursel, $iindex)
Else
Return GUICtrlSendMsg($hwnd, $tcm_setcursel, $iindex, 0)
EndIf
EndFunc

tyle)

Func _guictrltab_setextendedstyle($hwnd, $istyle)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $tcm_setextendedstyle, 0, $is
Else

istyle)
EndFunc

Return GUICtrlSendMsg($hwnd, $tcm_setextendedstyle, 0, $

EndIf

Func _guictrltab_setimagelist($hwnd, $himage)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $tcm_setimagelist, 0, $himage
, 0, "wparam", "handle", "handle")
Else
Return Ptr(GUICtrlSendMsg($hwnd, $tcm_setimagelist, 0, $
himage))
EndIf
EndFunc
Func _guictrltab_setitem($hwnd, $iindex, $stext = -1, $istate = -1, $iim
age = -1, $iparam = -1)
If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
Local $titem = DllStructCreate($tagtcitem)
Local $ibuffer, $tbuffer, $imask = 0, $iret
Local $bunicode = _guictrltab_getunicodeformat($hwnd)
If IsString($stext) Then
$ibuffer = StringLen($stext) + 1
If $bunicode Then
$tbuffer = DllStructCreate("wchar Text[" & $ibuf
fer & "]")
$ibuffer *= 2

Else
er & "]")

r))

ibuffer)
mory) <> 0
mory) <> 0

EndFunc

$tbuffer = DllStructCreate("char Text[" & $ibuff

EndIf
DllStructSetData($tbuffer, "Text", $stext)
DllStructSetData($titem, "Text", DllStructGetPtr($tbuffe
$imask = $tcif_text
EndIf
If $istate <> -1 Then
DllStructSetData($titem, "State", $istate)
DllStructSetData($titem, "StateMask", $istate)
$imask = BitOR($imask, $tcif_state)
EndIf
If $iimage <> -1 Then
DllStructSetData($titem, "Image", $iimage)
$imask = BitOR($imask, $tcif_image)
EndIf
If $iparam <> -1 Then
DllStructSetData($titem, "Param", $iparam)
$imask = BitOR($imask, $tcif_param)
EndIf
DllStructSetData($titem, "Mask", $imask)
Local $iitem = DllStructGetSize($titem)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $iitem + 8192, $tmemmap)
Local $ptext = $pmemory + 4096
DllStructSetData($titem, "Text", $ptext)
_memwrite($tmemmap, $titem, $pmemory, $iitem)
If IsString($stext) Then _memwrite($tmemmap, $tbuffer, $ptext, $
If $bunicode Then
$iret = _sendmessage($hwnd, $tcm_setitemw, $iindex, $pme
Else

$iret = _sendmessage($hwnd, $tcm_setitema, $iindex, $pme

EndIf
_memfree($tmemmap)
Return $iret

Func _guictrltab_setitemimage($hwnd, $iindex, $iimage)


Return _guictrltab_setitem($hwnd, $iindex, -1, -1, $iimage)
EndFunc
Func _guictrltab_setitemparam($hwnd, $iindex, $iparam)
Return _guictrltab_setitem($hwnd, $iindex, -1, -1, -1, $iparam)
EndFunc
Func _guictrltab_setitemsize($hwnd, $iwidth, $iheight)
If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $tcm_setitemsize, 0, _winapi_
makelong($iwidth, $iheight))
Else
Return GUICtrlSendMsg($hwnd, $tcm_setitemsize, 0, _winap
i_makelong($iwidth, $iheight))
EndIf
EndFunc

Func _guictrltab_setitemstate($hwnd, $iindex, $istate)


Return _guictrltab_setitem($hwnd, $iindex, -1, $istate)
EndFunc
Func _guictrltab_setitemtext($hwnd, $iindex, $stext)
Return _guictrltab_setitem($hwnd, $iindex, $stext)
EndFunc

width)

Func _guictrltab_setmintabwidth($hwnd, $iminwidth)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $tcm_setmintabwidth, 0, $imin
Else

inwidth)

Return GUICtrlSendMsg($hwnd, $tcm_setmintabwidth, 0, $im

EndIf

EndFunc

Func _guictrltab_setpadding($hwnd, $ihorz, $ivert)


If IsHWnd($hwnd) Then
_sendmessage($hwnd, $tcm_setpadding, 0, _winapi_makelong
($ihorz, $ivert))
Else
GUICtrlSendMsg($hwnd, $tcm_setpadding, 0, _winapi_makelo
ng($ihorz, $ivert))
EndIf
EndFunc

hwnd")

Func _guictrltab_settooltips($hwnd, $htooltip)


If IsHWnd($hwnd) Then
_sendmessage($hwnd, $tcm_settooltips, $htooltip, 0, 0, "
Else

GUICtrlSendMsg($hwnd, $tcm_settooltips, $htooltip, 0)

EndFunc

EndIf

Func _guictrltab_setunicodeformat($hwnd, $bunicode)


If IsHWnd($hwnd) Then
Return _sendmessage($hwnd, $tcm_setunicodeformat, $bunic
ode) <> 0
Else
Return GUICtrlSendMsg($hwnd, $tcm_setunicodeformat, $bun
icode, 0) <> 0
EndIf
EndFunc
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$fw_dontcare = 0
$fw_thin = 100
$fw_extralight = 200
$fw_ultralight = 200
$fw_light = 300
$fw_normal = 400
$fw_regular = 400
$fw_medium = 500
$fw_semibold = 600
$fw_demibold = 600
$fw_bold = 700
$fw_extrabold = 800
$fw_ultrabold = 800

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$fw_heavy = 900
$fw_black = 900
$cf_effects = 256
$cf_printerfonts = 2
$cf_screenfonts = 1
$cf_noscriptsel = 8388608
$cf_inittologfontstruct = 64
$logpixelsx = 88
$logpixelsy = 90
$ansi_charset = 0
$arabic_charset = 178
$baltic_charset = 186
$chinesebig5_charset = 136
$default_charset = 1
$easteurope_charset = 238
$gb2312_charset = 134
$greek_charset = 161
$hangeul_charset = 129
$hebrew_charset = 177
$johab_charset = 130
$mac_charset = 77
$oem_charset = 255
$russian_charset = 204
$shiftjis_charset = 128
$symbol_charset = 2
$thai_charset = 222
$turkish_charset = 162
$vietnamese_charset = 163
$out_character_precis = 2
$out_default_precis = 0
$out_device_precis = 5
$out_outline_precis = 8
$out_ps_only_precis = 10
$out_raster_precis = 6
$out_string_precis = 1
$out_stroke_precis = 3
$out_tt_only_precis = 7
$out_tt_precis = 4
$clip_character_precis = 1
$clip_default_precis = 0
$clip_dfa_disable = 48
$clip_embedded = 128
$clip_lh_angles = 16
$clip_mask = 15
$clip_dfa_override = 64
$clip_stroke_precis = 2
$clip_tt_always = 32
$antialiased_quality = 4
$default_quality = 0
$draft_quality = 1
$nonantialiased_quality = 3
$proof_quality = 2
$cleartype_quality = 5
$default_pitch = 0
$fixed_pitch = 1
$variable_pitch = 2
$ff_decorative = 80
$ff_dontcare = 0
$ff_modern = 48
$ff_roman = 16

Global Const $ff_script = 64


Global Const $ff_swiss = 32
Global Const $fs_regular = 0
Global Const $fs_bold = 1
Global Const $fs_italic = 2
Global Const $__miscconstant_cc_anycolor = 256
Global Const $__miscconstant_cc_fullopen = 2
Global Const $__miscconstant_cc_rgbinit = 1
Global Const $tagchoosecolor = "dword Size;hwnd hWndOwnder;handle hInsta
nce;dword rgbResult;ptr CustColors;dword Flags;lparam lCustData;" & "ptr lpfnHoo
k;ptr lpTemplateName"
Global Const $tagchoosefont = "dword Size;hwnd hWndOwner;handle hDC;ptr
LogFont;int PointSize;dword Flags;dword rgbColors;lparam CustData;" & "ptr fnHoo
k;ptr TemplateName;handle hInstance;ptr szStyle;word FontType;int SizeMin;int Si
zeMax"
Func _choosecolor($ireturntype = 0, $icolorref = 0, $ireftype = 0, $hwnd
ownder = 0)
Local $tagcustcolors = "dword[16]"
Local $tchoose = DllStructCreate($tagchoosecolor)
Local $tcc = DllStructCreate($tagcustcolors)
If $ireftype = 1 Then
$icolorref = Int($icolorref)
ElseIf $ireftype = 2 Then
$icolorref = Hex(String($icolorref), 6)
$icolorref = "0x" & StringMid($icolorref, 5, 2) & String
Mid($icolorref, 3, 2) & StringMid($icolorref, 1, 2)
EndIf
DllStructSetData($tchoose, "Size", DllStructGetSize($tchoose))
DllStructSetData($tchoose, "hWndOwnder", $hwndownder)
DllStructSetData($tchoose, "rgbResult", $icolorref)
DllStructSetData($tchoose, "CustColors", DllStructGetPtr($tcc))
DllStructSetData($tchoose, "Flags", BitOR($__miscconstant_cc_any
color, $__miscconstant_cc_fullopen, $__miscconstant_cc_rgbinit))
Local $aresult = DllCall("comdlg32.dll", "bool", "ChooseColor",
"struct*", $tchoose)
If @error Then Return SetError(@error, @extended, -1)
If $aresult[0] = 0 Then Return SetError(-3, -3, -1)
Local $scolor_picked = DllStructGetData($tchoose, "rgbResult")
If $ireturntype = 1 Then
Return "0x" & Hex(String($scolor_picked), 6)
ElseIf $ireturntype = 2 Then
$scolor_picked = Hex(String($scolor_picked), 6)
Return "0x" & StringMid($scolor_picked, 5, 2) & StringMi
d($scolor_picked, 3, 2) & StringMid($scolor_picked, 1, 2)
ElseIf $ireturntype = 0 Then
Return $scolor_picked
Else
Return SetError(-4, -4, -1)
EndIf
EndFunc
Func _choosefont($sfontname = "Courier New", $ipointsize = 10, $ifontcol
orref = 0, $ifontweight = 0, $bitalic = False, $bunderline = False, $bstrikethru
= False, $hwndowner = 0)
Local $iitalic = 0, $iunderline = 0, $istrikeout = 0
$ifontcolorref = BitOR(BitShift(BitAND($ifontcolorref, 255), -16
), BitAND($ifontcolorref, 65280), BitShift(BitAND($ifontcolorref, 16711680), 16)
)
Local $hdc = __misc_getdc(0)

Local $iheight = Round(($ipointsize * __misc_getdevicecaps($hdc,


$logpixelsx)) / 72, 0)
__misc_releasedc(0, $hdc)
Local $tchoosefont = DllStructCreate($tagchoosefont)
Local $tlogfont = DllStructCreate($taglogfont)
DllStructSetData($tchoosefont, "Size", DllStructGetSize($tchoose
font))
DllStructSetData($tchoosefont, "hWndOwner", $hwndowner)
DllStructSetData($tchoosefont, "LogFont", DllStructGetPtr($tlogf
ont))
DllStructSetData($tchoosefont, "PointSize", $ipointsize)
DllStructSetData($tchoosefont, "Flags", BitOR($cf_screenfonts, $
cf_printerfonts, $cf_effects, $cf_inittologfontstruct, $cf_noscriptsel))
DllStructSetData($tchoosefont, "rgbColors", $ifontcolorref)
DllStructSetData($tchoosefont, "FontType", 0)
DllStructSetData($tlogfont, "Height", $iheight)
DllStructSetData($tlogfont, "Weight", $ifontweight)
DllStructSetData($tlogfont, "Italic", $bitalic)
DllStructSetData($tlogfont, "Underline", $bunderline)
DllStructSetData($tlogfont, "Strikeout", $bstrikethru)
DllStructSetData($tlogfont, "FaceName", $sfontname)
Local $aresult = DllCall("comdlg32.dll", "bool", "ChooseFontW",
"struct*", $tchoosefont)
If @error Then Return SetError(@error, @extended, -1)
If $aresult[0] = 0 Then Return SetError(-3, -3, -1)
Local $sfacename = DllStructGetData($tlogfont, "FaceName")
If StringLen($sfacename) = 0 AND StringLen($sfontname) > 0 Then
$sfacename = $sfontname
If DllStructGetData($tlogfont, "Italic") Then $iitalic = 2
If DllStructGetData($tlogfont, "Underline") Then $iunderline = 4
If DllStructGetData($tlogfont, "Strikeout") Then $istrikeout = 8
Local $iattributes = BitOR($iitalic, $iunderline, $istrikeout)
Local $isize = DllStructGetData($tchoosefont, "PointSize") / 10
Local $icolorref = DllStructGetData($tchoosefont, "rgbColors")
Local $iweight = DllStructGetData($tlogfont, "Weight")
Local $scolor_picked = Hex(String($icolorref), 6)
Return StringSplit($iattributes & "," & $sfacename & "," & $isiz
e & "," & $iweight & "," & $icolorref & "," & "0x" & $scolor_picked & "," & "0x"
& StringMid($scolor_picked, 5, 2) & StringMid($scolor_picked, 3, 2) & StringMid
($scolor_picked, 1, 2), ",")
EndFunc
Func _clipputfile($sfilepath, $sdelimiter = "|")
Local Const $gmem_moveable = 2, $cf_hdrop = 15
$sfilepath &= $sdelimiter & $sdelimiter
Local $nglobmemsize = 2 * (StringLen($sfilepath) + 20)
Local $aresult = DllCall("user32.dll", "bool", "OpenClipboard",
"hwnd", 0)
If @error OR $aresult[0] = 0 Then Return SetError(1, _winapi_get
lasterror(), False)
Local $ierror = 0, $ilasterror = 0
$aresult = DllCall("user32.dll", "bool", "EmptyClipboard")
If @error OR NOT $aresult[0] Then
$ierror = 2
$ilasterror = _winapi_getlasterror()
Else
$aresult = DllCall("kernel32.dll", "handle", "GlobalAllo
c", "uint", $gmem_moveable, "ulong_ptr", $nglobmemsize)
If @error OR NOT $aresult[0] Then
$ierror = 3

Else
lLock", "handle", $hglobal)

$ilasterror = _winapi_getlasterror()
Local $hglobal = $aresult[0]
$aresult = DllCall("kernel32.dll", "ptr", "Globa

If @error OR NOT $aresult[0] Then


$ierror = 4
$ilasterror = _winapi_getlasterror()
Else
Local $hlock = $aresult[0]
Local $tdropfiles = DllStructCreate("dwo
rd pFiles;" & $tagpoint & ";bool fNC;bool fWide;wchar[" & StringLen($sfilepath)
+ 1 & "]", $hlock)
If @error Then Return SetError(5, 6, Fal
se)
Local $tstruct = DllStructCreate("dword;
long;long;bool;bool")
DllStructSetData($tdropfiles, "pFiles",
DllStructGetSize($tstruct))
DllStructSetData($tdropfiles, "X", 0)
DllStructSetData($tdropfiles, "Y", 0)
DllStructSetData($tdropfiles, "fNC", 0)
DllStructSetData($tdropfiles, "fWide", 1
)
DllStructSetData($tdropfiles, 6, $sfilep
ath)
For $i = 1 To StringLen($sfilepath)
If DllStructGetData($tdropfiles,
6, $i) = $sdelimiter Then DllStructSetData($tdropfiles, 6, Chr(0), $i)
Next
$aresult = DllCall("user32.dll", "handle
", "SetClipboardData", "uint", $cf_hdrop, "handle", $hglobal)
If @error OR NOT $aresult[0] Then
$ierror = 6
$ilasterror = _winapi_getlasterr
or()
EndIf
$aresult = DllCall("kernel32.dll", "bool
", "GlobalUnlock", "handle", $hglobal)
If (@error OR NOT $aresult[0]) AND NOT $
ierror AND _winapi_getlasterror() Then
$ierror = 8
$ilasterror = _winapi_getlasterr
or()
EndIf
EndIf
$aresult = DllCall("kernel32.dll", "ptr", "Globa
lFree", "handle", $hglobal)
If (@error OR $aresult[0]) AND NOT $ierror Then
$ierror = 9
$ilasterror = _winapi_getlasterror()
EndIf
EndIf
EndIf
$aresult = DllCall("user32.dll", "bool", "CloseClipboard")
If (@error OR NOT $aresult[0]) AND NOT $ierror Then Return SetEr
ror(7, _winapi_getlasterror(), False)
If $ierror Then Return SetError($ierror, $ilasterror, False)
Return True
EndFunc

Func _mousetrap($ileft = 0, $itop = 0, $iright = 0, $ibottom = 0)


Local $areturn = 0
If $ileft = Default Then $ileft = 0
If $itop = Default Then $itop = 0
If $iright = Default Then $iright = 0
If $ibottom = Default Then $ibottom = 0
If @NumParams = 0 Then
$areturn = DllCall("user32.dll", "bool", "ClipCursor", "
ptr", 0)
If @error OR NOT $areturn[0] Then Return SetError(1, _wi
napi_getlasterror(), False)
Else
If @NumParams = 2 Then
$iright = $ileft + 1
$ibottom = $itop + 1
EndIf
Local $trect = DllStructCreate($tagrect)
DllStructSetData($trect, "Left", $ileft)
DllStructSetData($trect, "Top", $itop)
DllStructSetData($trect, "Right", $iright)
DllStructSetData($trect, "Bottom", $ibottom)
$areturn = DllCall("user32.dll", "bool", "ClipCursor", "
struct*", $trect)
If @error OR NOT $areturn[0] Then Return SetError(2, _wi
napi_getlasterror(), False)
EndIf
Return True
EndFunc
Func _singleton($soccurrencename, $iflag = 0)
Local Const $error_already_exists = 183
Local Const $security_descriptor_revision = 1
Local $tsecurityattributes = 0
If BitAND($iflag, 2) Then
Local $tsecuritydescriptor = DllStructCreate("byte;byte;
word;ptr[4]")
Local $aret = DllCall("advapi32.dll", "bool", "Initializ
eSecurityDescriptor", "struct*", $tsecuritydescriptor, "dword", $security_descri
ptor_revision)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then
$aret = DllCall("advapi32.dll", "bool", "SetSecu
rityDescriptorDacl", "struct*", $tsecuritydescriptor, "bool", 1, "ptr", 0, "bool
", 0)
If @error Then Return SetError(@error, @extended
, 0)
If $aret[0] Then
$tsecurityattributes = DllStructCreate($
tagsecurity_attributes)
DllStructSetData($tsecurityattributes, 1
, DllStructGetSize($tsecurityattributes))
DllStructSetData($tsecurityattributes, 2
, DllStructGetPtr($tsecuritydescriptor))
DllStructSetData($tsecurityattributes, 3
, 0)
EndIf
EndIf
EndIf
Local $ahandle = DllCall("kernel32.dll", "handle", "CreateMutexW

", "struct*", $tsecurityattributes, "bool", 1, "wstr", $soccurrencename)


If @error Then Return SetError(@error, @extended, 0)
Local $alasterror = DllCall("kernel32.dll", "dword", "GetLastErr
or")
If @error Then Return SetError(@error, @extended, 0)
If $alasterror[0] = $error_already_exists Then
If BitAND($iflag, 1) Then
DllCall("kernel32.dll", "bool", "CloseHandle", "
handle", $ahandle[0])
If @error Then Return SetError(@error, @extended
, 0)
Return SetError($alasterror[0], $alasterror[0],
0)
Else
Exit -1
EndIf
EndIf
Return $ahandle[0]
EndFunc
Func _ispressed($shexkey, $vdll = "user32.dll")
Local $a_r = DllCall($vdll, "short", "GetAsyncKeyState", "int",
"0x" & $shexkey)
If @error Then Return SetError(@error, @extended, False)
Return BitAND($a_r[0], 32768) <> 0
EndFunc
Func _versioncompare($sversion1, $sversion2)
If $sversion1 = $sversion2 Then Return 0
Local $ssubversion1 = "", $ssubversion2 = ""
If StringIsAlpha(StringRight($sversion1, 1)) Then
$ssubversion1 = StringRight($sversion1, 1)
$sversion1 = StringTrimRight($sversion1, 1)
EndIf
If StringIsAlpha(StringRight($sversion2, 1)) Then
$ssubversion2 = StringRight($sversion2, 1)
$sversion2 = StringTrimRight($sversion2, 1)
EndIf
Local $aversion1 = StringSplit($sversion1, ".,"), $aversion2 = S
tringSplit($sversion2, ".,")
Local $ipartdifference = ($aversion1[0] - $aversion2[0])
If $ipartdifference < 0 Then
ReDim $aversion1[UBound($aversion2)]
$aversion1[0] = UBound($aversion1) - 1
For $i = (UBound($aversion1) - Abs($ipartdifference)) To
$aversion1[0]
$aversion1[$i] = "0"
Next
ElseIf $ipartdifference > 0 Then
ReDim $aversion2[UBound($aversion1)]
$aversion2[0] = UBound($aversion2) - 1
For $i = (UBound($aversion2) - Abs($ipartdifference)) To
$aversion2[0]
$aversion2[$i] = "0"
Next
EndIf
For $i = 1 To $aversion1[0]
If StringIsDigit($aversion1[$i]) AND StringIsDigit($aver
sion2[$i]) Then
If Number($aversion1[$i]) > Number($aversion2[$i

]) Then

Return SetExtended(2, 1)
ElseIf Number($aversion1[$i]) < Number($aversion

2[$i]) Then

Return SetExtended(2, -1)


ElseIf $i = $aversion1[0] Then
If $ssubversion1 > $ssubversion2 Then
Return SetExtended(3, 1)
ElseIf $ssubversion1 < $ssubversion2 The

Else

EndIf

EndIf

Return SetExtended(3, -1)

If $aversion1[$i] > $aversion2[$i] Then


Return SetExtended(1, 1)
ElseIf $aversion1[$i] < $aversion2[$i] Then
Return SetExtended(1, -1)
EndIf

EndFunc

EndIf
Next
Return SetExtended(Abs($ipartdifference), 0)

Func __misc_getdc($hwnd)
Local $aresult = DllCall("user32.dll", "handle", "GetDC", "hwnd"
, $hwnd)
If @error OR NOT $aresult[0] Then Return SetError(1, _winapi_get
lasterror(), 0)
Return $aresult[0]
EndFunc
Func __misc_getdevicecaps($hdc, $iindex)
Local $aresult = DllCall("gdi32.dll", "int", "GetDeviceCaps", "h
andle", $hdc, "int", $iindex)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func __misc_releasedc($hwnd, $hdc)
Local $aresult = DllCall("user32.dll", "int", "ReleaseDC", "hwnd
", $hwnd, "handle", $hdc)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0] <> 0
EndFunc
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const $__ipaddressconstant_wm_user = 1024


Const $ipm_clearaddress = ($__ipaddressconstant_wm_user + 100)
Const $ipm_setaddress = ($__ipaddressconstant_wm_user + 101)
Const $ipm_getaddress = ($__ipaddressconstant_wm_user + 102)
Const $ipm_setrange = ($__ipaddressconstant_wm_user + 103)
Const $ipm_setfocus = ($__ipaddressconstant_wm_user + 104)
Const $ipm_isblank = ($__ipaddressconstant_wm_user + 105)
Const $ipn_first = (-860)
Const $ipn_fieldchanged = ($ipn_first + 0)
$__g_hiplastwnd
Const $__ipaddressconstant_classname = "SysIPAddress32"
Const $__ipaddressconstant_default_gui_font = 17
Const $__ipaddressconstant_logpixelsx = 88
Const $__ipaddressconstant_proof_quality = 2

Func _guictrlipaddress_create($hwnd, $ix, $iy, $iwidth = 125, $iheight =


25, $istyles = 0, $iexstyles = 0)
If NOT IsHWnd($hwnd) Then Return SetError(1, 0, 0)
If $istyles = -1 Then $istyles = 0
If $iexstyles = -1 Then $iexstyles = 0
Local $istyle = BitOR($__udfguiconstant_ws_child, $__udfguiconst
ant_ws_visible, $__udfguiconstant_ws_tabstop, $istyles)
Local Const $icc_internet_classes = 2048
Local $ticce = DllStructCreate("dword dwSize;dword dwICC")
DllStructSetData($ticce, "dwSize", DllStructGetSize($ticce))
DllStructSetData($ticce, "dwICC", $icc_internet_classes)
DllCall("comctl32.dll", "bool", "InitCommonControlsEx", "struct*
", $ticce)
If @error Then Return SetError(@error, @extended, 0)
Local $nctrlid = __udf_getnextglobalid($hwnd)
If @error Then Return SetError(@error, @extended, 0)
Local $hipaddress = _winapi_createwindowex($iexstyles, $__ipaddr
essconstant_classname, "", $istyle, $ix, $iy, $iwidth, $iheight, $hwnd, $nctrlid
)
_winapi_setfont($hipaddress, _winapi_getstockobject($__ipaddress
constant_default_gui_font))
Return $hipaddress
EndFunc
Func _guictrlipaddress_clearaddress($hwnd)
_sendmessage($hwnd, $ipm_clearaddress)
EndFunc
Func _guictrlipaddress_destroy($hwnd)
If NOT _winapi_isclassname($hwnd, $__ipaddressconstant_classname
) Then Return SetError(2, 2, False)
Local $idestroyed = 0
If _winapi_inprocess($hwnd, $__g_hiplastwnd) Then
Local $nctrlid = _winapi_getdlgctrlid($hwnd)
Local $hparent = _winapi_getparent($hwnd)
$idestroyed = _winapi_destroywindow($hwnd)
Local $iret = __udf_freeglobalid($hparent, $nctrlid)
If NOT $iret Then
EndIf
Else
Return SetError(1, 1, False)
EndIf
If $idestroyed Then $hwnd = 0
Return $idestroyed <> 0
EndFunc
Func _guictrlipaddress_get($hwnd)
Local $tip = _guictrlipaddress_getex($hwnd)
If @error Then Return SetError(2, 2, "")
Return StringFormat("%d.%d.%d.%d", DllStructGetData($tip, "Field
1"), DllStructGetData($tip, "Field2"), DllStructGetData($tip, "Field3"), DllStru
ctGetData($tip, "Field4"))
EndFunc
Func _guictrlipaddress_getarray($hwnd)
Local $tip = _guictrlipaddress_getex($hwnd)
Local $aip[4]
$aip[0] = DllStructGetData($tip, "Field1")
$aip[1] = DllStructGetData($tip, "Field2")

EndFunc

$aip[2] = DllStructGetData($tip, "Field3")


$aip[3] = DllStructGetData($tip, "Field4")
Return $aip

Func _guictrlipaddress_getex($hwnd)
Local $tip = DllStructCreate($taggetipaddress)
If @error Then Return SetError(1, 1, "")
If _winapi_inprocess($hwnd, $__g_hiplastwnd) Then
_sendmessage($hwnd, $ipm_getaddress, 0, $tip, 0, "wparam
", "struct*")
Else
Local $iip = DllStructGetSize($tip)
Local $tmemmap
Local $pmemory = _meminit($hwnd, $iip, $tmemmap)
_sendmessage($hwnd, $ipm_getaddress, 0, $pmemory, 0, "wp
aram", "ptr")
_memread($tmemmap, $pmemory, $tip, $iip)
_memfree($tmemmap)
EndIf
Return $tip
EndFunc
Func _guictrlipaddress_isblank($hwnd)
Return _sendmessage($hwnd, $ipm_isblank) <> 0
EndFunc

x])

Func _guictrlipaddress_set($hwnd, $saddress)


Local $aaddress = StringSplit($saddress, ".")
If $aaddress[0] = 4 Then
Local $tip = DllStructCreate($taggetipaddress)
For $x = 1 To 4
DllStructSetData($tip, "Field" & $x, $aaddress[$

EndFunc

ss[$x])

EndIf

Next
_guictrlipaddress_setex($hwnd, $tip)

Func _guictrlipaddress_setarray($hwnd, $aaddress)


If UBound($aaddress) = 4 Then
Local $tip = DllStructCreate($taggetipaddress)
For $x = 0 To 3
DllStructSetData($tip, "Field" & $x + 1, $aaddre

EndFunc

EndIf

Next
_guictrlipaddress_setex($hwnd, $tip)

Func _guictrlipaddress_setex($hwnd, $tip)


_sendmessage($hwnd, $ipm_setaddress, 0, _winapi_makelong(BitOR(D
llStructGetData($tip, "Field4"), 256 * DllStructGetData($tip, "Field3")), BitOR(
DllStructGetData($tip, "Field2"), 256 * DllStructGetData($tip, "Field1"))))
EndFunc
Func _guictrlipaddress_setfocus($hwnd, $iindex)
_sendmessage($hwnd, $ipm_setfocus, $iindex)
EndFunc

Func _guictrlipaddress_setfont($hwnd, $sfacename = "Arial", $ifontsize =


12, $ifontweight = 400, $bfontitalic = False)
Local $hdc = _winapi_getdc(0)
Local $iheight = Round(($ifontsize * _winapi_getdevicecaps($hdc,
$__ipaddressconstant_logpixelsx)) / 72, 0)
_winapi_releasedc(0, $hdc)
Local $tfont = DllStructCreate($taglogfont)
DllStructSetData($tfont, "Height", $iheight)
DllStructSetData($tfont, "Weight", $ifontweight)
DllStructSetData($tfont, "Italic", $bfontitalic)
DllStructSetData($tfont, "Underline", False)
DllStructSetData($tfont, "Strikeout", False)
DllStructSetData($tfont, "Quality", $__ipaddressconstant_proof_q
uality)
DllStructSetData($tfont, "FaceName", $sfacename)
Local $hfont = _winapi_createfontindirect($tfont)
_winapi_setfont($hwnd, $hfont)
EndFunc
Func _guictrlipaddress_setrange($hwnd, $iindex, $ilowrange = 0, $ihighra
nge = 255)
If ($ilowrange < 0 OR $ilowrange > $ihighrange) OR $ihighrange >
255 OR ($iindex < 0 OR $iindex > 3) Then Return SetError(-1, -1, False)
Return _sendmessage($hwnd, $ipm_setrange, $iindex, BitOR($ilowra
nge, 256 * $ihighrange)) <> 0
EndFunc
Func _guictrlipaddress_showhide($hwnd, $istate)
If $istate <> @SW_HIDE AND $istate <> @SW_SHOW Then Return SetEr
ror(1, 1, 0)
Return _winapi_showwindow($hwnd, $istate) <> 0
EndFunc
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$acs_center = 1
$acs_transparent = 2
$acs_autoplay = 4
$acs_timer = 8
$acs_nontransparent = 16
$gui_ss_default_avi = $acs_transparent
$__aviconstant_wm_user = 1024
$acm_opena = $__aviconstant_wm_user + 100
$acm_play = $__aviconstant_wm_user + 101
$acm_stop = $__aviconstant_wm_user + 102
$acm_isplaying = $__aviconstant_wm_user + 104
$acm_openw = $__aviconstant_wm_user + 103
$acn_start = 1
$acn_stop = 2
$dts_shortdateformat = 0
$dts_updown = 1
$dts_shownone = 2
$dts_longdateformat = 4
$dts_timeformat = 9
$dts_rightalign = 32
$dts_shortdatecenturyformat = 12
$dts_appcanparse = 16
$dmw_longname = 0
$dmw_shortname = 1
$dmw_locale_longname = 2
$dmw_locale_shortname = 3
$gdt_error = -1

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$gdt_valid = 0
$gdt_none = 1
$gdtr_min = 1
$gdtr_max = 2
$mcht_nowhere = 0
$mcht_title = 65536
$mcht_calendar = 131072
$mcht_todaylink = 196608
$mcht_next = 16777216
$mcht_prev = 33554432
$mcht_titlebk = 65536
$mcht_titlemonth = 65537
$mcht_titleyear = 65538
$mcht_titlebtnnext = 16842755
$mcht_titlebtnprev = 33619971
$mcht_calendarbk = 131072
$mcht_calendardate = 131073
$mcht_calendarday = 131074
$mcht_calendarweeknum = 131075
$mcht_calendardatenext = 16908288
$mcht_calendardateprev = 33685504
$mcs_daystate = 1
$mcs_multiselect = 2
$mcs_weeknumbers = 4
$mcs_notodaycircle = 8
$mcs_notoday = 16
$mcs_notrailingdates = 64
$mcs_shortdaysofweek = 128
$mcs_noselchangeonnav = 256
$mcm_first = 4096
$mcm_getcalendarborder = ($mcm_first + 31)
$mcm_getcalendarcount = ($mcm_first + 23)
$mcm_getcalendargridinfo = ($mcm_first + 24)
$mcm_getcalid = ($mcm_first + 27)
$mcm_getcolor = ($mcm_first + 11)
$mcm_getcurrentview = ($mcm_first + 22)
$mcm_getcursel = ($mcm_first + 1)
$mcm_getfirstdayofweek = ($mcm_first + 16)
$mcm_getmaxselcount = ($mcm_first + 3)
$mcm_getmaxtodaywidth = ($mcm_first + 21)
$mcm_getminreqrect = ($mcm_first + 9)
$mcm_getmonthdelta = ($mcm_first + 19)
$mcm_getmonthrange = ($mcm_first + 7)
$mcm_getrange = ($mcm_first + 17)
$mcm_getselrange = ($mcm_first + 5)
$mcm_gettoday = ($mcm_first + 13)
$mcm_getunicodeformat = 8192 + 6
$mcm_hittest = ($mcm_first + 14)
$mcm_setcalendarborder = ($mcm_first + 30)
$mcm_setcalid = ($mcm_first + 28)
$mcm_setcolor = ($mcm_first + 10)
$mcm_setcurrentview = ($mcm_first + 32)
$mcm_setcursel = ($mcm_first + 2)
$mcm_setdaystate = ($mcm_first + 8)
$mcm_setfirstdayofweek = ($mcm_first + 15)
$mcm_setmaxselcount = ($mcm_first + 4)
$mcm_setmonthdelta = ($mcm_first + 20)
$mcm_setrange = ($mcm_first + 18)
$mcm_setselrange = ($mcm_first + 6)
$mcm_settoday = ($mcm_first + 12)

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$mcm_setunicodeformat = 8192 + 5
$mcm_sizerecttomin = ($mcm_first + 29)
$mcn_first = -746
$mcn_selchange = ($mcn_first - 3)
$mcn_getdaystate = ($mcn_first - 1)
$mcn_select = ($mcn_first)
$mcn_viewchange = ($mcn_first - 4)
$mcsc_background = 0
$mcsc_monthbk = 4
$mcsc_text = 1
$mcsc_titlebk = 2
$mcsc_titletext = 3
$mcsc_trailingtext = 5
$dtm_first = 4096
$dtm_getsystemtime = $dtm_first + 1
$dtm_setsystemtime = $dtm_first + 2
$dtm_getrange = $dtm_first + 3
$dtm_setrange = $dtm_first + 4
$dtm_setformat = $dtm_first + 5
$dtm_setmccolor = $dtm_first + 6
$dtm_getmccolor = $dtm_first + 7
$dtm_getmonthcal = $dtm_first + 8
$dtm_setmcfont = $dtm_first + 9
$dtm_getmcfont = $dtm_first + 10
$dtm_setformatw = $dtm_first + 50
$dtn_first = -740
$dtn_first2 = -753
$dtn_datetimechange = $dtn_first2 - 6
$dtn_userstring = $dtn_first2 - 5
$dtn_wmkeydown = $dtn_first2 - 4
$dtn_format = $dtn_first2 - 3
$dtn_formatquery = $dtn_first2 - 2
$dtn_dropdown = $dtn_first2 - 1
$dtn_closeup = $dtn_first2 + 0
$dtn_userstringw = $dtn_first - 5
$dtn_wmkeydownw = $dtn_first - 4
$dtn_formatw = $dtn_first - 3
$dtn_formatqueryw = $dtn_first - 2
$gui_ss_default_date = $dts_longdateformat
$gui_ss_default_monthcal = 0
$lbs_notify = 1
$lbs_sort = 2
$lbs_noredraw = 4
$lbs_multiplesel = 8
$lbs_ownerdrawfixed = 16
$lbs_ownerdrawvariable = 32
$lbs_hasstrings = 64
$lbs_usetabstops = 128
$lbs_nointegralheight = 256
$lbs_multicolumn = 512
$lbs_wantkeyboardinput = 1024
$lbs_extendedsel = 2048
$lbs_disablenoscroll = 4096
$lbs_nodata = 8192
$lbs_nosel = 16384
$lbs_combobox = 32768
$lbs_standard = 3
$gui_ss_default_list = 10485763
$lb_err = -1
$lb_errattribute = -3

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$lb_errrequired = -4
$lb_errspace = -2
$lb_addstring = 384
$lb_insertstring = 385
$lb_deletestring = 386
$lb_selitemrangeex = 387
$lb_resetcontent = 388
$lb_setsel = 389
$lb_setcursel = 390
$lb_getsel = 391
$lb_getcursel = 392
$lb_gettext = 393
$lb_gettextlen = 394
$lb_getcount = 395
$lb_selectstring = 396
$lb_dir = 397
$lb_gettopindex = 398
$lb_findstring = 399
$lb_getselcount = 400
$lb_getselitems = 401
$lb_settabstops = 402
$lb_gethorizontalextent = 403
$lb_sethorizontalextent = 404
$lb_setcolumnwidth = 405
$lb_addfile = 406
$lb_settopindex = 407
$lb_getitemrect = 408
$lb_getitemdata = 409
$lb_setitemdata = 410
$lb_selitemrange = 411
$lb_setanchorindex = 412
$lb_getanchorindex = 413
$lb_setcaretindex = 414
$lb_getcaretindex = 415
$lb_setitemheight = 416
$lb_getitemheight = 417
$lb_findstringexact = 418
$lb_setlocale = 421
$lb_getlocale = 422
$lb_setcount = 423
$lb_initstorage = 424
$lb_itemfrompoint = 425
$lb_multipleaddstring = 433
$lb_getlistboxinfo = 434
$lbn_errspace = -2
$lbn_selchange = 1
$lbn_dblclk = 2
$lbn_selcancel = 3
$lbn_setfocus = 4
$lbn_killfocus = 5
$pbs_marquee = 8
$pbs_smooth = 1
$pbs_smoothreverse = 16
$pbs_vertical = 4
$gui_ss_default_progress = 0
$__progressbarconstant_wm_user = 1024
$pbm_deltapos = $__progressbarconstant_wm_user + 3
$pbm_getbarcolor = 1039
$pbm_getbkcolor = 1038
$pbm_getpos = $__progressbarconstant_wm_user + 8

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$pbm_getrange = $__progressbarconstant_wm_user + 7
$pbm_getstate = 1041
$pbm_getstep = 1037
$pbm_setbarcolor = $__progressbarconstant_wm_user + 9
$pbm_setbkcolor = 8192 + 1
$pbm_setmarquee = $__progressbarconstant_wm_user + 10
$pbm_setpos = $__progressbarconstant_wm_user + 2
$pbm_setrange = $__progressbarconstant_wm_user + 1
$pbm_setrange32 = $__progressbarconstant_wm_user + 6
$pbm_setstate = 1040
$pbm_setstep = $__progressbarconstant_wm_user + 4
$pbm_stepit = $__progressbarconstant_wm_user + 5
$__richeditconstant_wm_user = 1024
$em_autourldetect = $__richeditconstant_wm_user + 91
$em_canpaste = $__richeditconstant_wm_user + 50
$em_canredo = $__richeditconstant_wm_user + 85
$em_displayband = $__richeditconstant_wm_user + 51
$em_exgetsel = $__richeditconstant_wm_user + 52
$em_exlimittext = $__richeditconstant_wm_user + 53
$em_exlinefromchar = $__richeditconstant_wm_user + 54
$em_exsetsel = $__richeditconstant_wm_user + 55
$em_findtext = $__richeditconstant_wm_user + 56
$em_findtextex = $__richeditconstant_wm_user + 79
$em_findtextexw = $__richeditconstant_wm_user + 124
$em_findtextw = $__richeditconstant_wm_user + 123
$em_findwordbreak = $__richeditconstant_wm_user + 76
$em_formatrange = $__richeditconstant_wm_user + 57
$em_getautourldetect = $__richeditconstant_wm_user + 92
$em_getbidioptions = $__richeditconstant_wm_user + 201
$em_getcharformat = $__richeditconstant_wm_user + 58
$em_geteditstyle = $__richeditconstant_wm_user + 205
$em_geteventmask = $__richeditconstant_wm_user + 59
$em_getimecolor = $__richeditconstant_wm_user + 105
$em_getimecompmode = $__richeditconstant_wm_user + 122
$em_getimemodebias = $__richeditconstant_wm_user + 127
$em_getimeoptions = $__richeditconstant_wm_user + 107
$em_getlangoptions = $__richeditconstant_wm_user + 121
$em_getoptions = $__richeditconstant_wm_user + 78
$em_getparaformat = $__richeditconstant_wm_user + 61
$em_getpunctuation = $__richeditconstant_wm_user + 101
$em_getredoname = $__richeditconstant_wm_user + 87
$em_getscrollpos = $__richeditconstant_wm_user + 221
$em_getseltext = $__richeditconstant_wm_user + 62
$em_gettextex = $__richeditconstant_wm_user + 94
$em_gettextlengthex = $__richeditconstant_wm_user + 95
$em_gettextmode = $__richeditconstant_wm_user + 90
$em_gettextrange = $__richeditconstant_wm_user + 75
$em_gettypographyoptions = $__richeditconstant_wm_user + 20

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$em_getundoname = $__richeditconstant_wm_user + 86
$em_getwordbreakprocex = $__richeditconstant_wm_user + 80
$em_getwordwrapmode = $__richeditconstant_wm_user + 103
$em_getzoom = $__richeditconstant_wm_user + 224
$em_hideselection = $__richeditconstant_wm_user + 63
$em_pastespecial = $__richeditconstant_wm_user + 64
$em_reconversion = $__richeditconstant_wm_user + 125
$em_redo = $__richeditconstant_wm_user + 84
$em_requestresize = $__richeditconstant_wm_user + 65
$em_selectiontype = $__richeditconstant_wm_user + 66
$em_setbidioptions = $__richeditconstant_wm_user + 200

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$em_setbkgndcolor = $__richeditconstant_wm_user + 67
$em_setcharformat = $__richeditconstant_wm_user + 68
$em_seteditstyle = $__richeditconstant_wm_user + 204
$em_seteventmask = $__richeditconstant_wm_user + 69
$em_setfontsize = $__richeditconstant_wm_user + 223
$em_setimecolor = $__richeditconstant_wm_user + 104
$em_setimemodebias = $__richeditconstant_wm_user + 126
$em_setimeoptions = $__richeditconstant_wm_user + 106
$em_setlangoptions = $__richeditconstant_wm_user + 120
$em_setolecallback = $__richeditconstant_wm_user + 70
$em_setoptions = $__richeditconstant_wm_user + 77
$em_setpalette = $__richeditconstant_wm_user + 93
$em_setparaformat = $__richeditconstant_wm_user + 71
$em_setpunctuation = $__richeditconstant_wm_user + 100
$em_setscrollpos = $__richeditconstant_wm_user + 222
$em_settargetdevice = $__richeditconstant_wm_user + 72
$em_settextex = $__richeditconstant_wm_user + 97
$em_settextmode = $__richeditconstant_wm_user + 89
$em_settypographyoptions = $__richeditconstant_wm_user + 20

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$em_setundolimit = $__richeditconstant_wm_user + 82
$em_setwordbreakprocex = $__richeditconstant_wm_user + 81
$em_setwordwrapmode = $__richeditconstant_wm_user + 102
$em_setzoom = $__richeditconstant_wm_user + 225
$em_showscrollbar = $__richeditconstant_wm_user + 96
$em_stopgrouptyping = $__richeditconstant_wm_user + 88
$em_streamin = $__richeditconstant_wm_user + 73
$em_streamout = $__richeditconstant_wm_user + 74
$en_alignltr = 1808
$en_alignrtl = 1809
$en_correcttext = 1797
$en_dragdropdone = 1804
$en_dropfiles = 1795
$en_imechange = 1799
$en_link = 1803
$en_msgfilter = 1792
$en_objectpositions = 1802
$en_oleopfailed = 1801
$en_protected = 1796
$en_requestresize = 1793
$en_saveclipboard = 1800
$en_selchange = 1794
$en_stopnoundo = 1798
$enm_change = 1
$enm_correcttext = 4194304
$enm_dragdropdone = 16
$enm_dropfiles = 1048576
$enm_imechange = 8388608
$enm_keyevents = 65536
$enm_link = 67108864
$enm_mouseevents = 131072
$enm_objectpositions = 33554432
$enm_protected = 2097152
$enm_requestresize = 262144
$enm_scroll = 4
$enm_scrollevents = 8
$enm_selchange = 524288
$enm_update = 2
$bom_defparadir = 1
$bom_plaintext = 2

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$bom_neutraloverride = 4
$bom_contextreading = 8
$bom_contextalignment = 16
$bom_legacybidiclass = 64
$boe_rtldir = 1
$boe_plaintext = 2
$boe_neutraloverride = 4
$boe_contextreading = 8
$boe_contextalignment = 16
$boe_legacybidiclass = 64
$st_default = 0
$st_keepundo = 1
$st_selection = 2
$gt_default = 0
$gt_selection = 2
$gt_usecrlf = 1
$gtl_close = 4
$gtl_default = 0
$gtl_numbytes = 16
$gtl_numchars = 8
$gtl_precise = 2
$gtl_usecrlf = 1
$cfu_underlinenone = 0
$cfu_underline = 1
$cfu_underlineword = 2
$cfu_underlinedouble = 3
$cfu_underlinedotted = 4
$cp_acp = 0
$cp_unicode = 1200
$cfe_subscript = 65536
$cfe_superscript = 131072
$cfm_allcaps = 128
$cfm_animation = 262144
$cfm_backcolor = 67108864
$cfm_bold = 1
$cfm_charset = 134217728
$cfm_color = 1073741824
$cfm_disabled = 8192
$cfm_emboss = 2048
$cfm_face = 536870912
$cfm_hidden = 256
$cfm_imprint = 4096
$cfm_italic = 2
$cfm_kerning = 1048576
$cfm_lcid = 33554432
$cfm_link = 32
$cfm_offset = 268435456
$cfm_outline = 512
$cfm_protected = 16
$cfm_revauthor = 32768
$cfm_revised = 16384
$cfm_shadow = 1024
$cfm_size = -2147483648
$cfm_smallcaps = 64
$cfm_spacing = 2097152
$cfm_strikeout = 8
$cfm_style = 524288
$cfm_subscript = BitOR($cfe_subscript, $cfe_superscript)
$cfm_superscript = $cfm_subscript
$cfm_underline = 4

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$cfm_underlinetype = 8388608
$cfm_weight = 4194304
$cfe_allcaps = $cfm_allcaps
$cfe_autobackcolor = $cfm_backcolor
$cfe_autocolor = $cfm_color
$cfe_bold = $cfm_bold
$cfe_disabled = $cfm_disabled
$cfe_emboss = $cfm_emboss
$cfe_hidden = $cfm_hidden
$cfe_imprint = $cfm_imprint
$cfe_italic = $cfm_italic
$cfe_link = $cfm_link
$cfe_outline = $cfm_outline
$cfe_protected = $cfm_protected
$cfe_revised = $cfm_revised
$cfe_shadow = $cfm_shadow
$cfe_smallcaps = $cfm_smallcaps
$cfe_strikeout = $cfm_strikeout
$cfe_underline = $cfm_underline
$fr_matchalefhamza = -2147483648
$fr_matchdiac = 536870912
$fr_matchkashida = 1073741824
$scf_default = 0
$scf_selection = 1
$scf_word = 2
$scf_all = 4
$scf_useuirules = 8
$scf_associatefont = 16
$scf_nokbupdate = 32
$lf_facesize = 32
$max_tab_stops = 32
$pfa_left = 1
$pfa_right = 2
$pfa_center = 3
$pfa_justify = 4
$pfa_full_interword = 4
$pfe_table = 16384
$pfm_numbering = 32
$pfm_alignment = 8
$pfm_spacebefore = 64
$pfm_numberingstyle = 8192
$pfm_numberingstart = 32768
$pfm_border = 2048
$pfm_rightindent = 2
$pfm_startindent = 1
$pfm_offset = 4
$pfm_linespacing = 256
$pfm_spaceafter = 128
$pfm_numberingtab = 16384
$pfm_table = 1073741824
$pfm_tabstops = 16
$pfn_bullet = 1
$pfm_rtlpara = 65536
$pfm_keep = 131072
$pfm_keepnext = 262144
$pfm_pagebreakbefore = 524288
$pfm_nolinenumber = 1048576
$pfm_nowidowcontrol = 2097152
$pfm_donothyphen = 4194304
$pfm_sidebyside = 8388608

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$pfe_rtlpara = 1
$pfe_keep = 2
$pfe_keepnext = 4
$pfe_pagebreakbefore = 8
$pfe_nolinenumber = 16
$pfe_nowidowcontrol = 32
$pfe_donothyphen = 64
$pfe_sidebyside = 128
$pfm_shading = 4096
$wb_classify = 3
$wb_isdelimiter = 2
$wb_left = 0
$wb_leftbreak = 6
$wb_movewordleft = 4
$wb_movewordnext = 5
$wb_movewordprev = 4
$wb_movewordright = 5
$wb_nextbreak = 7
$wb_prevbreak = 6
$wb_right = 1
$wb_rightbreak = 7
$wbf_iswhite = 16
$wbf_breakline = 32
$wbf_breakafter = 64
$sf_text = 1
$sf_rtf = 2
$sf_rtfnoobjs = 3
$sf_textized = 4
$sf_unicode = 16
$sf_usecodepage = 32
$sff_plainrtf = 16384
$sff_selection = 32768
$tbcd_channel = 3
$tbcd_thumb = 2
$tbcd_tics = 1
$__sliderconstant_wm_user = 1024
$tbm_clearsel = $__sliderconstant_wm_user + 19
$tbm_cleartics = $__sliderconstant_wm_user + 9
$tbm_getbuddy = $__sliderconstant_wm_user + 33
$tbm_getchannelrect = $__sliderconstant_wm_user + 26
$tbm_getlinesize = $__sliderconstant_wm_user + 24
$tbm_getnumtics = $__sliderconstant_wm_user + 16
$tbm_getpagesize = $__sliderconstant_wm_user + 22
$tbm_getpos = $__sliderconstant_wm_user
$tbm_getptics = $__sliderconstant_wm_user + 14
$tbm_getselend = $__sliderconstant_wm_user + 18
$tbm_getselstart = $__sliderconstant_wm_user + 17
$tbm_getrangemax = $__sliderconstant_wm_user + 2
$tbm_getrangemin = $__sliderconstant_wm_user + 1
$tbm_getthumblength = $__sliderconstant_wm_user + 28
$tbm_getthumbrect = $__sliderconstant_wm_user + 25
$tbm_gettic = $__sliderconstant_wm_user + 3
$tbm_getticpos = $__sliderconstant_wm_user + 15
$tbm_gettooltips = $__sliderconstant_wm_user + 30
$tbm_getunicodeformat = 8192 + 6
$tbm_setbuddy = $__sliderconstant_wm_user + 32
$tbm_setlinesize = $__sliderconstant_wm_user + 23
$tbm_setpagesize = $__sliderconstant_wm_user + 21
$tbm_setpos = $__sliderconstant_wm_user + 5
$tbm_setrange = $__sliderconstant_wm_user + 6

Global Const $tbm_setrangemax = $__sliderconstant_wm_user + 8


Global Const $tbm_setrangemin = $__sliderconstant_wm_user + 7
Global Const $tbm_setsel = $__sliderconstant_wm_user + 10
Global Const $tbm_setselend = $__sliderconstant_wm_user + 12
Global Const $tbm_setselstart = $__sliderconstant_wm_user + 11
Global Const $tbm_setthumblength = $__sliderconstant_wm_user + 27
Global Const $tbm_settic = $__sliderconstant_wm_user + 4
Global Const $tbm_setticfreq = $__sliderconstant_wm_user + 20
Global Const $tbm_settipside = $__sliderconstant_wm_user + 31
Global Const $tbm_settooltips = $__sliderconstant_wm_user + 29
Global Const $tbm_setunicodeformat = 8192 + 5
Global Const $tbts_bottom = 2
Global Const $tbts_left = 1
Global Const $tbts_right = 3
Global Const $tbts_top = 0
Global Const $tbs_autoticks = 1
Global Const $tbs_both = 8
Global Const $tbs_bottom = 0
Global Const $tbs_downisleft = 1024
Global Const $tbs_enableselrange = 32
Global Const $tbs_fixedlength = 64
Global Const $tbs_horz = 0
Global Const $tbs_left = 4
Global Const $tbs_nothumb = 128
Global Const $tbs_noticks = 16
Global Const $tbs_reversed = 512
Global Const $tbs_right = 0
Global Const $tbs_top = 4
Global Const $tbs_tooltips = 256
Global Const $tbs_vert = 2
Global Const $gui_ss_default_slider = $tbs_autoticks
Global Const $tvs_hasbuttons = 1
Global Const $tvs_haslines = 2
Global Const $tvs_linesatroot = 4
Global Const $tvs_editlabels = 8
Global Const $tvs_disabledragdrop = 16
Global Const $tvs_showselalways = 32
Global Const $tvs_rtlreading = 64
Global Const $tvs_notooltips = 128
Global Const $tvs_checkboxes = 256
Global Const $tvs_trackselect = 512
Global Const $tvs_singleexpand = 1024
Global Const $tvs_infotip = 2048
Global Const $tvs_fullrowselect = 4096
Global Const $tvs_noscroll = 8192
Global Const $tvs_nonevenheight = 16384
Global Const $tvs_nohscroll = 32768
Global Const $tvs_default = 55
Global Const $gui_ss_default_treeview = BitOR($tvs_hasbuttons, $tvs_hasl
ines, $tvs_linesatroot, $tvs_disabledragdrop, $tvs_showselalways)
Global Const $tve_collapse = 1
Global Const $tve_expand = 2
Global Const $tve_toggle = 3
Global Const $tve_expandpartial = 16384
Global Const $tve_collapsereset = 32768
Global Const $tvgn_root = 0
Global Const $tvgn_next = 1
Global Const $tvgn_previous = 2
Global Const $tvgn_parent = 3
Global Const $tvgn_child = 4

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$tvgn_firstvisible = 5
$tvgn_nextvisible = 6
$tvgn_previousvisible = 7
$tvgn_drophilite = 8
$tvgn_caret = 9
$tvgn_lastvisible = 10
$tvht_nowhere = 1
$tvht_onitemicon = 2
$tvht_onitemlabel = 4
$tvht_onitemindent = 8
$tvht_onitembutton = 16
$tvht_onitemright = 32
$tvht_onitemstateicon = 64
$tvht_onitem = 70
$tvht_above = 256
$tvht_below = 512
$tvht_toright = 1024
$tvht_toleft = 2048
$tvi_root = -65536
$tvi_first = -65535
$tvi_last = -65534
$tvi_sort = -65533
$tvif_text = 1
$tvif_image = 2
$tvif_param = 4
$tvif_state = 8
$tvif_handle = 16
$tvif_selectedimage = 32
$tvif_children = 64
$tvif_integral = 128
$tvif_expandedimage = 256
$tvif_stateex = 512
$tvif_di_setitem = 4096
$tvsil_normal = 0
$tvsil_state = 2
$tvc_bykeyboard = 2
$tvc_bymouse = 1
$tvc_unknown = 0
$tvis_focused = 1
$tvis_selected = 2
$tvis_cut = 4
$tvis_drophilited = 8
$tvis_bold = 16
$tvis_expanded = 32
$tvis_expandedonce = 64
$tvis_expandpartial = 128
$tvis_overlaymask = 3840
$tvis_stateimagemask = 61440
$tvis_usermask = 61440
$tvis_unchecked = 4096
$tvis_checked = 8192
$tvna_add = 1
$tvna_addfirst = 2
$tvna_addchild = 3
$tvna_addchildfirst = 4
$tvna_insert = 5
$tvta_addfirst = 1
$tvta_add = 2
$tvta_insert = 3
$tv_first = 4352

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$tvm_insertitema = $tv_first + 0
$tvm_deleteitem = $tv_first + 1
$tvm_expand = $tv_first + 2
$tvm_getitemrect = $tv_first + 4
$tvm_getcount = $tv_first + 5
$tvm_getindent = $tv_first + 6
$tvm_setindent = $tv_first + 7
$tvm_getimagelist = $tv_first + 8
$tvm_setimagelist = $tv_first + 9
$tvm_getnextitem = $tv_first + 10
$tvm_selectitem = $tv_first + 11
$tvm_getitema = $tv_first + 12
$tvm_setitema = $tv_first + 13
$tvm_editlabela = $tv_first + 14
$tvm_geteditcontrol = $tv_first + 15
$tvm_getvisiblecount = $tv_first + 16
$tvm_hittest = $tv_first + 17
$tvm_createdragimage = $tv_first + 18
$tvm_sortchildren = $tv_first + 19
$tvm_ensurevisible = $tv_first + 20
$tvm_sortchildrencb = $tv_first + 21
$tvm_endeditlabelnow = $tv_first + 22
$tvm_getisearchstringa = $tv_first + 23
$tvm_settooltips = $tv_first + 24
$tvm_gettooltips = $tv_first + 25
$tvm_setinsertmark = $tv_first + 26
$tvm_setitemheight = $tv_first + 27
$tvm_getitemheight = $tv_first + 28
$tvm_setbkcolor = $tv_first + 29
$tvm_settextcolor = $tv_first + 30
$tvm_getbkcolor = $tv_first + 31
$tvm_gettextcolor = $tv_first + 32
$tvm_setscrolltime = $tv_first + 33
$tvm_getscrolltime = $tv_first + 34
$tvm_setinsertmarkcolor = $tv_first + 37
$tvm_getinsertmarkcolor = $tv_first + 38
$tvm_getitemstate = $tv_first + 39
$tvm_setlinecolor = $tv_first + 40
$tvm_getlinecolor = $tv_first + 41
$tvm_mapaccidtohtreeitem = $tv_first + 42
$tvm_maphtreeitemtoaccid = $tv_first + 43
$tvm_insertitemw = $tv_first + 50
$tvm_getitemw = $tv_first + 62
$tvm_setitemw = $tv_first + 63
$tvm_getisearchstringw = $tv_first + 64
$tvm_editlabelw = $tv_first + 65
$tvm_getunicodeformat = 8192 + 6
$tvm_setunicodeformat = 8192 + 5
$tvn_first = -400
$tvn_selchanginga = $tvn_first - 1
$tvn_selchangeda = $tvn_first - 2
$tvn_getdispinfoa = $tvn_first - 3
$tvn_setdispinfoa = $tvn_first - 4
$tvn_itemexpandinga = $tvn_first - 5
$tvn_itemexpandeda = $tvn_first - 6
$tvn_begindraga = $tvn_first - 7
$tvn_beginrdraga = $tvn_first - 8
$tvn_deleteitema = $tvn_first - 9
$tvn_beginlabeledita = $tvn_first - 10
$tvn_endlabeledita = $tvn_first - 11

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$tvn_keydown = $tvn_first - 12
$tvn_getinfotipa = $tvn_first - 13
$tvn_getinfotipw = $tvn_first - 14
$tvn_singleexpand = $tvn_first - 15
$tvn_itemchanginga = $tvn_first - 16
$tvn_itemchangingw = $tvn_first - 17
$tvn_itemchangeda = $tvn_first - 18
$tvn_itemchangedw = $tvn_first - 19
$tvn_selchangingw = $tvn_first - 50
$tvn_selchangedw = $tvn_first - 51
$tvn_getdispinfow = $tvn_first - 52
$tvn_setdispinfow = $tvn_first - 53
$tvn_itemexpandingw = $tvn_first - 54
$tvn_itemexpandedw = $tvn_first - 55
$tvn_begindragw = $tvn_first - 56
$tvn_beginrdragw = $tvn_first - 57
$tvn_deleteitemw = $tvn_first - 58
$tvn_beginlabeleditw = $tvn_first - 59
$tvn_endlabeleditw = $tvn_first - 60
$uds_wrap = 1
$uds_setbuddyint = 2
$uds_alignright = 4
$uds_alignleft = 8
$uds_arrowkeys = 32
$uds_horz = 64
$uds_nothousands = 128
$gui_ss_default_updown = $uds_alignleft

Func _processgetname($ipid)
Local $aprocesslist = ProcessList()
If NOT @error Then
For $i = 1 To $aprocesslist[0][0]
If $aprocesslist[$i][1] = $ipid Then
Return $aprocesslist[$i][0]
EndIf
Next
EndIf
Return SetError(1, 0, "")
EndFunc
Func _processgetpriority($vprocess)
Local $ierror = 0, $iextended = 0, $ireturn = -1
Local $ipid = ProcessExists($vprocess)
If NOT $ipid Then Return SetError(1, 0, -1)
Local $hdll = DllOpen("kernel32.dll")
Do
Local $aprocesshandle = DllCall($hdll, "handle", "OpenPr
ocess", "dword", $process_query_information, "bool", False, "dword", $ipid)
If @error Then
$ierror = @error + 10
$iextended = @extended
ExitLoop
EndIf
If NOT $aprocesshandle[0] Then ExitLoop
Local $apriority = DllCall($hdll, "dword", "GetPriorityC
lass", "handle", $aprocesshandle[0])
If @error Then
$ierror = @error
$iextended = @extended
EndIf

DllCall($hdll, "bool", "CloseHandle", "handle", $aproces

shandle[0])

EndFunc

If $ierror Then ExitLoop


Switch $apriority[0]
Case 64
$ireturn = 0
Case 16384
$ireturn = 1
Case 32
$ireturn = 2
Case 32768
$ireturn = 3
Case 128
$ireturn = 4
Case 256
$ireturn = 5
Case Else
$ierror = 1
$iextended = $apriority[0]
$ireturn = -1
EndSwitch
Until True
DllClose($hdll)
Return SetError($ierror, $iextended, $ireturn)

HIDE)

Func _rundos($scommand)
Local $nresult = RunWait(@ComSpec & " /C " & $scommand, "", @SW_
Return SetError(@error, @extended, $nresult)

EndFunc
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$ddl_archive = 32
$ddl_directory = 16
$ddl_drives = 16384
$ddl_exclusive = 32768
$ddl_hidden = 2
$ddl_readonly = 1
$ddl_readwrite = 0
$ddl_system = 4
$tray_item_exit = 3
$tray_item_pause = 4
$tray_item_first = 7
$tray_checked = 1
$tray_unchecked = 4
$tray_enable = 64
$tray_disable = 128
$tray_focus = 256
$tray_default = 512
$tray_event_none = 0
$tray_event_showicon = -3
$tray_event_hideicon = -4
$tray_event_flashicon = -5
$tray_event_noflashicon = -6
$tray_event_primarydown = -7
$tray_event_primaryup = -8
$tray_event_secondarydown = -9
$tray_event_secondaryup = -10
$tray_event_mouseover = -11
$tray_event_mouseout = -12

Global Const $tray_event_primarydouble = -13


Global Const $tray_event_secondarydouble = -14
Global Const $tip_iconnone = 0
Global Const $tip_iconasterisk = 1
Global Const $tip_iconexclamation = 2
Global Const $tip_iconhand = 3
Global Const $tip_nosound = 16
Global Const $tray_item_normal = 0
Global Const $tray_item_radio = 1
Global Const $tray_click_show = 0
Global Const $tray_click_primarydown = 1
Global Const $tray_click_primaryup = 2
Global Const $tray_dblclick_primary = 4
Global Const $tray_click_secondarydown = 8
Global Const $tray_click_secondaryup = 16
Global Const $tray_dblclick_secondary = 32
Global Const $tray_click_hovering = 64
Global Const $tray_iconstate_show = 1
Global Const $tray_iconstate_hide = 2
Global Const $tray_iconstate_flash = 4
Global Const $tray_iconstate_stopflash = 8
Global Const $tray_iconstate_reset = 16
Global Const $bpbf_compatiblebitmap = 0
Global Const $bpbf_dib = 1
Global Const $bpbf_topdowndib = 2
Global Const $bpbf_topdownmonodib = 3
Global Const $bppf_erase = 1
Global Const $bppf_noclip = 2
Global Const $bppf_nonclient = 4
Global Const $dtt_textcolor = 1
Global Const $dtt_bordercolor = 2
Global Const $dtt_shadowcolor = 4
Global Const $dtt_shadowtype = 8
Global Const $dtt_shadowoffset = 16
Global Const $dtt_bordersize = 32
Global Const $dtt_fontprop = 64
Global Const $dtt_colorprop = 128
Global Const $dtt_stateid = 256
Global Const $dtt_calcrect = 512
Global Const $dtt_applyoverlay = 1024
Global Const $dtt_glowsize = 2048
Global Const $dtt_callback = 4096
Global Const $dtt_composited = 8192
Global Const $dtt_validbits = BitOR($dtt_textcolor, $dtt_bordercolor, $d
tt_shadowcolor, $dtt_shadowtype, $dtt_shadowoffset, $dtt_bordersize, $dtt_fontpr
op, $dtt_colorprop, $dtt_stateid, $dtt_calcrect, $dtt_applyoverlay, $dtt_glowsiz
e, $dtt_composited)
Global Const $tst_none = 0
Global Const $tst_single = 1
Global Const $tst_continuous = 2
Global Const $stap_allow_nonclient = 1
Global Const $stap_allow_controls = 2
Global Const $stap_allow_webcontent = 4
Global Const $gbf_direct = 1
Global Const $gbf_copy = 2
Global Const $gbf_validbits = BitOR($gbf_direct, $gbf_copy)
Global Const $sz_thdocprop_author = "Author"
Global Const $sz_thdocprop_canonicalname = "ThemeName"
Global Const $sz_thdocprop_displayname = "DisplayName"
Global Const $sz_thdocprop_tooltip = "ToolTip"

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$ts_min = 0
$ts_true = 1
$ts_draw = 2
$po_class = 2
$po_global = 3
$po_notfound = 4
$po_part = 1
$po_state = 0
$tmt_bool = 203
$tmt_color = 204
$tmt_dibdata = 2
$tmt_diskstream = 213
$tmt_enum = 200
$tmt_filename = 206
$tmt_font = 210
$tmt_glyphdibdata = 8
$tmt_hbitmap = 212
$tmt_int = 202
$tmt_intlist = 211
$tmt_margins = 205
$tmt_position = 208
$tmt_rect = 209
$tmt_size = 207
$tmt_string = 201
$tmt_alwaysshowsizingbar = 2208
$tmt_autosize = 2202
$tmt_bgfill = 2205
$tmt_borderonly = 2203
$tmt_composited = 2204
$tmt_compositedopaque = 2219
$tmt_drawborders = 2214
$tmt_flatmenus = 1001
$tmt_glyphonly = 2207
$tmt_glyphtransparent = 2206
$tmt_integralsizing = 2211
$tmt_localizedmirrorimage = 2220
$tmt_mirrorimage = 2209
$tmt_noetchedeffect = 2215
$tmt_sourcegrow = 2212
$tmt_sourceshrink = 2213
$tmt_textapplyoverlay = 2216
$tmt_textglow = 2217
$tmt_textitalic = 2218
$tmt_transparent = 2201
$tmt_uniformsizing = 2210
$tmt_userpicture = 5001
$tmt_accentcolorhint = 3823
$tmt_activeborder = 1611
$tmt_activecaption = 1603
$tmt_appworkspace = 1613
$tmt_background = 1602
$tmt_blendcolor = 5003
$tmt_bodytextcolor = 3827
$tmt_bordercolor = 3801
$tmt_bordercolorhint = 3822
$tmt_btnface = 1616
$tmt_btnhighlight = 1621
$tmt_btnshadow = 1617
$tmt_btntext = 1619
$tmt_buttonalternateface = 1626

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$tmt_captiontext = 1610
$tmt_dkshadow3d = 1622
$tmt_edgedkshadowcolor = 3807
$tmt_edgefillcolor = 3808
$tmt_edgehighlightcolor = 3805
$tmt_edgelightcolor = 3804
$tmt_edgeshadowcolor = 3806
$tmt_fillcolor = 3802
$tmt_fillcolorhint = 3821
$tmt_fromcolor1 = 2001
$tmt_fromcolor2 = 2002
$tmt_fromcolor3 = 2003
$tmt_fromcolor4 = 2004
$tmt_fromcolor5 = 2005
$tmt_glowcolor = 3816
$tmt_glyphtextcolor = 3819
$tmt_glyphtransparentcolor = 3820
$tmt_gradientactivecaption = 1628
$tmt_gradientcolor1 = 3810
$tmt_gradientcolor2 = 3811
$tmt_gradientcolor3 = 3812
$tmt_gradientcolor4 = 3813
$tmt_gradientcolor5 = 3814
$tmt_gradientinactivecaption = 1629
$tmt_graytext = 1618
$tmt_heading1textcolor = 3825
$tmt_heading2textcolor = 3826
$tmt_highlight = 1614
$tmt_highlighttext = 1615
$tmt_hottracking = 1627
$tmt_inactiveborder = 1612
$tmt_inactivecaption = 1604
$tmt_inactivecaptiontext = 1620
$tmt_infobk = 1625
$tmt_infotext = 1624
$tmt_light3d = 1623
$tmt_menu = 1605
$tmt_menubar = 1631
$tmt_menuhilight = 1630
$tmt_menutext = 1608
$tmt_scrollbar = 1601
$tmt_shadowcolor = 3815
$tmt_textbordercolor = 3817
$tmt_textcolor = 3803
$tmt_textcolorhint = 3824
$tmt_textshadowcolor = 3818
$tmt_transparentcolor = 3809
$tmt_window = 1606
$tmt_windowframe = 1607
$tmt_windowtext = 1609
$tmt_atlasimage = 8000
$tmt_bgtype = 4001
$tmt_bordertype = 4002
$tmt_contentalignment = 4006
$tmt_filltype = 4003
$tmt_glyphtype = 4012
$tmt_glyphfontsizingtype = 4014
$tmt_halign = 4005
$tmt_iconeffect = 4009
$tmt_imagelayout = 4011

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$tmt_imageselecttype = 4013
$tmt_offsettype = 4008
$tmt_sizingtype = 4004
$tmt_textshadowtype = 4010
$tmt_truesizescalingtype = 4015
$tmt_valign = 4007
$tmt_glyphimagefile = 3008
$tmt_imagefile = 3001
$tmt_imagefile1 = 3002
$tmt_imagefile2 = 3003
$tmt_imagefile3 = 3004
$tmt_imagefile4 = 3005
$tmt_imagefile5 = 3006
$tmt_scaledbackground = 7001
$tmt_bodyfont = 809
$tmt_captionfont = 801
$tmt_glyphfont = 2601
$tmt_heading1font = 807
$tmt_heading2font = 808
$tmt_icontitlefont = 806
$tmt_menufont = 803
$tmt_msgboxfont = 805
$tmt_smallcaptionfont = 802
$tmt_statusfont = 804
$tmt_alphalevel = 2402
$tmt_alphathreshold = 2415
$tmt_animationdelay = 2428
$tmt_animationduration = 5006
$tmt_bordersize = 2403
$tmt_charset = 403
$tmt_colorizationcolor = 2431
$tmt_colorizationopacity = 2432
$tmt_framespersecond = 2426
$tmt_fromhue1 = 1801
$tmt_fromhue2 = 1802
$tmt_fromhue3 = 1803
$tmt_fromhue4 = 1804
$tmt_fromhue5 = 1805
$tmt_glowintensity = 2429
$tmt_glyphindex = 2418
$tmt_gradientratio1 = 2406
$tmt_gradientratio2 = 2407
$tmt_gradientratio3 = 2408
$tmt_gradientratio4 = 2409
$tmt_gradientratio5 = 2410
$tmt_height = 2417
$tmt_imagecount = 2401
$tmt_mincolordepth = 1301
$tmt_mindpi1 = 2420
$tmt_mindpi2 = 2421
$tmt_mindpi3 = 2422
$tmt_mindpi4 = 2423
$tmt_mindpi5 = 2424
$tmt_opacity = 2430
$tmt_pixelsperframe = 2427
$tmt_progresschunksize = 2411
$tmt_progressspacesize = 2412
$tmt_roundcornerheight = 2405
$tmt_roundcornerwidth = 2404
$tmt_saturation = 2413

Global Const $tmt_textbordersize = 2414


Global Const $tmt_textglowsize = 2425
Global Const $tmt_tocolor1 = 2006
Global Const $tmt_tocolor2 = 2007
Global Const $tmt_tocolor3 = 2008
Global Const $tmt_tocolor4 = 2009
Global Const $tmt_tocolor5 = 2010
Global Const $tmt_tohue1 = 1806
Global Const $tmt_tohue2 = 1807
Global Const $tmt_tohue3 = 1808
Global Const $tmt_tohue4 = 1809
Global Const $tmt_tohue5 = 1810
Global Const $tmt_truesizestretchmark = 2419
Global Const $tmt_width = 2416
Global Const $tmt_transitiondurations = 6000
Global Const $tmt_captionmargins = 3603
Global Const $tmt_contentmargins = 3602
Global Const $tmt_sizingmargins = 3601
Global Const $tmt_minsize = 3403
Global Const $tmt_minsize1 = 3404
Global Const $tmt_minsize2 = 3405
Global Const $tmt_minsize3 = 3406
Global Const $tmt_minsize4 = 3407
Global Const $tmt_minsize5 = 3408
Global Const $tmt_normalsize = 3409
Global Const $tmt_offset = 3401
Global Const $tmt_textshadowoffset = 3402
Global Const $tmt_animationbuttonrect = 5005
Global Const $tmt_atlasrect = 8002
Global Const $tmt_customsplitrect = 5004
Global Const $tmt_defaultpanesize = 5002
Global Const $tmt_captionbarheight = 1205
Global Const $tmt_captionbarwidth = 1204
Global Const $tmt_menubarheight = 1209
Global Const $tmt_menubarwidth = 1208
Global Const $tmt_paddedborderwidth = 1210
Global Const $tmt_scrollbarheight = 1203
Global Const $tmt_scrollbarwidth = 1202
Global Const $tmt_sizingborderwidth = 1201
Global Const $tmt_smcaptionbarheight = 1207
Global Const $tmt_smcaptionbarwidth = 1206
Global Const $tmt_alias = 1404
Global Const $tmt_atlasinputimage = 8001
Global Const $tmt_author = 604
Global Const $tmt_classicvalue = 3202
Global Const $tmt_colorschemes = 401
Global Const $tmt_company = 603
Global Const $tmt_copyright = 605
Global Const $tmt_cssname = 1401
Global Const $tmt_description = 608
Global Const $tmt_displayname = 601
Global Const $tmt_lastupdated = 1403
Global Const $tmt_sizes = 402
Global Const $tmt_text = 3201
Global Const $tmt_tooltip = 602
Global Const $tmt_url = 606
Global Const $tmt_version = 607
Global Const $tmt_xmlname = 1402
Global Const $tmt_name = 600
#Region Global Variables and Constants

Global $__g_venum, $__g_vext = 0


Global $__g_hheap = 0, $__g_irgbmode = 1
Global Const $tagosversioninfo = "struct;dword OSVersionInfoSize
;dword MajorVersion;dword MinorVersion;dword BuildNumber;dword PlatformId;wchar
CSDVersion[128];endstruct"
Global Const $__winver = __winver()
#EndRegion Global Variables and Constants
#Region Functions list
#EndRegion Functions list
#Region Public Functions
d = -1)

Func _winapi_arraytostruct(Const ByRef $adata, $istart = 0, $ien

If __checkerrorarraybounds($adata, $istart, $iend) Then


Return SetError(@error + 10, @extended, 0)
Local $tagstruct = ""
For $i = $istart To $iend
$tagstruct &= "wchar[" & (StringLen($adata[$i])
+ 1) & "];"
Next
Local $tdata = DllStructCreate($tagstruct & "wchar[1]")
Local $icount = 1
For $i = $istart To $iend
DllStructSetData($tdata, $icount, $adata[$i])
$icount += 1
Next
DllStructSetData($tdata, $icount, ChrW(0))
Return $tdata
EndFunc
Func _winapi_createmargins($ileftwidth, $irightwidth, $itopheigh
t, $ibottomheight)
Local $tmargins = DllStructCreate($tagmargins)
DllStructSetData($tmargins, 1, $ileftwidth)
DllStructSetData($tmargins, 2, $irightwidth)
DllStructSetData($tmargins, 3, $itopheight)
DllStructSetData($tmargins, 4, $ibottomheight)
Return $tmargins
EndFunc
Func _winapi_createpoint($ix, $iy)
Local $tpoint = DllStructCreate($tagpoint)
DllStructSetData($tpoint, 1, $ix)
DllStructSetData($tpoint, 2, $iy)
Return $tpoint
EndFunc
Func _winapi_createrect($ileft, $itop, $iright, $ibottom)
Local $trect = DllStructCreate($tagrect)
DllStructSetData($trect, 1, $ileft)
DllStructSetData($trect, 2, $itop)
DllStructSetData($trect, 3, $iright)
DllStructSetData($trect, 4, $ibottom)
Return $trect
EndFunc
Func _winapi_createrectex($ix, $iy, $iwidth, $iheight)
Local $trect = DllStructCreate($tagrect)
DllStructSetData($trect, 1, $ix)
DllStructSetData($trect, 2, $iy)

EndFunc

DllStructSetData($trect, 3, $ix + $iwidth)


DllStructSetData($trect, 4, $iy + $iheight)
Return $trect

Func _winapi_createsize($iwidth, $iheight)


Local $tsize = DllStructCreate($tagsize)
DllStructSetData($tsize, 1, $iwidth)
DllStructSetData($tsize, 2, $iheight)
Return $tsize
EndFunc

de)

Func _winapi_fatalexit($icode)
DllCall("kernel32.dll", "none", "FatalExit", "int", $ico
EndFunc

If @error Then Return SetError(@error, @extended)

Func _winapi_getbitmapdimension($hbitmap)
Local Const $tagbitmap = "struct;long bmType;long bmWidt
h;long bmHeight;long bmWidthBytes;ushort bmPlanes;ushort bmBitsPixel;ptr bmBits;
endstruct"
Local $tobj = DllStructCreate($tagbitmap)
Local $aret = DllCall("gdi32.dll", "int", "GetObject", "
handle", $hbitmap, "int", DllStructGetSize($tobj), "struct*", $tobj)
If @error OR NOT $aret[0] Then Return SetError(@error +
10, @extended, 0)
Return _winapi_createsize(DllStructGetData($tobj, "bmWid
th"), DllStructGetData($tobj, "bmHeight"))
EndFunc
Func _winapi_getstring($pstring, $bunicode = True)
Local $ilength = _winapi_strlen($pstring, $bunicode)
If @error OR NOT $ilength Then Return SetError(@error +
10, @extended, "")
Local $tstring = DllStructCreate(__iif($bunicode, "wchar
", "char") & "[" & ($ilength + 1) & "]", $pstring)
If @error Then Return SetError(@error, @extended, "")
Return SetExtended($ilength, DllStructGetData($tstring,
1))
EndFunc
Func _winapi_isbadreadptr($paddress, $ilength)
Local $aret = DllCall("kernel32.dll", "bool", "IsBadRead
Ptr", "struct*", $paddress, "uint_ptr", $ilength)
If @error Then Return SetError(@error, @extended, False)
Return $aret[0]
EndFunc
Func _winapi_isbadwriteptr($paddress, $ilength)
Local $aret = DllCall("kernel32.dll", "bool", "IsBadWrit
ePtr", "struct*", $paddress, "uint_ptr", $ilength)
If @error Then Return SetError(@error, @extended, False)
Return $aret[0]
EndFunc
Func _winapi_iswow64process($ipid = 0)
If NOT $ipid Then $ipid = @AutoItPID
Local $hprocess = DllCall("kernel32.dll", "handle", "Ope
nProcess", "dword", __iif($__winver < 1536, 1024, 4096), "bool", 0, "dword", $ip

id)

If @error OR NOT $hprocess[0] Then Return SetError(@erro


r + 20, @extended, False)
Local $aret = DllCall("kernel32.dll", "bool", "IsWow64Pr
ocess", "handle", $hprocess[0], "bool*", 0)
If __checkerrorclosehandle($aret, $hprocess[0]) Then Ret
urn SetError(@error, @extended, False)
Return $aret[2]
EndFunc
Func _winapi_movememory($pdestination, $psource, $ilength)
If _winapi_isbadreadptr($psource, $ilength) Then Return
SetError(10, @extended, 0)
If _winapi_isbadwriteptr($pdestination, $ilength) Then R
eturn SetError(11, @extended, 0)
DllCall("ntdll.dll", "none", "RtlMoveMemory", "struct*",
$pdestination, "struct*", $psource, "ulong_ptr", $ilength)
If @error Then Return SetError(@error, @extended, 0)
Return 1
EndFunc
Func _winapi_pathisdirectory($sfilepath)
Local $aret = DllCall("shlwapi.dll", "bool", "PathIsDire
ctoryW", "wstr", $sfilepath)
If @error Then Return SetError(@error, @extended, False)
Return $aret[0]
EndFunc
Func _winapi_strlen($pstring, $bunicode = True)
Local $w = ""
If $bunicode Then $w = "W"
Local $aret = DllCall("kernel32.dll", "int", "lstrlen" &
$w, "struct*", $pstring)
If @error Then Return SetError(@error, @extended, 0)
Return $aret[0]
EndFunc

0)

Func _winapi_structtoarray(ByRef $tstruct, $iitems = 0)


Local $isize = 2 * Floor(DllStructGetSize($tstruct) / 2)
Local $pstruct = DllStructGetPtr($tstruct)
If NOT $isize OR NOT $pstruct Then Return SetError(1, 0,

eturn SetError(3, 0, 0)

Local $tdata, $ilength, $ioffset = 0


Local $aresult[101] = [0]
While 1
$ilength = _winapi_strlen($pstruct + $ioffset)
If NOT $ilength Then
ExitLoop
EndIf
If 2 * (1 + $ilength) + $ioffset > $isize Then R

h) & "]", $pstruct + $ioffset)


)
1)

$tdata = DllStructCreate("wchar[" & (1 + $ilengt


If @error Then Return SetError(@error + 10, 0, 0
__inc($aresult)
$aresult[$aresult[0]] = DllStructGetData($tdata,
If $aresult[0] = $iitems Then
ExitLoop

EndIf
$ioffset += 2 * (1 + $ilength)
If $ioffset >= $isize Then Return SetError(3, 0,

0)

EndFunc

WEnd
If NOT $aresult[0] Then Return SetError(2, 0, 0)
__inc($aresult, -1)
Return $aresult

Func _winapi_swapdword($ivalue)
Local $tstruct1 = DllStructCreate("dword;dword")
Local $tstruct2 = DllStructCreate("byte[4];byte[4]", Dll
StructGetPtr($tstruct1))
DllStructSetData($tstruct1, 1, $ivalue)
For $i = 1 To 4
DllStructSetData($tstruct2, 2, DllStructGetData(
$tstruct2, 1, 5 - $i), $i)
Next
Return DllStructGetData($tstruct1, 2)
EndFunc
Func _winapi_swapqword($ivalue)
Local $tstruct1 = DllStructCreate("int64;int64")
Local $tstruct2 = DllStructCreate("byte[8];byte[8]", Dll
StructGetPtr($tstruct1))
DllStructSetData($tstruct1, 1, $ivalue)
For $i = 1 To 8
DllStructSetData($tstruct2, 2, DllStructGetData(
$tstruct2, 1, 9 - $i), $i)
Next
Return DllStructGetData($tstruct1, 2)
EndFunc
Func _winapi_swapword($ivalue)
Local $tstruct1 = DllStructCreate("word;word")
Local $tstruct2 = DllStructCreate("byte[2];byte[2]", Dll
StructGetPtr($tstruct1))
DllStructSetData($tstruct1, 1, $ivalue)
For $i = 1 To 2
DllStructSetData($tstruct2, 2, DllStructGetData(
$tstruct2, 1, 3 - $i), $i)
Next
Return DllStructGetData($tstruct1, 2)
EndFunc
Func _winapi_switchcolor($icolor)
If $icolor = -1 Then Return $icolor
Return BitOR(BitAND($icolor, 65280), BitShift(BitAND($ic
olor, 255), -16), BitShift(BitAND($icolor, 16711680), 16))
EndFunc
Func _winapi_zeromemory($pmemory, $ilength)
If _winapi_isbadwriteptr($pmemory, $ilength) Then Return
SetError(11, @extended, 0)
DllCall("ntdll.dll", "none", "RtlZeroMemory", "struct*",
$pmemory, "ulong_ptr", $ilength)
If @error Then Return SetError(@error, @extended, 0)
Return 1
EndFunc

#EndRegion Public Functions


#Region Internal Functions
Func __checkerrorarraybounds(Const ByRef $adata, ByRef $istart,
ByRef $iend, $ndim = 1, $idim = $ubound_dimensions)
If NOT IsArray($adata) Then Return SetError(1, 0, 1)
If UBound($adata, $idim) <> $ndim Then Return SetError(2
, 0, 1)
If $istart < 0 Then $istart = 0
Local $iubound = UBound($adata) - 1
If $iend < 1 OR $iend > $iubound Then $iend = $iubound
If $istart > $iend Then Return SetError(4, 0, 1)
Return 0
EndFunc
Func __checkerrorclosehandle($aret, $hfile, $blasterror = 0, $ic
urerr = @error, $icurext = @extended)
If NOT $icurerr AND NOT $aret[0] Then $icurerr = 10
Local $ilasterror = _winapi_getlasterror()
DllCall("kernel32.dll", "bool", "CloseHandle", "handle",
$hfile)
If $icurerr Then _winapi_setlasterror($ilasterror)
If $blasterror Then $icurext = $ilasterror
Return SetError($icurerr, $icurext, $icurerr)
EndFunc
Func __dll($spath, $bpin = False)
Local $aret = DllCall("kernel32.dll", "bool", "GetModule
HandleExW", "dword", __iif($bpin, 1, 2), "wstr", $spath, "ptr*", 0)
If NOT $aret[3] Then
Local $aresult = DllCall("kernel32.dll", "handle
", "LoadLibraryW", "wstr", $spath)
If NOT $aresult[0] Then Return 0
EndIf
Return 1
EndFunc
Func __enumwindowsproc($hwnd, $bvisible)
Local $aresult
If $bvisible Then
$aresult = DllCall("user32.dll", "bool", "IsWind
owVisible", "hwnd", $hwnd)
If NOT $aresult[0] Then
Return 1
EndIf
EndIf
__inc($__g_venum)
$__g_venum[$__g_venum[0][0]][0] = $hwnd
$aresult = DllCall("user32.dll", "int", "GetClassNameW",
"hwnd", $hwnd, "wstr", "", "int", 4096)
$__g_venum[$__g_venum[0][0]][1] = $aresult[2]
Return 1
EndFunc
Func __fatalexit($icode, $stext = "")
If $stext Then MsgBox($mb_systemmodal, "AutoIt", $stext)
_winapi_fatalexit($icode)
EndFunc

Func __heapalloc($isize, $babort = False)


Local $aret
If NOT $__g_hheap Then
$aret = DllCall("kernel32.dll", "handle", "HeapC
reate", "dword", 0, "ulong_ptr", 0, "ulong_ptr", 0)
If @error OR NOT $aret[0] Then __fatalexit(1, "E
rror allocating memory.")
$__g_hheap = $aret[0]
EndIf
$aret = DllCall("kernel32.dll", "ptr", "HeapAlloc", "han
dle", $__g_hheap, "dword", 8, "ulong_ptr", $isize)
If @error OR NOT $aret[0] Then
If $babort Then __fatalexit(1, "Error allocating
memory.")
Return SetError(@error + 30, @extended, 0)
EndIf
Return $aret[0]
EndFunc
Func __heapfree(ByRef $pmemory, $bcheck = False, $icurerr = @err
or, $icurext = @extended)
If $bcheck AND (NOT __heapvalidate($pmemory)) Then Retur
n SetError(@error, @extended, 0)
Local $aret = DllCall("kernel32.dll", "int", "HeapFree",
"handle", $__g_hheap, "dword", 0, "ptr", $pmemory)
If @error OR NOT $aret[0] Then Return SetError(@error +
40, @extended, 0)
$pmemory = 0
Return SetError($icurerr, $icurext, 1)
EndFunc
False)

Func __heaprealloc($pmemory, $isize, $bamount = False, $babort =

Local $aret, $pret


If __heapvalidate($pmemory) Then
If $bamount AND (__heapsize($pmemory) >= $isize)
Then Return SetExtended(1, Ptr($pmemory))
$aret = DllCall("kernel32.dll", "ptr", "HeapReAl
loc", "handle", $__g_hheap, "dword", 8, "ptr", $pmemory, "ulong_ptr", $isize)
If @error OR NOT $aret[0] Then
If $babort Then __fatalexit(1, "Error al
locating memory.")
Return SetError(@error + 20, @extended,
Ptr($pmemory))
EndIf
$pret = $aret[0]
Else
$pret = __heapalloc($isize, $babort)
If @error Then Return SetError(@error, @extended
, 0)
EndIf
Return $pret
EndFunc
Func __heapsize($pmemory, $bcheck = False)
If $bcheck AND (NOT __heapvalidate($pmemory)) Then Retur
n SetError(@error, @extended, 0)
Local $aret = DllCall("kernel32.dll", "ulong_ptr", "Heap
Size", "handle", $__g_hheap, "dword", 0, "ptr", $pmemory)
If @error OR ($aret[0] = Ptr(-1)) Then Return SetError(@

error + 50, @extended, 0)


Return $aret[0]
EndFunc
Func __heapvalidate($pmemory)
If (NOT $__g_hheap) OR (NOT Ptr($pmemory)) Then Return S
etError(9, 0, False)
Local $aret = DllCall("kernel32.dll", "int", "HeapValida
te", "handle", $__g_hheap, "dword", 0, "ptr", $pmemory)
If @error Then Return SetError(@error, @extended, False)
Return $aret[0]
EndFunc
Func __inc(ByRef $adata, $iincrement = 100)
Select
Case UBound($adata, $ubound_columns)
If $iincrement < 0 Then
ReDim $adata[$adata[0][0] + 1][U
Bound($adata, $ubound_columns)]
Else
$adata[0][0] += 1
If $adata[0][0] > UBound($adata)
- 1 Then
ReDim $adata[$adata[0][0
] + $iincrement][UBound($adata, $ubound_columns)]
EndIf
EndIf
Case UBound($adata, $ubound_rows)
If $iincrement < 0 Then
ReDim $adata[$adata[0] + 1]
Else
$adata[0] += 1
If $adata[0] > UBound($adata) 1 Then
ReDim $adata[$adata[0] +
$iincrement]
EndIf
EndIf
Case Else
Return 0
EndSelect
Return 1
EndFunc
Func __iif($btest, $vtrue, $vfalse)
Return $btest ? $vtrue : $vfalse
EndFunc
Func __init($ddata)
Local $ilength = BinaryLen($ddata)
Local $aret = DllCall("kernel32.dll", "ptr", "VirtualAll
oc", "ptr", 0, "ulong_ptr", $ilength, "dword", 4096, "dword", 64)
If @error OR NOT $aret[0] Then __fatalexit(1, "Error all
ocating memory.")
Local $tdata = DllStructCreate("byte[" & $ilength & "]",
$aret[0])
DllStructSetData($tdata, 1, $ddata)
Return $aret[0]
EndFunc

Func __rgb($icolor)
If $__g_irgbmode Then
$icolor = _winapi_switchcolor($icolor)
EndIf
Return $icolor
EndFunc
Func __winver()
Local $tosvi = DllStructCreate($tagosversioninfo)
DllStructSetData($tosvi, 1, DllStructGetSize($tosvi))
Local $aret = DllCall("kernel32.dll", "bool", "GetVersio
nExW", "struct*", $tosvi)
If @error OR NOT $aret[0] Then Return SetError(@error, @
extended, 0)
Return BitOR(BitShift(DllStructGetData($tosvi, 2), -8),
DllStructGetData($tosvi, 3))
EndFunc
#EndRegion Internal Functions
#Region Global Variables and Constants
Global Const $tagdttopts = "dword Size;dword Flags;dword clrText
;dword clrBorder;dword clrShadow;int TextShadowType;" & $tagpoint & ";int Border
Size;int FontPropId;int ColorPropId;int StateId;int ApplyOverlay;int GlowSize;pt
r DrawTextCallback;lparam lParam"
#EndRegion Global Variables and Constants
#Region Functions list
#EndRegion Functions list
#Region Public Functions
Func _winapi_beginbufferedpaint($hdc, $ttarget, ByRef $hnewdc, $
iformat = 0, $iflags = 0, $texclude = 0, $ialpha = -1)
Local Const $tagbp_paintparams = "dword cbSize;dword dwF
lags;ptr prcExclude;ptr pBlendFunction"
Local $tpp = DllStructCreate($tagbp_paintparams)
$hnewdc = 0
Local $tbf = 0
If $ialpha <> -1 Then
$tbf = DllStructCreate($tagblendfunction)
DllStructSetData($tbf, 1, 0)
DllStructSetData($tbf, 2, 0)
DllStructSetData($tbf, 3, $ialpha)
DllStructSetData($tbf, 4, 1)
EndIf
DllStructSetData($tpp, 1, DllStructGetSize($tpp))
DllStructSetData($tpp, 2, $iflags)
DllStructSetData($tpp, 3, DllStructGetPtr($texclude))
DllStructSetData($tpp, 4, DllStructGetPtr($tbf))
Local $aret = DllCall("uxtheme.dll", "handle", "BeginBuf
feredPaint", "handle", $hdc, "struct*", $ttarget, "dword", $iformat, "struct*",
$tpp, "handle*", 0)
If @error OR NOT $aret[0] Then Return SetError(@error, @
extended, 0)
$hnewdc = $aret[5]
Return $aret[0]
EndFunc
Func _winapi_bufferedpaintclear($hbp, $trect = 0)
Local $aret = DllCall("uxtheme.dll", "long", "BufferedPa
intClear", "handle", $hbp, "struct*", $trect)
If @error Then Return SetError(@error, @extended, 0)

EndFunc

intInit")

Func _winapi_bufferedpaintinit()
Local $aret = DllCall("uxtheme.dll", "long", "BufferedPa

EndFunc
0)

If $aret[0] Then Return SetError(10, $aret[0], 0)


Return 1

If @error Then Return SetError(@error, @extended, 0)


If $aret[0] Then Return SetError(10, $aret[0], 0)
Return 1

Func _winapi_bufferedpaintsetalpha($hbp, $ialpha = 255, $trect =

Local $aret = DllCall("uxtheme.dll", "long", "BufferedPa


intSetAlpha", "handle", $hbp, "struct*", $trect, "byte", $ialpha)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return 1
EndFunc

intUnInit")

Func _winapi_bufferedpaintuninit()
Local $aret = DllCall("uxtheme.dll", "long", "BufferedPa

EndFunc

If @error Then Return SetError(@error, @extended, 0)


If $aret[0] Then Return SetError(10, $aret[0], 0)
Return 1

Func _winapi_closethemedata($htheme)
Local $aret = DllCall("uxtheme.dll", "long", "CloseTheme
Data", "handle", $htheme)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return 1
EndFunc
Func _winapi_drawthemebackground($htheme, $ipartid, $istateid, $
hdc, $trect, $tclip = 0)
Local $aret = DllCall("uxtheme.dll", "long", "DrawThemeB
ackground", "handle", $htheme, "handle", $hdc, "int", $ipartid, "int", $istateid
, "struct*", $trect, "struct*", $tclip)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return 1
EndFunc
Func _winapi_drawthemeedge($htheme, $ipartid, $istateid, $hdc, $
trect, $iedge, $iflags, $tarea = 0)
Local $aret = DllCall("uxtheme.dll", "long", "DrawThemeE
dge", "handle", $htheme, "handle", $hdc, "int", $ipartid, "int", $istateid, "str
uct*", $trect, "uint", $iedge, "uint", $iflags, "struct*", $tarea)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return 1
EndFunc
Func _winapi_drawthemeicon($htheme, $ipartid, $istateid, $hdc, $
trect, $hil, $iindex)
Local $aret = DllCall("uxtheme.dll", "long", "DrawThemeI

con", "handle", $htheme, "handle", $hdc, "int", $ipartid, "int", $istateid, "str
uct*", $trect, "handle", $hil, "int", $iindex)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return 1
EndFunc
Func _winapi_drawthemeparentbackground($hwnd, $hdc, $trect = 0)
Local $aret = DllCall("uxtheme.dll", "long", "DrawThemeP
arentBackground", "hwnd", $hwnd, "handle", $hdc, "struct*", $trect)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return 1
EndFunc
Func _winapi_drawthemetext($htheme, $ipartid, $istateid, $hdc, $
stext, $trect, $iflags)
Local $aret = DllCall("uxtheme.dll", "long", "DrawThemeT
ext", "handle", $htheme, "handle", $hdc, "int", $ipartid, "int", $istateid, "wst
r", $stext, "int", -1, "dword", $iflags, "dword", 0, "struct*", $trect)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return 1
EndFunc
Func _winapi_drawthemetextex($htheme, $ipartid, $istateid, $hdc,
$stext, $trect, $iflags, $tdttopts)
Local $aret = DllCall("uxtheme.dll", "long", "DrawThemeT
extEx", "handle", $htheme, "handle", $hdc, "int", $ipartid, "int", $istateid, "w
str", $stext, "int", -1, "dword", $iflags, "struct*", $trect, "struct*", $tdttop
ts)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return 1
EndFunc
Func _winapi_endbufferedpaint($hbp, $bupdate = True)
Local $aret = DllCall("uxtheme.dll", "long", "EndBuffere
dPaint", "handle", $hbp, "bool", $bupdate)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return 1
EndFunc
Func _winapi_getbufferedpaintbits($hbp)
Local $aret = DllCall("uxtheme.dll", "long", "GetBuffere
dPaintBits", "handle", $hbp, "ptr*", 0, "int*", 0)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return SetExtended($aret[3], $aret[2])
EndFunc
Func _winapi_getbufferedpaintdc($hbp)
Local $aret = DllCall("uxtheme.dll", "handle", "GetBuffe
redPaintDC", "handle", $hbp)
If @error Then Return SetError(@error, @extended, 0)
Return $aret[0]
EndFunc
Func _winapi_getbufferedpainttargetdc($hbp)

Local $aret = DllCall("uxtheme.dll", "handle", "GetBuffe


redPaintTargetDC", "handle", $hbp)
If @error Then Return SetError(@error, @extended, 0)
Return $aret[0]
EndFunc
Func _winapi_getbufferedpainttargetrect($hbp)
Local $trect = DllStructCreate($tagrect)
Local $aret = DllCall("uxtheme.dll", "long", "GetBuffere
dPaintTargetRect", "handle", $hbp, "struct*", $trect)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return $trect
EndFunc
Func _winapi_getcurrentthemename()
Local $aret = DllCall("uxtheme.dll", "long", "GetCurrent
ThemeName", "wstr", "", "int", 4096, "wstr", "", "int", 2048, "wstr", "", "int",
2048)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Local $aresult[3]
For $i = 0 To 2
$aresult[$i] = $aret[$i * 2 + 1]
Next
Return $aresult
EndFunc

ppProperties")

Func _winapi_getthemeappproperties()
Local $aret = DllCall("uxtheme.dll", "dword", "GetThemeA

EndFunc

If @error Then Return SetError(@error, @extended, 0)


Return $aret[0]

Func _winapi_getthemebackgroundcontentrect($htheme, $ipartid, $i


stateid, $hdc, $trect)
Local $tarea = DllStructCreate($tagrect)
Local $aret = DllCall("uxtheme.dll", "long", "GetThemeBa
ckgroundContentRect", "handle", $htheme, "handle", $hdc, "int", $ipartid, "int",
$istateid, "struct*", $trect, "struct*", $tarea)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return $tarea
EndFunc
Func _winapi_getthemebackgroundextent($htheme, $ipartid, $istate
id, $hdc, $trect)
Local $tarea = DllStructCreate($tagrect)
Local $aret = DllCall("uxtheme.dll", "long", "GetThemeBa
ckgroundExtent", "handle", $htheme, "handle", $hdc, "int", $ipartid, "int", $ist
ateid, "struct*", $trect, "struct*", $tarea)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return $tarea
EndFunc
Func _winapi_getthemebackgroundregion($htheme, $ipartid, $istate
id, $hdc, $trect)
Local $aret = DllCall("uxtheme.dll", "long", "GetThemeBa

ckgroundRegion", "handle", $htheme, "handle", $hdc, "int", $ipartid, "int", $ist


ateid, "struct*", $trect, "handle*", 0)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return $aret[6]
EndFunc
id, $iflag = 1)

Func _winapi_getthemebitmap($htheme, $ipartid, $istateid, $iprop

Local $aret = DllCall("uxtheme.dll", "long", "GetThemeBi


tmap", "handle", $htheme, "int", $ipartid, "int", $istateid, "int", $ipropid, "u
long", $iflag, "handle*", 0)
If @error Then Return SetError(@error, @extended, -1)
If $aret[0] Then Return SetError(10, $aret[0], -1)
Return $aret[6]
EndFunc
)

Func _winapi_getthemebool($htheme, $ipartid, $istateid, $ipropid

Local $aret = DllCall("uxtheme.dll", "long", "GetThemeBo


ol", "handle", $htheme, "int", $ipartid, "int", $istateid, "int", $ipropid, "boo
l*", 0)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return $aret[5]
EndFunc
d)

Func _winapi_getthemecolor($htheme, $ipartid, $istateid, $ipropi

Local $aret = DllCall("uxtheme.dll", "long", "GetThemeCo


lor", "handle", $htheme, "int", $ipartid, "int", $istateid, "int", $ipropid, "dw
ord*", 0)
If @error Then Return SetError(@error, @extended, -1)
If $aret[0] Then Return SetError(10, $aret[0], -1)
Return __rgb($aret[5])
EndFunc
y)

Func _winapi_getthemedocumentationproperty($sfilepath, $spropert

Local $aret = DllCall("uxtheme.dll", "long", "GetThemeDo


cumentationProperty", "wstr", $sfilepath, "wstr", $sproperty, "wstr", "", "int",
4096)
If @error Then Return SetError(@error, @extended, "")
If $aret[0] Then Return SetError(10, $aret[0], "")
Return $aret[3]
EndFunc
ropid)

Func _winapi_getthemeenumvalue($htheme, $ipartid, $istateid, $ip

Local $aret = DllCall("uxtheme.dll", "long", "GetThemeEn


umValue", "handle", $htheme, "int", $ipartid, "int", $istateid, "int", $ipropid,
"int*", 0)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return $aret[5]
EndFunc
opid)

Func _winapi_getthemefilename($htheme, $ipartid, $istateid, $ipr


Local $aret = DllCall("uxtheme.dll", "uint", "GetThemeFi

lename", "handle", $htheme, "int", $ipartid, "int", $istateid, "int", $ipropid,


"wstr", "", "int", 4096)
If @error Then Return SetError(@error, @extended, "")
If $aret[0] Then Return SetError(10, $aret[0], "")
Return $aret[5]
EndFunc
, $hdc = 0)

Func _winapi_getthemefont($htheme, $ipartid, $istateid, $ipropid

Local $tlogfont = DllStructCreate($taglogfont)


Local $aret = DllCall("uxtheme.dll", "long", "GetThemeFo
nt", "handle", $htheme, "handle", $hdc, "int", $ipartid, "int", $istateid, "int"
, $ipropid, "struct*", $tlogfont)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return $tlogfont
EndFunc
Func _winapi_getthemeint($htheme, $ipartid, $istateid, $ipropid)
Local $aret = DllCall("uxtheme.dll", "long", "GetThemeIn
t", "handle", $htheme, "int", $ipartid, "int", $istateid, "int", $ipropid, "int*
", 0)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return $aret[5]
EndFunc
Func _winapi_getthememargins($htheme, $ipartid, $istateid, $ipro
pid, $hdc, $trect)
Local $tmargins = DllStructCreate($tagmargins)
Local $aret = DllCall("uxtheme.dll", "long", "GetThemeMa
rgins", "handle", $htheme, "handle", $hdc, "int", $ipartid, "int", $istateid, "i
nt", $ipropid, "struct*", $trect, "struct*", $tmargins)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return $tmargins
EndFunc
id, $hdc = 0)

Func _winapi_getthememetric($htheme, $ipartid, $istateid, $iprop

Local $aret = DllCall("uxtheme.dll", "long", "GetThemeMe


tric", "handle", $htheme, "handle", $hdc, "int", $ipartid, "int", $istateid, "in
t", $ipropid, "int*", 0)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return $aret[6]
EndFunc
Func _winapi_getthemepartsize($htheme, $ipartid, $istateid, $hdc
, $trect, $itype)
Local $tsize = DllStructCreate($tagsize)
Local $aret = DllCall("uxtheme.dll", "long", "GetThemePa
rtSize", "handle", $htheme, "handle", $hdc, "int", $ipartid, "int", $istateid, "
struct*", $trect, "int", $itype, "struct*", $tsize)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return $tsize
EndFunc
Func _winapi_getthemeposition($htheme, $ipartid, $istateid, $ipr

opid)

Local $tpoint = DllStructCreate($tagpoint)


Local $aret = DllCall("uxtheme.dll", "long", "GetThemePo
sition", "handle", $htheme, "int", $ipartid, "int", $istateid, "int", $ipropid,
"struct*", $tpoint)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return $tpoint
EndFunc
, $ipropid)

Func _winapi_getthemepropertyorigin($htheme, $ipartid, $istateid

Local $aret = DllCall("uxtheme.dll", "long", "GetThemePr


opertyOrigin", "handle", $htheme, "int", $ipartid, "int", $istateid, "int", $ipr
opid, "uint*", 0)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return $aret[5]
EndFunc
)

Func _winapi_getthemerect($htheme, $ipartid, $istateid, $ipropid

Local $trect = DllStructCreate($tagrect)


Local $aret = DllCall("uxtheme.dll", "long", "GetThemeRe
ct", "handle", $htheme, "int", $ipartid, "int", $istateid, "int", $ipropid, "str
uct*", $trect)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return $trect
EndFunc
id)

Func _winapi_getthemestring($htheme, $ipartid, $istateid, $iprop

Local $aret = DllCall("uxtheme.dll", "long", "GetThemeSt


ring", "handle", $htheme, "int", $ipartid, "int", $istateid, "int", $ipropid, "w
str", "", "int", 4096)
If @error Then Return SetError(@error, @extended, "")
If $aret[0] Then Return SetError(10, $aret[0], "")
Return $aret[5]
EndFunc
Func _winapi_getthemesysbool($htheme, $iboolid)
Local $aret = DllCall("uxtheme.dll", "bool", "GetThemeSy
sBool", "handle", $htheme, "int", $iboolid)
If @error Then Return SetError(@error, @extended, 0)
Return $aret[0]
EndFunc
Func _winapi_getthemesyscolor($htheme, $icolorid)
Local $aret = DllCall("uxtheme.dll", "dword", "GetThemeS
ysColor", "handle", $htheme, "int", $icolorid)
If @error Then Return SetError(@error, @extended, -1)
Return $aret[0]
EndFunc
Func _winapi_getthemesyscolorbrush($htheme, $icolorid)
Local $aret = DllCall("uxtheme.dll", "handle", "GetTheme
SysColorBrush", "handle", $htheme, "int", $icolorid)
If @error Then Return SetError(@error, @extended, 0)
Return $aret[0]

EndFunc
Func _winapi_getthemesysfont($htheme, $ifontid)
Local $tlogfont = DllStructCreate($taglogfont)
Local $aret = DllCall("uxtheme.dll", "long", "GetThemeSy
sFont", "handle", $htheme, "int", $ifontid, "struct*", $tlogfont)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return $tlogfont
EndFunc
Func _winapi_getthemesysint($htheme, $iintid)
Local $aret = DllCall("uxtheme.dll", "long", "GetThemeSy
sInt", "handle", $htheme, "int", $iintid, "int*", 0)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return $aret[3]
EndFunc
Func _winapi_getthemesyssize($htheme, $isizeid)
Local $aret = DllCall("uxtheme.dll", "int", "GetThemeSys
Size", "handle", $htheme, "int", $isizeid)
If @error Then Return SetError(@error, @extended, 0)
Return $aret[0]
EndFunc
Func _winapi_getthemesysstring($htheme, $istringid)
Local $aret = DllCall("uxtheme.dll", "long", "GetThemeSy
sString", "handle", $htheme, "int", $istringid, "wstr", "", "int", 4096)
If @error Then Return SetError(@error, @extended, "")
If $aret[0] Then Return SetError(10, $aret[0], "")
Return $aret[3]
EndFunc
Func _winapi_getthemetextextent($htheme, $ipartid, $istateid, $h
dc, $stext, $trect, $iflags)
Local $tarea = DllStructCreate($tagrect)
Local $aret = DllCall("uxtheme.dll", "long", "GetThemeTe
xtExtent", "handle", $htheme, "handle", $hdc, "int", $ipartid, "int", $istateid,
"wstr", $stext, "int", -1, "dword", $iflags, "struct*", $trect, "struct*", $tar
ea)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return $tarea
EndFunc
hdc = 0)

Func _winapi_getthemetextmetrics($htheme, $ipartid, $istateid, $

Local $ttextmetric = DllStructCreate($tagtextmetric)


Local $aret = DllCall("uxtheme.dll", "long", "GetThemeTe
xtMetrics", "handle", $htheme, "handle", $hdc, "int", $ipartid, "int", $istateid
, "struct*", $ttextmetric)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return $ttextmetric
EndFunc
Func _winapi_getthemetransitionduration($htheme, $ipartid, $ista
teidfrom, $istateidto, $ipropid)
Local $aret = DllCall("uxtheme.dll", "long", "GetThemeTr

ansitionDuration", "handle", $htheme, "int", $ipartid, "int", $istateidfrom, "in


t", $istateidto, "int", $ipropid, "dword*", 0)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return $aret[6]
EndFunc
Func _winapi_getwindowtheme($hwnd)
Local $aret = DllCall("uxtheme.dll", "handle", "GetWindo
wTheme", "hwnd", $hwnd)
If @error Then Return SetError(@error, @extended, 0)
Return $aret[0]
EndFunc

ive")

Func _winapi_isthemeactive()
Local $aret = DllCall("uxtheme.dll", "bool", "IsThemeAct

EndFunc

If @error Then Return SetError(@error, @extended, False)


Return $aret[0]

Func _winapi_isthemebackgroundpartiallytransparent($htheme, $ipa


rtid, $istateid)
Local $aret = DllCall("uxtheme.dll", "bool", "IsThemeBac
kgroundPartiallyTransparent", "handle", $htheme, "int", $ipartid, "int", $istate
id)
If @error Then Return SetError(@error, @extended, False)
Return $aret[0]
EndFunc
Func _winapi_isthemepartdefined($htheme, $ipartid)
Local $aret = DllCall("uxtheme.dll", "int", "IsThemePart
Defined", "handle", $htheme, "int", $ipartid, "int", 0)
If @error Then Return SetError(@error, @extended, False)
Return $aret[0]
EndFunc
Func _winapi_openthemedata($hwnd, $sclass)
Local $aret = DllCall("uxtheme.dll", "handle", "OpenThem
eData", "hwnd", $hwnd, "wstr", $sclass)
If @error Then Return SetError(@error, @extended, 0)
Return $aret[0]
EndFunc
Func _winapi_setthemeappproperties($iflags)
DllCall("uxtheme.dll", "none", "SetThemeAppProperties",
"dword", $iflags)
If @error Then Return SetError(@error, @extended, 0)
Return 1
EndFunc
Func _winapi_setwindowtheme($hwnd, $sname = 0, $slist = 0)
Local $stypeofname = "wstr", $stypeoflist = "wstr"
If NOT IsString($sname) Then
$stypeofname = "ptr"
$sname = 0
EndIf
If NOT IsString($slist) Then
$stypeoflist = "ptr"
$slist = 0

EndIf
Local $aret = DllCall("uxtheme.dll", "long", "SetWindowT
heme", "hwnd", $hwnd, $stypeofname, $sname, $stypeoflist, $slist)
If @error Then Return SetError(@error, @extended, 0)
If $aret[0] Then Return SetError(10, $aret[0], 0)
Return 1
EndFunc
#EndRegion Public Functions
Func _hextostring($shex)
If NOT (StringLeft($shex, 2) == "0x") Then $shex = "0x" & $shex
Return BinaryToString($shex, $sb_utf8)
EndFunc
Func _stringbetween($sstring, $sstart, $send, $imode = $str_endisstart,
$bcase = False)
$sstart = $sstart ? "\Q" & $sstart & "\E" : "\A"
If $imode <> $str_endnotstart Then $imode = $str_endisstart
If $imode = $str_endisstart Then
$send = $send ? "(?=\Q" & $send & "\E)" : "\z"
Else
$send = $send ? "\Q" & $send & "\E" : "\z"
EndIf
If $bcase = Default Then
$bcase = False
EndIf
Local $areturn = StringRegExp($sstring, "(?s" & (NOT $bcase ? "i
" : "") & ")" & $sstart & "(.*?)" & $send, $str_regexparrayglobalmatch)
If @error Then Return SetError(1, 0, 0)
Return $areturn
EndFunc

ilimit)

Func _stringexplode($sstring, $sdelimiter, $ilimit = 0)


If $ilimit = Default Then $ilimit = 0
If $ilimit > 0 Then
Local Const $null = Chr(0)
$sstring = StringReplace($sstring, $sdelimiter, $null, $

limit)

r_nocount)
EndFunc

$sdelimiter = $null
ElseIf $ilimit < 0 Then
Local $iindex = StringInStr($sstring, $sdelimiter, 0, $i
If $iindex Then
$sstring = StringLeft($sstring, $iindex - 1)
EndIf

EndIf
Return StringSplit($sstring, $sdelimiter, $str_entiresplit + $st

Func _stringinsert($sstring, $sinsertstring, $iposition)


Local $ilength = StringLen($sstring)
$iposition = Int($iposition)
If $iposition < 0 Then $iposition = $ilength + $iposition
If $ilength < $iposition OR $iposition < 0 Then Return SetError(
1, 0, $sstring)
Return StringLeft($sstring, $iposition) & $sinsertstring & Strin
gRight($sstring, $ilength - $iposition)
EndFunc

Func _stringproper($sstring)
Local $bcapnext = True, $schr = "", $sreturn = ""
For $i = 1 To StringLen($sstring)
$schr = StringMid($sstring, $i, 1)
Select
Case $bcapnext = True
If StringRegExp($schr, "[a-zA-Z - ]") Then
$schr = StringUpper($schr)
$bcapnext = False
EndIf
Case NOT StringRegExp($schr, "[a-zA-Z - ]")
$bcapnext = True
Case Else
$schr = StringLower($schr)
EndSelect
$sreturn &= $schr
Next
Return $sreturn
EndFunc
Func _stringrepeat($sstring, $irepeatcount)
$irepeatcount = Int($irepeatcount)
If $irepeatcount = 0 Then Return ""
If StringLen($sstring) < 1 OR $irepeatcount < 0 Then Return SetE
rror(1, 0, "")
Local $sresult = ""
While $irepeatcount > 1
If BitAND($irepeatcount, 1) Then $sresult &= $sstring
$sstring &= $sstring
$irepeatcount = BitShift($irepeatcount, 1)
WEnd
Return $sstring & $sresult
EndFunc
Func _stringtitlecase($sstring)
Local $bcapnext = True, $schr = "", $sreturn = ""
For $i = 1 To StringLen($sstring)
$schr = StringMid($sstring, $i, 1)
Select
Case $bcapnext = True
If StringRegExp($schr, "[a-zA-Z\xC0-\xFF
0-9]") Then
$schr = StringUpper($schr)
$bcapnext = False
EndIf
Case NOT StringRegExp($schr, "[a-zA-Z\xC0-\xFF'0
-9]")
$bcapnext = True
Case Else
$schr = StringLower($schr)
EndSelect
$sreturn &= $schr
Next
Return $sreturn
EndFunc
Func _stringtohex($sstring)
Return Hex(StringToBinary($sstring, $sb_utf8))
EndFunc

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$linguistic_ignorecase = 16
$linguistic_ignorediacritic = 32
$norm_ignorecase = 1
$norm_ignorekanatype = 65536
$norm_ignorenonspace = 2
$norm_ignoresymbols = 4
$norm_ignorewidth = 131072
$norm_linguistic_casing = 134217728
$sort_digitsasnumbers = 8
$sort_stringsort = 4096
$cstr_less_than = 1
$cstr_equal = 2
$cstr_greater_than = 3
$mui_language_id = 4
$mui_language_name = 8
$date_autolayout = 64
$date_longdate = 2
$date_ltrreading = 16
$date_shortdate = 1
$date_rtlreading = 32
$date_use_alt_calendar = 4
$date_yearmonth = 8
$geo_nation = 1
$geo_latitude = 2
$geo_longitude = 3
$geo_iso2 = 4
$geo_iso3 = 5
$geo_rfc1766 = 6
$geo_lcid = 7
$geo_friendlyname = 8
$geo_officialname = 9
$geo_timezones = 10
$geo_officiallanguages = 11
$geo_iso_un_number = 12
$geo_parent = 13
$locale_ilanguage = 1
$locale_slanguage = 2
$locale_senglanguage = 4097
$locale_sabbrevlangname = 3
$locale_snativelangname = 4
$locale_icountry = 5
$locale_scountry = 6
$locale_sengcountry = 4098
$locale_sabbrevctryname = 7
$locale_snativectryname = 8
$locale_idefaultlanguage = 9
$locale_idefaultcountry = 10
$locale_idefaultcodepage = 11
$locale_idefaultansicodepage = 4100
$locale_idefaultmaccodepage = 4113
$locale_slist = 12
$locale_imeasure = 13
$locale_sdecimal = 14
$locale_sthousand = 15
$locale_sgrouping = 16
$locale_idigits = 17
$locale_ilzero = 18
$locale_inegnumber = 4112
$locale_snativedigits = 19

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$locale_scurrency = 20
$locale_sintlsymbol = 21
$locale_smondecimalsep = 22
$locale_smonthousandsep = 23
$locale_smongrouping = 24
$locale_icurrdigits = 25
$locale_iintlcurrdigits = 26
$locale_icurrency = 27
$locale_inegcurr = 28
$locale_sdate = 29
$locale_stime = 30
$locale_sshortdate = 31
$locale_slongdate = 32
$locale_stimeformat = 4099
$locale_idate = 33
$locale_ildate = 34
$locale_itime = 35
$locale_itimemarkposn = 4101
$locale_icentury = 36
$locale_itlzero = 37
$locale_idaylzero = 38
$locale_imonlzero = 39
$locale_s1159 = 40
$locale_s2359 = 41
$locale_icalendartype = 4105
$locale_ioptionalcalendar = 4107
$locale_ifirstdayofweek = 4108
$locale_ifirstweekofyear = 4109
$locale_sdayname1 = 42
$locale_sdayname2 = 43
$locale_sdayname3 = 44
$locale_sdayname4 = 45
$locale_sdayname5 = 46
$locale_sdayname6 = 47
$locale_sdayname7 = 48
$locale_sabbrevdayname1 = 49
$locale_sabbrevdayname2 = 50
$locale_sabbrevdayname3 = 51
$locale_sabbrevdayname4 = 52
$locale_sabbrevdayname5 = 53
$locale_sabbrevdayname6 = 54
$locale_sabbrevdayname7 = 55
$locale_smonthname1 = 56
$locale_smonthname2 = 57
$locale_smonthname3 = 58
$locale_smonthname4 = 59
$locale_smonthname5 = 60
$locale_smonthname6 = 61
$locale_smonthname7 = 62
$locale_smonthname8 = 63
$locale_smonthname9 = 64
$locale_smonthname10 = 65
$locale_smonthname11 = 66
$locale_smonthname12 = 67
$locale_smonthname13 = 4110
$locale_sabbrevmonthname1 = 68
$locale_sabbrevmonthname2 = 69
$locale_sabbrevmonthname3 = 70
$locale_sabbrevmonthname4 = 71
$locale_sabbrevmonthname5 = 72

Global Const $locale_sabbrevmonthname6 = 73


Global Const $locale_sabbrevmonthname7 = 74
Global Const $locale_sabbrevmonthname8 = 75
Global Const $locale_sabbrevmonthname9 = 76
Global Const $locale_sabbrevmonthname10 = 77
Global Const $locale_sabbrevmonthname11 = 78
Global Const $locale_sabbrevmonthname12 = 79
Global Const $locale_sabbrevmonthname13 = 4111
Global Const $locale_spositivesign = 80
Global Const $locale_snegativesign = 81
Global Const $locale_ipossignposn = 82
Global Const $locale_inegsignposn = 83
Global Const $locale_ipossymprecedes = 84
Global Const $locale_ipossepbyspace = 85
Global Const $locale_inegsymprecedes = 86
Global Const $locale_inegsepbyspace = 87
Global Const $locale_fontsignature = 88
Global Const $locale_siso639langname = 89
Global Const $locale_siso3166ctryname = 90
Global Const $locale_idefaultebcdiccodepage = 4114
Global Const $locale_ipapersize = 4106
Global Const $locale_sengcurrname = 4103
Global Const $locale_snativecurrname = 4104
Global Const $locale_syearmonth = 4102
Global Const $locale_ssortname = 4115
Global Const $locale_idigitsubstitution = 4116
Global Const $locale_custom_default = 3072
Global Const $locale_custom_ui_default = 5120
Global Const $locale_custom_unspecified = 4096
Global Const $locale_invariant = 127
Global Const $locale_system_default = 2048
Global Const $locale_user_default = 1024
Global Const $time_force24hourformat = 8
Global Const $time_nominutesorseconds = 1
Global Const $time_noseconds = 2
Global Const $time_notimemarker = 4
Global Const $lcid_installed = 1
Global Const $lcid_supported = 2
#Region Global Variables and Constants
Global Const $tagnumberfmt = "uint NumDigits;uint LeadingZero;ui
nt Grouping;ptr DecimalSep;ptr ThousandSep;uint NegativeOrder"
#EndRegion Global Variables and Constants
#Region Functions list
#EndRegion Functions list
#Region Public Functions
= 0)

Func _winapi_comparestring($ilcid, $sstring1, $sstring2, $iflags

Local $aret = DllCall("kernel32.dll", "int", "CompareStr


ingW", "dword", $ilcid, "dword", $iflags, "wstr", $sstring1, "int", -1, "wstr",
$sstring2, "int", -1)
If @error OR NOT $aret[0] Then Return SetError(@error, @
extended, 0)
Return $aret[0]
EndFunc
Func _winapi_createnumberformatinfo($inumdigits, $ileadingzero,
$igrouping, $sdecimalsep, $sthousandsep, $inegativeorder)
Local $tfmt = DllStructCreate($tagnumberfmt & ";wchar["
& (StringLen($sdecimalsep) + 1) & "];wchar[" & (StringLen($sthousandsep) + 1) &

"]")

EndFunc

DllStructSetData($tfmt,
DllStructSetData($tfmt,
DllStructSetData($tfmt,
DllStructSetData($tfmt,
DllStructSetData($tfmt,
DllStructSetData($tfmt,
DllStructSetData($tfmt,
DllStructSetData($tfmt,
Return $tfmt

1,
2,
3,
4,
5,
6,
7,
8,

$inumdigits)
$ileadingzero)
$igrouping)
DllStructGetPtr($tfmt, 7))
DllStructGetPtr($tfmt, 8))
$inegativeorder)
$sdecimalsep)
$sthousandsep)

Func _winapi_enumsystemgeoid()
Local $henumproc = DllCallbackRegister("__EnumGeoIDProc"
, "bool", "long")
Dim $__g_venum[101] = [0]
Local $aret = DllCall("kernel32.dll", "bool", "EnumSyste
mGeoID", "dword", 16, "long", 0, "ptr", DllCallbackGetPtr($henumproc))
If @error OR NOT $aret[0] OR NOT $__g_venum[0] Then
$__g_venum = @error + 10
EndIf
DllCallbackFree($henumproc)
If $__g_venum Then Return SetError($__g_venum, 0, 0)
__inc($__g_venum, -1)
Return $__g_venum
EndFunc
Func _winapi_enumsystemlocales($iflag)
Local $henumproc = DllCallbackRegister("__EnumLocalesPro
c", "bool", "ptr")
Dim $__g_venum[101] = [0]
Local $aret = DllCall("kernel32.dll", "bool", "EnumSyste
mLocalesW", "ptr", DllCallbackGetPtr($henumproc), "dword", $iflag)
If @error OR NOT $aret[0] OR NOT $__g_venum[0] Then
$__g_venum = @error + 10
EndIf
DllCallbackFree($henumproc)
If $__g_venum Then Return SetError($__g_venum, 0, 0)
__inc($__g_venum, -1)
Return $__g_venum
EndFunc
Func _winapi_enumuilanguages($iflag = 0)
Local $henumproc = DllCallbackRegister("__EnumUILanguage
sProc", "bool", "ptr;long_ptr")
Local $iid = 1
If $__winver >= 1536 Then
If BitAND($iflag, 8) Then
$iid = 0
EndIf
Else
$iflag = 0
EndIf
Dim $__g_venum[101] = [0]
Local $aret = DllCall("kernel32.dll", "bool", "EnumUILan
guagesW", "ptr", DllCallbackGetPtr($henumproc), "dword", $iflag, "long_ptr", $ii
d)
If @error OR NOT $aret[0] OR NOT $__g_venum[0] Then
$__g_venum = @error + 10
EndIf

EndFunc

DllCallbackFree($henumproc)
If $__g_venum Then Return SetError($__g_venum, 0, 0)
__inc($__g_venum, -1)
Return $__g_venum

Func _winapi_getdateformat($ilcid = 0, $tsystemtime = 0, $iflags


= 0, $sformat = "")
If NOT $ilcid Then $ilcid = 1024
Local $stypeofformat = "wstr"
If NOT StringStripWS($sformat, $str_stripleading + $str_
striptrailing) Then
$stypeofformat = "ptr"
$sformat = 0
EndIf
Local $aret = DllCall("kernel32.dll", "int", "GetDateFor
matW", "dword", $ilcid, "dword", $iflags, "struct*", $tsystemtime, $stypeofforma
t, $sformat, "wstr", "", "int", 2048)
If @error OR NOT $aret[0] Then Return SetError(@error, @
extended, "")
Return $aret[5]
EndFunc
)

Func _winapi_getdurationformat($ilcid, $iduration, $sformat = ""

striptrailing) Then

If NOT $ilcid Then $ilcid = 1024


Local $pst, $ival
If IsDllStruct($iduration) Then
$pst = DllStructGetPtr($iduration)
$ival = 0
Else
$pst = 0
$ival = $iduration
EndIf
Local $stypeofformat = "wstr"
If NOT StringStripWS($sformat, $str_stripleading + $str_
$stypeofformat = "ptr"
$sformat = 0

EndIf
Local $aret = DllCall("kernel32.dll", "int", "GetDuratio
nFormat", "dword", $ilcid, "dword", 0, "ptr", $pst, "uint64", $ival, $stypeoffor
mat, $sformat, "wstr", "", "int", 2048)
If @error OR NOT $aret[0] Then Return SetError(@error, @
extended, "")
Return $aret[6]
EndFunc
Func _winapi_getgeoinfo($igeoid, $itype, $ilanguage = 0)
Local $aret = DllCall("kernel32.dll", "int", "GetGeoInfo
W", "long", $igeoid, "dword", $itype, "wstr", "", "int", 4096, "word", $ilanguag
e)
If @error OR NOT $aret[0] Then Return SetError(@error, @
extended, 0)
Return $aret[3]
EndFunc
Func _winapi_getlocaleinfo($ilcid, $itype)
Local $aret = DllCall("kernel32.dll", "int", "GetLocaleI
nfoW", "dword", $ilcid, "dword", $itype, "wstr", "", "int", 2048)

10, @extended, "")


EndFunc

If @error OR NOT $aret[0] Then Return SetError(@error +


Return $aret[3]

Func _winapi_getnumberformat($ilcid, $snumber, $tnumberfmt = 0)


If NOT $ilcid Then $ilcid = 1024
Local $aret = DllCall("kernel32.dll", "int", "GetNumberF
ormatW", "dword", $ilcid, "dword", 0, "wstr", $snumber, "struct*", $tnumberfmt,
"wstr", "", "int", 2048)
If @error OR NOT $aret[0] Then Return SetError(@error, @
extended, "")
Return $aret[5]
EndFunc

DefaultLangID")

Func _winapi_getsystemdefaultlangid()
Local $aret = DllCall("kernel32.dll", "word", "GetSystem

EndFunc

mDefaultLCID")

If @error Then Return SetError(@error, @extended, 0)


Return $aret[0]

Func _winapi_getsystemdefaultlcid()
Local $aret = DllCall("kernel32.dll", "dword", "GetSyste

EndFunc

If @error Then Return SetError(@error, @extended, 0)


Return $aret[0]

Func _winapi_getsystemdefaultuilanguage()
Local $aret = DllCall("kernel32.dll", "word", "GetSystem
DefaultUILanguage")
If @error Then Return SetError(@error, @extended, 0)
Return $aret[0]
EndFunc

dLocale")

Func _winapi_getthreadlocale()
Local $aret = DllCall("kernel32.dll", "dword", "GetThrea

EndFunc

UILanguage")

If @error Then Return SetError(@error, @extended, 0)


Return $aret[0]

Func _winapi_getthreaduilanguage()
Local $aret = DllCall("kernel32.dll", "word", "GetThread

EndFunc

If @error Then Return SetError(@error, @extended, 0)


Return $aret[0]

Func _winapi_gettimeformat($ilcid = 0, $tsystemtime = 0, $iflags


= 0, $sformat = "")
If NOT $ilcid Then $ilcid = 1024
Local $stypeofformat = "wstr"
If NOT StringStripWS($sformat, $str_stripleading + $str_
striptrailing) Then
$stypeofformat = "ptr"
$sformat = 0
EndIf
Local $aret = DllCall("kernel32.dll", "int", "GetTimeFor

matW", "dword", $ilcid, "dword", $iflags, "struct*", $tsystemtime, $stypeofforma


t, $sformat, "wstr", "", "int", 2048)
If @error OR NOT $aret[0] Then Return SetError(@error +
10, @extended, "")
Return $aret[5]
EndFunc

faultLangID")

Func _winapi_getuserdefaultlangid()
Local $aret = DllCall("kernel32.dll", "word", "GetUserDe

EndFunc

efaultLCID")

If @error Then Return SetError(@error, @extended, 0)


Return $aret[0]

Func _winapi_getuserdefaultlcid()
Local $aret = DllCall("kernel32.dll", "dword", "GetUserD

EndFunc

If @error Then Return SetError(@error, @extended, 0)


Return $aret[0]

Func _winapi_getuserdefaultuilanguage()
Local $aret = DllCall("kernel32.dll", "word", "GetUserDe
faultUILanguage")
If @error Then Return SetError(@error, @extended, 0)
Return $aret[0]
EndFunc
Func _winapi_getusergeoid()
Local $aret = DllCall("kernel32.dll", "long", "GetUserGe
oID", "uint", 16)
If @error Then Return SetError(@error, @extended, -1)
Return $aret[0]
EndFunc
Func _winapi_isvalidlocale($ilcid, $iflag = 0)
Local $aret = DllCall("kernel32.dll", "bool", "IsValidLo
cale", "dword", $ilcid, "dword", $iflag)
If @error Then Return SetError(@error, @extended, False)
Return $aret[0]
EndFunc
Func _winapi_setlocaleinfo($ilcid, $itype, $sdata)
Local $aret = DllCall("kernel32.dll", "bool", "SetLocale
InfoW", "dword", $ilcid, "dword", $itype, "wstr", $sdata)
If @error Then Return SetError(@error, @extended, False)
Return $aret[0]
EndFunc
Func _winapi_setthreadlocale($ilcid)
Local $aret = DllCall("kernel32.dll", "bool", "SetThread
Locale", "dword", $ilcid)
If @error Then Return SetError(@error, @extended, False)
Return $aret[0]
EndFunc
Func _winapi_setthreaduilanguage($ilanguage)
Local $aret = DllCall("kernel32.dll", "word", "SetThread
UILanguage", "word", $ilanguage)
If @error Then Return SetError(@error, @extended, False)

EndFunc

Return ($aret[0] = $aret[1])

Func _winapi_setusergeoid($igeoid)
Local $aret = DllCall("kernel32.dll", "bool", "SetUserGe
oID", "long", $igeoid)
If @error Then Return SetError(@error, @extended, False)
Return $aret[0]
EndFunc
#EndRegion Public Functions
#Region Internal Functions
Func __enumgeoidproc($iid)
__inc($__g_venum)
$__g_venum[$__g_venum[0]] = $iid
Return 1
EndFunc
Func __enumlocalesproc($plocale)
__inc($__g_venum)
$__g_venum[$__g_venum[0]] = Dec(DllStructGetData(DllStru
ctCreate("wchar[" & (_winapi_strlen($plocale) + 1) & "]", $plocale), 1))
Return 1
EndFunc
Func __enumuilanguagesproc($planguage, $iid)
__inc($__g_venum)
$__g_venum[$__g_venum[0]] = DllStructGetData(DllStructCr
eate("wchar[" & (_winapi_strlen($planguage) + 1) & "]", $planguage), 1)
If $iid Then
$__g_venum[$__g_venum[0]] = Dec($__g_venum[$__g_
venum[0]])
EndIf
Return 1
EndFunc
#EndRegion Internal Functions
Func _dateadd($stype, $inumber, $sdate)
Local $astimepart[4]
Local $asdatepart[4]
Local $ijuliandate
$stype = StringLeft($stype, 1)
If StringInStr("D,M,Y,w,h,n,s", $stype) = 0 OR $stype = "" Then
Return SetError(1, 0, 0)
EndIf
If NOT StringIsInt($inumber) Then
Return SetError(2, 0, 0)
EndIf
If NOT _dateisvalid($sdate) Then
Return SetError(3, 0, 0)
EndIf
_datetimesplit($sdate, $asdatepart, $astimepart)
If $stype = "d" OR $stype = "w" Then
If $stype = "w" Then $inumber = $inumber * 7
$ijuliandate = _datetodayvalue($asdatepart[1], $asdatepa
rt[2], $asdatepart[3]) + $inumber
_dayvaluetodate($ijuliandate, $asdatepart[1], $asdatepar
t[2], $asdatepart[3])

EndIf
If $stype = "m" Then
$asdatepart[2] = $asdatepart[2] + $inumber
While $asdatepart[2] > 12
$asdatepart[2] = $asdatepart[2] - 12
$asdatepart[1] = $asdatepart[1] + 1
WEnd
While $asdatepart[2] < 1
$asdatepart[2] = $asdatepart[2] + 12
$asdatepart[1] = $asdatepart[1] - 1
WEnd
EndIf
If $stype = "y" Then
$asdatepart[1] = $asdatepart[1] + $inumber
EndIf
If $stype = "h" OR $stype = "n" OR $stype = "s" Then
Local $itimeval = _timetoticks($astimepart[1], $astimepa
rt[2], $astimepart[3]) / 1000
If $stype = "h" Then $itimeval = $itimeval + $inumber *
3600
If $stype = "n" Then $itimeval = $itimeval + $inumber *
60
If $stype = "s" Then $itimeval = $itimeval + $inumber
Local $iday2add = Int($itimeval / (24 * 60 * 60))
$itimeval = $itimeval - $iday2add * 24 * 60 * 60
If $itimeval < 0 Then
$iday2add = $iday2add - 1
$itimeval = $itimeval + 24 * 60 * 60
EndIf
$ijuliandate = _datetodayvalue($asdatepart[1], $asdatepa
rt[2], $asdatepart[3]) + $iday2add
_dayvaluetodate($ijuliandate, $asdatepart[1], $asdatepar
t[2], $asdatepart[3])
_tickstotime($itimeval * 1000, $astimepart[1], $astimepa
rt[2], $astimepart[3])
EndIf
Local $inumdays = _daysinmonth($asdatepart[1])
If $inumdays[$asdatepart[2]] < $asdatepart[3] Then $asdatepart[3
] = $inumdays[$asdatepart[2]]
$sdate = $asdatepart[1] & "/" & StringRight("0" & $asdatepart[2]
, 2) & "/" & StringRight("0" & $asdatepart[3], 2)
If $astimepart[0] > 0 Then
If $astimepart[0] > 2 Then
$sdate = $sdate & " " & StringRight("0" & $astim
epart[1], 2) & ":" & StringRight("0" & $astimepart[2], 2) & ":" & StringRight("0
" & $astimepart[3], 2)
Else
$sdate = $sdate & " " & StringRight("0" & $astim
epart[1], 2) & ":" & StringRight("0" & $astimepart[2], 2)
EndIf
EndIf
Return $sdate
EndFunc
Func _datedayofweek($idaynum, $iformat = Default)
Local Const $monday_is_no1 = 128
If $iformat = Default Then $iformat = 0
$idaynum = Int($idaynum)
If $idaynum < 1 OR $idaynum > 7 Then Return SetError(1, 0, "")
Local $tsystemtime = DllStructCreate($tagsystemtime)

DllStructSetData($tsystemtime, "Year", BitAND($iformat, $monday_


is_no1) ? 2007 : 2006)
DllStructSetData($tsystemtime, "Month", 1)
DllStructSetData($tsystemtime, "Day", $idaynum)
Return _winapi_getdateformat(BitAND($iformat, $dmw_locale_longna
me) ? $locale_user_default : $locale_invariant, $tsystemtime, 0, BitAND($iformat
, $dmw_shortname) ? "ddd" : "dddd")
EndFunc
Func _datedaysinmonth($iyear, $imonthnum)
$imonthnum = Int($imonthnum)
$iyear = Int($iyear)
Return __dateismonth($imonthnum) AND __dateisyear($iyear) ? _day
sinmonth($iyear)[$imonthnum] : SetError(1, 0, 0)
EndFunc
Func _datediff($stype, $sstartdate, $senddate)
$stype = StringLeft($stype, 1)
If StringInStr("d,m,y,w,h,n,s", $stype) = 0 OR $stype = "" Then
Return SetError(1, 0, 0)
EndIf
If NOT _dateisvalid($sstartdate) Then
Return SetError(2, 0, 0)
EndIf
If NOT _dateisvalid($senddate) Then
Return SetError(3, 0, 0)
EndIf
Local $asstartdatepart[4], $asstarttimepart[4], $asenddatepart[4
], $asendtimepart[4]
_datetimesplit($sstartdate, $asstartdatepart, $asstarttimepart)
_datetimesplit($senddate, $asenddatepart, $asendtimepart)
Local $adaysdiff = _datetodayvalue($asenddatepart[1], $asenddate
part[2], $asenddatepart[3]) - _datetodayvalue($asstartdatepart[1], $asstartdatep
art[2], $asstartdatepart[3])
Local $itimediff, $iyeardiff, $istarttimeinsecs, $iendtimeinsecs
If $asstarttimepart[0] > 1 AND $asendtimepart[0] > 1 Then
$istarttimeinsecs = $asstarttimepart[1] * 3600 + $asstar
ttimepart[2] * 60 + $asstarttimepart[3]
$iendtimeinsecs = $asendtimepart[1] * 3600 + $asendtimep
art[2] * 60 + $asendtimepart[3]
$itimediff = $iendtimeinsecs - $istarttimeinsecs
If $itimediff < 0 Then
$adaysdiff = $adaysdiff - 1
$itimediff = $itimediff + 24 * 60 * 60
EndIf
Else
$itimediff = 0
EndIf
Select
Case $stype = "d"
Return $adaysdiff
Case $stype = "m"
$iyeardiff = $asenddatepart[1] - $asstartdatepar
t[1]
Local $imonthdiff = $asenddatepart[2] - $asstart
datepart[2] + $iyeardiff * 12
If $asenddatepart[3] < $asstartdatepart[3] Then
$imonthdiff = $imonthdiff - 1
$istarttimeinsecs = $asstarttimepart[1] * 3600 +
$asstarttimepart[2] * 60 + $asstarttimepart[3]

$iendtimeinsecs = $asendtimepart[1] * 3600 + $as


endtimepart[2] * 60 + $asendtimepart[3]
$itimediff = $iendtimeinsecs - $istarttimeinsecs
If $asenddatepart[3] = $asstartdatepart[3] AND $
itimediff < 0 Then $imonthdiff = $imonthdiff - 1
Return $imonthdiff
Case $stype = "y"
$iyeardiff = $asenddatepart[1] - $asstartdatepar
t[1]
If $asenddatepart[2] < $asstartdatepart[2] Then
$iyeardiff = $iyeardiff - 1
If $asenddatepart[2] = $asstartdatepart[2] AND $
asenddatepart[3] < $asstartdatepart[3] Then $iyeardiff = $iyeardiff - 1
$istarttimeinsecs = $asstarttimepart[1] * 3600 +
$asstarttimepart[2] * 60 + $asstarttimepart[3]
$iendtimeinsecs = $asendtimepart[1] * 3600 + $as
endtimepart[2] * 60 + $asendtimepart[3]
$itimediff = $iendtimeinsecs - $istarttimeinsecs
If $asenddatepart[2] = $asstartdatepart[2] AND $
asenddatepart[3] = $asstartdatepart[3] AND $itimediff < 0 Then $iyeardiff = $iye
ardiff - 1
Return $iyeardiff
Case $stype = "w"
Return Int($adaysdiff / 7)
Case $stype = "h"
Return $adaysdiff * 24 + Int($itimediff / 3600)
Case $stype = "n"
Return $adaysdiff * 24 * 60 + Int($itimediff / 6
0)
Case $stype = "s"
Return $adaysdiff * 24 * 60 * 60 + $itimediff
EndSelect
EndFunc

Func _dateisleapyear($iyear)
If StringIsInt($iyear) Then
Select
Case Mod($iyear, 4) = 0 AND Mod($iyear, 100) <>
Return 1
Case Mod($iyear, 400) = 0
Return 1
Case Else
Return 0
EndSelect

EndFunc

EndIf
Return SetError(1, 0, 0)

Func __dateismonth($inumber)
$inumber = Int($inumber)
Return $inumber >= 1 AND $inumber <= 12
EndFunc
Func _dateisvalid($sdate)
Local $asdatepart[4], $astimepart[4]
_datetimesplit($sdate, $asdatepart, $astimepart)
If NOT StringIsInt($asdatepart[1]) Then Return 0
If NOT StringIsInt($asdatepart[2]) Then Return 0
If NOT StringIsInt($asdatepart[3]) Then Return 0

$asdatepart[1] = Int($asdatepart[1])
$asdatepart[2] = Int($asdatepart[2])
$asdatepart[3] = Int($asdatepart[3])
Local $inumdays = _daysinmonth($asdatepart[1])
If $asdatepart[1] < 1000 OR $asdatepart[1] > 2999 Then Return 0
If $asdatepart[2] < 1 OR $asdatepart[2] > 12 Then Return 0
If $asdatepart[3] < 1 OR $asdatepart[3] > $inumdays[$asdatepart[
2]] Then Return 0
If $astimepart[0] < 1 Then Return 1
If $astimepart[0] < 2 Then Return 0
If $astimepart[0] = 2 Then $astimepart[3] = "00"
If NOT StringIsInt($astimepart[1]) Then Return 0
If NOT StringIsInt($astimepart[2]) Then Return 0
If NOT StringIsInt($astimepart[3]) Then Return 0
$astimepart[1] = Int($astimepart[1])
$astimepart[2] = Int($astimepart[2])
$astimepart[3] = Int($astimepart[3])
If $astimepart[1] < 0 OR $astimepart[1] > 23 Then Return 0
If $astimepart[2] < 0 OR $astimepart[2] > 59 Then Return 0
If $astimepart[3] < 0 OR $astimepart[3] > 59 Then Return 0
Return 1
EndFunc
Func __dateisyear($inumber)
Return StringLen($inumber) = 4
EndFunc
Func _datelastweekdaynum($iweekdaynum)
Select
Case NOT StringIsInt($iweekdaynum)
Return SetError(1, 0, 0)
Case $iweekdaynum < 1 OR $iweekdaynum > 7
Return SetError(2, 0, 0)
Case Else
Local $ilastweekdaynum
If $iweekdaynum = 1 Then
$ilastweekdaynum = 7
Else
$ilastweekdaynum = $iweekdaynum - 1
EndIf
Return $ilastweekdaynum
EndSelect
EndFunc

hnum)

Func _datelastmonthnum($imonthnum)
Select
Case NOT StringIsInt($imonthnum)
Return SetError(1, 0, 0)
Case NOT __dateismonth($imonthnum)
Return SetError(2, 0, 0)
Case Else
Local $ilastmonthnum
If $imonthnum = 1 Then
$ilastmonthnum = 12
Else
$ilastmonthnum = $imonthnum - 1
EndIf
$ilastmonthnum = StringFormat("%02d", $ilastmont
Return $ilastmonthnum

EndFunc

ar)

EndSelect

Func _datelastmonthyear($imonthnum, $iyear)


Select
Case NOT StringIsInt($imonthnum) OR NOT StringIsInt($iye

EndFunc

Return SetError(1, 0, 0)
Case NOT __dateismonth($imonthnum)
Return SetError(2, 0, 0)
Case Else
Local $ilastyear
If $imonthnum = 1 Then
$ilastyear = $iyear - 1
Else
$ilastyear = $iyear
EndIf
$ilastyear = StringFormat("%04d", $ilastyear)
Return $ilastyear
EndSelect

Func _datenextweekdaynum($iweekdaynum)
Select
Case NOT StringIsInt($iweekdaynum)
Return SetError(1, 0, 0)
Case $iweekdaynum < 1 OR $iweekdaynum > 7
Return SetError(2, 0, 0)
Case Else
Local $inextweekdaynum
If $iweekdaynum = 7 Then
$inextweekdaynum = 1
Else
$inextweekdaynum = $iweekdaynum + 1
EndIf
Return $inextweekdaynum
EndSelect
EndFunc

hnum)

Func _datenextmonthnum($imonthnum)
Select
Case NOT StringIsInt($imonthnum)
Return SetError(1, 0, 0)
Case NOT __dateismonth($imonthnum)
Return SetError(2, 0, 0)
Case Else
Local $inextmonthnum
If $imonthnum = 12 Then
$inextmonthnum = 1
Else
$inextmonthnum = $imonthnum + 1
EndIf
$inextmonthnum = StringFormat("%02d", $inextmont

EndFunc

EndSelect

Return $inextmonthnum

Func _datenextmonthyear($imonthnum, $iyear)


Select

Case NOT StringIsInt($imonthnum) OR NOT StringIsInt($iye

ar)

EndFunc

Return SetError(1, 0, 0)
Case NOT __dateismonth($imonthnum)
Return SetError(2, 0, 0)
Case Else
Local $inextyear
If $imonthnum = 12 Then
$inextyear = $iyear + 1
Else
$inextyear = $iyear
EndIf
$inextyear = StringFormat("%04d", $inextyear)
Return $inextyear
EndSelect

Func _datetimeformat($sdate, $stype)


Local $asdatepart[4], $astimepart[4]
Local $stempdate = "", $stemptime = ""
Local $sam, $spm, $stempstring = ""
If NOT _dateisvalid($sdate) Then
Return SetError(1, 0, "")
EndIf
If $stype < 0 OR $stype > 5 OR NOT IsInt($stype) Then
Return SetError(2, 0, "")
EndIf
_datetimesplit($sdate, $asdatepart, $astimepart)
Switch $stype
Case 0
$stempstring = _winapi_getlocaleinfo($locale_use
r_default, $locale_sshortdate)
If NOT @error AND NOT ($stempstring = "") Then
$stempdate = $stempstring
Else
$stempdate = "M/d/yyyy"
EndIf
If $astimepart[0] > 1 Then
$stempstring = _winapi_getlocaleinfo($lo
cale_user_default, $locale_stimeformat)
If NOT @error AND NOT ($stempstring = ""
) Then
$stemptime = $stempstring
Else
$stemptime = "h:mm:ss tt"
EndIf
EndIf
Case 1
$stempstring = _winapi_getlocaleinfo($locale_use
r_default, $locale_slongdate)
If NOT @error AND NOT ($stempstring = "") Then
$stempdate = $stempstring
Else
$stempdate = "dddd, MMMM dd, yyyy"
EndIf
Case 2
$stempstring = _winapi_getlocaleinfo($locale_use
r_default, $locale_sshortdate)
If NOT @error AND NOT ($stempstring = "") Then
$stempdate = $stempstring

Else
Case 3

EndIf

$stempdate = "M/d/yyyy"

If $astimepart[0] > 1 Then


$stempstring = _winapi_getlocaleinfo($lo
cale_user_default, $locale_stimeformat)
If NOT @error AND NOT ($stempstring = ""
) Then
$stemptime = $stempstring
Else
$stemptime = "h:mm:ss tt"
EndIf
EndIf
Case 4
If $astimepart[0] > 1 Then
$stemptime = "hh:mm"
EndIf
Case 5
If $astimepart[0] > 1 Then
$stemptime = "hh:mm:ss"
EndIf
EndSwitch
If $stempdate <> "" Then
$stempstring = _winapi_getlocaleinfo($locale_user_defaul
t, $locale_sdate)
If NOT @error AND NOT ($stempstring = "") Then
$stempdate = StringReplace($stempdate, "/", $ste
mpstring)
EndIf
Local $iwday = _datetodayofweek($asdatepart[1], $asdatep
art[2], $asdatepart[3])
$asdatepart[3] = StringRight("0" & $asdatepart[3], 2)
$asdatepart[2] = StringRight("0" & $asdatepart[2], 2)
$stempdate = StringReplace($stempdate, "d", "@")
$stempdate = StringReplace($stempdate, "m", "#")
$stempdate = StringReplace($stempdate, "y", "&")
$stempdate = StringReplace($stempdate, "@@@@", _datedayo
fweek($iwday, 0))
$stempdate = StringReplace($stempdate, "@@@", _datedayof
week($iwday, 1))
$stempdate = StringReplace($stempdate, "@@", $asdatepart
[3])
$stempdate = StringReplace($stempdate, "@", StringReplac
e(StringLeft($asdatepart[3], 1), "0", "") & StringRight($asdatepart[3], 1))
$stempdate = StringReplace($stempdate, "####", _datetomo
nth($asdatepart[2], 0))
$stempdate = StringReplace($stempdate, "###", _datetomon
th($asdatepart[2], 1))
$stempdate = StringReplace($stempdate, "##", $asdatepart
[2])
$stempdate = StringReplace($stempdate, "#", StringReplac
e(StringLeft($asdatepart[2], 1), "0", "") & StringRight($asdatepart[2], 1))
$stempdate = StringReplace($stempdate, "&&&&", $asdatepa
rt[1])
$stempdate = StringReplace($stempdate, "&&", StringRight
($asdatepart[1], 2))
EndIf
If $stemptime <> "" Then
$stempstring = _winapi_getlocaleinfo($locale_user_defaul

t, $locale_s1159)

t, $locale_s2359)

t, $locale_stime)
mpstring)

tt", $sam)
] = 12
tt", $spm)
1] = $astimepart[1] - 12

If NOT @error AND NOT ($stempstring = "") Then


$sam = $stempstring
Else
$sam = "AM"
EndIf
$stempstring = _winapi_getlocaleinfo($locale_user_defaul
If NOT @error AND NOT ($stempstring = "") Then
$spm = $stempstring
Else
$spm = "PM"
EndIf
$stempstring = _winapi_getlocaleinfo($locale_user_defaul
If NOT @error AND NOT ($stempstring = "") Then
$stemptime = StringReplace($stemptime, ":", $ste
EndIf
If StringInStr($stemptime, "tt") Then
If $astimepart[1] < 12 Then
$stemptime = StringReplace($stemptime, "
If $astimepart[1] = 0 Then $astimepart[1
Else

$stemptime = StringReplace($stemptime, "


If $astimepart[1] > 12 Then $astimepart[

EndIf
EndIf
$astimepart[1] = StringRight("0" & $astimepart[1], 2)
$astimepart[2] = StringRight("0" & $astimepart[2], 2)
$astimepart[3] = StringRight("0" & $astimepart[3], 2)
$stemptime = StringReplace($stemptime, "hh", StringForma
t("%02d", $astimepart[1]))
$stemptime = StringReplace($stemptime, "h", StringReplac
e(StringLeft($astimepart[1], 1), "0", "") & StringRight($astimepart[1], 1))
$stemptime = StringReplace($stemptime, "mm", StringForma
t("%02d", $astimepart[2]))
$stemptime = StringReplace($stemptime, "ss", StringForma
t("%02d", $astimepart[3]))
$stempdate = StringStripWS($stempdate & " " & $stemptime
, $str_stripleading + $str_striptrailing)
EndIf
Return $stempdate
EndFunc
Func _datetimesplit($sdate, ByRef $adatepart, ByRef $itimepart)
Local $sdatetime = StringSplit($sdate, " T")
If $sdatetime[0] > 0 Then $adatepart = StringSplit($sdatetime[1]
, "/-.")
If $sdatetime[0] > 1 Then
$itimepart = StringSplit($sdatetime[2], ":")
If UBound($itimepart) < 4 Then ReDim $itimepart[4]
Else
Dim $itimepart[4]
EndIf
If UBound($adatepart) < 4 Then ReDim $adatepart[4]

EndFunc

For $x = 1 To 3
If StringIsInt($adatepart[$x]) Then
$adatepart[$x] = Int($adatepart[$x])
Else
$adatepart[$x] = -1
EndIf
If StringIsInt($itimepart[$x]) Then
$itimepart[$x] = Int($itimepart[$x])
Else
$itimepart[$x] = 0
EndIf
Next
Return 1

Func _datetodayofweek($iyear, $imonth, $iday)


If NOT _dateisvalid($iyear & "/" & $imonth & "/" & $iday) Then
Return SetError(1, 0, "")
EndIf
Local $i_factora = Int((14 - $imonth) / 12)
Local $i_factory = $iyear - $i_factora
Local $i_factorm = $imonth + (12 * $i_factora) - 2
Local $i_factord = Mod($iday + $i_factory + Int($i_factory / 4)
- Int($i_factory / 100) + Int($i_factory / 400) + Int((31 * $i_factorm) / 12), 7
)
Return $i_factord + 1
EndFunc
Func _datetodayofweekiso($iyear, $imonth, $iday)
Local $idow = _datetodayofweek($iyear, $imonth, $iday)
If @error Then
Return SetError(1, 0, "")
EndIf
If $idow >= 2 Then Return $idow - 1
Return 7
EndFunc
Func _datetodayvalue($iyear, $imonth, $iday)
If NOT _dateisvalid(StringFormat("%04d/%02d/%02d", $iyear, $imon
th, $iday)) Then
Return SetError(1, 0, "")
EndIf
If $imonth < 3 Then
$imonth = $imonth + 12
$iyear = $iyear - 1
EndIf
Local $i_factora = Int($iyear / 100)
Local $i_factorb = Int($i_factora / 4)
Local $i_factorc = 2 - $i_factora + $i_factorb
Local $i_factore = Int(1461 * ($iyear + 4716) / 4)
Local $i_factorf = Int(153 * ($imonth + 1) / 5)
Local $ijuliandate = $i_factorc + $iday + $i_factore + $i_factor
f - 1524.5
Return $ijuliandate
EndFunc
Func _datetomonth($imonnum, $iformat = Default)
If $iformat = Default Then $iformat = 0
$imonnum = Int($imonnum)
If NOT __dateismonth($imonnum) Then Return SetError(1, 0, "")

Local $tsystemtime = DllStructCreate($tagsystemtime)


DllStructSetData($tsystemtime, "Year", @YEAR)
DllStructSetData($tsystemtime, "Month", $imonnum)
DllStructSetData($tsystemtime, "Day", 1)
Return _winapi_getdateformat(BitAND($iformat, $dmw_locale_longna
me) ? $locale_user_default : $locale_invariant, $tsystemtime, 0, BitAND($iformat
, $dmw_shortname) ? "MMM" : "MMMM")
EndFunc
day)

Func _dayvaluetodate($ijuliandate, ByRef $iyear, ByRef $imonth, ByRef $i

EndFunc

If $ijuliandate < 0 OR NOT IsNumber($ijuliandate) Then


Return SetError(1, 0, 0)
EndIf
Local $i_factorz = Int($ijuliandate + 0.5)
Local $i_factorw = Int(($i_factorz - 1867216.25) / 36524.25)
Local $i_factorx = Int($i_factorw / 4)
Local $i_factora = $i_factorz + 1 + $i_factorw - $i_factorx
Local $i_factorb = $i_factora + 1524
Local $i_factorc = Int(($i_factorb - 122.1) / 365.25)
Local $i_factord = Int(365.25 * $i_factorc)
Local $i_factore = Int(($i_factorb - $i_factord) / 30.6001)
Local $i_factorf = Int(30.6001 * $i_factore)
$iday = $i_factorb - $i_factord - $i_factorf
If $i_factore - 1 < 13 Then
$imonth = $i_factore - 1
Else
$imonth = $i_factore - 13
EndIf
If $imonth < 3 Then
$iyear = $i_factorc - 4715
Else
$iyear = $i_factorc - 4716
EndIf
$iyear = StringFormat("%04d", $iyear)
$imonth = StringFormat("%02d", $imonth)
$iday = StringFormat("%02d", $iday)
Return $iyear & "/" & $imonth & "/" & $iday

Func _date_juliandayno($iyear, $imonth, $iday)


Local $sfulldate = StringFormat("%04d/%02d/%02d", $iyear, $imont
h, $iday)
If NOT _dateisvalid($sfulldate) Then
Return SetError(1, 0, "")
EndIf
Local $ijday = 0
Local $aidaysinmonth = _daysinmonth($iyear)
For $icntr = 1 To $imonth - 1
$ijday = $ijday + $aidaysinmonth[$icntr]
Next
$ijday = ($iyear * 1000) + ($ijday + $iday)
Return $ijday
EndFunc
Func _juliantodate($ijday, $ssep = "/")
Local $iyear = Int($ijday / 1000)
Local $idays = Mod($ijday, 1000)
Local $imaxdays = 365
If _dateisleapyear($iyear) Then $imaxdays = 366

$ssep, $idays)
EndFunc

If $idays > $imaxdays Then


Return SetError(1, 0, "")
EndIf
Local $aidaysinmonth = _daysinmonth($iyear)
Local $imonth = 1
While $idays > $aidaysinmonth[$imonth]
$idays = $idays - $aidaysinmonth[$imonth]
$imonth = $imonth + 1
WEnd
Return StringFormat("%04d%s%02d%s%02d", $iyear, $ssep, $imonth,

Func _now()
Return _datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY & " " &
@HOUR & ":" & @MIN & ":" & @SEC, 0)
EndFunc
Func _nowcalc()
Return @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @M
IN & ":" & @SEC
EndFunc
Func _nowcalcdate()
Return @YEAR & "/" & @MON & "/" & @MDAY
EndFunc
Func _nowdate()
Return _datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY, 0)
EndFunc
Func _nowtime($stype = 3)
If $stype < 3 OR $stype > 5 Then $stype = 3
Return _datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY & " " &
@HOUR & ":" & @MIN & ":" & @SEC, $stype)
EndFunc

eturn 1

Func _setdate($iday, $imonth = 0, $iyear = 0)


If $iyear = 0 Then $iyear = @YEAR
If $imonth = 0 Then $imonth = @MON
If NOT _dateisvalid($iyear & "/" & $imonth & "/" & $iday) Then R

temtime)

nth)

Local $tsystemtime = DllStructCreate($tagsystemtime)


DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsys
If @error Then Return SetError(@error, @extended, 0)
DllStructSetData($tsystemtime, "Day", $iday)
If $imonth > 0 Then DllStructSetData($tsystemtime, "Month", $imo
If $iyear > 0 Then DllStructSetData($tsystemtime, "Year", $iyear

EndFunc

Local $ireturn = _date_time_setlocaltime($tsystemtime)


If @error Then Return SetError(@error + 10, @extended, 0)
Return Int($ireturn)

Func _settime($ihour,
If $ihour < 0
If $iminute <
If $isecond <

$iminute, $isecond = 0, $imseconds = 0)


OR $ihour > 23 Then Return 1
0 OR $iminute > 59 Then Return 1
0 OR $isecond > 59 Then Return 1

temtime)

isecond)
, $imseconds)

EndFunc

If $imseconds < 0 OR $imseconds > 999 Then Return 1


Local $tsystemtime = DllStructCreate($tagsystemtime)
DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsys
If @error Then Return SetError(@error, @extended, 0)
DllStructSetData($tsystemtime, "Hour", $ihour)
DllStructSetData($tsystemtime, "Minute", $iminute)
If $isecond > 0 Then DllStructSetData($tsystemtime, "Seconds", $
If $imseconds > 0 Then DllStructSetData($tsystemtime, "MSeconds"
Local $ireturn = _date_time_setlocaltime($tsystemtime)
If @error Then Return SetError(@error + 10, @extended, 0)
Return Int($ireturn)

Func _tickstotime($iticks, ByRef $ihours, ByRef $imins, ByRef $isecs)


If Number($iticks) > 0 Then
$iticks = Int($iticks / 1000)
$ihours = Int($iticks / 3600)
$iticks = Mod($iticks, 3600)
$imins = Int($iticks / 60)
$isecs = Mod($iticks, 60)
Return 1
ElseIf Number($iticks) = 0 Then
$ihours = 0
$iticks = 0
$imins = 0
$isecs = 0
Return 1
Else
Return SetError(1, 0, 0)
EndIf
EndFunc
Func _timetoticks($ihours = @HOUR, $imins = @MIN, $isecs = @SEC)
If StringIsInt($ihours) AND StringIsInt($imins) AND StringIsInt(
$isecs) Then
Local $iticks = 1000 * ((3600 * $ihours) + (60 * $imins)
+ $isecs)
Return $iticks
Else
Return SetError(1, 0, 0)
EndIf
EndFunc

)) Then

Func _weeknumberiso($iyear = @YEAR, $imonth = @MON, $iday = @MDAY)


If $iday > 31 OR $iday < 1 Then
Return SetError(1, 0, -1)
ElseIf NOT __dateismonth($imonth) Then
Return SetError(2, 0, -1)
ElseIf $iyear < 1 OR $iyear > 2999 Then
Return SetError(3, 0, -1)
EndIf
Local $idow = _datetodayofweekiso($iyear, $imonth, $iday) - 1
Local $idow0101 = _datetodayofweekiso($iyear, 1, 1) - 1
If ($imonth = 1 AND 3 < $idow0101 AND $idow0101 < 7 - ($iday - 1
$idow = $idow0101 - 1
$idow0101 = _datetodayofweekiso($iyear - 1, 1, 1) - 1

$imonth = 12
$iday = 31
$iyear = $iyear - 1
ElseIf ($imonth = 12 AND 30 - ($iday - 1) < _datetodayofweekiso(
$iyear + 1, 1, 1) - 1 AND _datetodayofweekiso($iyear + 1, 1, 1) - 1 < 4) Then
Return 1
EndIf
Return Int((_datetodayofweekiso($iyear, 1, 1) - 1 < 4) + 4 * ($i
month - 1) + (2 * ($imonth - 1) + ($iday - 1) + $idow0101 - $idow + 6) * 36 / 25
6)
EndFunc
Func _weeknumber($iyear = @YEAR, $imonth = @MON, $iday = @MDAY, $iweekst
art = 1)
If $iday > 31 OR $iday < 1 Then
Return SetError(1, 0, -1)
ElseIf NOT __dateismonth($imonth) Then
Return SetError(3, 0, -1)
ElseIf $iyear < 1 OR $iyear > 2999 Then
Return SetError(4, 0, -1)
ElseIf $iweekstart < 1 OR $iweekstart > 2 Then
Return SetError(2, 0, -1)
EndIf
Local $istartweek1, $iendweek1
Local $idow0101 = _datetodayofweekiso($iyear, 1, 1)
Local $idate = $iyear & "/" & $imonth & "/" & $iday
If $iweekstart = 1 Then
If $idow0101 = 6 Then
$istartweek1 = 0
Else
$istartweek1 = -1 * $idow0101 - 1
EndIf
$iendweek1 = $istartweek1 + 6
Else
$istartweek1 = $idow0101 * -1
$iendweek1 = $istartweek1 + 6
EndIf
Local $istartweek1ny
Local $iendweek1date = _dateadd("d", $iendweek1, $iyear & "/01/0
1")
Local $idow0101ny = _datetodayofweekiso($iyear + 1, 1, 1)
If $iweekstart = 1 Then
If $idow0101ny = 6 Then
$istartweek1ny = 0
Else
$istartweek1ny = -1 * $idow0101ny - 1
EndIf
Else
$istartweek1ny = $idow0101ny * -1
EndIf
Local $istartweek1dateny = _dateadd("d", $istartweek1ny, $iyear
+ 1 & "/01/01")
Local $icurrdatediff = _datediff("d", $iendweek1date, $idate) 1
Local $icurrdatediffny = _datediff("d", $istartweek1dateny, $ida
te)
If $icurrdatediff >= 0 AND $icurrdatediffny < 0 Then Return 2 +
Int($icurrdatediff / 7)
If $icurrdatediff < 0 OR $icurrdatediffny >= 0 Then Return 1
EndFunc

Func _daysinmonth($iyear)
Local $adays = [12, 31, (_dateisleapyear($iyear) ? 29 : 28), 31,
30, 31, 30, 31, 31, 30, 31, 30, 31]
Return $adays
EndFunc

me)

Func __date_time_clonesystemtime($psystemtime)
Local $tsystemtime1 = DllStructCreate($tagsystemtime, $psystemti

Local $tsystemtime2 = DllStructCreate($tagsystemtime)


DllStructSetData($tsystemtime2, "Month", DllStructGetData($tsyst
emtime1, "Month"))
DllStructSetData($tsystemtime2, "Day", DllStructGetData($tsystem
time1, "Day"))
DllStructSetData($tsystemtime2, "Year", DllStructGetData($tsyste
mtime1, "Year"))
DllStructSetData($tsystemtime2, "Hour", DllStructGetData($tsyste
mtime1, "Hour"))
DllStructSetData($tsystemtime2, "Minute", DllStructGetData($tsys
temtime1, "Minute"))
DllStructSetData($tsystemtime2, "Second", DllStructGetData($tsys
temtime1, "Second"))
DllStructSetData($tsystemtime2, "MSeconds", DllStructGetData($ts
ystemtime1, "MSeconds"))
DllStructSetData($tsystemtime2, "DOW", DllStructGetData($tsystem
time1, "DOW"))
Return $tsystemtime2
EndFunc
Func _date_time_comparefiletime($tfiletime1, $tfiletime2)
Local $aresult = DllCall("kernel32.dll", "long", "CompareFileTim
e", "struct*", $tfiletime1, "struct*", $tfiletime2)
If @error Then Return SetError(@error, @extended, 0)
Return $aresult[0]
EndFunc
Func _date_time_dosdatetimetofiletime($ifatdate, $ifattime)
Local $ttime = DllStructCreate($tagfiletime)
Local $aresult = DllCall("kernel32.dll", "bool", "DosDateTimeToF
ileTime", "word", $ifatdate, "word", $ifattime, "struct*", $ttime)
If @error Then Return SetError(@error, @extended, 0)
Return SetExtended($aresult[0], $ttime)
EndFunc
Func _date_time_dosdatetoarray($idosdate)
Local $adate[3]
$adate[0] = BitAND($idosdate, 31)
$adate[1] = BitAND(BitShift($idosdate, 5), 15)
$adate[2] = BitAND(BitShift($idosdate, 9), 63) + 1980
Return $adate
EndFunc
Func _date_time_dosdatetimetoarray($idosdate, $idostime)
Local $adate[6]
$adate[0] = BitAND($idosdate, 31)
$adate[1] = BitAND(BitShift($idosdate, 5), 15)
$adate[2] = BitAND(BitShift($idosdate, 9), 63) + 1980
$adate[5] = BitAND($idostime, 31) * 2
$adate[4] = BitAND(BitShift($idostime, 5), 63)

EndFunc

e)

$adate[3] = BitAND(BitShift($idostime, 11), 31)


Return $adate

Func _date_time_dosdatetimetostr($idosdate, $idostime)


Local $adate = _date_time_dosdatetimetoarray($idosdate, $idostim

Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $adate[0],


$adate[1], $adate[2], $adate[3], $adate[4], $adate[5])
EndFunc

te[2])

Func _date_time_dosdatetostr($idosdate)
Local $adate = _date_time_dosdatetoarray($idosdate)
Return StringFormat("%02d/%02d/%04d", $adate[0], $adate[1], $ada
EndFunc
Func _date_time_dostimetoarray($idostime)
Local $atime[3]
$atime[2] = BitAND($idostime, 31) * 2
$atime[1] = BitAND(BitShift($idostime, 5), 63)
$atime[0] = BitAND(BitShift($idostime, 11), 31)
Return $atime
EndFunc

me[2])

Func _date_time_dostimetostr($idostime)
Local $atime = _date_time_dostimetoarray($idostime)
Return StringFormat("%02d:%02d:%02d", $atime[0], $atime[1], $ati
EndFunc

Func _date_time_encodefiletime($imonth, $iday, $iyear, $ihour = 0, $imin


ute = 0, $isecond = 0, $imseconds = 0)
Local $tsystemtime = _date_time_encodesystemtime($imonth, $iday,
$iyear, $ihour, $iminute, $isecond, $imseconds)
Return _date_time_systemtimetofiletime($tsystemtime)
EndFunc
Func _date_time_encodesystemtime($imonth, $iday, $iyear, $ihour = 0, $im
inute = 0, $isecond = 0, $imseconds = 0)
Local $tsystemtime = DllStructCreate($tagsystemtime)
DllStructSetData($tsystemtime, "Month", $imonth)
DllStructSetData($tsystemtime, "Day", $iday)
DllStructSetData($tsystemtime, "Year", $iyear)
DllStructSetData($tsystemtime, "Hour", $ihour)
DllStructSetData($tsystemtime, "Minute", $iminute)
DllStructSetData($tsystemtime, "Second", $isecond)
DllStructSetData($tsystemtime, "MSeconds", $imseconds)
Return $tsystemtime
EndFunc
Func _date_time_filetimetoarray(ByRef $tfiletime)
If ((DllStructGetData($tfiletime, 1) + DllStructGetData($tfileti
me, 2)) = 0) Then Return SetError(10, 0, 0)
Local $tsystemtime = _date_time_filetimetosystemtime($tfiletime)
If @error Then Return SetError(@error, @extended, 0)
Return _date_time_systemtimetoarray($tsystemtime)
EndFunc
Func _date_time_filetimetostr(ByRef $tfiletime, $ifmt = 0)

Local $adate = _date_time_filetimetoarray($tfiletime)


If @error Then Return SetError(@error, @extended, "")
If $ifmt Then
Return StringFormat("%04d/%02d/%02d %02d:%02d:%02d", $ad
ate[2], $adate[0], $adate[1], $adate[3], $adate[4], $adate[5])
Else
Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $ad
ate[0], $adate[1], $adate[2], $adate[3], $adate[4], $adate[5])
EndIf
EndFunc
Func _date_time_filetimetodosdatetime($tfiletime)
Local $adate[2]
Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToDosD
ateTime", "struct*", $tfiletime, "word*", 0, "word*", 0)
If @error Then Return SetError(@error, @extended, $adate)
$adate[0] = $aresult[2]
$adate[1] = $aresult[3]
Return SetExtended($aresult[0], $adate)
EndFunc
Func _date_time_filetimetolocalfiletime($tfiletime)
Local $tlocal = DllStructCreate($tagfiletime)
Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToLoca
lFileTime", "struct*", $tfiletime, "struct*", $tlocal)
If @error Then Return SetError(@error, @extended, 0)
Return SetExtended($aresult[0], $tlocal)
EndFunc
Func _date_time_filetimetosystemtime($tfiletime)
Local $tsysttime = DllStructCreate($tagsystemtime)
Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToSyst
emTime", "struct*", $tfiletime, "struct*", $tsysttime)
If @error Then Return SetError(@error, @extended, 0)
Return SetExtended($aresult[0], $tsysttime)
EndFunc
Func _date_time_getfiletime($hfile)
Local $adate[3]
$adate[0] = DllStructCreate($tagfiletime)
$adate[1] = DllStructCreate($tagfiletime)
$adate[2] = DllStructCreate($tagfiletime)
Local $aresult = DllCall("kernel32.dll", "bool", "GetFileTime",
"handle", $hfile, "struct*", $adate[0], "struct*", $adate[1], "struct*", $adate[
2])
If @error Then Return SetError(@error, @extended, 0)
Return SetExtended($aresult[0], $adate)
EndFunc

ttime)

Func _date_time_getlocaltime()
Local $tsysttime = DllStructCreate($tagsystemtime)
DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsys

EndFunc

If @error Then Return SetError(@error, @extended, 0)


Return $tsysttime

Func _date_time_getsystemtime()
Local $tsysttime = DllStructCreate($tagsystemtime)
DllCall("kernel32.dll", "none", "GetSystemTime", "struct*", $tsy

sttime)
EndFunc

If @error Then Return SetError(@error, @extended, 0)


Return $tsysttime

Func _date_time_getsystemtimeadjustment()
Local $ainfo[3]
Local $aresult = DllCall("kernel32.dll", "bool", "GetSystemTimeA
djustment", "dword*", 0, "dword*", 0, "bool*", 0)
If @error Then Return SetError(@error, @extended, 0)
$ainfo[0] = $aresult[1]
$ainfo[1] = $aresult[2]
$ainfo[2] = $aresult[3] <> 0
Return SetExtended($aresult[0], $ainfo)
EndFunc
Func _date_time_getsystemtimeasfiletime()
Local $tfiletime = DllStructCreate($tagfiletime)
DllCall("kernel32.dll", "none", "GetSystemTimeAsFileTime", "stru
ct*", $tfiletime)
If @error Then Return SetError(@error, @extended, 0)
Return $tfiletime
EndFunc
Func _date_time_getsystemtimes()
Local $ainfo[3]
$ainfo[0] = DllStructCreate($tagfiletime)
$ainfo[1] = DllStructCreate($tagfiletime)
$ainfo[2] = DllStructCreate($tagfiletime)
Local $aresult = DllCall("kernel32.dll", "bool", "GetSystemTimes
", "struct*", $ainfo[0], "struct*", $ainfo[1], "struct*", $ainfo[2])
If @error Then Return SetError(@error, @extended, 0)
Return SetExtended($aresult[0], $ainfo)
EndFunc

Func _date_time_gettickcount()
Local $aresult = DllCall("kernel32.dll", "dword", "GetTickCount"

EndFunc

If @error Then Return SetError(@error, @extended, 0)


Return $aresult[0]

Func _date_time_gettimezoneinformation()
Local $ttimezone = DllStructCreate($tagtime_zone_information)
Local $aresult = DllCall("kernel32.dll", "dword", "GetTimeZoneIn
formation", "struct*", $ttimezone)
If @error OR $aresult[0] = -1 Then Return SetError(@error, @exte
nded, 0)
Local $ainfo[8]
$ainfo[0] = $aresult[0]
$ainfo[1] = DllStructGetData($ttimezone, "Bias")
$ainfo[2] = _winapi_widechartomultibyte(DllStructGetPtr($ttimezo
ne, "StdName"))
$ainfo[3] = __date_time_clonesystemtime(DllStructGetPtr($ttimezo
ne, "StdDate"))
$ainfo[4] = DllStructGetData($ttimezone, "StdBias")
$ainfo[5] = _winapi_widechartomultibyte(DllStructGetPtr($ttimezo
ne, "DayName"))
$ainfo[6] = __date_time_clonesystemtime(DllStructGetPtr($ttimezo
ne, "DayDate"))

EndFunc

$ainfo[7] = DllStructGetData($ttimezone, "DayBias")


Return $ainfo

Func _date_time_localfiletimetofiletime($tlocaltime)
Local $tfiletime = DllStructCreate($tagfiletime)
Local $aresult = DllCall("kernel32.dll", "bool", "LocalFileTimeT
oFileTime", "struct*", $tlocaltime, "struct*", $tfiletime)
If @error Then Return SetError(@error, @extended, 0)
Return SetExtended($aresult[0], $tfiletime)
EndFunc
ite)

Func _date_time_setfiletime($hfile, $tcreatetime, $tlastaccess, $tlastwr

Local $aresult = DllCall("kernel32.dll", "bool", "SetFileTime",


"handle", $hfile, "struct*", $tcreatetime, "struct*", $tlastaccess, "struct*", $
tlastwrite)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _date_time_setlocaltime($tsystemtime)
Local $aresult = DllCall("kernel32.dll", "bool", "SetLocalTime",
"struct*", $tsystemtime)
If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @
extended, False)
$aresult = DllCall("kernel32.dll", "bool", "SetLocalTime", "stru
ct*", $tsystemtime)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _date_time_setsystemtime($tsystemtime)
Local $aresult = DllCall("kernel32.dll", "bool", "SetSystemTime"
, "struct*", $tsystemtime)
If @error Then Return SetError(@error, @extended, False)
Return $aresult[0]
EndFunc
Func _date_time_setsystemtimeadjustment($iadjustment, $bdisabled)
Local $htoken = _security__openthreadtokenex(BitOR($token_adjust
_privileges, $token_query))
If @error Then Return SetError(@error + 10, @extended, False)
_security__setprivilege($htoken, "SeSystemtimePrivilege", True)
Local $ierror = @error
Local $ilasterror = @extended
Local $bret = False
If NOT @error Then
Local $aresult = DllCall("kernel32.dll", "bool", "SetSys
temTimeAdjustment", "dword", $iadjustment, "bool", $bdisabled)
If @error Then
$ierror = @error
$ilasterror = @extended
ElseIf $aresult[0] Then
$bret = True
Else
$ierror = 20
$ilasterror = _winapi_getlasterror()
EndIf
_security__setprivilege($htoken, "SeSystemtimePrivilege"

, False)

EndFunc

If NOT $ierror AND @error Then $ierror = 22


EndIf
_winapi_closehandle($htoken)
Return SetError($ierror, $ilasterror, $bret)

Func _date_time_settimezoneinformation($ibias, $sstdname, $tstddate, $is


tdbias, $sdayname, $tdaydate, $idaybias)
Local $tstdname = _winapi_multibytetowidechar($sstdname)
Local $tdayname = _winapi_multibytetowidechar($sdayname)
Local $tzoneinfo = DllStructCreate($tagtime_zone_information)
DllStructSetData($tzoneinfo, "Bias", $ibias)
DllStructSetData($tzoneinfo, "StdName", DllStructGetData($tstdna
me, 1))
_memmovememory($tstddate, DllStructGetPtr($tzoneinfo, "StdDate")
, DllStructGetSize($tstddate))
DllStructSetData($tzoneinfo, "StdBias", $istdbias)
DllStructSetData($tzoneinfo, "DayName", DllStructGetData($tdayna
me, 1))
_memmovememory($tdaydate, DllStructGetPtr($tzoneinfo, "DayDate")
, DllStructGetSize($tdaydate))
DllStructSetData($tzoneinfo, "DayBias", $idaybias)
Local $htoken = _security__openthreadtokenex(BitOR($token_adjust
_privileges, $token_query))
If @error Then Return SetError(@error + 10, @extended, False)
_security__setprivilege($htoken, "SeSystemtimePrivilege", True)
Local $ierror = @error
Local $ilasterror = @extended
Local $bret = False
If NOT @error Then
Local $aresult = DllCall("kernel32.dll", "bool", "SetTim
eZoneInformation", "struct*", $tzoneinfo)
If @error Then
$ierror = @error
$ilasterror = @extended
ElseIf $aresult[0] Then
$ilasterror = 0
$bret = True
Else
$ierror = 20
$ilasterror = _winapi_getlasterror()
EndIf
_security__setprivilege($htoken, "SeSystemtimePrivilege"
, False)
If NOT $ierror AND @error Then $ierror = 22
EndIf
_winapi_closehandle($htoken)
Return SetError($ierror, $ilasterror, $bret)
EndFunc
Func _date_time_systemtimetoarray(ByRef $tsystemtime)
Local $ainfo[8]
$ainfo[0] = DllStructGetData($tsystemtime, "Month")
$ainfo[1] = DllStructGetData($tsystemtime, "Day")
$ainfo[2] = DllStructGetData($tsystemtime, "Year")
$ainfo[3] = DllStructGetData($tsystemtime, "Hour")
$ainfo[4] = DllStructGetData($tsystemtime, "Minute")
$ainfo[5] = DllStructGetData($tsystemtime, "Second")
$ainfo[6] = DllStructGetData($tsystemtime, "MSeconds")

EndFunc

$ainfo[7] = DllStructGetData($tsystemtime, "DOW")


Return $ainfo

Func _date_time_systemtimetodatestr(ByRef $tsystemtime, $ifmt = 0)


Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
If @error Then Return SetError(@error, @extended, "")
If $ifmt Then
Return StringFormat("%04d/%02d/%02d", $ainfo[2], $ainfo[
0], $ainfo[1])
Else
Return StringFormat("%02d/%02d/%04d", $ainfo[0], $ainfo[
1], $ainfo[2])
EndIf
EndFunc
Func _date_time_systemtimetodatetimestr(ByRef $tsystemtime, $ifmt = 0)
Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
If @error Then Return SetError(@error, @extended, "")
If $ifmt Then
Return StringFormat("%04d/%02d/%02d %02d:%02d:%02d", $ai
nfo[2], $ainfo[0], $ainfo[1], $ainfo[3], $ainfo[4], $ainfo[5])
Else
Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $ai
nfo[0], $ainfo[1], $ainfo[2], $ainfo[3], $ainfo[4], $ainfo[5])
EndIf
EndFunc
Func _date_time_systemtimetofiletime($tsystemtime)
Local $tfiletime = DllStructCreate($tagfiletime)
Local $aresult = DllCall("kernel32.dll", "bool", "SystemTimeToFi
leTime", "struct*", $tsystemtime, "struct*", $tfiletime)
If @error Then Return SetError(@error, @extended, 0)
Return SetExtended($aresult[0], $tfiletime)
EndFunc

fo[5])

Func _date_time_systemtimetotimestr(ByRef $tsystemtime)


Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
Return StringFormat("%02d:%02d:%02d", $ainfo[3], $ainfo[4], $ain
EndFunc

Func _date_time_systemtimetotzspecificlocaltime($tutc, $ttimezone = 0)


Local $tlocaltime = DllStructCreate($tagsystemtime)
Local $aresult = DllCall("kernel32.dll", "bool", "SystemTimeToTz
SpecificLocalTime", "struct*", $ttimezone, "struct*", $tutc, "struct*", $tlocalt
ime)
If @error Then Return SetError(@error, @extended, 0)
Return SetExtended($aresult[0], $tlocaltime)
EndFunc
= 0)

Func _date_time_tzspecificlocaltimetosystemtime($tlocaltime, $ttimezone

Local $tutc = DllStructCreate($tagsystemtime)


Local $aresult = DllCall("kernel32.dll", "bool", "TzSpecificLoca
lTimeToSystemTime", "struct*", $ttimezone, "struct*", $tlocaltime, "struct*", $t
utc)
If @error Then Return SetError(@error, @extended, 0)
Return SetExtended($aresult[0], $tutc)
EndFunc

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$inet_localcache = 0
$inet_forcereload = 1
$inet_ignoressl = 2
$inet_asciitransfer = 4
$inet_binarytransfer = 8
$inet_forcebypass = 16
$inet_downloadwait = 0
$inet_downloadbackground = 1
$inet_downloadread = 0
$inet_downloadsize = 1
$inet_downloadcomplete = 2
$inet_downloadsuccess = 3
$inet_downloaderror = 4
$inet_downloadextended = 5

Func _getip()
Local Const $getip_timer = 300000
Local Static $htimer = 0
Local Static $slastip = 0
If TimerDiff($htimer) < $getip_timer AND NOT $slastip Then
Return SetExtended(1, $slastip)
EndIf
Local $agetipurl[] = ["http://checkip.dyndns.org", "http://www.m
yexternalip.com/raw", "http://bot.whatismyipaddress.com"], $areturn = 0, $sretur
n = ""
For $i = 0 To UBound($agetipurl) - 1
$sreturn = InetRead($agetipurl[$i])
If @error OR $sreturn == "" Then ContinueLoop
$areturn = StringRegExp(BinaryToString($sreturn), "((?:\
d{1,3}\.){3}\d{1,3})", $str_regexparrayglobalmatch)
If NOT @error Then
$sreturn = $areturn[0]
ExitLoop
EndIf
$sreturn = ""
Next
$htimer = TimerInit()
$slastip = $sreturn
If $sreturn == "" Then Return SetError(1, 0, -1)
Return $sreturn
EndFunc
Func _inetexplorercapable($siestring)
If StringLen($siestring) <= 0 Then Return SetError(1, 0, "")
Local $s_iereturn
Local $n_iechar
For $i_iecount = 1 To StringLen($siestring)
$n_iechar = "0x" & Hex(Asc(StringMid($siestring, $i_ieco
unt, 1)), 2)
If $n_iechar < 33 OR $n_iechar = 37 OR $n_iechar = 47 OR
$n_iechar > 127 Then
$s_iereturn = $s_iereturn & "%" & StringRight($n
_iechar, 2)
Else
$s_iereturn = $s_iereturn & Chr($n_iechar)
EndIf
Next
Return $s_iereturn
EndFunc

Func _inetgetsource($surl, $bstring = True)


Local $sstring = InetRead($surl, $inet_forcereload)
Local $ierror = @error, $iextended = @extended
If $bstring = Default OR $bstring Then $sstring = BinaryToString
($sstring)
Return SetError($ierror, $iextended, $sstring)
EndFunc
Func _inetmail($smailto, $smailsubject, $smailbody)
Local $iprev = Opt("ExpandEnvStrings", 1)
Local $svar, $sdflt = RegRead("HKCU\Software\Clients\Mail", "")
If $sdflt = "Windows Live Mail" Then
$svar = RegRead("HKCR\WLMail.Url.Mailto\Shell\open\comma
nd", "")
Else
$svar = RegRead("HKCR\mailto\shell\open\command", "")
EndIf
Local $iret = Run(StringReplace($svar, "%1", _inetexplorercapabl
e("mailto:" & $smailto & "?subject=" & $smailsubject & "&body=" & $smailbody)))
Local $ierror = @error, $iextended = @extended
Opt("ExpandEnvStrings", $iprev)
Return SetError($ierror, $iextended, $iret)
EndFunc
Func _inetsmtpmail($ssmtpserver, $sfromname, $sfromaddress, $stoaddress,
$ssubject = "", $abody = "", $sehlo = "", $sfirst = "", $btrace = 0)
If $ssmtpserver = "" OR $sfromaddress = "" OR $stoaddress = "" O
R $sfromname = "" OR StringLen($sfromname) > 256 Then Return SetError(1, 0, 0)
If $sehlo = "" Then $sehlo = @ComputerName
If TCPStartup() = 0 Then Return SetError(2, 0, 0)
Local $s_ipaddress, $i_count
If StringRegExp($ssmtpserver, "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[
0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$") Then
$s_ipaddress = $ssmtpserver
Else
$s_ipaddress = TCPNameToIP($ssmtpserver)
EndIf
If $s_ipaddress = "" Then
TCPShutdown()
Return SetError(3, 0, 0)
EndIf
Local $vsocket = TCPConnect($s_ipaddress, 25)
If $vsocket = -1 Then
TCPShutdown()
Return SetError(4, 0, 0)
EndIf
Local $asend[6], $areplycode[6]
$asend[0] = "HELO " & $sehlo & @CRLF
If StringLeft($sehlo, 5) = "EHLO " Then $asend[0] = $sehlo & @CR
LF
$areplycode[0] = "250"
$asend[1] = "MAIL FROM: <" & $sfromaddress & ">" & @CRLF
$areplycode[1] = "250"
$asend[2] = "RCPT TO: <" & $stoaddress & ">" & @CRLF
$areplycode[2] = "250"
$asend[3] = "DATA" & @CRLF
$areplycode[3] = "354"
Local $aresult = _date_time_gettimezoneinformation()
Local $ibias = -$aresult[1] / 60

Local $ibiash = Int($ibias)


Local $ibiasm = 0
If $ibiash <> $ibias Then $ibiasm = Abs($ibias - $ibiash) * 60
$ibias = StringFormat(" (%+.2d%.2d)", $ibiash, $ibiasm)
$asend[4] = "From:" & $sfromname & "<" & $sfromaddress & ">" & @
CRLF & "To:" & "<" & $stoaddress & ">" & @CRLF & "Subject:" & $ssubject & @CRLF
& "Mime-Version: 1.0" & @CRLF & "Date: " & _datedayofweek(@WDAY, 1) & ", " & @MD
AY & " " & _datetomonth(@MON, 1) & " " & @YEAR & " " & @HOUR & ":" & @MIN & ":"
& @SEC & $ibias & @CRLF & "Content-Type: text/plain; charset=US-ASCII" & @CRLF &
@CRLF
$areplycode[4] = ""
$asend[5] = @CRLF & "." & @CRLF
$areplycode[5] = "250"
If __smtpsend($vsocket, $asend[0], $areplycode[0], $btrace, "220
", $sfirst) Then Return SetError(50, 0, 0)
For $i_count = 1 To UBound($asend) - 2
If __smtpsend($vsocket, $asend[$i_count], $areplycode[$i
_count], $btrace) Then Return SetError(50 + $i_count, 0, 0)
Next
For $i_count = 0 To UBound($abody) - 1
If StringLeft($abody[$i_count], 1) = "." Then $abody[$i_
count] = "." & $abody[$i_count]
If __smtpsend($vsocket, $abody[$i_count] & @CRLF, "", $b
trace) Then Return SetError(500 + $i_count, 0, 0)
Next
$i_count = UBound($asend) - 1
If __smtpsend($vsocket, $asend[$i_count], $areplycode[$i_count],
$btrace) Then Return SetError(5000, 0, 0)
TCPCloseSocket($vsocket)
TCPShutdown()
Return 1
EndFunc

LF

Func __smtptrace($sstr, $itimeout = 0)


Local $sw_title = "SMTP trace"
Local $ssmtptrace = ControlGetText($sw_title, "", "Static1")
$sstr = StringLeft(StringReplace($sstr, @CRLF, ""), 70)
$ssmtptrace &= @HOUR & ":" & @MIN & ":" & @SEC & " " & $sstr & @

4 + 16, "", 8)
EndFunc

If WinExists($sw_title) Then
ControlSetText($sw_title, "", "Static1", $ssmtptrace)
Else
SplashTextOn($sw_title, $ssmtptrace, 400, 500, 500, 100,
EndIf
If $itimeout Then Sleep($itimeout * 1000)

Func __smtpsend($vsocket, $ssend, $sreplycode, $btrace, $sintreply = "",


$sfirst = "")
Local $sreceive, $i, $htimer
If $btrace Then __smtptrace($ssend)
If $sintreply <> "" Then
If $sfirst <> -1 Then
If TCPSend($vsocket, $sfirst) = 0 Then
TCPCloseSocket($vsocket)
TCPShutdown()
Return 1
EndIf
EndIf

$sreceive = ""
$htimer = TimerInit()
While StringLeft($sreceive, StringLen($sintreply)) <> $s
intreply AND TimerDiff($htimer) < 45000
$sreceive = TCPRecv($vsocket, 1000)
If $btrace AND $sreceive <> "" Then __smtptrace(
"intermediate->" & $sreceive)
WEnd
EndIf
If TCPSend($vsocket, $ssend) = 0 Then
TCPCloseSocket($vsocket)
TCPShutdown()
Return 1
EndIf
$htimer = TimerInit()
$sreceive = ""
While $sreceive = "" AND TimerDiff($htimer) < 45000
$i += 1
$sreceive = TCPRecv($vsocket, 1000)
If $sreplycode = "" Then ExitLoop
WEnd
If $sreplycode <> "" Then
If $btrace Then __smtptrace($i & " <- " & $sreceive)
If StringLeft($sreceive, StringLen($sreplycode)) <> $sre
plycode Then
TCPCloseSocket($vsocket)
TCPShutdown()
If $btrace Then __smtptrace("<-> " & $sreplycode
, 5)
Return 2
EndIf
EndIf
Return 0
EndFunc

sip)

Func _tcpiptoname($sip, $ioption = Default, $hdll = Default)


Local $iinaddr_none = -1, $iaf_inet = 2, $sseparator = @CR
If $ioption = Default Then $ioption = 0
If $hdll = Default Then $hdll = "ws2_32.dll"
Local $avdllcall = DllCall($hdll, "ulong", "inet_addr", "STR", $

If @error Then Return SetError(1, 0, "")


Local $vbinip = $avdllcall[0]
If $vbinip = $iinaddr_none Then Return SetError(2, 0, "")
$avdllcall = DllCall($hdll, "ptr", "gethostbyaddr", "ptr*", $vbi
nip, "int", 4, "int", $iaf_inet)
If @error Then Return SetError(3, 0, "")
Local $pvhostent = $avdllcall[0]
If $pvhostent = 0 Then
$avdllcall = DllCall($hdll, "int", "WSAGetLastError")
If @error Then Return SetError(5, 0, "")
Return SetError(4, $avdllcall[0], "")
EndIf
Local $thostent = DllStructCreate("ptr;ptr;short;short;ptr", $pv
hostent)
Local $shostnames = __tcpiptoname_szstringread(DllStructGetData(
$thostent, 1))
If @error Then Return SetError(6, 0, $shostnames)
If $ioption = 1 Then
Local $taliases

$shostnames &= $sseparator


For $i = 0 To 63
$taliases = DllStructCreate("ptr", DllStructGetD
ata($thostent, 2) + ($i * 4))
If DllStructGetData($taliases, 1) = 0 Then ExitL
oop
$shostnames &= __tcpiptoname_szstringread(DllStr
uctGetData($taliases, 1))
If @error Then
SetError(7)
ExitLoop
EndIf
Next
Return StringSplit(StringStripWS($shostnames, $str_strip
trailing), @CR)
Else
Return $shostnames
EndIf
EndFunc
Func __tcpiptoname_szstringread($pstr, $ilen = -1)
Local $tstring
If $pstr < 1 Then Return ""
If $ilen < 0 Then $ilen = _winapi_stringlena($pstr)
$tstring = DllStructCreate("char[" & $ilen & "]", $pstr)
If @error Then Return SetError(2, 0, "")
Return SetExtended($ilen, DllStructGetData($tstring, 1))
EndFunc
#Region _Memory
ithandle = 1)

Func _memoryopen($iv_pid, $iv_desiredaccess = 2035711, $iv_inher

If NOT ProcessExists($iv_pid) Then


SetError(1)
Return 0
EndIf
Local $ah_handle[2] = [DllOpen("kernel32.dll")]
If @error Then
SetError(2)
Return 0
EndIf
Local $av_openprocess = DllCall($ah_handle[0], "int", "O
penProcess", "int", $iv_desiredaccess, "int", $iv_inherithandle, "int", $iv_pid)
If @error Then
DllClose($ah_handle[0])
SetError(3)
Return 0
EndIf
$ah_handle[1] = $av_openprocess[0]
Return $ah_handle
EndFunc
Func _memoryread($iv_address, $ah_handle, $sv_type = "dword")
If NOT IsArray($ah_handle) Then
SetError(1)
Return 0
EndIf
Local $v_buffer = DllStructCreate($sv_type)
If @error Then

SetError(@error + 1)
Return 0

EndIf
DllCall($ah_handle[0], "int", "ReadProcessMemory", "int"
, $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", D
llStructGetSize($v_buffer), "int", "")
If NOT @error Then
Local $v_value = DllStructGetData($v_buffer, 1)
Return $v_value
Else
SetError(6)
Return 0
EndIf
EndFunc
dword")

Func _memorywrite($iv_address, $ah_handle, $v_data, $sv_type = "

If NOT IsArray($ah_handle) Then


SetError(1)
Return 0
EndIf
Local $v_buffer = DllStructCreate($sv_type)
If @error Then
SetError(@error + 1)
Return 0
Else
DllStructSetData($v_buffer, 1, $v_data)
If @error Then
SetError(6)
Return 0
EndIf
EndIf
DllCall($ah_handle[0], "int", "WriteProcessMemory", "int
", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int",
DllStructGetSize($v_buffer), "int", "")
If NOT @error Then
Return 1
Else
SetError(7)
Return 0
EndIf
EndFunc

handle[1])

Func _memoryclose($ah_handle)
If NOT IsArray($ah_handle) Then
SetError(1)
Return 0
EndIf
DllCall($ah_handle[0], "int", "CloseHandle", "int", $ah_

EndFunc

If NOT @error Then


DllClose($ah_handle[0])
Return 1
Else
DllClose($ah_handle[0])
SetError(2)
Return 0
EndIf

Func setprivilege($privilege, $benable)


Const $token_adjust_privileges = 32
Const $token_query = 8
Const $se_privilege_enabled = 2
Local $htoken, $sp_auxret, $sp_ret, $hcurrprocess, $ntok
ens, $ntokenindex, $priv
$ntokens = 1
$luid = DllStructCreate("dword;int")
If IsArray($privilege) Then $ntokens = UBound($privilege
)
$token_privileges = DllStructCreate("dword;dword[" & (3
* $ntokens) & "]")
$newtoken_privileges = DllStructCreate("dword;dword[" &
(3 * $ntokens) & "]")
$hcurrprocess = DllCall("kernel32.dll", "hwnd", "GetCurr
entProcess")
$sp_auxret = DllCall("advapi32.dll", "int", "OpenProcess
Token", "hwnd", $hcurrprocess[0], "int", BitOR($token_adjust_privileges, $token_
query), "int_ptr", 0)
If $sp_auxret[0] Then
$htoken = $sp_auxret[3]
DllStructSetData($token_privileges, 1, 1)
$ntokenindex = 1
While $ntokenindex <= $ntokens
If IsArray($privilege) Then
$priv = $privilege[$ntokenindex
- 1]
Else
$priv = $privilege
EndIf
$ret = DllCall("advapi32.dll", "int", "L
ookupPrivilegeValue", "str", "", "str", $priv, "ptr", DllStructGetPtr($luid))
If $ret[0] Then
If $benable Then
DllStructSetData($token_
privileges, 2, $se_privilege_enabled, (3 * $ntokenindex))
Else
DllStructSetData($token_
privileges, 2, 0, (3 * $ntokenindex))
EndIf
DllStructSetData($token_privileg
es, 2, DllStructGetData($luid, 1), (3 * ($ntokenindex - 1)) + 1)
DllStructSetData($token_privileg
es, 2, DllStructGetData($luid, 2), (3 * ($ntokenindex - 1)) + 2)
DllStructSetData($luid, 1, 0)
DllStructSetData($luid, 2, 0)
EndIf
$ntokenindex += 1
WEnd
$ret = DllCall("advapi32.dll", "int", "AdjustTok
enPrivileges", "hwnd", $htoken, "int", 0, "ptr", DllStructGetPtr($token_privileg
es), "int", DllStructGetSize($newtoken_privileges), "ptr", DllStructGetPtr($newt
oken_privileges), "int_ptr", 0)
$f = DllCall("kernel32.dll", "int", "GetLastErro
r")
EndIf
$newtoken_privileges = 0
$token_privileges = 0
$luid = 0
If $sp_auxret[0] = 0 Then Return 0

", "hwnd", $htoken)


EndFunc

$sp_auxret = DllCall("kernel32.dll", "int", "CloseHandle


If NOT $ret[0] AND NOT $sp_auxret[0] Then Return 0
Return $ret[0]

#EndRegion
Global $__binarycall_kernel32dll = DllOpen("kernel32.dll")
Global $__binarycall_msvcrtdll = DllOpen("msvcrt.dll")
Global $__binarycall_lasterror = ""
Func _binarycall_getprocaddress($module, $proc)
Local $ret = DllCall($__binarycall_kernel32dll, "ptr", "GetProcA
ddress", "ptr", $module, "str", $proc)
If @error OR NOT $ret[0] Then Return SetError(1, @error, 0)
Return $ret[0]
EndFunc
Func _binarycall_loadlibrary($filename)
Local $ret = DllCall($__binarycall_kernel32dll, "handle", "LoadL
ibraryW", "wstr", $filename)
If @error Then Return SetError(1, @error, 0)
Return $ret[0]
EndFunc
Func _binarycall_lstrlena($ptr)
Local $ret = DllCall($__binarycall_kernel32dll, "int", "lstrlenA
", "ptr", $ptr)
If @error Then Return SetError(1, @error, 0)
Return $ret[0]
EndFunc
Func _binarycall_alloc($code, $padding = 0)
Local $length = BinaryLen($code) + $padding
Local $ret = DllCall($__binarycall_kernel32dll, "ptr", "VirtualA
lloc", "ptr", 0, "ulong_ptr", $length, "dword", 4096, "dword", 64)
If @error OR NOT $ret[0] Then Return SetError(1, @error, 0)
If BinaryLen($code) Then
Local $buffer = DllStructCreate("byte[" & $length & "]",
$ret[0])
DllStructSetData($buffer, 1, $code)
EndIf
Return $ret[0]
EndFunc
Func _binarycall_regionsize($ptr)
Local $buffer = DllStructCreate("ptr;ptr;dword;uint_ptr;dword;dw
ord;dword")
Local $ret = DllCall($__binarycall_kernel32dll, "int", "VirtualQ
uery", "ptr", $ptr, "ptr", DllStructGetPtr($buffer), "uint_ptr", DllStructGetSiz
e($buffer))
If @error OR $ret[0] = 0 Then Return SetError(1, @error, 0)
Return DllStructGetData($buffer, 4)
EndFunc
Func _binarycall_free($ptr)
Local $ret = DllCall($__binarycall_kernel32dll, "bool", "Virtual
Free", "ptr", $ptr, "ulong_ptr", 0, "dword", 32768)
If @error OR $ret[0] = 0 Then
$ret = DllCall($__binarycall_kernel32dll, "bool", "Globa

lFree", "ptr", $ptr)


, False)
EndFunc

If @error OR $ret[0] <> 0 Then Return SetError(1, @error

EndIf
Return True

Func _binarycall_release($codebase)
Local $ret = _binarycall_free($codebase)
Return SetError(@error, @extended, $ret)
EndFunc
Func _binarycall_memorysearch($ptr, $length, $binary)
Static $codebase
If NOT $codebase Then
If @AutoItX64 Then
$codebase = _binarycall_create("0x4883EC084D85C9
4889C8742C4C39CA72254C29CA488D141131C9EB0848FFC14C39C97414448A1408453A140874EE48
FFC04839D076E231C05AC3", "", 0, True, False)
Else
$codebase = _binarycall_create("0x5589E58B4D1457
8B4508568B550C538B7D1085C9742139CA721B29CA8D341031D2EB054239CA740F8A1C17381C1074
F34039F076EA31C05B5E5F5DC3", "", 0, True, False)
EndIf
If NOT $codebase Then Return SetError(1, 0, 0)
EndIf
$binary = Binary($binary)
Local $buffer = DllStructCreate("byte[" & BinaryLen($binary) & "
]")
DllStructSetData($buffer, 1, $binary)
Local $ret = DllCallAddress("ptr:cdecl", $codebase, "ptr", $ptr,
"uint", $length, "ptr", DllStructGetPtr($buffer), "uint", DllStructGetSize($buf
fer))
Return $ret[0]
EndFunc
Func _binarycall_base64decode($src)
Static $codebase
If NOT $codebase Then
If @AutoItX64 Then
$codebase = _binarycall_create("0x41544989CAB9FF
000000555756E8BE000000534881EC000100004889E7F3A44C89D6E98A0000004439C87E0731C0E9
8D0000000FB66E01440FB626FFC00FB65E020FB62C2C460FB62424408A3C1C0FB65E034189EB41C1
E4024183E3308A1C1C41C1FB044509E34080FF634189CC45881C08744C440FB6DFC1E5044489DF40
88E883E73CC1FF0209C7418D44240241887C08014883C10380FB63742488D841C1E3064883C60483
E03F4409D841884408FF89F389C84429D339D30F8C67FFFFFF4881C4000100005B5E5F5D415CC35E
C3E8F9FFFFFF00000000000000000000000000000000000000000000000000000000000000000000
0000000000000000003E0000003F3435363738393A3B3C3D00000063000000000102030405060708
090A0B0C0D0E0F101112131415161718190000000000001A1B1C1D1E1F202122232425262728292A
2B2C2D2E2F30313233", "", 132, True, False)
Else
$codebase = _binarycall_create("0x55B9FF00000089
E531C05756E8F10000005381EC0C0100008B55088DBDF5FEFFFFF3A4E9C00000003B45140F8FC200
00000FB65C0A028A9C1DF5FEFFFF889DF3FEFFFF0FB65C0A038A9C1DF5FEFFFF889DF2FEFFFF0FB6
5C0A018985E8FEFFFF0FB69C1DF5FEFFFF899DECFEFFFF0FB63C0A89DE83E630C1FE040FB6BC3DF5
FEFFFFC1E70209FE8B7D1089F3881C074080BDF3FEFFFF63745C0FB6B5F3FEFFFF8BBDECFEFFFF8B
9DE8FEFFFF89F083E03CC1E704C1F80209F88B7D1088441F0189D883C00280BDF2FEFFFF6374278A
85F2FEFFFFC1E60683C10483E03F09F088441F0289D883C0033B4D0C0F8C37FFFFFFEB0231C081C4
0C0100005B5E5F5DC35EC3E8F9FFFFFF000000000000000000000000000000000000000000000000
000000000000000000000000000000000000003E0000003F3435363738393A3B3C3D000000630000

00000102030405060708090A0B0C0D0E0F101112131415161718190000000000001A1B1C1D1E1F20
2122232425262728292A2B2C2D2E2F30313233", "", 132, True, False)
EndIf
If NOT $codebase Then Return SetError(1, 0, Binary(""))
EndIf
$src = String($src)
Local $srclen = StringLen($src)
Local $srcbuf = DllStructCreate("char[" & $srclen & "]")
DllStructSetData($srcbuf, 1, $src)
Local $dstlen = Int(($srclen + 2) / 4) * 3 + 1
Local $dstbuf = DllStructCreate("byte[" & $dstlen & "]")
Local $ret = DllCallAddress("uint:cdecl", $codebase, "ptr", DllS
tructGetPtr($srcbuf), "uint", $srclen, "ptr", DllStructGetPtr($dstbuf), "uint",
$dstlen)
If $ret[0] = 0 Then Return SetError(2, 0, Binary(""))
Return BinaryMid(DllStructGetData($dstbuf, 1), 1, $ret[0])
EndFunc
Func _binarycall_base64encode($src)
Static $codebase
If NOT $codebase Then
If @AutoItX64 Then
$codebase = _binarycall_create("AwAAAARiAQAAAAAA
AAArkuFQDAlvIp0qAgbDnjr76UDZs1EPNIP2K18t9s6SNTbd43IB7HfdyPM8VfD/o36z4AmSW2m2AIsC
6Af3fKNsHU4BdQKGd0PQXHxPSX0iNqp1YAKovksqQna06NeKMoOYqryTUX4WgpHjokhp6zY2sEFSIjcL
7dW3FDoNVz4bGPyZHRvjFwmqvr7YGlNYKwNoh+SYCXmIgVPVZ63Vz1fbT33/QFpWmWOeBRqs4J+c8Qp6
zJFsK345Pjw0I8kMSsnho4F4oNzQ2OsAbmIioaQ6Ma2ziw5NH+M+t4SpEeHDnBdUTTL20sxWZ0yKruFA
sBIRoHvM7LYcid2eBV2d5roSjnkwMG0g69LNjs1fHjbI/9iU/hJwpSsgl4fltXdZG659/li13UFY89M7
UfckiZ9XOeBM0zadgNsy8r8M3rEAAA==")
Else
$codebase = _binarycall_create("AwAAAARVAQAAAAAA
AAAqr7blBndrIGnmhhfXD7R1fkOTKhicg1W6MCtStbz+CsneBEg0bbHH1sqTLmLfY7A6LqZl6LYWT5UL
Vj6MXgugPbBn9wKsSU2ZCcBBPNkx09HVPdUaKnbqghDGj/C5SHoF+A/5g+UgE1C5zJZORjJ8ljs5lt2Y
9lA4BsY7jVKX2vmDvHK1NnSR6nVwh7Pb+Po/UpNcy5sObVWDKkYSCCtCIjKIYqOe3c6k8Xsp4eritCUp
rXEVvCFi7K5Z6HFXdm3nZsFcE+eSJ1WkRnVQbWcmpjGMGka61C68+CI7tsQ13UnCFWNSpDrCbzUejMZh
8HdPgEc5vCg3pKMKin/NavNpB6+87Y9y7HIxmKsPdjDT30u9hUKWnYiRe3nrwKyVDsiYpKU/Nse368jH
ag5B5or3UKA+nb2+eY8JwzgA")
EndIf
If NOT $codebase Then Return SetError(1, 0, Binary(""))
EndIf
$src = Binary($src)
Local $srclen = BinaryLen($src)
Local $srcbuf = DllStructCreate("byte[" & $srclen & "]")
DllStructSetData($srcbuf, 1, $src)
Local $dstlen = Int(($srclen + 2) / 3) * 4 + 1
Local $dstbuf = DllStructCreate("char[" & $dstlen & "]")
Local $ret = DllCallAddress("uint:cdecl", $codebase, "ptr", DllS
tructGetPtr($srcbuf), "uint", $srclen, "ptr", DllStructGetPtr($dstbuf), "uint",
$dstlen)
If $ret[0] = 0 Then Return Binary("")
Return StringMid(DllStructGetData($dstbuf, 1), 1, $ret[0])
EndFunc
Func _binarycall_lzmadecompress($src)
Static $codebase
If NOT $codebase Then
If @AutoItX64 Then
$codebase = _binarycall_create(_binarycall_base6
4decode("QVcxwEFWQVVBVFVXSInXVkiJzlMx20iB7OgAAABEiiFBgPzgdgnpyQAAAEGD7C1BiMf/wEG
A/Cx38THA6wRBg+wJQYjG/8BBgPwId/GLRglEi24FQQ+2zkyJRCQoRQ+2/0HB5xBBiQFBD7bEAcG4AAM

AANPgjYQAcA4AAEhjyOjIBAAATInpSInF6L0EAABIicMxwEyJ8kSI4EyLRCQoiNQl//8A/0QJ+EiF24l
FAHQoTYXtdCNIjVfzSI1MJDhIg8YNTIkEJE2J6UmJ2EiJ7+g2AAAAicbrBb4BAAAASInp6IQEAACF9nQ
KSInZMdvodgQAAEiJ2EiBxOgAAABbXl9dQVxBXUFeQV/DVVNBV0FWQVVBVEFQTQHBQVFNicVRVkgB8lJ
IieX8SYn0iwdMjX8Eik8Cg8r/0+L30olV6Ijhg8r/0+L30olV5ADBiUXsuAEAAACJReCJRdyJRdhIiUX
QRSnJKfaDy/8A0bgAAwAA0+BIjYg2BwAAuAAEAARMif/R6fOrvwUAAADoUAMAAP/PdfdEie9EicgrfSD
B4ARBifpEI1XoRAHQTY0cR+hAAwAAD4WTAAAAik3sI33k0+eA6Qj22dPuAfe4AQAAAEiNPH++AAEAAMH
nCEGD+QdNjbR/bA4AAHI0TInvSCt90A+2P9HnQYnzIf5BAfNPjRxe6O8CAACJwcHuCIPhATnOvgABAAB
1DjnGd9jrDE2J8+jQAgAAOfBy9EyJ76pEiclBg/kEcg65AwAAAEGD+QpyA4PBA0EpyelDAgAAT42cT4A
BAADomgIAAHUsi0XcQYP5B4lF4BnAi1XY99CLTdCD4AOJVdxBicGJTdhNjbdkBgAA6akAAABPjZxPmAE
AAOhfAgAAdUZEicjB4AREAdBNjZxH4AEAAOhHAgAAdWpBg/kHuQkAAAByA4PBAkGJyUyJ70grfdBIO30
gD4L9AQAAigdIA33QqumzAQAAT42cT7ABAADoCgIAAIt12HQhT42cT8gBAADo+AEAAIt13HQJi03ci3X
giU3gi03YiU3ci03QiU3YiXXQQYP5B7kIAAAAcgODwQNBiclNjbdoCgAATYnz6LsBAAB1FESJ0CnJweA
DvggAAABJjXxGBOs2TY1eAuicAQAAdRpEidC5CAAAAMHgA74IAAAASY28RgQBAADrEUmNvgQCAAC5EAA
AAL4AAQAAiU3MuAEAAABJifvoYQEAAInCKfJy8gNVzEGD+QSJVcwPg7kAAABBg8EHuQMAAAA50XICidH
B4Qa4AQAAAEmNvE9gAwAAvkAAAABJifvoHwEAAEGJwkEp8nLwQYP6BHJ4RInWRIlV0NHug2XQAf/Og03
QAkGD+g5zFYnx0mXQi0XQRCnQTY20R14FAADrLIPuBOi6AAAA0evRZdBBOdhyBv9F0EEp2P/OdedNjbd
EBgAAwWXQBL4EAAAAvwEAAACJ+E2J8+ioAAAAqAF0Awl90NHn/8516+sERIlV0P9F0EyJ74tNzEiJ+IP
BAkgrRSBIOUXQd1RIif5IK3XQSItVGKyqSDnXcwT/yXX1SYn9D7bwTDttGA+C9fz//+gwAAAAKcBIi1U
QTCtlCESJIkiLVWBMK20gRIkqSIPEKEFcQV1BXUFfW13DXli4AQAAAOvSgfsAAAABcgHDweMITDtlAHP
mQcHgCEWKBCRJg8QBwynATY0cQ4H7AAAAAXMVweMITDtlAHPBQcHgCEWKBCRJg8QBidlBD7cTwekLD6/
KQTnIcxOJy7kACAAAKdHB6QVmQQELAcDDKcvB6gVBKchmQSkTAcCDwAHDSLj////////////gbXN2Y3J
0LmRsbHxtYWxsb2MASLj////////////gZnJlZQA="))
Else
$codebase = _binarycall_create(_binarycall_base6
4decode("VYnlVzH/VlOD7EyLXQiKC4D54A+HxQAAADHA6wWD6S2I0ID5LI1QAXfziEXmMcDrBYPpCYj
QgPkIjVABd/OIReWLRRSITeSLUwkPtsmLcwWJEA+2ReUBwbgAAwAA0+CNhABwDgAAiQQk6EcEAACJNCS
JRdToPAQAAItV1InHi0Xkhf+JArgBAAAAdDaF9nQyi0UQg8MNiRQkiXQkFIl8JBCJRCQYjUXgiUQkDIt
FDIlcJASD6A2JRCQI6CkAAACLVdSJRdSJFCToAQQAAItF1IXAdAqJPCQx/+jwAwAAg8RMifhbXl9dw1d
WU1WJ5YtFJAFFKFD8i3UYAXUcVot1FK2SUopO/oPI/9Pg99BQiPGDyP/T4PfQUADRifeD7AwpwEBQUFB
QUFcp9laDy/+4AAMAANPgjYg2BwAAuAAEAATR6fOragVZ6MoCAADi+Yt9/ItF8Ct9JCH4iUXosADoywI
AAA+FhQAAAIpN9CN97NPngOkI9tnT7lgB916NPH/B5wg8B1qNjH5sDgAAUVa+AAEAAFCwAXI0i338K33
cD7Y/i23M0eeJ8SH+AfGNbE0A6JgCAACJwcHuCIPhATnOvgABAAB1DjnwctfrDIttzOh5AgAAOfBy9Fq
D+gSJ0XIJg/oKsQNyArEGKcpS60mwwOhJAgAAdRRYX1pZWln/NCRRUrpkBgAAsQDrb7DM6CwCAAB1LLD
w6BMCAAB1U1g8B7AJcgKwC1CLdfwrddw7dSQPgs8BAACsi338qumOAQAAsNjo9wEAAIt12HQbsOTo6wE
AAIt11HQJi3XQi03UiU3Qi03YiU3Ui03ciU3YiXXcWF9ZumgKAACxCAH6Ulc8B4jIcgIEA1CLbczovAE
AAHUUi0Xoi33MweADKclqCF6NfEcE6zWLbcyDxQLomwEAAHUYi0Xoi33MweADaghZaghejbxHBAEAAOs
QvwQCAAADfcxqEFm+AAEAAIlN5CnAQIn96GYBAACJwSnxcvMBTeSDfcQED4OwAAAAg0XEB4tN5IP5BHI
DagNZi33IweEGKcBAakBejbxPYAMAAIn96CoBAACJwSnxcvOJTeiJTdyD+QRyc4nOg2XcAdHug03cAk6
D+Q5zGbivAgAAKciJ8dJl3ANF3NHgA0XIiUXM6y2D7gToowAAANHr0WXcOV3gcgb/RdwpXeBOdei4RAY
AAANFyIlFzMFl3ARqBF4p/0eJ+IttzOi0AAAAqAF0Awl93NHnTnXs6wD/RdyLTeSDwQKLffyJ+CtFJDl
F3HdIif4rddyLVSisqjnXcwNJdfeJffwPtvA7fSgPgnH9///oKAAAACnAjWwkPItVIIt1+Ct1GIkyi1U
si338K30kiTrJW15fw15YKcBA69qB+wAAAAFyAcPB4whWi3X4O3Ucc+SLReDB4AisiUXgiXX4XsOLTcQ
PtsDB4QQDRegByOsGD7bAA0XEi23IjWxFACnAjWxFAIH7AAAAAXMci0wkOMFkJCAIO0wkXHOcihH/RCQ
4weMIiFQkIInZD7dVAMHpCw+vyjlMJCBzF4nLuQAIAAAp0cHpBWYBTQABwI1sJEDDweoFKUwkICnLZil
VAAHAg8ABjWwkQMO4///////gbXN2Y3J0LmRsbHxtYWxsb2MAuP//////4GZyZWUA"))
EndIf
If NOT $codebase Then Return SetError(1, 0, Binary(""))
EndIf
$src = Binary($src)
Local $srclen = BinaryLen($src)
Local $srcbuf = DllStructCreate("byte[" & $srclen & "]")
DllStructSetData($srcbuf, 1, $src)
Local $ret = DllCallAddress("ptr:cdecl", $codebase, "ptr", DllSt
ructGetPtr($srcbuf), "uint_ptr", $srclen, "uint_ptr*", 0, "uint*", 0)
If $ret[0] Then
Local $dstbuf = DllStructCreate("byte[" & $ret[3] & "]",
$ret[0])
Local $output = DllStructGetData($dstbuf, 1)
DllCall($__binarycall_msvcrtdll, "none:cdecl", "free", "
ptr", $ret[0])

EndFunc

Return $output
EndIf
Return SetError(2, 0, Binary(""))

Func _binarycall_relocation($base, $reloc)


Local $size = Int(BinaryMid($reloc, 1, 2))
For $i = 3 To BinaryLen($reloc) Step $size
Local $offset = Int(BinaryMid($reloc, $i, $size))
Local $ptr = $base + $offset
DllStructSetData(DllStructCreate("ptr", $ptr), 1, DllStr
uctGetData(DllStructCreate("ptr", $ptr), 1) + $base)
Next
EndFunc

mpbin)

Func _binarycall_importlibrary($base, $length)


Local $jmpbin, $jmpoff, $jmplen, $dllname, $procname
If @AutoItX64 Then
$jmpbin = Binary("0x48B8FFFFFFFFFFFFFFFFFFE0")
$jmpoff = 2
Else
$jmpbin = Binary("0xB8FFFFFFFFFFE0")
$jmpoff = 1
EndIf
$jmplen = BinaryLen($jmpbin)
Do
Local $ptr = _binarycall_memorysearch($base, $length, $j

If $ptr = 0 Then ExitLoop


Local $stringptr = $ptr + $jmplen
Local $stringlen = _binarycall_lstrlena($stringptr)
Local $string = DllStructGetData(DllStructCreate("char["
& $stringlen & "]", $stringptr), 1)
Local $split = StringSplit($string, "|")
If $split[0] = 1 Then
$procname = $split[1]
ElseIf $split[0] = 2 Then
If $split[1] Then $dllname = $split[1]
$procname = $split[2]
EndIf
If $dllname AND $procname Then
Local $handle = _binarycall_loadlibrary($dllname

If NOT $handle Then


$__binarycall_lasterror = "LoadLibrary f

ail on " & $dllname

Return SetError(1, 0, False)


EndIf
Local $proc = _binarycall_getprocaddress($handle

, $procname)
s failed on " & $procname

jmpoff), 1, $proc)
1)

If NOT $proc Then


$__binarycall_lasterror = "GetProcAddres
Return SetError(2, 0, False)
EndIf
DllStructSetData(DllStructCreate("ptr", $ptr + $

EndIf
Local $diff = Int($ptr - $base + $jmplen + $stringlen +

EndFunc

))

ify)

Func _binarycall_codeprepare($code)
If NOT $code Then Return ""
If IsBinary($code) Then Return $code
$code = String($code)
If StringLeft($code, 2) = "0x" Then Return Binary($code)
If StringIsXDigit($code) Then Return Binary("0x" & $code)
Return _binarycall_lzmadecompress(_binarycall_base64decode($code
EndFunc
Func _binarycall_symbolfind($codebase, $identify, $length = Default)
$identify = Binary($identify)
If IsKeyword($length) Then
$length = _binarycall_regionsize($codebase)
EndIf
Local $ptr = _binarycall_memorysearch($codebase, $length, $ident

EndFunc

0, 0)

$base += $diff
$length -= $diff
Until $length <= $jmplen
Return True

If $ptr = 0 Then Return SetError(1, 0, 0)


Return $ptr + BinaryLen($identify)

Func _binarycall_symbollist($codebase, $symbol)


If NOT IsArray($symbol) OR $codebase = 0 Then Return SetError(1,
Local $tag = ""
For $i = 0 To UBound($symbol) - 1
$tag &= "ptr " & $symbol[$i] & ";"
Next
Local $symbollist = DllStructCreate($tag)
If @error Then Return SetError(1, 0, 0)
For $i = 0 To UBound($symbol) - 1
$codebase = _binarycall_symbolfind($codebase, $symbol[$i

])

EndFunc

DllStructSetData($symbollist, $symbol[$i], $codebase)


Next
Return $symbollist

Func _binarycall_create($code, $reloc = "", $padding = 0, $releaseonexit


= True, $libraryimport = True)
Local $binarycode = _binarycall_codeprepare($code)
If NOT $binarycode Then Return SetError(1, 0, 0)
Local $binarycodelen = BinaryLen($binarycode)
Local $totalcodelen = $binarycodelen + $padding
Local $codebase = _binarycall_alloc($binarycode, $padding)
If NOT $codebase Then Return SetError(2, 0, 0)
If $reloc Then
$reloc = _binarycall_codeprepare($reloc)
If NOT $reloc Then Return SetError(3, 0, 0)
_binarycall_relocation($codebase, $reloc)
EndIf
If $libraryimport Then
If NOT _binarycall_importlibrary($codebase, $binarycodel
en) Then

_binarycall_free($codebase)
Return SetError(4, 0, 0)

EndFunc

EndIf
EndIf
If $releaseonexit Then
_binarycall_releaseonexit($codebase)
EndIf
Return SetError(0, $totalcodelen, $codebase)

Func _binarycall_commandlinetoargv($commandline, ByRef $argc, $isunicode


= False)
Static $symbollist
If NOT IsDllStruct($symbollist) Then
Local $code
If @AutoItX64 Then
$code = "AwAAAASuAgAAAAAAAAAkL48ClEB9jTEOeYv4yYT
osNjFNgf81Ag4vS2VP4y4wxFa+4yMI7GDB7CG+xn4JE3cdEVvk8cMp4oIuS3DgTxlcKHGVIg94tvzG/2
56bizZfGtAETQUCPQjW5+JSx2C/Y4C0VNJMKTlSCHiV5AzXRZ5gw3WFghbtkCCFxWOX+RDSI2oH/vROE
Onqc0jfKTo17EBjqX+dW3QxrUe45xsbyYTZ9ccIGySgcOAxetbRiSxQnz8BOMbJyfrbZbuVJyGpKrXFL
h/5MlBZ09Cim9qgflbGzmkrGStT9QL1f+O2krzyOzgaWWqhWL6S+y0G32RWVi0uMLR/JOGLEW/+Yg/4b
zkeC0lKELT+RmWAatNa38BRfaitROMN12moRDHM6LYD1lzPLnaiefSQRVti561sxni/AFkYoCb5Lkuyw
4RIn/r/flRiUg5w48YkqBBd9rXkaXrEoKwPg6rmOvOCZadu//B6HN4+Ipq5aYNuZMxSJXmxwXVRSQZVp
SfLS2ATZMd9/Y7kLqrKy1H4V76SgI/d9OKApfKSbQ8ZaKIHBCsoluEip3UDOB82Z21zd933UH5l0laGW
LIrTz7xVGkecjo0NQzR7LyhhoV3xszlIuw2v8q0Q/S9LxB5G6tYbOXo7lLjNIZc0derZz7DNeeeJ9dQE
9hp8unubaTBpulPxTNtRjog=="
Else
$code = "AwAAAAR6AgAAAAAAAABcQfD553vjya/3DmalU0B
KqABevUb/60GZ55rMwmzpQfPSRUlIl04lEiS8RDrXpS0EoBUe+uzDgZd37nVu9wsJ4fykqYvLoMz3Apx
QbTBKleOIRSla6I0V8dNP3P7rHeUfjH0jCho0RvhhVpf0o4ht/iZptauxaoy1zQ19TkPZ/vf5Im8ecY6
qEdHNzjo2H60jVwiOJ+1J47TmQRwxJ+yKLakq8QNxtKkRIB9B9ugfo3NAL0QslDxbyU0dSgw2aOPxV+u
ttLzYNnWbLBZVQbchcKgLRjC/32U3Op576sOYFolB1Nj4/33c7MRgtGLjlZfTB/4yNvd4/E+u3U6/Q4M
YApCfWF4R/d9CAdiwgIjCYUkGDExKjFtHbAWXfWh9kQ7Q/GWUjsfF9BtHO6924Cy1Ou+BUKksqsxmIKP
4dBjvvmz9OHc1FdtR9I63XKyYtlUnqVRtKwlNrYAZVCSFsyAefMbteq1ihU33sCsLkAnp1LRZ2wofgT1
/JtT8+GO2s/n52D18wM70RH2n5uJJv8tlxQc1lwbmo4XQvcbcE91U2j9glvt2wC1pkP0hF23Nr/iiIEZ
HIPAOAHvhervlHE830LSHyUx8yh5Tjojr0gdLvQ=="
EndIf
Local $codebase = _binarycall_create($code)
If @error Then Return SetError(1, 0, 0)
Local $symbol[] = ["ToArgvW", "ToArgvA"]
$symbollist = _binarycall_symbollist($codebase, $symbol)
If @error Then Return SetError(1, 0, 0)
EndIf
Local $ret
If $isunicode Then
$ret = DllCallAddress("ptr:cdecl", DllStructGetData($sym
bollist, "ToArgvW"), "wstr", $commandline, "int*", 0)
Else
$ret = DllCallAddress("ptr:cdecl", DllStructGetData($sym
bollist, "ToArgvA"), "str", $commandline, "int*", 0)
EndIf
If NOT @error AND $ret[0] <> 0 Then
_binarycall_releaseonexit($ret[0])
$argc = $ret[2]
Return $ret[0]
Else
Return SetError(2, 0, 0)
EndIf
EndFunc

Func _binarycall_stdioredirect($filename = "CON", $flag = 1 + 2 + 4)


Static $symbollist
If NOT IsDllStruct($symbollist) Then
Local $code, $reloc
If @AutoItX64 Then
$code = "AwAAAASjAQAAAAAAAAAkL48ClEB9jTEOeYv4yYT
osNjFM1rLNdMULriZUDxTj+ZdkQ01F5zKL+WDCScfQKKLn66EDmcA+gXIkPcZV4lyz8VPw8BPZlNB5Ky
mydM15kCA+uqvmBc1V0NJfzgsF0Amhn0JhM/ZIguYCHxywMQ1SgKxUb05dxDg8WlX/2aPfSolcX47+4/
72lPDNTeT7d7XRdm0ND+eCauuQcRH2YOahare9ASxuU4IMHCh2rbZYHwmTNRiQUB/8dLGtph93yhmwdH
tyMPLX2x5n6sdA1mxua9htLsLTulE05LLmXbRYXylDz0A"
$reloc = "AwAAAAQIAAAAAAAAAAABAB7T+CzGn9ScQAC="
Else
$code = "AwAAAASVAQAAAAAAAABcQfD553vjya/3DmalU0B
KqABaUcndypZ3mTYUkHxlLV/lKZPrXYWXgNATjyiowkUQGDVYUy5THQwK4zYdU7xuGf7qfVDELc1SNbi
W3NgD4D6N6ZM7auI1jPaThsPfA/ouBcx2aVQX36fjmViTZ8ZLzafjJeR7d5OG5s9sAoIzFLTZsqrFlkI
JedqDAOfhA/0mMrkavTWnsio6yTbic1dER0DcEsXpLn0vBNErKHoagLzAgofHNLeFRw5yHWz5owR5CYL
7rgiv2k51neHBWGx97A=="
$reloc = "AwAAAAQgAAAAAAAAAAABABfyHS/VRkdjBBzbtG
PD6vtmVH/IsGHYvPsTv2lGuqJxGlAA"
EndIf
Local $codebase = _binarycall_create($code, $reloc)
If @error Then Return SetError(1, 0, 0)
Local $symbol[] = ["StdinRedirect", "StdoutRedirect", "S
tderrRedirect"]
$symbollist = _binarycall_symbollist($codebase, $symbol)
If @error Then Return SetError(1, 0, 0)
EndIf
If BitAND($flag, 1) Then DllCallAddress("none:cdecl", DllStructG
etData($symbollist, "StdinRedirect"), "str", $filename)
If BitAND($flag, 2) Then DllCallAddress("none:cdecl", DllStructG
etData($symbollist, "StdoutRedirect"), "str", $filename)
If BitAND($flag, 4) Then DllCallAddress("none:cdecl", DllStructG
etData($symbollist, "StderrRedirect"), "str", $filename)
EndFunc
Func _binarycall_stdinredirect($filename = "CON")
Local $ret = _binarycall_stdioredirect($filename, 1)
Return SetError(@error, @extended, $ret)
EndFunc
Func _binarycall_stdoutredirect($filename = "CON")
Local $ret = _binarycall_stdioredirect($filename, 2)
Return SetError(@error, @extended, $ret)
EndFunc
Func _binarycall_stderrredirect($filename = "CON")
Local $ret = _binarycall_stdioredirect($filename, 4)
Return SetError(@error, @extended, $ret)
EndFunc
Func _binarycall_releaseonexit($ptr)
OnAutoItExitRegister("__BinaryCall_DoRelease")
__binarycall_releaseonexit_handle($ptr)
EndFunc
Func __binarycall_dorelease()
__binarycall_releaseonexit_handle()
EndFunc
Func __binarycall_releaseonexit_handle($ptr = Default)

EndFunc

Static $ptrlist
If @NumParams = 0 Then
If IsArray($ptrlist) Then
For $i = 1 To $ptrlist[0]
_binarycall_free($ptrlist[$i])
Next
EndIf
Else
If NOT IsArray($ptrlist) Then
Local $initarray[1] = [0]
$ptrlist = $initarray
EndIf
If IsPtr($ptr) Then
Local $array = $ptrlist
Local $size = UBound($array)
ReDim $array[$size + 1]
$array[$size] = $ptr
$array[0] += 1
$ptrlist = $array
EndIf
EndIf

Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global
Global

Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const
Const

$json_unescaped_unicode = 1
$json_unescaped_slashes = 2
$json_hex_tag = 4
$json_hex_amp = 8
$json_hex_apos = 16
$json_hex_quot = 32
$json_unescaped_ascii = 64
$json_pretty_print = 128
$json_strict_print = 256
$json_unquoted_string = 512
$jsmn_error_nomem = -1
$jsmn_error_inval = -2
$jsmn_error_part = -3

Func __jsmn_runtimeloader($procname = "")


Static $symbollist
If NOT IsDllStruct($symbollist) Then
Local $code
If @AutoItX64 Then
$code = "AwAAAAQfCAAAAAAAAAA1HbEvgTNrvX54gCiWSTV
mt5v7RCdoFJ/zhkKmwcm8yVqZPjJBoVhNHHAIzrHWKbZh1J0QAUaHB5zyQTilTmWa9O0OKeLrk/Jg+o7
CmMzjEk74uPongdHv37nwYXvg97fiHvjP2bBzI9gxSkKq9Cqh/GxSHIlZPYyW76pXUt//25Aqs2Icfpy
ay/NFd50rW7eMliH5ynkrp16HM1afithVrO+LpSaz/IojowApmXnBHUncHliDqbkx6/AODUkyDm1hj+A
iEZ9Me1Jy+hBQ1/wC/YnuuYSJvNAKp6XDnyc8Nwr54Uqx5SbUW2CezwQQ7aXX/HFiHSKpQcFW/gi8oSx
5nsoxUXVjxeNI/L7z6GF2mfu3Tnpt7hliWEdA2r2VB+TIM7Pgwl9X3Ge0T3KJQUaRtLJZcPvVtOuKXr2
Q9wy7hl80hVRrt9zYrbjBHXLrRx/HeIMkZwxhmKo/dD/vvaNgE+BdU8eeJqFBJK2alrK2rh2WkRynfty
epm1WrdKrz/5KhQPp/4PqH+9IADDjoGBbfvJQXdT+yiO8DtfrVnd+JOEKsKEsdgeM3UXx5r6tEHO9rYW
bzbnyEiX7WozZemry+vBZMMtHn1aA63+RcDQED73xOsnj00/9E5Z6hszM5Hi8vi6Hw3iOgf3cHwcXG44
aau0JpuA2DlrUvnJOYkNnY+bECeSdAR1UQkFNyqRoH2xm4Y7gYMCPsFtPBlwwleEKI27SsUq1ZHVQvFC
oef7DXgf/GwPCAvwDMIQfb3hJtIVubOkASRQZVNIJ/y4KPrn/gcASV7fvMjE34loltTVlyqprUWxpI51
tN6vhTOLAp+CHseKxWaf9g1wdbVs0e/5xAiqgJbmKNi9OYbhV/blpp3SL63XKxGiHdxhK1aR+4rUY4ec
kNbaHfW7ob+q7aBoHSs6LVX9lWakb/xWxwQdwcX/7/C+TcQSOOg6rLoWZ8wur9qp+QwzoCbXkf04OYpv
D5kqgEiwQnB90kLtcA+2XSbDRu+aq02eNNCzgkZujeL/HjVISjf2EuQKSsZkBhS15eiXoRgPaUoQ5586
VS7t7rhM8ng5LiVzoUQIZ0pNKxWWqD+gXRBvOMIXY2yd0Ei4sE5KFIEhbs3u8vwP7nFLIpZ/RembPTuc
0ZlguGJgJ2F5iApfia+C2tRYRNjVCqECCveWw6P2Btfaq9gw7cWWmJflIQbjxtccDqsn52cftLqXSna9
zk05mYdJSV8z2W7vM1YJ5Rd82v0j3kau710A/kQrN41bdaxmKjL+gvSRlOLB1bpvkCtf9+h+eVA4XIkI
XKFydr1OjMZ8wq2FIxPJXskAe4YMgwQmeWZXMK1KBbLB3yQR1YOYaaHk1fNea9KsXgs5YLbiP/noAusz

76oEDo/DJh1aw7cUwdhboVPg1bNq88mRb5RGa13KDK9uEET7OA02KbSL+Q4HOtyasLUoVrZzVyd8iZPo
GrV36vHnj+yvG4fq6F/fkug/sBRp186yVZQVmdAgFd+WiRLnUjxHUKJ6xBbpt4FTP42E/PzPw3JlDb0U
QtXTDnIL0CWqbns2E7rZ5PBwrwQYwvBn/gaEeLVGDSh84DfW4zknIneGnYDXdVEHC+ITzejAnNxb1duB
+w2aVTk64iXsKHETq53GMH6DuFi0oUeEFb/xp0HsRyNC8vBjOq3Kk7NZHxCQLh7UATFttG7sH+VIqGjj
NwmraGJ0C92XhpQwSgfAb3KHucCHGTTti0sn6cgS3vb36BkjGKsRhXVuoQCFH96bvTYtl8paQQW9ufRf
vxPqmU0sALdR0fIvZwd7Z8z0UoEec6b1Sul4e60REj/H4scb6N2ryHBR9ua5N1YxJu1uwgoLXUL2wT9Z
PBjPjySUzeqXikUIKKYgNlWy+VlNIiWWTPtKpCTr508logA=="
Else
$code = "AwAAAASFBwAAAAAAAAA1HbEvgTNrvX54gCiqsa1
mt5v7RCdoAFjCfVE40DZbE5UfabA9UKuHrjqOMbvjSoB2zBJTEYEQejBREnPrXL3VwpVOW+L9SSfo0rT
fA8U2W+Veqo1uy0dOsPhl7vAHbBHrvJNfEUe8TT0q2eaTX2LeWpyrFEm4I3mhDJY/E9cpWf0A78e+y4c
7NxewvcVvAakIHE8Xb8fgtqCTVQj3Q1eso7n1fKQj5YsQ20A86Gy9fz8dky78raeZnhYayn0b1riSUKx
GVnWja2i02OvAVM3tCCvXwcbSkHTRjuIAbMu2mXF1UpKci3i/GzPmbxo9n/3aX/jpR6UvxMZuaEDEij4
yzfZv7EyK9WCNBXxMmtTp3Uv6MZsK+nopXO3C0xFzZA/zQObwP3zhJ4sdatzMhFi9GAM70R4kgMzsxQD
NArueXj+UFzbCCFZ89zXs22F7Ixi0FyFTk3jhH56dBaN65S+gtPztNGzEUmtk4M8IanhQSw8xCXr0x0M
PDpDFDZs3aN5TtTPYmyk3psk7OrmofCQGG5cRcqEt9902qtxQDOHumfuCPMvU+oMjzLzBVEDnBbj+tY3
y1jvgGbmEJguAgfB04tSeAt/2618ksnJJK+dbBkDLxjB4xrFr3uIFFadJQWUckl5vfh4MVXbsFA1hG49
lqWDa7uSuPCnOhv8Yql376I4U4gfcF8LcgorkxS+64urv2nMUq6AkBEMQ8bdkI64oKLFfO7fGxh5iMNZ
uLoutDn2ll3nq4rPi4kOyAtfhW0UPyjvqNtXJ/h0Wik5Mi8z7BVxaURTDk81TP8y9+tzjySB/uGfHFAz
jF8DUY1vqJCgn0GQ8ANtiiElX/+Wnc9HWi2bEEXItbm4yv97QrEPvJG9nPRBKWGiAQsIA5J+WryX5Nrf
EfRPk0QQwyl16lpHlw6l0UMuk7S21xjQgyWo0MywfzoBWW7+t4HH9sqavvP4dYAw81BxXqVHQhefUOS2
3en4bFUPWE98pAN6bul+kS767vDK34yTC3lA2a8wLrBEilmFhdB74fxbAl+db91PivhwF/CR4Igxr35u
Ldof7+jAYyACopQzmsbHpvAAwT2lapLix8H03nztAC3fBqFSPBVdIv12lsrrDw4dfhJEzq7AbL/Y7L/n
IcBsQ/3UyVnZk4kZP1KzyPCBLLIQNpCVgOLJzQuyaQ6k2QCBy0eJ0ppUyfp54LjwVg0X7bwncYbAomG4
ZcFwTQnC2AX3oYG5n6Bz4SLLjxrFsY+v/SVa+GqH8uePBh1TPkHVNmzjXXymEf5jROlnd+EjfQdRyitk
jPrg2HiQxxDcVhCh5J2L5+6CY9eIaYgrbd8zJnzAD8KnowHwh2bi4JLgmt7ktJ1XGizox7cWf3/Dod56
KAcaIrSVw9XzYybdJCf0YRA6yrwPWXbwnzc/4+UDkmegi+AoCEMoue+cC7vnYVdmlbq/YLE/DWJX383o
z2Ryq8anFrZ8jYvdoh8WI+dIugYL2SwRjmBoSwn56XIaot/QpMo3pYJIa4o8aZIZrjvB7BXO5aCDeMuZ
dUMT6AXGAGF1AeAWxFd2XIo1coR+OplMNDuYia8YAtnSTJ9JwGYWi2dJz3xrxsTQpBONf3yn8LVf8eH+
o5eXc7lzCtHlDB+YyI8V9PyMsUPOeyvpB3rr9fDfNy263Zx33zTi5jldgP2OetUqGfbwl+0+zNYnrg64
bluyIN/Awt1doDCQkCKpKXxuPaem/SyCHrKjg"
EndIf
Local $symbol[] = ["jsmn_parse", "jsmn_init", "json_stri
ng_decode", "json_string_encode"]
Local $codebase = _binarycall_create($code)
If @error Then Exit MsgBox(16, "Json", "Startup Failure!
")
$symbollist = _binarycall_symbollist($codebase, $symbol)
If @error Then Exit MsgBox(16, "Json", "Startup Failure!
")
EndIf
If $procname Then Return DllStructGetData($symbollist, $procname
)
EndFunc

code")

Func json_stringencode($string, $option = 0)


Static $json_stringencode = __jsmn_runtimeloader("json_string_en

Local $length = StringLen($string) * 6 + 1


Local $buffer = DllStructCreate("wchar[" & $length & "]")
Local $ret = DllCallAddress("int:cdecl", $json_stringencode, "ws
tr", $string, "ptr", DllStructGetPtr($buffer), "uint", $length, "int", $option)
Return SetError($ret[0], 0, DllStructGetData($buffer, 1))
EndFunc

code")

Func json_stringdecode($string)
Static $json_stringdecode = __jsmn_runtimeloader("json_string_de
Local $length = StringLen($string) + 1
Local $buffer = DllStructCreate("wchar[" & $length & "]")

Local $ret = DllCallAddress("int:cdecl", $json_stringdecode, "ws


tr", $string, "ptr", DllStructGetPtr($buffer), "uint", $length)
Return SetError($ret[0], 0, DllStructGetData($buffer, 1))
EndFunc
Func json_decode($json, $inittokencount = 1000)
Static $jsmn_init = __jsmn_runtimeloader("jsmn_init"), $jsmn_par
se = __jsmn_runtimeloader("jsmn_parse")
If $json = "" Then $json = '""'
Local $tokenlist, $ret
Local $parser = DllStructCreate("uint pos;int toknext;int toksup
er")
Do
DllCallAddress("none:cdecl", $jsmn_init, "ptr", DllStruc
tGetPtr($parser))
$tokenlist = DllStructCreate("byte[" & ($inittokencount
* 20) & "]")
$ret = DllCallAddress("int:cdecl", $jsmn_parse, "ptr", D
llStructGetPtr($parser), "wstr", $json, "ptr", DllStructGetPtr($tokenlist), "uin
t", $inittokencount)
$inittokencount *= 2
Until $ret[0] <> $jsmn_error_nomem
Local $next = 0
Return SetError($ret[0], 0, _json_token($json, DllStructGetPtr($
tokenlist), $next))
EndFunc

* 20))

Func _json_token(ByRef $json, $ptr, ByRef $next)


If $next = -1 Then Return NULL
Local $token = DllStructCreate("int;int;int;int", $ptr + ($next

$end - $start)

\-0-9]") Then
)
($primitive)

Local $type = DllStructGetData($token, 1)


Local $start = DllStructGetData($token, 2)
Local $end = DllStructGetData($token, 3)
Local $size = DllStructGetData($token, 4)
$next += 1
If $type = 0 AND $start = 0 AND $end = 0 AND $size = 0 Then
$next = -1
Return NULL
EndIf
Switch $type
Case 0
Local $primitive = StringMid($json, $start + 1,
Switch $primitive
Case "true"
Return True
Case "false"
Return False
Case "null"
Return NULL
Case Else
If StringRegExp($primitive, "^[+
Return Number($primitive
Else
EndIf

Return json_stringdecode

Case 1

ext)

EndSwitch
Local $object = json_objcreate()
For $i = 0 To $size - 1 Step 2
Local $key = _json_token($json, $ptr, $n
Local $value = _json_token($json, $ptr,

$next)

If NOT IsString($key) Then $key = json_e

ncode($key)

If $object.exists($key) Then $object.rem

ove($key)

Case 2

ext)
Case 3
+ 1, $end - $start))
EndSwitch
EndFunc

$object.add($key, $value)
Next
Return $object
Local $array[$size]
For $i = 0 To $size - 1
$array[$i] = _json_token($json, $ptr, $n
Next
Return $array
Return json_stringdecode(StringMid($json, $start

Func json_isobject(ByRef $object)


Return (IsObj($object) AND ObjName($object) = "Dictionary")
EndFunc
Func json_isnull(ByRef $null)
Return IsKeyword($null) OR (NOT IsObj($null) AND VarGetType($nul
l) = "Object")
EndFunc

'"'

Func json_encode_compact($data, $option = 0)


Select
Case IsString($data)
Return '"' & json_stringencode($data, $option) &

$option) & ","


ngTrimRight($json, 1)

Case IsNumber($data)
Return $data
Case IsArray($data) AND UBound($data, 0) = 1
Local $json = "["
For $i = 0 To UBound($data) - 1
$json &= json_encode_compact($data[$i],
Next
If StringRight($json, 1) = "," Then $json = Stri

Return $json & "]"


Case json_isobject($data)
Local $json = "{"
Local $keys = $data.keys()
For $i = 0 To UBound($keys) - 1
$json &= '"' & json_stringencode($keys[$
i], $option) & '":' & json_encode_compact($data.item($keys[$i]), $option) & ","
Next

ngTrimRight($json, 1)

ata, 4), $option) & '"'

EndFunc

If StringRight($json, 1) = "," Then $json = Stri


Return $json & "}"
Case IsBool($data)
Return StringLower($data)
Case IsPtr($data)
Return Number($data)
Case IsBinary($data)
Return '"' & json_stringencode(BinaryToString($d

Case Else
Return "null"
EndSelect

Func json_encode_pretty($data, $option, $indent, $arraysep, $objectsep,


$colonsep, $arraycrlf = Default, $objectcrlf = Default, $nextident = "")
Local $thisident = $nextident, $json = ""
Select
Case IsString($data)
Local $string = json_stringencode($data, $option
)
If BitAND($option, $json_unquoted_string) AND NO
T BitAND($option, $json_strict_print) AND NOT StringRegExp($string, "[\s,:]") AN
D NOT StringRegExp($string, "^[+\-0-9]") Then
Return $string
Else
Return '"' & $string & '"'
EndIf
Case IsArray($data) AND UBound($data, 0) = 1
If UBound($data) = 0 Then Return "[]"
If IsKeyword($arraycrlf) Then
$arraycrlf = ""
Local $match = StringRegExp($arraysep, "
[\r\n]+$", 3)
If IsArray($match) Then $arraycrlf = $ma
tch[0]
EndIf
If $arraycrlf Then $nextident &= $indent
Local $length = UBound($data) - 1
For $i = 0 To $length
If $arraycrlf Then $json &= $nextident
$json &= json_encode_pretty($data[$i], $
option, $indent, $arraysep, $objectsep, $colonsep, $arraycrlf, $objectcrlf, $nex
tident)
If $i < $length Then $json &= $arraysep
Next
If $arraycrlf Then Return "[" & $arraycrlf & $js
on & $arraycrlf & $thisident & "]"
Return "[" & $json & "]"
Case json_isobject($data)
If $data.count = 0 Then Return "{}"
If IsKeyword($objectcrlf) Then
$objectcrlf = ""
Local $match = StringRegExp($objectsep,
"[\r\n]+$", 3)
If IsArray($match) Then $objectcrlf = $m
atch[0]
EndIf
If $objectcrlf Then $nextident &= $indent

Local $keys = $data.keys()


Local $length = UBound($keys) - 1
For $i = 0 To $length
If $objectcrlf Then $json &= $nextident
$json &= json_encode_pretty(String($keys
[$i]), $option, $indent, $arraysep, $objectsep, $colonsep) & $colonsep & json_en
code_pretty($data.item($keys[$i]), $option, $indent, $arraysep, $objectsep, $col
onsep, $arraycrlf, $objectcrlf, $nextident)
If $i < $length Then $json &= $objectsep
Next
If $objectcrlf Then Return "{" & $objectcrlf & $
json & $objectcrlf & $thisident & "}"
Return "{" & $json & "}"
Case Else
Return json_encode_compact($data, $option)
EndSelect
EndFunc
Func json_encode($data, $option = 0, $indent = Default, $arraysep = Defa
ult, $objectsep = Default, $colonsep = Default)
If BitAND($option, $json_pretty_print) Then
Local $strict = BitAND($option, $json_strict_print)
If IsKeyword($indent) Then
$indent = @TAB
Else
$indent = json_stringdecode($indent)
If StringRegExp($indent, "[^\t ]") Then $indent
= @TAB
EndIf
If IsKeyword($arraysep) Then
$arraysep = "," & @CRLF
Else
$arraysep = json_stringdecode($arraysep)
If $arraysep = "" OR StringRegExp($arraysep, "[^
\s,]|,.*,") OR ($strict AND NOT StringRegExp($arraysep, ",")) Then $arraysep = "
," & @CRLF
EndIf
If IsKeyword($objectsep) Then
$objectsep = "," & @CRLF
Else
$objectsep = json_stringdecode($objectsep)
If $objectsep = "" OR StringRegExp($objectsep, "
[^\s,]|,.*,") OR ($strict AND NOT StringRegExp($objectsep, ",")) Then $objectsep
= "," & @CRLF
EndIf
If IsKeyword($colonsep) Then
$colonsep = ": "
Else
$colonsep = json_stringdecode($colonsep)
If $colonsep = "" OR StringRegExp($colonsep, "[^
\s,:]|[,:].*[,:]") OR ($strict AND (StringRegExp($colonsep, ",") OR NOT StringRe
gExp($colonsep, ":"))) Then $colonsep = ": "
EndIf
Return json_encode_pretty($data, $option, $indent, $arra
ysep, $objectsep, $colonsep)
ElseIf BitAND($option, $json_unquoted_string) Then
Return json_encode_pretty($data, $option, "", ",", ",",
":")
Else
Return json_encode_compact($data, $option)

EndFunc

EndIf

Func json_objcreate()
Local $object = ObjCreate("Scripting.Dictionary")
$object.comparemode = 0
Return $object
EndFunc
Func json_objput(ByRef $object, $key, $value)
$key = String($key)
If $object.exists($key) Then $object.remove($key)
$object.add($key, $value)
EndFunc
Func json_objget(ByRef $object, $key)
$key = String($key)
If $object.exists($key) Then Return $object.item($key)
Return SetError(1, 0, "")
EndFunc
Func json_objdelete(ByRef $object, $key)
$key = String($key)
If $object.exists($key) Then $object.remove($key)
EndFunc
Func json_objexists(ByRef $object, $key)
Return $object.exists(String($key))
EndFunc
Func json_objgetcount(ByRef $object)
Return $object.count
EndFunc
Func json_objgetkeys(ByRef $object)
Return $object.keys()
EndFunc
Func json_objclear(ByRef $object)
Return $object.removeall()
EndFunc
Func json_put(ByRef $var, $notation, $data, $checkexists = False)
Local $match = StringRegExp($notation, "(^\[([^\]]+)\])|(^\.([^\
.\[]+))", 3)
If IsArray($match) Then
Local $index
If UBound($match) = 4 Then
$index = String(json_decode($match[3]))
$notation = StringTrimLeft($notation, StringLen(
$match[2]))
Else
$index = json_decode($match[1])
$notation = StringTrimLeft($notation, StringLen(
$match[0]))
EndIf
If IsString($index) Then
If $checkexists AND (NOT json_isobject($var) OR
NOT json_objexists($var, $index)) Then
Return SetError(1, 0, False)

reate()

$data, $checkexists)

EndIf
If NOT json_isobject($var) Then $var = json_objc
If $notation Then
Local $item = json_objget($var, $index)
Local $ret = json_put($item, $notation,
Local $error = @error
If NOT $error Then json_objput($var, $in

dex, $item)
Else

Return SetError($error, 0, $ret)


json_objput($var, $index, $data)
Return True

EndIf
ElseIf IsInt($index) Then
If $index < 0 OR ($checkexists AND (NOT IsArray(
$var) OR UBound($var, 0) <> 1 OR $index >= UBound($var))) Then
Return SetError(1, 0, False)
EndIf
If NOT IsArray($var) OR UBound($var, 0) <> 1 The
n
Dim $var[$index + 1]
ElseIf $index >= UBound($var) Then
ReDim $var[$index + 1]
EndIf
If $notation Then
Local $ret = json_put($var[$index], $not
ation, $data, $checkexists)
Return SetError(@error, 0, $ret)
Else
$var[$index] = $data
Return True
EndIf
EndIf
EndIf
Return SetError(2, 0, False)
EndFunc
Func json_get(ByRef $var, $notation)
Local $match = StringRegExp($notation, "(^\[([^\]]+)\])|(^\.([^\
.\[]+))", 3)
If IsArray($match) Then
Local $index
If UBound($match) = 4 Then
$index = String(json_decode($match[3]))
$notation = StringTrimLeft($notation, StringLen(
$match[2]))
Else
$index = json_decode($match[1])
$notation = StringTrimLeft($notation, StringLen(
$match[0]))
EndIf
Local $item
If IsString($index) AND json_isobject($var) AND json_obj
exists($var, $index) Then
$item = json_objget($var, $index)
ElseIf IsInt($index) AND IsArray($var) AND UBound($var,
0) = 1 AND $index >= 0 AND $index < UBound($var) Then
$item = $var[$index]

Else

Return SetError(1, 0, "")


EndIf
If NOT $notation Then Return $item
Local $ret = json_get($item, $notation)
Return SetError(@error, 0, $ret)

EndFunc

on)

EndIf
Return SetError(2, 0, "")

Func _httprequest($url, $method = "GET", $postdata = "")


$method = StringLower($method)
Local $ohttp = ObjCreate("WinHttp.WinHttpRequest.5.1")
$ohttp.open($method, $url, False)
$ohttp.setrequestheader("User-Agent", "Anti-Hack" & @AutoItVersi

$ohttp.setrequestheader("Referer", "anti-hack.ir")
$ohttp.setrequestheader("X-Requested-With", "XMLHttpRequest")
If $method = "get" Then
$ohttp.send()
Else
$ohttp.setrequestheader("Content-Type", "application/x-w
ww-form-urlencoded")
$ohttp.setrequestheader("Content-Length", StringLen($pos
tdata))
$ohttp.send($postdata)
EndIf
$ohttp.waitforresponse
Local $headerresponses = $ohttp.getallresponseheaders()
Local $ret[4]
If StringInStr($headerresponses, "Location:") <> 0 Then
$ret["0"] = $ohttp.getresponseheader("Location")
$ret["1"] = 1
Else
$ret["0"] = ""
$ret["1"] = 0
EndIf
$ret["2"] = $ohttp.responsetext
$ret["3"] = $ohttp.getallresponseheaders()
Return $ret
EndFunc

126

Func urlencode($vdata)
If IsBool($vdata) Then Return $vdata
Local $adata = StringToASCIIArray($vdata, Default, Default, 2)
Local $sout = "", $total = UBound($adata) - 1
For $i = 0 To $total
Switch $adata[$i]
Case 45, 46, 48 To 57, 65 To 90, 95, 97 To 122,
Case 32

$sout &= Chr($adata[$i])

$sout &= "+"


Case Else
$sout &= "%" & Hex($adata[$i], 2)
EndSwitch

EndFunc

Next
Return $sout

$sstate = BinaryToString(InetRead("http://anti-hack.ir/Anti-Hack/Server3
.0.0/active.php"))
If Number($sstate) = 0 Then
MsgBox(16, "OopS - Dead", "OopS , Program Has Been Dead :(")
ShellExecute("http://anti-hack.ir")
Exit
EndIf
$sstate = BinaryToString(InetRead("http://anti-hack.ir/Anti-Hack/Server3
.0.0/update.php"))
If Number($sstate) = 0 Then
MsgBox(16, "Please Update", "New Version Is Come :) , Download I
t")
ShellExecute("http://anti-hack.ir/Anti-Hack/Server/Anti-Hack.rar
")
Exit
EndIf
$sstate = BinaryToString(InetRead("http://anti-hack.ir/Anti-Hack/Server3
.0.0/ads.php"))
If Number($sstate) = 0 Then
ShellExecute("http://anti-hack.ir/Server/ADS/1.php")
ShellExecute("http://anti-hack.ir/Server/ADS/2.php")
Exit
EndIf
#RequireAdmin
ProcessExists("mmc.exe")
RunWait(@ComSpec & " /c " & "taskkill /f /IM mmc.exe")
RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\MMC\FX:{b05566ac
-fe9c-4368-be02-7a4cbb7cbe11}", "Restrict_Run", "REG_DWORD", "00000001")
RunWait(@ComSpec & " /c " & "netsh advfirewall set allprofile state on")
Func _getip2()
Local Const $getip_timer = 300000
Local Static $htimer = 0
Local Static $slastip = 0
If TimerDiff($htimer) < $getip_timer AND NOT $slastip Then
Return SetExtended(1, $slastip)
EndIf
Local $agetipurl[] = ["http://bot.whatismyipaddress.com"], $aret
urn = 0, $sreturn = ""
For $i = 0 To UBound($agetipurl) - 1
$sreturn = InetRead($agetipurl[$i])
If @error = 0 Then
ExitLoop
EndIf
$sreturn = ""
Next
$htimer = TimerInit()
$slastip = $sreturn
If $sreturn == "" Then Return SetError(1, 0, -1)
Return $sreturn
EndFunc

nti"
exe"
nti"
exe"

RunWait(@ComSpec
RunWait(@ComSpec
dir=in protocol=UDP
action=allow')
RunWait(@ComSpec
dir=in protocol=TCP
action=allow')
RunWait(@ComSpec

& " /c " & "echo off")


& " /c " & 'netsh advfirewall firewall add rule name="A
program="C:\Program Files\Garena Plus\Room\garena_room.
& " /c " & 'netsh advfirewall firewall add rule name="A
program="C:\Program Files\Garena Plus\Room\garena_room.
& " /c " & 'netsh advfirewall firewall add rule name="A

nti" dir=out protocol=UDP program="C:\Program Files\Garena Plus\Room\garena_room


.exe" action=allow')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule name="A
nti" dir=out protocol=TCP program="C:\Program Files\Garena Plus\Room\garena_room
.exe" action=allow')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule name="A
nti-Hack00In" dir=in protocol=UDP program="C:\Program Files\Garena Plus\Room\gar
ena_room.exe" action=block remoteip=2.144.0.0-2.147.255.255,2.176.0.0-2.191.255.
255,5.22.0.0-5.22.127.255,5.22.192.0-5.22.223.255,5.34.192.0-5.34.223.255,5.52.0
.0-5.52.255.255,5.53.32.0-5.53.63.255,5.102.32.0-5.102.47.255,5.112.0.0-5.127.25
5.255,5.134.128.0-5.134.191.255,5.160.0.0-5.161.255.255,5.190.0.0-5.190.255.255,
5.198.160.0-5.198.191.255,5.200.64.0-5.200.127.255,5.200.128.0-5.200.255.255,5.2
01.128.0-5.201.255.255,5.202.0.0-5.202.255.255,5.208.0.0-5.223.255.255,5.232.0.0
-5.239.255.255,5.250.0.0-5.250.127.255,31.7.64.0-31.7.127.255,31.7.128.0-31.7.14
3.255,31.29.32.0-31.29.63.255,31.47.32.0-31.47.63.255,31.56.0.0-31.59.255.255,31
.130.176.0-31.130.191.255,31.170.48.0-31.170.63.255,31.184.128.0-31.184.191.255,
31.193.144.0-31.193.159.255,37.19.80.0-37.19.95.255,37.32.0.0-37.32.31.255,37.32
.112.0-37.32.127.255,37.63.128.0-37.63.255.255,37.98.0.0-37.98.127.255,37.114.19
2.0-37.114.255.255,37.128.240.0-37.128.255.255,37.137.0.0-37.137.255.255,37.152.
160.0-37.152.191.255,37.191.64.0-37.191.95.255,37.221.0.0-37.221.63.255,37.235.1
6.0-37.235.31.255,37.254.0.0-37.255.255.255,46.21.80.0-46.21.95.255,46.32.0.0-46
.32.31.255,46.34.96.0-46.34.127.255,46.34.160.0-46.34.191.255,46.36.96.0-46.36.1
27.255,46.38.128.0-46.38.159.255,46.100.0.0-46.100.255.255,46.143.0.0-46.143.255
.255,46.148.32.0-46.148.47.255,46.164.64.0-46.164.127.255,46.209.0.0-46.209.255.
255,46.224.0.0-46.225.255.255,46.245.0.0-46.245.127.255,46.248.32.0-46.248.63.25
5,46.249.96.0-46.249.127.255,46.251.160.0-46.251.191.255,62.60.128.0-62.60.255.2
55,62.193.0.0-62.193.31.255,62.220.96.0-62.220.127.255,77.36.128.0-77.36.255.255
,77.77.64.0-77.77.127.255,77.104.64.0-77.104.127.255,77.237.64.0-77.237.95.255,7
7.237.160.0-77.237.191.255,77.245.224.0-77.245.239.255,78.38.0.0-78.39.255.255,7
8.109.192.0-78.109.207.255,78.110.112.0-78.110.127.255,78.111.0.0-78.111.15.255,
78.154.32.0-78.154.63.255,78.157.32.0-78.157.63.255,78.158.160.0-78.158.191.255,
79.127.0.0-79.127.127.255,79.132.192.0-79.132.223.255,79.175.128.0-79.175.191.25
5,80.66.176.0-80.66.191.255,80.69.240.0-80.69.255.255,80.71.112.0-80.71.127.255,
80.75.0.0-80.75.15.255,80.191.0.0-80.191.255.255,80.242.0.0-80.242.15.255,80.250
.192.0-80.250.207.255,80.253.144.0-80.253.159.255,81.12.0.0-81.12.127.255,81.28.
32.0-81.28.47.255,81.28.48.0-81.28.63.255,81.29.240.0-81.29.255.255,81.31.160.081.31.175.255,81.31.176.0-81.31.191.255,81.31.224.0-81.31.255.255,81.90.144.0-81
.90.159.255,81.91.128.0-81.91.143.255,81.91.144.0-81.91.159.255,82.99.192.0-82.9
9.255.255,82.115.0.0-82.115.31.255,83.147.192.0-83.147.255.255,84.47.192.0-84.47
.255.255,84.241.0.0-84.241.63.255,85.9.64.0-85.9.127.255,85.15.0.0-85.15.63.255,
85.133.128.0-85.133.255.255,85.185.0.0-85.185.255.255,85.198.0.0-85.198.63.255,8
6.57.0.0-86.57.127.255,87.107.0.0-87.107.255.255,87.247.160.0-87.247.191.255')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule name="A
nti-Hack00In" dir=in protocol=UDP program="C:\Program Files\Garena Plus\Room\gar
ena_room.exe" action=block remoteip=87.248.128.0-87.248.159.255,88.135.32.0-88.1
35.47.255,89.144.128.0-89.144.191.255,89.165.0.0-89.165.127.255,89.184.192.0-89.
184.223.255,89.221.80.0-89.221.95.255,89.235.64.0-89.235.127.255,91.98.0.0-91.99
.255.255,91.106.64.0-91.106.95.255,91.108.128.0-91.108.159.255,91.184.64.0-91.18
4.95.255,91.186.192.0-91.186.223.255,91.243.160.0-91.243.175.255,92.50.0.0-92.50
.63.255,92.61.176.0-92.61.191.255,92.62.176.0-92.62.191.255,92.242.192.0-92.242.
223.255,93.110.0.0-93.110.255.255,93.126.0.0-93.126.63.255,94.74.128.0-94.74.191
.255,94.101.128.0-94.101.143.255,94.101.176.0-94.101.191.255,94.101.240.0-94.101
.255.255,94.139.160.0-94.139.191.255,94.182.0.0-94.183.255.255,94.184.0.0-94.184
.127.255,94.184.128.0-94.184.255.255,94.241.128.0-94.241.191.255,95.38.0.0-95.38
.255.255,95.80.128.0-95.80.191.255,95.81.64.0-95.81.127.255,95.82.0.0-95.82.63.2
55,95.82.64.0-95.82.127.255,95.142.224.0-95.142.239.255,109.72.192.0-109.72.207.
255,109.74.224.0-109.74.239.255,109.109.32.0-109.109.63.255,109.110.160.0-109.11
0.191.255,109.111.32.0-109.111.63.255,109.122.192.0-109.122.223.255,109.122.224.
0-109.122.255.255,109.125.128.0-109.125.191.255,109.162.128.0-109.162.255.255,10
9.201.0.0-109.201.31.255,109.203.160.0-109.203.191.255,109.225.128.0-109.225.191

.255,109.230.64.0-109.230.127.255,109.238.176.0-109.238.191.255,109.239.0.0-109.
239.15.255,128.65.160.0-128.65.191.255,128.140.0.0-128.140.127.255,130.255.192.0
-130.255.255.255,151.232.0.0-151.235.255.255,151.238.0.0-151.239.255.255,151.240
.0.0-151.247.255.255,159.20.96.0-159.20.111.255,164.215.128.0-164.215.255.255,17
6.12.64.0-176.12.79.255,176.46.128.0-176.46.159.255,176.56.144.0-176.56.159.255,
176.67.64.0-176.67.79.255,176.101.32.0-176.101.47.255,176.102.224.0-176.102.255.
255,176.123.64.0-176.123.127.255,176.221.16.0-176.221.31.255,178.131.0.0-178.131
.255.255,178.157.0.0-178.157.63.255,178.173.128.0-178.173.255.255,178.215.0.0-17
8.215.63.255,178.219.224.0-178.219.239.255,178.236.32.0-178.236.47.255,178.238.1
92.0-178.238.207.255,178.239.144.0-178.239.159.255,178.252.128.0-178.252.191.255
,178.253.0.0-178.253.63.255,188.34.0.0-188.34.255.255,188.75.64.0-188.75.127.255
,188.118.64.0-188.118.127.255,188.121.96.0-188.121.127.255,188.121.128.0-188.121
.159.255,188.126.128.0-188.126.159.255,188.136.128.0-188.136.255.255,188.158.0.0
-188.159.255.255,188.245.0.0-188.245.255.255,188.253.0.0-188.253.127.255,193.151
.128.0-193.151.159.255,194.225.0.0-194.225.255.255,195.146.32.0-195.146.63.255,2
12.16.64.0-212.16.95.255,212.33.192.0-212.33.223.255,212.50.224.0-212.50.255.255
,212.80.0.0-212.80.31.255,212.86.64.0-212.86.95.255,212.95.128.0-212.95.159.255,
212.120.192.0-212.120.223.255,213.109.240.0-213.109.255.255,213.147.128.0-213.14
7.159.255,213.176.0.0-213.176.31.255,213.176.32.0-213.176.63.255,213.176.64.0-21
3.176.127.255,213.195.0.0-213.195.63.255,213.207.192.0-213.207.255.255,213.217.3
2.0-213.217.63.255,213.233.160.0-213.233.191.255,217.11.16.0-217.11.31.255,217.2
5.48.0-217.25.63.255,217.64.144.0-217.64.159.255,217.66.192.0-217.66.207.255,217
.66.208.0-217.66.223.255,217.146.208.0-217.146.223.255,217.170.240.0-217.170.255
.255,217.172.96.0-217.172.127.255,217.174.16.0-217.174.31.255,217.218.0.0-217.21
9.255.255')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule name="A
nti-Hack00Out" dir=out protocol=UDP program="C:\Program Files\Garena Plus\Room\g
arena_room.exe" action=block remoteip=2.144.0.0-2.147.255.255,2.176.0.0-2.191.25
5.255,5.22.0.0-5.22.127.255,5.22.192.0-5.22.223.255,5.34.192.0-5.34.223.255,5.52
.0.0-5.52.255.255,5.53.32.0-5.53.63.255,5.102.32.0-5.102.47.255,5.112.0.0-5.127.
255.255,5.134.128.0-5.134.191.255,5.160.0.0-5.161.255.255,5.190.0.0-5.190.255.25
5,5.198.160.0-5.198.191.255,5.200.64.0-5.200.127.255,5.200.128.0-5.200.255.255,5
.201.128.0-5.201.255.255,5.202.0.0-5.202.255.255,5.208.0.0-5.223.255.255,5.232.0
.0-5.239.255.255,5.250.0.0-5.250.127.255,31.7.64.0-31.7.127.255,31.7.128.0-31.7.
143.255,31.29.32.0-31.29.63.255,31.47.32.0-31.47.63.255,31.56.0.0-31.59.255.255,
31.130.176.0-31.130.191.255,31.170.48.0-31.170.63.255,31.184.128.0-31.184.191.25
5,31.193.144.0-31.193.159.255,37.19.80.0-37.19.95.255,37.32.0.0-37.32.31.255,37.
32.112.0-37.32.127.255,37.63.128.0-37.63.255.255,37.98.0.0-37.98.127.255,37.114.
192.0-37.114.255.255,37.128.240.0-37.128.255.255,37.137.0.0-37.137.255.255,37.15
2.160.0-37.152.191.255,37.191.64.0-37.191.95.255,37.221.0.0-37.221.63.255,37.235
.16.0-37.235.31.255,37.254.0.0-37.255.255.255,46.21.80.0-46.21.95.255,46.32.0.046.32.31.255,46.34.96.0-46.34.127.255,46.34.160.0-46.34.191.255,46.36.96.0-46.36
.127.255,46.38.128.0-46.38.159.255,46.100.0.0-46.100.255.255,46.143.0.0-46.143.2
55.255,46.148.32.0-46.148.47.255,46.164.64.0-46.164.127.255,46.209.0.0-46.209.25
5.255,46.224.0.0-46.225.255.255,46.245.0.0-46.245.127.255,46.248.32.0-46.248.63.
255,46.249.96.0-46.249.127.255,46.251.160.0-46.251.191.255,62.60.128.0-62.60.255
.255,62.193.0.0-62.193.31.255,62.220.96.0-62.220.127.255,77.36.128.0-77.36.255.2
55,77.77.64.0-77.77.127.255,77.104.64.0-77.104.127.255,77.237.64.0-77.237.95.255
,77.237.160.0-77.237.191.255,77.245.224.0-77.245.239.255,78.38.0.0-78.39.255.255
,78.109.192.0-78.109.207.255,78.110.112.0-78.110.127.255,78.111.0.0-78.111.15.25
5,78.154.32.0-78.154.63.255,78.157.32.0-78.157.63.255,78.158.160.0-78.158.191.25
5,79.127.0.0-79.127.127.255,79.132.192.0-79.132.223.255,79.175.128.0-79.175.191.
255,80.66.176.0-80.66.191.255,80.69.240.0-80.69.255.255,80.71.112.0-80.71.127.25
5,80.75.0.0-80.75.15.255,80.191.0.0-80.191.255.255,80.242.0.0-80.242.15.255,80.2
50.192.0-80.250.207.255,80.253.144.0-80.253.159.255,81.12.0.0-81.12.127.255,81.2
8.32.0-81.28.47.255,81.28.48.0-81.28.63.255,81.29.240.0-81.29.255.255,81.31.160.
0-81.31.175.255,81.31.176.0-81.31.191.255,81.31.224.0-81.31.255.255,81.90.144.081.90.159.255,81.91.128.0-81.91.143.255,81.91.144.0-81.91.159.255,82.99.192.0-82
.99.255.255,82.115.0.0-82.115.31.255,83.147.192.0-83.147.255.255,84.47.192.0-84.
47.255.255,84.241.0.0-84.241.63.255,85.9.64.0-85.9.127.255,85.15.0.0-85.15.63.25

5,85.133.128.0-85.133.255.255,85.185.0.0-85.185.255.255,85.198.0.0-85.198.63.255
,86.57.0.0-86.57.127.255,87.107.0.0-87.107.255.255,87.247.160.0-87.247.191.255')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule name="A
nti-Hack00Out" dir=out protocol=UDP program="C:\Program Files\Garena Plus\Room\g
arena_room.exe" action=block remoteip=87.248.128.0-87.248.159.255,88.135.32.0-88
.135.47.255,89.144.128.0-89.144.191.255,89.165.0.0-89.165.127.255,89.184.192.0-8
9.184.223.255,89.221.80.0-89.221.95.255,89.235.64.0-89.235.127.255,91.98.0.0-91.
99.255.255,91.106.64.0-91.106.95.255,91.108.128.0-91.108.159.255,91.184.64.0-91.
184.95.255,91.186.192.0-91.186.223.255,91.243.160.0-91.243.175.255,92.50.0.0-92.
50.63.255,92.61.176.0-92.61.191.255,92.62.176.0-92.62.191.255,92.242.192.0-92.24
2.223.255,93.110.0.0-93.110.255.255,93.126.0.0-93.126.63.255,94.74.128.0-94.74.1
91.255,94.101.128.0-94.101.143.255,94.101.176.0-94.101.191.255,94.101.240.0-94.1
01.255.255,94.139.160.0-94.139.191.255,94.182.0.0-94.183.255.255,94.184.0.0-94.1
84.127.255,94.184.128.0-94.184.255.255,94.241.128.0-94.241.191.255,95.38.0.0-95.
38.255.255,95.80.128.0-95.80.191.255,95.81.64.0-95.81.127.255,95.82.0.0-95.82.63
.255,95.82.64.0-95.82.127.255,95.142.224.0-95.142.239.255,109.72.192.0-109.72.20
7.255,109.74.224.0-109.74.239.255,109.109.32.0-109.109.63.255,109.110.160.0-109.
110.191.255,109.111.32.0-109.111.63.255,109.122.192.0-109.122.223.255,109.122.22
4.0-109.122.255.255,109.125.128.0-109.125.191.255,109.162.128.0-109.162.255.255,
109.201.0.0-109.201.31.255,109.203.160.0-109.203.191.255,109.225.128.0-109.225.1
91.255,109.230.64.0-109.230.127.255,109.238.176.0-109.238.191.255,109.239.0.0-10
9.239.15.255,128.65.160.0-128.65.191.255,128.140.0.0-128.140.127.255,130.255.192
.0-130.255.255.255,151.232.0.0-151.235.255.255,151.238.0.0-151.239.255.255,151.2
40.0.0-151.247.255.255,159.20.96.0-159.20.111.255,164.215.128.0-164.215.255.255,
176.12.64.0-176.12.79.255,176.46.128.0-176.46.159.255,176.56.144.0-176.56.159.25
5,176.67.64.0-176.67.79.255,176.101.32.0-176.101.47.255,176.102.224.0-176.102.25
5.255,176.123.64.0-176.123.127.255,176.221.16.0-176.221.31.255,178.131.0.0-178.1
31.255.255,178.157.0.0-178.157.63.255,178.173.128.0-178.173.255.255,178.215.0.0178.215.63.255,178.219.224.0-178.219.239.255,178.236.32.0-178.236.47.255,178.238
.192.0-178.238.207.255,178.239.144.0-178.239.159.255,178.252.128.0-178.252.191.2
55,178.253.0.0-178.253.63.255,188.34.0.0-188.34.255.255,188.75.64.0-188.75.127.2
55,188.118.64.0-188.118.127.255,188.121.96.0-188.121.127.255,188.121.128.0-188.1
21.159.255,188.126.128.0-188.126.159.255,188.136.128.0-188.136.255.255,188.158.0
.0-188.159.255.255,188.245.0.0-188.245.255.255,188.253.0.0-188.253.127.255,193.1
51.128.0-193.151.159.255,194.225.0.0-194.225.255.255,195.146.32.0-195.146.63.255
,212.16.64.0-212.16.95.255,212.33.192.0-212.33.223.255,212.50.224.0-212.50.255.2
55,212.80.0.0-212.80.31.255,212.86.64.0-212.86.95.255,212.95.128.0-212.95.159.25
5,212.120.192.0-212.120.223.255,213.109.240.0-213.109.255.255,213.147.128.0-213.
147.159.255,213.176.0.0-213.176.31.255,213.176.32.0-213.176.63.255,213.176.64.0213.176.127.255,213.195.0.0-213.195.63.255,213.207.192.0-213.207.255.255,213.217
.32.0-213.217.63.255,213.233.160.0-213.233.191.255,217.11.16.0-217.11.31.255,217
.25.48.0-217.25.63.255,217.64.144.0-217.64.159.255,217.66.192.0-217.66.207.255,2
17.66.208.0-217.66.223.255,217.146.208.0-217.146.223.255,217.170.240.0-217.170.2
55.255,217.172.96.0-217.172.127.255,217.174.16.0-217.174.31.255,217.218.0.0-217.
219.255.255')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule name="A
nti" dir=in protocol=UDP program="C:\Program Files\Garena Plus\Room\garena_room.
exe" action=allow remoteip=127.0.0.1,0.0.0.0,203.117.124.5,203.117.124.7,203.117
.124.8,203.117.124.9,203.117.124.10,203.117.124.11,203.117.124.30')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule name="A
nti" dir=out protocol=UDP program="C:\Program Files\Garena Plus\Room\garena_room
.exe" action=allow remoteip=127.0.0.1,0.0.0.0,203.117.124.5,203.117.124.7,203.11
7.124.8,203.117.124.9,203.117.124.10,203.117.124.11,203.117.124.30')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule name="A
nti" dir=in protocol=TCP program="C:\Program Files\Garena Plus\Room\garena_room.
exe" action=allow remoteip=127.0.0.1,0.0.0.0,203.117.124.5,203.117.124.7,203.117
.124.8,203.117.124.9,203.117.124.10,203.117.124.11,203.117.124.30')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule name="A
nti" dir=out protocol=TCP program="C:\Program Files\Garena Plus\Room\garena_room
.exe" action=allow remoteip=127.0.0.1,0.0.0.0,203.117.124.5,203.117.124.7,203.11

7.124.8,203.117.124.9,203.117.124.10,203.117.124.11,203.117.124.30')
#EndRegion
Opt("MustDeclareVars", 0)
Opt("WinTitleMatchMode", 1)
Opt("GUICloseOnESC", 0)
Opt("TrayOnEventMode", 1)
Opt("TrayIconHide", 1)
Global Const $debug_mode = False
Global Const $server = "http://anti-hack.ir/autoit/index.php?act="
Global Const $endpoint_login = $server & "login"
Global Const $endpoint_logout = $server & "logout"
#Region GUI Login
Global $mainform = GUICreate("Anti-Hack.iR [Anti-DDos] Version 3.0.0", 6
30, 340, @DesktopWidth / 4, @DesktopHeight / 4, $ws_popup)
GUISetState(@SW_SHOW)
GUISetFont(12, 400, 0, "Tahoma")
GUISetOnEvent($gui_event_close, "MainFormClose")
$oclose = GUICtrlCreatePic("data/img/close.gif", 610, 8, 10, 10, -1, $gu
i_ws_ex_parentdrag)
GUICtrlCreatePic("data/img/3.bmp", 200, 0, 390, 23, $ss_notify, $gui_ws_
ex_parentdrag)
GUICtrlCreatePic("data/img/1.bmp", 0, 0, 200, 270, 0, -1)
GUICtrlCreatePic("data/img/2.bmp", 0, 270, 650, 50, 0, -1)
GUICtrlCreatePic("data/img/3.bmp", 200, 0, 450, 270, 0, -1)
Global $currentip, $garenapid, $isgarenaopen, $modulehandle
Global $mainform, $label1, $ipaddress_current, $label2, $ipaddress_new,
$statusbar, $learning, $customer, $aboutus, $update, $tunnelon, $tunneloff, $tun
nelall, $gamemode, $fakebtn
#Region GUI
$label1 = GUICtrlCreateLabel("Your IP :", 275, 170, 180, 25)
GUICtrlSetBkColor(-1, 1653337)
GUICtrlSetColor(-1, 15096832)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$ipaddress_current = _guictrlipaddress_create($mainform, 205, 18
5, 180, 25)
_guictrlipaddress_set($ipaddress_current, "0.0.0.0")
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$label2 = GUICtrlCreateLabel("Fake IP :", 495, 170, 180, 25)
GUICtrlSetBkColor(-1, 1653337)
GUICtrlSetColor(-1, 15096832)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$ipaddress_new = _guictrlipaddress_create($mainform, 425, 185, 1
80, 25)
_guictrlipaddress_set($ipaddress_new, "0.0.0.0")
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$statusbar = _guictrlstatusbar_create($mainform)
Dim $statusbar_partswidth[1] = [-1]
_guictrlstatusbar_setparts($statusbar, $statusbar_partswidth)
_guictrlstatusbar_settext($statusbar, "Open LAN!", 0)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$fakebtn = GUICtrlCreateButton("Fake IP -- ", 1
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$gamemode = GUICtrlCreateButton("Unblock --
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$tunneloff = GUICtrlCreateButton("Off Tunnel -- ", 10, 92, 1
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$tunnelon = GUICtrlCreateButton("On Tunnel -- ", 10,
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$learning = GUICtrlCreateButton("Learning --
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")

$customer = GUICtrlCreateButton("Customer -- ", 10, 18


GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$aboutus = GUICtrlCreateButton("About -- ", 10, 210, 180, 25
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$update = GUICtrlCreateButton("Update -- ",
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
#EndRegion GUI
GUICtrlSetState($fakebtn, 128)
GUICtrlSetState($gamemode, 128)
GUICtrlSetState($tunneloff, 128)
GUICtrlSetState($tunnelon, 128)
GUICtrlSetState($learning, 128)
GUICtrlSetState($customer, 128)
GUICtrlSetState($update, 128)
GUICtrlSetState($aboutus, 128)
Global $labelcopyright = GUICtrlCreateLabel("Copyright [2014 - " & @YEAR
& "]", 455, 318, 250, 160)
GUICtrlSetColor(-1, 1653337)
Global $labelunblock = GUICtrlCreateLabel("Unblock IP :", 240, 220, 100,
26)
GUICtrlSetBkColor(-1, 1653337)
GUICtrlSetColor(-1, 15096832)
GUICtrlSetState($labelunblock, 32)
Global $inputunblock = GUICtrlCreateInput("", 335, 220, 150, 26, BitOR($
gui_ss_default_input, $es_center))
GUICtrlSetColor(-1, 15096832)
GUICtrlSetState($inputunblock, 32)
Global $labelusername = GUICtrlCreateLabel("Username:", 235, 50, 80, 22)
GUICtrlSetBkColor(-1, 1653337)
GUICtrlSetColor(-1, 15096832)
Global $inputusername = GUICtrlCreateInput("", 335, 50, 162, 26, BitOR($
gui_ss_default_input, $es_center))
GUICtrlSetColor(-1, 15096832)
Global $labelpassword = GUICtrlCreateLabel("Password:", 235, 100, 78, 22
)
GUICtrlSetBkColor(-1, 1653337)
GUICtrlSetColor(-1, 15096832)
Global $inputpassword = GUICtrlCreateInput("", 335, 100, 162, 26, BitOR(
$gui_ss_default_input, $es_center, $es_password))
GUICtrlSetColor(-1, 15096832)
Global $buttonlogin = GUICtrlCreateButton("Login", 500, 100, 70, 25)
GUICtrlSetFont(-1, 10, 200, 1, "tahoma")
GUICtrlSetCursor(-1, 0)
GUICtrlSetState(-1, $gui_defbutton)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $labelfreeacc = GUICtrlCreateLabel(" ", 10, 285, 150, 25
GUICtrlSetFont(-1, 10, 200, 1, "tahoma")
GUICtrlSetBkColor(-1, 15096832)
GUICtrlSetColor(-1, 1653337)
Global $labelbuy = GUICtrlCreateLabel(" ", 173, 285, 150, 25)
GUICtrlSetFont(-1, 10, 200, 1, "tahoma")
GUICtrlSetBkColor(-1, 15096832)
GUICtrlSetColor(-1, 1653337)
Global $labelhomepage = GUICtrlCreateLabel(" ", 346, 285, 150, 25
GUICtrlSetFont(-1, 10, 200, 1, "tahoma")
GUICtrlSetBkColor(-1, 15096832)
GUICtrlSetColor(-1, 1653337)
Global $labelsupport = GUICtrlCreateLabel(" ", 560, 285, 60, 25)
GUICtrlSetFont(-1, 10, 200, 1, "tahoma")
GUICtrlSetBkColor(-1, 15096832)

GUICtrlSetColor(-1, 1653337)
If NOT $debug_mode Then togglecontrol(0)
#EndRegion GUI Login
Global $nmsg
While 1
$nmsg = GUIGetMsg()
Switch $nmsg
Case $learning
learning()
RunWait(@ComSpec & " /c " & "taskkill /f /IM cmd.exe")
MsgBox(64, "Anti-Hack.iR ::: Learning", "Don't Touch Any
thing ")
Run("notepad.exe")
WinWaitActive("[CLASS:Notepad]")
Send("~ English ~ {Enter}")
Send("1 ) Copy Your Garena In C:\Program Files\Garena Pl
us {Enter}")
Send("2 ) Open Anti-Hack Program {Enter}")
Send("3 ) Open Garena Plus (Simple And Or By Garena Mast
er ) {Enter}")
Send("4 ) Open Garena LAN {Enter}")
Send("5 ) Choise A Fake IP & Click On 'Fake' Button {Ent
er}")
Send("6 ) Enter In Room You Want {Enter}")
Send("7 ) Enjoy :) {Enter 2}")
Send("~Warning~ If You Have Any Problem Follow To Down {
Enter}")
Send("1 ) Off/On Your Internet Modem (Router) For 5 Sec
{Enter}")
Send("2 ) Delete Your Anti Virus {Enter 2}")
Send("~About Each Button~{Enter}")
Send("Fake : It's Do For Changing Your IP {Enter}")
Send("Off Tunnel : Disallow Members To Tunneling You :(
{Enter}")
Send("On Tunnel : It's Opiside Of Off Tunnel {Enter}")
Send("UnBlock IP : Before U Going To Any Host , Please U
nblock Host IP (Or Members) {Enter}")
Send("Learning : Teach You How This Program To Do {Enter
}")
Send("Customer : Members List And When They Account's Wi
ll Deactive {Enter}")
Send("About : Something About Autor (Mr..Mrs) {Enter}")
Send("Update : Know What Is Version And New Version {Ent
er 2}")
Send("~ Today : {F5} ~ {Enter}")
Send("Copyright 2015 http://Anti-Hack.iR {ENTER}")
Case $customer
customer()
Case $aboutus
aboutus()
Case $update
update()
Case $tunnelon
tunnelon()
Case $tunneloff
tunneloff()
Case $fakebtn
fakebtn()
Case $gamemode
gamemode()

eset")

Case $gui_event_close
Exit
Case $oclose
If GUICtrlRead($buttonlogin) = "Login" Then
RunWait(@ComSpec & " /c " & "netsh advfirewall r

RegWrite("HKEY_CURRENT_USER\Software\Policies\Mi
crosoft\MMC\FX:{b05566ac-fe9c-4368-be02-7a4cbb7cbe11}", "Restrict_Run", "REG_DWO
RD", "-")
#RequireAdmin
ProcessExists("mmc.exe")
RunWait(@ComSpec & " /c " & "taskkill /f /IM mmc
.exe")
Exit
EndIf
If GUICtrlRead($buttonlogin) = "Logout" Then
MsgBox(16, "Error", " " &
Else
Exit
EndIf
Case $labelbuy
labelbuy()
Case $labelfreeacc
labelfreeacc()
Case $labelhomepage
labelhomepage()
Case $labelsupport
labelsupport()
Case $buttonlogin
If _showerror = True Then
$debug_mode = False
Exit
Else
buttonloginclick()
If (GUICtrlRead($buttonlogin) = "Logout") Then
logout()
EndIf
EndIf
EndSwitch
checkgarena()
Sleep(10)
WEnd
Func labelbuy()
If $labelbuy = True Then
ShellExecute("http://ddos.anti-hack.ir")
EndIf
EndFunc
Func labelfreeacc()
If $labelfreeacc = True Then
ShellExecute("http://ddos.anti-hack.ir/free")
EndIf
EndFunc
Func labelhomepage()
If $labelhomepage = True Then
ShellExecute("http://anti-hack.ir")
EndIf
EndFunc

Func labelsupport()
If $labelsupport = True Then
ShellExecute("http://support.anti-hack.ir")
EndIf
EndFunc
Func learning()
If $learning = True Then
RunWait(@ComSpec & " /c " & "Data\learning.exe")
EndIf
EndFunc
Func customer()
If $customer = True Then
MsgBox(64, "Anti-Hack.iR", "It's Free For All <3")
EndIf
EndFunc
Func aboutus()
If $aboutus = True Then
MsgBox(64, "Anti-Hack.iR", "Mr..Mrs :)")
EndIf
EndFunc
Func update()
If $update = True Then
MsgBox(64, "Anti-Hack.iR", "Mr..Mrs :)")
EndIf
EndFunc
Func tunnelon()
If $isgarenaopen = True Then
RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\MMC\FX:{
b05566ac-fe9c-4368-be02-7a4cbb7cbe11}", "Restrict_Run", "REG_DWORD", "00000001")
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall delete r
ule name="Anti-Hack0006" protocol=UDP localport=1513')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall delete r
ule name="Anti-Hack0007" program="C:\Program Files\Garena Plus\Room\garena_room.
exe"')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall delete r
ule name="Anti-Hack0008" program="C:\Program Files\Garena Plus\ggdllhost.exe"')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall delete r
ule name="Anti-Hack0009" protocol=udp remoteport=1513')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall delete r
ule name="Anti-Hack0010" program="C:\Program Files\Garena Plus\Room\garena_room.
exe"')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule
name="Anti-Hack0001" dir=in action=allow protocol=UDP localport = 1513')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule
name="Anti-Hack0002" dir=in action=allow program="C:\Program Files\Garena Plus\
Room\garena_room.exe" enable=yes profile=public,domain,private')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule
name="Anti-Hack0003" dir=in action=allow program="C:\Program Files\Garena Plus\
ggdllhost.exe" enable=yes profile=public,domain,private')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule
name="Anti-Hack0004" dir=out action=allow protocol=UDP remoteport = 1513')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule
name="Anti-Hack0005" dir=out action=allow program="C:\Program Files\Garena Plus
\Room\garena_room.exe" enable=yes protocol=udp profile=public,domain,private')

Else
EndFunc

EndIf

MsgBox(16, "Error -- Developed By Mr..Mrs", "Open Garena Lan")

Func tunneloff()
If $isgarenaopen = True Then
RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\MMC\FX:{
b05566ac-fe9c-4368-be02-7a4cbb7cbe11}", "Restrict_Run", "REG_DWORD", "00000001")
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall delete r
ule name="Anti-Hack0001" protocol=UDP localport=1513')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall delete r
ule name="Anti-Hack0002" program="C:\Program Files\Garena Plus\Room\garena_room.
exe"')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall delete r
ule name="Anti-Hack0003" program="C:\Program Files\Garena Plus\ggdllhost.exe"')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall delete r
ule name="Anti-Hack0004" protocol=udp remoteport=1513')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall delete r
ule name="Anti-Hack0005" program="C:\Program Files\Garena Plus\Room\garena_room.
exe"')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule
name="Anti-Hack0006" dir=in action=block protocol=UDP localport = 1513')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule
name="Anti-Hack0007" dir=in action=block program="C:\Program Files\Garena Plus\
Room\garena_room.exe" enable=yes profile=public,domain,private')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule
name="Anti-Hack0008" dir=in action=block program="C:\Program Files\Garena Plus\
ggdllhost.exe" enable=yes profile=public,domain,private')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule
name="Anti-Hack0009" dir=out action=block protocol=UDP remoteport = 1513')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule
name="Anti-Hack0010" dir=out action=block program="C:\Program Files\Garena Plus
\Room\garena_room.exe" enable=yes protocol=udp profile=public,domain,private')
Else
MsgBox(16, "Error -- Developed By Mr..Mrs", "Open Garena Lan")
EndIf
EndFunc
Func fakebtn()
If $isgarenaopen = True Then
RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\MMC\FX:{
b05566ac-fe9c-4368-be02-7a4cbb7cbe11}", "Restrict_Run", "REG_DWORD", "00000001")
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule
name="Anti-HackEnt1" dir=in action=block protocol=UDP program="C:\Program Files
\Garena Plus\Room\garena_room.exe" remoteport = 7456 remoteip=0.0.0.0,127.0.0.1,
127.0.0.2-255.255.255.255')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule
name="Anti-HackEnt2" dir=in action=block protocol=TCP program="C:\Program Files
\Garena Plus\Room\garena_room.exe" remoteport = 7456 remoteip=0.0.0.0,127.0.0.1,
127.0.0.2-255.255.255.255')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule
name="Anti-HackEnt3" dir=out action=block protocol=UDP program="C:\Program File
s\Garena Plus\Room\garena_room.exe" remoteport = 7456 remoteip=0.0.0.0,127.0.0.1
,127.0.0.2-255.255.255.255')
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall add rule
name="Anti-HackEnt4" dir=out action=block protocol=TCP program="C:\Program File
s\Garena Plus\Room\garena_room.exe" remoteport = 7456 remoteip=0.0.0.0,127.0.0.1
,127.0.0.2-255.255.255.255')
_write($garenapid)

Else
EndFunc

EndIf

MsgBox(16, "Error -- Developed By Mr..Mrs", "Open Garena Lan")

Func gamemode()
If $isgarenaopen = True Then
If GUICtrlRead($inputunblock) = "" Then
MsgBox(16, "OopS!", "
Else
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall
add rule name="Unblock" dir=in action=allow profile=any localip=' & GUICtrlRead(
$inputunblock))
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall
add rule name="Unblock" dir=in action=allow profile=any remoteip=' & GUICtrlRead
($inputunblock))
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall
add rule name="Unblock" dir=out action=allow profile=any localip=' & GUICtrlRead
($inputunblock))
RunWait(@ComSpec & " /c " & 'netsh advfirewall firewall
add rule name="Unblock" dir=out action=allow profile=any remoteip=' & GUICtrlRea
d($inputunblock))
MsgBox(64, "Success!", "IP : " & GUICtrlRead($inputunblo
ck) & " Was Successfuly Unblock ")
EndIf
Else
MsgBox(16, "Error -- Developed By Mr..Mrs", "Open Garena Lan")
EndIf
EndFunc
Func checkgarena()
$garenapid = ProcessExists("garena_room.exe")
If $garenapid <> 0 Then
$modulehandle = _memorymodulegetbaseaddress($garenapid, "garena_
room.exe")
$isgarenaopen = True
_read($garenapid)
If getstatus() <> "Rdy For Fight" Then
setstatus("Rdy For Fight")
EndIf
Else
$isgarenaopen = False
If getstatus() <> "Open LAN!" Then
setstatus("Open LAN!")
EndIf
EndIf
EndFunc
Func setstatus($text)
_guictrlstatusbar_settext($statusbar, $text, 0)
EndFunc
Func getstatus()
Return _guictrlstatusbar_gettext($statusbar, 0)
EndFunc
Func _read($pid)
$memory = _memoryopen($pid)
$baseaddr = _memorymodulegetbaseaddress($pid, "garena_room.exe")
$firstaddress = $baseaddr + 2622304

EndFunc

$aval = _memoryread($firstaddress, $memory)


$dovom = _memoryread($aval + 4, $memory)
$sevom = Hex(_memoryread($dovom + 28, $memory), 8)
setcurrentip(String($sevom))
_memoryclose($memory)

Func _write($pid)
$memory = _memoryopen($pid)
$baseaddr = _memorymodulegetbaseaddress($pid, "garena_room.exe")
$firstaddress = $baseaddr + 2622304
$aval = _memoryread($firstaddress, $memory)
$dovom = _memoryread($aval + 4, $memory)
If getstatus() <> "Bing O Bing O ..." Then
setstatus("Bing O Bing O ...")
Sleep(1000)
EndIf
Local $ip = StringSplit(_guictrlipaddress_get($ipaddress_new), ".")
$ip[1] = Hex($ip[1], 2)
$ip[2] = Hex($ip[2], 2)
$ip[3] = Hex($ip[3], 2)
$ip[4] = Hex($ip[4], 2)
$final = Binary("0x" & $ip[1] & $ip[2] & $ip[3] & $ip[4])
If getstatus() <> "Fake IP Will Be Doing !!!" Then
setstatus("Fake IP Will Be Doing !!!")
Sleep(1000)
EndIf
If _memorywrite($dovom + 28, $memory, $final) = 1 Then
If getstatus() <> "Fake IP Will Be Doing !!!" Then
setstatus("Fake IP Will Be Doing !!!")
Sleep(1000)
EndIf
If getstatus() <> "Fixed" Then
setstatus("Fixed")
Sleep(500)
EndIf
Else
If getstatus() <> "Failed !" Then
setstatus("Failed !")
Sleep(500)
EndIf
EndIf
_memoryclose($memory)
EndFunc
Func setcurrentip($binary)
Local $ip[4]
$ip[0] = Dec(StringMid($binary, 7, 2))
$ip[1] = Dec(StringMid($binary, 5, 2))
$ip[2] = Dec(StringMid($binary, 3, 2))
$ip[3] = Dec(StringMid($binary, 1, 2))
_guictrlipaddress_set($ipaddress_current, $ip[0] & "." & $ip[1] & "." &
$ip[2] & "." & $ip[3])
EndFunc
Func _memorymodulegetbaseaddress($ipid, $smodule)
If NOT ProcessExists($ipid) Then Return SetError(1, 0, 0)
If NOT IsString($smodule) Then Return SetError(2, 0, 0)
Local $psapi = DllOpen("psapi.dll")
Local $hprocess

Local $permission = BitOR(2, 1024, 8, 16, 32)


If $ipid > 0 Then
Local $hprocess = DllCall("kernel32.dll", "ptr", "OpenProcess",
"dword", $permission, "int", 0, "dword", $ipid)
If $hprocess[0] Then
$hprocess = $hprocess[0]
EndIf
EndIf
Local $modules = DllStructCreate("ptr[1024]")
Local $acall = DllCall($psapi, "int", "EnumProcessModules", "ptr", $hpro
cess, "ptr", DllStructGetPtr($modules), "dword", DllStructGetSize($modules), "dw
ord*", 0)
If $acall[4] > 0 Then
Local $imodnum = $acall[4] / 4
Local $atemp
For $i = 1 To $imodnum
$atemp = DllCall($psapi, "dword", "GetModuleBaseNameW",
"ptr", $hprocess, "ptr", Ptr(DllStructGetData($modules, 1, $i)), "wstr", "", "dw
ord", 260)
If $atemp[3] = $smodule Then
DllClose($psapi)
Return Ptr(DllStructGetData($modules, 1, $i))
EndIf
Next
EndIf
DllClose($psapi)
Return SetError(-1, 0, 0)
EndFunc
Func buttonloginclick()
Local $username, $password
$username = GUICtrlRead($inputusername)
If NOT $username Then
_showerror("Enter Your Username!", $inputusername)
Return False
EndIf
$password = GUICtrlRead($inputpassword)
If NOT $password Then
_showerror("Enter Your Password!", $inputpassword)
Return False
EndIf
GUICtrlSetState($inputusername, $gui_disable)
GUICtrlSetState($inputpassword, $gui_disable)
GUICtrlSetState($buttonlogin, $gui_disable)
Local $data, $request
$data = "username=" & urlencode($username)
$data &= "&password=" & urlencode($password)
$request = _httprequest($endpoint_login, "POST", $data)
If $debug_mode Then _arraydisplay($request)
Local $json = json_decode($request[2])
Local $success = json_get($json, '["success"]')
GUICtrlSetState($inputusername, $gui_enable)
GUICtrlSetState($inputpassword, $gui_enable)
GUICtrlSetState($buttonlogin, $gui_enable)
If $success Then
GUICtrlSetState($labelbuy, 32)
GUICtrlSetState($labelfreeacc, 32)
GUICtrlSetState($labelunblock, 16)
GUICtrlSetState($inputunblock, 16)
GUICtrlSetState($fakebtn, 64)

Else

EndFunc

EndIf

GUICtrlSetState($gamemode, 64)
GUICtrlSetState($tunnelall, 64)
GUICtrlSetState($tunneloff, 64)
GUICtrlSetState($tunnelon, 64)
GUICtrlSetState($learning, 64)
GUICtrlSetState($customer, 64)
GUICtrlSetState($update, 64)
GUICtrlSetState($aboutus, 64)
GUICtrlSetState($inputusername, $gui_disable)
GUICtrlSetState($inputpassword, $gui_disable)
GUICtrlSetData($buttonlogin, "Logout")
GUICtrlSetOnEvent($buttonlogin, "Logout")
GUICtrlSetState($buttonlogin, $gui_enable)
togglecontrol(1)
Return True

Local $errorcode = json_get($json, '["data"]')


If $errorcode = -1 Then
_showerror("
Return False
Else
_showerror(" : " & $username & "
Return False
EndIf

Func _showerror($errormsg, $ctrid = Default)


MsgBox(64 + 262144, " -- System Message", $errormsg, 0, $mainform)
If $ctrid <> Default Then GUICtrlSetState($ctrid, $gui_focus)
EndFunc
Func logout()
If NOT $debug_mode Then
If MsgBox(32 + 4 + 256 + 262144, "
EndIf
Local $username, $data, $request
$username = GUICtrlRead($inputusername)
$data = "username=" & urlencode($username)
$request = _httprequest($endpoint_logout, "POST", $data)
Local $json = json_decode($request[2])
Local $success = json_get($json, '["success"]')
If $debug_mode Then _arraydisplay($request)
If $success Then
GUICtrlSetState($labelbuy, 16)
GUICtrlSetState($labelfreeacc, 16)
GUICtrlSetState($labelunblock, 32)
GUICtrlSetState($inputunblock, 32)
GUICtrlSetState($fakebtn, 128)
GUICtrlSetState($gamemode, 128)
GUICtrlSetState($tunnelall, 128)
GUICtrlSetState($tunneloff, 128)
GUICtrlSetState($tunnelon, 128)
GUICtrlSetState($learning, 128)
GUICtrlSetState($customer, 128)
GUICtrlSetState($update, 128)
GUICtrlSetState($aboutus, 128)
GUICtrlSetData($inputusername, "")
GUICtrlSetData($inputpassword, "")
GUICtrlSetState($inputusername, $gui_enable)

-- System Message", "

Else

EndFunc

EndIf

GUICtrlSetState($inputpassword, $gui_enable)
GUICtrlSetData($buttonlogin, "Login")
GUICtrlSetOnEvent($buttonlogin, "ButtonLoginClick")
GUICtrlSetState($inputusername, $gui_focus)
If NOT $debug_mode Then togglecontrol(0)
Return True
_showerror("!
Return False

" &

Func togglecontrol($state = 1)
$state = ($state = 1) ? 64 : 128
EndFunc
Func _ucfirst($str)
Return StringUpper(StringMid($str, 1, 1)) & StringMid($str, 2)
EndFunc

Global $currentip, $garenapid, $isgarenaopen, $modulehandle


Global $mainform, $label1, $ipaddress_current, $label2, $ipaddress_new, $statusb
ar, $learning, $customer, $aboutus, $update, $tunnelon, $tunneloff, $tunnelall,
$gamemode, $fakebtn
#Region GUI
$label1 = GUICtrlCreateLabel("Your IP :", 275, 170, 180, 25)
GUICtrlSetBkColor(-1, 1653337)
GUICtrlSetColor(-1, 15096832)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$ipaddress_current = _guictrlipaddress_create($mainform, 205, 185, 180,
25)
_guictrlipaddress_set($ipaddress_current, "0.0.0.0")
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$label2 = GUICtrlCreateLabel("Fake IP :", 495, 170, 180, 25)
GUICtrlSetBkColor(-1, 1653337)
GUICtrlSetColor(-1, 15096832)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$ipaddress_new = _guictrlipaddress_create($mainform, 425, 185, 180, 25)
_guictrlipaddress_set($ipaddress_new, "0.0.0.0")
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$statusbar = _guictrlstatusbar_create($mainform)
Dim $statusbar_partswidth[1] = [-1]
_guictrlstatusbar_setparts($statusbar, $statusbar_partswidth)
_guictrlstatusbar_settext($statusbar, "Open LAN!", 0)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$fakebtn = GUICtrlCreateButton("Fake IP -- ", 10, 25, 1
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$gamemode = GUICtrlCreateButton("Unblock -- ",
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$tunneloff = GUICtrlCreateButton("Off Tunnel -- ", 10, 92, 180, 25)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$tunnelon = GUICtrlCreateButton("On Tunnel -- ", 10, 117, 180
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$learning = GUICtrlCreateButton("Learning --
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$customer = GUICtrlCreateButton("Customer -- ", 10, 188, 180,
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$aboutus = GUICtrlCreateButton("About -- ", 10, 210, 180, 25)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$update = GUICtrlCreateButton("Update -- ", 10, 235

GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")


#EndRegion GUI
GUICtrlSetState($fakebtn, 128)
GUICtrlSetState($gamemode, 128)
GUICtrlSetState($tunneloff, 128)
GUICtrlSetState($tunnelon, 128)
GUICtrlSetState($learning, 128)
GUICtrlSetState($customer, 128)
GUICtrlSetState($update, 128)
GUICtrlSetState($aboutus, 128)

You might also like