Advertisement
Guest User

Sillyre bot decompiled

a guest
Nov 5th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 276.69 KB | None | 0 0
  1. #RequireAdmin
  2. Global Const $fc_nooverwrite = 0
  3. Global Const $fc_overwrite = 1
  4. Global Const $fc_createpath = 8
  5. Global Const $ft_modified = 0
  6. Global Const $ft_created = 1
  7. Global Const $ft_accessed = 2
  8. Global Const $ft_array = 0
  9. Global Const $ft_string = 1
  10. Global Const $fsf_createbutton = 1
  11. Global Const $fsf_newdialog = 2
  12. Global Const $fsf_editcontrol = 4
  13. Global Const $ft_nonrecursive = 0
  14. Global Const $ft_recursive = 1
  15. Global Const $fo_read = 0
  16. Global Const $fo_append = 1
  17. Global Const $fo_overwrite = 2
  18. Global Const $fo_createpath = 8
  19. Global Const $fo_binary = 16
  20. Global Const $fo_unicode = 32
  21. Global Const $fo_utf16_le = 32
  22. Global Const $fo_utf16_be = 64
  23. Global Const $fo_utf8 = 128
  24. Global Const $fo_utf8_nobom = 256
  25. Global Const $fo_ansi = 512
  26. Global Const $fo_utf16_le_nobom = 1024
  27. Global Const $fo_utf16_be_nobom = 2048
  28. Global Const $fo_utf8_full = 16384
  29. Global Const $fo_fullfile_detect = 16384
  30. Global Const $eof = -1
  31. Global Const $fd_filemustexist = 1
  32. Global Const $fd_pathmustexist = 2
  33. Global Const $fd_multiselect = 4
  34. Global Const $fd_promptcreatenew = 8
  35. Global Const $fd_promptoverwrite = 16
  36. Global Const $create_new = 1
  37. Global Const $create_always = 2
  38. Global Const $open_existing = 3
  39. Global Const $open_always = 4
  40. Global Const $truncate_existing = 5
  41. Global Const $invalid_set_file_pointer = -1
  42. Global Const $file_begin = 0
  43. Global Const $file_current = 1
  44. Global Const $file_end = 2
  45. Global Const $file_attribute_readonly = 1
  46. Global Const $file_attribute_hidden = 2
  47. Global Const $file_attribute_system = 4
  48. Global Const $file_attribute_directory = 16
  49. Global Const $file_attribute_archive = 32
  50. Global Const $file_attribute_device = 64
  51. Global Const $file_attribute_normal = 128
  52. Global Const $file_attribute_temporary = 256
  53. Global Const $file_attribute_sparse_file = 512
  54. Global Const $file_attribute_reparse_point = 1024
  55. Global Const $file_attribute_compressed = 2048
  56. Global Const $file_attribute_offline = 4096
  57. Global Const $file_attribute_not_content_indexed = 8192
  58. Global Const $file_attribute_encrypted = 16384
  59. Global Const $file_share_read = 1
  60. Global Const $file_share_write = 2
  61. Global Const $file_share_delete = 4
  62. Global Const $file_share_readwrite = BitOR($file_share_read, $file_share_write)
  63. Global Const $file_share_any = BitOR($file_share_read, $file_share_write, $file_share_delete)
  64. Global Const $generic_all = 268435456
  65. Global Const $generic_execute = 536870912
  66. Global Const $generic_write = 1073741824
  67. Global Const $generic_read = -2147483648
  68. Global Const $generic_readwrite = BitOR($generic_read, $generic_write)
  69. Global Const $file_encoding_utf16le = 32
  70. Global Const $fe_entire_utf8 = 1
  71. Global Const $fe_partialfirst_utf8 = 2
  72. Global Const $fn_fullpath = 0
  73. Global Const $fn_relativepath = 1
  74. Global Const $fv_comments = "Comments"
  75. Global Const $fv_companyname = "CompanyName"
  76. Global Const $fv_filedescription = "FileDescription"
  77. Global Const $fv_fileversion = "FileVersion"
  78. Global Const $fv_internalname = "InternalName"
  79. Global Const $fv_legalcopyright = "LegalCopyright"
  80. Global Const $fv_legaltrademarks = "LegalTrademarks"
  81. Global Const $fv_originalfilename = "OriginalFilename"
  82. Global Const $fv_productname = "ProductName"
  83. Global Const $fv_productversion = "ProductVersion"
  84. Global Const $fv_privatebuild = "PrivateBuild"
  85. Global Const $fv_specialbuild = "SpecialBuild"
  86. Global Const $frta_nocount = 0
  87. Global Const $frta_count = 1
  88. Global Const $frta_intarrays = 2
  89. Global Const $frta_entiresplit = 4
  90. Global Const $flta_filesfolders = 0
  91. Global Const $flta_files = 1
  92. Global Const $flta_folders = 2
  93. Global Const $fltar_filesfolders = 0
  94. Global Const $fltar_files = 1
  95. Global Const $fltar_folders = 2
  96. Global Const $fltar_nohidden = 4
  97. Global Const $fltar_nosystem = 8
  98. Global Const $fltar_nolink = 16
  99. Global Const $fltar_norecur = 0
  100. Global Const $fltar_recur = 1
  101. Global Const $fltar_nosort = 0
  102. Global Const $fltar_sort = 1
  103. Global Const $fltar_fastsort = 2
  104. Global Const $fltar_nopath = 0
  105. Global Const $fltar_relpath = 1
  106. Global Const $fltar_fullpath = 2
  107. Global Const $path_original = 0
  108. Global Const $path_drive = 1
  109. Global Const $path_directory = 2
  110. Global Const $path_filename = 3
  111. Global Const $path_extension = 4
  112. Global Const $mb_ok = 0
  113. Global Const $mb_okcancel = 1
  114. Global Const $mb_abortretryignore = 2
  115. Global Const $mb_yesnocancel = 3
  116. Global Const $mb_yesno = 4
  117. Global Const $mb_retrycancel = 5
  118. Global Const $mb_canceltrycontinue = 6
  119. Global Const $mb_help = 16384
  120. Global Const $mb_iconstop = 16
  121. Global Const $mb_iconerror = 16
  122. Global Const $mb_iconhand = 16
  123. Global Const $mb_iconquestion = 32
  124. Global Const $mb_iconexclamation = 48
  125. Global Const $mb_iconwarning = 48
  126. Global Const $mb_iconinformation = 64
  127. Global Const $mb_iconasterisk = 64
  128. Global Const $mb_usericon = 128
  129. Global Const $mb_defbutton1 = 0
  130. Global Const $mb_defbutton2 = 256
  131. Global Const $mb_defbutton3 = 512
  132. Global Const $mb_defbutton4 = 768
  133. Global Const $mb_applmodal = 0
  134. Global Const $mb_systemmodal = 4096
  135. Global Const $mb_taskmodal = 8192
  136. Global Const $mb_default_desktop_only = 131072
  137. Global Const $mb_right = 524288
  138. Global Const $mb_rtlreading = 1048576
  139. Global Const $mb_setforeground = 65536
  140. Global Const $mb_topmost = 262144
  141. Global Const $mb_service_notification = 2097152
  142. Global Const $mb_rightjustified = $mb_right
  143. Global Const $idtimeout = -1
  144. Global Const $idok = 1
  145. Global Const $idcancel = 2
  146. Global Const $idabort = 3
  147. Global Const $idretry = 4
  148. Global Const $idignore = 5
  149. Global Const $idyes = 6
  150. Global Const $idno = 7
  151. Global Const $idclose = 8
  152. Global Const $idhelp = 9
  153. Global Const $idtryagain = 10
  154. Global Const $idcontinue = 11
  155. Global Const $str_nocasesense = 0
  156. Global Const $str_casesense = 1
  157. Global Const $str_nocasesensebasic = 2
  158. Global Const $str_stripleading = 1
  159. Global Const $str_striptrailing = 2
  160. Global Const $str_stripspaces = 4
  161. Global Const $str_stripall = 8
  162. Global Const $str_chrsplit = 0
  163. Global Const $str_entiresplit = 1
  164. Global Const $str_nocount = 2
  165. Global Const $str_regexpmatch = 0
  166. Global Const $str_regexparraymatch = 1
  167. Global Const $str_regexparrayfullmatch = 2
  168. Global Const $str_regexparrayglobalmatch = 3
  169. Global Const $str_regexparrayglobalfullmatch = 4
  170. Global Const $str_endisstart = 0
  171. Global Const $str_endnotstart = 1
  172. Global Const $sb_ansi = 1
  173. Global Const $sb_utf16le = 2
  174. Global Const $sb_utf16be = 3
  175. Global Const $sb_utf8 = 4
  176. Global Const $se_utf16 = 0
  177. Global Const $se_ansi = 1
  178. Global Const $se_utf8 = 2
  179. Global Const $str_utf16 = 0
  180. Global Const $str_ucs2 = 1
  181. #Region Global Variables and Constants
  182. Global Const $format_message_allocate_buffer = 256
  183. Global Const $format_message_ignore_inserts = 512
  184. Global Const $format_message_from_string = 1024
  185. Global Const $format_message_from_hmodule = 2048
  186. Global Const $format_message_from_system = 4096
  187. Global Const $format_message_argument_array = 8192
  188. #EndRegion Global Variables and Constants
  189.  
  190. Func _winapi_beep($ifreq = 500, $iduration = 1000)
  191. Local $aresult = DllCall("kernel32.dll", "bool", "Beep", "dword", $ifreq, "dword", $iduration)
  192. If @error Then Return SetError(@error, @extended, False)
  193. Return $aresult[0]
  194. EndFunc
  195.  
  196. Func _winapi_formatmessage($iflags, $psource, $imessageid, $ilanguageid, ByRef $pbuffer, $isize, $varguments)
  197. Local $sbuffertype = "struct*"
  198. If IsString($pbuffer) Then $sbuffertype = "wstr"
  199. Local $aresult = DllCall("kernel32.dll", "dword", "FormatMessageW", "dword", $iflags, "struct*", $psource, "dword", $imessageid, "dword", $ilanguageid, $sbuffertype, $pbuffer, "dword", $isize, "ptr", $varguments)
  200. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
  201. If $sbuffertype = "wstr" Then $pbuffer = $aresult[5]
  202. Return $aresult[0]
  203. EndFunc
  204.  
  205. Func _winapi_geterrormessage($icode, $ilanguage = 0, Const $_icurrenterror = @error, Const $_icurrentextended = @extended)
  206. Local $aret = DllCall("kernel32.dll", "dword", "FormatMessageW", "dword", 4096, "ptr", 0, "dword", $icode, "dword", $ilanguage, "wstr", "", "dword", 4096, "ptr", 0)
  207. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  208. Return SetError($_icurrenterror, $_icurrentextended, StringRegExpReplace($aret[5], "[" & @LF & "," & @CR & "]*\Z", ""))
  209. EndFunc
  210.  
  211. Func _winapi_getlasterror(Const $_icurrenterror = @error, Const $_icurrentextended = @extended)
  212. Local $aresult = DllCall("kernel32.dll", "dword", "GetLastError")
  213. Return SetError($_icurrenterror, $_icurrentextended, $aresult[0])
  214. EndFunc
  215.  
  216. Func _winapi_getlasterrormessage(Const $_icurrenterror = @error, Const $_icurrentextended = @extended)
  217. Local $ilasterror = _winapi_getlasterror()
  218. Local $tbufferptr = DllStructCreate("ptr")
  219. Local $ncount = _winapi_formatmessage(BitOR($format_message_allocate_buffer, $format_message_from_system), 0, $ilasterror, 0, $tbufferptr, 0, 0)
  220. If @error Then Return SetError(-@error, @extended, "")
  221. Local $stext = ""
  222. Local $pbuffer = DllStructGetData($tbufferptr, 1)
  223. If $pbuffer Then
  224. If $ncount > 0 Then
  225. Local $tbuffer = DllStructCreate("wchar[" & ($ncount + 1) & "]", $pbuffer)
  226. $stext = DllStructGetData($tbuffer, 1)
  227. If StringRight($stext, 2) = @CRLF Then $stext = StringTrimRight($stext, 2)
  228. EndIf
  229. DllCall("kernel32.dll", "handle", "LocalFree", "handle", $pbuffer)
  230. EndIf
  231. Return SetError($_icurrenterror, $_icurrentextended, $stext)
  232. EndFunc
  233.  
  234. Func _winapi_messagebeep($itype = 1)
  235. Local $isound
  236. Switch $itype
  237. Case 1
  238. $isound = 0
  239. Case 2
  240. $isound = 16
  241. Case 3
  242. $isound = 32
  243. Case 4
  244. $isound = 48
  245. Case 5
  246. $isound = 64
  247. Case Else
  248. $isound = -1
  249. EndSwitch
  250. Local $aresult = DllCall("user32.dll", "bool", "MessageBeep", "uint", $isound)
  251. If @error Then Return SetError(@error, @extended, False)
  252. Return $aresult[0]
  253. EndFunc
  254.  
  255. Func _winapi_msgbox($iflags, $stitle, $stext)
  256. BlockInput(0)
  257. MsgBox($iflags, $stitle, $stext & " ")
  258. EndFunc
  259.  
  260. Func _winapi_setlasterror($ierrorcode, Const $_icurrenterror = @error, Const $_icurrentextended = @extended)
  261. DllCall("kernel32.dll", "none", "SetLastError", "dword", $ierrorcode)
  262. Return SetError($_icurrenterror, $_icurrentextended, NULL )
  263. EndFunc
  264.  
  265. Func _winapi_showerror($stext, $bexit = True)
  266. BlockInput(0)
  267. MsgBox($mb_systemmodal, "Error", $stext & " ")
  268. If $bexit Then Exit
  269. EndFunc
  270.  
  271. Func _winapi_showlasterror($stext = "", $babort = False, $ilanguage = 0, Const $_icurrenterror = @error, Const $_icurrentextended = @extended)
  272. Local $serror
  273. Local $ilasterror = _winapi_getlasterror()
  274. While 1
  275. $serror = _winapi_geterrormessage($ilasterror, $ilanguage)
  276. If @error AND $ilanguage Then
  277. $ilanguage = 0
  278. Else
  279. ExitLoop
  280. EndIf
  281. WEnd
  282. If StringStripWS($stext, $str_stripleading + $str_striptrailing) Then
  283. $stext &= @CRLF & @CRLF
  284. Else
  285. $stext = ""
  286. EndIf
  287. _winapi_msgbox(BitOR(262144, BitShift(16, -2 * (NOT $ilasterror))), $ilasterror, $stext & $serror)
  288. If $ilasterror Then
  289. _winapi_setlasterror($ilasterror)
  290. If $babort Then
  291. Exit $ilasterror
  292. EndIf
  293. EndIf
  294. Return SetError($_icurrenterror, $_icurrentextended, 1)
  295. EndFunc
  296.  
  297. Func _winapi_showmsg($stext)
  298. _winapi_msgbox($mb_systemmodal, "Information", $stext)
  299. EndFunc
  300.  
  301. Func __comerrorformating(ByRef $ocomerror, $sprefix = @TAB)
  302. Local Const $str_striptrailing = 2
  303. Local $serror = "COM Error encountered in " & @ScriptName & " (" & $ocomerror.scriptline & ") :" & @CRLF & $sprefix & "Number " & @TAB & "= 0x" & Hex($ocomerror.number, 8) & " (" & $ocomerror.number & ")" & @CRLF & $sprefix & "WinDescription" & @TAB & "= " & StringStripWS($ocomerror.windescription, $str_striptrailing) & @CRLF & $sprefix & "Description " & @TAB & "= " & StringStripWS($ocomerror.description, $str_striptrailing) & @CRLF & $sprefix & "Source " & @TAB & "= " & $ocomerror.source & @CRLF & $sprefix & "HelpFile " & @TAB & "= " & $ocomerror.helpfile & @CRLF & $sprefix & "HelpContext " & @TAB & "= " & $ocomerror.helpcontext & @CRLF & $sprefix & "LastDllError " & @TAB & "= " & $ocomerror.lastdllerror & @CRLF & $sprefix & "Retcode " & @TAB & "= 0x" & Hex($ocomerror.retcode)
  304. Return $serror
  305. EndFunc
  306.  
  307. Global Const $prov_rsa_full = 1
  308. Global Const $prov_rsa_aes = 24
  309. Global Const $crypt_verifycontext = -268435456
  310. Global Const $hp_hashsize = 4
  311. Global Const $hp_hashval = 2
  312. Global Const $crypt_exportable = 1
  313. Global Const $crypt_userdata = 1
  314. Global Const $kp_algid = 7
  315. Global Const $calg_md2 = 32769
  316. Global Const $calg_md4 = 32770
  317. Global Const $calg_md5 = 32771
  318. Global Const $calg_sha1 = 32772
  319. Global Const $calg_sha_256 = 32780
  320. Global Const $calg_sha_384 = 32781
  321. Global Const $calg_sha_512 = 32782
  322. Global Const $calg_3des = 26115
  323. Global Const $calg_aes_128 = 26126
  324. Global Const $calg_aes_192 = 26127
  325. Global Const $calg_aes_256 = 26128
  326. Global Const $calg_des = 26113
  327. Global Const $calg_rc2 = 26114
  328. Global Const $calg_rc4 = 26625
  329. Global Const $calg_userkey = 0
  330. Global $__g_acryptinternaldata[3]
  331.  
  332. Func _crypt_startup()
  333. If __crypt_refcount() = 0 Then
  334. Local $hadvapi32 = DllOpen("Advapi32.dll")
  335. If $hadvapi32 = -1 Then Return SetError(1001, 0, False)
  336. __crypt_dllhandleset($hadvapi32)
  337. Local $iproviderid = $prov_rsa_aes
  338. Local $aret = DllCall(__crypt_dllhandle(), "bool", "CryptAcquireContext", "handle*", 0, "ptr", 0, "ptr", 0, "dword", $iproviderid, "dword", $crypt_verifycontext)
  339. If @error OR NOT $aret[0] Then
  340. Local $ierror = @error + 1002, $iextended = @extended
  341. If NOT $aret[0] Then $iextended = _winapi_getlasterror()
  342. DllClose(__crypt_dllhandle())
  343. Return SetError($ierror, $iextended, False)
  344. Else
  345. __crypt_contextset($aret[1])
  346. EndIf
  347. EndIf
  348. __crypt_refcountinc()
  349. Return True
  350. EndFunc
  351.  
  352. Func _crypt_shutdown()
  353. __crypt_refcountdec()
  354. If __crypt_refcount() = 0 Then
  355. DllCall(__crypt_dllhandle(), "bool", "CryptReleaseContext", "handle", __crypt_context(), "dword", 0)
  356. DllClose(__crypt_dllhandle())
  357. EndIf
  358. EndFunc
  359.  
  360. Func _crypt_derivekey($vpassword, $ialgid, $ihashpasswordid = $calg_md5)
  361. Local $aret = 0, $tbuff = 0, $hcrypthash = 0, $ierror = 0, $iextended = 0, $vreturn = 0
  362. _crypt_startup()
  363. If @error Then Return SetError(@error, @extended, -1)
  364. Do
  365. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptCreateHash", "handle", __crypt_context(), "uint", $ihashpasswordid, "ptr", 0, "dword", 0, "handle*", 0)
  366. If @error OR NOT $aret[0] Then
  367. $ierror = @error + 10
  368. $iextended = @extended
  369. If NOT $aret[0] Then $iextended = _winapi_getlasterror()
  370. $vreturn = -1
  371. ExitLoop
  372. EndIf
  373. $hcrypthash = $aret[5]
  374. $tbuff = DllStructCreate("byte[" & BinaryLen($vpassword) & "]")
  375. DllStructSetData($tbuff, 1, $vpassword)
  376. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptHashData", "handle", $hcrypthash, "struct*", $tbuff, "dword", DllStructGetSize($tbuff), "dword", $crypt_userdata)
  377. If @error OR NOT $aret[0] Then
  378. $ierror = @error + 20
  379. $iextended = @extended
  380. If NOT $aret[0] Then $iextended = _winapi_getlasterror()
  381. $vreturn = -1
  382. ExitLoop
  383. EndIf
  384. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptDeriveKey", "handle", __crypt_context(), "uint", $ialgid, "handle", $hcrypthash, "dword", $crypt_exportable, "handle*", 0)
  385. If @error OR NOT $aret[0] Then
  386. $ierror = @error + 30
  387. $iextended = @extended
  388. If NOT $aret[0] Then $iextended = _winapi_getlasterror()
  389. $vreturn = -1
  390. ExitLoop
  391. EndIf
  392. $vreturn = $aret[5]
  393. Until True
  394. If $hcrypthash <> 0 Then DllCall(__crypt_dllhandle(), "bool", "CryptDestroyHash", "handle", $hcrypthash)
  395. Return SetError($ierror, $iextended, $vreturn)
  396. EndFunc
  397.  
  398. Func _crypt_destroykey($hcryptkey)
  399. Local $aret = DllCall(__crypt_dllhandle(), "bool", "CryptDestroyKey", "handle", $hcryptkey)
  400. Local $ierror = @error, $iextended = @extended
  401. If NOT $aret[0] Then $iextended = _winapi_getlasterror()
  402. _crypt_shutdown()
  403. If $ierror OR NOT $aret[0] Then
  404. Return SetError($ierror + 10, $iextended, False)
  405. Else
  406. Return True
  407. EndIf
  408. EndFunc
  409.  
  410. Func _crypt_encryptdata($vdata, $vcryptkey, $ialgid, $bfinal = True)
  411. Switch $ialgid
  412. Case $calg_userkey
  413. Local $icalgused = __crypt_getcalgfromcryptkey($vcryptkey)
  414. If @error Then Return SetError(@error, @extended, -1)
  415. If $icalgused = $calg_rc4 Then ContinueCase
  416. Case $calg_rc4
  417. If BinaryLen($vdata) = 0 Then Return SetError(0, 0, Binary(""))
  418. EndSwitch
  419. Local $ireqbuffsize = 0, $aret = 0, $tbuff = 0, $ierror = 0, $iextended = 0, $vreturn = 0
  420. _crypt_startup()
  421. If @error Then Return SetError(@error, @extended, -1)
  422. Do
  423. If $ialgid <> $calg_userkey Then
  424. $vcryptkey = _crypt_derivekey($vcryptkey, $ialgid)
  425. If @error Then
  426. $ierror = @error
  427. $iextended = @extended
  428. $vreturn = -1
  429. ExitLoop
  430. EndIf
  431. EndIf
  432. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptEncrypt", "handle", $vcryptkey, "handle", 0, "bool", $bfinal, "dword", 0, "ptr", 0, "dword*", BinaryLen($vdata), "dword", 0)
  433. If @error OR NOT $aret[0] Then
  434. $ierror = @error + 50
  435. $iextended = @extended
  436. If NOT $aret[0] Then $iextended = _winapi_getlasterror()
  437. $vreturn = -1
  438. ExitLoop
  439. EndIf
  440. $ireqbuffsize = $aret[6]
  441. $tbuff = DllStructCreate("byte[" & $ireqbuffsize + 1 & "]")
  442. DllStructSetData($tbuff, 1, $vdata)
  443. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptEncrypt", "handle", $vcryptkey, "handle", 0, "bool", $bfinal, "dword", 0, "struct*", $tbuff, "dword*", BinaryLen($vdata), "dword", $ireqbuffsize)
  444. If @error OR NOT $aret[0] Then
  445. $ierror = @error + 60
  446. $iextended = @extended
  447. If NOT $aret[0] Then $iextended = _winapi_getlasterror()
  448. $vreturn = -1
  449. ExitLoop
  450. EndIf
  451. $vreturn = BinaryMid(DllStructGetData($tbuff, 1), 1, $ireqbuffsize)
  452. Until True
  453. If $ialgid <> $calg_userkey Then _crypt_destroykey($vcryptkey)
  454. _crypt_shutdown()
  455. Return SetError($ierror, $iextended, $vreturn)
  456. EndFunc
  457.  
  458. Func _crypt_decryptdata($vdata, $vcryptkey, $ialgid, $bfinal = True)
  459. Switch $ialgid
  460. Case $calg_userkey
  461. Local $icalgused = __crypt_getcalgfromcryptkey($vcryptkey)
  462. If @error Then Return SetError(@error, @extended, -1)
  463. If $icalgused = $calg_rc4 Then ContinueCase
  464. Case $calg_rc4
  465. If BinaryLen($vdata) = 0 Then Return SetError(0, 0, Binary(""))
  466. EndSwitch
  467. Local $aret = 0, $tbuff = 0, $ttempstruct = 0, $ierror = 0, $iextended = 0, $iplaintextsize = 0, $vreturn = 0
  468. _crypt_startup()
  469. If @error Then Return SetError(@error, @extended, -1)
  470. Do
  471. If $ialgid <> $calg_userkey Then
  472. $vcryptkey = _crypt_derivekey($vcryptkey, $ialgid)
  473. If @error Then
  474. $ierror = @error
  475. $iextended = @extended
  476. $vreturn = -1
  477. ExitLoop
  478. EndIf
  479. EndIf
  480. $tbuff = DllStructCreate("byte[" & BinaryLen($vdata) + 1000 & "]")
  481. If BinaryLen($vdata) > 0 Then DllStructSetData($tbuff, 1, $vdata)
  482. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptDecrypt", "handle", $vcryptkey, "handle", 0, "bool", $bfinal, "dword", 0, "struct*", $tbuff, "dword*", BinaryLen($vdata))
  483. If @error OR NOT $aret[0] Then
  484. $ierror = @error + 70
  485. $iextended = @extended
  486. If NOT $aret[0] Then $iextended = _winapi_getlasterror()
  487. $vreturn = -1
  488. ExitLoop
  489. EndIf
  490. $iplaintextsize = $aret[6]
  491. $ttempstruct = DllStructCreate("byte[" & $iplaintextsize + 1 & "]", DllStructGetPtr($tbuff))
  492. $vreturn = BinaryMid(DllStructGetData($ttempstruct, 1), 1, $iplaintextsize)
  493. Until True
  494. If $ialgid <> $calg_userkey Then _crypt_destroykey($vcryptkey)
  495. _crypt_shutdown()
  496. Return SetError($ierror, $iextended, $vreturn)
  497. EndFunc
  498.  
  499. Func _crypt_hashdata($vdata, $ialgid, $bfinal = True, $hcrypthash = 0)
  500. Local $aret = 0, $tbuff = 0, $ierror = 0, $iextended = 0, $ihashsize = 0, $vreturn = 0
  501. _crypt_startup()
  502. If @error Then Return SetError(@error, @extended, -1)
  503. Do
  504. If $hcrypthash = 0 Then
  505. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptCreateHash", "handle", __crypt_context(), "uint", $ialgid, "ptr", 0, "dword", 0, "handle*", 0)
  506. If @error OR NOT $aret[0] Then
  507. $ierror = @error + 10
  508. $iextended = @extended
  509. If NOT $aret[0] Then $iextended = _winapi_getlasterror()
  510. $vreturn = -1
  511. ExitLoop
  512. EndIf
  513. $hcrypthash = $aret[5]
  514. EndIf
  515. $tbuff = DllStructCreate("byte[" & BinaryLen($vdata) & "]")
  516. DllStructSetData($tbuff, 1, $vdata)
  517. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptHashData", "handle", $hcrypthash, "struct*", $tbuff, "dword", DllStructGetSize($tbuff), "dword", $crypt_userdata)
  518. If @error OR NOT $aret[0] Then
  519. $ierror = @error + 20
  520. $iextended = @extended
  521. If NOT $aret[0] Then $iextended = _winapi_getlasterror()
  522. $vreturn = -1
  523. ExitLoop
  524. EndIf
  525. If $bfinal Then
  526. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptGetHashParam", "handle", $hcrypthash, "dword", $hp_hashsize, "dword*", 0, "dword*", 4, "dword", 0)
  527. If @error OR NOT $aret[0] Then
  528. $ierror = @error + 30
  529. $iextended = @extended
  530. If NOT $aret[0] Then $iextended = _winapi_getlasterror()
  531. $vreturn = -1
  532. ExitLoop
  533. EndIf
  534. $ihashsize = $aret[3]
  535. $tbuff = DllStructCreate("byte[" & $ihashsize & "]")
  536. $aret = DllCall(__crypt_dllhandle(), "bool", "CryptGetHashParam", "handle", $hcrypthash, "dword", $hp_hashval, "struct*", $tbuff, "dword*", $ihashsize, "dword", 0)
  537. If @error OR NOT $aret[0] Then
  538. $ierror = @error + 40
  539. $iextended = @extended
  540. If NOT $aret[0] Then $iextended = _winapi_getlasterror()
  541. $vreturn = -1
  542. ExitLoop
  543. EndIf
  544. $vreturn = DllStructGetData($tbuff, 1)
  545. Else
  546. $vreturn = $hcrypthash
  547. EndIf
  548. Until True
  549. If $hcrypthash <> 0 AND $bfinal Then DllCall(__crypt_dllhandle(), "bool", "CryptDestroyHash", "handle", $hcrypthash)
  550. _crypt_shutdown()
  551. Return SetError($ierror, $iextended, $vreturn)
  552. EndFunc
  553.  
  554. Func _crypt_hashfile($sfilepath, $ialgid)
  555. Local $dtempdata = 0, $hfile = 0, $hhashobject = 0, $ierror = 0, $iextended = 0, $vreturn = 0
  556. _crypt_startup()
  557. If @error Then Return SetError(@error, @extended, -1)
  558. Do
  559. $hfile = FileOpen($sfilepath, $fo_binary)
  560. If $hfile = -1 Then
  561. $ierror = 1
  562. $iextended = _winapi_getlasterror()
  563. $vreturn = -1
  564. ExitLoop
  565. EndIf
  566. Do
  567. $dtempdata = FileRead($hfile, 512 * 1024)
  568. If @error Then
  569. $vreturn = _crypt_hashdata($dtempdata, $ialgid, True, $hhashobject)
  570. If @error Then
  571. $ierror = @error
  572. $iextended = @extended
  573. $vreturn = -1
  574. ExitLoop 2
  575. EndIf
  576. ExitLoop 2
  577. Else
  578. $hhashobject = _crypt_hashdata($dtempdata, $ialgid, False, $hhashobject)
  579. If @error Then
  580. $ierror = @error + 100
  581. $iextended = @extended
  582. $vreturn = -1
  583. ExitLoop 2
  584. EndIf
  585. EndIf
  586. Until False
  587. Until True
  588. _crypt_shutdown()
  589. If $hfile <> -1 Then FileClose($hfile)
  590. Return SetError($ierror, $iextended, $vreturn)
  591. EndFunc
  592.  
  593. Func _crypt_encryptfile($ssourcefile, $sdestinationfile, $vcryptkey, $ialgid)
  594. Local $dtempdata = 0, $hinfile = 0, $houtfile = 0, $ierror = 0, $iextended = 0, $ifilesize = FileGetSize($ssourcefile), $iread = 0, $breturn = True
  595. _crypt_startup()
  596. If @error Then Return SetError(@error, @extended, -1)
  597. Do
  598. If $ialgid <> $calg_userkey Then
  599. $vcryptkey = _crypt_derivekey($vcryptkey, $ialgid)
  600. If @error Then
  601. $ierror = @error
  602. $iextended = @extended
  603. $breturn = False
  604. ExitLoop
  605. EndIf
  606. EndIf
  607. $hinfile = FileOpen($ssourcefile, $fo_binary)
  608. If $hinfile = -1 Then
  609. $ierror = 2
  610. $iextended = _winapi_getlasterror()
  611. $breturn = False
  612. ExitLoop
  613. EndIf
  614. $houtfile = FileOpen($sdestinationfile, $fo_overwrite + $fo_createpath + $fo_binary)
  615. If $houtfile = -1 Then
  616. $ierror = 3
  617. $iextended = _winapi_getlasterror()
  618. $breturn = False
  619. ExitLoop
  620. EndIf
  621. Do
  622. $dtempdata = FileRead($hinfile, 1024 * 1024)
  623. $iread += BinaryLen($dtempdata)
  624. If $iread = $ifilesize Then
  625. $dtempdata = _crypt_encryptdata($dtempdata, $vcryptkey, $calg_userkey, True)
  626. If @error Then
  627. $ierror = @error + 400
  628. $iextended = @extended
  629. $breturn = False
  630. EndIf
  631. FileWrite($houtfile, $dtempdata)
  632. ExitLoop 2
  633. Else
  634. $dtempdata = _crypt_encryptdata($dtempdata, $vcryptkey, $calg_userkey, False)
  635. If @error Then
  636. $ierror = @error + 500
  637. $iextended = @extended
  638. $breturn = False
  639. ExitLoop 2
  640. EndIf
  641. FileWrite($houtfile, $dtempdata)
  642. EndIf
  643. Until False
  644. Until True
  645. If $ialgid <> $calg_userkey Then _crypt_destroykey($vcryptkey)
  646. _crypt_shutdown()
  647. If $hinfile <> -1 Then FileClose($hinfile)
  648. If $houtfile <> -1 Then FileClose($houtfile)
  649. Return SetError($ierror, $iextended, $breturn)
  650. EndFunc
  651.  
  652. Func _crypt_decryptfile($ssourcefile, $sdestinationfile, $vcryptkey, $ialgid)
  653. Local $dtempdata = 0, $hinfile = 0, $houtfile = 0, $ierror = 0, $iextended = 0, $ifilesize = FileGetSize($ssourcefile), $iread = 0, $breturn = True
  654. _crypt_startup()
  655. If @error Then Return SetError(@error, @extended, -1)
  656. Do
  657. If $ialgid <> $calg_userkey Then
  658. $vcryptkey = _crypt_derivekey($vcryptkey, $ialgid)
  659. If @error Then
  660. $ierror = @error
  661. $iextended = @extended
  662. $breturn = False
  663. ExitLoop
  664. EndIf
  665. EndIf
  666. $hinfile = FileOpen($ssourcefile, $fo_binary)
  667. If $hinfile = -1 Then
  668. $ierror = 2
  669. $iextended = _winapi_getlasterror()
  670. $breturn = False
  671. ExitLoop
  672. EndIf
  673. $houtfile = FileOpen($sdestinationfile, $fo_overwrite + $fo_createpath + $fo_binary)
  674. If $houtfile = -1 Then
  675. $ierror = 3
  676. $iextended = _winapi_getlasterror()
  677. $breturn = False
  678. ExitLoop
  679. EndIf
  680. Do
  681. $dtempdata = FileRead($hinfile, 1024 * 1024)
  682. $iread += BinaryLen($dtempdata)
  683. If $iread = $ifilesize Then
  684. $dtempdata = _crypt_decryptdata($dtempdata, $vcryptkey, $calg_userkey, True)
  685. If @error Then
  686. $ierror = @error + 400
  687. $iextended = @extended
  688. $breturn = False
  689. EndIf
  690. FileWrite($houtfile, $dtempdata)
  691. ExitLoop 2
  692. Else
  693. $dtempdata = _crypt_decryptdata($dtempdata, $vcryptkey, $calg_userkey, False)
  694. If @error Then
  695. $ierror = @error + 500
  696. $iextended = @extended
  697. $breturn = False
  698. ExitLoop 2
  699. EndIf
  700. FileWrite($houtfile, $dtempdata)
  701. EndIf
  702. Until False
  703. Until True
  704. If $ialgid <> $calg_userkey Then _crypt_destroykey($vcryptkey)
  705. _crypt_shutdown()
  706. If $hinfile <> -1 Then FileClose($hinfile)
  707. If $houtfile <> -1 Then FileClose($houtfile)
  708. Return SetError($ierror, $iextended, $breturn)
  709. EndFunc
  710.  
  711. Func _crypt_genrandom($pbuffer, $isize)
  712. _crypt_startup()
  713. If @error Then Return SetError(@error, @extended, False)
  714. Local $aret = DllCall(__crypt_dllhandle(), "bool", "CryptGenRandom", "handle", __crypt_context(), "dword", $isize, "struct*", $pbuffer)
  715. Local $ierror = @error, $iextended = @extended
  716. If NOT $aret[0] Then $iextended = _winapi_getlasterror()
  717. _crypt_shutdown()
  718. If $ierror OR (NOT $aret[0]) Then
  719. Return SetError($ierror + 10, $iextended, False)
  720. Else
  721. Return True
  722. EndIf
  723. EndFunc
  724.  
  725. Func __crypt_refcount()
  726. Return $__g_acryptinternaldata[0]
  727. EndFunc
  728.  
  729. Func __crypt_refcountinc()
  730. $__g_acryptinternaldata[0] += 1
  731. EndFunc
  732.  
  733. Func __crypt_refcountdec()
  734. If $__g_acryptinternaldata[0] > 0 Then $__g_acryptinternaldata[0] -= 1
  735. EndFunc
  736.  
  737. Func __crypt_dllhandle()
  738. Return $__g_acryptinternaldata[1]
  739. EndFunc
  740.  
  741. Func __crypt_dllhandleset($hadvapi32)
  742. $__g_acryptinternaldata[1] = $hadvapi32
  743. EndFunc
  744.  
  745. Func __crypt_context()
  746. Return $__g_acryptinternaldata[2]
  747. EndFunc
  748.  
  749. Func __crypt_contextset($hcryptcontext)
  750. $__g_acryptinternaldata[2] = $hcryptcontext
  751. EndFunc
  752.  
  753. Func __crypt_getcalgfromcryptkey($vcryptkey)
  754. Local $talgid = DllStructCreate("uint")
  755. Local $aret = DllCall(__crypt_dllhandle(), "bool", "CryptGetKeyParam", "handle", $vcryptkey, "dword", $kp_algid, "struct*", $talgid, "dword*", DllStructGetSize($talgid), "dword", 0)
  756. Local $ierror = @error, $iextended = @extended
  757. If NOT $aret[0] Then $iextended = _winapi_getlasterror()
  758. If $ierror OR NOT $aret[0] Then
  759. Return SetError($ierror + 80, $iextended, $crypt_userdata)
  760. Else
  761. Return DllStructGetData($talgid, 1)
  762. EndIf
  763. EndFunc
  764.  
  765. Global Const $dts_shortdateformat = 0
  766. Global Const $dts_updown = 1
  767. Global Const $dts_shownone = 2
  768. Global Const $dts_longdateformat = 4
  769. Global Const $dts_timeformat = 9
  770. Global Const $dts_rightalign = 32
  771. Global Const $dts_shortdatecenturyformat = 12
  772. Global Const $dts_appcanparse = 16
  773. Global Const $dmw_longname = 0
  774. Global Const $dmw_shortname = 1
  775. Global Const $dmw_locale_longname = 2
  776. Global Const $dmw_locale_shortname = 3
  777. Global Const $gdt_error = -1
  778. Global Const $gdt_valid = 0
  779. Global Const $gdt_none = 1
  780. Global Const $gdtr_min = 1
  781. Global Const $gdtr_max = 2
  782. Global Const $mcht_nowhere = 0
  783. Global Const $mcht_title = 65536
  784. Global Const $mcht_calendar = 131072
  785. Global Const $mcht_todaylink = 196608
  786. Global Const $mcht_next = 16777216
  787. Global Const $mcht_prev = 33554432
  788. Global Const $mcht_titlebk = 65536
  789. Global Const $mcht_titlemonth = 65537
  790. Global Const $mcht_titleyear = 65538
  791. Global Const $mcht_titlebtnnext = 16842755
  792. Global Const $mcht_titlebtnprev = 33619971
  793. Global Const $mcht_calendarbk = 131072
  794. Global Const $mcht_calendardate = 131073
  795. Global Const $mcht_calendarday = 131074
  796. Global Const $mcht_calendarweeknum = 131075
  797. Global Const $mcht_calendardatenext = 16908288
  798. Global Const $mcht_calendardateprev = 33685504
  799. Global Const $mcs_daystate = 1
  800. Global Const $mcs_multiselect = 2
  801. Global Const $mcs_weeknumbers = 4
  802. Global Const $mcs_notodaycircle = 8
  803. Global Const $mcs_notoday = 16
  804. Global Const $mcs_notrailingdates = 64
  805. Global Const $mcs_shortdaysofweek = 128
  806. Global Const $mcs_noselchangeonnav = 256
  807. Global Const $mcm_first = 4096
  808. Global Const $mcm_getcalendarborder = ($mcm_first + 31)
  809. Global Const $mcm_getcalendarcount = ($mcm_first + 23)
  810. Global Const $mcm_getcalendargridinfo = ($mcm_first + 24)
  811. Global Const $mcm_getcalid = ($mcm_first + 27)
  812. Global Const $mcm_getcolor = ($mcm_first + 11)
  813. Global Const $mcm_getcurrentview = ($mcm_first + 22)
  814. Global Const $mcm_getcursel = ($mcm_first + 1)
  815. Global Const $mcm_getfirstdayofweek = ($mcm_first + 16)
  816. Global Const $mcm_getmaxselcount = ($mcm_first + 3)
  817. Global Const $mcm_getmaxtodaywidth = ($mcm_first + 21)
  818. Global Const $mcm_getminreqrect = ($mcm_first + 9)
  819. Global Const $mcm_getmonthdelta = ($mcm_first + 19)
  820. Global Const $mcm_getmonthrange = ($mcm_first + 7)
  821. Global Const $mcm_getrange = ($mcm_first + 17)
  822. Global Const $mcm_getselrange = ($mcm_first + 5)
  823. Global Const $mcm_gettoday = ($mcm_first + 13)
  824. Global Const $mcm_getunicodeformat = 8192 + 6
  825. Global Const $mcm_hittest = ($mcm_first + 14)
  826. Global Const $mcm_setcalendarborder = ($mcm_first + 30)
  827. Global Const $mcm_setcalid = ($mcm_first + 28)
  828. Global Const $mcm_setcolor = ($mcm_first + 10)
  829. Global Const $mcm_setcurrentview = ($mcm_first + 32)
  830. Global Const $mcm_setcursel = ($mcm_first + 2)
  831. Global Const $mcm_setdaystate = ($mcm_first + 8)
  832. Global Const $mcm_setfirstdayofweek = ($mcm_first + 15)
  833. Global Const $mcm_setmaxselcount = ($mcm_first + 4)
  834. Global Const $mcm_setmonthdelta = ($mcm_first + 20)
  835. Global Const $mcm_setrange = ($mcm_first + 18)
  836. Global Const $mcm_setselrange = ($mcm_first + 6)
  837. Global Const $mcm_settoday = ($mcm_first + 12)
  838. Global Const $mcm_setunicodeformat = 8192 + 5
  839. Global Const $mcm_sizerecttomin = ($mcm_first + 29)
  840. Global Const $mcn_first = -746
  841. Global Const $mcn_selchange = ($mcn_first - 3)
  842. Global Const $mcn_getdaystate = ($mcn_first - 1)
  843. Global Const $mcn_select = ($mcn_first)
  844. Global Const $mcn_viewchange = ($mcn_first - 4)
  845. Global Const $mcsc_background = 0
  846. Global Const $mcsc_monthbk = 4
  847. Global Const $mcsc_text = 1
  848. Global Const $mcsc_titlebk = 2
  849. Global Const $mcsc_titletext = 3
  850. Global Const $mcsc_trailingtext = 5
  851. Global Const $dtm_first = 4096
  852. Global Const $dtm_getsystemtime = $dtm_first + 1
  853. Global Const $dtm_setsystemtime = $dtm_first + 2
  854. Global Const $dtm_getrange = $dtm_first + 3
  855. Global Const $dtm_setrange = $dtm_first + 4
  856. Global Const $dtm_setformat = $dtm_first + 5
  857. Global Const $dtm_setmccolor = $dtm_first + 6
  858. Global Const $dtm_getmccolor = $dtm_first + 7
  859. Global Const $dtm_getmonthcal = $dtm_first + 8
  860. Global Const $dtm_setmcfont = $dtm_first + 9
  861. Global Const $dtm_getmcfont = $dtm_first + 10
  862. Global Const $dtm_setformatw = $dtm_first + 50
  863. Global Const $dtn_first = -740
  864. Global Const $dtn_first2 = -753
  865. Global Const $dtn_datetimechange = $dtn_first2 - 6
  866. Global Const $dtn_userstring = $dtn_first2 - 5
  867. Global Const $dtn_wmkeydown = $dtn_first2 - 4
  868. Global Const $dtn_format = $dtn_first2 - 3
  869. Global Const $dtn_formatquery = $dtn_first2 - 2
  870. Global Const $dtn_dropdown = $dtn_first2 - 1
  871. Global Const $dtn_closeup = $dtn_first2 + 0
  872. Global Const $dtn_userstringw = $dtn_first - 5
  873. Global Const $dtn_wmkeydownw = $dtn_first - 4
  874. Global Const $dtn_formatw = $dtn_first - 3
  875. Global Const $dtn_formatqueryw = $dtn_first - 2
  876. Global Const $gui_ss_default_date = $dts_longdateformat
  877. Global Const $gui_ss_default_monthcal = 0
  878. Global Const $gmem_fixed = 0
  879. Global Const $gmem_moveable = 2
  880. Global Const $gmem_nocompact = 16
  881. Global Const $gmem_nodiscard = 32
  882. Global Const $gmem_zeroinit = 64
  883. Global Const $gmem_modify = 128
  884. Global Const $gmem_discardable = 256
  885. Global Const $gmem_not_banked = 4096
  886. Global Const $gmem_share = 8192
  887. Global Const $gmem_ddeshare = 8192
  888. Global Const $gmem_notify = 16384
  889. Global Const $gmem_lower = 4096
  890. Global Const $gmem_valid_flags = 32626
  891. Global Const $gmem_invalid_handle = 32768
  892. Global Const $gptr = BitOR($gmem_fixed, $gmem_zeroinit)
  893. Global Const $ghnd = BitOR($gmem_moveable, $gmem_zeroinit)
  894. Global Const $mem_commit = 4096
  895. Global Const $mem_reserve = 8192
  896. Global Const $mem_top_down = 1048576
  897. Global Const $mem_shared = 134217728
  898. Global Const $page_noaccess = 1
  899. Global Const $page_readonly = 2
  900. Global Const $page_readwrite = 4
  901. Global Const $page_execute = 16
  902. Global Const $page_execute_read = 32
  903. Global Const $page_execute_readwrite = 64
  904. Global Const $page_execute_writecopy = 128
  905. Global Const $page_guard = 256
  906. Global Const $page_nocache = 512
  907. Global Const $page_writecombine = 1024
  908. Global Const $page_writecopy = 8
  909. Global Const $mem_decommit = 16384
  910. Global Const $mem_release = 32768
  911. Global Enum $mem_load, $mem_totalphysram, $mem_availphysram, $mem_totalpagefile, $mem_availpagefile, $mem_totalvirtual, $mem_availvirtual
  912. Global Const $process_terminate = 1
  913. Global Const $process_create_thread = 2
  914. Global Const $process_set_sessionid = 4
  915. Global Const $process_vm_operation = 8
  916. Global Const $process_vm_read = 16
  917. Global Const $process_vm_write = 32
  918. Global Const $process_dup_handle = 64
  919. Global Const $process_create_process = 128
  920. Global Const $process_set_quota = 256
  921. Global Const $process_set_information = 512
  922. Global Const $process_query_information = 1024
  923. Global Const $process_query_limited_information = 4096
  924. Global Const $process_suspend_resume = 2048
  925. Global Const $process_all_access = 2035711
  926. Global Const $se_assignprimarytoken_name = "SeAssignPrimaryTokenPrivilege"
  927. Global Const $se_audit_name = "SeAuditPrivilege"
  928. Global Const $se_backup_name = "SeBackupPrivilege"
  929. Global Const $se_change_notify_name = "SeChangeNotifyPrivilege"
  930. Global Const $se_create_global_name = "SeCreateGlobalPrivilege"
  931. Global Const $se_create_pagefile_name = "SeCreatePagefilePrivilege"
  932. Global Const $se_create_permanent_name = "SeCreatePermanentPrivilege"
  933. Global Const $se_create_symbolic_link_name = "SeCreateSymbolicLinkPrivilege"
  934. Global Const $se_create_token_name = "SeCreateTokenPrivilege"
  935. Global Const $se_debug_name = "SeDebugPrivilege"
  936. Global Const $se_enable_delegation_name = "SeEnableDelegationPrivilege"
  937. Global Const $se_impersonate_name = "SeImpersonatePrivilege"
  938. Global Const $se_inc_base_priority_name = "SeIncreaseBasePriorityPrivilege"
  939. Global Const $se_inc_working_set_name = "SeIncreaseWorkingSetPrivilege"
  940. Global Const $se_increase_quota_name = "SeIncreaseQuotaPrivilege"
  941. Global Const $se_load_driver_name = "SeLoadDriverPrivilege"
  942. Global Const $se_lock_memory_name = "SeLockMemoryPrivilege"
  943. Global Const $se_machine_account_name = "SeMachineAccountPrivilege"
  944. Global Const $se_manage_volume_name = "SeManageVolumePrivilege"
  945. Global Const $se_prof_single_process_name = "SeProfileSingleProcessPrivilege"
  946. Global Const $se_relabel_name = "SeRelabelPrivilege"
  947. Global Const $se_remote_shutdown_name = "SeRemoteShutdownPrivilege"
  948. Global Const $se_restore_name = "SeRestorePrivilege"
  949. Global Const $se_security_name = "SeSecurityPrivilege"
  950. Global Const $se_shutdown_name = "SeShutdownPrivilege"
  951. Global Const $se_sync_agent_name = "SeSyncAgentPrivilege"
  952. Global Const $se_system_environment_name = "SeSystemEnvironmentPrivilege"
  953. Global Const $se_system_profile_name = "SeSystemProfilePrivilege"
  954. Global Const $se_systemtime_name = "SeSystemtimePrivilege"
  955. Global Const $se_take_ownership_name = "SeTakeOwnershipPrivilege"
  956. Global Const $se_tcb_name = "SeTcbPrivilege"
  957. Global Const $se_time_zone_name = "SeTimeZonePrivilege"
  958. Global Const $se_trusted_credman_access_name = "SeTrustedCredManAccessPrivilege"
  959. Global Const $se_unsolicited_input_name = "SeUnsolicitedInputPrivilege"
  960. Global Const $se_undock_name = "SeUndockPrivilege"
  961. Global Const $se_privilege_enabled_by_default = 1
  962. Global Const $se_privilege_enabled = 2
  963. Global Const $se_privilege_removed = 4
  964. Global Const $se_privilege_used_for_access = -2147483648
  965. Global Const $se_group_mandatory = 1
  966. Global Const $se_group_enabled_by_default = 2
  967. Global Const $se_group_enabled = 4
  968. Global Const $se_group_owner = 8
  969. Global Const $se_group_use_for_deny_only = 16
  970. Global Const $se_group_integrity = 32
  971. Global Const $se_group_integrity_enabled = 64
  972. Global Const $se_group_resource = 536870912
  973. Global Const $se_group_logon_id = -1073741824
  974. Global Enum $tokenprimary = 1, $tokenimpersonation
  975. Global Enum $securityanonymous = 0, $securityidentification, $securityimpersonation, $securitydelegation
  976. 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
  977. Global Const $token_assign_primary = 1
  978. Global Const $token_duplicate = 2
  979. Global Const $token_impersonate = 4
  980. Global Const $token_query = 8
  981. Global Const $token_query_source = 16
  982. Global Const $token_adjust_privileges = 32
  983. Global Const $token_adjust_groups = 64
  984. Global Const $token_adjust_default = 128
  985. Global Const $token_adjust_sessionid = 256
  986. Global Const $token_all_access = 983551
  987. Global Const $token_read = 131080
  988. Global Const $token_write = 131296
  989. Global Const $token_execute = 131072
  990. Global Const $token_has_traverse_privilege = 1
  991. Global Const $token_has_backup_privilege = 2
  992. Global Const $token_has_restore_privilege = 4
  993. Global Const $token_has_admin_group = 8
  994. Global Const $token_is_restricted = 16
  995. Global Const $token_session_not_referenced = 32
  996. Global Const $token_sandbox_inert = 64
  997. Global Const $token_has_impersonate_privilege = 128
  998. Global Const $rights_delete = 65536
  999. Global Const $read_control = 131072
  1000. Global Const $write_dac = 262144
  1001. Global Const $write_owner = 524288
  1002. Global Const $synchronize = 1048576
  1003. Global Const $access_system_security = 16777216
  1004. Global Const $standard_rights_required = 983040
  1005. Global Const $standard_rights_read = $read_control
  1006. Global Const $standard_rights_write = $read_control
  1007. Global Const $standard_rights_execute = $read_control
  1008. Global Const $standard_rights_all = 2031616
  1009. Global Const $specific_rights_all = 65535
  1010. Global Enum $not_used_access = 0, $grant_access, $set_access, $deny_access, $revoke_access, $set_audit_success, $set_audit_failure
  1011. 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
  1012. Global Const $logon_with_profile = 1
  1013. Global Const $logon_netcredentials_only = 2
  1014. Global Enum $sidtypeuser = 1, $sidtypegroup, $sidtypedomain, $sidtypealias, $sidtypewellknowngroup, $sidtypedeletedaccount, $sidtypeinvalid, $sidtypeunknown, $sidtypecomputer, $sidtypelabel
  1015. Global Const $sid_administrators = "S-1-5-32-544"
  1016. Global Const $sid_users = "S-1-5-32-545"
  1017. Global Const $sid_guests = "S-1-5-32-546"
  1018. Global Const $sid_account_operators = "S-1-5-32-548"
  1019. Global Const $sid_server_operators = "S-1-5-32-549"
  1020. Global Const $sid_print_operators = "S-1-5-32-550"
  1021. Global Const $sid_backup_operators = "S-1-5-32-551"
  1022. Global Const $sid_replicator = "S-1-5-32-552"
  1023. Global Const $sid_owner = "S-1-3-0"
  1024. Global Const $sid_everyone = "S-1-1-0"
  1025. Global Const $sid_network = "S-1-5-2"
  1026. Global Const $sid_interactive = "S-1-5-4"
  1027. Global Const $sid_system = "S-1-5-18"
  1028. Global Const $sid_authenticated_users = "S-1-5-11"
  1029. Global Const $sid_schannel_authentication = "S-1-5-64-14"
  1030. Global Const $sid_digest_authentication = "S-1-5-64-21"
  1031. Global Const $sid_nt_service = "S-1-5-80"
  1032. Global Const $sid_untrusted_mandatory_level = "S-1-16-0"
  1033. Global Const $sid_low_mandatory_level = "S-1-16-4096"
  1034. Global Const $sid_medium_mandatory_level = "S-1-16-8192"
  1035. Global Const $sid_medium_plus_mandatory_level = "S-1-16-8448"
  1036. Global Const $sid_high_mandatory_level = "S-1-16-12288"
  1037. Global Const $sid_system_mandatory_level = "S-1-16-16384"
  1038. Global Const $sid_protected_process_mandatory_level = "S-1-16-20480"
  1039. Global Const $sid_secure_process_mandatory_level = "S-1-16-28672"
  1040. Global Const $sid_all_services = "S-1-5-80-0"
  1041.  
  1042. Func _security__adjusttokenprivileges($htoken, $bdisableall, $tnewstate, $ibufferlen, $tprevstate = 0, $prequired = 0)
  1043. Local $acall = DllCall("advapi32.dll", "bool", "AdjustTokenPrivileges", "handle", $htoken, "bool", $bdisableall, "struct*", $tnewstate, "dword", $ibufferlen, "struct*", $tprevstate, "struct*", $prequired)
  1044. If @error Then Return SetError(@error, @extended, False)
  1045. Return NOT ($acall[0] = 0)
  1046. EndFunc
  1047.  
  1048. Func _security__createprocesswithtoken($htoken, $ilogonflags, $scommandline, $icreationflags, $scurdir, $tstartupinfo, $tprocess_information)
  1049. 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)
  1050. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, False)
  1051. Return True
  1052. EndFunc
  1053.  
  1054. Func _security__duplicatetokenex($hexistingtoken, $idesiredaccess, $iimpersonationlevel, $itokentype)
  1055. Local $acall = DllCall("advapi32.dll", "bool", "DuplicateTokenEx", "handle", $hexistingtoken, "dword", $idesiredaccess, "struct*", 0, "int", $iimpersonationlevel, "int", $itokentype, "handle*", 0)
  1056. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  1057. Return $acall[6]
  1058. EndFunc
  1059.  
  1060. Func _security__getaccountsid($saccount, $ssystem = "")
  1061. Local $aacct = _security__lookupaccountname($saccount, $ssystem)
  1062. If @error Then Return SetError(@error, @extended, 0)
  1063. If IsArray($aacct) Then Return _security__stringsidtosid($aacct[0])
  1064. Return ""
  1065. EndFunc
  1066.  
  1067. Func _security__getlengthsid($psid)
  1068. If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, @extended, 0)
  1069. Local $acall = DllCall("advapi32.dll", "dword", "GetLengthSid", "struct*", $psid)
  1070. If @error Then Return SetError(@error, @extended, 0)
  1071. Return $acall[0]
  1072. EndFunc
  1073.  
  1074. Func _security__gettokeninformation($htoken, $iclass)
  1075. Local $acall = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $htoken, "int", $iclass, "struct*", 0, "dword", 0, "dword*", 0)
  1076. If @error OR NOT $acall[5] Then Return SetError(@error + 10, @extended, 0)
  1077. Local $ilen = $acall[5]
  1078. Local $tbuffer = DllStructCreate("byte[" & $ilen & "]")
  1079. $acall = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $htoken, "int", $iclass, "struct*", $tbuffer, "dword", DllStructGetSize($tbuffer), "dword*", 0)
  1080. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  1081. Return $tbuffer
  1082. EndFunc
  1083.  
  1084. Func _security__impersonateself($ilevel = $securityimpersonation)
  1085. Local $acall = DllCall("advapi32.dll", "bool", "ImpersonateSelf", "int", $ilevel)
  1086. If @error Then Return SetError(@error, @extended, False)
  1087. Return NOT ($acall[0] = 0)
  1088. EndFunc
  1089.  
  1090. Func _security__isvalidsid($psid)
  1091. Local $acall = DllCall("advapi32.dll", "bool", "IsValidSid", "struct*", $psid)
  1092. If @error Then Return SetError(@error, @extended, False)
  1093. Return NOT ($acall[0] = 0)
  1094. EndFunc
  1095.  
  1096. Func _security__lookupaccountname($saccount, $ssystem = "")
  1097. Local $tdata = DllStructCreate("byte SID[256]")
  1098. Local $acall = DllCall("advapi32.dll", "bool", "LookupAccountNameW", "wstr", $ssystem, "wstr", $saccount, "struct*", $tdata, "dword*", DllStructGetSize($tdata), "wstr", "", "dword*", DllStructGetSize($tdata), "int*", 0)
  1099. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  1100. Local $aacct[3]
  1101. $aacct[0] = _security__sidtostringsid(DllStructGetPtr($tdata, "SID"))
  1102. $aacct[1] = $acall[5]
  1103. $aacct[2] = $acall[7]
  1104. Return $aacct
  1105. EndFunc
  1106.  
  1107. Func _security__lookupaccountsid($vsid, $ssystem = "")
  1108. Local $psid, $aacct[3]
  1109. If IsString($vsid) Then
  1110. $psid = _security__stringsidtosid($vsid)
  1111. Else
  1112. $psid = $vsid
  1113. EndIf
  1114. If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, @extended, 0)
  1115. Local $stypesystem = "ptr"
  1116. If $ssystem Then $stypesystem = "wstr"
  1117. Local $acall = DllCall("advapi32.dll", "bool", "LookupAccountSidW", $stypesystem, $ssystem, "struct*", $psid, "wstr", "", "dword*", 65536, "wstr", "", "dword*", 65536, "int*", 0)
  1118. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  1119. Local $aacct[3]
  1120. $aacct[0] = $acall[3]
  1121. $aacct[1] = $acall[5]
  1122. $aacct[2] = $acall[7]
  1123. Return $aacct
  1124. EndFunc
  1125.  
  1126. Func _security__lookupprivilegevalue($ssystem, $sname)
  1127. Local $acall = DllCall("advapi32.dll", "bool", "LookupPrivilegeValueW", "wstr", $ssystem, "wstr", $sname, "int64*", 0)
  1128. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  1129. Return $acall[3]
  1130. EndFunc
  1131.  
  1132. Func _security__openprocesstoken($hprocess, $iaccess)
  1133. Local $acall = DllCall("advapi32.dll", "bool", "OpenProcessToken", "handle", $hprocess, "dword", $iaccess, "handle*", 0)
  1134. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  1135. Return $acall[3]
  1136. EndFunc
  1137.  
  1138. Func _security__openthreadtoken($iaccess, $hthread = 0, $bopenasself = False)
  1139. If $hthread = 0 Then
  1140. Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentThread")
  1141. If @error Then Return SetError(@error + 10, @extended, 0)
  1142. $hthread = $aresult[0]
  1143. EndIf
  1144. Local $acall = DllCall("advapi32.dll", "bool", "OpenThreadToken", "handle", $hthread, "dword", $iaccess, "bool", $bopenasself, "handle*", 0)
  1145. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  1146. Return $acall[4]
  1147. EndFunc
  1148.  
  1149. Func _security__openthreadtokenex($iaccess, $hthread = 0, $bopenasself = False)
  1150. Local $htoken = _security__openthreadtoken($iaccess, $hthread, $bopenasself)
  1151. If $htoken = 0 Then
  1152. Local Const $error_no_token = 1008
  1153. If _winapi_getlasterror() <> $error_no_token Then Return SetError(20, _winapi_getlasterror(), 0)
  1154. If NOT _security__impersonateself() Then Return SetError(@error + 10, _winapi_getlasterror(), 0)
  1155. $htoken = _security__openthreadtoken($iaccess, $hthread, $bopenasself)
  1156. If $htoken = 0 Then Return SetError(@error, _winapi_getlasterror(), 0)
  1157. EndIf
  1158. Return $htoken
  1159. EndFunc
  1160.  
  1161. Func _security__setprivilege($htoken, $sprivilege, $benable)
  1162. Local $iluid = _security__lookupprivilegevalue("", $sprivilege)
  1163. If $iluid = 0 Then Return SetError(@error + 10, @extended, False)
  1164. Local Const $tagtoken_privileges = "dword Count;align 4;int64 LUID;dword Attributes"
  1165. Local $tcurrstate = DllStructCreate($tagtoken_privileges)
  1166. Local $icurrstate = DllStructGetSize($tcurrstate)
  1167. Local $tprevstate = DllStructCreate($tagtoken_privileges)
  1168. Local $iprevstate = DllStructGetSize($tprevstate)
  1169. Local $trequired = DllStructCreate("int Data")
  1170. DllStructSetData($tcurrstate, "Count", 1)
  1171. DllStructSetData($tcurrstate, "LUID", $iluid)
  1172. If NOT _security__adjusttokenprivileges($htoken, False, $tcurrstate, $icurrstate, $tprevstate, $trequired) Then Return SetError(2, @error, False)
  1173. DllStructSetData($tprevstate, "Count", 1)
  1174. DllStructSetData($tprevstate, "LUID", $iluid)
  1175. Local $iattributes = DllStructGetData($tprevstate, "Attributes")
  1176. If $benable Then
  1177. $iattributes = BitOR($iattributes, $se_privilege_enabled)
  1178. Else
  1179. $iattributes = BitAND($iattributes, BitNOT($se_privilege_enabled))
  1180. EndIf
  1181. DllStructSetData($tprevstate, "Attributes", $iattributes)
  1182. If NOT _security__adjusttokenprivileges($htoken, False, $tprevstate, $iprevstate, $tcurrstate, $trequired) Then Return SetError(3, @error, False)
  1183. Return True
  1184. EndFunc
  1185.  
  1186. Func _security__settokeninformation($htoken, $itokeninformation, $vtokeninformation, $itokeninformationlength)
  1187. Local $acall = DllCall("advapi32.dll", "bool", "SetTokenInformation", "handle", $htoken, "int", $itokeninformation, "struct*", $vtokeninformation, "dword", $itokeninformationlength)
  1188. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, False)
  1189. Return True
  1190. EndFunc
  1191.  
  1192. Func _security__sidtostringsid($psid)
  1193. If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, 0, "")
  1194. Local $acall = DllCall("advapi32.dll", "bool", "ConvertSidToStringSidW", "struct*", $psid, "ptr*", 0)
  1195. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, "")
  1196. Local $pstringsid = $acall[2]
  1197. Local $alen = DllCall("kernel32.dll", "int", "lstrlenW", "struct*", $pstringsid)
  1198. Local $ssid = DllStructGetData(DllStructCreate("wchar Text[" & $alen[0] + 1 & "]", $pstringsid), "Text")
  1199. DllCall("kernel32.dll", "handle", "LocalFree", "handle", $pstringsid)
  1200. Return $ssid
  1201. EndFunc
  1202.  
  1203. Func _security__sidtypestr($itype)
  1204. Switch $itype
  1205. Case $sidtypeuser
  1206. Return "User"
  1207. Case $sidtypegroup
  1208. Return "Group"
  1209. Case $sidtypedomain
  1210. Return "Domain"
  1211. Case $sidtypealias
  1212. Return "Alias"
  1213. Case $sidtypewellknowngroup
  1214. Return "Well Known Group"
  1215. Case $sidtypedeletedaccount
  1216. Return "Deleted Account"
  1217. Case $sidtypeinvalid
  1218. Return "Invalid"
  1219. Case $sidtypeunknown
  1220. Return "Unknown Type"
  1221. Case $sidtypecomputer
  1222. Return "Computer"
  1223. Case $sidtypelabel
  1224. Return "A mandatory integrity label SID"
  1225. Case Else
  1226. Return "Unknown SID Type"
  1227. EndSwitch
  1228. EndFunc
  1229.  
  1230. Func _security__stringsidtosid($ssid)
  1231. Local $acall = DllCall("advapi32.dll", "bool", "ConvertStringSidToSidW", "wstr", $ssid, "ptr*", 0)
  1232. If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  1233. Local $psid = $acall[2]
  1234. Local $tbuffer = DllStructCreate("byte Data[" & _security__getlengthsid($psid) & "]", $psid)
  1235. Local $tsid = DllStructCreate("byte Data[" & DllStructGetSize($tbuffer) & "]")
  1236. DllStructSetData($tsid, "Data", DllStructGetData($tbuffer, "Data"))
  1237. DllCall("kernel32.dll", "handle", "LocalFree", "handle", $psid)
  1238. Return $tsid
  1239. EndFunc
  1240.  
  1241. Global Const $tagpoint = "struct;long X;long Y;endstruct"
  1242. Global Const $tagrect = "struct;long Left;long Top;long Right;long Bottom;endstruct"
  1243. Global Const $tagsize = "struct;long X;long Y;endstruct"
  1244. Global Const $tagmargins = "int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight"
  1245. Global Const $tagfiletime = "struct;dword Lo;dword Hi;endstruct"
  1246. Global Const $tagsystemtime = "struct;word Year;word Month;word Dow;word Day;word Hour;word Minute;word Second;word MSeconds;endstruct"
  1247. 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"
  1248. Global Const $tagnmhdr = "struct;hwnd hWndFrom;uint_ptr IDFrom;INT Code;endstruct"
  1249. Global Const $tagcomboboxexitem = "uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;int SelectedImage;int OverlayImage;" & "int Indent;lparam Param"
  1250. Global Const $tagnmcbedragbegin = $tagnmhdr & ";int ItemID;wchar szText[260]"
  1251. Global Const $tagnmcbeendedit = $tagnmhdr & ";bool fChanged;int NewSelection;wchar szText[260];int Why"
  1252. Global Const $tagnmcomboboxex = $tagnmhdr & ";uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;" & "int SelectedImage;int OverlayImage;int Indent;lparam Param"
  1253. 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"
  1254. Global Const $tagnmdatetimechange = $tagnmhdr & ";dword Flag;" & $tagsystemtime
  1255. Global Const $tagnmdatetimeformat = $tagnmhdr & ";ptr Format;" & $tagsystemtime & ";ptr pDisplay;wchar Display[64]"
  1256. Global Const $tagnmdatetimeformatquery = $tagnmhdr & ";ptr Format;struct;long SizeX;long SizeY;endstruct"
  1257. Global Const $tagnmdatetimekeydown = $tagnmhdr & ";int VirtKey;ptr Format;" & $tagsystemtime
  1258. Global Const $tagnmdatetimestring = $tagnmhdr & ";ptr UserString;" & $tagsystemtime & ";dword Flags"
  1259. 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"
  1260. Global Const $taggdip_effectparams_blur = "float Radius; bool ExpandEdge"
  1261. Global Const $taggdip_effectparams_brightnesscontrast = "int BrightnessLevel; int ContrastLevel"
  1262. Global Const $taggdip_effectparams_colorbalance = "int CyanRed; int MagentaGreen; int YellowBlue"
  1263. Global Const $taggdip_effectparams_colorcurve = "int Adjustment; int Channel; int AdjustValue"
  1264. Global Const $taggdip_effectparams_colorlut = "byte LutB[256]; byte LutG[256]; byte LutR[256]; byte LutA[256]"
  1265. Global Const $taggdip_effectparams_huesaturationlightness = "int HueLevel; int SaturationLevel; int LightnessLevel"
  1266. Global Const $taggdip_effectparams_levels = "int Highlight; int Midtone; int Shadow"
  1267. Global Const $taggdip_effectparams_redeyecorrection = "uint NumberOfAreas; ptr Areas"
  1268. Global Const $taggdip_effectparams_sharpen = "float Radius; float Amount"
  1269. Global Const $taggdip_effectparams_tint = "int Hue; int Amount"
  1270. Global Const $taggdipbitmapdata = "uint Width;uint Height;int Stride;int Format;ptr Scan0;uint_ptr Reserved"
  1271. Global Const $taggdipcolormatrix = "float m[25]"
  1272. Global Const $taggdipencoderparam = "struct;byte GUID[16];ulong NumberOfValues;ulong Type;ptr Values;endstruct"
  1273. Global Const $taggdipencoderparams = "uint Count;" & $taggdipencoderparam
  1274. Global Const $taggdiprectf = "struct;float X;float Y;float Width;float Height;endstruct"
  1275. Global Const $taggdipstartupinput = "uint Version;ptr Callback;bool NoThread;bool NoCodecs"
  1276. Global Const $taggdipstartupoutput = "ptr HookProc;ptr UnhookProc"
  1277. 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"
  1278. Global Const $taggdippencoderparams = "uint Count;byte Params[1]"
  1279. 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"
  1280. Global Const $tagnmhddispinfo = $tagnmhdr & ";int Item;uint Mask;ptr Text;int TextMax;int Image;lparam lParam"
  1281. Global Const $tagnmhdfilterbtnclick = $tagnmhdr & ";int Item;" & $tagrect
  1282. Global Const $tagnmheader = $tagnmhdr & ";int Item;int Button;ptr pItem"
  1283. Global Const $taggetipaddress = "byte Field4;byte Field3;byte Field2;byte Field1"
  1284. Global Const $tagnmipaddress = $tagnmhdr & ";int Field;int Value"
  1285. Global Const $taglvfindinfo = "struct;uint Flags;ptr Text;lparam Param;" & $tagpoint & ";uint Direction;endstruct"
  1286. Global Const $taglvhittestinfo = $tagpoint & ";uint Flags;int Item;int SubItem;int iGroup"
  1287. 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"
  1288. Global Const $tagnmlistview = $tagnmhdr & ";int Item;int SubItem;uint NewState;uint OldState;uint Changed;" & "struct;long ActionX;long ActionY;endstruct;lparam Param"
  1289. 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"
  1290. Global Const $tagnmlvdispinfo = $tagnmhdr & ";" & $taglvitem
  1291. Global Const $tagnmlvfinditem = $tagnmhdr & ";int Start;" & $taglvfindinfo
  1292. Global Const $tagnmlvgetinfotip = $tagnmhdr & ";dword Flags;ptr Text;int TextMax;int Item;int SubItem;lparam lParam"
  1293. Global Const $tagnmitemactivate = $tagnmhdr & ";int Index;int SubItem;uint NewState;uint OldState;uint Changed;" & $tagpoint & ";lparam lParam;uint KeyFlags"
  1294. Global Const $tagnmlvkeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
  1295. Global Const $tagnmlvscroll = $tagnmhdr & ";int DX;int DY"
  1296. Global Const $tagmchittestinfo = "uint Size;" & $tagpoint & ";uint Hit;" & $tagsystemtime & ";" & $tagrect & ";int iOffset;int iRow;int iCol"
  1297. 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"
  1298. 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"
  1299. 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"
  1300. Global Const $tagnmdaystate = $tagnmhdr & ";" & $tagsystemtime & ";int DayState;ptr pDayState"
  1301. 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"
  1302. Global Const $tagnmobjectnotify = $tagnmhdr & ";int Item;ptr piid;ptr pObject;long Result;dword dwFlags"
  1303. Global Const $tagnmtckeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
  1304. 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"
  1305. Global Const $tagtvitemex = "struct;" & $tagtvitem & ";int Integral;uint uStateEx;hwnd hwnd;int iExpandedImage;int iReserved;endstruct"
  1306. 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"
  1307. Global Const $tagnmtvcustomdraw = "struct;" & $tagnmhdr & ";dword DrawStage;handle HDC;" & $tagrect & ";dword_ptr ItemSpec;uint ItemState;lparam ItemParam;endstruct" & ";dword ClrText;dword ClrTextBk;int Level"
  1308. Global Const $tagnmtvdispinfo = $tagnmhdr & ";" & $tagtvitem
  1309. Global Const $tagnmtvgetinfotip = $tagnmhdr & ";ptr Text;int TextMax;handle hItem;lparam lParam"
  1310. Global Const $tagnmtvitemchange = $tagnmhdr & ";uint Changed;handle hItem;uint StateNew;uint StateOld;lparam lParam;"
  1311. Global Const $tagtvhittestinfo = $tagpoint & ";uint Flags;handle Item"
  1312. Global Const $tagnmtvkeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
  1313. Global Const $tagnmmouse = $tagnmhdr & ";dword_ptr ItemSpec;dword_ptr ItemData;" & $tagpoint & ";lparam HitInfo"
  1314. Global Const $tagtoken_privileges = "dword Count;align 4;int64 LUID;dword Attributes"
  1315. Global Const $tagimageinfo = "handle hBitmap;handle hMask;int Unused1;int Unused2;" & $tagrect
  1316. Global Const $tagmenuinfo = "dword Size;INT Mask;dword Style;uint YMax;handle hBack;dword ContextHelpID;ulong_ptr MenuData"
  1317. 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"
  1318. 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")
  1319. Global Const $tagnmrebarautobreak = $tagnmhdr & ";uint uBand;uint wID;lparam lParam;uint uMsg;uint fStyleCurrent;bool fAutoBreak"
  1320. 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"
  1321. Global Const $tagnmrebar = $tagnmhdr & ";dword dwMask;uint uBand;uint fStyle;uint wID;lparam lParam"
  1322. Global Const $tagnmrebarchevron = $tagnmhdr & ";uint uBand;uint wID;lparam lParam;" & $tagrect & ";lparam lParamNM"
  1323. 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"
  1324. Global Const $tagcolorscheme = "dword Size;dword BtnHighlight;dword BtnShadow"
  1325. 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
  1326. Global Const $tagnmtbhotitem = $tagnmhdr & ";int idOld;int idNew;dword dwFlags"
  1327. Global Const $tagtbbutton = "int Bitmap;int Command;byte State;byte Style;dword_ptr Param;int_ptr String"
  1328. Global Const $tagtbbuttoninfo = "uint Size;dword Mask;int Command;int Image;byte State;byte Style;word CX;dword_ptr Param;ptr Text;int TextMax"
  1329. Global Const $tagnetresource = "dword Scope;dword Type;dword DisplayType;dword Usage;ptr LocalName;ptr RemoteName;ptr Comment;ptr Provider"
  1330. Global Const $tagoverlapped = "ulong_ptr Internal;ulong_ptr InternalHigh;struct;dword Offset;dword OffsetHigh;endstruct;handle hEvent"
  1331. 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"
  1332. 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"
  1333. Global Const $tagbitmapinfo = $tagbitmapinfoheader & ";dword biRGBQuad[1]"
  1334. Global Const $tagblendfunction = "byte Op;byte Flags;byte Alpha;byte Format"
  1335. Global Const $tagguid = "struct;ulong Data1;ushort Data2;ushort Data3;byte Data4[8];endstruct"
  1336. Global Const $tagwindowplacement = "uint length;uint flags;uint showCmd;long ptMinPosition[2];long ptMaxPosition[2];long rcNormalPosition[4]"
  1337. Global Const $tagwindowpos = "hwnd hWnd;hwnd InsertAfter;int X;int Y;int CX;int CY;uint Flags"
  1338. Global Const $tagscrollinfo = "uint cbSize;uint fMask;int nMin;int nMax;uint nPage;int nPos;int nTrackPos"
  1339. Global Const $tagscrollbarinfo = "dword cbSize;" & $tagrect & ";int dxyLineButton;int xyThumbTop;" & "int xyThumbBottom;int reserved;dword rgstate[6]"
  1340. 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"
  1341. Global Const $tagkbdllhookstruct = "dword vkCode;dword scanCode;dword flags;dword time;ulong_ptr dwExtraInfo"
  1342. Global Const $tagprocess_information = "handle hProcess;handle hThread;dword ProcessID;dword ThreadID"
  1343. 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"
  1344. Global Const $tagsecurity_attributes = "dword Length;ptr Descriptor;bool InheritHandle"
  1345. 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]"
  1346. 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"
  1347. Global Const $tagmemmap = "handle hProc;ulong_ptr Size;ptr Mem"
  1348.  
  1349. Func _memfree(ByRef $tmemmap)
  1350. Local $pmemory = DllStructGetData($tmemmap, "Mem")
  1351. Local $hprocess = DllStructGetData($tmemmap, "hProc")
  1352. Local $bresult = _memvirtualfreeex($hprocess, $pmemory, 0, $mem_release)
  1353. DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hprocess)
  1354. If @error Then Return SetError(@error, @extended, False)
  1355. Return $bresult
  1356. EndFunc
  1357.  
  1358. Func _memglobalalloc($ibytes, $iflags = 0)
  1359. Local $aresult = DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", $iflags, "ulong_ptr", $ibytes)
  1360. If @error Then Return SetError(@error, @extended, 0)
  1361. Return $aresult[0]
  1362. EndFunc
  1363.  
  1364. Func _memglobalfree($hmemory)
  1365. Local $aresult = DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", $hmemory)
  1366. If @error Then Return SetError(@error, @extended, False)
  1367. Return $aresult[0]
  1368. EndFunc
  1369.  
  1370. Func _memgloballock($hmemory)
  1371. Local $aresult = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", $hmemory)
  1372. If @error Then Return SetError(@error, @extended, 0)
  1373. Return $aresult[0]
  1374. EndFunc
  1375.  
  1376. Func _memglobalsize($hmemory)
  1377. Local $aresult = DllCall("kernel32.dll", "ulong_ptr", "GlobalSize", "handle", $hmemory)
  1378. If @error Then Return SetError(@error, @extended, 0)
  1379. Return $aresult[0]
  1380. EndFunc
  1381.  
  1382. Func _memglobalunlock($hmemory)
  1383. Local $aresult = DllCall("kernel32.dll", "bool", "GlobalUnlock", "handle", $hmemory)
  1384. If @error Then Return SetError(@error, @extended, 0)
  1385. Return $aresult[0]
  1386. EndFunc
  1387.  
  1388. Func _meminit($hwnd, $isize, ByRef $tmemmap)
  1389. Local $aresult = DllCall("user32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $hwnd, "dword*", 0)
  1390. If @error Then Return SetError(@error + 10, @extended, 0)
  1391. Local $iprocessid = $aresult[2]
  1392. If $iprocessid = 0 Then Return SetError(1, 0, 0)
  1393. Local $iaccess = BitOR($process_vm_operation, $process_vm_read, $process_vm_write)
  1394. Local $hprocess = __mem_openprocess($iaccess, False, $iprocessid, True)
  1395. Local $ialloc = BitOR($mem_reserve, $mem_commit)
  1396. Local $pmemory = _memvirtualallocex($hprocess, 0, $isize, $ialloc, $page_readwrite)
  1397. If $pmemory = 0 Then Return SetError(2, 0, 0)
  1398. $tmemmap = DllStructCreate($tagmemmap)
  1399. DllStructSetData($tmemmap, "hProc", $hprocess)
  1400. DllStructSetData($tmemmap, "Size", $isize)
  1401. DllStructSetData($tmemmap, "Mem", $pmemory)
  1402. Return $pmemory
  1403. EndFunc
  1404.  
  1405. Func _memmovememory($psource, $pdest, $ilength)
  1406. DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pdest, "struct*", $psource, "ulong_ptr", $ilength)
  1407. If @error Then Return SetError(@error, @extended)
  1408. EndFunc
  1409.  
  1410. Func _memread(ByRef $tmemmap, $psrce, $pdest, $isize)
  1411. Local $aresult = DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", DllStructGetData($tmemmap, "hProc"), "ptr", $psrce, "struct*", $pdest, "ulong_ptr", $isize, "ulong_ptr*", 0)
  1412. If @error Then Return SetError(@error, @extended, False)
  1413. Return $aresult[0]
  1414. EndFunc
  1415.  
  1416. Func _memwrite(ByRef $tmemmap, $psrce, $pdest = 0, $isize = 0, $ssrce = "struct*")
  1417. If $pdest = 0 Then $pdest = DllStructGetData($tmemmap, "Mem")
  1418. If $isize = 0 Then $isize = DllStructGetData($tmemmap, "Size")
  1419. Local $aresult = DllCall("kernel32.dll", "bool", "WriteProcessMemory", "handle", DllStructGetData($tmemmap, "hProc"), "ptr", $pdest, $ssrce, $psrce, "ulong_ptr", $isize, "ulong_ptr*", 0)
  1420. If @error Then Return SetError(@error, @extended, False)
  1421. Return $aresult[0]
  1422. EndFunc
  1423.  
  1424. Func _memvirtualalloc($paddress, $isize, $iallocation, $iprotect)
  1425. Local $aresult = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", $paddress, "ulong_ptr", $isize, "dword", $iallocation, "dword", $iprotect)
  1426. If @error Then Return SetError(@error, @extended, 0)
  1427. Return $aresult[0]
  1428. EndFunc
  1429.  
  1430. Func _memvirtualallocex($hprocess, $paddress, $isize, $iallocation, $iprotect)
  1431. Local $aresult = DllCall("kernel32.dll", "ptr", "VirtualAllocEx", "handle", $hprocess, "ptr", $paddress, "ulong_ptr", $isize, "dword", $iallocation, "dword", $iprotect)
  1432. If @error Then Return SetError(@error, @extended, 0)
  1433. Return $aresult[0]
  1434. EndFunc
  1435.  
  1436. Func _memvirtualfree($paddress, $isize, $ifreetype)
  1437. Local $aresult = DllCall("kernel32.dll", "bool", "VirtualFree", "ptr", $paddress, "ulong_ptr", $isize, "dword", $ifreetype)
  1438. If @error Then Return SetError(@error, @extended, False)
  1439. Return $aresult[0]
  1440. EndFunc
  1441.  
  1442. Func _memvirtualfreeex($hprocess, $paddress, $isize, $ifreetype)
  1443. Local $aresult = DllCall("kernel32.dll", "bool", "VirtualFreeEx", "handle", $hprocess, "ptr", $paddress, "ulong_ptr", $isize, "dword", $ifreetype)
  1444. If @error Then Return SetError(@error, @extended, False)
  1445. Return $aresult[0]
  1446. EndFunc
  1447.  
  1448. Func __mem_openprocess($iaccess, $binherit, $ipid, $bdebugpriv = False)
  1449. Local $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $binherit, "dword", $ipid)
  1450. If @error Then Return SetError(@error, @extended, 0)
  1451. If $aresult[0] Then Return $aresult[0]
  1452. If NOT $bdebugpriv Then Return SetError(100, 0, 0)
  1453. Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
  1454. If @error Then Return SetError(@error + 10, @extended, 0)
  1455. _security__setprivilege($htoken, "SeDebugPrivilege", True)
  1456. Local $ierror = @error
  1457. Local $iextended = @extended
  1458. Local $iret = 0
  1459. If NOT @error Then
  1460. $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $binherit, "dword", $ipid)
  1461. $ierror = @error
  1462. $iextended = @extended
  1463. If $aresult[0] Then $iret = $aresult[0]
  1464. _security__setprivilege($htoken, "SeDebugPrivilege", False)
  1465. If @error Then
  1466. $ierror = @error + 20
  1467. $iextended = @extended
  1468. EndIf
  1469. Else
  1470. $ierror = @error + 30
  1471. EndIf
  1472. DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $htoken)
  1473. Return SetError($ierror, $iextended, $iret)
  1474. EndFunc
  1475.  
  1476. Global Const $opt_coordsrelative = 0
  1477. Global Const $opt_coordsabsolute = 1
  1478. Global Const $opt_coordsclient = 2
  1479. Global Const $opt_errorsilent = 0
  1480. Global Const $opt_errorfatal = 1
  1481. Global Const $opt_capsnostore = 0
  1482. Global Const $opt_capsstore = 1
  1483. Global Const $opt_matchstart = 1
  1484. Global Const $opt_matchany = 2
  1485. Global Const $opt_matchexact = 3
  1486. Global Const $opt_matchadvanced = 4
  1487. Global Const $ccs_top = 1
  1488. Global Const $ccs_nomovey = 2
  1489. Global Const $ccs_bottom = 3
  1490. Global Const $ccs_noresize = 4
  1491. Global Const $ccs_noparentalign = 8
  1492. Global Const $ccs_nohilite = 16
  1493. Global Const $ccs_adjustable = 32
  1494. Global Const $ccs_nodivider = 64
  1495. Global Const $ccs_vert = 128
  1496. Global Const $ccs_left = 129
  1497. Global Const $ccs_nomovex = 130
  1498. Global Const $ccs_right = 131
  1499. Global Const $dt_drivetype = 1
  1500. Global Const $dt_ssdstatus = 2
  1501. Global Const $dt_bustype = 3
  1502. Global Const $proxy_ie = 0
  1503. Global Const $proxy_none = 1
  1504. Global Const $proxy_specified = 2
  1505. Global Const $objid_window = 0
  1506. Global Const $objid_titlebar = -2
  1507. Global Const $objid_sizegrip = -7
  1508. Global Const $objid_caret = -8
  1509. Global Const $objid_cursor = -9
  1510. Global Const $objid_alert = -10
  1511. Global Const $objid_sound = -11
  1512. Global Const $dlg_centerontop = 0
  1513. Global Const $dlg_notitle = 1
  1514. Global Const $dlg_notontop = 2
  1515. Global Const $dlg_textleft = 4
  1516. Global Const $dlg_textright = 8
  1517. Global Const $dlg_moveable = 16
  1518. Global Const $dlg_textvcenter = 32
  1519. Global Const $idc_unknown = 0
  1520. Global Const $idc_appstarting = 1
  1521. Global Const $idc_arrow = 2
  1522. Global Const $idc_cross = 3
  1523. Global Const $idc_hand = 32649
  1524. Global Const $idc_help = 4
  1525. Global Const $idc_ibeam = 5
  1526. Global Const $idc_icon = 6
  1527. Global Const $idc_no = 7
  1528. Global Const $idc_size = 8
  1529. Global Const $idc_sizeall = 9
  1530. Global Const $idc_sizenesw = 10
  1531. Global Const $idc_sizens = 11
  1532. Global Const $idc_sizenwse = 12
  1533. Global Const $idc_sizewe = 13
  1534. Global Const $idc_uparrow = 14
  1535. Global Const $idc_wait = 15
  1536. Global Const $idi_application = 32512
  1537. Global Const $idi_asterisk = 32516
  1538. Global Const $idi_exclamation = 32515
  1539. Global Const $idi_hand = 32513
  1540. Global Const $idi_question = 32514
  1541. Global Const $idi_winlogo = 32517
  1542. Global Const $idi_shield = 32518
  1543. Global Const $idi_error = $idi_hand
  1544. Global Const $idi_information = $idi_asterisk
  1545. Global Const $idi_warning = $idi_exclamation
  1546. Global Const $sd_logoff = 0
  1547. Global Const $sd_shutdown = 1
  1548. Global Const $sd_reboot = 2
  1549. Global Const $sd_force = 4
  1550. Global Const $sd_powerdown = 8
  1551. Global Const $sd_forcehung = 16
  1552. Global Const $sd_standby = 32
  1553. Global Const $sd_hibernate = 64
  1554. Global Const $stdin_child = 1
  1555. Global Const $stdout_child = 2
  1556. Global Const $stderr_child = 4
  1557. Global Const $stderr_merged = 8
  1558. Global Const $stdio_inherit_parent = 16
  1559. Global Const $run_create_new_console = 65536
  1560. Global Const $ubound_dimensions = 0
  1561. Global Const $ubound_rows = 1
  1562. Global Const $ubound_columns = 2
  1563. Global Const $mouseeventf_absolute = 32768
  1564. Global Const $mouseeventf_move = 1
  1565. Global Const $mouseeventf_leftdown = 2
  1566. Global Const $mouseeventf_leftup = 4
  1567. Global Const $mouseeventf_rightdown = 8
  1568. Global Const $mouseeventf_rightup = 16
  1569. Global Const $mouseeventf_middledown = 32
  1570. Global Const $mouseeventf_middleup = 64
  1571. Global Const $mouseeventf_wheel = 2048
  1572. Global Const $mouseeventf_xdown = 128
  1573. Global Const $mouseeventf_xup = 256
  1574. Global Const $reg_none = 0
  1575. Global Const $reg_sz = 1
  1576. Global Const $reg_expand_sz = 2
  1577. Global Const $reg_binary = 3
  1578. Global Const $reg_dword = 4
  1579. Global Const $reg_dword_little_endian = 4
  1580. Global Const $reg_dword_big_endian = 5
  1581. Global Const $reg_link = 6
  1582. Global Const $reg_multi_sz = 7
  1583. Global Const $reg_resource_list = 8
  1584. Global Const $reg_full_resource_descriptor = 9
  1585. Global Const $reg_resource_requirements_list = 10
  1586. Global Const $reg_qword = 11
  1587. Global Const $reg_qword_little_endian = 11
  1588. Global Const $hwnd_bottom = 1
  1589. Global Const $hwnd_notopmost = -2
  1590. Global Const $hwnd_top = 0
  1591. Global Const $hwnd_topmost = -1
  1592. Global Const $swp_nosize = 1
  1593. Global Const $swp_nomove = 2
  1594. Global Const $swp_nozorder = 4
  1595. Global Const $swp_noredraw = 8
  1596. Global Const $swp_noactivate = 16
  1597. Global Const $swp_framechanged = 32
  1598. Global Const $swp_drawframe = 32
  1599. Global Const $swp_showwindow = 64
  1600. Global Const $swp_hidewindow = 128
  1601. Global Const $swp_nocopybits = 256
  1602. Global Const $swp_noownerzorder = 512
  1603. Global Const $swp_noreposition = 512
  1604. Global Const $swp_nosendchanging = 1024
  1605. Global Const $swp_defererase = 8192
  1606. Global Const $swp_asyncwindowpos = 16384
  1607. Global Const $keyword_default = 1
  1608. Global Const $keyword_null = 2
  1609. Global Const $declared_local = -1
  1610. Global Const $declared_unknown = 0
  1611. Global Const $declared_global = 1
  1612. Global Const $assign_create = 0
  1613. Global Const $assign_forcelocal = 1
  1614. Global Const $assign_forceglobal = 2
  1615. Global Const $assign_existfail = 4
  1616. Global Const $bi_enable = 0
  1617. Global Const $bi_disable = 1
  1618. Global Const $break_enable = 1
  1619. Global Const $break_disable = 0
  1620. Global Const $cdtray_open = "open"
  1621. Global Const $cdtray_closed = "closed"
  1622. Global Const $send_default = 0
  1623. Global Const $send_raw = 1
  1624. Global Const $dir_default = 0
  1625. Global Const $dir_extended = 1
  1626. Global Const $dir_norecurse = 2
  1627. Global Const $dir_remove = 1
  1628. Global Const $dt_all = "ALL"
  1629. Global Const $dt_cdrom = "CDROM"
  1630. Global Const $dt_removable = "REMOVABLE"
  1631. Global Const $dt_fixed = "FIXED"
  1632. Global Const $dt_network = "NETWORK"
  1633. Global Const $dt_ramdisk = "RAMDISK"
  1634. Global Const $dt_unknown = "UNKNOWN"
  1635. Global Const $dt_undefined = 1
  1636. Global Const $dt_fat = "FAT"
  1637. Global Const $dt_fat32 = "FAT32"
  1638. Global Const $dt_exfat = "exFAT"
  1639. Global Const $dt_ntfs = "NTFS"
  1640. Global Const $dt_nwfs = "NWFS"
  1641. Global Const $dt_cdfs = "CDFS"
  1642. Global Const $dt_udf = "UDF"
  1643. Global Const $dma_default = 0
  1644. Global Const $dma_persistent = 1
  1645. Global Const $dma_authentication = 8
  1646. Global Const $ds_unknown = "UNKNOWN"
  1647. Global Const $ds_ready = "READY"
  1648. Global Const $ds_notready = "NOTREADY"
  1649. Global Const $ds_invalid = "INVALID"
  1650. Global Const $mouse_click_left = "left"
  1651. Global Const $mouse_click_right = "right"
  1652. Global Const $mouse_click_middle = "middle"
  1653. Global Const $mouse_click_main = "main"
  1654. Global Const $mouse_click_menu = "menu"
  1655. Global Const $mouse_click_primary = "primary"
  1656. Global Const $mouse_click_secondary = "secondary"
  1657. Global Const $mouse_wheel_up = "up"
  1658. Global Const $mouse_wheel_down = "down"
  1659. Global Const $number_auto = 0
  1660. Global Const $number_32bit = 1
  1661. Global Const $number_64bit = 2
  1662. Global Const $number_double = 3
  1663. Global Const $obj_name = 1
  1664. Global Const $obj_string = 2
  1665. Global Const $obj_progid = 3
  1666. Global Const $obj_file = 4
  1667. Global Const $obj_module = 5
  1668. Global Const $obj_clsid = 6
  1669. Global Const $obj_iid = 7
  1670. Global Const $exitclose_normal = 0
  1671. Global Const $exitclose_byexit = 1
  1672. Global Const $exitclose_byclick = 2
  1673. Global Const $exitclose_bylogoff = 3
  1674. Global Const $exitclose_byshutdown = 4
  1675. Global Const $process_stats_memory = 0
  1676. Global Const $process_stats_io = 1
  1677. Global Const $process_low = 0
  1678. Global Const $process_belownormal = 1
  1679. Global Const $process_normal = 2
  1680. Global Const $process_abovenormal = 3
  1681. Global Const $process_high = 4
  1682. Global Const $process_realtime = 5
  1683. Global Const $run_logon_noprofile = 0
  1684. Global Const $run_logon_profile = 1
  1685. Global Const $run_logon_network = 2
  1686. Global Const $run_logon_inherit = 4
  1687. Global Const $sound_nowait = 0
  1688. Global Const $sound_wait = 1
  1689. Global Const $shex_open = "open"
  1690. Global Const $shex_edit = "edit"
  1691. Global Const $shex_print = "print"
  1692. Global Const $shex_properties = "properties"
  1693. Global Const $tcp_data_default = 0
  1694. Global Const $tcp_data_binary = 1
  1695. Global Const $udp_open_default = 0
  1696. Global Const $udp_open_broadcast = 1
  1697. Global Const $udp_data_default = 0
  1698. Global Const $udp_data_binary = 1
  1699. Global Const $udp_data_array = 2
  1700. Global Const $tip_noicon = 0
  1701. Global Const $tip_infoicon = 1
  1702. Global Const $tip_warningicon = 2
  1703. Global Const $tip_erroricon = 3
  1704. Global Const $tip_balloon = 1
  1705. Global Const $tip_center = 2
  1706. Global Const $tip_forcevisible = 4
  1707. Global Const $windows_noontop = 0
  1708. Global Const $windows_ontop = 1
  1709. Global Const $win_state_exists = 1
  1710. Global Const $win_state_visible = 2
  1711. Global Const $win_state_enabled = 4
  1712. Global Const $win_state_active = 8
  1713. Global Const $win_state_minimized = 16
  1714. Global Const $win_state_maximized = 32
  1715. #Region Global Variables and Constants
  1716. Global $__g_venum, $__g_vext = 0
  1717. Global $__g_irgbmode = 1
  1718. Global Const $tagosversioninfo = "struct;dword OSVersionInfoSize;dword MajorVersion;dword MinorVersion;dword BuildNumber;dword PlatformId;wchar CSDVersion[128];endstruct"
  1719. Global Const $image_bitmap = 0
  1720. Global Const $image_icon = 1
  1721. Global Const $image_cursor = 2
  1722. Global Const $image_enhmetafile = 3
  1723. Global Const $lr_defaultcolor = 0
  1724. Global Const $lr_monochrome = 1
  1725. Global Const $lr_color = 2
  1726. Global Const $lr_copyreturnorg = 4
  1727. Global Const $lr_copydeleteorg = 8
  1728. Global Const $lr_loadfromfile = 16
  1729. Global Const $lr_loadtransparent = 32
  1730. Global Const $lr_defaultsize = 64
  1731. Global Const $lr_vgacolor = 128
  1732. Global Const $lr_loadmap3dcolors = 4096
  1733. Global Const $lr_createdibsection = 8192
  1734. Global Const $lr_copyfromresource = 16384
  1735. Global Const $lr_shared = 32768
  1736. Global Const $__tagcursorinfo = "dword Size;dword Flags;handle hCursor;" & "struct;long X;long Y;endstruct"
  1737. Global Const $__winver = __winver()
  1738. #EndRegion Global Variables and Constants
  1739. #Region Functions list
  1740. #EndRegion Functions list
  1741. #Region Public Functions
  1742.  
  1743. Func _winapi_createfile($sfilename, $icreation, $iaccess = 4, $ishare = 0, $iattributes = 0, $tsecurity = 0)
  1744. Local $ida = 0, $ism = 0, $icd = 0, $ifa = 0
  1745. If BitAND($iaccess, 1) <> 0 Then $ida = BitOR($ida, $generic_execute)
  1746. If BitAND($iaccess, 2) <> 0 Then $ida = BitOR($ida, $generic_read)
  1747. If BitAND($iaccess, 4) <> 0 Then $ida = BitOR($ida, $generic_write)
  1748. If BitAND($ishare, 1) <> 0 Then $ism = BitOR($ism, $file_share_delete)
  1749. If BitAND($ishare, 2) <> 0 Then $ism = BitOR($ism, $file_share_read)
  1750. If BitAND($ishare, 4) <> 0 Then $ism = BitOR($ism, $file_share_write)
  1751. Switch $icreation
  1752. Case 0
  1753. $icd = $create_new
  1754. Case 1
  1755. $icd = $create_always
  1756. Case 2
  1757. $icd = $open_existing
  1758. Case 3
  1759. $icd = $open_always
  1760. Case 4
  1761. $icd = $truncate_existing
  1762. EndSwitch
  1763. If BitAND($iattributes, 1) <> 0 Then $ifa = BitOR($ifa, $file_attribute_archive)
  1764. If BitAND($iattributes, 2) <> 0 Then $ifa = BitOR($ifa, $file_attribute_hidden)
  1765. If BitAND($iattributes, 4) <> 0 Then $ifa = BitOR($ifa, $file_attribute_readonly)
  1766. If BitAND($iattributes, 8) <> 0 Then $ifa = BitOR($ifa, $file_attribute_system)
  1767. Local $aresult = DllCall("kernel32.dll", "handle", "CreateFileW", "wstr", $sfilename, "dword", $ida, "dword", $ism, "struct*", $tsecurity, "dword", $icd, "dword", $ifa, "ptr", 0)
  1768. If @error OR ($aresult[0] = Ptr(-1)) Then Return SetError(@error, @extended, 0)
  1769. Return $aresult[0]
  1770. EndFunc
  1771.  
  1772. Func _winapi_freelibrary($hmodule)
  1773. Local $aresult = DllCall("kernel32.dll", "bool", "FreeLibrary", "handle", $hmodule)
  1774. If @error Then Return SetError(@error, @extended, False)
  1775. Return $aresult[0]
  1776. EndFunc
  1777.  
  1778. Func _winapi_getcursorinfo()
  1779. Local $tcursor = DllStructCreate($__tagcursorinfo)
  1780. Local $icursor = DllStructGetSize($tcursor)
  1781. DllStructSetData($tcursor, "Size", $icursor)
  1782. Local $aret = DllCall("user32.dll", "bool", "GetCursorInfo", "struct*", $tcursor)
  1783. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  1784. Local $acursor[5]
  1785. $acursor[0] = True
  1786. $acursor[1] = DllStructGetData($tcursor, "Flags") <> 0
  1787. $acursor[2] = DllStructGetData($tcursor, "hCursor")
  1788. $acursor[3] = DllStructGetData($tcursor, "X")
  1789. $acursor[4] = DllStructGetData($tcursor, "Y")
  1790. Return $acursor
  1791. EndFunc
  1792.  
  1793. Func _winapi_getdlgctrlid($hwnd)
  1794. Local $aresult = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hwnd)
  1795. If @error Then Return SetError(@error, @extended, 0)
  1796. Return $aresult[0]
  1797. EndFunc
  1798.  
  1799. Func _winapi_getmodulehandle($smodulename)
  1800. Local $smodulenametype = "wstr"
  1801. If $smodulename = "" Then
  1802. $smodulename = 0
  1803. $smodulenametype = "ptr"
  1804. EndIf
  1805. Local $aresult = DllCall("kernel32.dll", "handle", "GetModuleHandleW", $smodulenametype, $smodulename)
  1806. If @error Then Return SetError(@error, @extended, 0)
  1807. Return $aresult[0]
  1808. EndFunc
  1809.  
  1810. Func _winapi_getstring($pstring, $bunicode = True)
  1811. Local $ilength = _winapi_strlen($pstring, $bunicode)
  1812. If @error OR NOT $ilength Then Return SetError(@error + 10, @extended, "")
  1813. Local $tstring = DllStructCreate(($bunicode ? "wchar" : "char") & "[" & ($ilength + 1) & "]", $pstring)
  1814. If @error Then Return SetError(@error, @extended, "")
  1815. Return SetExtended($ilength, DllStructGetData($tstring, 1))
  1816. EndFunc
  1817.  
  1818. Func _winapi_iswow64process($ipid = 0)
  1819. If NOT $ipid Then $ipid = @AutoItPID
  1820. Local $hprocess = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", ($__winver < 1536 ? 1024 : 4096), "bool", 0, "dword", $ipid)
  1821. If @error OR NOT $hprocess[0] Then Return SetError(@error + 20, @extended, False)
  1822. Local $aret = DllCall("kernel32.dll", "bool", "IsWow64Process", "handle", $hprocess[0], "bool*", 0)
  1823. If __checkerrorclosehandle($aret, $hprocess[0]) Then Return SetError(@error, @extended, False)
  1824. Return $aret[2]
  1825. EndFunc
  1826.  
  1827. Func _winapi_loadimage($hinstance, $simage, $itype, $ixdesired, $iydesired, $iload)
  1828. Local $aresult, $simagetype = "int"
  1829. If IsString($simage) Then $simagetype = "wstr"
  1830. $aresult = DllCall("user32.dll", "handle", "LoadImageW", "handle", $hinstance, $simagetype, $simage, "uint", $itype, "int", $ixdesired, "int", $iydesired, "uint", $iload)
  1831. If @error Then Return SetError(@error, @extended, 0)
  1832. Return $aresult[0]
  1833. EndFunc
  1834.  
  1835. Func _winapi_loadlibrary($sfilename)
  1836. Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryW", "wstr", $sfilename)
  1837. If @error Then Return SetError(@error, @extended, 0)
  1838. Return $aresult[0]
  1839. EndFunc
  1840.  
  1841. Func _winapi_pathisdirectory($sfilepath)
  1842. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsDirectoryW", "wstr", $sfilepath)
  1843. If @error Then Return SetError(@error, @extended, False)
  1844. Return $aret[0]
  1845. EndFunc
  1846.  
  1847. Func _winapi_readfile($hfile, $pbuffer, $itoread, ByRef $iread, $toverlapped = 0)
  1848. Local $aresult = DllCall("kernel32.dll", "bool", "ReadFile", "handle", $hfile, "struct*", $pbuffer, "dword", $itoread, "dword*", 0, "struct*", $toverlapped)
  1849. If @error Then Return SetError(@error, @extended, False)
  1850. $iread = $aresult[4]
  1851. Return $aresult[0]
  1852. EndFunc
  1853.  
  1854. Func _winapi_strlen($pstring, $bunicode = True)
  1855. Local $w = ""
  1856. If $bunicode Then $w = "W"
  1857. Local $aret = DllCall("kernel32.dll", "int", "lstrlen" & $w, "struct*", $pstring)
  1858. If @error Then Return SetError(@error, @extended, 0)
  1859. Return $aret[0]
  1860. EndFunc
  1861.  
  1862. Func _winapi_switchcolor($icolor)
  1863. If $icolor = -1 Then Return $icolor
  1864. Return BitOR(BitAND($icolor, 65280), BitShift(BitAND($icolor, 255), -16), BitShift(BitAND($icolor, 16711680), 16))
  1865. EndFunc
  1866.  
  1867. Func _winapi_writefile($hfile, $pbuffer, $itowrite, ByRef $iwritten, $toverlapped = 0)
  1868. Local $aresult = DllCall("kernel32.dll", "bool", "WriteFile", "handle", $hfile, "struct*", $pbuffer, "dword", $itowrite, "dword*", 0, "struct*", $toverlapped)
  1869. If @error Then Return SetError(@error, @extended, False)
  1870. $iwritten = $aresult[4]
  1871. Return $aresult[0]
  1872. EndFunc
  1873.  
  1874. #EndRegion Public Functions
  1875. #Region Internal Functions
  1876.  
  1877. Func __checkerrorarraybounds(Const ByRef $adata, ByRef $istart, ByRef $iend, $ndim = 1, $idim = $ubound_dimensions)
  1878. If NOT IsArray($adata) Then Return SetError(1, 0, 1)
  1879. If UBound($adata, $idim) <> $ndim Then Return SetError(2, 0, 1)
  1880. If $istart < 0 Then $istart = 0
  1881. Local $iubound = UBound($adata) - 1
  1882. If $iend < 1 OR $iend > $iubound Then $iend = $iubound
  1883. If $istart > $iend Then Return SetError(4, 0, 1)
  1884. Return 0
  1885. EndFunc
  1886.  
  1887. Func __checkerrorclosehandle($aret, $hfile, $blasterror = False, $icurerr = @error, $icurext = @extended)
  1888. If NOT $icurerr AND NOT $aret[0] Then $icurerr = 10
  1889. Local $alasterror = DllCall("kernel32.dll", "dword", "GetLastError")
  1890. DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hfile)
  1891. If $icurerr Then DllCall("kernel32.dll", "none", "SetLastError", "dword", $alasterror[0])
  1892. If $blasterror Then $icurext = $alasterror[0]
  1893. Return SetError($icurerr, $icurext, $icurerr)
  1894. EndFunc
  1895.  
  1896. Func __dll($spath, $bpin = False)
  1897. Local $aret = DllCall("kernel32.dll", "bool", "GetModuleHandleExW", "dword", ($bpin ? 1 : 2), "wstr", $spath, "ptr*", 0)
  1898. If NOT $aret[3] Then
  1899. Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryW", "wstr", $spath)
  1900. If NOT $aresult[0] Then Return 0
  1901. EndIf
  1902. Return 1
  1903. EndFunc
  1904.  
  1905. Func __enumwindowsproc($hwnd, $bvisible)
  1906. Local $aresult
  1907. If $bvisible Then
  1908. $aresult = DllCall("user32.dll", "bool", "IsWindowVisible", "hwnd", $hwnd)
  1909. If NOT $aresult[0] Then
  1910. Return 1
  1911. EndIf
  1912. EndIf
  1913. __inc($__g_venum)
  1914. $__g_venum[$__g_venum[0][0]][0] = $hwnd
  1915. $aresult = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $hwnd, "wstr", "", "int", 4096)
  1916. $__g_venum[$__g_venum[0][0]][1] = $aresult[2]
  1917. Return 1
  1918. EndFunc
  1919.  
  1920. Func __fatalexit($icode, $stext = "")
  1921. If $stext Then MsgBox($mb_systemmodal, "AutoIt", $stext)
  1922. DllCall("kernel32.dll", "none", "FatalExit", "int", $icode)
  1923. EndFunc
  1924.  
  1925. Func __inc(ByRef $adata, $iincrement = 100)
  1926. Select
  1927. Case UBound($adata, $ubound_columns)
  1928. If $iincrement < 0 Then
  1929. ReDim $adata[$adata[0][0] + 1][UBound($adata, $ubound_columns)]
  1930. Else
  1931. $adata[0][0] += 1
  1932. If $adata[0][0] > UBound($adata) - 1 Then
  1933. ReDim $adata[$adata[0][0] + $iincrement][UBound($adata, $ubound_columns)]
  1934. EndIf
  1935. EndIf
  1936. Case UBound($adata, $ubound_rows)
  1937. If $iincrement < 0 Then
  1938. ReDim $adata[$adata[0] + 1]
  1939. Else
  1940. $adata[0] += 1
  1941. If $adata[0] > UBound($adata) - 1 Then
  1942. ReDim $adata[$adata[0] + $iincrement]
  1943. EndIf
  1944. EndIf
  1945. Case Else
  1946. Return 0
  1947. EndSelect
  1948. Return 1
  1949. EndFunc
  1950.  
  1951. Func __rgb($icolor)
  1952. If $__g_irgbmode Then
  1953. $icolor = _winapi_switchcolor($icolor)
  1954. EndIf
  1955. Return $icolor
  1956. EndFunc
  1957.  
  1958. Func __winver()
  1959. Local $tosvi = DllStructCreate($tagosversioninfo)
  1960. DllStructSetData($tosvi, 1, DllStructGetSize($tosvi))
  1961. Local $aret = DllCall("kernel32.dll", "bool", "GetVersionExW", "struct*", $tosvi)
  1962. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
  1963. Return BitOR(BitShift(DllStructGetData($tosvi, 2), -8), DllStructGetData($tosvi, 3))
  1964. EndFunc
  1965.  
  1966. #EndRegion Internal Functions
  1967. #Region Global Variables and Constants
  1968. Global Const $duplicate_close_source = 1
  1969. Global Const $duplicate_same_access = 2
  1970. Global Const $obj_bitmap = 7
  1971. Global Const $obj_brush = 2
  1972. Global Const $obj_colorspace = 14
  1973. Global Const $obj_dc = 3
  1974. Global Const $obj_enhmetadc = 12
  1975. Global Const $obj_enhmetafile = 13
  1976. Global Const $obj_extpen = 11
  1977. Global Const $obj_font = 6
  1978. Global Const $obj_memdc = 10
  1979. Global Const $obj_metadc = 4
  1980. Global Const $obj_metafile = 9
  1981. Global Const $obj_pal = 5
  1982. Global Const $obj_pen = 1
  1983. Global Const $obj_region = 8
  1984. Global Const $null_brush = 5
  1985. Global Const $null_pen = 8
  1986. Global Const $black_brush = 4
  1987. Global Const $dkgray_brush = 3
  1988. Global Const $dc_brush = 18
  1989. Global Const $gray_brush = 2
  1990. Global Const $hollow_brush = $null_brush
  1991. Global Const $ltgray_brush = 1
  1992. Global Const $white_brush = 0
  1993. Global Const $black_pen = 7
  1994. Global Const $dc_pen = 19
  1995. Global Const $white_pen = 6
  1996. Global Const $ansi_fixed_font = 11
  1997. Global Const $ansi_var_font = 12
  1998. Global Const $device_default_font = 14
  1999. Global Const $default_gui_font = 17
  2000. Global Const $oem_fixed_font = 10
  2001. Global Const $system_font = 13
  2002. Global Const $system_fixed_font = 16
  2003. Global Const $default_palette = 15
  2004. #EndRegion Global Variables and Constants
  2005. #Region Functions list
  2006. #EndRegion Functions list
  2007. #Region Public Functions
  2008.  
  2009. Func _winapi_closehandle($hobject)
  2010. Local $aresult = DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hobject)
  2011. If @error Then Return SetError(@error, @extended, False)
  2012. Return $aresult[0]
  2013. EndFunc
  2014.  
  2015. Func _winapi_deleteobject($hobject)
  2016. Local $aresult = DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hobject)
  2017. If @error Then Return SetError(@error, @extended, False)
  2018. Return $aresult[0]
  2019. EndFunc
  2020.  
  2021. Func _winapi_duplicatehandle($hsourceprocesshandle, $hsourcehandle, $htargetprocesshandle, $idesiredaccess, $iinherithandle, $ioptions)
  2022. Local $aresult = DllCall("kernel32.dll", "bool", "DuplicateHandle", "handle", $hsourceprocesshandle, "handle", $hsourcehandle, "handle", $htargetprocesshandle, "handle*", 0, "dword", $idesiredaccess, "bool", $iinherithandle, "dword", $ioptions)
  2023. If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, 0)
  2024. Return $aresult[4]
  2025. EndFunc
  2026.  
  2027. Func _winapi_getcurrentobject($hdc, $itype)
  2028. Local $aret = DllCall("gdi32.dll", "handle", "GetCurrentObject", "handle", $hdc, "uint", $itype)
  2029. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
  2030. Return $aret[0]
  2031. EndFunc
  2032.  
  2033. Func _winapi_getcurrentprocess()
  2034. Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentProcess")
  2035. If @error Then Return SetError(@error, @extended, 0)
  2036. Return $aresult[0]
  2037. EndFunc
  2038.  
  2039. Func _winapi_getobject($hobject, $isize, $pobject)
  2040. Local $aresult = DllCall("gdi32.dll", "int", "GetObjectW", "handle", $hobject, "int", $isize, "struct*", $pobject)
  2041. If @error Then Return SetError(@error, @extended, 0)
  2042. Return $aresult[0]
  2043. EndFunc
  2044.  
  2045. Func _winapi_getobjectinfobyhandle($hobject)
  2046. Local $tagpublic_object_basic_information = "ulong Attributes;ulong GrantedAcess;ulong HandleCount;ulong PointerCount;ulong Reserved[10]"
  2047. Local $tpobi = DllStructCreate($tagpublic_object_basic_information)
  2048. Local $aret = DllCall("ntdll.dll", "long", "ZwQueryObject", "handle", $hobject, "uint", 0, "struct*", $tpobi, "ulong", DllStructGetSize($tpobi), "ptr", 0)
  2049. If @error Then Return SetError(@error, @extended, 0)
  2050. If $aret[0] Then Return SetError(10, $aret[0], 0)
  2051. Local $aresult[4]
  2052. For $i = 0 To 3
  2053. $aresult[$i] = DllStructGetData($tpobi, $i + 1)
  2054. Next
  2055. Return $aresult
  2056. EndFunc
  2057.  
  2058. Func _winapi_getobjectnamebyhandle($hobject)
  2059. Local $tagunicode_string = "struct;ushort Length;ushort MaximumLength;ptr Buffer;endstruct"
  2060. Local $tagpublic_object_type_information = "struct;" & $tagunicode_string & ";ulong Reserved[22];endstruct"
  2061. Local $tpoti = DllStructCreate($tagpublic_object_type_information & ";byte[32]")
  2062. Local $aret = DllCall("ntdll.dll", "long", "ZwQueryObject", "handle", $hobject, "uint", 2, "struct*", $tpoti, "ulong", DllStructGetSize($tpoti), "ulong*", 0)
  2063. If @error Then Return SetError(@error, @extended, "")
  2064. If $aret[0] Then Return SetError(10, $aret[0], "")
  2065. Local $pdata = DllStructGetData($tpoti, 3)
  2066. If NOT $pdata Then Return SetError(11, 0, "")
  2067. Return _winapi_getstring($pdata)
  2068. EndFunc
  2069.  
  2070. Func _winapi_getobjecttype($hobject)
  2071. Local $aret = DllCall("gdi32.dll", "dword", "GetObjectType", "handle", $hobject)
  2072. If @error Then Return SetError(@error, @extended, 0)
  2073. Return $aret[0]
  2074. EndFunc
  2075.  
  2076. Func _winapi_getstdhandle($istdhandle)
  2077. If $istdhandle < 0 OR $istdhandle > 2 Then Return SetError(2, 0, -1)
  2078. Local Const $ahandle[3] = [-10, -11, -12]
  2079. Local $aresult = DllCall("kernel32.dll", "handle", "GetStdHandle", "dword", $ahandle[$istdhandle])
  2080. If @error Then Return SetError(@error, @extended, -1)
  2081. Return $aresult[0]
  2082. EndFunc
  2083.  
  2084. Func _winapi_getstockobject($iobject)
  2085. Local $aresult = DllCall("gdi32.dll", "handle", "GetStockObject", "int", $iobject)
  2086. If @error Then Return SetError(@error, @extended, 0)
  2087. Return $aresult[0]
  2088. EndFunc
  2089.  
  2090. Func _winapi_selectobject($hdc, $hgdiobj)
  2091. Local $aresult = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hdc, "handle", $hgdiobj)
  2092. If @error Then Return SetError(@error, @extended, False)
  2093. Return $aresult[0]
  2094. EndFunc
  2095.  
  2096. Func _winapi_sethandleinformation($hobject, $imask, $iflags)
  2097. Local $aresult = DllCall("kernel32.dll", "bool", "SetHandleInformation", "handle", $hobject, "dword", $imask, "dword", $iflags)
  2098. If @error Then Return SetError(@error, @extended, False)
  2099. Return $aresult[0]
  2100. EndFunc
  2101.  
  2102. #EndRegion Public Functions
  2103. Global Const $linguistic_ignorecase = 16
  2104. Global Const $linguistic_ignorediacritic = 32
  2105. Global Const $norm_ignorecase = 1
  2106. Global Const $norm_ignorekanatype = 65536
  2107. Global Const $norm_ignorenonspace = 2
  2108. Global Const $norm_ignoresymbols = 4
  2109. Global Const $norm_ignorewidth = 131072
  2110. Global Const $norm_linguistic_casing = 134217728
  2111. Global Const $sort_digitsasnumbers = 8
  2112. Global Const $sort_stringsort = 4096
  2113. Global Const $cstr_less_than = 1
  2114. Global Const $cstr_equal = 2
  2115. Global Const $cstr_greater_than = 3
  2116. Global Const $mui_language_id = 4
  2117. Global Const $mui_language_name = 8
  2118. Global Const $date_autolayout = 64
  2119. Global Const $date_longdate = 2
  2120. Global Const $date_ltrreading = 16
  2121. Global Const $date_shortdate = 1
  2122. Global Const $date_rtlreading = 32
  2123. Global Const $date_use_alt_calendar = 4
  2124. Global Const $date_yearmonth = 8
  2125. Global Const $geo_nation = 1
  2126. Global Const $geo_latitude = 2
  2127. Global Const $geo_longitude = 3
  2128. Global Const $geo_iso2 = 4
  2129. Global Const $geo_iso3 = 5
  2130. Global Const $geo_rfc1766 = 6
  2131. Global Const $geo_lcid = 7
  2132. Global Const $geo_friendlyname = 8
  2133. Global Const $geo_officialname = 9
  2134. Global Const $geo_timezones = 10
  2135. Global Const $geo_officiallanguages = 11
  2136. Global Const $geo_iso_un_number = 12
  2137. Global Const $geo_parent = 13
  2138. Global Const $locale_ilanguage = 1
  2139. Global Const $locale_slanguage = 2
  2140. Global Const $locale_senglanguage = 4097
  2141. Global Const $locale_sabbrevlangname = 3
  2142. Global Const $locale_snativelangname = 4
  2143. Global Const $locale_icountry = 5
  2144. Global Const $locale_scountry = 6
  2145. Global Const $locale_sengcountry = 4098
  2146. Global Const $locale_sabbrevctryname = 7
  2147. Global Const $locale_snativectryname = 8
  2148. Global Const $locale_idefaultlanguage = 9
  2149. Global Const $locale_idefaultcountry = 10
  2150. Global Const $locale_idefaultcodepage = 11
  2151. Global Const $locale_idefaultansicodepage = 4100
  2152. Global Const $locale_idefaultmaccodepage = 4113
  2153. Global Const $locale_slist = 12
  2154. Global Const $locale_imeasure = 13
  2155. Global Const $locale_sdecimal = 14
  2156. Global Const $locale_sthousand = 15
  2157. Global Const $locale_sgrouping = 16
  2158. Global Const $locale_idigits = 17
  2159. Global Const $locale_ilzero = 18
  2160. Global Const $locale_inegnumber = 4112
  2161. Global Const $locale_snativedigits = 19
  2162. Global Const $locale_scurrency = 20
  2163. Global Const $locale_sintlsymbol = 21
  2164. Global Const $locale_smondecimalsep = 22
  2165. Global Const $locale_smonthousandsep = 23
  2166. Global Const $locale_smongrouping = 24
  2167. Global Const $locale_icurrdigits = 25
  2168. Global Const $locale_iintlcurrdigits = 26
  2169. Global Const $locale_icurrency = 27
  2170. Global Const $locale_inegcurr = 28
  2171. Global Const $locale_sdate = 29
  2172. Global Const $locale_stime = 30
  2173. Global Const $locale_sshortdate = 31
  2174. Global Const $locale_slongdate = 32
  2175. Global Const $locale_stimeformat = 4099
  2176. Global Const $locale_idate = 33
  2177. Global Const $locale_ildate = 34
  2178. Global Const $locale_itime = 35
  2179. Global Const $locale_itimemarkposn = 4101
  2180. Global Const $locale_icentury = 36
  2181. Global Const $locale_itlzero = 37
  2182. Global Const $locale_idaylzero = 38
  2183. Global Const $locale_imonlzero = 39
  2184. Global Const $locale_s1159 = 40
  2185. Global Const $locale_s2359 = 41
  2186. Global Const $locale_icalendartype = 4105
  2187. Global Const $locale_ioptionalcalendar = 4107
  2188. Global Const $locale_ifirstdayofweek = 4108
  2189. Global Const $locale_ifirstweekofyear = 4109
  2190. Global Const $locale_sdayname1 = 42
  2191. Global Const $locale_sdayname2 = 43
  2192. Global Const $locale_sdayname3 = 44
  2193. Global Const $locale_sdayname4 = 45
  2194. Global Const $locale_sdayname5 = 46
  2195. Global Const $locale_sdayname6 = 47
  2196. Global Const $locale_sdayname7 = 48
  2197. Global Const $locale_sabbrevdayname1 = 49
  2198. Global Const $locale_sabbrevdayname2 = 50
  2199. Global Const $locale_sabbrevdayname3 = 51
  2200. Global Const $locale_sabbrevdayname4 = 52
  2201. Global Const $locale_sabbrevdayname5 = 53
  2202. Global Const $locale_sabbrevdayname6 = 54
  2203. Global Const $locale_sabbrevdayname7 = 55
  2204. Global Const $locale_smonthname1 = 56
  2205. Global Const $locale_smonthname2 = 57
  2206. Global Const $locale_smonthname3 = 58
  2207. Global Const $locale_smonthname4 = 59
  2208. Global Const $locale_smonthname5 = 60
  2209. Global Const $locale_smonthname6 = 61
  2210. Global Const $locale_smonthname7 = 62
  2211. Global Const $locale_smonthname8 = 63
  2212. Global Const $locale_smonthname9 = 64
  2213. Global Const $locale_smonthname10 = 65
  2214. Global Const $locale_smonthname11 = 66
  2215. Global Const $locale_smonthname12 = 67
  2216. Global Const $locale_smonthname13 = 4110
  2217. Global Const $locale_sabbrevmonthname1 = 68
  2218. Global Const $locale_sabbrevmonthname2 = 69
  2219. Global Const $locale_sabbrevmonthname3 = 70
  2220. Global Const $locale_sabbrevmonthname4 = 71
  2221. Global Const $locale_sabbrevmonthname5 = 72
  2222. Global Const $locale_sabbrevmonthname6 = 73
  2223. Global Const $locale_sabbrevmonthname7 = 74
  2224. Global Const $locale_sabbrevmonthname8 = 75
  2225. Global Const $locale_sabbrevmonthname9 = 76
  2226. Global Const $locale_sabbrevmonthname10 = 77
  2227. Global Const $locale_sabbrevmonthname11 = 78
  2228. Global Const $locale_sabbrevmonthname12 = 79
  2229. Global Const $locale_sabbrevmonthname13 = 4111
  2230. Global Const $locale_spositivesign = 80
  2231. Global Const $locale_snegativesign = 81
  2232. Global Const $locale_ipossignposn = 82
  2233. Global Const $locale_inegsignposn = 83
  2234. Global Const $locale_ipossymprecedes = 84
  2235. Global Const $locale_ipossepbyspace = 85
  2236. Global Const $locale_inegsymprecedes = 86
  2237. Global Const $locale_inegsepbyspace = 87
  2238. Global Const $locale_fontsignature = 88
  2239. Global Const $locale_siso639langname = 89
  2240. Global Const $locale_siso3166ctryname = 90
  2241. Global Const $locale_idefaultebcdiccodepage = 4114
  2242. Global Const $locale_ipapersize = 4106
  2243. Global Const $locale_sengcurrname = 4103
  2244. Global Const $locale_snativecurrname = 4104
  2245. Global Const $locale_syearmonth = 4102
  2246. Global Const $locale_ssortname = 4115
  2247. Global Const $locale_idigitsubstitution = 4116
  2248. Global Const $locale_custom_default = 3072
  2249. Global Const $locale_custom_ui_default = 5120
  2250. Global Const $locale_custom_unspecified = 4096
  2251. Global Const $locale_invariant = 127
  2252. Global Const $locale_system_default = 2048
  2253. Global Const $locale_user_default = 1024
  2254. Global Const $time_force24hourformat = 8
  2255. Global Const $time_nominutesorseconds = 1
  2256. Global Const $time_noseconds = 2
  2257. Global Const $time_notimemarker = 4
  2258. Global Const $lcid_installed = 1
  2259. Global Const $lcid_supported = 2
  2260. #Region Global Variables and Constants
  2261. Global Const $tagnumberfmt = "uint NumDigits;uint LeadingZero;uint Grouping;ptr DecimalSep;ptr ThousandSep;uint NegativeOrder"
  2262. #EndRegion Global Variables and Constants
  2263. #Region Functions list
  2264. #EndRegion Functions list
  2265. #Region Public Functions
  2266.  
  2267. Func _winapi_comparestring($ilcid, $sstring1, $sstring2, $iflags = 0)
  2268. Local $aret = DllCall("kernel32.dll", "int", "CompareStringW", "dword", $ilcid, "dword", $iflags, "wstr", $sstring1, "int", -1, "wstr", $sstring2, "int", -1)
  2269. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
  2270. Return $aret[0]
  2271. EndFunc
  2272.  
  2273. Func _winapi_createnumberformatinfo($inumdigits, $ileadingzero, $igrouping, $sdecimalsep, $sthousandsep, $inegativeorder)
  2274. Local $tfmt = DllStructCreate($tagnumberfmt & ";wchar[" & (StringLen($sdecimalsep) + 1) & "];wchar[" & (StringLen($sthousandsep) + 1) & "]")
  2275. DllStructSetData($tfmt, 1, $inumdigits)
  2276. DllStructSetData($tfmt, 2, $ileadingzero)
  2277. DllStructSetData($tfmt, 3, $igrouping)
  2278. DllStructSetData($tfmt, 4, DllStructGetPtr($tfmt, 7))
  2279. DllStructSetData($tfmt, 5, DllStructGetPtr($tfmt, 8))
  2280. DllStructSetData($tfmt, 6, $inegativeorder)
  2281. DllStructSetData($tfmt, 7, $sdecimalsep)
  2282. DllStructSetData($tfmt, 8, $sthousandsep)
  2283. Return $tfmt
  2284. EndFunc
  2285.  
  2286. Func _winapi_enumsystemgeoid()
  2287. Local $henumproc = DllCallbackRegister("__EnumGeoIDProc", "bool", "long")
  2288. Dim $__g_venum[101] = [0]
  2289. Local $aret = DllCall("kernel32.dll", "bool", "EnumSystemGeoID", "dword", 16, "long", 0, "ptr", DllCallbackGetPtr($henumproc))
  2290. If @error OR NOT $aret[0] OR NOT $__g_venum[0] Then
  2291. $__g_venum = @error + 10
  2292. EndIf
  2293. DllCallbackFree($henumproc)
  2294. If $__g_venum Then Return SetError($__g_venum, 0, 0)
  2295. __inc($__g_venum, -1)
  2296. Return $__g_venum
  2297. EndFunc
  2298.  
  2299. Func _winapi_enumsystemlocales($iflag)
  2300. Local $henumproc = DllCallbackRegister("__EnumLocalesProc", "bool", "ptr")
  2301. Dim $__g_venum[101] = [0]
  2302. Local $aret = DllCall("kernel32.dll", "bool", "EnumSystemLocalesW", "ptr", DllCallbackGetPtr($henumproc), "dword", $iflag)
  2303. If @error OR NOT $aret[0] OR NOT $__g_venum[0] Then
  2304. $__g_venum = @error + 10
  2305. EndIf
  2306. DllCallbackFree($henumproc)
  2307. If $__g_venum Then Return SetError($__g_venum, 0, 0)
  2308. __inc($__g_venum, -1)
  2309. Return $__g_venum
  2310. EndFunc
  2311.  
  2312. Func _winapi_enumuilanguages($iflag = 0)
  2313. Local $henumproc = DllCallbackRegister("__EnumUILanguagesProc", "bool", "ptr;long_ptr")
  2314. Local $iid = 1
  2315. If $__winver >= 1536 Then
  2316. If BitAND($iflag, 8) Then
  2317. $iid = 0
  2318. EndIf
  2319. Else
  2320. $iflag = 0
  2321. EndIf
  2322. Dim $__g_venum[101] = [0]
  2323. Local $aret = DllCall("kernel32.dll", "bool", "EnumUILanguagesW", "ptr", DllCallbackGetPtr($henumproc), "dword", $iflag, "long_ptr", $iid)
  2324. If @error OR NOT $aret[0] OR NOT $__g_venum[0] Then
  2325. $__g_venum = @error + 10
  2326. EndIf
  2327. DllCallbackFree($henumproc)
  2328. If $__g_venum Then Return SetError($__g_venum, 0, 0)
  2329. __inc($__g_venum, -1)
  2330. Return $__g_venum
  2331. EndFunc
  2332.  
  2333. Func _winapi_getdateformat($ilcid = 0, $tsystemtime = 0, $iflags = 0, $sformat = "")
  2334. If NOT $ilcid Then $ilcid = 1024
  2335. Local $stypeofformat = "wstr"
  2336. If NOT StringStripWS($sformat, $str_stripleading + $str_striptrailing) Then
  2337. $stypeofformat = "ptr"
  2338. $sformat = 0
  2339. EndIf
  2340. Local $aret = DllCall("kernel32.dll", "int", "GetDateFormatW", "dword", $ilcid, "dword", $iflags, "struct*", $tsystemtime, $stypeofformat, $sformat, "wstr", "", "int", 2048)
  2341. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  2342. Return $aret[5]
  2343. EndFunc
  2344.  
  2345. Func _winapi_getdurationformat($ilcid, $iduration, $sformat = "")
  2346. If NOT $ilcid Then $ilcid = 1024
  2347. Local $pst, $ival
  2348. If IsDllStruct($iduration) Then
  2349. $pst = DllStructGetPtr($iduration)
  2350. $ival = 0
  2351. Else
  2352. $pst = 0
  2353. $ival = $iduration
  2354. EndIf
  2355. Local $stypeofformat = "wstr"
  2356. If NOT StringStripWS($sformat, $str_stripleading + $str_striptrailing) Then
  2357. $stypeofformat = "ptr"
  2358. $sformat = 0
  2359. EndIf
  2360. Local $aret = DllCall("kernel32.dll", "int", "GetDurationFormat", "dword", $ilcid, "dword", 0, "ptr", $pst, "uint64", $ival, $stypeofformat, $sformat, "wstr", "", "int", 2048)
  2361. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  2362. Return $aret[6]
  2363. EndFunc
  2364.  
  2365. Func _winapi_getgeoinfo($igeoid, $itype, $ilanguage = 0)
  2366. Local $aret = DllCall("kernel32.dll", "int", "GetGeoInfoW", "long", $igeoid, "dword", $itype, "wstr", "", "int", 4096, "word", $ilanguage)
  2367. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
  2368. Return $aret[3]
  2369. EndFunc
  2370.  
  2371. Func _winapi_getlocaleinfo($ilcid, $itype)
  2372. Local $aret = DllCall("kernel32.dll", "int", "GetLocaleInfoW", "dword", $ilcid, "dword", $itype, "wstr", "", "int", 2048)
  2373. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  2374. Return $aret[3]
  2375. EndFunc
  2376.  
  2377. Func _winapi_getnumberformat($ilcid, $snumber, $tnumberfmt = 0)
  2378. If NOT $ilcid Then $ilcid = 1024
  2379. Local $aret = DllCall("kernel32.dll", "int", "GetNumberFormatW", "dword", $ilcid, "dword", 0, "wstr", $snumber, "struct*", $tnumberfmt, "wstr", "", "int", 2048)
  2380. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  2381. Return $aret[5]
  2382. EndFunc
  2383.  
  2384. Func _winapi_getsystemdefaultlangid()
  2385. Local $aret = DllCall("kernel32.dll", "word", "GetSystemDefaultLangID")
  2386. If @error Then Return SetError(@error, @extended, 0)
  2387. Return $aret[0]
  2388. EndFunc
  2389.  
  2390. Func _winapi_getsystemdefaultlcid()
  2391. Local $aret = DllCall("kernel32.dll", "dword", "GetSystemDefaultLCID")
  2392. If @error Then Return SetError(@error, @extended, 0)
  2393. Return $aret[0]
  2394. EndFunc
  2395.  
  2396. Func _winapi_getsystemdefaultuilanguage()
  2397. Local $aret = DllCall("kernel32.dll", "word", "GetSystemDefaultUILanguage")
  2398. If @error Then Return SetError(@error, @extended, 0)
  2399. Return $aret[0]
  2400. EndFunc
  2401.  
  2402. Func _winapi_getthreadlocale()
  2403. Local $aret = DllCall("kernel32.dll", "dword", "GetThreadLocale")
  2404. If @error Then Return SetError(@error, @extended, 0)
  2405. Return $aret[0]
  2406. EndFunc
  2407.  
  2408. Func _winapi_getthreaduilanguage()
  2409. Local $aret = DllCall("kernel32.dll", "word", "GetThreadUILanguage")
  2410. If @error Then Return SetError(@error, @extended, 0)
  2411. Return $aret[0]
  2412. EndFunc
  2413.  
  2414. Func _winapi_gettimeformat($ilcid = 0, $tsystemtime = 0, $iflags = 0, $sformat = "")
  2415. If NOT $ilcid Then $ilcid = 1024
  2416. Local $stypeofformat = "wstr"
  2417. If NOT StringStripWS($sformat, $str_stripleading + $str_striptrailing) Then
  2418. $stypeofformat = "ptr"
  2419. $sformat = 0
  2420. EndIf
  2421. Local $aret = DllCall("kernel32.dll", "int", "GetTimeFormatW", "dword", $ilcid, "dword", $iflags, "struct*", $tsystemtime, $stypeofformat, $sformat, "wstr", "", "int", 2048)
  2422. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  2423. Return $aret[5]
  2424. EndFunc
  2425.  
  2426. Func _winapi_getuserdefaultlangid()
  2427. Local $aret = DllCall("kernel32.dll", "word", "GetUserDefaultLangID")
  2428. If @error Then Return SetError(@error, @extended, 0)
  2429. Return $aret[0]
  2430. EndFunc
  2431.  
  2432. Func _winapi_getuserdefaultlcid()
  2433. Local $aret = DllCall("kernel32.dll", "dword", "GetUserDefaultLCID")
  2434. If @error Then Return SetError(@error, @extended, 0)
  2435. Return $aret[0]
  2436. EndFunc
  2437.  
  2438. Func _winapi_getuserdefaultuilanguage()
  2439. Local $aret = DllCall("kernel32.dll", "word", "GetUserDefaultUILanguage")
  2440. If @error Then Return SetError(@error, @extended, 0)
  2441. Return $aret[0]
  2442. EndFunc
  2443.  
  2444. Func _winapi_getusergeoid()
  2445. Local $aret = DllCall("kernel32.dll", "long", "GetUserGeoID", "uint", 16)
  2446. If @error Then Return SetError(@error, @extended, -1)
  2447. Return $aret[0]
  2448. EndFunc
  2449.  
  2450. Func _winapi_isvalidlocale($ilcid, $iflag = 0)
  2451. Local $aret = DllCall("kernel32.dll", "bool", "IsValidLocale", "dword", $ilcid, "dword", $iflag)
  2452. If @error Then Return SetError(@error, @extended, False)
  2453. Return $aret[0]
  2454. EndFunc
  2455.  
  2456. Func _winapi_setlocaleinfo($ilcid, $itype, $sdata)
  2457. Local $aret = DllCall("kernel32.dll", "bool", "SetLocaleInfoW", "dword", $ilcid, "dword", $itype, "wstr", $sdata)
  2458. If @error Then Return SetError(@error, @extended, False)
  2459. Return $aret[0]
  2460. EndFunc
  2461.  
  2462. Func _winapi_setthreadlocale($ilcid)
  2463. Local $aret = DllCall("kernel32.dll", "bool", "SetThreadLocale", "dword", $ilcid)
  2464. If @error Then Return SetError(@error, @extended, False)
  2465. Return $aret[0]
  2466. EndFunc
  2467.  
  2468. Func _winapi_setthreaduilanguage($ilanguage)
  2469. Local $aret = DllCall("kernel32.dll", "word", "SetThreadUILanguage", "word", $ilanguage)
  2470. If @error Then Return SetError(@error, @extended, False)
  2471. Return ($aret[0] = $aret[1])
  2472. EndFunc
  2473.  
  2474. Func _winapi_setusergeoid($igeoid)
  2475. Local $aret = DllCall("kernel32.dll", "bool", "SetUserGeoID", "long", $igeoid)
  2476. If @error Then Return SetError(@error, @extended, False)
  2477. Return $aret[0]
  2478. EndFunc
  2479.  
  2480. #EndRegion Public Functions
  2481. #Region Internal Functions
  2482.  
  2483. Func __enumgeoidproc($iid)
  2484. __inc($__g_venum)
  2485. $__g_venum[$__g_venum[0]] = $iid
  2486. Return 1
  2487. EndFunc
  2488.  
  2489. Func __enumlocalesproc($plocale)
  2490. __inc($__g_venum)
  2491. $__g_venum[$__g_venum[0]] = Dec(DllStructGetData(DllStructCreate("wchar[" & (_winapi_strlen($plocale) + 1) & "]", $plocale), 1))
  2492. Return 1
  2493. EndFunc
  2494.  
  2495. Func __enumuilanguagesproc($planguage, $iid)
  2496. __inc($__g_venum)
  2497. $__g_venum[$__g_venum[0]] = DllStructGetData(DllStructCreate("wchar[" & (_winapi_strlen($planguage) + 1) & "]", $planguage), 1)
  2498. If $iid Then
  2499. $__g_venum[$__g_venum[0]] = Dec($__g_venum[$__g_venum[0]])
  2500. EndIf
  2501. Return 1
  2502. EndFunc
  2503.  
  2504. #EndRegion Internal Functions
  2505.  
  2506. Func _dateadd($stype, $inumber, $sdate)
  2507. Local $astimepart[4]
  2508. Local $asdatepart[4]
  2509. Local $ijuliandate
  2510. $stype = StringLeft($stype, 1)
  2511. If StringInStr("D,M,Y,w,h,n,s", $stype) = 0 OR $stype = "" Then
  2512. Return SetError(1, 0, 0)
  2513. EndIf
  2514. If NOT StringIsInt($inumber) Then
  2515. Return SetError(2, 0, 0)
  2516. EndIf
  2517. If NOT _dateisvalid($sdate) Then
  2518. Return SetError(3, 0, 0)
  2519. EndIf
  2520. _datetimesplit($sdate, $asdatepart, $astimepart)
  2521. If $stype = "d" OR $stype = "w" Then
  2522. If $stype = "w" Then $inumber = $inumber * 7
  2523. $ijuliandate = _datetodayvalue($asdatepart[1], $asdatepart[2], $asdatepart[3]) + $inumber
  2524. _dayvaluetodate($ijuliandate, $asdatepart[1], $asdatepart[2], $asdatepart[3])
  2525. EndIf
  2526. If $stype = "m" Then
  2527. $asdatepart[2] = $asdatepart[2] + $inumber
  2528. While $asdatepart[2] > 12
  2529. $asdatepart[2] = $asdatepart[2] - 12
  2530. $asdatepart[1] = $asdatepart[1] + 1
  2531. WEnd
  2532. While $asdatepart[2] < 1
  2533. $asdatepart[2] = $asdatepart[2] + 12
  2534. $asdatepart[1] = $asdatepart[1] - 1
  2535. WEnd
  2536. EndIf
  2537. If $stype = "y" Then
  2538. $asdatepart[1] = $asdatepart[1] + $inumber
  2539. EndIf
  2540. If $stype = "h" OR $stype = "n" OR $stype = "s" Then
  2541. Local $itimeval = _timetoticks($astimepart[1], $astimepart[2], $astimepart[3]) / 1000
  2542. If $stype = "h" Then $itimeval = $itimeval + $inumber * 3600
  2543. If $stype = "n" Then $itimeval = $itimeval + $inumber * 60
  2544. If $stype = "s" Then $itimeval = $itimeval + $inumber
  2545. Local $iday2add = Int($itimeval / (24 * 60 * 60))
  2546. $itimeval = $itimeval - $iday2add * 24 * 60 * 60
  2547. If $itimeval < 0 Then
  2548. $iday2add = $iday2add - 1
  2549. $itimeval = $itimeval + 24 * 60 * 60
  2550. EndIf
  2551. $ijuliandate = _datetodayvalue($asdatepart[1], $asdatepart[2], $asdatepart[3]) + $iday2add
  2552. _dayvaluetodate($ijuliandate, $asdatepart[1], $asdatepart[2], $asdatepart[3])
  2553. _tickstotime($itimeval * 1000, $astimepart[1], $astimepart[2], $astimepart[3])
  2554. EndIf
  2555. Local $inumdays = _daysinmonth($asdatepart[1])
  2556. If $inumdays[$asdatepart[2]] < $asdatepart[3] Then $asdatepart[3] = $inumdays[$asdatepart[2]]
  2557. $sdate = $asdatepart[1] & "/" & StringRight("0" & $asdatepart[2], 2) & "/" & StringRight("0" & $asdatepart[3], 2)
  2558. If $astimepart[0] > 0 Then
  2559. If $astimepart[0] > 2 Then
  2560. $sdate = $sdate & " " & StringRight("0" & $astimepart[1], 2) & ":" & StringRight("0" & $astimepart[2], 2) & ":" & StringRight("0" & $astimepart[3], 2)
  2561. Else
  2562. $sdate = $sdate & " " & StringRight("0" & $astimepart[1], 2) & ":" & StringRight("0" & $astimepart[2], 2)
  2563. EndIf
  2564. EndIf
  2565. Return $sdate
  2566. EndFunc
  2567.  
  2568. Func _datedayofweek($idaynum, $iformat = Default)
  2569. Local Const $monday_is_no1 = 128
  2570. If $iformat = Default Then $iformat = 0
  2571. $idaynum = Int($idaynum)
  2572. If $idaynum < 1 OR $idaynum > 7 Then Return SetError(1, 0, "")
  2573. Local $tsystemtime = DllStructCreate($tagsystemtime)
  2574. DllStructSetData($tsystemtime, "Year", BitAND($iformat, $monday_is_no1) ? 2007 : 2006)
  2575. DllStructSetData($tsystemtime, "Month", 1)
  2576. DllStructSetData($tsystemtime, "Day", $idaynum)
  2577. Return _winapi_getdateformat(BitAND($iformat, $dmw_locale_longname) ? $locale_user_default : $locale_invariant, $tsystemtime, 0, BitAND($iformat, $dmw_shortname) ? "ddd" : "dddd")
  2578. EndFunc
  2579.  
  2580. Func _datedaysinmonth($iyear, $imonthnum)
  2581. $imonthnum = Int($imonthnum)
  2582. $iyear = Int($iyear)
  2583. Return __dateismonth($imonthnum) AND __dateisyear($iyear) ? _daysinmonth($iyear)[$imonthnum] : SetError(1, 0, 0)
  2584. EndFunc
  2585.  
  2586. Func _datediff($stype, $sstartdate, $senddate)
  2587. $stype = StringLeft($stype, 1)
  2588. If StringInStr("d,m,y,w,h,n,s", $stype) = 0 OR $stype = "" Then
  2589. Return SetError(1, 0, 0)
  2590. EndIf
  2591. If NOT _dateisvalid($sstartdate) Then
  2592. Return SetError(2, 0, 0)
  2593. EndIf
  2594. If NOT _dateisvalid($senddate) Then
  2595. Return SetError(3, 0, 0)
  2596. EndIf
  2597. Local $asstartdatepart[4], $asstarttimepart[4], $asenddatepart[4], $asendtimepart[4]
  2598. _datetimesplit($sstartdate, $asstartdatepart, $asstarttimepart)
  2599. _datetimesplit($senddate, $asenddatepart, $asendtimepart)
  2600. Local $adaysdiff = _datetodayvalue($asenddatepart[1], $asenddatepart[2], $asenddatepart[3]) - _datetodayvalue($asstartdatepart[1], $asstartdatepart[2], $asstartdatepart[3])
  2601. Local $itimediff, $iyeardiff, $istarttimeinsecs, $iendtimeinsecs
  2602. If $asstarttimepart[0] > 1 AND $asendtimepart[0] > 1 Then
  2603. $istarttimeinsecs = $asstarttimepart[1] * 3600 + $asstarttimepart[2] * 60 + $asstarttimepart[3]
  2604. $iendtimeinsecs = $asendtimepart[1] * 3600 + $asendtimepart[2] * 60 + $asendtimepart[3]
  2605. $itimediff = $iendtimeinsecs - $istarttimeinsecs
  2606. If $itimediff < 0 Then
  2607. $adaysdiff = $adaysdiff - 1
  2608. $itimediff = $itimediff + 24 * 60 * 60
  2609. EndIf
  2610. Else
  2611. $itimediff = 0
  2612. EndIf
  2613. Select
  2614. Case $stype = "d"
  2615. Return $adaysdiff
  2616. Case $stype = "m"
  2617. $iyeardiff = $asenddatepart[1] - $asstartdatepart[1]
  2618. Local $imonthdiff = $asenddatepart[2] - $asstartdatepart[2] + $iyeardiff * 12
  2619. If $asenddatepart[3] < $asstartdatepart[3] Then $imonthdiff = $imonthdiff - 1
  2620. $istarttimeinsecs = $asstarttimepart[1] * 3600 + $asstarttimepart[2] * 60 + $asstarttimepart[3]
  2621. $iendtimeinsecs = $asendtimepart[1] * 3600 + $asendtimepart[2] * 60 + $asendtimepart[3]
  2622. $itimediff = $iendtimeinsecs - $istarttimeinsecs
  2623. If $asenddatepart[3] = $asstartdatepart[3] AND $itimediff < 0 Then $imonthdiff = $imonthdiff - 1
  2624. Return $imonthdiff
  2625. Case $stype = "y"
  2626. $iyeardiff = $asenddatepart[1] - $asstartdatepart[1]
  2627. If $asenddatepart[2] < $asstartdatepart[2] Then $iyeardiff = $iyeardiff - 1
  2628. If $asenddatepart[2] = $asstartdatepart[2] AND $asenddatepart[3] < $asstartdatepart[3] Then $iyeardiff = $iyeardiff - 1
  2629. $istarttimeinsecs = $asstarttimepart[1] * 3600 + $asstarttimepart[2] * 60 + $asstarttimepart[3]
  2630. $iendtimeinsecs = $asendtimepart[1] * 3600 + $asendtimepart[2] * 60 + $asendtimepart[3]
  2631. $itimediff = $iendtimeinsecs - $istarttimeinsecs
  2632. If $asenddatepart[2] = $asstartdatepart[2] AND $asenddatepart[3] = $asstartdatepart[3] AND $itimediff < 0 Then $iyeardiff = $iyeardiff - 1
  2633. Return $iyeardiff
  2634. Case $stype = "w"
  2635. Return Int($adaysdiff / 7)
  2636. Case $stype = "h"
  2637. Return $adaysdiff * 24 + Int($itimediff / 3600)
  2638. Case $stype = "n"
  2639. Return $adaysdiff * 24 * 60 + Int($itimediff / 60)
  2640. Case $stype = "s"
  2641. Return $adaysdiff * 24 * 60 * 60 + $itimediff
  2642. EndSelect
  2643. EndFunc
  2644.  
  2645. Func _dateisleapyear($iyear)
  2646. If StringIsInt($iyear) Then
  2647. Select
  2648. Case Mod($iyear, 4) = 0 AND Mod($iyear, 100) <> 0
  2649. Return 1
  2650. Case Mod($iyear, 400) = 0
  2651. Return 1
  2652. Case Else
  2653. Return 0
  2654. EndSelect
  2655. EndIf
  2656. Return SetError(1, 0, 0)
  2657. EndFunc
  2658.  
  2659. Func __dateismonth($inumber)
  2660. $inumber = Int($inumber)
  2661. Return $inumber >= 1 AND $inumber <= 12
  2662. EndFunc
  2663.  
  2664. Func _dateisvalid($sdate)
  2665. Local $asdatepart[4], $astimepart[4]
  2666. _datetimesplit($sdate, $asdatepart, $astimepart)
  2667. If NOT StringIsInt($asdatepart[1]) Then Return 0
  2668. If NOT StringIsInt($asdatepart[2]) Then Return 0
  2669. If NOT StringIsInt($asdatepart[3]) Then Return 0
  2670. $asdatepart[1] = Int($asdatepart[1])
  2671. $asdatepart[2] = Int($asdatepart[2])
  2672. $asdatepart[3] = Int($asdatepart[3])
  2673. Local $inumdays = _daysinmonth($asdatepart[1])
  2674. If $asdatepart[1] < 1000 OR $asdatepart[1] > 2999 Then Return 0
  2675. If $asdatepart[2] < 1 OR $asdatepart[2] > 12 Then Return 0
  2676. If $asdatepart[3] < 1 OR $asdatepart[3] > $inumdays[$asdatepart[2]] Then Return 0
  2677. If $astimepart[0] < 1 Then Return 1
  2678. If $astimepart[0] < 2 Then Return 0
  2679. If $astimepart[0] = 2 Then $astimepart[3] = "00"
  2680. If NOT StringIsInt($astimepart[1]) Then Return 0
  2681. If NOT StringIsInt($astimepart[2]) Then Return 0
  2682. If NOT StringIsInt($astimepart[3]) Then Return 0
  2683. $astimepart[1] = Int($astimepart[1])
  2684. $astimepart[2] = Int($astimepart[2])
  2685. $astimepart[3] = Int($astimepart[3])
  2686. If $astimepart[1] < 0 OR $astimepart[1] > 23 Then Return 0
  2687. If $astimepart[2] < 0 OR $astimepart[2] > 59 Then Return 0
  2688. If $astimepart[3] < 0 OR $astimepart[3] > 59 Then Return 0
  2689. Return 1
  2690. EndFunc
  2691.  
  2692. Func __dateisyear($inumber)
  2693. Return StringLen($inumber) = 4
  2694. EndFunc
  2695.  
  2696. Func _datelastweekdaynum($iweekdaynum)
  2697. Select
  2698. Case NOT StringIsInt($iweekdaynum)
  2699. Return SetError(1, 0, 0)
  2700. Case $iweekdaynum < 1 OR $iweekdaynum > 7
  2701. Return SetError(2, 0, 0)
  2702. Case Else
  2703. Local $ilastweekdaynum
  2704. If $iweekdaynum = 1 Then
  2705. $ilastweekdaynum = 7
  2706. Else
  2707. $ilastweekdaynum = $iweekdaynum - 1
  2708. EndIf
  2709. Return $ilastweekdaynum
  2710. EndSelect
  2711. EndFunc
  2712.  
  2713. Func _datelastmonthnum($imonthnum)
  2714. Select
  2715. Case NOT StringIsInt($imonthnum)
  2716. Return SetError(1, 0, 0)
  2717. Case NOT __dateismonth($imonthnum)
  2718. Return SetError(2, 0, 0)
  2719. Case Else
  2720. Local $ilastmonthnum
  2721. If $imonthnum = 1 Then
  2722. $ilastmonthnum = 12
  2723. Else
  2724. $ilastmonthnum = $imonthnum - 1
  2725. EndIf
  2726. $ilastmonthnum = StringFormat("%02d", $ilastmonthnum)
  2727. Return $ilastmonthnum
  2728. EndSelect
  2729. EndFunc
  2730.  
  2731. Func _datelastmonthyear($imonthnum, $iyear)
  2732. Select
  2733. Case NOT StringIsInt($imonthnum) OR NOT StringIsInt($iyear)
  2734. Return SetError(1, 0, 0)
  2735. Case NOT __dateismonth($imonthnum)
  2736. Return SetError(2, 0, 0)
  2737. Case Else
  2738. Local $ilastyear
  2739. If $imonthnum = 1 Then
  2740. $ilastyear = $iyear - 1
  2741. Else
  2742. $ilastyear = $iyear
  2743. EndIf
  2744. $ilastyear = StringFormat("%04d", $ilastyear)
  2745. Return $ilastyear
  2746. EndSelect
  2747. EndFunc
  2748.  
  2749. Func _datenextweekdaynum($iweekdaynum)
  2750. Select
  2751. Case NOT StringIsInt($iweekdaynum)
  2752. Return SetError(1, 0, 0)
  2753. Case $iweekdaynum < 1 OR $iweekdaynum > 7
  2754. Return SetError(2, 0, 0)
  2755. Case Else
  2756. Local $inextweekdaynum
  2757. If $iweekdaynum = 7 Then
  2758. $inextweekdaynum = 1
  2759. Else
  2760. $inextweekdaynum = $iweekdaynum + 1
  2761. EndIf
  2762. Return $inextweekdaynum
  2763. EndSelect
  2764. EndFunc
  2765.  
  2766. Func _datenextmonthnum($imonthnum)
  2767. Select
  2768. Case NOT StringIsInt($imonthnum)
  2769. Return SetError(1, 0, 0)
  2770. Case NOT __dateismonth($imonthnum)
  2771. Return SetError(2, 0, 0)
  2772. Case Else
  2773. Local $inextmonthnum
  2774. If $imonthnum = 12 Then
  2775. $inextmonthnum = 1
  2776. Else
  2777. $inextmonthnum = $imonthnum + 1
  2778. EndIf
  2779. $inextmonthnum = StringFormat("%02d", $inextmonthnum)
  2780. Return $inextmonthnum
  2781. EndSelect
  2782. EndFunc
  2783.  
  2784. Func _datenextmonthyear($imonthnum, $iyear)
  2785. Select
  2786. Case NOT StringIsInt($imonthnum) OR NOT StringIsInt($iyear)
  2787. Return SetError(1, 0, 0)
  2788. Case NOT __dateismonth($imonthnum)
  2789. Return SetError(2, 0, 0)
  2790. Case Else
  2791. Local $inextyear
  2792. If $imonthnum = 12 Then
  2793. $inextyear = $iyear + 1
  2794. Else
  2795. $inextyear = $iyear
  2796. EndIf
  2797. $inextyear = StringFormat("%04d", $inextyear)
  2798. Return $inextyear
  2799. EndSelect
  2800. EndFunc
  2801.  
  2802. Func _datetimeformat($sdate, $stype)
  2803. Local $asdatepart[4], $astimepart[4]
  2804. Local $stempdate = "", $stemptime = ""
  2805. Local $sam, $spm, $stempstring = ""
  2806. If NOT _dateisvalid($sdate) Then
  2807. Return SetError(1, 0, "")
  2808. EndIf
  2809. If $stype < 0 OR $stype > 5 OR NOT IsInt($stype) Then
  2810. Return SetError(2, 0, "")
  2811. EndIf
  2812. _datetimesplit($sdate, $asdatepart, $astimepart)
  2813. Switch $stype
  2814. Case 0
  2815. $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_sshortdate)
  2816. If NOT @error AND NOT ($stempstring = "") Then
  2817. $stempdate = $stempstring
  2818. Else
  2819. $stempdate = "M/d/yyyy"
  2820. EndIf
  2821. If $astimepart[0] > 1 Then
  2822. $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_stimeformat)
  2823. If NOT @error AND NOT ($stempstring = "") Then
  2824. $stemptime = $stempstring
  2825. Else
  2826. $stemptime = "h:mm:ss tt"
  2827. EndIf
  2828. EndIf
  2829. Case 1
  2830. $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_slongdate)
  2831. If NOT @error AND NOT ($stempstring = "") Then
  2832. $stempdate = $stempstring
  2833. Else
  2834. $stempdate = "dddd, MMMM dd, yyyy"
  2835. EndIf
  2836. Case 2
  2837. $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_sshortdate)
  2838. If NOT @error AND NOT ($stempstring = "") Then
  2839. $stempdate = $stempstring
  2840. Else
  2841. $stempdate = "M/d/yyyy"
  2842. EndIf
  2843. Case 3
  2844. If $astimepart[0] > 1 Then
  2845. $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_stimeformat)
  2846. If NOT @error AND NOT ($stempstring = "") Then
  2847. $stemptime = $stempstring
  2848. Else
  2849. $stemptime = "h:mm:ss tt"
  2850. EndIf
  2851. EndIf
  2852. Case 4
  2853. If $astimepart[0] > 1 Then
  2854. $stemptime = "hh:mm"
  2855. EndIf
  2856. Case 5
  2857. If $astimepart[0] > 1 Then
  2858. $stemptime = "hh:mm:ss"
  2859. EndIf
  2860. EndSwitch
  2861. If $stempdate <> "" Then
  2862. $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_sdate)
  2863. If NOT @error AND NOT ($stempstring = "") Then
  2864. $stempdate = StringReplace($stempdate, "/", $stempstring)
  2865. EndIf
  2866. Local $iwday = _datetodayofweek($asdatepart[1], $asdatepart[2], $asdatepart[3])
  2867. $asdatepart[3] = StringRight("0" & $asdatepart[3], 2)
  2868. $asdatepart[2] = StringRight("0" & $asdatepart[2], 2)
  2869. $stempdate = StringReplace($stempdate, "d", "@")
  2870. $stempdate = StringReplace($stempdate, "m", "#")
  2871. $stempdate = StringReplace($stempdate, "y", "&")
  2872. $stempdate = StringReplace($stempdate, "@@@@", _datedayofweek($iwday, 0))
  2873. $stempdate = StringReplace($stempdate, "@@@", _datedayofweek($iwday, 1))
  2874. $stempdate = StringReplace($stempdate, "@@", $asdatepart[3])
  2875. $stempdate = StringReplace($stempdate, "@", StringReplace(StringLeft($asdatepart[3], 1), "0", "") & StringRight($asdatepart[3], 1))
  2876. $stempdate = StringReplace($stempdate, "####", _datetomonth($asdatepart[2], 0))
  2877. $stempdate = StringReplace($stempdate, "###", _datetomonth($asdatepart[2], 1))
  2878. $stempdate = StringReplace($stempdate, "##", $asdatepart[2])
  2879. $stempdate = StringReplace($stempdate, "#", StringReplace(StringLeft($asdatepart[2], 1), "0", "") & StringRight($asdatepart[2], 1))
  2880. $stempdate = StringReplace($stempdate, "&&&&", $asdatepart[1])
  2881. $stempdate = StringReplace($stempdate, "&&", StringRight($asdatepart[1], 2))
  2882. EndIf
  2883. If $stemptime <> "" Then
  2884. $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_s1159)
  2885. If NOT @error AND NOT ($stempstring = "") Then
  2886. $sam = $stempstring
  2887. Else
  2888. $sam = "AM"
  2889. EndIf
  2890. $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_s2359)
  2891. If NOT @error AND NOT ($stempstring = "") Then
  2892. $spm = $stempstring
  2893. Else
  2894. $spm = "PM"
  2895. EndIf
  2896. $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_stime)
  2897. If NOT @error AND NOT ($stempstring = "") Then
  2898. $stemptime = StringReplace($stemptime, ":", $stempstring)
  2899. EndIf
  2900. If StringInStr($stemptime, "tt") Then
  2901. If $astimepart[1] < 12 Then
  2902. $stemptime = StringReplace($stemptime, "tt", $sam)
  2903. If $astimepart[1] = 0 Then $astimepart[1] = 12
  2904. Else
  2905. $stemptime = StringReplace($stemptime, "tt", $spm)
  2906. If $astimepart[1] > 12 Then $astimepart[1] = $astimepart[1] - 12
  2907. EndIf
  2908. EndIf
  2909. $astimepart[1] = StringRight("0" & $astimepart[1], 2)
  2910. $astimepart[2] = StringRight("0" & $astimepart[2], 2)
  2911. $astimepart[3] = StringRight("0" & $astimepart[3], 2)
  2912. $stemptime = StringReplace($stemptime, "hh", StringFormat("%02d", $astimepart[1]))
  2913. $stemptime = StringReplace($stemptime, "h", StringReplace(StringLeft($astimepart[1], 1), "0", "") & StringRight($astimepart[1], 1))
  2914. $stemptime = StringReplace($stemptime, "mm", StringFormat("%02d", $astimepart[2]))
  2915. $stemptime = StringReplace($stemptime, "ss", StringFormat("%02d", $astimepart[3]))
  2916. $stempdate = StringStripWS($stempdate & " " & $stemptime, $str_stripleading + $str_striptrailing)
  2917. EndIf
  2918. Return $stempdate
  2919. EndFunc
  2920.  
  2921. Func _datetimesplit($sdate, ByRef $adatepart, ByRef $itimepart)
  2922. Local $sdatetime = StringSplit($sdate, " T")
  2923. If $sdatetime[0] > 0 Then $adatepart = StringSplit($sdatetime[1], "/-.")
  2924. If $sdatetime[0] > 1 Then
  2925. $itimepart = StringSplit($sdatetime[2], ":")
  2926. If UBound($itimepart) < 4 Then ReDim $itimepart[4]
  2927. Else
  2928. Dim $itimepart[4]
  2929. EndIf
  2930. If UBound($adatepart) < 4 Then ReDim $adatepart[4]
  2931. For $x = 1 To 3
  2932. If StringIsInt($adatepart[$x]) Then
  2933. $adatepart[$x] = Int($adatepart[$x])
  2934. Else
  2935. $adatepart[$x] = -1
  2936. EndIf
  2937. If StringIsInt($itimepart[$x]) Then
  2938. $itimepart[$x] = Int($itimepart[$x])
  2939. Else
  2940. $itimepart[$x] = 0
  2941. EndIf
  2942. Next
  2943. Return 1
  2944. EndFunc
  2945.  
  2946. Func _datetodayofweek($iyear, $imonth, $iday)
  2947. If NOT _dateisvalid($iyear & "/" & $imonth & "/" & $iday) Then
  2948. Return SetError(1, 0, "")
  2949. EndIf
  2950. Local $i_factora = Int((14 - $imonth) / 12)
  2951. Local $i_factory = $iyear - $i_factora
  2952. Local $i_factorm = $imonth + (12 * $i_factora) - 2
  2953. Local $i_factord = Mod($iday + $i_factory + Int($i_factory / 4) - Int($i_factory / 100) + Int($i_factory / 400) + Int((31 * $i_factorm) / 12), 7)
  2954. Return $i_factord + 1
  2955. EndFunc
  2956.  
  2957. Func _datetodayofweekiso($iyear, $imonth, $iday)
  2958. Local $idow = _datetodayofweek($iyear, $imonth, $iday)
  2959. If @error Then
  2960. Return SetError(1, 0, "")
  2961. EndIf
  2962. If $idow >= 2 Then Return $idow - 1
  2963. Return 7
  2964. EndFunc
  2965.  
  2966. Func _datetodayvalue($iyear, $imonth, $iday)
  2967. If NOT _dateisvalid(StringFormat("%04d/%02d/%02d", $iyear, $imonth, $iday)) Then
  2968. Return SetError(1, 0, "")
  2969. EndIf
  2970. If $imonth < 3 Then
  2971. $imonth = $imonth + 12
  2972. $iyear = $iyear - 1
  2973. EndIf
  2974. Local $i_factora = Int($iyear / 100)
  2975. Local $i_factorb = Int($i_factora / 4)
  2976. Local $i_factorc = 2 - $i_factora + $i_factorb
  2977. Local $i_factore = Int(1461 * ($iyear + 4716) / 4)
  2978. Local $i_factorf = Int(153 * ($imonth + 1) / 5)
  2979. Local $ijuliandate = $i_factorc + $iday + $i_factore + $i_factorf - 1524.5
  2980. Return $ijuliandate
  2981. EndFunc
  2982.  
  2983. Func _datetomonth($imonnum, $iformat = Default)
  2984. If $iformat = Default Then $iformat = 0
  2985. $imonnum = Int($imonnum)
  2986. If NOT __dateismonth($imonnum) Then Return SetError(1, 0, "")
  2987. Local $tsystemtime = DllStructCreate($tagsystemtime)
  2988. DllStructSetData($tsystemtime, "Year", @YEAR)
  2989. DllStructSetData($tsystemtime, "Month", $imonnum)
  2990. DllStructSetData($tsystemtime, "Day", 1)
  2991. Return _winapi_getdateformat(BitAND($iformat, $dmw_locale_longname) ? $locale_user_default : $locale_invariant, $tsystemtime, 0, BitAND($iformat, $dmw_shortname) ? "MMM" : "MMMM")
  2992. EndFunc
  2993.  
  2994. Func _dayvaluetodate($ijuliandate, ByRef $iyear, ByRef $imonth, ByRef $iday)
  2995. If $ijuliandate < 0 OR NOT IsNumber($ijuliandate) Then
  2996. Return SetError(1, 0, 0)
  2997. EndIf
  2998. Local $i_factorz = Int($ijuliandate + 0.5)
  2999. Local $i_factorw = Int(($i_factorz - 1867216.25) / 36524.25)
  3000. Local $i_factorx = Int($i_factorw / 4)
  3001. Local $i_factora = $i_factorz + 1 + $i_factorw - $i_factorx
  3002. Local $i_factorb = $i_factora + 1524
  3003. Local $i_factorc = Int(($i_factorb - 122.1) / 365.25)
  3004. Local $i_factord = Int(365.25 * $i_factorc)
  3005. Local $i_factore = Int(($i_factorb - $i_factord) / 30.6001)
  3006. Local $i_factorf = Int(30.6001 * $i_factore)
  3007. $iday = $i_factorb - $i_factord - $i_factorf
  3008. If $i_factore - 1 < 13 Then
  3009. $imonth = $i_factore - 1
  3010. Else
  3011. $imonth = $i_factore - 13
  3012. EndIf
  3013. If $imonth < 3 Then
  3014. $iyear = $i_factorc - 4715
  3015. Else
  3016. $iyear = $i_factorc - 4716
  3017. EndIf
  3018. $iyear = StringFormat("%04d", $iyear)
  3019. $imonth = StringFormat("%02d", $imonth)
  3020. $iday = StringFormat("%02d", $iday)
  3021. Return $iyear & "/" & $imonth & "/" & $iday
  3022. EndFunc
  3023.  
  3024. Func _date_juliandayno($iyear, $imonth, $iday)
  3025. Local $sfulldate = StringFormat("%04d/%02d/%02d", $iyear, $imonth, $iday)
  3026. If NOT _dateisvalid($sfulldate) Then
  3027. Return SetError(1, 0, "")
  3028. EndIf
  3029. Local $ijday = 0
  3030. Local $aidaysinmonth = _daysinmonth($iyear)
  3031. For $icntr = 1 To $imonth - 1
  3032. $ijday = $ijday + $aidaysinmonth[$icntr]
  3033. Next
  3034. $ijday = ($iyear * 1000) + ($ijday + $iday)
  3035. Return $ijday
  3036. EndFunc
  3037.  
  3038. Func _juliantodate($ijday, $ssep = "/")
  3039. Local $iyear = Int($ijday / 1000)
  3040. Local $idays = Mod($ijday, 1000)
  3041. Local $imaxdays = 365
  3042. If _dateisleapyear($iyear) Then $imaxdays = 366
  3043. If $idays > $imaxdays Then
  3044. Return SetError(1, 0, "")
  3045. EndIf
  3046. Local $aidaysinmonth = _daysinmonth($iyear)
  3047. Local $imonth = 1
  3048. While $idays > $aidaysinmonth[$imonth]
  3049. $idays = $idays - $aidaysinmonth[$imonth]
  3050. $imonth = $imonth + 1
  3051. WEnd
  3052. Return StringFormat("%04d%s%02d%s%02d", $iyear, $ssep, $imonth, $ssep, $idays)
  3053. EndFunc
  3054.  
  3055. Func _now()
  3056. Return _datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, 0)
  3057. EndFunc
  3058.  
  3059. Func _nowcalc()
  3060. Return @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC
  3061. EndFunc
  3062.  
  3063. Func _nowcalcdate()
  3064. Return @YEAR & "/" & @MON & "/" & @MDAY
  3065. EndFunc
  3066.  
  3067. Func _nowdate()
  3068. Return _datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY, 0)
  3069. EndFunc
  3070.  
  3071. Func _nowtime($stype = 3)
  3072. If $stype < 3 OR $stype > 5 Then $stype = 3
  3073. Return _datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, $stype)
  3074. EndFunc
  3075.  
  3076. Func _setdate($iday, $imonth = 0, $iyear = 0)
  3077. If $iyear = 0 Then $iyear = @YEAR
  3078. If $imonth = 0 Then $imonth = @MON
  3079. If NOT _dateisvalid($iyear & "/" & $imonth & "/" & $iday) Then Return 1
  3080. Local $tsystemtime = DllStructCreate($tagsystemtime)
  3081. DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsystemtime)
  3082. If @error Then Return SetError(@error, @extended, 0)
  3083. DllStructSetData($tsystemtime, "Day", $iday)
  3084. If $imonth > 0 Then DllStructSetData($tsystemtime, "Month", $imonth)
  3085. If $iyear > 0 Then DllStructSetData($tsystemtime, "Year", $iyear)
  3086. Local $ireturn = _date_time_setlocaltime($tsystemtime)
  3087. If @error Then Return SetError(@error + 10, @extended, 0)
  3088. Return Int($ireturn)
  3089. EndFunc
  3090.  
  3091. Func _settime($ihour, $iminute, $isecond = 0, $imseconds = 0)
  3092. If $ihour < 0 OR $ihour > 23 Then Return 1
  3093. If $iminute < 0 OR $iminute > 59 Then Return 1
  3094. If $isecond < 0 OR $isecond > 59 Then Return 1
  3095. If $imseconds < 0 OR $imseconds > 999 Then Return 1
  3096. Local $tsystemtime = DllStructCreate($tagsystemtime)
  3097. DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsystemtime)
  3098. If @error Then Return SetError(@error, @extended, 0)
  3099. DllStructSetData($tsystemtime, "Hour", $ihour)
  3100. DllStructSetData($tsystemtime, "Minute", $iminute)
  3101. If $isecond > 0 Then DllStructSetData($tsystemtime, "Second", $isecond)
  3102. If $imseconds > 0 Then DllStructSetData($tsystemtime, "MSeconds", $imseconds)
  3103. Local $ireturn = _date_time_setlocaltime($tsystemtime)
  3104. If @error Then Return SetError(@error + 10, @extended, 0)
  3105. Return Int($ireturn)
  3106. EndFunc
  3107.  
  3108. Func _tickstotime($iticks, ByRef $ihours, ByRef $imins, ByRef $isecs)
  3109. If Number($iticks) > 0 Then
  3110. $iticks = Int($iticks / 1000)
  3111. $ihours = Int($iticks / 3600)
  3112. $iticks = Mod($iticks, 3600)
  3113. $imins = Int($iticks / 60)
  3114. $isecs = Mod($iticks, 60)
  3115. Return 1
  3116. ElseIf Number($iticks) = 0 Then
  3117. $ihours = 0
  3118. $iticks = 0
  3119. $imins = 0
  3120. $isecs = 0
  3121. Return 1
  3122. Else
  3123. Return SetError(1, 0, 0)
  3124. EndIf
  3125. EndFunc
  3126.  
  3127. Func _timetoticks($ihours = @HOUR, $imins = @MIN, $isecs = @SEC)
  3128. If StringIsInt($ihours) AND StringIsInt($imins) AND StringIsInt($isecs) Then
  3129. Local $iticks = 1000 * ((3600 * $ihours) + (60 * $imins) + $isecs)
  3130. Return $iticks
  3131. Else
  3132. Return SetError(1, 0, 0)
  3133. EndIf
  3134. EndFunc
  3135.  
  3136. Func _weeknumberiso($iyear = @YEAR, $imonth = @MON, $iday = @MDAY)
  3137. If $iday > 31 OR $iday < 1 Then
  3138. Return SetError(1, 0, -1)
  3139. ElseIf NOT __dateismonth($imonth) Then
  3140. Return SetError(2, 0, -1)
  3141. ElseIf $iyear < 1 OR $iyear > 2999 Then
  3142. Return SetError(3, 0, -1)
  3143. EndIf
  3144. Local $idow = _datetodayofweekiso($iyear, $imonth, $iday) - 1
  3145. Local $idow0101 = _datetodayofweekiso($iyear, 1, 1) - 1
  3146. If ($imonth = 1 AND 3 < $idow0101 AND $idow0101 < 7 - ($iday - 1)) Then
  3147. $idow = $idow0101 - 1
  3148. $idow0101 = _datetodayofweekiso($iyear - 1, 1, 1) - 1
  3149. $imonth = 12
  3150. $iday = 31
  3151. $iyear = $iyear - 1
  3152. ElseIf ($imonth = 12 AND 30 - ($iday - 1) < _datetodayofweekiso($iyear + 1, 1, 1) - 1 AND _datetodayofweekiso($iyear + 1, 1, 1) - 1 < 4) Then
  3153. Return 1
  3154. EndIf
  3155. Return Int((_datetodayofweekiso($iyear, 1, 1) - 1 < 4) + 4 * ($imonth - 1) + (2 * ($imonth - 1) + ($iday - 1) + $idow0101 - $idow + 6) * 36 / 256)
  3156. EndFunc
  3157.  
  3158. Func _weeknumber($iyear = @YEAR, $imonth = @MON, $iday = @MDAY, $iweekstart = 1)
  3159. If $iday > 31 OR $iday < 1 Then
  3160. Return SetError(1, 0, -1)
  3161. ElseIf NOT __dateismonth($imonth) Then
  3162. Return SetError(3, 0, -1)
  3163. ElseIf $iyear < 1 OR $iyear > 2999 Then
  3164. Return SetError(4, 0, -1)
  3165. ElseIf $iweekstart < 1 OR $iweekstart > 2 Then
  3166. Return SetError(2, 0, -1)
  3167. EndIf
  3168. Local $istartweek1, $iendweek1
  3169. Local $idow0101 = _datetodayofweekiso($iyear, 1, 1)
  3170. Local $idate = $iyear & "/" & $imonth & "/" & $iday
  3171. If $iweekstart = 1 Then
  3172. If $idow0101 = 6 Then
  3173. $istartweek1 = 0
  3174. Else
  3175. $istartweek1 = -1 * $idow0101 - 1
  3176. EndIf
  3177. $iendweek1 = $istartweek1 + 6
  3178. Else
  3179. $istartweek1 = $idow0101 * -1
  3180. $iendweek1 = $istartweek1 + 6
  3181. EndIf
  3182. Local $istartweek1ny
  3183. Local $iendweek1date = _dateadd("d", $iendweek1, $iyear & "/01/01")
  3184. Local $idow0101ny = _datetodayofweekiso($iyear + 1, 1, 1)
  3185. If $iweekstart = 1 Then
  3186. If $idow0101ny = 6 Then
  3187. $istartweek1ny = 0
  3188. Else
  3189. $istartweek1ny = -1 * $idow0101ny - 1
  3190. EndIf
  3191. Else
  3192. $istartweek1ny = $idow0101ny * -1
  3193. EndIf
  3194. Local $istartweek1dateny = _dateadd("d", $istartweek1ny, $iyear + 1 & "/01/01")
  3195. Local $icurrdatediff = _datediff("d", $iendweek1date, $idate) - 1
  3196. Local $icurrdatediffny = _datediff("d", $istartweek1dateny, $idate)
  3197. If $icurrdatediff >= 0 AND $icurrdatediffny < 0 Then Return 2 + Int($icurrdatediff / 7)
  3198. If $icurrdatediff < 0 OR $icurrdatediffny >= 0 Then Return 1
  3199. EndFunc
  3200.  
  3201. Func _daysinmonth($iyear)
  3202. Local $adays = [12, 31, (_dateisleapyear($iyear) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
  3203. Return $adays
  3204. EndFunc
  3205.  
  3206. Func __date_time_clonesystemtime($psystemtime)
  3207. Local $tsystemtime1 = DllStructCreate($tagsystemtime, $psystemtime)
  3208. Local $tsystemtime2 = DllStructCreate($tagsystemtime)
  3209. DllStructSetData($tsystemtime2, "Month", DllStructGetData($tsystemtime1, "Month"))
  3210. DllStructSetData($tsystemtime2, "Day", DllStructGetData($tsystemtime1, "Day"))
  3211. DllStructSetData($tsystemtime2, "Year", DllStructGetData($tsystemtime1, "Year"))
  3212. DllStructSetData($tsystemtime2, "Hour", DllStructGetData($tsystemtime1, "Hour"))
  3213. DllStructSetData($tsystemtime2, "Minute", DllStructGetData($tsystemtime1, "Minute"))
  3214. DllStructSetData($tsystemtime2, "Second", DllStructGetData($tsystemtime1, "Second"))
  3215. DllStructSetData($tsystemtime2, "MSeconds", DllStructGetData($tsystemtime1, "MSeconds"))
  3216. DllStructSetData($tsystemtime2, "DOW", DllStructGetData($tsystemtime1, "DOW"))
  3217. Return $tsystemtime2
  3218. EndFunc
  3219.  
  3220. Func _date_time_comparefiletime($tfiletime1, $tfiletime2)
  3221. Local $aresult = DllCall("kernel32.dll", "long", "CompareFileTime", "struct*", $tfiletime1, "struct*", $tfiletime2)
  3222. If @error Then Return SetError(@error, @extended, 0)
  3223. Return $aresult[0]
  3224. EndFunc
  3225.  
  3226. Func _date_time_dosdatetimetofiletime($ifatdate, $ifattime)
  3227. Local $ttime = DllStructCreate($tagfiletime)
  3228. Local $aresult = DllCall("kernel32.dll", "bool", "DosDateTimeToFileTime", "word", $ifatdate, "word", $ifattime, "struct*", $ttime)
  3229. If @error Then Return SetError(@error, @extended, 0)
  3230. Return SetExtended($aresult[0], $ttime)
  3231. EndFunc
  3232.  
  3233. Func _date_time_dosdatetoarray($idosdate)
  3234. Local $adate[3]
  3235. $adate[0] = BitAND($idosdate, 31)
  3236. $adate[1] = BitAND(BitShift($idosdate, 5), 15)
  3237. $adate[2] = BitAND(BitShift($idosdate, 9), 63) + 1980
  3238. Return $adate
  3239. EndFunc
  3240.  
  3241. Func _date_time_dosdatetimetoarray($idosdate, $idostime)
  3242. Local $adate[6]
  3243. $adate[0] = BitAND($idosdate, 31)
  3244. $adate[1] = BitAND(BitShift($idosdate, 5), 15)
  3245. $adate[2] = BitAND(BitShift($idosdate, 9), 63) + 1980
  3246. $adate[5] = BitAND($idostime, 31) * 2
  3247. $adate[4] = BitAND(BitShift($idostime, 5), 63)
  3248. $adate[3] = BitAND(BitShift($idostime, 11), 31)
  3249. Return $adate
  3250. EndFunc
  3251.  
  3252. Func _date_time_dosdatetimetostr($idosdate, $idostime)
  3253. Local $adate = _date_time_dosdatetimetoarray($idosdate, $idostime)
  3254. Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $adate[0], $adate[1], $adate[2], $adate[3], $adate[4], $adate[5])
  3255. EndFunc
  3256.  
  3257. Func _date_time_dosdatetostr($idosdate)
  3258. Local $adate = _date_time_dosdatetoarray($idosdate)
  3259. Return StringFormat("%02d/%02d/%04d", $adate[0], $adate[1], $adate[2])
  3260. EndFunc
  3261.  
  3262. Func _date_time_dostimetoarray($idostime)
  3263. Local $atime[3]
  3264. $atime[2] = BitAND($idostime, 31) * 2
  3265. $atime[1] = BitAND(BitShift($idostime, 5), 63)
  3266. $atime[0] = BitAND(BitShift($idostime, 11), 31)
  3267. Return $atime
  3268. EndFunc
  3269.  
  3270. Func _date_time_dostimetostr($idostime)
  3271. Local $atime = _date_time_dostimetoarray($idostime)
  3272. Return StringFormat("%02d:%02d:%02d", $atime[0], $atime[1], $atime[2])
  3273. EndFunc
  3274.  
  3275. Func _date_time_encodefiletime($imonth, $iday, $iyear, $ihour = 0, $iminute = 0, $isecond = 0, $imseconds = 0)
  3276. Local $tsystemtime = _date_time_encodesystemtime($imonth, $iday, $iyear, $ihour, $iminute, $isecond, $imseconds)
  3277. Return _date_time_systemtimetofiletime($tsystemtime)
  3278. EndFunc
  3279.  
  3280. Func _date_time_encodesystemtime($imonth, $iday, $iyear, $ihour = 0, $iminute = 0, $isecond = 0, $imseconds = 0)
  3281. Local $tsystemtime = DllStructCreate($tagsystemtime)
  3282. DllStructSetData($tsystemtime, "Month", $imonth)
  3283. DllStructSetData($tsystemtime, "Day", $iday)
  3284. DllStructSetData($tsystemtime, "Year", $iyear)
  3285. DllStructSetData($tsystemtime, "Hour", $ihour)
  3286. DllStructSetData($tsystemtime, "Minute", $iminute)
  3287. DllStructSetData($tsystemtime, "Second", $isecond)
  3288. DllStructSetData($tsystemtime, "MSeconds", $imseconds)
  3289. Return $tsystemtime
  3290. EndFunc
  3291.  
  3292. Func _date_time_filetimetoarray(ByRef $tfiletime)
  3293. If ((DllStructGetData($tfiletime, 1) + DllStructGetData($tfiletime, 2)) = 0) Then Return SetError(10, 0, 0)
  3294. Local $tsystemtime = _date_time_filetimetosystemtime($tfiletime)
  3295. If @error Then Return SetError(@error, @extended, 0)
  3296. Return _date_time_systemtimetoarray($tsystemtime)
  3297. EndFunc
  3298.  
  3299. Func _date_time_filetimetostr(ByRef $tfiletime, $ifmt = 0)
  3300. Local $adate = _date_time_filetimetoarray($tfiletime)
  3301. If @error Then Return SetError(@error, @extended, "")
  3302. If $ifmt Then
  3303. Return StringFormat("%04d/%02d/%02d %02d:%02d:%02d", $adate[2], $adate[0], $adate[1], $adate[3], $adate[4], $adate[5])
  3304. Else
  3305. Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $adate[0], $adate[1], $adate[2], $adate[3], $adate[4], $adate[5])
  3306. EndIf
  3307. EndFunc
  3308.  
  3309. Func _date_time_filetimetodosdatetime($tfiletime)
  3310. Local $adate[2]
  3311. Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToDosDateTime", "struct*", $tfiletime, "word*", 0, "word*", 0)
  3312. If @error Then Return SetError(@error, @extended, $adate)
  3313. $adate[0] = $aresult[2]
  3314. $adate[1] = $aresult[3]
  3315. Return SetExtended($aresult[0], $adate)
  3316. EndFunc
  3317.  
  3318. Func _date_time_filetimetolocalfiletime($tfiletime)
  3319. Local $tlocal = DllStructCreate($tagfiletime)
  3320. Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToLocalFileTime", "struct*", $tfiletime, "struct*", $tlocal)
  3321. If @error Then Return SetError(@error, @extended, 0)
  3322. Return SetExtended($aresult[0], $tlocal)
  3323. EndFunc
  3324.  
  3325. Func _date_time_filetimetosystemtime($tfiletime)
  3326. Local $tsysttime = DllStructCreate($tagsystemtime)
  3327. Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToSystemTime", "struct*", $tfiletime, "struct*", $tsysttime)
  3328. If @error Then Return SetError(@error, @extended, 0)
  3329. Return SetExtended($aresult[0], $tsysttime)
  3330. EndFunc
  3331.  
  3332. Func _date_time_getfiletime($hfile)
  3333. Local $adate[3]
  3334. $adate[0] = DllStructCreate($tagfiletime)
  3335. $adate[1] = DllStructCreate($tagfiletime)
  3336. $adate[2] = DllStructCreate($tagfiletime)
  3337. Local $aresult = DllCall("kernel32.dll", "bool", "GetFileTime", "handle", $hfile, "struct*", $adate[0], "struct*", $adate[1], "struct*", $adate[2])
  3338. If @error Then Return SetError(@error, @extended, 0)
  3339. Return SetExtended($aresult[0], $adate)
  3340. EndFunc
  3341.  
  3342. Func _date_time_getlocaltime()
  3343. Local $tsysttime = DllStructCreate($tagsystemtime)
  3344. DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsysttime)
  3345. If @error Then Return SetError(@error, @extended, 0)
  3346. Return $tsysttime
  3347. EndFunc
  3348.  
  3349. Func _date_time_getsystemtime()
  3350. Local $tsysttime = DllStructCreate($tagsystemtime)
  3351. DllCall("kernel32.dll", "none", "GetSystemTime", "struct*", $tsysttime)
  3352. If @error Then Return SetError(@error, @extended, 0)
  3353. Return $tsysttime
  3354. EndFunc
  3355.  
  3356. Func _date_time_getsystemtimeadjustment()
  3357. Local $ainfo[3]
  3358. Local $aresult = DllCall("kernel32.dll", "bool", "GetSystemTimeAdjustment", "dword*", 0, "dword*", 0, "bool*", 0)
  3359. If @error Then Return SetError(@error, @extended, 0)
  3360. $ainfo[0] = $aresult[1]
  3361. $ainfo[1] = $aresult[2]
  3362. $ainfo[2] = $aresult[3] <> 0
  3363. Return SetExtended($aresult[0], $ainfo)
  3364. EndFunc
  3365.  
  3366. Func _date_time_getsystemtimeasfiletime()
  3367. Local $tfiletime = DllStructCreate($tagfiletime)
  3368. DllCall("kernel32.dll", "none", "GetSystemTimeAsFileTime", "struct*", $tfiletime)
  3369. If @error Then Return SetError(@error, @extended, 0)
  3370. Return $tfiletime
  3371. EndFunc
  3372.  
  3373. Func _date_time_getsystemtimes()
  3374. Local $ainfo[3]
  3375. $ainfo[0] = DllStructCreate($tagfiletime)
  3376. $ainfo[1] = DllStructCreate($tagfiletime)
  3377. $ainfo[2] = DllStructCreate($tagfiletime)
  3378. Local $aresult = DllCall("kernel32.dll", "bool", "GetSystemTimes", "struct*", $ainfo[0], "struct*", $ainfo[1], "struct*", $ainfo[2])
  3379. If @error Then Return SetError(@error, @extended, 0)
  3380. Return SetExtended($aresult[0], $ainfo)
  3381. EndFunc
  3382.  
  3383. Func _date_time_gettickcount()
  3384. Local $aresult = DllCall("kernel32.dll", "dword", "GetTickCount")
  3385. If @error Then Return SetError(@error, @extended, 0)
  3386. Return $aresult[0]
  3387. EndFunc
  3388.  
  3389. Func _date_time_gettimezoneinformation()
  3390. Local $ttimezone = DllStructCreate($tagtime_zone_information)
  3391. Local $aresult = DllCall("kernel32.dll", "dword", "GetTimeZoneInformation", "struct*", $ttimezone)
  3392. If @error OR $aresult[0] = -1 Then Return SetError(@error, @extended, 0)
  3393. Local $ainfo[8]
  3394. $ainfo[0] = $aresult[0]
  3395. $ainfo[1] = DllStructGetData($ttimezone, "Bias")
  3396. $ainfo[2] = DllStructGetData($ttimezone, "StdName")
  3397. $ainfo[3] = __date_time_clonesystemtime(DllStructGetPtr($ttimezone, "StdDate"))
  3398. $ainfo[4] = DllStructGetData($ttimezone, "StdBias")
  3399. $ainfo[5] = DllStructGetData($ttimezone, "DayName")
  3400. $ainfo[6] = __date_time_clonesystemtime(DllStructGetPtr($ttimezone, "DayDate"))
  3401. $ainfo[7] = DllStructGetData($ttimezone, "DayBias")
  3402. Return $ainfo
  3403. EndFunc
  3404.  
  3405. Func _date_time_localfiletimetofiletime($tlocaltime)
  3406. Local $tfiletime = DllStructCreate($tagfiletime)
  3407. Local $aresult = DllCall("kernel32.dll", "bool", "LocalFileTimeToFileTime", "struct*", $tlocaltime, "struct*", $tfiletime)
  3408. If @error Then Return SetError(@error, @extended, 0)
  3409. Return SetExtended($aresult[0], $tfiletime)
  3410. EndFunc
  3411.  
  3412. Func _date_time_setfiletime($hfile, $tcreatetime, $tlastaccess, $tlastwrite)
  3413. Local $aresult = DllCall("kernel32.dll", "bool", "SetFileTime", "handle", $hfile, "struct*", $tcreatetime, "struct*", $tlastaccess, "struct*", $tlastwrite)
  3414. If @error Then Return SetError(@error, @extended, False)
  3415. Return $aresult[0]
  3416. EndFunc
  3417.  
  3418. Func _date_time_setlocaltime($tsystemtime)
  3419. Local $aresult = DllCall("kernel32.dll", "bool", "SetLocalTime", "struct*", $tsystemtime)
  3420. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, False)
  3421. $aresult = DllCall("kernel32.dll", "bool", "SetLocalTime", "struct*", $tsystemtime)
  3422. If @error Then Return SetError(@error, @extended, False)
  3423. Return $aresult[0]
  3424. EndFunc
  3425.  
  3426. Func _date_time_setsystemtime($tsystemtime)
  3427. Local $aresult = DllCall("kernel32.dll", "bool", "SetSystemTime", "struct*", $tsystemtime)
  3428. If @error Then Return SetError(@error, @extended, False)
  3429. Return $aresult[0]
  3430. EndFunc
  3431.  
  3432. Func _date_time_setsystemtimeadjustment($iadjustment, $bdisabled)
  3433. Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
  3434. If @error Then Return SetError(@error + 10, @extended, False)
  3435. _security__setprivilege($htoken, "SeSystemtimePrivilege", True)
  3436. Local $ierror = @error
  3437. Local $ilasterror = @extended
  3438. Local $bret = False
  3439. If NOT @error Then
  3440. Local $aresult = DllCall("kernel32.dll", "bool", "SetSystemTimeAdjustment", "dword", $iadjustment, "bool", $bdisabled)
  3441. If @error Then
  3442. $ierror = @error
  3443. $ilasterror = @extended
  3444. ElseIf $aresult[0] Then
  3445. $bret = True
  3446. Else
  3447. $ierror = 20
  3448. $ilasterror = _winapi_getlasterror()
  3449. EndIf
  3450. _security__setprivilege($htoken, "SeSystemtimePrivilege", False)
  3451. If NOT $ierror AND @error Then $ierror = 22
  3452. EndIf
  3453. _winapi_closehandle($htoken)
  3454. Return SetError($ierror, $ilasterror, $bret)
  3455. EndFunc
  3456.  
  3457. Func _date_time_settimezoneinformation($ibias, $sstdname, $tstddate, $istdbias, $sdayname, $tdaydate, $idaybias)
  3458. Local $tzoneinfo = DllStructCreate($tagtime_zone_information)
  3459. DllStructSetData($tzoneinfo, "Bias", $ibias)
  3460. DllStructSetData($tzoneinfo, "StdName", $sstdname)
  3461. _memmovememory($tstddate, DllStructGetPtr($tzoneinfo, "StdDate"), DllStructGetSize($tstddate))
  3462. DllStructSetData($tzoneinfo, "StdBias", $istdbias)
  3463. DllStructSetData($tzoneinfo, "DayName", $sdayname)
  3464. _memmovememory($tdaydate, DllStructGetPtr($tzoneinfo, "DayDate"), DllStructGetSize($tdaydate))
  3465. DllStructSetData($tzoneinfo, "DayBias", $idaybias)
  3466. Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
  3467. If @error Then Return SetError(@error + 10, @extended, False)
  3468. _security__setprivilege($htoken, "SeTimeZonePrivilege", True)
  3469. Local $ierror = @error
  3470. Local $ilasterror = @extended
  3471. Local $bret = False
  3472. If NOT @error Then
  3473. Local $aresult = DllCall("kernel32.dll", "bool", "SetTimeZoneInformation", "struct*", $tzoneinfo)
  3474. If @error Then
  3475. $ierror = @error
  3476. $ilasterror = @extended
  3477. ElseIf $aresult[0] Then
  3478. $ilasterror = 0
  3479. $bret = True
  3480. Else
  3481. $ierror = 20
  3482. $ilasterror = _winapi_getlasterror()
  3483. EndIf
  3484. _security__setprivilege($htoken, "SeTimeZonePrivilege", False)
  3485. If NOT $ierror AND @error Then $ierror = 22
  3486. EndIf
  3487. _winapi_closehandle($htoken)
  3488. Return SetError($ierror, $ilasterror, $bret)
  3489. EndFunc
  3490.  
  3491. Func _date_time_systemtimetoarray(ByRef $tsystemtime)
  3492. Local $ainfo[8]
  3493. $ainfo[0] = DllStructGetData($tsystemtime, "Month")
  3494. $ainfo[1] = DllStructGetData($tsystemtime, "Day")
  3495. $ainfo[2] = DllStructGetData($tsystemtime, "Year")
  3496. $ainfo[3] = DllStructGetData($tsystemtime, "Hour")
  3497. $ainfo[4] = DllStructGetData($tsystemtime, "Minute")
  3498. $ainfo[5] = DllStructGetData($tsystemtime, "Second")
  3499. $ainfo[6] = DllStructGetData($tsystemtime, "MSeconds")
  3500. $ainfo[7] = DllStructGetData($tsystemtime, "DOW")
  3501. Return $ainfo
  3502. EndFunc
  3503.  
  3504. Func _date_time_systemtimetodatestr(ByRef $tsystemtime, $ifmt = 0)
  3505. Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
  3506. If @error Then Return SetError(@error, @extended, "")
  3507. If $ifmt Then
  3508. Return StringFormat("%04d/%02d/%02d", $ainfo[2], $ainfo[0], $ainfo[1])
  3509. Else
  3510. Return StringFormat("%02d/%02d/%04d", $ainfo[0], $ainfo[1], $ainfo[2])
  3511. EndIf
  3512. EndFunc
  3513.  
  3514. Func _date_time_systemtimetodatetimestr(ByRef $tsystemtime, $ifmt = 0)
  3515. Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
  3516. If @error Then Return SetError(@error, @extended, "")
  3517. If $ifmt Then
  3518. Return StringFormat("%04d/%02d/%02d %02d:%02d:%02d", $ainfo[2], $ainfo[0], $ainfo[1], $ainfo[3], $ainfo[4], $ainfo[5])
  3519. Else
  3520. Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $ainfo[0], $ainfo[1], $ainfo[2], $ainfo[3], $ainfo[4], $ainfo[5])
  3521. EndIf
  3522. EndFunc
  3523.  
  3524. Func _date_time_systemtimetofiletime($tsystemtime)
  3525. Local $tfiletime = DllStructCreate($tagfiletime)
  3526. Local $aresult = DllCall("kernel32.dll", "bool", "SystemTimeToFileTime", "struct*", $tsystemtime, "struct*", $tfiletime)
  3527. If @error Then Return SetError(@error, @extended, 0)
  3528. Return SetExtended($aresult[0], $tfiletime)
  3529. EndFunc
  3530.  
  3531. Func _date_time_systemtimetotimestr(ByRef $tsystemtime)
  3532. Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
  3533. Return StringFormat("%02d:%02d:%02d", $ainfo[3], $ainfo[4], $ainfo[5])
  3534. EndFunc
  3535.  
  3536. Func _date_time_systemtimetotzspecificlocaltime($tutc, $ttimezone = 0)
  3537. Local $tlocaltime = DllStructCreate($tagsystemtime)
  3538. Local $aresult = DllCall("kernel32.dll", "bool", "SystemTimeToTzSpecificLocalTime", "struct*", $ttimezone, "struct*", $tutc, "struct*", $tlocaltime)
  3539. If @error Then Return SetError(@error, @extended, 0)
  3540. Return SetExtended($aresult[0], $tlocaltime)
  3541. EndFunc
  3542.  
  3543. Func _date_time_tzspecificlocaltimetosystemtime($tlocaltime, $ttimezone = 0)
  3544. Local $tutc = DllStructCreate($tagsystemtime)
  3545. Local $aresult = DllCall("kernel32.dll", "bool", "TzSpecificLocalTimeToSystemTime", "struct*", $ttimezone, "struct*", $tlocaltime, "struct*", $tutc)
  3546. If @error Then Return SetError(@error, @extended, 0)
  3547. Return SetExtended($aresult[0], $tutc)
  3548. EndFunc
  3549.  
  3550. Global Const $backup_alternate_data = 4
  3551. Global Const $backup_data = 1
  3552. Global Const $backup_ea_data = 2
  3553. Global Const $backup_link = 5
  3554. Global Const $backup_object_id = 7
  3555. Global Const $backup_property_data = 6
  3556. Global Const $backup_reparse_data = 8
  3557. Global Const $backup_security_data = 3
  3558. Global Const $backup_sparse_block = 9
  3559. Global Const $backup_txfs_data = 10
  3560. Global Const $copy_file_allow_decrypted_destination = 8
  3561. Global Const $copy_file_copy_symlink = 2048
  3562. Global Const $copy_file_fail_if_exists = 1
  3563. Global Const $copy_file_no_buffering = 4096
  3564. Global Const $copy_file_open_source_for_write = 4
  3565. Global Const $copy_file_restartable = 2
  3566. Global Const $move_file_copy_allowed = 2
  3567. Global Const $move_file_create_hardlink = 16
  3568. Global Const $move_file_delay_until_reboot = 4
  3569. Global Const $move_file_fail_if_not_trackable = 32
  3570. Global Const $move_file_replace_existing = 1
  3571. Global Const $move_file_write_through = 8
  3572. Global Const $progress_continue = 0
  3573. Global Const $progress_cancel = 1
  3574. Global Const $progress_stop = 2
  3575. Global Const $progress_quiet = 3
  3576. Global Const $file_append_data = 4
  3577. Global Const $file_delete_child = 64
  3578. Global Const $file_execute = 32
  3579. Global Const $file_read_attributes = 128
  3580. Global Const $file_read_data = 1
  3581. Global Const $file_read_ea = 8
  3582. Global Const $file_write_attributes = 256
  3583. Global Const $file_write_data = 2
  3584. Global Const $file_write_ea = 16
  3585. Global Const $file_add_file = $file_write_data
  3586. Global Const $file_add_subdirectory = $file_append_data
  3587. Global Const $file_create_pipe_instance = $file_append_data
  3588. Global Const $file_list_directory = $file_read_data
  3589. Global Const $file_traverse = $file_execute
  3590. Global Const $file_all_access = 2032127
  3591. Global Const $file_flag_backup_semantics = 33554432
  3592. Global Const $file_flag_delete_on_close = 67108864
  3593. Global Const $file_flag_no_buffering = 536870912
  3594. Global Const $file_flag_open_no_recall = 1048576
  3595. Global Const $file_flag_open_reparse_point = 2097152
  3596. Global Const $file_flag_overlapped = 1073741824
  3597. Global Const $file_flag_posix_semantics = 1048576
  3598. Global Const $file_flag_random_access = 268435456
  3599. Global Const $file_flag_sequential_scan = 134217728
  3600. Global Const $file_flag_write_through = -2147483648
  3601. Global Const $security_anonymous = 0
  3602. Global Const $security_context_tracking = 262144
  3603. Global Const $security_delegation = 196608
  3604. Global Const $security_effective_only = 524288
  3605. Global Const $security_identification = 65536
  3606. Global Const $security_impersonation = 131072
  3607. Global Const $sec_commit = 134217728
  3608. Global Const $sec_image = 16777216
  3609. Global Const $sec_large_pages = -2147483648
  3610. Global Const $sec_nocache = 268435456
  3611. Global Const $sec_reserve = 67108864
  3612. Global Const $sec_writecombine = 1073741824
  3613. Global Const $section_extend_size = 16
  3614. Global Const $section_map_execute = 8
  3615. Global Const $section_map_read = 4
  3616. Global Const $section_map_write = 2
  3617. Global Const $section_query = 1
  3618. Global Const $section_all_access = 2031647
  3619. Global Const $file_map_copy = 1
  3620. Global Const $file_map_execute = 32
  3621. Global Const $file_map_read = 4
  3622. Global Const $file_map_write = 2
  3623. Global Const $file_map_all_access = $section_all_access
  3624. Global Const $ddd_exact_match_on_remove = 4
  3625. Global Const $ddd_no_broadcast_system = 8
  3626. Global Const $ddd_raw_target_path = 1
  3627. Global Const $ddd_remove_definition = 2
  3628. Global Const $fsctl_allow_extended_dasd_io = 589955
  3629. Global Const $fsctl_create_or_get_object_id = 590016
  3630. Global Const $fsctl_create_usn_journal = 590055
  3631. Global Const $fsctl_delete_object_id = 589984
  3632. Global Const $fsctl_delete_reparse_point = 589996
  3633. Global Const $fsctl_delete_usn_journal = 590072
  3634. Global Const $fsctl_dismount_volume = 589856
  3635. Global Const $fsctl_dump_property_data = 589975
  3636. Global Const $fsctl_enable_upgrade = 622800
  3637. Global Const $fsctl_encryption_fsctl_io = 590043
  3638. Global Const $fsctl_enum_usn_data = 590003
  3639. Global Const $fsctl_extend_volume = 590064
  3640. Global Const $fsctl_filesystem_get_statistics = 589920
  3641. Global Const $fsctl_find_files_by_sid = 589967
  3642. Global Const $fsctl_get_compression = 589884
  3643. Global Const $fsctl_get_ntfs_file_record = 589928
  3644. Global Const $fsctl_get_ntfs_volume_data = 589924
  3645. Global Const $fsctl_get_object_id = 589980
  3646. Global Const $fsctl_get_reparse_point = 589992
  3647. Global Const $fsctl_get_retrieval_pointers = 589939
  3648. Global Const $fsctl_get_volume_bitmap = 589935
  3649. Global Const $fsctl_hsm_data = 639251
  3650. Global Const $fsctl_hsm_msg = 639240
  3651. Global Const $fsctl_invalidate_volumes = 589908
  3652. Global Const $fsctl_is_pathname_valid = 589868
  3653. Global Const $fsctl_is_volume_dirty = 589944
  3654. Global Const $fsctl_is_volume_mounted = 589864
  3655. Global Const $fsctl_lock_volume = 589848
  3656. Global Const $fsctl_mark_as_system_hive = 589903
  3657. Global Const $fsctl_mark_handle = 590076
  3658. Global Const $fsctl_mark_volume_dirty = 589872
  3659. Global Const $fsctl_move_file = 589940
  3660. Global Const $fsctl_opbatch_ack_close_pending = 589840
  3661. Global Const $fsctl_oplock_break_ack_no_2 = 589904
  3662. Global Const $fsctl_oplock_break_acknowledge = 589836
  3663. Global Const $fsctl_oplock_break_notify = 589844
  3664. Global Const $fsctl_query_allocated_ranges = 606415
  3665. Global Const $fsctl_query_fat_bpb = 589912
  3666. Global Const $fsctl_query_retrieval_pointers = 589883
  3667. Global Const $fsctl_query_usn_journal = 590068
  3668. Global Const $fsctl_read_file_usn_data = 590059
  3669. Global Const $fsctl_read_property_data = 589959
  3670. Global Const $fsctl_read_raw_encrypted = 590051
  3671. Global Const $fsctl_read_usn_journal = 590011
  3672. Global Const $fsctl_recall_file = 590103
  3673. Global Const $fsctl_request_batch_oplock = 589832
  3674. Global Const $fsctl_request_filter_oplock = 589916
  3675. Global Const $fsctl_request_oplock_level_1 = 589824
  3676. Global Const $fsctl_request_oplock_level_2 = 589828
  3677. Global Const $fsctl_security_id_check = 606391
  3678. Global Const $fsctl_set_compression = 639040
  3679. Global Const $fsctl_set_encryption = 590039
  3680. Global Const $fsctl_set_object_id = 589976
  3681. Global Const $fsctl_set_object_id_extended = 590012
  3682. Global Const $fsctl_set_reparse_point = 589988
  3683. Global Const $fsctl_set_sparse = 590020
  3684. Global Const $fsctl_set_zero_data = 622792
  3685. Global Const $fsctl_sis_copyfile = 590080
  3686. Global Const $fsctl_sis_link_files = 639236
  3687. Global Const $fsctl_unlock_volume = 589852
  3688. Global Const $fsctl_write_property_data = 589963
  3689. Global Const $fsctl_write_raw_encrypted = 590047
  3690. Global Const $fsctl_write_usn_close_record = 590063
  3691. Global Const $ioctl_aacs_end_session = 3363020
  3692. Global Const $ioctl_aacs_generate_binding_nonce = 3395824
  3693. Global Const $ioctl_aacs_get_certificate = 3363028
  3694. Global Const $ioctl_aacs_get_challenge_key = 3363032
  3695. Global Const $ioctl_aacs_read_binding_nonce = 3363052
  3696. Global Const $ioctl_aacs_read_media_id = 3363048
  3697. Global Const $ioctl_aacs_read_media_key_block = 3363012
  3698. Global Const $ioctl_aacs_read_media_key_block_size = 3363008
  3699. Global Const $ioctl_aacs_read_serial_number = 3363044
  3700. Global Const $ioctl_aacs_read_volume_id = 3363040
  3701. Global Const $ioctl_aacs_send_certificate = 3363024
  3702. Global Const $ioctl_aacs_send_challenge_key = 3363036
  3703. Global Const $ioctl_aacs_start_session = 3363016
  3704. Global Const $ioctl_ata_pass_through = 315436
  3705. Global Const $ioctl_ata_pass_through_direct = 315440
  3706. Global Const $ioctl_cdrom_check_verify = 149504
  3707. Global Const $ioctl_cdrom_disk_type = 131136
  3708. Global Const $ioctl_cdrom_eject_media = 149512
  3709. Global Const $ioctl_cdrom_find_new_devices = 149528
  3710. Global Const $ioctl_cdrom_get_configuration = 147544
  3711. Global Const $ioctl_cdrom_get_control = 147508
  3712. Global Const $ioctl_cdrom_get_drive_geometry = 147532
  3713. Global Const $ioctl_cdrom_get_drive_geometry_ex = 147536
  3714. Global Const $ioctl_cdrom_get_last_session = 147512
  3715. Global Const $ioctl_cdrom_get_volume = 147476
  3716. Global Const $ioctl_cdrom_load_media = 149516
  3717. Global Const $ioctl_cdrom_media_removal = 149508
  3718. Global Const $ioctl_cdrom_pause_audio = 147468
  3719. Global Const $ioctl_cdrom_play_audio_msf = 147480
  3720. Global Const $ioctl_cdrom_raw_read = 147518
  3721. Global Const $ioctl_cdrom_read_q_channel = 147500
  3722. Global Const $ioctl_cdrom_read_toc = 147456
  3723. Global Const $ioctl_cdrom_read_toc_ex = 147540
  3724. Global Const $ioctl_cdrom_release = 149524
  3725. Global Const $ioctl_cdrom_reserve = 149520
  3726. Global Const $ioctl_cdrom_resume_audio = 147472
  3727. Global Const $ioctl_cdrom_seek_audio_msf = 147460
  3728. Global Const $ioctl_cdrom_set_volume = 147496
  3729. Global Const $ioctl_cdrom_stop_audio = 147464
  3730. Global Const $ioctl_cdrom_unload_driver = 151560
  3731. Global Const $ioctl_disk_check_verify = 477184
  3732. Global Const $ioctl_disk_controller_number = 458820
  3733. Global Const $ioctl_disk_create_disk = 507992
  3734. Global Const $ioctl_disk_delete_drive_layout = 508160
  3735. Global Const $ioctl_disk_eject_media = 477192
  3736. Global Const $ioctl_disk_find_new_devices = 477208
  3737. Global Const $ioctl_disk_format_tracks = 507928
  3738. Global Const $ioctl_disk_format_tracks_ex = 507948
  3739. Global Const $ioctl_disk_get_cache_information = 475348
  3740. Global Const $ioctl_disk_get_drive_geometry = 458752
  3741. Global Const $ioctl_disk_get_drive_geometry_ex = 458912
  3742. Global Const $ioctl_disk_get_drive_layout = 475148
  3743. Global Const $ioctl_disk_get_drive_layout_ex = 458832
  3744. Global Const $ioctl_disk_get_length_info = 475228
  3745. Global Const $ioctl_disk_get_media_types = 461824
  3746. Global Const $ioctl_disk_get_partition_info = 475140
  3747. Global Const $ioctl_disk_get_partition_info_ex = 458824
  3748. Global Const $ioctl_disk_get_write_cache_state = 475356
  3749. Global Const $ioctl_disk_grow_partition = 508112
  3750. Global Const $ioctl_disk_histogram_data = 458804
  3751. Global Const $ioctl_disk_histogram_reset = 458808
  3752. Global Const $ioctl_disk_histogram_structure = 458800
  3753. Global Const $ioctl_disk_internal_clear_verify = 459783
  3754. Global Const $ioctl_disk_internal_set_notify = 459784
  3755. Global Const $ioctl_disk_internal_set_verify = 459779
  3756. Global Const $ioctl_disk_is_writable = 458788
  3757. Global Const $ioctl_disk_load_media = 477196
  3758. Global Const $ioctl_disk_logging = 458792
  3759. Global Const $ioctl_disk_media_removal = 477188
  3760. Global Const $ioctl_disk_performance = 458784
  3761. Global Const $ioctl_disk_performance_off = 458848
  3762. Global Const $ioctl_disk_reassign_blocks = 507932
  3763. Global Const $ioctl_disk_release = 477204
  3764. Global Const $ioctl_disk_request_data = 458816
  3765. Global Const $ioctl_disk_request_structure = 458812
  3766. Global Const $ioctl_disk_reserve = 477200
  3767. Global Const $ioctl_disk_set_cache_information = 508120
  3768. Global Const $ioctl_disk_set_drive_layout = 507920
  3769. Global Const $ioctl_disk_set_drive_layout_ex = 507988
  3770. Global Const $ioctl_disk_set_partition_info = 507912
  3771. Global Const $ioctl_disk_set_partition_info_ex = 507980
  3772. Global Const $ioctl_disk_update_drive_size = 508104
  3773. Global Const $ioctl_disk_update_properties = 459072
  3774. Global Const $ioctl_disk_verify = 458772
  3775. Global Const $ioctl_dvd_end_session = 3362828
  3776. Global Const $ioctl_dvd_get_region = 3362836
  3777. Global Const $ioctl_dvd_read_key = 3362820
  3778. Global Const $ioctl_dvd_read_structure = 3363136
  3779. Global Const $ioctl_dvd_send_key = 3362824
  3780. Global Const $ioctl_dvd_send_key2 = 3395608
  3781. Global Const $ioctl_dvd_set_read_ahead = 3362832
  3782. Global Const $ioctl_dvd_start_session = 3362816
  3783. Global Const $ioctl_mountdev_link_created = 5046288
  3784. Global Const $ioctl_mountdev_link_deleted = 5046292
  3785. Global Const $ioctl_mountdev_query_stable_guid = 5046296
  3786. Global Const $ioctl_mountdev_query_suggested_link_name = 5046284
  3787. Global Const $ioctl_mountdev_query_unique_id = 5046272
  3788. Global Const $ioctl_mountdev_unique_id_change_notify = 5046276
  3789. Global Const $ioctl_mountmgr_auto_dl_assignments = 7192596
  3790. Global Const $ioctl_mountmgr_change_notify = 7159840
  3791. Global Const $ioctl_mountmgr_check_unprocessed_volumes = 7159848
  3792. Global Const $ioctl_mountmgr_create_point = 7192576
  3793. Global Const $ioctl_mountmgr_delete_points = 7192580
  3794. Global Const $ioctl_mountmgr_delete_points_dbonly = 7192588
  3795. Global Const $ioctl_mountmgr_keep_links_when_offline = 7192612
  3796. Global Const $ioctl_mountmgr_next_drive_letter = 7192592
  3797. Global Const $ioctl_mountmgr_query_dos_volume_path = 7143472
  3798. Global Const $ioctl_mountmgr_query_dos_volume_paths = 7143476
  3799. Global Const $ioctl_mountmgr_query_points = 7143432
  3800. Global Const $ioctl_mountmgr_volume_arrival_notification = 7159852
  3801. Global Const $ioctl_mountmgr_volume_mount_point_created = 7192600
  3802. Global Const $ioctl_mountmgr_volume_mount_point_deleted = 7192604
  3803. Global Const $ioctl_scsi_get_inquiry_data = 266252
  3804. Global Const $ioctl_scsi_get_capabilities = 266256
  3805. Global Const $ioctl_scsi_get_address = 266264
  3806. Global Const $ioctl_scsi_miniport = 315400
  3807. Global Const $ioctl_scsi_pass_through = 315396
  3808. Global Const $ioctl_scsi_pass_through_direct = 315412
  3809. Global Const $ioctl_scsi_rescan_bus = 266268
  3810. Global Const $ioctl_storage_break_reservation = 2969620
  3811. Global Const $ioctl_storage_check_verify = 2967552
  3812. Global Const $ioctl_storage_check_verify2 = 2951168
  3813. Global Const $ioctl_storage_eject_media = 2967560
  3814. Global Const $ioctl_storage_ejection_control = 2951488
  3815. Global Const $ioctl_storage_find_new_devices = 2967576
  3816. Global Const $ioctl_storage_get_device_number = 2953344
  3817. Global Const $ioctl_storage_get_hotplug_info = 2952212
  3818. Global Const $ioctl_storage_get_media_serial_number = 2952208
  3819. Global Const $ioctl_storage_get_media_types = 2952192
  3820. Global Const $ioctl_storage_get_media_types_ex = 2952196
  3821. Global Const $ioctl_storage_load_media = 2967564
  3822. Global Const $ioctl_storage_load_media2 = 2951180
  3823. Global Const $ioctl_storage_manage_data_set_attributes = 2987012
  3824. Global Const $ioctl_storage_mcn_control = 2951492
  3825. Global Const $ioctl_storage_media_removal = 2967556
  3826. Global Const $ioctl_storage_persistent_reserve_in = 2969624
  3827. Global Const $ioctl_storage_persistent_reserve_out = 2969628
  3828. Global Const $ioctl_storage_predict_failure = 2953472
  3829. Global Const $ioctl_storage_query_property = 2954240
  3830. Global Const $ioctl_storage_release = 2967572
  3831. Global Const $ioctl_storage_reserve = 2967568
  3832. Global Const $ioctl_storage_reset_bus = 2969600
  3833. Global Const $ioctl_storage_reset_device = 2969604
  3834. Global Const $ioctl_storage_set_hotplug_info = 3001368
  3835. Global Const $ioctl_storage_set_read_ahead = 2966528
  3836. Global Const $ioctl_volume_get_gpt_attributes = 5636152
  3837. Global Const $ioctl_volume_get_volume_disk_extents = 5636096
  3838. Global Const $ioctl_volume_is_clustered = 5636144
  3839. Global Const $ioctl_volume_is_io_capable = 5636116
  3840. Global Const $ioctl_volume_is_offline = 5636112
  3841. Global Const $ioctl_volume_is_partition = 5636136
  3842. Global Const $ioctl_volume_logical_to_physical = 5636128
  3843. Global Const $ioctl_volume_offline = 5685260
  3844. Global Const $ioctl_volume_online = 5685256
  3845. Global Const $ioctl_volume_physical_to_logical = 5636132
  3846. Global Const $ioctl_volume_query_failover_set = 5636120
  3847. Global Const $ioctl_volume_query_volume_number = 5636124
  3848. Global Const $ioctl_volume_read_plex = 5652526
  3849. Global Const $ioctl_volume_set_gpt_attributes = 5636148
  3850. Global Const $ioctl_volume_supports_online_offline = 5636100
  3851. Global Const $smart_get_version = 475264
  3852. Global Const $smart_rcv_drive_data = 508040
  3853. Global Const $smart_send_drive_command = 508036
  3854. Global Const $file_encryptable = 0
  3855. Global Const $file_is_encrypted = 1
  3856. Global Const $file_read_only = 8
  3857. Global Const $file_root_dir = 3
  3858. Global Const $file_system_attr = 2
  3859. Global Const $file_system_dir = 4
  3860. Global Const $file_system_not_support = 6
  3861. Global Const $file_unknown = 5
  3862. Global Const $file_user_disallowed = 7
  3863. Global Const $scs_32bit_binary = 0
  3864. Global Const $scs_64bit_binary = 6
  3865. Global Const $scs_dos_binary = 1
  3866. Global Const $scs_os216_binary = 5
  3867. Global Const $scs_pif_binary = 3
  3868. Global Const $scs_posix_binary = 4
  3869. Global Const $scs_wow_binary = 2
  3870. Global Const $drive_bus_type_unknown = 0
  3871. Global Const $drive_bus_type_scsi = 1
  3872. Global Const $drive_bus_type_atapi = 2
  3873. Global Const $drive_bus_type_ata = 3
  3874. Global Const $drive_bus_type_1394 = 4
  3875. Global Const $drive_bus_type_ssa = 5
  3876. Global Const $drive_bus_type_fibre = 6
  3877. Global Const $drive_bus_type_usb = 7
  3878. Global Const $drive_bus_type_raid = 8
  3879. Global Const $drive_bus_type_iscsi = 9
  3880. Global Const $drive_bus_type_sas = 10
  3881. Global Const $drive_bus_type_sata = 11
  3882. Global Const $drive_bus_type_sd = 12
  3883. Global Const $drive_bus_type_mmc = 13
  3884. Global Const $drive_unknown = 0
  3885. Global Const $drive_no_root_dir = 1
  3886. Global Const $drive_removable = 2
  3887. Global Const $drive_fixed = 3
  3888. Global Const $drive_remote = 4
  3889. Global Const $drive_cdrom = 5
  3890. Global Const $drive_ramdisk = 6
  3891. Global Const $file_type_char = 2
  3892. Global Const $file_type_disk = 1
  3893. Global Const $file_type_pipe = 3
  3894. Global Const $file_type_remote = 32768
  3895. Global Const $file_type_unknown = 0
  3896. Global Const $file_name_normalized = 0
  3897. Global Const $file_name_opened = 8
  3898. Global Const $volume_name_dos = 0
  3899. Global Const $volume_name_guid = 1
  3900. Global Const $volume_name_none = 4
  3901. Global Const $volume_name_nt = 2
  3902. Global Const $image_file_machine_unknown = 0
  3903. Global Const $image_file_machine_am33 = 467
  3904. Global Const $image_file_machine_amd64 = 34404
  3905. Global Const $image_file_machine_arm = 448
  3906. Global Const $image_file_machine_ebc = 3772
  3907. Global Const $image_file_machine_i386 = 332
  3908. Global Const $image_file_machine_ia64 = 512
  3909. Global Const $image_file_machine_m32r = 36929
  3910. Global Const $image_file_machine_mips16 = 614
  3911. Global Const $image_file_machine_mipsfpu = 870
  3912. Global Const $image_file_machine_mipsfpu16 = 1126
  3913. Global Const $image_file_machine_powerpc = 496
  3914. Global Const $image_file_machine_powerpcfp = 497
  3915. Global Const $image_file_machine_r4000 = 358
  3916. Global Const $image_file_machine_sh3 = 418
  3917. Global Const $image_file_machine_sh3dsp = 419
  3918. Global Const $image_file_machine_sh4 = 422
  3919. Global Const $image_file_machine_sh5 = 424
  3920. Global Const $image_file_machine_thumb = 450
  3921. Global Const $image_file_machine_wcemipsv2 = 361
  3922. Global Const $file_case_preserved_names = 2
  3923. Global Const $file_case_sensitive_search = 1
  3924. Global Const $file_file_compression = 16
  3925. Global Const $file_named_streams = 262144
  3926. Global Const $file_persistent_acls = 8
  3927. Global Const $file_read_only_volume = 524288
  3928. Global Const $file_sequential_write_once = 1048576
  3929. Global Const $file_supports_encryption = 131072
  3930. Global Const $file_supports_extended_attributes = 8388608
  3931. Global Const $file_supports_hard_links = 4194304
  3932. Global Const $file_supports_object_ids = 65536
  3933. Global Const $file_supports_open_by_file_id = 16777216
  3934. Global Const $file_supports_reparse_points = 128
  3935. Global Const $file_supports_sparse_files = 64
  3936. Global Const $file_supports_transactions = 2097152
  3937. Global Const $file_supports_usn_journal = 33554432
  3938. Global Const $file_unicode_on_disk = 4
  3939. Global Const $file_volume_is_compressed = 32768
  3940. Global Const $file_volume_quotas = 32
  3941. Global Const $file_device_8042_port = 39
  3942. Global Const $file_device_acpi = 50
  3943. Global Const $file_device_battery = 41
  3944. Global Const $file_device_beep = 1
  3945. Global Const $file_device_bus_extender = 42
  3946. Global Const $file_device_cd_rom = 2
  3947. Global Const $file_device_cd_rom_file_system = 3
  3948. Global Const $file_device_changer = 48
  3949. Global Const $file_device_controller = 4
  3950. Global Const $file_device_datalink = 5
  3951. Global Const $file_device_dfs = 6
  3952. Global Const $file_device_dfs_file_system = 53
  3953. Global Const $file_device_dfs_volume = 54
  3954. Global Const $file_device_disk = 7
  3955. Global Const $file_device_disk_file_system = 8
  3956. Global Const $file_device_dvd = 51
  3957. Global Const $file_device_file_system = 9
  3958. Global Const $file_device_fips = 58
  3959. Global Const $file_device_fullscreen_video = 52
  3960. Global Const $file_device_inport_port = 10
  3961. Global Const $file_device_keyboard = 11
  3962. Global Const $file_device_ks = 47
  3963. Global Const $file_device_ksec = 57
  3964. Global Const $file_device_mailslot = 12
  3965. Global Const $file_device_mass_storage = 45
  3966. Global Const $file_device_midi_in = 13
  3967. Global Const $file_device_midi_out = 14
  3968. Global Const $file_device_modem = 43
  3969. Global Const $file_device_mouse = 15
  3970. Global Const $file_device_multi_unc_provider = 16
  3971. Global Const $file_device_named_pipe = 17
  3972. Global Const $file_device_network = 18
  3973. Global Const $file_device_network_browser = 19
  3974. Global Const $file_device_network_file_system = 20
  3975. Global Const $file_device_network_redirector = 40
  3976. Global Const $file_device_null = 21
  3977. Global Const $file_device_parallel_port = 22
  3978. Global Const $file_device_physical_netcard = 23
  3979. Global Const $file_device_printer = 24
  3980. Global Const $file_device_scanner = 25
  3981. Global Const $file_device_screen = 28
  3982. Global Const $file_device_serenum = 55
  3983. Global Const $file_device_serial_mouse_port = 26
  3984. Global Const $file_device_serial_port = 27
  3985. Global Const $file_device_smartcard = 49
  3986. Global Const $file_device_smb = 46
  3987. Global Const $file_device_sound = 29
  3988. Global Const $file_device_streams = 30
  3989. Global Const $file_device_tape = 31
  3990. Global Const $file_device_tape_file_system = 32
  3991. Global Const $file_device_termsrv = 56
  3992. Global Const $file_device_transport = 33
  3993. Global Const $file_device_unknown = 34
  3994. Global Const $file_device_vdm = 44
  3995. Global Const $file_device_video = 35
  3996. Global Const $file_device_virtual_disk = 36
  3997. Global Const $file_device_wave_in = 37
  3998. Global Const $file_device_wave_out = 38
  3999. Global Const $file_any_access = 0
  4000. Global Const $file_special_access = $file_any_access
  4001. Global Const $file_read_access = 1
  4002. Global Const $file_write_access = 2
  4003. Global Const $method_buffered = 0
  4004. Global Const $method_in_direct = 1
  4005. Global Const $method_out_direct = 2
  4006. Global Const $method_neither = 3
  4007. Global Const $file_notify_change_file_name = 1
  4008. Global Const $file_notify_change_dir_name = 2
  4009. Global Const $file_notify_change_attributes = 4
  4010. Global Const $file_notify_change_size = 8
  4011. Global Const $file_notify_change_last_write = 16
  4012. Global Const $file_notify_change_last_access = 32
  4013. Global Const $file_notify_change_creation = 64
  4014. Global Const $file_notify_change_security = 256
  4015. Global Const $file_action_added = 1
  4016. Global Const $file_action_removed = 2
  4017. Global Const $file_action_modified = 3
  4018. Global Const $file_action_renamed_old_name = 4
  4019. Global Const $file_action_renamed_new_name = 5
  4020. Global Const $replacefile_write_through = 1
  4021. Global Const $replacefile_ignore_merge_errors = 2
  4022. Global Const $replacefile_ignore_acl_errors = 4
  4023. Global Const $base_search_path_enable_safe_searchmode = 1
  4024. Global Const $base_search_path_disable_safe_searchmode = 65536
  4025. Global Const $base_search_path_permanent = 32768
  4026. #Region Global Variables and Constants
  4027. #EndRegion Global Variables and Constants
  4028. #Region Functions list
  4029. #EndRegion Functions list
  4030. #Region Public Functions
  4031.  
  4032. Func _winapi_chartooem($sstr)
  4033. Local $aret = DllCall("user32.dll", "bool", "CharToOemW", "wstr", $sstr, "wstr", "")
  4034. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  4035. Return $aret[2]
  4036. EndFunc
  4037.  
  4038. Func _winapi_clienttoscreen($hwnd, ByRef $tpoint)
  4039. Local $aret = DllCall("user32.dll", "bool", "ClientToScreen", "hwnd", $hwnd, "struct*", $tpoint)
  4040. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  4041. Return $tpoint
  4042. EndFunc
  4043.  
  4044. Func _winapi_dwordtofloat($ivalue)
  4045. Local $tdword = DllStructCreate("dword")
  4046. Local $tfloat = DllStructCreate("float", DllStructGetPtr($tdword))
  4047. DllStructSetData($tdword, 1, $ivalue)
  4048. Return DllStructGetData($tfloat, 1)
  4049. EndFunc
  4050.  
  4051. Func _winapi_dwordtoint($ivalue)
  4052. Local $tdata = DllStructCreate("int")
  4053. DllStructSetData($tdata, 1, $ivalue)
  4054. Return DllStructGetData($tdata, 1)
  4055. EndFunc
  4056.  
  4057. Func _winapi_floattodword($ivalue)
  4058. Local $tfloat = DllStructCreate("float")
  4059. Local $tdword = DllStructCreate("dword", DllStructGetPtr($tfloat))
  4060. DllStructSetData($tfloat, 1, $ivalue)
  4061. Return DllStructGetData($tdword, 1)
  4062. EndFunc
  4063.  
  4064. Func _winapi_floattoint($nfloat)
  4065. Local $tfloat = DllStructCreate("float")
  4066. Local $tint = DllStructCreate("int", DllStructGetPtr($tfloat))
  4067. DllStructSetData($tfloat, 1, $nfloat)
  4068. Return DllStructGetData($tint, 1)
  4069. EndFunc
  4070.  
  4071. Func _winapi_getxyfrompoint(ByRef $tpoint, ByRef $ix, ByRef $iy)
  4072. $ix = DllStructGetData($tpoint, "X")
  4073. $iy = DllStructGetData($tpoint, "Y")
  4074. EndFunc
  4075.  
  4076. Func _winapi_guidfromstring($sguid)
  4077. Local $tguid = DllStructCreate($tagguid)
  4078. _winapi_guidfromstringex($sguid, $tguid)
  4079. If @error Then Return SetError(@error + 10, @extended, 0)
  4080. Return $tguid
  4081. EndFunc
  4082.  
  4083. Func _winapi_guidfromstringex($sguid, $tguid)
  4084. Local $aresult = DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $sguid, "struct*", $tguid)
  4085. If @error Then Return SetError(@error, @extended, False)
  4086. Return $aresult[0]
  4087. EndFunc
  4088.  
  4089. Func _winapi_hashdata($pmemory, $isize, $ilength = 32)
  4090. If ($ilength <= 0) OR ($ilength > 256) Then Return SetError(11, 0, 0)
  4091. Local $tdata = DllStructCreate("byte[" & $ilength & "]")
  4092. Local $aret = DllCall("shlwapi.dll", "uint", "HashData", "struct*", $pmemory, "dword", $isize, "struct*", $tdata, "dword", $ilength)
  4093. If @error Then Return SetError(@error, @extended, 0)
  4094. If $aret[0] Then Return SetError(10, $aret[0], 0)
  4095. Return DllStructGetData($tdata, 1)
  4096. EndFunc
  4097.  
  4098. Func _winapi_hashstring($sstring, $bcasesensitive = True, $ilength = 32)
  4099. Local $ilengths = StringLen($sstring)
  4100. If NOT $ilengths OR ($ilength > 256) Then Return SetError(12, 0, 0)
  4101. Local $tstring = DllStructCreate("wchar[" & ($ilengths + 1) & "]")
  4102. If NOT $bcasesensitive Then
  4103. $sstring = StringLower($sstring)
  4104. EndIf
  4105. DllStructSetData($tstring, 1, $sstring)
  4106. Local $shash = _winapi_hashdata($tstring, 2 * $ilengths, $ilength)
  4107. If @error Then Return SetError(@error, @extended, 0)
  4108. Return $shash
  4109. EndFunc
  4110.  
  4111. Func _winapi_hibyte($ivalue)
  4112. Return BitAND(BitShift($ivalue, 8), 255)
  4113. EndFunc
  4114.  
  4115. Func _winapi_hidword($ivalue)
  4116. Local $tint64 = DllStructCreate("int64")
  4117. Local $tqword = DllStructCreate("dword;dword", DllStructGetPtr($tint64))
  4118. DllStructSetData($tint64, 1, $ivalue)
  4119. Return DllStructGetData($tqword, 2)
  4120. EndFunc
  4121.  
  4122. Func _winapi_hiword($ilong)
  4123. Return BitShift($ilong, 16)
  4124. EndFunc
  4125.  
  4126. Func _winapi_inttodword($ivalue)
  4127. Local $tdata = DllStructCreate("dword")
  4128. DllStructSetData($tdata, 1, $ivalue)
  4129. Return DllStructGetData($tdata, 1)
  4130. EndFunc
  4131.  
  4132. Func _winapi_inttofloat($iint)
  4133. Local $tint = DllStructCreate("int")
  4134. Local $tfloat = DllStructCreate("float", DllStructGetPtr($tint))
  4135. DllStructSetData($tint, 1, $iint)
  4136. Return DllStructGetData($tfloat, 1)
  4137. EndFunc
  4138.  
  4139. Func _winapi_lobyte($ivalue)
  4140. Return BitAND($ivalue, 255)
  4141. EndFunc
  4142.  
  4143. Func _winapi_lodword($ivalue)
  4144. Local $tint64 = DllStructCreate("int64")
  4145. Local $tqword = DllStructCreate("dword;dword", DllStructGetPtr($tint64))
  4146. DllStructSetData($tint64, 1, $ivalue)
  4147. Return DllStructGetData($tqword, 1)
  4148. EndFunc
  4149.  
  4150. Func _winapi_loword($ilong)
  4151. Return BitAND($ilong, 65535)
  4152. EndFunc
  4153.  
  4154. Func _winapi_longmid($ivalue, $istart, $icount)
  4155. Return BitAND(BitShift($ivalue, $istart), BitOR(BitShift(BitShift(2147483647, 32 - ($icount + 1)), 1), BitShift(1, -($icount - 1))))
  4156. EndFunc
  4157.  
  4158. Func _winapi_makelangid($ilngidprimary, $ilngidsub)
  4159. Return BitOR(BitShift($ilngidsub, -10), $ilngidprimary)
  4160. EndFunc
  4161.  
  4162. Func _winapi_makelcid($ilngid, $isortid)
  4163. Return BitOR(BitShift($isortid, -16), $ilngid)
  4164. EndFunc
  4165.  
  4166. Func _winapi_makelong($ilo, $ihi)
  4167. Return BitOR(BitShift($ihi, -16), BitAND($ilo, 65535))
  4168. EndFunc
  4169.  
  4170. Func _winapi_makeqword($ilodword, $ihidword)
  4171. Local $tint64 = DllStructCreate("uint64")
  4172. Local $tdwords = DllStructCreate("dword;dword", DllStructGetPtr($tint64))
  4173. DllStructSetData($tdwords, 1, $ilodword)
  4174. DllStructSetData($tdwords, 2, $ihidword)
  4175. Return DllStructGetData($tint64, 1)
  4176. EndFunc
  4177.  
  4178. Func _winapi_makeword($ilo, $ihi)
  4179. Local $tword = DllStructCreate("ushort")
  4180. Local $tbyte = DllStructCreate("byte;byte", DllStructGetPtr($tword))
  4181. DllStructSetData($tbyte, 1, $ihi)
  4182. DllStructSetData($tbyte, 2, $ilo)
  4183. Return DllStructGetData($tword, 1)
  4184. EndFunc
  4185.  
  4186. Func _winapi_multibytetowidechar($vtext, $icodepage = 0, $iflags = 0, $bretstring = False)
  4187. Local $stexttype = "str"
  4188. If NOT IsString($vtext) Then $stexttype = "struct*"
  4189. Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, $stexttype, $vtext, "int", -1, "ptr", 0, "int", 0)
  4190. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
  4191. Local $iout = $aresult[0]
  4192. Local $tout = DllStructCreate("wchar[" & $iout & "]")
  4193. $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, $stexttype, $vtext, "int", -1, "struct*", $tout, "int", $iout)
  4194. If @error OR NOT $aresult[0] Then Return SetError(@error + 20, @extended, 0)
  4195. If $bretstring Then Return DllStructGetData($tout, 1)
  4196. Return $tout
  4197. EndFunc
  4198.  
  4199. Func _winapi_multibytetowidecharex($stext, $ptext, $icodepage = 0, $iflags = 0)
  4200. Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, "STR", $stext, "int", -1, "struct*", $ptext, "int", (StringLen($stext) + 1) * 2)
  4201. If @error Then Return SetError(@error, @extended, False)
  4202. Return $aresult[0]
  4203. EndFunc
  4204.  
  4205. Func _winapi_oemtochar($sstr)
  4206. Local $aret = DllCall("user32.dll", "bool", "OemToChar", "str", $sstr, "str", "")
  4207. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  4208. Return $aret[2]
  4209. EndFunc
  4210.  
  4211. Func _winapi_pointfromrect(ByRef $trect, $bcenter = True)
  4212. Local $ix1 = DllStructGetData($trect, "Left")
  4213. Local $iy1 = DllStructGetData($trect, "Top")
  4214. Local $ix2 = DllStructGetData($trect, "Right")
  4215. Local $iy2 = DllStructGetData($trect, "Bottom")
  4216. If $bcenter Then
  4217. $ix1 = $ix1 + (($ix2 - $ix1) / 2)
  4218. $iy1 = $iy1 + (($iy2 - $iy1) / 2)
  4219. EndIf
  4220. Local $tpoint = DllStructCreate($tagpoint)
  4221. DllStructSetData($tpoint, "X", $ix1)
  4222. DllStructSetData($tpoint, "Y", $iy1)
  4223. Return $tpoint
  4224. EndFunc
  4225.  
  4226. Func _winapi_primarylangid($ilngid)
  4227. Return BitAND($ilngid, 1023)
  4228. EndFunc
  4229.  
  4230. Func _winapi_screentoclient($hwnd, ByRef $tpoint)
  4231. Local $aresult = DllCall("user32.dll", "bool", "ScreenToClient", "hwnd", $hwnd, "struct*", $tpoint)
  4232. If @error Then Return SetError(@error, @extended, False)
  4233. Return $aresult[0]
  4234. EndFunc
  4235.  
  4236. Func _winapi_shorttoword($ivalue)
  4237. Return BitAND($ivalue, 65535)
  4238. EndFunc
  4239.  
  4240. Func _winapi_strformatbytesize($isize)
  4241. Local $aret = DllCall("shlwapi.dll", "ptr", "StrFormatByteSizeW", "int64", $isize, "wstr", "", "uint", 1024)
  4242. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  4243. Return $aret[2]
  4244. EndFunc
  4245.  
  4246. Func _winapi_strformatbytesizeex($isize)
  4247. Local $asymbol = DllCall("kernel32.dll", "int", "GetLocaleInfoW", "dword", 1024, "dword", 15, "wstr", "", "int", 2048)
  4248. If @error Then Return SetError(@error + 10, @extended, "")
  4249. Local $ssize = _winapi_strformatbytesize(0)
  4250. If @error Then Return SetError(@error, @extended, "")
  4251. Return StringReplace($ssize, "0", StringRegExpReplace(Number($isize), "(?<=\d)(?=(\d{3})+\z)", $asymbol[3]))
  4252. EndFunc
  4253.  
  4254. Func _winapi_strformatkbsize($isize)
  4255. Local $aret = DllCall("shlwapi.dll", "ptr", "StrFormatKBSizeW", "int64", $isize, "wstr", "", "uint", 1024)
  4256. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  4257. Return $aret[2]
  4258. EndFunc
  4259.  
  4260. Func _winapi_strfromtimeinterval($itime, $idigits = 7)
  4261. Local $aret = DllCall("shlwapi.dll", "int", "StrFromTimeIntervalW", "wstr", "", "uint", 1024, "dword", $itime, "int", $idigits)
  4262. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  4263. Return StringStripWS($aret[1], $str_stripleading + $str_striptrailing)
  4264. EndFunc
  4265.  
  4266. Func _winapi_stringfromguid($tguid)
  4267. Local $aresult = DllCall("ole32.dll", "int", "StringFromGUID2", "struct*", $tguid, "wstr", "", "int", 40)
  4268. If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, "")
  4269. Return SetExtended($aresult[0], $aresult[2])
  4270. EndFunc
  4271.  
  4272. Func _winapi_sublangid($ilngid)
  4273. Return BitShift($ilngid, 10)
  4274. EndFunc
  4275.  
  4276. Func _winapi_swapdword($ivalue)
  4277. Local $tstruct1 = DllStructCreate("dword;dword")
  4278. Local $tstruct2 = DllStructCreate("byte[4];byte[4]", DllStructGetPtr($tstruct1))
  4279. DllStructSetData($tstruct1, 1, $ivalue)
  4280. For $i = 1 To 4
  4281. DllStructSetData($tstruct2, 2, DllStructGetData($tstruct2, 1, 5 - $i), $i)
  4282. Next
  4283. Return DllStructGetData($tstruct1, 2)
  4284. EndFunc
  4285.  
  4286. Func _winapi_swapqword($ivalue)
  4287. Local $tstruct1 = DllStructCreate("int64;int64")
  4288. Local $tstruct2 = DllStructCreate("byte[8];byte[8]", DllStructGetPtr($tstruct1))
  4289. DllStructSetData($tstruct1, 1, $ivalue)
  4290. For $i = 1 To 8
  4291. DllStructSetData($tstruct2, 2, DllStructGetData($tstruct2, 1, 9 - $i), $i)
  4292. Next
  4293. Return DllStructGetData($tstruct1, 2)
  4294. EndFunc
  4295.  
  4296. Func _winapi_swapword($ivalue)
  4297. Local $tstruct1 = DllStructCreate("word;word")
  4298. Local $tstruct2 = DllStructCreate("byte[2];byte[2]", DllStructGetPtr($tstruct1))
  4299. DllStructSetData($tstruct1, 1, $ivalue)
  4300. For $i = 1 To 2
  4301. DllStructSetData($tstruct2, 2, DllStructGetData($tstruct2, 1, 3 - $i), $i)
  4302. Next
  4303. Return DllStructGetData($tstruct1, 2)
  4304. EndFunc
  4305.  
  4306. Func _winapi_widechartomultibyte($vunicode, $icodepage = 0, $bretnostruct = True, $bretbinary = False)
  4307. Local $sunicodetype = "wstr"
  4308. If NOT IsString($vunicode) Then $sunicodetype = "struct*"
  4309. Local $aresult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $icodepage, "dword", 0, $sunicodetype, $vunicode, "int", -1, "ptr", 0, "int", 0, "ptr", 0, "ptr", 0)
  4310. If @error OR NOT $aresult[0] Then Return SetError(@error + 20, @extended, "")
  4311. Local $tmultibyte = DllStructCreate((($bretbinary) ? ("byte") : ("char")) & "[" & $aresult[0] & "]")
  4312. $aresult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $icodepage, "dword", 0, $sunicodetype, $vunicode, "int", -1, "struct*", $tmultibyte, "int", $aresult[0], "ptr", 0, "ptr", 0)
  4313. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
  4314. If $bretnostruct Then Return DllStructGetData($tmultibyte, 1)
  4315. Return $tmultibyte
  4316. EndFunc
  4317.  
  4318. Func _winapi_wordtoshort($ivalue)
  4319. If BitAND($ivalue, 32768) Then
  4320. Return BitOR($ivalue, -32768)
  4321. EndIf
  4322. Return BitAND($ivalue, 32767)
  4323. EndFunc
  4324.  
  4325. #EndRegion Public Functions
  4326. #Region Global Variables and Constants
  4327. Global $__g_hheap = 0
  4328. #EndRegion Global Variables and Constants
  4329. #Region Functions list
  4330. #EndRegion Functions list
  4331. #Region Public Functions
  4332.  
  4333. Func _winapi_createbuffer($ilength, $pbuffer = 0, $babort = True)
  4334. $pbuffer = __heaprealloc($pbuffer, $ilength, 0, $babort)
  4335. If @error Then Return SetError(@error, @extended, 0)
  4336. Return $pbuffer
  4337. EndFunc
  4338.  
  4339. Func _winapi_createbufferfromstruct($tstruct, $pbuffer = 0, $babort = True)
  4340. If NOT IsDllStruct($tstruct) Then Return SetError(1, 0, 0)
  4341. $pbuffer = __heaprealloc($pbuffer, DllStructGetSize($tstruct), 0, $babort)
  4342. If @error Then Return SetError(@error + 100, @extended, 0)
  4343. _winapi_movememory($pbuffer, $tstruct, DllStructGetSize($tstruct))
  4344. Return $pbuffer
  4345. EndFunc
  4346.  
  4347. Func _winapi_createstring($sstring, $pstring = 0, $ilength = -1, $bunicode = True, $babort = True)
  4348. $ilength = Number($ilength)
  4349. If $ilength >= 0 Then
  4350. $sstring = StringLeft($sstring, $ilength)
  4351. Else
  4352. $ilength = StringLen($sstring)
  4353. EndIf
  4354. Local $isize = $ilength + 1
  4355. If $bunicode Then
  4356. $isize *= 2
  4357. EndIf
  4358. $pstring = __heaprealloc($pstring, $isize, 0, $babort)
  4359. If @error Then Return SetError(@error, @extended, 0)
  4360. DllStructSetData(DllStructCreate(($bunicode ? "wchar" : "char") & "[" & ($ilength + 1) & "]", $pstring), 1, $sstring)
  4361. Return SetExtended($ilength, $pstring)
  4362. EndFunc
  4363.  
  4364. Func _winapi_equalmemory($psource1, $psource2, $ilength)
  4365. If _winapi_isbadreadptr($psource1, $ilength) Then Return SetError(11, @extended, 0)
  4366. If _winapi_isbadreadptr($psource2, $ilength) Then Return SetError(12, @extended, 0)
  4367. Local $aret = DllCall("ntdll.dll", "ulong_ptr", "RtlCompareMemory", "struct*", $psource1, "struct*", $psource2, "ulong_ptr", $ilength)
  4368. If @error Then Return SetError(@error, @extended, 0)
  4369. Return Number($aret[0] = $ilength)
  4370. EndFunc
  4371.  
  4372. Func _winapi_fillmemory($pmemory, $ilength, $ivalue = 0)
  4373. If _winapi_isbadwriteptr($pmemory, $ilength) Then Return SetError(11, @extended, 0)
  4374. DllCall("ntdll.dll", "none", "RtlFillMemory", "struct*", $pmemory, "ulong_ptr", $ilength, "byte", $ivalue)
  4375. If @error Then Return SetError(@error, @extended, 0)
  4376. Return 1
  4377. EndFunc
  4378.  
  4379. Func _winapi_freememory($pmemory)
  4380. If NOT __heapfree($pmemory, 1) Then Return SetError(@error, @extended, 0)
  4381. Return 1
  4382. EndFunc
  4383.  
  4384. Func _winapi_getmemorysize($pmemory)
  4385. Local $iresult = __heapsize($pmemory, 1)
  4386. If @error Then Return SetError(@error, @extended, 0)
  4387. Return $iresult
  4388. EndFunc
  4389.  
  4390. Func _winapi_globalmemorystatus()
  4391. Local Const $tagmemorystatusex = "dword Length;dword MemoryLoad;" & "uint64 TotalPhys;uint64 AvailPhys;uint64 TotalPageFile;uint64 AvailPageFile;" & "uint64 TotalVirtual;uint64 AvailVirtual;uint64 AvailExtendedVirtual"
  4392. Local $tmem = DllStructCreate($tagmemorystatusex)
  4393. DllStructSetData($tmem, 1, DllStructGetSize($tmem))
  4394. Local $aret = DllCall("kernel32.dll", "bool", "GlobalMemoryStatusEx", "struct*", $tmem)
  4395. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  4396. Local $amem[7]
  4397. $amem[0] = DllStructGetData($tmem, 2)
  4398. $amem[1] = DllStructGetData($tmem, 3)
  4399. $amem[2] = DllStructGetData($tmem, 4)
  4400. $amem[3] = DllStructGetData($tmem, 5)
  4401. $amem[4] = DllStructGetData($tmem, 6)
  4402. $amem[5] = DllStructGetData($tmem, 7)
  4403. $amem[6] = DllStructGetData($tmem, 8)
  4404. Return $amem
  4405. EndFunc
  4406.  
  4407. Func _winapi_isbadcodeptr($paddress)
  4408. Local $aret = DllCall("kernel32.dll", "bool", "IsBadCodePtr", "struct*", $paddress)
  4409. If @error Then Return SetError(@error, @extended, False)
  4410. Return $aret[0]
  4411. EndFunc
  4412.  
  4413. Func _winapi_isbadreadptr($paddress, $ilength)
  4414. Local $aret = DllCall("kernel32.dll", "bool", "IsBadReadPtr", "struct*", $paddress, "uint_ptr", $ilength)
  4415. If @error Then Return SetError(@error, @extended, False)
  4416. Return $aret[0]
  4417. EndFunc
  4418.  
  4419. Func _winapi_isbadstringptr($paddress, $ilength)
  4420. Local $aret = DllCall("kernel32.dll", "bool", "IsBadStringPtr", "struct*", $paddress, "uint_ptr", $ilength)
  4421. If @error Then Return SetError(@error, @extended, False)
  4422. Return $aret[0]
  4423. EndFunc
  4424.  
  4425. Func _winapi_isbadwriteptr($paddress, $ilength)
  4426. Local $aret = DllCall("kernel32.dll", "bool", "IsBadWritePtr", "struct*", $paddress, "uint_ptr", $ilength)
  4427. If @error Then Return SetError(@error, @extended, False)
  4428. Return $aret[0]
  4429. EndFunc
  4430.  
  4431. Func _winapi_ismemory($pmemory)
  4432. Local $bresult = __heapvalidate($pmemory)
  4433. Return SetError(@error, @extended, $bresult)
  4434. EndFunc
  4435.  
  4436. Func _winapi_localfree($hmemory)
  4437. Local $aresult = DllCall("kernel32.dll", "handle", "LocalFree", "handle", $hmemory)
  4438. If @error Then Return SetError(@error, @extended, False)
  4439. Return $aresult[0]
  4440. EndFunc
  4441.  
  4442. Func _winapi_movememory($pdestination, $psource, $ilength)
  4443. If _winapi_isbadreadptr($psource, $ilength) Then Return SetError(10, @extended, 0)
  4444. If _winapi_isbadwriteptr($pdestination, $ilength) Then Return SetError(11, @extended, 0)
  4445. DllCall("ntdll.dll", "none", "RtlMoveMemory", "struct*", $pdestination, "struct*", $psource, "ulong_ptr", $ilength)
  4446. If @error Then Return SetError(@error, @extended, 0)
  4447. Return 1
  4448. EndFunc
  4449.  
  4450. Func _winapi_readprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isize, ByRef $iread)
  4451. Local $aresult = DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $hprocess, "ptr", $pbaseaddress, "struct*", $pbuffer, "ulong_ptr", $isize, "ulong_ptr*", 0)
  4452. If @error Then Return SetError(@error, @extended, False)
  4453. $iread = $aresult[5]
  4454. Return $aresult[0]
  4455. EndFunc
  4456.  
  4457. Func _winapi_writeprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isize, ByRef $iwritten, $sbuffer = "ptr")
  4458. Local $aresult = DllCall("kernel32.dll", "bool", "WriteProcessMemory", "handle", $hprocess, "ptr", $pbaseaddress, $sbuffer, $pbuffer, "ulong_ptr", $isize, "ulong_ptr*", 0)
  4459. If @error Then Return SetError(@error, @extended, False)
  4460. $iwritten = $aresult[5]
  4461. Return $aresult[0]
  4462. EndFunc
  4463.  
  4464. Func _winapi_zeromemory($pmemory, $ilength)
  4465. If _winapi_isbadwriteptr($pmemory, $ilength) Then Return SetError(11, @extended, 0)
  4466. DllCall("ntdll.dll", "none", "RtlZeroMemory", "struct*", $pmemory, "ulong_ptr", $ilength)
  4467. If @error Then Return SetError(@error, @extended, 0)
  4468. Return 1
  4469. EndFunc
  4470.  
  4471. #EndRegion Public Functions
  4472. #Region Internal Functions
  4473.  
  4474. Func __heapalloc($isize, $babort = False)
  4475. Local $aret
  4476. If NOT $__g_hheap Then
  4477. $aret = DllCall("kernel32.dll", "handle", "HeapCreate", "dword", 0, "ulong_ptr", 0, "ulong_ptr", 0)
  4478. If @error OR NOT $aret[0] Then __fatalexit(1, "Error allocating memory.")
  4479. $__g_hheap = $aret[0]
  4480. EndIf
  4481. $aret = DllCall("kernel32.dll", "ptr", "HeapAlloc", "handle", $__g_hheap, "dword", 8, "ulong_ptr", $isize)
  4482. If @error OR NOT $aret[0] Then
  4483. If $babort Then __fatalexit(1, "Error allocating memory.")
  4484. Return SetError(@error + 30, @extended, 0)
  4485. EndIf
  4486. Return $aret[0]
  4487. EndFunc
  4488.  
  4489. Func __heapfree(ByRef $pmemory, $bcheck = False, $icurerr = @error, $icurext = @extended)
  4490. If $bcheck AND (NOT __heapvalidate($pmemory)) Then Return SetError(@error, @extended, 0)
  4491. Local $aret = DllCall("kernel32.dll", "int", "HeapFree", "handle", $__g_hheap, "dword", 0, "ptr", $pmemory)
  4492. If @error OR NOT $aret[0] Then Return SetError(@error + 40, @extended, 0)
  4493. $pmemory = 0
  4494. Return SetError($icurerr, $icurext, 1)
  4495. EndFunc
  4496.  
  4497. Func __heaprealloc($pmemory, $isize, $bamount = False, $babort = False)
  4498. Local $aret, $pret
  4499. If __heapvalidate($pmemory) Then
  4500. If $bamount AND (__heapsize($pmemory) >= $isize) Then Return SetExtended(1, Ptr($pmemory))
  4501. $aret = DllCall("kernel32.dll", "ptr", "HeapReAlloc", "handle", $__g_hheap, "dword", 8, "ptr", $pmemory, "ulong_ptr", $isize)
  4502. If @error OR NOT $aret[0] Then
  4503. If $babort Then __fatalexit(1, "Error allocating memory.")
  4504. Return SetError(@error + 20, @extended, Ptr($pmemory))
  4505. EndIf
  4506. $pret = $aret[0]
  4507. Else
  4508. $pret = __heapalloc($isize, $babort)
  4509. If @error Then Return SetError(@error, @extended, 0)
  4510. EndIf
  4511. Return $pret
  4512. EndFunc
  4513.  
  4514. Func __heapsize($pmemory, $bcheck = False)
  4515. If $bcheck AND (NOT __heapvalidate($pmemory)) Then Return SetError(@error, @extended, 0)
  4516. Local $aret = DllCall("kernel32.dll", "ulong_ptr", "HeapSize", "handle", $__g_hheap, "dword", 0, "ptr", $pmemory)
  4517. If @error OR ($aret[0] = Ptr(-1)) Then Return SetError(@error + 50, @extended, 0)
  4518. Return $aret[0]
  4519. EndFunc
  4520.  
  4521. Func __heapvalidate($pmemory)
  4522. If (NOT $__g_hheap) OR (NOT Ptr($pmemory)) Then Return SetError(9, 0, False)
  4523. Local $aret = DllCall("kernel32.dll", "int", "HeapValidate", "handle", $__g_hheap, "dword", 0, "ptr", $pmemory)
  4524. If @error Then Return SetError(@error, @extended, False)
  4525. Return $aret[0]
  4526. EndFunc
  4527.  
  4528. #EndRegion Internal Functions
  4529. Global Const $snd_application = 128
  4530. Global Const $snd_alias = 65536
  4531. Global Const $snd_alias_id = 1114112
  4532. Global Const $snd_async = 1
  4533. Global Const $snd_filename = 131072
  4534. Global Const $snd_loop = 8
  4535. Global Const $snd_memory = 4
  4536. Global Const $snd_nodefault = 2
  4537. Global Const $snd_nostop = 16
  4538. Global Const $snd_nowait = 8192
  4539. Global Const $snd_purge = 64
  4540. Global Const $snd_resource = 262148
  4541. Global Const $snd_sentry = 524288
  4542. Global Const $snd_sync = 0
  4543. Global Const $snd_system = 2097152
  4544. Global Const $snd_system_nostop = 2097168
  4545. Global Const $snd_alias_systemasterisk = "SystemAsterisk"
  4546. Global Const $snd_alias_systemdefault = "SystemDefault"
  4547. Global Const $snd_alias_systemexclamation = "SystemExclamation"
  4548. Global Const $snd_alias_systemexit = "SystemExit"
  4549. Global Const $snd_alias_systemhand = "SystemHand"
  4550. Global Const $snd_alias_systemquestion = "SystemQuestion"
  4551. Global Const $snd_alias_systemstart = "SystemStart"
  4552. Global Const $snd_alias_systemwelcome = "SystemWelcome"
  4553. #Region Global Variables and Constants
  4554. #EndRegion Global Variables and Constants
  4555. #Region Functions list
  4556. #EndRegion Functions list
  4557. #Region Public Functions
  4558.  
  4559. Func _winapi_arraytostruct(Const ByRef $adata, $istart = 0, $iend = -1)
  4560. If __checkerrorarraybounds($adata, $istart, $iend) Then Return SetError(@error + 10, @extended, 0)
  4561. Local $tagstruct = ""
  4562. For $i = $istart To $iend
  4563. $tagstruct &= "wchar[" & (StringLen($adata[$i]) + 1) & "];"
  4564. Next
  4565. Local $tdata = DllStructCreate($tagstruct & "wchar[1]")
  4566. Local $icount = 1
  4567. For $i = $istart To $iend
  4568. DllStructSetData($tdata, $icount, $adata[$i])
  4569. $icount += 1
  4570. Next
  4571. DllStructSetData($tdata, $icount, ChrW(0))
  4572. Return $tdata
  4573. EndFunc
  4574.  
  4575. Func _winapi_createmargins($ileftwidth, $irightwidth, $itopheight, $ibottomheight)
  4576. Local $tmargins = DllStructCreate($tagmargins)
  4577. DllStructSetData($tmargins, 1, $ileftwidth)
  4578. DllStructSetData($tmargins, 2, $irightwidth)
  4579. DllStructSetData($tmargins, 3, $itopheight)
  4580. DllStructSetData($tmargins, 4, $ibottomheight)
  4581. Return $tmargins
  4582. EndFunc
  4583.  
  4584. Func _winapi_createpoint($ix, $iy)
  4585. Local $tpoint = DllStructCreate($tagpoint)
  4586. DllStructSetData($tpoint, 1, $ix)
  4587. DllStructSetData($tpoint, 2, $iy)
  4588. Return $tpoint
  4589. EndFunc
  4590.  
  4591. Func _winapi_createrect($ileft, $itop, $iright, $ibottom)
  4592. Local $trect = DllStructCreate($tagrect)
  4593. DllStructSetData($trect, 1, $ileft)
  4594. DllStructSetData($trect, 2, $itop)
  4595. DllStructSetData($trect, 3, $iright)
  4596. DllStructSetData($trect, 4, $ibottom)
  4597. Return $trect
  4598. EndFunc
  4599.  
  4600. Func _winapi_createrectex($ix, $iy, $iwidth, $iheight)
  4601. Local $trect = DllStructCreate($tagrect)
  4602. DllStructSetData($trect, 1, $ix)
  4603. DllStructSetData($trect, 2, $iy)
  4604. DllStructSetData($trect, 3, $ix + $iwidth)
  4605. DllStructSetData($trect, 4, $iy + $iheight)
  4606. Return $trect
  4607. EndFunc
  4608.  
  4609. Func _winapi_createsize($iwidth, $iheight)
  4610. Local $tsize = DllStructCreate($tagsize)
  4611. DllStructSetData($tsize, 1, $iwidth)
  4612. DllStructSetData($tsize, 2, $iheight)
  4613. Return $tsize
  4614. EndFunc
  4615.  
  4616. Func _winapi_copystruct($tstruct, $sstruct = "")
  4617. Local $isize = DllStructGetSize($tstruct)
  4618. If NOT $isize Then Return SetError(1, 0, 0)
  4619. Local $tresult
  4620. If NOT StringStripWS($sstruct, $str_stripleading + $str_striptrailing + $str_stripspaces) Then
  4621. $tresult = DllStructCreate("byte[" & $isize & "]")
  4622. Else
  4623. $tresult = DllStructCreate($sstruct)
  4624. EndIf
  4625. If DllStructGetSize($tresult) < $isize Then Return SetError(2, 0, 0)
  4626. _winapi_movememory($tresult, $tstruct, $isize)
  4627. Return $tresult
  4628. EndFunc
  4629.  
  4630. Func _winapi_getextended()
  4631. Return $__g_vext
  4632. EndFunc
  4633.  
  4634. Func _winapi_getmousepos($btoclient = False, $hwnd = 0)
  4635. Local $imode = Opt("MouseCoordMode", 1)
  4636. Local $apos = MouseGetPos()
  4637. Opt("MouseCoordMode", $imode)
  4638. Local $tpoint = DllStructCreate($tagpoint)
  4639. DllStructSetData($tpoint, "X", $apos[0])
  4640. DllStructSetData($tpoint, "Y", $apos[1])
  4641. If $btoclient AND NOT _winapi_screentoclient($hwnd, $tpoint) Then Return SetError(@error + 20, @extended, 0)
  4642. Return $tpoint
  4643. EndFunc
  4644.  
  4645. Func _winapi_getmouseposx($btoclient = False, $hwnd = 0)
  4646. Local $tpoint = _winapi_getmousepos($btoclient, $hwnd)
  4647. If @error Then Return SetError(@error, @extended, 0)
  4648. Return DllStructGetData($tpoint, "X")
  4649. EndFunc
  4650.  
  4651. Func _winapi_getmouseposy($btoclient = False, $hwnd = 0)
  4652. Local $tpoint = _winapi_getmousepos($btoclient, $hwnd)
  4653. If @error Then Return SetError(@error, @extended, 0)
  4654. Return DllStructGetData($tpoint, "Y")
  4655. EndFunc
  4656.  
  4657. Func _winapi_muldiv($inumber, $inumerator, $idenominator)
  4658. Local $aresult = DllCall("kernel32.dll", "int", "MulDiv", "int", $inumber, "int", $inumerator, "int", $idenominator)
  4659. If @error Then Return SetError(@error, @extended, -1)
  4660. Return $aresult[0]
  4661. EndFunc
  4662.  
  4663. Func _winapi_playsound($ssound, $iflags = $snd_system_nostop, $hinstance = 0)
  4664. Local $stypeofsound = "ptr"
  4665. If $ssound Then
  4666. If IsString($ssound) Then
  4667. $stypeofsound = "wstr"
  4668. EndIf
  4669. Else
  4670. $ssound = 0
  4671. $iflags = 0
  4672. EndIf
  4673. Local $aret = DllCall("winmm.dll", "bool", "PlaySoundW", $stypeofsound, $ssound, "handle", $hinstance, "dword", $iflags)
  4674. If @error Then Return SetError(@error, @extended, False)
  4675. Return $aret[0]
  4676. EndFunc
  4677.  
  4678. Func _winapi_stringlena(Const ByRef $tstring)
  4679. Local $aresult = DllCall("kernel32.dll", "int", "lstrlenA", "struct*", $tstring)
  4680. If @error Then Return SetError(@error, @extended, 0)
  4681. Return $aresult[0]
  4682. EndFunc
  4683.  
  4684. Func _winapi_stringlenw(Const ByRef $tstring)
  4685. Local $aresult = DllCall("kernel32.dll", "int", "lstrlenW", "struct*", $tstring)
  4686. If @error Then Return SetError(@error, @extended, 0)
  4687. Return $aresult[0]
  4688. EndFunc
  4689.  
  4690. Func _winapi_structtoarray(ByRef $tstruct, $iitems = 0)
  4691. Local $isize = 2 * Floor(DllStructGetSize($tstruct) / 2)
  4692. Local $pstruct = DllStructGetPtr($tstruct)
  4693. If NOT $isize OR NOT $pstruct Then Return SetError(1, 0, 0)
  4694. Local $tdata, $ilength, $ioffset = 0
  4695. Local $aresult[101] = [0]
  4696. While 1
  4697. $ilength = _winapi_strlen($pstruct + $ioffset)
  4698. If NOT $ilength Then
  4699. ExitLoop
  4700. EndIf
  4701. If 2 * (1 + $ilength) + $ioffset > $isize Then Return SetError(3, 0, 0)
  4702. $tdata = DllStructCreate("wchar[" & (1 + $ilength) & "]", $pstruct + $ioffset)
  4703. If @error Then Return SetError(@error + 10, 0, 0)
  4704. __inc($aresult)
  4705. $aresult[$aresult[0]] = DllStructGetData($tdata, 1)
  4706. If $aresult[0] = $iitems Then
  4707. ExitLoop
  4708. EndIf
  4709. $ioffset += 2 * (1 + $ilength)
  4710. If $ioffset >= $isize Then Return SetError(3, 0, 0)
  4711. WEnd
  4712. If NOT $aresult[0] Then Return SetError(2, 0, 0)
  4713. __inc($aresult, -1)
  4714. Return $aresult
  4715. EndFunc
  4716.  
  4717. Func _winapi_unionstruct($tstruct1, $tstruct2, $sstruct = "")
  4718. Local $asize[2] = [DllStructGetSize($tstruct1), DllStructGetSize($tstruct2)]
  4719. If NOT $asize[0] OR NOT $asize[1] Then Return SetError(1, 0, 0)
  4720. Local $tresult
  4721. If NOT StringStripWS($sstruct, $str_stripleading + $str_striptrailing + $str_stripspaces) Then
  4722. $tresult = DllStructCreate("byte[" & ($asize[0] + $asize[1]) & "]")
  4723. Else
  4724. $tresult = DllStructCreate($sstruct)
  4725. EndIf
  4726. If DllStructGetSize($tresult) < ($asize[0] + $asize[1]) Then Return SetError(2, 0, 0)
  4727. _winapi_movememory($tresult, $tstruct1, $asize[0])
  4728. _winapi_movememory(DllStructGetPtr($tresult) + $asize[0], $tstruct2, $asize[1])
  4729. Return $tresult
  4730. EndFunc
  4731.  
  4732. #EndRegion Public Functions
  4733. Global Const $url_scheme_invalid = -1
  4734. Global Const $url_scheme_unknown = 0
  4735. Global Const $url_scheme_ftp = 1
  4736. Global Const $url_scheme_http = 2
  4737. Global Const $url_scheme_gopher = 3
  4738. Global Const $url_scheme_mailto = 4
  4739. Global Const $url_scheme_news = 5
  4740. Global Const $url_scheme_nntp = 6
  4741. Global Const $url_scheme_telnet = 7
  4742. Global Const $url_scheme_wais = 8
  4743. Global Const $url_scheme_file = 9
  4744. Global Const $url_scheme_mk = 10
  4745. Global Const $url_scheme_https = 11
  4746. Global Const $url_scheme_shell = 12
  4747. Global Const $url_scheme_snews = 13
  4748. Global Const $url_scheme_local = 14
  4749. Global Const $url_scheme_javascript = 15
  4750. Global Const $url_scheme_vbscript = 16
  4751. Global Const $url_scheme_about = 17
  4752. Global Const $url_scheme_res = 18
  4753. Global Const $url_scheme_msshellrooted = 19
  4754. Global Const $url_scheme_msshellidlist = 20
  4755. Global Const $url_scheme_mshelp = 21
  4756. Global Const $url_scheme_msshelldevice = 22
  4757. Global Const $url_scheme_wildcard = 23
  4758. Global Const $url_scheme_search_ms = 24
  4759. Global Const $url_scheme_search = 25
  4760. Global Const $url_scheme_knownfolder = 26
  4761. Global Const $gct_invalid = 0
  4762. Global Const $gct_lfnchar = 1
  4763. Global Const $gct_separator = 8
  4764. Global Const $gct_shortchar = 2
  4765. Global Const $gct_wild = 4
  4766. Global Const $url_apply_default = 1
  4767. Global Const $url_apply_guessscheme = 2
  4768. Global Const $url_apply_guessfile = 4
  4769. Global Const $url_apply_forceapply = 8
  4770. Global Const $url_dont_simplify = 134217728
  4771. Global Const $url_escape_as_utf8 = 262144
  4772. Global Const $url_escape_percent = 4096
  4773. Global Const $url_escape_spaces_only = 67108864
  4774. Global Const $url_escape_unsafe = 536870912
  4775. Global Const $url_no_meta = 134217728
  4776. Global Const $url_pluggable_protocol = 1073741824
  4777. Global Const $url_unescape = 268435456
  4778. Global Const $url_part_hostname = 2
  4779. Global Const $url_part_password = 4
  4780. Global Const $url_part_port = 5
  4781. Global Const $url_part_query = 6
  4782. Global Const $url_part_scheme = 1
  4783. Global Const $url_part_username = 3
  4784. Global Const $urlis_appliable = 4
  4785. Global Const $urlis_directory = 5
  4786. Global Const $urlis_fileurl = 3
  4787. Global Const $urlis_hasquery = 6
  4788. Global Const $urlis_nohistory = 2
  4789. Global Const $urlis_opaque = 1
  4790. Global Const $urlis_url = 0
  4791. #Region Functions list
  4792. #EndRegion Functions list
  4793. #Region Public Functions
  4794.  
  4795. Func _winapi_commandlinetoargv($scmd)
  4796. Local $aresult[1] = [0]
  4797. $scmd = StringStripWS($scmd, $str_stripleading + $str_striptrailing)
  4798. If NOT $scmd Then
  4799. Return $aresult
  4800. EndIf
  4801. Local $aret = DllCall("shell32.dll", "ptr", "CommandLineToArgvW", "wstr", $scmd, "int*", 0)
  4802. If @error OR NOT $aret[0] OR (NOT $aret[2]) Then Return SetError(@error + 10, @extended, 0)
  4803. Local $tptr = DllStructCreate("ptr[" & $aret[2] & "]", $aret[0])
  4804. Dim $aresult[$aret[2] + 1] = [$aret[2]]
  4805. For $i = 1 To $aret[2]
  4806. $aresult[$i] = _winapi_getstring(DllStructGetData($tptr, 1, $i))
  4807. Next
  4808. DllCall("kernel32.dll", "handle", "LocalFree", "handle", $aret[0])
  4809. Return $aresult
  4810. EndFunc
  4811.  
  4812. Func _winapi_isnameinexpression($sstring, $spattern, $bcasesensitive = False)
  4813. If NOT $bcasesensitive Then $spattern = StringUpper($spattern)
  4814. Local $tus1 = __us($spattern)
  4815. Local $tus2 = __us($sstring)
  4816. Local $aret = DllCall("ntdll.dll", "boolean", "RtlIsNameInExpression", "struct*", $tus1, "struct*", $tus2, "boolean", NOT $bcasesensitive, "ptr", 0)
  4817. If @error Then Return SetError(@error, @extended, False)
  4818. Return $aret[0]
  4819. EndFunc
  4820.  
  4821. Func _winapi_parseurl($surl)
  4822. Local $tagparsedurl = "dword Size;ptr Protocol;uint cchProtocol;ptr Suffix;uint cchSuffix;uint Scheme"
  4823. Local $tpurl = DllStructCreate($tagparsedurl)
  4824. DllStructSetData($tpurl, 1, DllStructGetSize($tpurl))
  4825. Local $turl = DllStructCreate("wchar[4096]")
  4826. DllStructSetData($turl, 1, $surl)
  4827. Local $aret = DllCall("shlwapi.dll", "long", "ParseURLW", "struct*", $turl, "struct*", $tpurl)
  4828. If @error Then Return SetError(@error, @extended, "")
  4829. If $aret[0] Then Return SetError(10, $aret[0], "")
  4830. Local $aresult[3]
  4831. $aresult[0] = DllStructGetData(DllStructCreate("wchar[" & DllStructGetData($tpurl, 3) & "]", DllStructGetData($tpurl, 2)), 1)
  4832. $aresult[1] = DllStructGetData(DllStructCreate("wchar[" & DllStructGetData($tpurl, 5) & "]", DllStructGetData($tpurl, 4)), 1)
  4833. $aresult[2] = DllStructGetData($tpurl, 6)
  4834. Return $aresult
  4835. EndFunc
  4836.  
  4837. Func _winapi_parseusername($suser)
  4838. If NOT __dll("credui.dll") Then Return SetError(103, 0, 0)
  4839. Local $aret = DllCall("credui.dll", "dword", "CredUIParseUserNameW", "wstr", $suser, "wstr", "", "ulong", 4096, "wstr", "", "ulong", 4096)
  4840. If @error Then Return SetError(@error, @extended, 0)
  4841. Switch $aret[0]
  4842. Case 0
  4843. Case 1315
  4844. If StringStripWS($suser, $str_stripleading + $str_striptrailing) Then
  4845. $aret[2] = $suser
  4846. $aret[4] = ""
  4847. Else
  4848. ContinueCase
  4849. EndIf
  4850. Case Else
  4851. Return SetError(10, $aret[0], 0)
  4852. EndSwitch
  4853. Local $aresult[2]
  4854. $aresult[0] = $aret[4]
  4855. $aresult[1] = $aret[2]
  4856. Return $aresult
  4857. EndFunc
  4858.  
  4859. Func _winapi_pathaddbackslash($sfilepath)
  4860. Local $tpath = DllStructCreate("wchar[260]")
  4861. DllStructSetData($tpath, 1, $sfilepath)
  4862. Local $aret = DllCall("shlwapi.dll", "ptr", "PathAddBackslashW", "struct*", $tpath)
  4863. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  4864. Return DllStructGetData($tpath, 1)
  4865. EndFunc
  4866.  
  4867. Func _winapi_pathaddextension($sfilepath, $sext = "")
  4868. Local $tpath = DllStructCreate("wchar[260]")
  4869. DllStructSetData($tpath, 1, $sfilepath)
  4870. Local $stypeofext = "wstr"
  4871. If NOT StringStripWS($sext, $str_stripleading + $str_striptrailing) Then
  4872. $stypeofext = "ptr"
  4873. $sext = 0
  4874. EndIf
  4875. Local $aret = DllCall("shlwapi.dll", "bool", "PathAddExtensionW", "struct*", $tpath, $stypeofext, $sext)
  4876. If @error Then Return SetError(@error, @extended, "")
  4877. Return SetExtended($aret[0], DllStructGetData($tpath, 1))
  4878. EndFunc
  4879.  
  4880. Func _winapi_pathappend($sfilepath, $smore)
  4881. Local $tpath = DllStructCreate("wchar[260]")
  4882. DllStructSetData($tpath, 1, $sfilepath)
  4883. Local $aret = DllCall("shlwapi.dll", "bool", "PathAppendW", "struct*", $tpath, "wstr", $smore)
  4884. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  4885. Return DllStructGetData($tpath, 1)
  4886. EndFunc
  4887.  
  4888. Func _winapi_pathbuildroot($idrive)
  4889. Local $aret = DllCall("shlwapi.dll", "ptr", "PathBuildRootW", "wstr", "", "int", $idrive)
  4890. If @error Then Return SetError(@error, @extended, "")
  4891. Return $aret[1]
  4892. EndFunc
  4893.  
  4894. Func _winapi_pathcanonicalize($sfilepath)
  4895. Local $aret = DllCall("shlwapi.dll", "bool", "PathCanonicalizeW", "wstr", "", "wstr", $sfilepath)
  4896. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, $sfilepath)
  4897. Return $aret[1]
  4898. EndFunc
  4899.  
  4900. Func _winapi_pathcommonprefix($spath1, $spath2)
  4901. Local $aret = DllCall("shlwapi.dll", "int", "PathCommonPrefixW", "wstr", $spath1, "wstr", $spath2, "wstr", "")
  4902. If @error Then Return SetError(@error, @extended, "")
  4903. Return SetExtended($aret[0], $aret[3])
  4904. EndFunc
  4905.  
  4906. Func _winapi_pathcompactpath($hwnd, $sfilepath, $iwidth = 0)
  4907. If $iwidth < 1 Then
  4908. Local $trect = DllStructCreate($tagrect)
  4909. DllCall("user32.dll", "bool", "GetClientRect", "hwnd", $hwnd, "struct*", $trect)
  4910. $iwidth += DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left")
  4911. EndIf
  4912. Local $aret = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hwnd)
  4913. If @error OR NOT $aret[0] Then Return SetError(@error + 20, @extended, $sfilepath)
  4914. Local $hdc = $aret[0]
  4915. Local Const $wm_getfont = 49
  4916. $aret = DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hwnd, "uint", $wm_getfont, "wparam", 0, "lparam", 0)
  4917. Local $hback = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hdc, "handle", $aret[0])
  4918. Local $ierror = 0
  4919. $aret = DllCall("shlwapi.dll", "bool", "PathCompactPathW", "handle", $hdc, "wstr", $sfilepath, "int", $iwidth)
  4920. If @error OR NOT $aret[0] Then $ierror = @error + 10
  4921. DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hdc, "handle", $hback[0])
  4922. DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hwnd, "handle", $hdc)
  4923. If $ierror Then Return SetError($ierror, 0, $sfilepath)
  4924. Return $aret[2]
  4925. EndFunc
  4926.  
  4927. Func _winapi_pathcompactpathex($sfilepath, $imax)
  4928. Local $aret = DllCall("shlwapi.dll", "bool", "PathCompactPathExW", "wstr", "", "wstr", $sfilepath, "uint", $imax + 1, "dword", 0)
  4929. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, $sfilepath)
  4930. Return $aret[1]
  4931. EndFunc
  4932.  
  4933. Func _winapi_pathcreatefromurl($surl)
  4934. Local $aret = DllCall("shlwapi.dll", "long", "PathCreateFromUrlW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", 0)
  4935. If @error Then Return SetError(@error, @extended, "")
  4936. If $aret[0] Then Return SetError(10, $aret[0], "")
  4937. Return $aret[2]
  4938. EndFunc
  4939.  
  4940. Func _winapi_pathfindextension($sfilepath)
  4941. Local $aret = DllCall("shlwapi.dll", "wstr", "PathFindExtensionW", "wstr", $sfilepath)
  4942. If @error Then Return SetError(@error, @extended, "")
  4943. Return $aret[0]
  4944. EndFunc
  4945.  
  4946. Func _winapi_pathfindfilename($sfilepath)
  4947. Local $aret = DllCall("shlwapi.dll", "wstr", "PathFindFileNameW", "wstr", $sfilepath)
  4948. If @error Then Return SetError(@error, @extended, $sfilepath)
  4949. Return $aret[0]
  4950. EndFunc
  4951.  
  4952. Func _winapi_pathfindnextcomponent($sfilepath)
  4953. Local $tpath = DllStructCreate("wchar[" & (StringLen($sfilepath) + 1) & "]")
  4954. DllStructSetData($tpath, 1, $sfilepath)
  4955. Local $aret = DllCall("shlwapi.dll", "ptr", "PathFindNextComponentW", "struct*", $tpath)
  4956. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  4957. Return _winapi_getstring($aret[0])
  4958. EndFunc
  4959.  
  4960. Func _winapi_pathfindonpath(Const $sfilepath, $aextrapaths = "", Const $spathdelimiter = @LF)
  4961. Local $iextracount = 0
  4962. If IsString($aextrapaths) Then
  4963. If StringLen($aextrapaths) Then
  4964. $aextrapaths = StringSplit($aextrapaths, $spathdelimiter, $str_entiresplit + $str_nocount)
  4965. $iextracount = UBound($aextrapaths, $ubound_rows)
  4966. EndIf
  4967. ElseIf IsArray($aextrapaths) Then
  4968. $iextracount = UBound($aextrapaths)
  4969. EndIf
  4970. Local $tpaths, $tpathptrs
  4971. If $iextracount Then
  4972. Local $tagstruct = ""
  4973. For $path In $aextrapaths
  4974. $tagstruct &= "wchar[" & StringLen($path) + 1 & "];"
  4975. Next
  4976. $tpaths = DllStructCreate($tagstruct)
  4977. $tpathptrs = DllStructCreate("ptr[" & $iextracount + 1 & "]")
  4978. For $i = 1 To $iextracount
  4979. DllStructSetData($tpaths, $i, $aextrapaths[$i - 1])
  4980. DllStructSetData($tpathptrs, 1, DllStructGetPtr($tpaths, $i), $i)
  4981. Next
  4982. DllStructSetData($tpathptrs, 1, Ptr(0), $iextracount + 1)
  4983. EndIf
  4984. Local $aresult = DllCall("shlwapi.dll", "bool", "PathFindOnPathW", "wstr", $sfilepath, "struct*", $tpathptrs)
  4985. If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, $sfilepath)
  4986. Return $aresult[1]
  4987. EndFunc
  4988.  
  4989. Func _winapi_pathgetargs($sfilepath)
  4990. Local $tpath = DllStructCreate("wchar[" & (StringLen($sfilepath) + 1) & "]")
  4991. DllStructSetData($tpath, 1, $sfilepath)
  4992. Local $aret = DllCall("shlwapi.dll", "ptr", "PathGetArgsW", "struct*", $tpath)
  4993. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  4994. Return _winapi_getstring($aret[0])
  4995. EndFunc
  4996.  
  4997. Func _winapi_pathgetchartype($schar)
  4998. Local $aret = DllCall("shlwapi.dll", "uint", "PathGetCharTypeW", "word", AscW($schar))
  4999. If @error Then Return SetError(@error, @extended, -1)
  5000. Return $aret[0]
  5001. EndFunc
  5002.  
  5003. Func _winapi_pathgetdrivenumber($sfilepath)
  5004. Local $aret = DllCall("shlwapi.dll", "int", "PathGetDriveNumberW", "wstr", $sfilepath)
  5005. If @error OR ($aret[0] = -1) Then Return SetError(@error, @extended, "")
  5006. Return Chr($aret[0] + 65) & ":"
  5007. EndFunc
  5008.  
  5009. Func _winapi_pathiscontenttype($sfilepath, $stype)
  5010. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsContentTypeW", "wstr", $sfilepath, "wstr", $stype)
  5011. If @error Then Return SetError(@error, @extended, False)
  5012. Return $aret[0]
  5013. EndFunc
  5014.  
  5015. Func _winapi_pathisexe($sfilepath)
  5016. Local $aret = DllCall("shell32.dll", "bool", "PathIsExe", "wstr", $sfilepath)
  5017. If @error Then Return SetError(@error, @extended, False)
  5018. Return $aret[0]
  5019. EndFunc
  5020.  
  5021. Func _winapi_pathisfilespec($sfilepath)
  5022. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsFileSpecW", "wstr", $sfilepath)
  5023. If @error Then Return SetError(@error, @extended, False)
  5024. Return $aret[0]
  5025. EndFunc
  5026.  
  5027. Func _winapi_pathislfnfilespec($sfilepath)
  5028. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsLFNFileSpecW", "wstr", $sfilepath)
  5029. If @error Then Return SetError(@error, @extended, False)
  5030. Return $aret[0]
  5031. EndFunc
  5032.  
  5033. Func _winapi_pathisrelative($sfilepath)
  5034. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsRelativeW", "wstr", $sfilepath)
  5035. If @error Then Return SetError(@error, @extended, False)
  5036. Return $aret[0]
  5037. EndFunc
  5038.  
  5039. Func _winapi_pathisroot($sfilepath)
  5040. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsRootW", "wstr", $sfilepath)
  5041. If @error Then Return SetError(@error, @extended, False)
  5042. Return $aret[0]
  5043. EndFunc
  5044.  
  5045. Func _winapi_pathissameroot($spath1, $spath2)
  5046. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsSameRootW", "wstr", $spath1, "wstr", $spath2)
  5047. If @error Then Return SetError(@error, @extended, False)
  5048. Return $aret[0]
  5049. EndFunc
  5050.  
  5051. Func _winapi_pathissystemfolder($sfilepath)
  5052. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsSystemFolderW", "wstr", $sfilepath, "dword", 0)
  5053. If @error Then Return SetError(@error, @extended, False)
  5054. Return $aret[0]
  5055. EndFunc
  5056.  
  5057. Func _winapi_pathisunc($sfilepath)
  5058. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsUNCW", "wstr", $sfilepath)
  5059. If @error Then Return SetError(@error, @extended, False)
  5060. Return $aret[0]
  5061. EndFunc
  5062.  
  5063. Func _winapi_pathisuncserver($sfilepath)
  5064. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsUNCServerW", "wstr", $sfilepath)
  5065. If @error Then Return SetError(@error, @extended, False)
  5066. Return $aret[0]
  5067. EndFunc
  5068.  
  5069. Func _winapi_pathisuncservershare($sfilepath)
  5070. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsUNCServerShareW", "wstr", $sfilepath)
  5071. If @error Then Return SetError(@error, @extended, False)
  5072. Return $aret[0]
  5073. EndFunc
  5074.  
  5075. Func _winapi_pathmakesystemfolder($sfilepath)
  5076. Local $aret = DllCall("shlwapi.dll", "bool", "PathMakeSystemFolderW", "wstr", $sfilepath)
  5077. If @error Then Return SetError(@error, @extended, False)
  5078. Return $aret[0]
  5079. EndFunc
  5080.  
  5081. Func _winapi_pathmatchspec($sfilepath, $sspec)
  5082. Local $aret = DllCall("shlwapi.dll", "bool", "PathMatchSpecW", "wstr", $sfilepath, "wstr", $sspec)
  5083. If @error Then Return SetError(@error, @extended, False)
  5084. Return $aret[0]
  5085. EndFunc
  5086.  
  5087. Func _winapi_pathparseiconlocation($sfilepath)
  5088. Local $aret = DllCall("shlwapi.dll", "int", "PathParseIconLocationW", "wstr", $sfilepath)
  5089. If @error Then Return SetError(@error, @extended, 0)
  5090. Local $aresult[2]
  5091. $aresult[0] = $aret[1]
  5092. $aresult[1] = $aret[0]
  5093. Return $aresult
  5094. EndFunc
  5095.  
  5096. Func _winapi_pathrelativepathto($spathfrom, $bdirfrom, $spathto, $bdirto)
  5097. If $bdirfrom Then
  5098. $bdirfrom = 16
  5099. EndIf
  5100. If $bdirto Then
  5101. $bdirto = 16
  5102. EndIf
  5103. Local $aret = DllCall("shlwapi.dll", "bool", "PathRelativePathToW", "wstr", "", "wstr", $spathfrom, "dword", $bdirfrom, "wstr", $spathto, "dword", $bdirto)
  5104. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  5105. Return $aret[1]
  5106. EndFunc
  5107.  
  5108. Func _winapi_pathremoveargs($sfilepath)
  5109. Local $aret = DllCall("shlwapi.dll", "none", "PathRemoveArgsW", "wstr", $sfilepath)
  5110. If @error Then Return SetError(@error, @extended, "")
  5111. Return $aret[1]
  5112. EndFunc
  5113.  
  5114. Func _winapi_pathremovebackslash($sfilepath)
  5115. Local $aret = DllCall("shlwapi.dll", "ptr", "PathRemoveBackslashW", "wstr", $sfilepath)
  5116. If @error Then Return SetError(@error, @extended, "")
  5117. Return $aret[1]
  5118. EndFunc
  5119.  
  5120. Func _winapi_pathremoveextension($sfilepath)
  5121. Local $aret = DllCall("shlwapi.dll", "none", "PathRemoveExtensionW", "wstr", $sfilepath)
  5122. If @error Then Return SetError(@error, @extended, "")
  5123. Return $aret[1]
  5124. EndFunc
  5125.  
  5126. Func _winapi_pathremovefilespec($sfilepath)
  5127. Local $aret = DllCall("shlwapi.dll", "bool", "PathRemoveFileSpecW", "wstr", $sfilepath)
  5128. If @error Then Return SetError(@error, @extended, "")
  5129. Return SetExtended($aret[0], $aret[1])
  5130. EndFunc
  5131.  
  5132. Func _winapi_pathrenameextension($sfilepath, $sext)
  5133. Local $tpath = DllStructCreate("wchar[260]")
  5134. DllStructSetData($tpath, 1, $sfilepath)
  5135. Local $aret = DllCall("shlwapi.dll", "bool", "PathRenameExtensionW", "struct*", $tpath, "wstr", $sext)
  5136. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  5137. Return DllStructGetData($tpath, 1)
  5138. EndFunc
  5139.  
  5140. Func _winapi_pathsearchandqualify($sfilepath, $bexists = False)
  5141. Local $aret = DllCall("shlwapi.dll", "bool", "PathSearchAndQualifyW", "wstr", $sfilepath, "wstr", "", "int", 4096)
  5142. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  5143. If $bexists AND NOT FileExists($aret[2]) Then Return SetError(20, 0, "")
  5144. Return $aret[2]
  5145. EndFunc
  5146.  
  5147. Func _winapi_pathskiproot($sfilepath)
  5148. Local $tpath = DllStructCreate("wchar[" & (StringLen($sfilepath) + 1) & "]")
  5149. DllStructSetData($tpath, 1, $sfilepath)
  5150. Local $aret = DllCall("shlwapi.dll", "ptr", "PathSkipRootW", "struct*", $tpath)
  5151. If @error Then Return SetError(@error, @extended, "")
  5152. If NOT $aret[0] Then Return $sfilepath
  5153. Return _winapi_getstring($aret[0])
  5154. EndFunc
  5155.  
  5156. Func _winapi_pathstrippath($sfilepath)
  5157. Local $aret = DllCall("shlwapi.dll", "none", "PathStripPathW", "wstr", $sfilepath)
  5158. If @error Then Return SetError(@error, @extended, "")
  5159. Return $aret[1]
  5160. EndFunc
  5161.  
  5162. Func _winapi_pathstriptoroot($sfilepath)
  5163. Local $aret = DllCall("shlwapi.dll", "bool", "PathStripToRootW", "wstr", $sfilepath)
  5164. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  5165. Return $aret[1]
  5166. EndFunc
  5167.  
  5168. Func _winapi_pathundecorate($sfilepath)
  5169. Local $aret = DllCall("shlwapi.dll", "none", "PathUndecorateW", "wstr", $sfilepath)
  5170. If @error Then Return SetError(@error, @extended, "")
  5171. Return $aret[1]
  5172. EndFunc
  5173.  
  5174. Func _winapi_pathunexpandenvstrings($sfilepath)
  5175. Local $aret = DllCall("shlwapi.dll", "bool", "PathUnExpandEnvStringsW", "wstr", $sfilepath, "wstr", "", "uint", 4096)
  5176. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  5177. Return $aret[2]
  5178. EndFunc
  5179.  
  5180. Func _winapi_pathunmakesystemfolder($sfilepath)
  5181. Local $aret = DllCall("shlwapi.dll", "bool", "PathUnmakeSystemFolderW", "wstr", $sfilepath)
  5182. If @error Then Return SetError(@error, @extended, False)
  5183. Return $aret[0]
  5184. EndFunc
  5185.  
  5186. Func _winapi_pathunquotespaces($sfilepath)
  5187. Local $aret = DllCall("shlwapi.dll", "none", "PathUnquoteSpacesW", "wstr", $sfilepath)
  5188. If @error Then Return SetError(@error, @extended, "")
  5189. Return $aret[1]
  5190. EndFunc
  5191.  
  5192. Func _winapi_pathyetanothermakeuniquename($sfilepath)
  5193. Local $aret = DllCall("shell32.dll", "int", "PathYetAnotherMakeUniqueName", "wstr", "", "wstr", $sfilepath, "ptr", 0, "ptr", 0)
  5194. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  5195. Return $aret[1]
  5196. EndFunc
  5197.  
  5198. Func _winapi_shellgetimagelist($bsmall = False)
  5199. Local $plarge, $psmall, $tptr = DllStructCreate("ptr")
  5200. If $bsmall Then
  5201. $plarge = 0
  5202. $psmall = DllStructGetPtr($tptr)
  5203. Else
  5204. $plarge = DllStructGetPtr($tptr)
  5205. $psmall = 0
  5206. EndIf
  5207. Local $aret = DllCall("shell32.dll", "int", "Shell_GetImageLists", "ptr", $plarge, "ptr", $psmall)
  5208. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
  5209. Return DllStructGetData($tptr, 1)
  5210. EndFunc
  5211.  
  5212. Func _winapi_urlapplyscheme($surl, $iflags = 1)
  5213. Local $aret = DllCall("shlwapi.dll", "long", "UrlApplySchemeW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", $iflags)
  5214. If @error Then Return SetError(@error, @extended, "")
  5215. If $aret[0] Then Return SetError(10, $aret[0], "")
  5216. Return $aret[2]
  5217. EndFunc
  5218.  
  5219. Func _winapi_urlcanonicalize($surl, $iflags)
  5220. Local $aret = DllCall("shlwapi.dll", "long", "UrlCanonicalizeW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", $iflags)
  5221. If @error Then Return SetError(@error, @extended, "")
  5222. If $aret[0] Then Return SetError(10, $aret[0], "")
  5223. Return $aret[2]
  5224. EndFunc
  5225.  
  5226. Func _winapi_urlcombine($surl, $spart, $iflags = 0)
  5227. Local $aret = DllCall("shlwapi.dll", "long", "UrlCombineW", "wstr", $surl, "wstr", $spart, "wstr", "", "dword*", 4096, "dword", $iflags)
  5228. If @error Then Return SetError(@error, @extended, "")
  5229. If $aret[0] Then Return SetError(10, $aret[0], "")
  5230. Return $aret[3]
  5231. EndFunc
  5232.  
  5233. Func _winapi_urlcompare($surl1, $surl2, $bignoreslash = False)
  5234. Local $aret = DllCall("shlwapi.dll", "int", "UrlCompareW", "wstr", $surl1, "wstr", $surl2, "bool", $bignoreslash)
  5235. If @error Then Return SetError(@error, @extended, 0)
  5236. Return $aret[0]
  5237. EndFunc
  5238.  
  5239. Func _winapi_urlcreatefrompath($sfilepath)
  5240. Local $aret = DllCall("shlwapi.dll", "long", "UrlCreateFromPathW", "wstr", $sfilepath, "wstr", "", "dword*", 4096, "dword", 0)
  5241. If @error Then Return SetError(@error, @extended, "")
  5242. If $aret[0] < 0 OR $aret[0] > 1 Then
  5243. Return SetError(10, $aret[0], "")
  5244. EndIf
  5245. Return $aret[2]
  5246. EndFunc
  5247.  
  5248. Func _winapi_urlfixup($surl)
  5249. Local $aret = DllCall("shlwapi.dll", "long", "UrlFixupW", "wstr", $surl, "wstr", "", "dword", 4096)
  5250. If @error Then Return SetError(@error, @extended, "")
  5251. If $aret[0] Then Return SetError(10, $aret[0], "")
  5252. Return $aret[2]
  5253. EndFunc
  5254.  
  5255. Func _winapi_urlgetpart($surl, $ipart)
  5256. Local $aret = DllCall("shlwapi.dll", "long", "UrlGetPartW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", $ipart, "dword", 0)
  5257. If @error Then Return SetError(@error, @extended, "")
  5258. If $aret[0] Then Return SetError(10, $aret[0], "")
  5259. Return $aret[2]
  5260. EndFunc
  5261.  
  5262. Func _winapi_urlhash($surl, $ilength = 32)
  5263. If $ilength <= 0 OR $ilength > 256 Then Return SetError(256, 0, 0)
  5264. Local $tdata = DllStructCreate("byte[" & $ilength & "]")
  5265. Local $aret = DllCall("shlwapi.dll", "long", "UrlHashW", "wstr", $surl, "struct*", $tdata, "dword", $ilength)
  5266. If @error Then Return SetError(@error + 10, @extended, 0)
  5267. If $aret[0] Then Return SetError(10, $aret[0], 0)
  5268. Return DllStructGetData($tdata, 1)
  5269. EndFunc
  5270.  
  5271. Func _winapi_urlis($surl, $itype = 0)
  5272. Local $aret = DllCall("shlwapi.dll", "bool", "UrlIsW", "wstr", $surl, "uint", $itype)
  5273. If @error Then Return SetError(@error, @extended, False)
  5274. Return $aret[0]
  5275. EndFunc
  5276.  
  5277. #EndRegion Public Functions
  5278. #Region Internal Functions
  5279.  
  5280. Func __us($sstring, $ilength = 0)
  5281. If $ilength Then
  5282. $sstring = StringLeft($sstring, $ilength)
  5283. Else
  5284. $ilength = StringLen($sstring)
  5285. EndIf
  5286. Local $tus = DllStructCreate("ushort;ushort;ptr;wchar[" & ($ilength + 1) & "]")
  5287. DllStructSetData($tus, 1, 2 * StringLen($sstring))
  5288. DllStructSetData($tus, 2, 2 * $ilength)
  5289. DllStructSetData($tus, 3, DllStructGetPtr($tus, 4))
  5290. DllStructSetData($tus, 4, $sstring)
  5291. Return $tus
  5292. EndFunc
  5293.  
  5294. #EndRegion Internal Functions
  5295. #Region Global Variables and Constants
  5296. Global $__g_iheapsize = 8388608
  5297. Global Const $tagfileinfo = "uint64 CreationTime;uint64 LastAccessTime;uint64 LastWriteTime;uint64 ChangeTime;dword Attributes"
  5298. Global Const $tagfile_id_descriptor = "dword Size;uint Type;" & $tagguid
  5299. Global Const $tagwin32_find_stream_data = "int64 StreamSize;wchar StreamName[296]"
  5300. Global Const $tagwin32_stream_id = "dword StreamId;dword StreamAttributes;int64 Size;dword StreamNameSize;wchar StreamName[1]"
  5301. #EndRegion Global Variables and Constants
  5302. #Region Functions list
  5303. #EndRegion Functions list
  5304. #Region Public Functions
  5305.  
  5306. Func _winapi_backupread($hfile, $pbuffer, $ilength, ByRef $ibytes, ByRef $pcontext, $bsecurity = False)
  5307. $ibytes = 0
  5308. Local $aret = DllCall("kernel32.dll", "bool", "BackupRead", "handle", $hfile, "struct*", $pbuffer, "dword", $ilength, "dword*", 0, "bool", 0, "bool", $bsecurity, "ptr*", $pcontext)
  5309. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, False)
  5310. $ibytes = $aret[4]
  5311. $pcontext = $aret[7]
  5312. Return $aret[0]
  5313. EndFunc
  5314.  
  5315. Func _winapi_backupreadabort(ByRef $pcontext)
  5316. Local $aret = DllCall("kernel32.dll", "bool", "BackupRead", "handle", 0, "ptr", 0, "dword", 0, "dword*", 0, "bool", 1, "bool", 0, "ptr*", $pcontext)
  5317. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, False)
  5318. $pcontext = $aret[7]
  5319. Return $aret[0]
  5320. EndFunc
  5321.  
  5322. Func _winapi_backupseek($hfile, $iseek, ByRef $ibytes, ByRef $pcontext)
  5323. $ibytes = 0
  5324. Local $aret = DllCall("kernel32.dll", "bool", "BackupSeek", "handle", $hfile, "dword", _winapi_lodword($iseek), "dword", _winapi_hidword($iseek), "dword*", 0, "dword*", 0, "ptr*", $pcontext)
  5325. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, False)
  5326. $ibytes = __winapi_makeqword($aret[4], $aret[5])
  5327. $pcontext = $aret[6]
  5328. Return $aret[0]
  5329. EndFunc
  5330.  
  5331. Func _winapi_backupwrite($hfile, $pbuffer, $ilength, ByRef $ibytes, ByRef $pcontext, $bsecurity = False)
  5332. $ibytes = 0
  5333. Local $aret = DllCall("kernel32.dll", "bool", "BackupWrite", "handle", $hfile, "struct*", $pbuffer, "dword", $ilength, "dword*", 0, "bool", 0, "bool", $bsecurity, "ptr*", $pcontext)
  5334. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, False)
  5335. $ibytes = $aret[4]
  5336. $pcontext = $aret[7]
  5337. Return $aret[0]
  5338. EndFunc
  5339.  
  5340. Func _winapi_backupwriteabort(ByRef $pcontext)
  5341. Local $aret = DllCall("kernel32.dll", "bool", "BackupWrite", "handle", 0, "ptr", 0, "dword", 0, "dword*", 0, "bool", 1, "bool", 0, "ptr*", $pcontext)
  5342. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, False)
  5343. $pcontext = $aret[7]
  5344. Return $aret[0]
  5345. EndFunc
  5346.  
  5347. Func _winapi_copyfileex($sexistingfile, $snewfile, $iflags = 0, $pprogressproc = 0, $pdata = 0)
  5348. Local $aret = DllCall("kernel32.dll", "bool", "CopyFileExW", "wstr", $sexistingfile, "wstr", $snewfile, "ptr", $pprogressproc, "struct*", $pdata, "bool*", 0, "dword", $iflags)
  5349. If @error Then Return SetError(@error, @extended, 0)
  5350. Return $aret[0]
  5351. EndFunc
  5352.  
  5353. Func _winapi_createdirectory($sdir, $tsecurity = 0)
  5354. Local $aret = DllCall("kernel32.dll", "bool", "CreateDirectoryW", "wstr", $sdir, "struct*", $tsecurity)
  5355. If @error Then Return SetError(@error, @extended, False)
  5356. Return $aret[0]
  5357. EndFunc
  5358.  
  5359. Func _winapi_createdirectoryex($snewdir, $stemplatedir, $tsecurity = 0)
  5360. Local $aret = DllCall("kernel32.dll", "bool", "CreateDirectoryExW", "wstr", $stemplatedir, "wstr", $snewdir, "struct*", $tsecurity)
  5361. If @error Then Return SetError(@error, @extended, False)
  5362. Return $aret[0]
  5363. EndFunc
  5364.  
  5365. Func _winapi_createfileex($sfilepath, $icreation, $iaccess = 0, $ishare = 0, $iflagsandattributes = 0, $tsecurity = 0, $htemplate = 0)
  5366. Local $aret = DllCall("kernel32.dll", "handle", "CreateFileW", "wstr", $sfilepath, "dword", $iaccess, "dword", $ishare, "struct*", $tsecurity, "dword", $icreation, "dword", $iflagsandattributes, "handle", $htemplate)
  5367. If @error Then Return SetError(@error, @extended, 0)
  5368. If $aret[0] = Ptr(-1) Then Return SetError(10, _winapi_getlasterror(), 0)
  5369. Return $aret[0]
  5370. EndFunc
  5371.  
  5372. Func _winapi_createfilemapping($hfile, $isize = 0, $sname = "", $iprotect = 4, $tsecurity = 0)
  5373. Local $stypeofname = "wstr"
  5374. If NOT StringStripWS($sname, $str_stripleading + $str_striptrailing) Then
  5375. $stypeofname = "ptr"
  5376. $sname = 0
  5377. EndIf
  5378. Local $aret = DllCall("kernel32.dll", "handle", "CreateFileMappingW", "handle", $hfile, "struct*", $tsecurity, "dword", $iprotect, "dword", _winapi_hidword($isize), "dword", _winapi_lodword($isize), $stypeofname, $sname)
  5379. If @error Then Return SetError(@error, @extended, 0)
  5380. Return SetExtended(_winapi_getlasterror(), $aret[0])
  5381. EndFunc
  5382.  
  5383. Func _winapi_createhardlink($snewfile, $sexistingfile)
  5384. Local $aret = DllCall("kernel32.dll", "bool", "CreateHardLinkW", "wstr", $snewfile, "wstr", $sexistingfile, "ptr", 0)
  5385. If @error Then Return SetError(@error, @extended, False)
  5386. Return $aret[0]
  5387. EndFunc
  5388.  
  5389. Func _winapi_createobjectid($sfilepath)
  5390. Local $hfile = _winapi_createfileex($sfilepath, $open_existing, 0, $file_share_readwrite, $file_flag_backup_semantics)
  5391. If @error Then Return SetError(@error + 20, @extended, 0)
  5392. Local $tfoid = DllStructCreate("byte[16];byte[48]")
  5393. Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 590016, "ptr", 0, "dword", 0, "struct*", $tfoid, "dword", DllStructGetSize($tfoid), "dword*", 0, "ptr", 0)
  5394. If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, 0)
  5395. Local $tguid = DllStructCreate($tagguid)
  5396. _winapi_movememory($tguid, $tfoid, 16)
  5397. Return $tguid
  5398. EndFunc
  5399.  
  5400. Func _winapi_createsymboliclink($ssymlink, $starget, $bdirectory = False)
  5401. If $bdirectory Then
  5402. $bdirectory = 1
  5403. EndIf
  5404. Local $aret = DllCall("kernel32.dll", "boolean", "CreateSymbolicLinkW", "wstr", $ssymlink, "wstr", $starget, "dword", $bdirectory)
  5405. If @error Then Return SetError(@error, @extended, False)
  5406. Return $aret[0]
  5407. EndFunc
  5408.  
  5409. Func _winapi_decryptfile($sfilepath)
  5410. Local $aret = DllCall("advapi32.dll", "bool", "DecryptFileW", "wstr", $sfilepath, "dword", 0)
  5411. If @error Then Return SetError(@error, @extended, False)
  5412. Return $aret[0]
  5413. EndFunc
  5414.  
  5415. Func _winapi_definedosdevice($sdevice, $iflags, $sfilepath = "")
  5416. Local $stypeofpath = "wstr"
  5417. If NOT StringStripWS($sfilepath, $str_stripleading + $str_striptrailing) Then
  5418. $stypeofpath = "ptr"
  5419. $sfilepath = 0
  5420. EndIf
  5421. Local $aret = DllCall("kernel32.dll", "bool", "DefineDosDeviceW", "dword", $iflags, "wstr", $sdevice, $stypeofpath, $sfilepath)
  5422. If @error Then Return SetError(@error, @extended, False)
  5423. Return $aret[0]
  5424. EndFunc
  5425.  
  5426. Func _winapi_deletefile($sfilepath)
  5427. Local $aret = DllCall("kernel32.dll", "bool", "DeleteFileW", "wstr", $sfilepath)
  5428. If @error Then Return SetError(@error, @extended, False)
  5429. Return $aret[0]
  5430. EndFunc
  5431.  
  5432. Func _winapi_deleteobjectid($sfilepath)
  5433. Local $hfile = _winapi_createfileex($sfilepath, $open_existing, $generic_write, $file_share_readwrite, $file_flag_backup_semantics)
  5434. If @error Then Return SetError(@error + 20, @extended, 0)
  5435. Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 589984, "ptr", 0, "dword", 0, "ptr", 0, "dword", 0, "dword*", 0, "ptr", 0)
  5436. If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, 0)
  5437. Return 1
  5438. EndFunc
  5439.  
  5440. Func _winapi_deletevolumemountpoint($smountedpath)
  5441. Local $aret = DllCall("kernel32.dll", "bool", "DeleteVolumeMountPointW", "wstr", $smountedpath)
  5442. If @error Then Return SetError(@error, @extended, 0)
  5443. Return $aret[0]
  5444. EndFunc
  5445.  
  5446. Func _winapi_deviceiocontrol($hdevice, $icontrolcode, $pinbuffer = 0, $iinbuffersize = 0, $poutbuffer = 0, $ioutbuffersize = 0)
  5447. Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hdevice, "dword", $icontrolcode, "struct*", $pinbuffer, "dword", $iinbuffersize, "struct*", $poutbuffer, "dword", $ioutbuffersize, "dword*", 0, "ptr", 0)
  5448. If @error Then Return SetError(@error, @extended, False)
  5449. Return SetExtended($aret[7], $aret[0])
  5450. EndFunc
  5451.  
  5452. Func _winapi_duplicateencryptioninfofile($ssrcfilepath, $sdestfilepath, $icreation = 2, $iattributes = 0, $tsecurity = 0)
  5453. Local $aret = DllCall("advapi32.dll", "dword", "DuplicateEncryptionInfoFile", "wstr", $ssrcfilepath, "wstr", $sdestfilepath, "dword", $icreation, "dword", $iattributes, "struct*", $tsecurity)
  5454. If @error Then Return SetError(@error, @extended, 0)
  5455. If $aret[0] Then Return SetError(10, $aret[0], 0)
  5456. Return 1
  5457. EndFunc
  5458.  
  5459. Func _winapi_ejectmedia($sdrive)
  5460. Local $hfile = _winapi_createfileex("\\.\" & $sdrive, $open_existing, $generic_read, $file_share_readwrite)
  5461. If @error Then Return SetError(@error + 20, @extended, 0)
  5462. Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 2967560, "ptr", 0, "dword", 0, "ptr", 0, "dword", 0, "dword*", 0, "ptr", 0)
  5463. If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, 0)
  5464. Return 1
  5465. EndFunc
  5466.  
  5467. Func _winapi_encryptfile($sfilepath)
  5468. Local $aret = DllCall("advapi32.dll", "bool", "EncryptFileW", "wstr", $sfilepath)
  5469. If @error Then Return SetError(@error, @extended, False)
  5470. Return $aret[0]
  5471. EndFunc
  5472.  
  5473. Func _winapi_encryptiondisable($sdir, $bdisable)
  5474. Local $aret = DllCall("advapi32.dll", "bool", "EncryptionDisable", "wstr", $sdir, "bool", $bdisable)
  5475. If @error Then Return SetError(@error, @extended, False)
  5476. Return $aret[0]
  5477. EndFunc
  5478.  
  5479. Func _winapi_enumfiles($sdir, $iflag = 0, $stemplate = "", $bexclude = False)
  5480. Local $aret = 0, $ierror = 0
  5481. Local $adata[501][7] = [[0]]
  5482. Local $hdir = _winapi_createfileex($sdir, $open_existing, 1, $file_share_any, $file_flag_backup_semantics)
  5483. If @error Then Return SetError(@error + 20, @extended, 0)
  5484. Local $pbuffer = __heapalloc($__g_iheapsize)
  5485. If @error Then
  5486. $ierror = @error
  5487. Else
  5488. Local $tiosb = DllStructCreate("ptr;ulong_ptr")
  5489. $aret = DllCall("ntdll.dll", "uint", "ZwQueryDirectoryFile", "handle", $hdir, "ptr", 0, "ptr", 0, "ptr", 0, "struct*", $tiosb, "struct*", $pbuffer, "ulong", 8388608, "uint", 1, "boolean", 0, "ptr", 0, "boolean", 1)
  5490. If @error OR $aret[0] Then
  5491. $ierror = @error + 40
  5492. EndIf
  5493. EndIf
  5494. DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hdir)
  5495. If $ierror Then
  5496. __heapfree($pbuffer, 1)
  5497. If IsArray($aret) Then
  5498. Return SetError(10, $aret[0], 0)
  5499. Else
  5500. Return SetError($ierror, 0, 0)
  5501. EndIf
  5502. EndIf
  5503. Local $tfdi, $iattrib, $starget, $ilength = 0, $ioffset = 0
  5504. Do
  5505. $ilength += $ioffset
  5506. $tfdi = DllStructCreate("ulong;ulong;int64;int64;int64;int64;int64;int64;ulong;ulong;wchar[" & (DllStructGetData(DllStructCreate("ulong", $pbuffer + $ilength + 60), 1) / 2) & "]", $pbuffer + $ilength)
  5507. $starget = DllStructGetData($tfdi, 11)
  5508. $iattrib = DllStructGetData($tfdi, 9)
  5509. $ioffset = DllStructGetData($tfdi, 1)
  5510. Switch $starget
  5511. Case ".", ".."
  5512. ContinueLoop
  5513. Case Else
  5514. Switch $iflag
  5515. Case 1, 2
  5516. If BitAND($iattrib, 16) Then
  5517. If $iflag = 1 Then
  5518. ContinueLoop
  5519. EndIf
  5520. Else
  5521. If $iflag = 2 Then
  5522. ContinueLoop
  5523. EndIf
  5524. EndIf
  5525. EndSwitch
  5526. If $stemplate Then
  5527. $aret = DllCall("shlwapi.dll", "int", "PathMatchSpecW", "wstr", $starget, "wstr", $stemplate)
  5528. If @error OR ($aret[0] AND $bexclude) OR (NOT $aret[0] AND NOT $bexclude) Then
  5529. ContinueLoop
  5530. EndIf
  5531. EndIf
  5532. EndSwitch
  5533. __inc($adata, 500)
  5534. $adata[$adata[0][0]][0] = $starget
  5535. $adata[$adata[0][0]][1] = DllStructGetData($tfdi, 3)
  5536. $adata[$adata[0][0]][2] = DllStructGetData($tfdi, 4)
  5537. $adata[$adata[0][0]][3] = DllStructGetData($tfdi, 5)
  5538. $adata[$adata[0][0]][4] = DllStructGetData($tfdi, 7)
  5539. $adata[$adata[0][0]][5] = DllStructGetData($tfdi, 8)
  5540. $adata[$adata[0][0]][6] = $iattrib
  5541. Until NOT $ioffset
  5542. __heapfree($pbuffer)
  5543. __inc($adata, -1)
  5544. Return $adata
  5545. EndFunc
  5546.  
  5547. Func _winapi_enumfilestreams($sfilepath)
  5548. Local $tdata = DllStructCreate("byte[32768]")
  5549. Local $pdata = DllStructGetPtr($tdata)
  5550. Local $adata[101][2] = [[0]]
  5551. Local $hfile = _winapi_createfileex($sfilepath, $open_existing, 0, $file_share_readwrite, $file_flag_backup_semantics)
  5552. If @error Then Return SetError(@error + 20, @extended, 0)
  5553. Local $ierror = 0
  5554. Local $tiosb = DllStructCreate("ptr;ulong_ptr")
  5555. Local $aret = DllCall("ntdll.dll", "long", "ZwQueryInformationFile", "handle", $hfile, "struct*", $tiosb, "ptr", $pdata, "ulong", 32768, "uint", 22)
  5556. If @error Then $ierror = @error
  5557. DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hfile)
  5558. If $ierror Then Return SetError($ierror, 0, 0)
  5559. If $aret[0] Then Return SetError(10, $aret[0], 0)
  5560. Local $tfsi, $ilength = 0, $ioffset = 0
  5561. Do
  5562. $ilength += $ioffset
  5563. $tfsi = DllStructCreate("ulong;ulong;int64;int64;wchar[" & (DllStructGetData(DllStructCreate("ulong", $pdata + $ilength + 4), 1) / 2) & "]", $pdata + $ilength)
  5564. __inc($adata)
  5565. $adata[$adata[0][0]][0] = DllStructGetData($tfsi, 5)
  5566. $adata[$adata[0][0]][1] = DllStructGetData($tfsi, 3)
  5567. $ioffset = DllStructGetData($tfsi, 1)
  5568. Until NOT $ioffset
  5569. __inc($adata, -1)
  5570. Return $adata
  5571. EndFunc
  5572.  
  5573. Func _winapi_enumhardlinks($sfilepath)
  5574. Local $tdata = DllStructCreate("byte[32768]")
  5575. Local $pdata = DllStructGetPtr($tdata)
  5576. Local $hfile = _winapi_createfileex($sfilepath, $open_existing, 0, $file_share_readwrite)
  5577. If @error Then Return SetError(@error + 20, @extended, 0)
  5578. Local $ierror = 0
  5579. Local $tiosb = DllStructCreate("ptr;ulong_ptr")
  5580. Local $aret = DllCall("ntdll.dll", "long", "ZwQueryInformationFile", "handle", $hfile, "struct*", $tiosb, "ptr", $pdata, "ulong", 32768, "uint", 46)
  5581. If @error OR $aret[0] Then
  5582. $ierror = @error + 10
  5583. DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hfile)
  5584. If $aret Then Return SetError($ierror, 0, 0)
  5585. If $aret[0] Then Return SetError(10, $ierror, 0)
  5586. EndIf
  5587. Local $icount = DllStructGetData(DllStructCreate("ulong;ulong", $pdata), 2)
  5588. Local $adata[$icount + 1] = [$icount]
  5589. Local $tflei, $hpath, $spath, $ilength = 8
  5590. For $i = 1 To $icount
  5591. $tflei = DllStructCreate("ulong;int64;ulong;wchar[" & (DllStructGetData(DllStructCreate("ulong", $pdata + $ilength + 16), 1)) & "]", $pdata + $ilength)
  5592. $ierror = 0
  5593. Do
  5594. $hpath = _winapi_openfilebyid($hfile, DllStructGetData($tflei, 2), 1048704, $file_share_readwrite, $file_flag_backup_semantics)
  5595. If @error Then
  5596. $ierror = @error + 100
  5597. ExitLoop
  5598. EndIf
  5599. $spath = _winapi_getfinalpathnamebyhandleex($hpath)
  5600. If @error Then
  5601. $ierror = @error + 200
  5602. ExitLoop
  5603. EndIf
  5604. Until 1
  5605. If $hpath Then
  5606. DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hpath)
  5607. EndIf
  5608. If $ierror Then ExitLoop
  5609. $adata[$i] = _winapi_pathappend($spath, DllStructGetData($tflei, 4))
  5610. $ilength += DllStructGetData($tflei, 1)
  5611. Next
  5612. DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hfile)
  5613. If $ierror Then Return SetError($ierror, 0, 0)
  5614. Return $adata
  5615. EndFunc
  5616.  
  5617. Func _winapi_fileencryptionstatus($sfilepath)
  5618. Local $aret = DllCall("advapi32.dll", "bool", "FileEncryptionStatusW", "wstr", $sfilepath, "dword*", 0)
  5619. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, -1)
  5620. Return $aret[2]
  5621. EndFunc
  5622.  
  5623. Func _winapi_fileexists($sfilepath)
  5624. If NOT FileExists($sfilepath) Then Return 0
  5625. If _winapi_pathisdirectory($sfilepath) Then Return SetExtended(1, 0)
  5626. Return 1
  5627. EndFunc
  5628.  
  5629. Func _winapi_fileinuse($sfilepath)
  5630. Local $hfile = _winapi_createfileex($sfilepath, $open_existing, $generic_read)
  5631. If @error Then
  5632. If @extended = 32 Then Return 1
  5633. Return SetError(@error, @extended, 0)
  5634. EndIf
  5635. DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hfile)
  5636. Return 0
  5637. EndFunc
  5638.  
  5639. Func _winapi_findclose($hsearch)
  5640. Local $aret = DllCall("kernel32.dll", "bool", "FindClose", "handle", $hsearch)
  5641. If @error Then Return SetError(@error, @extended, False)
  5642. Return $aret[0]
  5643. EndFunc
  5644.  
  5645. Func _winapi_findclosechangenotification($hchange)
  5646. Local $aret = DllCall("kernel32.dll", "bool", "FindCloseChangeNotification", "handle", $hchange)
  5647. If @error Then Return SetError(@error, @extended, False)
  5648. Return $aret[0]
  5649. EndFunc
  5650.  
  5651. Func _winapi_findfirstchangenotification($sdirectory, $iflags, $bsubtree = False)
  5652. Local $aret = DllCall("kernel32.dll", "handle", "FindFirstChangeNotificationW", "wstr", $sdirectory, "bool", $bsubtree, "dword", $iflags)
  5653. If @error OR ($aret[0] = Ptr(-1)) Then Return SetError(@error + 10, @extended, 0)
  5654. Return $aret[0]
  5655. EndFunc
  5656.  
  5657. Func _winapi_findfirstfile($sfilepath, $tdata)
  5658. Local $aret = DllCall("kernel32.dll", "handle", "FindFirstFileW", "wstr", $sfilepath, "struct*", $tdata)
  5659. If @error Then Return SetError(@error, @extended, 0)
  5660. If $aret[0] = Ptr(-1) Then Return SetError(10, _winapi_getlasterror(), 0)
  5661. Return $aret[0]
  5662. EndFunc
  5663.  
  5664. Func _winapi_findfirstfilename($sfilepath, ByRef $slink)
  5665. $slink = ""
  5666. Local $aret = DllCall("kernel32.dll", "handle", "FindFirstFileNameW", "wstr", $sfilepath, "dword", 0, "dword*", 4096, "wstr", "")
  5667. If @error OR ($aret[0] = Ptr(-1)) Then Return SetError(@error + 10, @extended, 0)
  5668. $slink = $aret[4]
  5669. Return $aret[0]
  5670. EndFunc
  5671.  
  5672. Func _winapi_findfirststream($sfilepath, $tdata)
  5673. Local $aret = DllCall("kernel32.dll", "handle", "FindFirstStreamW", "wstr", $sfilepath, "uint", 0, "struct*", $tdata, "dword", 0)
  5674. If @error Then Return SetError(@error, @extended, 0)
  5675. If $aret[0] = Ptr(-1) Then Return SetError(10, _winapi_getlasterror(), 0)
  5676. Return $aret[0]
  5677. EndFunc
  5678.  
  5679. Func _winapi_findnextchangenotification($hchange)
  5680. Local $aret = DllCall("kernel32.dll", "bool", "FindNextChangeNotification", "handle", $hchange)
  5681. If @error Then Return SetError(@error, @extended, 0)
  5682. Return $aret[0]
  5683. EndFunc
  5684.  
  5685. Func _winapi_findnextfile($hsearch, $tdata)
  5686. Local $aret = DllCall("kernel32.dll", "bool", "FindNextFileW", "handle", $hsearch, "struct*", $tdata)
  5687. If @error Then Return SetError(@error, @extended, False)
  5688. If NOT $aret[0] Then Return SetError(10, _winapi_getlasterror(), 0)
  5689. Return $aret[0]
  5690. EndFunc
  5691.  
  5692. Func _winapi_findnextfilename($hsearch, ByRef $slink)
  5693. $slink = ""
  5694. Local $aret = DllCall("kernel32.dll", "bool", "FindNextFileNameW", "handle", $hsearch, "dword*", 4096, "wstr", "")
  5695. If @error Then Return SetError(@error, @extended, False)
  5696. If NOT $aret[0] Then Return SetError(10, _winapi_getlasterror(), 0)
  5697. $slink = $aret[3]
  5698. Return $aret[0]
  5699. EndFunc
  5700.  
  5701. Func _winapi_findnextstream($hsearch, $tdata)
  5702. Local $aret = DllCall("kernel32.dll", "bool", "FindNextStreamW", "handle", $hsearch, "struct*", $tdata)
  5703. If @error Then Return SetError(@error, @extended, False)
  5704. If NOT $aret[0] Then Return SetError(10, _winapi_getlasterror(), 0)
  5705. Return $aret[0]
  5706. EndFunc
  5707.  
  5708. Func _winapi_flushfilebuffers($hfile)
  5709. Local $aresult = DllCall("kernel32.dll", "bool", "FlushFileBuffers", "handle", $hfile)
  5710. If @error Then Return SetError(@error, @extended, False)
  5711. Return $aresult[0]
  5712. EndFunc
  5713.  
  5714. Func _winapi_flushviewoffile($paddress, $ibytes = 0)
  5715. Local $aret = DllCall("kernel32.dll", "bool", "FlushViewOfFile", "struct*", $paddress, "dword", $ibytes)
  5716. If @error Then Return SetError(@error, @extended, 0)
  5717. Return $aret[0]
  5718. EndFunc
  5719.  
  5720. Func _winapi_getbinarytype($sfilepath)
  5721. Local $aret = DllCall("kernel32.dll", "int", "GetBinaryTypeW", "wstr", $sfilepath, "dword*", 0)
  5722. If @error Then Return SetError(@error, @extended, 0)
  5723. If NOT $aret[0] Then $aret[2] = 0
  5724. Return SetExtended($aret[2], $aret[0])
  5725. EndFunc
  5726.  
  5727. Func _winapi_getcdtype($sdrive)
  5728. Local $hfile = _winapi_createfileex("\\.\" & $sdrive, $open_existing, $generic_readwrite, $file_share_readwrite)
  5729. If @error Then Return SetError(@error + 20, @extended, 0)
  5730. Local $tagscsi_pass_through = "struct;ushort Length;byte ScsiStatus;byte PathId;byte TargetId;byte Lun;byte CdbLength;byte SenseInfoLength;byte DataIn;ulong DataTransferLength;ulong TimeOutValue;ulong_ptr DataBufferOffset;ulong SenseInfoOffset;byte Cdb[16];endstruct"
  5731. Local $tspt = DllStructCreate($tagscsi_pass_through & ";byte Hdr[8]")
  5732. Local $tcdb = DllStructCreate("byte;byte;byte[2];byte[3];byte[2];byte;byte[2];byte[4]", DllStructGetPtr($tspt, "Cdb"))
  5733. Local $thdr = DllStructCreate("byte[4];byte;byte;byte[2]", DllStructGetPtr($tspt, "Hdr"))
  5734. Local $isize = DllStructGetPtr($tspt, "Hdr") - DllStructGetPtr($tspt)
  5735. DllStructSetData($tspt, "Length", $isize)
  5736. DllStructSetData($tspt, "ScsiStatus", 0)
  5737. DllStructSetData($tspt, "PathId", 0)
  5738. DllStructSetData($tspt, "TargetId", 0)
  5739. DllStructSetData($tspt, "Lun", 0)
  5740. DllStructSetData($tspt, "CdbLength", 12)
  5741. DllStructSetData($tspt, "SenseInfoLength", 0)
  5742. DllStructSetData($tspt, "DataIn", 1)
  5743. DllStructSetData($tspt, "DataTransferLength", 8)
  5744. DllStructSetData($tspt, "TimeOutValue", 86400)
  5745. DllStructSetData($tspt, "DataBufferOffset", $isize)
  5746. DllStructSetData($tspt, "SenseInfoOffset", 0)
  5747. DllStructSetData($tcdb, 1, 70)
  5748. DllStructSetData($tcdb, 2, 0)
  5749. DllStructSetData($tcdb, 3, 0, 1)
  5750. DllStructSetData($tcdb, 3, 0, 2)
  5751. DllStructSetData($tcdb, 5, 0, 1)
  5752. DllStructSetData($tcdb, 5, 8, 2)
  5753. DllStructSetData($tcdb, 6, 0)
  5754. DllStructSetData($tcdb, 7, 0, 1)
  5755. DllStructSetData($tcdb, 7, 0, 2)
  5756. Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 315396, "struct*", $tspt, "dword", $isize, "struct*", $tspt, "dword", DllStructGetSize($tspt), "dword*", 0, "ptr", 0)
  5757. If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, 0)
  5758. Return BitOR(BitShift(DllStructGetData($thdr, 4, 1), -8), DllStructGetData($thdr, 4, 2))
  5759. EndFunc
  5760.  
  5761. Func _winapi_getcompressedfilesize($sfilepath)
  5762. Local $aret = DllCall("kernel32.dll", "dword", "GetCompressedFileSizeW", "wstr", $sfilepath, "dword*", 0)
  5763. If @error Then Return SetError(@error, @extended, 0)
  5764. If $aret[0] = -1 Then
  5765. Local $ilasterror = _winapi_getlasterror()
  5766. If $aret[2] = 0 Then Return SetError(10, $ilasterror, 0)
  5767. If $ilasterror Then Return SetError(11, $ilasterror, 0)
  5768. EndIf
  5769. Return __winapi_makeqword($aret[0], $aret[2])
  5770. EndFunc
  5771.  
  5772. Func _winapi_getcompression($sfilepath)
  5773. Local $hfile = _winapi_createfileex($sfilepath, $open_existing, $generic_read, $file_share_readwrite, $file_flag_backup_semantics)
  5774. If @error Then Return SetError(@error + 20, @extended, 0)
  5775. Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 589884, "ptr", 0, "dword", 0, "ushort*", 0, "dword", 2, "dword*", 0, "ptr", 0)
  5776. If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, -1)
  5777. Return $aret[5]
  5778. EndFunc
  5779.  
  5780. Func _winapi_getcurrentdirectory()
  5781. Local $aret = DllCall("kernel32.dll", "dword", "GetCurrentDirectoryW", "dword", 4096, "wstr", "")
  5782. If @error Then Return SetError(@error, @extended, "")
  5783. Return SetExtended($aret[0], $aret[2])
  5784. EndFunc
  5785.  
  5786. Func _winapi_getdiskfreespaceex($sdrive)
  5787. Local $aret = DllCall("kernel32.dll", "bool", "GetDiskFreeSpaceEx", "str", $sdrive, "int64*", 0, "int64*", 0, "int64*", 0)
  5788. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  5789. Local $aresult[3]
  5790. For $i = 0 To 2
  5791. $aresult[$i] = $aret[$i + 2]
  5792. Next
  5793. Return $aresult
  5794. EndFunc
  5795.  
  5796. Func _winapi_getdrivebustype($sdrive)
  5797. Local $hfile = _winapi_createfileex("\\.\" & $sdrive, $open_existing, 0, $file_share_readwrite)
  5798. If @error Then Return SetError(@error + 20, @extended, -1)
  5799. Local $tagstorage_property_query = "ulong PropertyId;ulong QueryType;byte AdditionalParameters[1]"
  5800. Local $tspq = DllStructCreate($tagstorage_property_query)
  5801. Local $tsdd = DllStructCreate("ulong Version;ulong Size;byte DeviceType;byte DeviceTypeModifier;byte RemovableMedia;byte CommandQueueing;ulong VendorIdOffset;ulong ProductIdOffset;ulong ProductRevisionOffset;ulong SerialNumberOffset;ulong BusType;ulong RawPropertiesLength;byte RawDeviceProperties[1]")
  5802. DllStructSetData($tspq, "PropertyId", 0)
  5803. DllStructSetData($tspq, "QueryType", 0)
  5804. Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 2954240, "struct*", $tspq, "dword", DllStructGetSize($tspq), "struct*", $tsdd, "dword", DllStructGetSize($tsdd), "dword*", 0, "ptr", 0)
  5805. If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, -1)
  5806. Return DllStructGetData($tsdd, "BusType")
  5807. EndFunc
  5808.  
  5809. Func _winapi_getdrivegeometryex($idrive)
  5810. Local $hfile = _winapi_createfileex("\\.\PhysicalDrive" & $idrive, $open_existing, 0, $file_share_readwrite)
  5811. If @error Then Return SetError(@error + 20, @extended, 0)
  5812. Local $tdgex = DllStructCreate("uint64;dword;dword;dword;dword;uint64")
  5813. Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 458912, "ptr", 0, "dword", 0, "struct*", $tdgex, "dword", DllStructGetSize($tdgex), "dword*", 0, "ptr", 0)
  5814. If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, 0)
  5815. Local $aresult[6]
  5816. For $i = 0 To 5
  5817. $aresult[$i] = DllStructGetData($tdgex, $i + 1)
  5818. Next
  5819. Return $aresult
  5820. EndFunc
  5821.  
  5822. Func _winapi_getdrivenumber($sdrive)
  5823. Local $hfile = _winapi_createfileex("\\.\" & $sdrive, $open_existing, 0, $file_share_readwrite)
  5824. If @error Then Return SetError(@error + 20, @extended, 0)
  5825. Local $tsdn = DllStructCreate("dword;ulong;ulong")
  5826. Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 2953344, "ptr", 0, "dword", 0, "struct*", $tsdn, "dword", DllStructGetSize($tsdn), "dword*", 0, "ptr", 0)
  5827. If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, 0)
  5828. Local $aresult[3]
  5829. For $i = 0 To 2
  5830. $aresult[$i] = DllStructGetData($tsdn, $i + 1)
  5831. Next
  5832. Return $aresult
  5833. EndFunc
  5834.  
  5835. Func _winapi_getdrivetype($sdrive = "")
  5836. Local $itypeofdrive = "str"
  5837. If NOT StringStripWS($sdrive, $str_stripleading + $str_striptrailing) Then
  5838. $itypeofdrive = "ptr"
  5839. $sdrive = 0
  5840. EndIf
  5841. Local $aret = DllCall("kernel32.dll", "uint", "GetDriveType", $itypeofdrive, $sdrive)
  5842. If @error Then Return SetError(@error, @extended, 0)
  5843. Return $aret[0]
  5844. EndFunc
  5845.  
  5846. Func _winapi_getfileattributes($sfilepath)
  5847. Local $aret = DllCall("kernel32.dll", "dword", "GetFileAttributesW", "wstr", $sfilepath)
  5848. If @error OR ($aret[0] = 4294967295) Then Return SetError(@error, @extended, 0)
  5849. Return $aret[0]
  5850. EndFunc
  5851.  
  5852. Func _winapi_getfileid($hfile)
  5853. Local $tiosb = DllStructCreate("ptr;ulong_ptr")
  5854. Local $aret = DllCall("ntdll.dll", "long", "ZwQueryInformationFile", "handle", $hfile, "struct*", $tiosb, "int64*", 0, "ulong", 8, "uint", 6)
  5855. If @error Then Return SetError(@error, @extended, 0)
  5856. If $aret[0] Then Return SetError(10, $aret[0], 0)
  5857. Return $aret[3]
  5858. EndFunc
  5859.  
  5860. Func _winapi_getfileinformationbyhandle($hfile)
  5861. Local $tbhfi = DllStructCreate("dword;dword[2];dword[2];dword[2];dword;dword;dword;dword;dword;dword")
  5862. Local $aret = DllCall("kernel32.dll", "bool", "GetFileInformationByHandle", "handle", $hfile, "struct*", $tbhfi)
  5863. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  5864. Local $aresult[8]
  5865. $aresult[0] = DllStructGetData($tbhfi, 1)
  5866. For $i = 1 To 3
  5867. If DllStructGetData($tbhfi, $i + 1) Then
  5868. $aresult[$i] = DllStructCreate($tagfiletime)
  5869. _winapi_movememory($aresult[$i], DllStructGetPtr($tbhfi, $i + 1), 8)
  5870. Else
  5871. $aresult[$i] = 0
  5872. EndIf
  5873. Next
  5874. $aresult[4] = DllStructGetData($tbhfi, 5)
  5875. $aresult[5] = __winapi_makeqword(DllStructGetData($tbhfi, 7), DllStructGetData($tbhfi, 6))
  5876. $aresult[6] = DllStructGetData($tbhfi, 8)
  5877. $aresult[7] = __winapi_makeqword(DllStructGetData($tbhfi, 9), DllStructGetData($tbhfi, 10))
  5878. Return $aresult
  5879. EndFunc
  5880.  
  5881. Func _winapi_getfileinformationbyhandleex($hfile)
  5882. Local $tfi = DllStructCreate($tagfileinfo)
  5883. Local $tiosb = DllStructCreate("ptr;ulong_ptr")
  5884. Local $aret = DllCall("ntdll.dll", "long", "ZwQueryInformationFile", "handle", $hfile, "struct*", $tiosb, "struct*", $tfi, "ulong", DllStructGetSize($tfi), "uint", 4)
  5885. If @error Then Return SetError(@error, @extended, 0)
  5886. If $aret[0] Then Return SetError(10, $aret[0], 0)
  5887. Return $tfi
  5888. EndFunc
  5889.  
  5890. Func _winapi_getfilepointerex($hfile)
  5891. Local $tiosb = DllStructCreate("ptr;ulong_ptr")
  5892. Local $aret = DllCall("ntdll.dll", "long", "ZwQueryInformationFile", "handle", $hfile, "struct*", $tiosb, "int64*", 0, "ulong", 8, "uint", 14)
  5893. If @error Then Return SetError(@error, @extended, "")
  5894. If $aret[0] Then Return SetError(10, $aret[0], "")
  5895. Return $aret[3]
  5896. EndFunc
  5897.  
  5898. Func _winapi_getfilesizeex($hfile)
  5899. Local $aresult = DllCall("kernel32.dll", "bool", "GetFileSizeEx", "handle", $hfile, "int64*", 0)
  5900. If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, -1)
  5901. Return $aresult[2]
  5902. EndFunc
  5903.  
  5904. Func _winapi_getfilesizeondisk($sfilepath)
  5905. Local $isize = FileGetSize($sfilepath)
  5906. If @error Then Return SetError(@error + 10, @extended, 0)
  5907. Local $aret = DllCall("kernel32.dll", "bool", "GetDiskFreeSpaceW", "wstr", _winapi_pathstriptoroot(_winapi_getfullpathname($sfilepath)), "dword*", 0, "dword*", 0, "dword*", 0, "dword*", 0)
  5908. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
  5909. Return Ceiling($isize / ($aret[2] * $aret[3])) * ($aret[2] * $aret[3])
  5910. EndFunc
  5911.  
  5912. Func _winapi_getfiletitle($sfilepath)
  5913. Local $aret = DllCall("comdlg32.dll", "short", "GetFileTitleW", "wstr", $sfilepath, "wstr", "", "word", 4096)
  5914. If @error OR $aret[0] Then Return SetError(@error, @extended, "")
  5915. Return $aret[2]
  5916. EndFunc
  5917.  
  5918. Func _winapi_getfiletype($hfile)
  5919. Local $aret = DllCall("kernel32.dll", "dword", "GetFileType", "handle", $hfile)
  5920. If @error Then Return SetError(@error, @extended, -1)
  5921. Local $ilasterror = _winapi_getlasterror()
  5922. If NOT $aret[0] AND $ilasterror Then Return SetError(10, $ilasterror, -1)
  5923. Return $aret[0]
  5924. EndFunc
  5925.  
  5926. Func _winapi_getfinalpathnamebyhandle($hfile)
  5927. Local $tfni = DllStructCreate("ulong;wchar[4096]")
  5928. Local $tiosb = DllStructCreate("ptr;ulong_ptr")
  5929. Local $aret = DllCall("ntdll.dll", "long", "ZwQueryInformationFile", "handle", $hfile, "struct*", $tiosb, "struct*", $tfni, "ulong", DllStructGetSize($tfni), "uint", 9)
  5930. If @error Then Return SetError(@error, @extended, "")
  5931. If $aret[0] Then Return SetError(10, $aret[0], "")
  5932. Local $ilength = DllStructGetData($tfni, 1)
  5933. If NOT $ilength Then Return SetError(12, 0, "")
  5934. Return DllStructGetData(DllStructCreate("wchar[" & ($ilength / 2) & "]", DllStructGetPtr($tfni, 2)), 1)
  5935. EndFunc
  5936.  
  5937. Func _winapi_getfinalpathnamebyhandleex($hfile, $iflags = 0)
  5938. Local $aret = DllCall("kernel32.dll", "dword", "GetFinalPathNameByHandleW", "handle", $hfile, "wstr", "", "dword", 4096, "dword", $iflags)
  5939. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  5940. Return $aret[2]
  5941. EndFunc
  5942.  
  5943. Func _winapi_getfullpathname($sfilepath)
  5944. Local $aret = DllCall("kernel32.dll", "dword", "GetFullPathNameW", "wstr", $sfilepath, "dword", 4096, "wstr", "", "ptr", 0)
  5945. If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
  5946. Return $aret[3]
  5947. EndFunc
  5948.  
  5949. Func _winapi_getlogicaldrives()
  5950. Local $aret = DllCall("kernel32.dll", "dword", "GetLogicalDrives")
  5951. If @error Then Return SetError(@error, @extended, 0)
  5952. Return $aret[0]
  5953. EndFunc
  5954.  
  5955. Func _winapi_getobjectid($sfilepath)
  5956. Local $hfile = _winapi_createfileex($sfilepath, $open_existing, 0, $file_share_readwrite, $file_flag_backup_semantics)
  5957. If @error Then Return SetError(@error + 20, @extended, 0)
  5958. Local $tfoid = DllStructCreate("byte[16];byte[48]")
  5959. Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 589980, "ptr", 0, "dword", 0, "struct*", $tfoid, "dword", DllStructGetSize($tfoid), "dword*", 0, "ptr", 0)
  5960. If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, 0)
  5961. Local $tguid = DllStructCreate($tagguid)
  5962. _winapi_movememory($tguid, $tfoid, 16)
  5963. Return $tguid
  5964. EndFunc
  5965.  
  5966. Func _winapi_getoverlappedresult($hfile, $toverlapped, ByRef $ibytes, $bwait = False)
  5967. Local $aresult = DllCall("kernel32.dll", "bool", "GetOverlappedResult", "handle", $hfile, "struct*", $toverlapped, "dword*", 0, "bool", $bwait)
  5968. If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, False)
  5969. $ibytes = $aresult[3]
  5970. Return $aresult[0]
  5971. EndFunc
  5972.  
  5973. Func _winapi_getpetype($sfilepath)
  5974. Local $tdata = DllStructCreate("ushort[2]")
  5975. Local $tuint = DllStructCreate("uint", DllStructGetPtr($tdata))
  5976. Local $hfile = _winapi_createfileex($sfilepath, $open_existing, $generic_read, $file_share_readwrite)
  5977. If @error Then Return SetError(@error + 20, @extended, 0)
  5978. Local $ierror = 0, $ival
  5979. Do
  5980. Local $aret = DllCall("kernel32.dll", "bool", "ReadFile", "handle", $hfile, "struct*", $tdata, "dword", 2, "dword*", 0, "ptr", 0)
  5981. If @error OR (NOT $aret[0]) OR ($aret[4] <> 2) Then
  5982. $ierror = @error + 30
  5983. ExitLoop
  5984. EndIf
  5985. $ival = DllStructGetData($tdata, 1, 1)
  5986. If $ival <> 23117 Then
  5987. $ierror = 3
  5988. ExitLoop
  5989. EndIf
  5990. If NOT _winapi_setfilepointerex($hfile, 60) Then
  5991. $ierror = @error + 40
  5992. ExitLoop
  5993. EndIf
  5994. $aret = DllCall("kernel32.dll", "bool", "ReadFile", "handle", $hfile, "struct*", $tdata, "dword", 4, "dword*", 0, "ptr", 0)
  5995. If @error OR (NOT $aret[0]) OR ($aret[4] <> 4) Then
  5996. $ierror = @error + 50
  5997. ExitLoop
  5998. EndIf
  5999. If NOT _winapi_setfilepointerex($hfile, DllStructGetData($tuint, 1)) Then
  6000. $ierror = @error + 60
  6001. ExitLoop
  6002. EndIf
  6003. $aret = DllCall("kernel32.dll", "bool", "ReadFile", "handle", $hfile, "struct*", $tdata, "dword", 4, "dword*", 0, "ptr", 0)
  6004. If @error OR (NOT $aret[0]) OR ($aret[4] <> 4) Then
  6005. $ierror = @error + 70
  6006. ExitLoop
  6007. EndIf
  6008. $ival = DllStructGetData($tuint, 1)
  6009. If $ival <> 17744 Then
  6010. $ierror = 4
  6011. ExitLoop
  6012. EndIf
  6013. $aret = DllCall("kernel32.dll", "bool", "ReadFile", "handle", $hfile, "struct*", $tdata, "dword", 2, "dword*", 0, "ptr", 0)
  6014. If @error OR (NOT $aret[0]) OR ($aret[4] <> 2) Then
  6015. $ierror = @error + 80
  6016. ExitLoop
  6017. EndIf
  6018. $ival = DllStructGetData($tdata, 1, 1)
  6019. Until 1
  6020. DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hfile)
  6021. If $ierror Then Return SetError($ierror, 0, 0)
  6022. Return $ival
  6023. EndFunc
  6024.  
  6025. Func _winapi_getprofilesdirectory()
  6026. Local $aret = DllCall("userenv.dll", "bool", "GetProfilesDirectoryW", "wstr", "", "dword*", 4096)
  6027. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  6028. Return $aret[1]
  6029. EndFunc
  6030.  
  6031. Func _winapi_gettempfilename($sfilepath, $sprefix = "")
  6032. Local $aret = DllCall("kernel32.dll", "uint", "GetTempFileNameW", "wstr", $sfilepath, "wstr", $sprefix, "uint", 0, "wstr", "")
  6033. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  6034. Return $aret[4]
  6035. EndFunc
  6036.  
  6037. Func _winapi_getvolumeinformation($sroot = "")
  6038. Local $stypeofroot = "wstr"
  6039. If NOT StringStripWS($sroot, $str_stripleading + $str_striptrailing) Then
  6040. $stypeofroot = "ptr"
  6041. $sroot = 0
  6042. EndIf
  6043. Local $aret = DllCall("kernel32.dll", "bool", "GetVolumeInformationW", $stypeofroot, $sroot, "wstr", "", "dword", 4096, "dword*", 0, "dword*", 0, "dword*", 0, "wstr", "", "dword", 4096)
  6044. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  6045. Local $aresult[5]
  6046. For $i = 0 To 4
  6047. Switch $i
  6048. Case 0
  6049. $aresult[$i] = $aret[2]
  6050. Case Else
  6051. $aresult[$i] = $aret[$i + 3]
  6052. EndSwitch
  6053. Next
  6054. Return $aresult
  6055. EndFunc
  6056.  
  6057. Func _winapi_getvolumeinformationbyhandle($hfile)
  6058. Local $aret = DllCall("kernel32.dll", "bool", "GetVolumeInformationByHandleW", "handle", $hfile, "wstr", "", "dword", 4096, "dword*", 0, "dword*", 0, "dword*", 0, "wstr", "", "dword", 4096)
  6059. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  6060. Local $aresult[5]
  6061. For $i = 0 To 4
  6062. Switch $i
  6063. Case 0
  6064. $aresult[$i] = $aret[2]
  6065. Case Else
  6066. $aresult[$i] = $aret[$i + 3]
  6067. EndSwitch
  6068. Next
  6069. Return $aresult
  6070. EndFunc
  6071.  
  6072. Func _winapi_getvolumenameforvolumemountpoint($smountedpath)
  6073. Local $aret = DllCall("kernel32.dll", "bool", "GetVolumeNameForVolumeMountPointW", "wstr", $smountedpath, "wstr", "", "dword", 80)
  6074. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  6075. Return $aret[2]
  6076. EndFunc
  6077.  
  6078. Func _winapi_ioctl($idevicetype, $ifunction, $imethod, $iaccess)
  6079. Return BitOR(BitShift($idevicetype, -16), BitShift($iaccess, -14), BitShift($ifunction, -2), $imethod)
  6080. EndFunc
  6081.  
  6082. Func _winapi_isdooropen($sdrive)
  6083. Local $hfile = _winapi_createfileex("\\.\" & $sdrive, $open_existing, $generic_readwrite, $file_share_readwrite)
  6084. If @error Then Return SetError(@error + 20, @extended, False)
  6085. Local $tspt = DllStructCreate("ushort Length;byte ScsiStatus;byte PathId;byte TargetId;byte Lun;byte CdbLength;byte SenseInfoLength;byte DataIn;byte Alignment[3];ulong DataTransferLength;ulong TimeOutValue;ulong_ptr DataBufferOffset;ulong SenseInfoOffset;byte Cdb[16]" & (@AutoItX64 ? ";byte[4]" : "") & ";byte Hdr[8]")
  6086. Local $tcdb = DllStructCreate("byte;byte;byte[6];byte[2];byte;byte;byte[4]", DllStructGetPtr($tspt, "Cdb"))
  6087. Local $thdr = DllStructCreate("byte;byte;byte[3];byte;byte[2]", DllStructGetPtr($tspt, "Hdr"))
  6088. Local $isize = DllStructGetPtr($tspt, "Hdr") - DllStructGetPtr($tspt)
  6089. DllStructSetData($tspt, "Length", $isize)
  6090. DllStructSetData($tspt, "ScsiStatus", 0)
  6091. DllStructSetData($tspt, "PathId", 0)
  6092. DllStructSetData($tspt, "TargetId", 0)
  6093. DllStructSetData($tspt, "Lun", 0)
  6094. DllStructSetData($tspt, "CdbLength", 12)
  6095. DllStructSetData($tspt, "SenseInfoLength", 0)
  6096. DllStructSetData($tspt, "DataIn", 1)
  6097. DllStructSetData($tspt, "DataTransferLength", 8)
  6098. DllStructSetData($tspt, "TimeOutValue", 86400)
  6099. DllStructSetData($tspt, "DataBufferOffset", $isize)
  6100. DllStructSetData($tspt, "SenseInfoOffset", 0)
  6101. DllStructSetData($tcdb, 1, 189)
  6102. DllStructSetData($tcdb, 2, 0)
  6103. DllStructSetData($tcdb, 4, 0, 1)
  6104. DllStructSetData($tcdb, 4, 8, 2)
  6105. DllStructSetData($tcdb, 5, 0)
  6106. DllStructSetData($tcdb, 6, 0)
  6107. Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 315396, "struct*", $tspt, "dword", $isize, "struct*", $tspt, "dword", DllStructGetSize($tspt), "dword*", 0, "ptr", 0)
  6108. If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, False)
  6109. Return (BitAND(DllStructGetData($thdr, 2), 16) = 16)
  6110. EndFunc
  6111.  
  6112. Func _winapi_ispathshared($sfilepath)
  6113. If NOT __dll("ntshrui.dll") Then Return SetError(103, 0, 0)
  6114. Local $aret = DllCall("ntshrui.dll", "bool", "IsPathSharedW", "wstr", _winapi_pathremovebackslash($sfilepath), "int", 1)
  6115. If @error Then Return SetError(@error, @extended, 0)
  6116. Return $aret[0]
  6117. EndFunc
  6118.  
  6119. Func _winapi_iswritable($sdrive)
  6120. DriveGetFileSystem($sdrive)
  6121. If @error Then Return SetError(40 + @error, _winapi_getlasterror(), 0)
  6122. Local $hfile = _winapi_createfileex("\\.\" & $sdrive, $open_existing, 0, $file_share_readwrite)
  6123. If @error Then Return SetError(@error + 20, @extended, 0)
  6124. Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 458788, "ptr", 0, "dword", 0, "ptr", 0, "dword", 0, "dword*", 0, "ptr", 0)
  6125. Local Const $error_write_protect = 19
  6126. If __checkerrorclosehandle($aret, $hfile, 1) <> 10 AND @extended = $error_write_protect Then Return SetError(@error, @extended, 0)
  6127. Return $aret[0]
  6128. EndFunc
  6129.  
  6130. Func _winapi_loadmedia($sdrive)
  6131. Local $hfile = _winapi_createfileex("\\.\" & $sdrive, $open_existing, $generic_read, $file_share_readwrite)
  6132. If @error Then Return SetError(@error + 20, @extended, False)
  6133. Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 2967564, "ptr", 0, "dword", 0, "ptr", 0, "dword", 0, "dword*", 0, "ptr", 0)
  6134. If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, False)
  6135. Return $aret[0]
  6136. EndFunc
  6137.  
  6138. Func _winapi_lockdevice($sdrive, $block)
  6139. Local $hfile = _winapi_createfileex("\\.\" & $sdrive, $open_existing, $generic_readwrite, $file_share_readwrite)
  6140. If @error Then Return SetError(@error + 20, @extended, False)
  6141. Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 2967556, "boolean*", $block, "dword", 1, "ptr", 0, "dword", 0, "dword*", 0, "ptr", 0)
  6142. If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, False)
  6143. Return $aret[0]
  6144. EndFunc
  6145.  
  6146. Func _winapi_lockfile($hfile, $ioffset, $ilength)
  6147. Local $aret = DllCall("kernel32.dll", "bool", "LockFile", "handle", $hfile, "dword", _winapi_lodword($ioffset), "dword", _winapi_hidword($ioffset), "dword", _winapi_lodword($ilength), "dword", _winapi_hidword($ilength))
  6148. If @error Then Return SetError(@error, @extended, False)
  6149. Return $aret[0]
  6150. EndFunc
  6151.  
  6152. Func _winapi_mapviewoffile($hmapping, $ioffset = 0, $ibytes = 0, $iaccess = 6)
  6153. Local $aret = DllCall("kernel32.dll", "ptr", "MapViewOfFile", "handle", $hmapping, "dword", $iaccess, "dword", _winapi_hidword($ioffset), "dword", _winapi_lodword($ioffset), "ulong_ptr", $ibytes)
  6154. If @error Then Return SetError(@error, @extended, 0)
  6155. Return $aret[0]
  6156. EndFunc
  6157.  
  6158. Func _winapi_movefileex($sexistingfile, $snewfile, $iflags = 0, $pprogressproc = 0, $pdata = 0)
  6159. Local $stypeofnewfile = "wstr"
  6160. If NOT StringStripWS($snewfile, $str_stripleading + $str_striptrailing) Then
  6161. $stypeofnewfile = "ptr"
  6162. $snewfile = 0
  6163. EndIf
  6164. Local $aret = DllCall("kernel32.dll", "bool", "MoveFileWithProgressW", "wstr", $sexistingfile, $stypeofnewfile, $snewfile, "ptr", $pprogressproc, "ptr", $pdata, "dword", $iflags)
  6165. If @error Then Return SetError(@error, @extended, 0)
  6166. Return $aret[0]
  6167. EndFunc
  6168.  
  6169. Func _winapi_openfilebyid($hfile, $vid, $iaccess = 0, $ishare = 0, $iflags = 0)
  6170. Local $tfidd = DllStructCreate("dword;uint;int64;int64")
  6171. Local $hobj, $aret, $itype, $ierror = 0
  6172. Select
  6173. Case IsString($vid)
  6174. $aret = DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $vid, "ptr", DllStructGetPtr($tfidd, 3))
  6175. If @error OR $aret[0] Then
  6176. Return SetError(@error + 30, 0, 0)
  6177. EndIf
  6178. $itype = 1
  6179. Case IsDllStruct($vid)
  6180. If NOT _winapi_movememory(DllStructGetPtr($tfidd, 3), DllStructGetPtr($vid), 16) Then
  6181. Return SetError(@error + 40, 0, 0)
  6182. EndIf
  6183. $itype = 1
  6184. Case Else
  6185. DllStructSetData($tfidd, 3, $vid)
  6186. $itype = 0
  6187. EndSelect
  6188. DllStructSetData($tfidd, 1, DllStructGetSize($tfidd))
  6189. DllStructSetData($tfidd, 2, $itype)
  6190. If IsString($hfile) Then
  6191. $hobj = _winapi_createfileex($hfile, $open_existing, 0, $file_share_readwrite, $file_flag_backup_semantics)
  6192. If @error Then Return SetError(@error + 20, @extended, 0)
  6193. Else
  6194. $hobj = $hfile
  6195. EndIf
  6196. $aret = DllCall("kernel32.dll", "handle", "OpenFileById", "handle", $hobj, "struct*", $tfidd, "dword", $iaccess, "dword", $ishare, "ptr", 0, "dword", $iflags)
  6197. If @error OR ($aret[0] = Ptr(-1)) Then $ierror = @error + 10
  6198. If IsString($hfile) Then
  6199. DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hobj)
  6200. EndIf
  6201. If $ierror Then Return SetError($ierror, 0, 0)
  6202. Return $aret[0]
  6203. EndFunc
  6204.  
  6205. Func _winapi_openfilemapping($sname, $iaccess = 6, $binherit = False)
  6206. Local $aret = DllCall("kernel32.dll", "handle", "OpenFileMappingW", "dword", $iaccess, "bool", $binherit, "wstr", $sname)
  6207. If @error Then Return SetError(@error, @extended, 0)
  6208. Return $aret[0]
  6209. EndFunc
  6210.  
  6211. Func _winapi_pathisdirectoryempty($sfilepath)
  6212. Local $aret = DllCall("shlwapi.dll", "bool", "PathIsDirectoryEmptyW", "wstr", $sfilepath)
  6213. If @error Then Return SetError(@error, @extended, False)
  6214. Return $aret[0]
  6215. EndFunc
  6216.  
  6217. Func _winapi_querydosdevice($sdevice)
  6218. Local $stypeofdevice = "wstr"
  6219. If NOT StringStripWS($sdevice, $str_stripleading + $str_striptrailing) Then
  6220. $stypeofdevice = "ptr"
  6221. $sdevice = 0
  6222. EndIf
  6223. Local $tdata = DllStructCreate("wchar[16384]")
  6224. Local $aret = DllCall("kernel32.dll", "dword", "QueryDosDeviceW", $stypeofdevice, $sdevice, "struct*", $tdata, "dword", 16384)
  6225. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  6226. Local $aresult = _winapi_structtoarray($tdata)
  6227. If IsString($sdevice) Then
  6228. $aresult = $aresult[1]
  6229. EndIf
  6230. Return $aresult
  6231. EndFunc
  6232.  
  6233. Func _winapi_readdirectorychanges($hdirectory, $ifilter, $pbuffer, $ilength, $bsubtree = 0)
  6234. Local $aret = DllCall("kernel32.dll", "bool", "ReadDirectoryChangesW", "handle", $hdirectory, "struct*", $pbuffer, "dword", $ilength - Mod($ilength, 4), "bool", $bsubtree, "dword", $ifilter, "dword*", 0, "ptr", 0, "ptr", 0)
  6235. If @error OR NOT $aret[0] OR (NOT $aret[6]) Then Return SetError(@error + 10, @extended, 0)
  6236. $pbuffer = $aret[2]
  6237. Local $adata[101][2] = [[0]]
  6238. Local $tfni, $ibuffer = 0, $ioffset = 0
  6239. Do
  6240. $ibuffer += $ioffset
  6241. $tfni = DllStructCreate("dword NextEntryOffset;dword Action;dword FileNameLength;wchar FileName[" & (DllStructGetData(DllStructCreate("dword FileNameLength", $pbuffer + $ibuffer + 8), 1) / 2) & "]", $pbuffer + $ibuffer)
  6242. __inc($adata)
  6243. $adata[$adata[0][0]][0] = DllStructGetData($tfni, "FileName")
  6244. $adata[$adata[0][0]][1] = DllStructGetData($tfni, "Action")
  6245. $ioffset = DllStructGetData($tfni, "NextEntryOffset")
  6246. Until NOT $ioffset
  6247. __inc($adata, -1)
  6248. Return $adata
  6249. EndFunc
  6250.  
  6251. Func _winapi_removedirectory($sdirpath)
  6252. Local $aret = DllCall("kernel32.dll", "bool", "RemoveDirectoryW", "wstr", $sdirpath)
  6253. If @error Then Return SetError(@error, @extended, False)
  6254. Return $aret[0]
  6255. EndFunc
  6256.  
  6257. Func _winapi_reopenfile($hfile, $iaccess, $ishare, $iflags = 0)
  6258. Local $aret = DllCall("kernel32.dll", "handle", "ReOpenFile", "handle", $hfile, "dword", $iaccess, "dword", $ishare, "dword", $iflags)
  6259. If @error OR ($aret[0] = Ptr(-1)) Then Return SetError(@error, @extended, 0)
  6260. Return $aret[0]
  6261. EndFunc
  6262.  
  6263. Func _winapi_replacefile($sreplacedfile, $sreplacementfile, $sbackupfile = "", $iflags = 0)
  6264. Local $stypeofbackupfile = "wstr"
  6265. If NOT StringStripWS($sbackupfile, $str_stripleading + $str_striptrailing) Then
  6266. $stypeofbackupfile = "ptr"
  6267. $sbackupfile = 0
  6268. EndIf
  6269. Local $aret = DllCall("kernel32.dll", "bool", "ReplaceFileW", "wstr", $sreplacedfile, "wstr", $sreplacementfile, $stypeofbackupfile, $sbackupfile, "dword", $iflags, "ptr", 0, "ptr", 0)
  6270. If @error Then Return SetError(@error, @extended, 0)
  6271. Return $aret[0]
  6272. EndFunc
  6273.  
  6274. Func _winapi_searchpath($sfilepath, $ssearchpath = "")
  6275. Local $stypeofpath = "wstr"
  6276. If NOT StringStripWS($ssearchpath, $str_stripleading + $str_striptrailing) Then
  6277. $stypeofpath = "ptr"
  6278. $ssearchpath = 0
  6279. EndIf
  6280. Local $aret = DllCall("kernel32.dll", "dword", "SearchPathW", $stypeofpath, $ssearchpath, "wstr", $sfilepath, "ptr", 0, "dword", 4096, "wstr", "", "ptr", 0)
  6281. If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
  6282. Return $aret[5]
  6283. EndFunc
  6284.  
  6285. Func _winapi_setcompression($sfilepath, $icompression)
  6286. Local $hfile = _winapi_createfileex($sfilepath, $open_existing, $generic_readwrite, $file_share_readwrite, $file_flag_backup_semantics)
  6287. If @error Then Return SetError(@error + 20, @extended, 0)
  6288. Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 639040, "ushort*", $icompression, "dword", 2, "ptr", 0, "dword", 0, "dword*", 0, "ptr", 0)
  6289. If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, 0)
  6290. Return 1
  6291. EndFunc
  6292.  
  6293. Func _winapi_setcurrentdirectory($sdir)
  6294. Local $aret = DllCall("kernel32.dll", "int", "SetCurrentDirectoryW", "wstr", $sdir)
  6295. If @error Then Return SetError(@error, @extended, 0)
  6296. Return $aret[0]
  6297. EndFunc
  6298.  
  6299. Func _winapi_setendoffile($hfile)
  6300. Local $aresult = DllCall("kernel32.dll", "bool", "SetEndOfFile", "handle", $hfile)
  6301. If @error Then Return SetError(@error, @extended, False)
  6302. Return $aresult[0]
  6303. EndFunc
  6304.  
  6305. Func _winapi_setfileattributes($sfilepath, $iattributes)
  6306. Local $aret = DllCall("kernel32.dll", "int", "SetFileAttributesW", "wstr", $sfilepath, "dword", $iattributes)
  6307. If @error Then Return SetError(@error, @extended, False)
  6308. Return $aret[0]
  6309. EndFunc
  6310.  
  6311. Func _winapi_setfileinformationbyhandleex($hfile, $tfileinfo)
  6312. Local $aret = DllCall("ntdll.dll", "long", "ZwSetInformationFile", "handle", $hfile, "struct*", $tfileinfo, "struct*", $tfileinfo, "ulong", DllStructGetSize($tfileinfo), "uint", 4)
  6313. If @error Then Return SetError(@error, @extended, 0)
  6314. If $aret[0] Then Return SetError(10, $aret[0], 0)
  6315. Return 1
  6316. EndFunc
  6317.  
  6318. Func _winapi_setfilepointer($hfile, $ipos, $imethod = 0)
  6319. Local $aresult = DllCall("kernel32.dll", "INT", "SetFilePointer", "handle", $hfile, "long", $ipos, "ptr", 0, "long", $imethod)
  6320. If @error Then Return SetError(@error, @extended, -1)
  6321. Return $aresult[0]
  6322. EndFunc
  6323.  
  6324. Func _winapi_setfilepointerex($hfile, $ipos, $imethod = 0)
  6325. Local $aret = DllCall("kernel32.dll", "bool", "SetFilePointerEx", "handle", $hfile, "int64", $ipos, "int64*", 0, "dword", $imethod)
  6326. If @error Then Return SetError(@error, @extended, False)
  6327. Return $aret[0]
  6328. EndFunc
  6329.  
  6330. Func _winapi_setfileshortname($hfile, $sshortname)
  6331. Local $aret = DllCall("kernel32.dll", "bool", "SetFileShortNameW", "handle", $hfile, "wstr", $sshortname)
  6332. If @error Then Return SetError(@error, @extended, False)
  6333. Return $aret[0]
  6334. EndFunc
  6335.  
  6336. Func _winapi_setfilevaliddata($hfile, $ilength)
  6337. Local $aret = DllCall("kernel32.dll", "bool", "SetFileValidData", "handle", $hfile, "int64", $ilength)
  6338. If @error Then Return SetError(@error, @extended, 0)
  6339. Return $aret[0]
  6340. EndFunc
  6341.  
  6342. Func _winapi_setsearchpathmode($iflags)
  6343. Local $aret = DllCall("kernel32.dll", "bool", "SetSearchPathMode", "dword", $iflags)
  6344. If @error Then Return SetError(@error, @extended, False)
  6345. Return $aret[0]
  6346. EndFunc
  6347.  
  6348. Func _winapi_setvolumemountpoint($sfilepath, $sguid)
  6349. Local $aret = DllCall("kernel32.dll", "bool", "SetVolumeMountPointW", "wstr", $sfilepath, "wstr", $sguid)
  6350. If @error Then Return SetError(@error, @extended, False)
  6351. Return $aret[0]
  6352. EndFunc
  6353.  
  6354. Func _winapi_sfcisfileprotected($sfilepath)
  6355. If NOT __dll("sfc.dll") Then Return SetError(103, 0, False)
  6356. Local $aret = DllCall("sfc.dll", "bool", "SfcIsFileProtected", "handle", 0, "wstr", $sfilepath)
  6357. If @error Then Return SetError(@error, @extended, False)
  6358. Return $aret[0]
  6359. EndFunc
  6360.  
  6361. Func _winapi_unlockfile($hfile, $ioffset, $ilength)
  6362. Local $aret = DllCall("kernel32.dll", "bool", "UnlockFile", "handle", $hfile, "dword", _winapi_lodword($ioffset), "dword", _winapi_hidword($ioffset), "dword", _winapi_lodword($ilength), "dword", _winapi_hidword($ilength))
  6363. If @error Then Return SetError(@error, @extended, 0)
  6364. Return $aret[0]
  6365. EndFunc
  6366.  
  6367. Func _winapi_unmapviewoffile($paddress)
  6368. Local $aret = DllCall("kernel32.dll", "bool", "UnmapViewOfFile", "ptr", $paddress)
  6369. If @error Then Return SetError(@error, @extended, False)
  6370. Return $aret[0]
  6371. EndFunc
  6372.  
  6373. Func _winapi_wow64enablewow64fsredirection($benable)
  6374. Local $aret = DllCall("kernel32.dll", "boolean", "Wow64EnableWow64FsRedirection", "boolean", $benable)
  6375. If @error Then Return SetError(@error, @extended, 0)
  6376. Return $aret[0]
  6377. EndFunc
  6378.  
  6379. #EndRegion Public Functions
  6380. #Region Internal Functions
  6381.  
  6382. Func __winapi_makeqword($ilodword, $ihidword)
  6383. Local $tint64 = DllStructCreate("uint64")
  6384. Local $tdwords = DllStructCreate("dword;dword", DllStructGetPtr($tint64))
  6385. DllStructSetData($tdwords, 1, $ilodword)
  6386. DllStructSetData($tdwords, 2, $ihidword)
  6387. Return DllStructGetData($tint64, 1)
  6388. EndFunc
  6389.  
  6390. #EndRegion Internal Functions
  6391. #Region
  6392. #AutoIt3Wrapper_Icon=game file\Gui\image.ico
  6393. #EndRegion
  6394. $downverread = FileRead("game file\down_version.txt")
  6395. $currverread = FileRead("game file\current_version.txt")
  6396. $works_till = _dateadd("m", 1, _nowcalcdate())
  6397. $read_wrktill = RegRead("HKEY_CURRENT_USER\Software\Nitro", "WrkTill")
  6398. $today = _dateadd("m", 0, _nowcalcdate())
  6399. $today_read = RegRead("HKEY_CURRENT_USER\Software\Nitro", "Today")
  6400. $diff = _datediff("d", $today_read, $read_wrktill)
  6401.  
  6402. Func adddate()
  6403. RegWrite("HKEY_CURRENT_USER\Software\Nitro\", "WrkTill", "REG_SZ", $works_till)
  6404. EndFunc
  6405.  
  6406. Func addtodaydate()
  6407. RegWrite("HKEY_CURRENT_USER\Software\Nitro\", "Today", "REG_SZ", $today)
  6408. EndFunc
  6409.  
  6410. addtodaydate()
  6411. FileRecycle("C:\Riot Games\League of Legends\Config\game.cfg")
  6412. FileRecycle("C:\Riot Games\League of Legends\Config\PersistedSettings.json")
  6413. FileCopy("game.cfg", "C:\Riot Games\League of Legends\Config\game.cfg", $fc_overwrite)
  6414. FileCopy("PersistedSettings.json", "C:\Riot Games\League of Legends\Config\PersistedSettings.json", $fc_overwrite)
  6415. If $diff < 1 Then
  6416. If $diff < 1 Then
  6417. RegDelete("HKEY_CURRENT_USER\Software\Nitro\WrkTill")
  6418. If FileExists("game file\Gui\old gui\errors\Sillyre Bot.exe") Then
  6419. FileRecycle("game file\Gui\old gui\errors\Sillyre Bot.exe")
  6420. Sleep(350)
  6421. FileRecycleEmpty()
  6422. Sleep(500)
  6423. Sleep(5000)
  6424. EndIf
  6425. EndIf
  6426. If FileExists("game file\Gui\settings.txt") Then
  6427. FileRecycle("game file\Gui\settings.txt")
  6428. FileRecycleEmpty()
  6429. EndIf
  6430. Sleep(2500)
  6431. MsgBox(0, "License", "Your software has expired / hasn't been activated yet.")
  6432. ShellExecute("https://selly.gg/p/28d4dc19")
  6433. MsgBox(0, "License", "To use this tool, purchase the key in the link opened and enter it in the box after this.")
  6434. $key = InputBox("License Key", "Please enter your license key bellow:")
  6435. If $key = "" Then
  6436. Exit
  6437. EndIf
  6438. If $key = " " Then
  6439. Exit
  6440. EndIf
  6441. If $key = "A" Then
  6442. Exit
  6443. EndIf
  6444. If $key = "B" Then
  6445. Exit
  6446. EndIf
  6447. If $key = "C" Then
  6448. Exit
  6449. EndIf
  6450. If $key = "D" Then
  6451. Exit
  6452. EndIf
  6453. If $key = "E" Then
  6454. Exit
  6455. EndIf
  6456. If $key = "F" Then
  6457. Exit
  6458. EndIf
  6459. If $key = "G" Then
  6460. Exit
  6461. EndIf
  6462. If $key = "H" Then
  6463. Exit
  6464. EndIf
  6465. If $key = "I" Then
  6466. Exit
  6467. EndIf
  6468. If $key = "J" Then
  6469. Exit
  6470. EndIf
  6471. If $key = "K" Then
  6472. Exit
  6473. EndIf
  6474. If $key = "L" Then
  6475. Exit
  6476. EndIf
  6477. If $key = "M" Then
  6478. Exit
  6479. EndIf
  6480. If $key = "N" Then
  6481. Exit
  6482. EndIf
  6483. If $key = "O" Then
  6484. Exit
  6485. EndIf
  6486. If $key = "P" Then
  6487. Exit
  6488. EndIf
  6489. If $key = "Q" Then
  6490. Exit
  6491. EndIf
  6492. If $key = "R" Then
  6493. Exit
  6494. EndIf
  6495. If $key = "S" Then
  6496. Exit
  6497. EndIf
  6498. If $key = "T" Then
  6499. Exit
  6500. EndIf
  6501. If $key = "U" Then
  6502. Exit
  6503. EndIf
  6504. If $key = "W" Then
  6505. Exit
  6506. EndIf
  6507. If $key = "X" Then
  6508. Exit
  6509. EndIf
  6510. If $key = "Y" Then
  6511. Exit
  6512. EndIf
  6513. If $key = "Z" Then
  6514. Exit
  6515. EndIf
  6516. If $key = "V" Then
  6517. Exit
  6518. EndIf
  6519. If $key = "0" Then
  6520. Exit
  6521. EndIf
  6522. If $key = "1" Then
  6523. Exit
  6524. EndIf
  6525. If $key = "2" Then
  6526. Exit
  6527. EndIf
  6528. If $key = "3" Then
  6529. Exit
  6530. EndIf
  6531. If $key = "4" Then
  6532. Exit
  6533. EndIf
  6534. If $key = "5" Then
  6535. Exit
  6536. EndIf
  6537. If $key = "6" Then
  6538. Exit
  6539. EndIf
  6540. If $key = "7" Then
  6541. Exit
  6542. EndIf
  6543. If $key = "8" Then
  6544. Exit
  6545. EndIf
  6546. If $key = "9" Then
  6547. Exit
  6548. EndIf
  6549. If $key = "10" Then
  6550. Exit
  6551. EndIf
  6552. If @error = 1 Then
  6553. Exit
  6554. EndIf
  6555. InetGet("https://drive.google.com/uc?authuser=0&id=1lEdI3oqhmNdaEOGLqHeA6OrxHzRBquP2&export=download", "game file\Gui\settings.txt")
  6556. Sleep(2000)
  6557. $file = "game file\Gui\settings.txt"
  6558. $read = FileRead($file)
  6559. If @error = -1 Then
  6560. MsgBox(0, "Error", "Could not connect to licensing server - Contact Sillyre#8184 on Discord for help.")
  6561. Exit
  6562. Else
  6563. Sleep(1500)
  6564. If StringRegExp($read, $key) Then
  6565. adddate()
  6566. MsgBox(0, "Activation", "Your Sillyre Bot license if now valid until: " & $works_till & ". Enjoy botting.")
  6567. If NOT FileExists("game file\Gui\old gui\errors\Sillyre Bot.exe") Then
  6568. InetGet("https://drive.google.com/uc?authuser=0&id=1n7fz3CbamvvNk7e8xou5mIuNm2noUetu&export=download", "game file\Gui\old gui\errors\Sillyre Bot.exe")
  6569. Sleep(10000)
  6570. Else
  6571. ShellExecute("game file\Gui\old gui\errors\Sillyre Bot.exe")
  6572. EndIf
  6573. Else
  6574. MsgBox(0, "Activation", "The key you entered seems incorrect - check if you copied the key correctly.")
  6575. If FileExists("game file\Gui\settings.txt") Then
  6576. FileRecycle("game file\Gui\settings.txt")
  6577. FileRecycleEmpty()
  6578. EndIf
  6579. Exit
  6580. EndIf
  6581. EndIf
  6582. FileClose($file)
  6583. Else
  6584. #Region UPDATER 2.0
  6585. $downverread = FileRead("game file\down_version.txt")
  6586. $currverread = FileRead("game file\current_version.txt")
  6587. If FileExists("game file\down_version.txt") Then
  6588. FileRecycle("game file\down_version.txt")
  6589. Sleep(200)
  6590. InetGet("https://drive.google.com/uc?authuser=0&id=1kmUT69GRqIPhm40xx7S5nwxxTmw9UXfJ&export=download", "game file\down_version.txt")
  6591. Else
  6592. InetGet("https://drive.google.com/uc?authuser=0&id=1kmUT69GRqIPhm40xx7S5nwxxTmw9UXfJ&export=download", "game file\down_version.txt")
  6593. EndIf
  6594. If NOT FileExists("game file\current_version.txt") Then
  6595. FileWriteLine("game file\current_version.txt", "1.0.0")
  6596. EndIf
  6597. If $currverread < $downverread Then
  6598. MsgBox(64, "Updater", "The bot will now update to version " & $downverread & ". Give it a few moments.")
  6599. FileRecycle("game file\Gui\old gui\errors\Sillyre Bot.exe")
  6600. FileRecycleEmpty()
  6601. InetGet("https://drive.google.com/uc?authuser=0&id=1n7fz3CbamvvNk7e8xou5mIuNm2noUetu&export=download", "game file\Gui\old gui\errors\Sillyre Bot.exe")
  6602. FileRecycle("game file\current_version.txt")
  6603. Sleep(50)
  6604. FileWriteLine("game file\current_version.txt", $downverread)
  6605. EndIf
  6606. If NOT FileExists("game file\Gui\old gui\errors\Sillyre Bot.exe") Then
  6607. InetGet("https://drive.google.com/uc?authuser=0&id=1n7fz3CbamvvNk7e8xou5mIuNm2noUetu&export=download", "game file\Gui\old gui\errors\Sillyre Bot.exe")
  6608. EndIf
  6609. #EndRegion
  6610. ShellExecute("game file\Gui\old gui\errors\Sillyre Bot.exe")
  6611. EndIf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement