Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #RequireAdmin
- Global Const $fc_nooverwrite = 0
- Global Const $fc_overwrite = 1
- Global Const $fc_createpath = 8
- Global Const $ft_modified = 0
- Global Const $ft_created = 1
- Global Const $ft_accessed = 2
- Global Const $ft_array = 0
- Global Const $ft_string = 1
- Global Const $fsf_createbutton = 1
- Global Const $fsf_newdialog = 2
- Global Const $fsf_editcontrol = 4
- Global Const $ft_nonrecursive = 0
- Global Const $ft_recursive = 1
- Global Const $fo_read = 0
- Global Const $fo_append = 1
- Global Const $fo_overwrite = 2
- Global Const $fo_createpath = 8
- Global Const $fo_binary = 16
- Global Const $fo_unicode = 32
- Global Const $fo_utf16_le = 32
- Global Const $fo_utf16_be = 64
- Global Const $fo_utf8 = 128
- Global Const $fo_utf8_nobom = 256
- Global Const $fo_ansi = 512
- Global Const $fo_utf16_le_nobom = 1024
- Global Const $fo_utf16_be_nobom = 2048
- Global Const $fo_utf8_full = 16384
- Global Const $fo_fullfile_detect = 16384
- Global Const $eof = -1
- Global Const $fd_filemustexist = 1
- Global Const $fd_pathmustexist = 2
- Global Const $fd_multiselect = 4
- Global Const $fd_promptcreatenew = 8
- Global Const $fd_promptoverwrite = 16
- Global Const $create_new = 1
- Global Const $create_always = 2
- Global Const $open_existing = 3
- Global Const $open_always = 4
- Global Const $truncate_existing = 5
- Global Const $invalid_set_file_pointer = -1
- Global Const $file_begin = 0
- Global Const $file_current = 1
- Global Const $file_end = 2
- Global Const $file_attribute_readonly = 1
- Global Const $file_attribute_hidden = 2
- Global Const $file_attribute_system = 4
- Global Const $file_attribute_directory = 16
- Global Const $file_attribute_archive = 32
- Global Const $file_attribute_device = 64
- Global Const $file_attribute_normal = 128
- Global Const $file_attribute_temporary = 256
- Global Const $file_attribute_sparse_file = 512
- Global Const $file_attribute_reparse_point = 1024
- Global Const $file_attribute_compressed = 2048
- Global Const $file_attribute_offline = 4096
- Global Const $file_attribute_not_content_indexed = 8192
- Global Const $file_attribute_encrypted = 16384
- Global Const $file_share_read = 1
- Global Const $file_share_write = 2
- Global Const $file_share_delete = 4
- Global Const $file_share_readwrite = BitOR($file_share_read, $file_share_write)
- Global Const $file_share_any = BitOR($file_share_read, $file_share_write, $file_share_delete)
- Global Const $generic_all = 268435456
- Global Const $generic_execute = 536870912
- Global Const $generic_write = 1073741824
- Global Const $generic_read = -2147483648
- Global Const $generic_readwrite = BitOR($generic_read, $generic_write)
- Global Const $file_encoding_utf16le = 32
- Global Const $fe_entire_utf8 = 1
- Global Const $fe_partialfirst_utf8 = 2
- Global Const $fn_fullpath = 0
- Global Const $fn_relativepath = 1
- Global Const $fv_comments = "Comments"
- Global Const $fv_companyname = "CompanyName"
- Global Const $fv_filedescription = "FileDescription"
- Global Const $fv_fileversion = "FileVersion"
- Global Const $fv_internalname = "InternalName"
- Global Const $fv_legalcopyright = "LegalCopyright"
- Global Const $fv_legaltrademarks = "LegalTrademarks"
- Global Const $fv_originalfilename = "OriginalFilename"
- Global Const $fv_productname = "ProductName"
- Global Const $fv_productversion = "ProductVersion"
- Global Const $fv_privatebuild = "PrivateBuild"
- Global Const $fv_specialbuild = "SpecialBuild"
- Global Const $frta_nocount = 0
- Global Const $frta_count = 1
- Global Const $frta_intarrays = 2
- Global Const $frta_entiresplit = 4
- Global Const $flta_filesfolders = 0
- Global Const $flta_files = 1
- Global Const $flta_folders = 2
- Global Const $fltar_filesfolders = 0
- Global Const $fltar_files = 1
- Global Const $fltar_folders = 2
- Global Const $fltar_nohidden = 4
- Global Const $fltar_nosystem = 8
- Global Const $fltar_nolink = 16
- Global Const $fltar_norecur = 0
- Global Const $fltar_recur = 1
- Global Const $fltar_nosort = 0
- Global Const $fltar_sort = 1
- Global Const $fltar_fastsort = 2
- Global Const $fltar_nopath = 0
- Global Const $fltar_relpath = 1
- Global Const $fltar_fullpath = 2
- Global Const $path_original = 0
- Global Const $path_drive = 1
- Global Const $path_directory = 2
- Global Const $path_filename = 3
- Global Const $path_extension = 4
- Global Const $mb_ok = 0
- Global Const $mb_okcancel = 1
- Global Const $mb_abortretryignore = 2
- Global Const $mb_yesnocancel = 3
- Global Const $mb_yesno = 4
- Global Const $mb_retrycancel = 5
- Global Const $mb_canceltrycontinue = 6
- Global Const $mb_help = 16384
- Global Const $mb_iconstop = 16
- Global Const $mb_iconerror = 16
- Global Const $mb_iconhand = 16
- Global Const $mb_iconquestion = 32
- Global Const $mb_iconexclamation = 48
- Global Const $mb_iconwarning = 48
- Global Const $mb_iconinformation = 64
- Global Const $mb_iconasterisk = 64
- Global Const $mb_usericon = 128
- Global Const $mb_defbutton1 = 0
- Global Const $mb_defbutton2 = 256
- Global Const $mb_defbutton3 = 512
- Global Const $mb_defbutton4 = 768
- Global Const $mb_applmodal = 0
- Global Const $mb_systemmodal = 4096
- Global Const $mb_taskmodal = 8192
- Global Const $mb_default_desktop_only = 131072
- Global Const $mb_right = 524288
- Global Const $mb_rtlreading = 1048576
- Global Const $mb_setforeground = 65536
- Global Const $mb_topmost = 262144
- Global Const $mb_service_notification = 2097152
- Global Const $mb_rightjustified = $mb_right
- Global Const $idtimeout = -1
- Global Const $idok = 1
- Global Const $idcancel = 2
- Global Const $idabort = 3
- Global Const $idretry = 4
- Global Const $idignore = 5
- Global Const $idyes = 6
- Global Const $idno = 7
- Global Const $idclose = 8
- Global Const $idhelp = 9
- Global Const $idtryagain = 10
- Global Const $idcontinue = 11
- Global Const $str_nocasesense = 0
- Global Const $str_casesense = 1
- Global Const $str_nocasesensebasic = 2
- Global Const $str_stripleading = 1
- Global Const $str_striptrailing = 2
- Global Const $str_stripspaces = 4
- Global Const $str_stripall = 8
- Global Const $str_chrsplit = 0
- Global Const $str_entiresplit = 1
- Global Const $str_nocount = 2
- Global Const $str_regexpmatch = 0
- Global Const $str_regexparraymatch = 1
- Global Const $str_regexparrayfullmatch = 2
- Global Const $str_regexparrayglobalmatch = 3
- Global Const $str_regexparrayglobalfullmatch = 4
- Global Const $str_endisstart = 0
- Global Const $str_endnotstart = 1
- Global Const $sb_ansi = 1
- Global Const $sb_utf16le = 2
- Global Const $sb_utf16be = 3
- Global Const $sb_utf8 = 4
- Global Const $se_utf16 = 0
- Global Const $se_ansi = 1
- Global Const $se_utf8 = 2
- Global Const $str_utf16 = 0
- Global Const $str_ucs2 = 1
- #Region Global Variables and Constants
- Global Const $format_message_allocate_buffer = 256
- Global Const $format_message_ignore_inserts = 512
- Global Const $format_message_from_string = 1024
- Global Const $format_message_from_hmodule = 2048
- Global Const $format_message_from_system = 4096
- Global Const $format_message_argument_array = 8192
- #EndRegion Global Variables and Constants
- Func _winapi_beep($ifreq = 500, $iduration = 1000)
- Local $aresult = DllCall("kernel32.dll", "bool", "Beep", "dword", $ifreq, "dword", $iduration)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_formatmessage($iflags, $psource, $imessageid, $ilanguageid, ByRef $pbuffer, $isize, $varguments)
- Local $sbuffertype = "struct*"
- If IsString($pbuffer) Then $sbuffertype = "wstr"
- Local $aresult = DllCall("kernel32.dll", "dword", "FormatMessageW", "dword", $iflags, "struct*", $psource, "dword", $imessageid, "dword", $ilanguageid, $sbuffertype, $pbuffer, "dword", $isize, "ptr", $varguments)
- If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
- If $sbuffertype = "wstr" Then $pbuffer = $aresult[5]
- Return $aresult[0]
- EndFunc
- Func _winapi_geterrormessage($icode, $ilanguage = 0, Const $_icurrenterror = @error, Const $_icurrentextended = @extended)
- Local $aret = DllCall("kernel32.dll", "dword", "FormatMessageW", "dword", 4096, "ptr", 0, "dword", $icode, "dword", $ilanguage, "wstr", "", "dword", 4096, "ptr", 0)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return SetError($_icurrenterror, $_icurrentextended, StringRegExpReplace($aret[5], "[" & @LF & "," & @CR & "]*\Z", ""))
- EndFunc
- Func _winapi_getlasterror(Const $_icurrenterror = @error, Const $_icurrentextended = @extended)
- Local $aresult = DllCall("kernel32.dll", "dword", "GetLastError")
- Return SetError($_icurrenterror, $_icurrentextended, $aresult[0])
- EndFunc
- Func _winapi_getlasterrormessage(Const $_icurrenterror = @error, Const $_icurrentextended = @extended)
- Local $ilasterror = _winapi_getlasterror()
- Local $tbufferptr = DllStructCreate("ptr")
- Local $ncount = _winapi_formatmessage(BitOR($format_message_allocate_buffer, $format_message_from_system), 0, $ilasterror, 0, $tbufferptr, 0, 0)
- If @error Then Return SetError(-@error, @extended, "")
- Local $stext = ""
- Local $pbuffer = DllStructGetData($tbufferptr, 1)
- If $pbuffer Then
- If $ncount > 0 Then
- Local $tbuffer = DllStructCreate("wchar[" & ($ncount + 1) & "]", $pbuffer)
- $stext = DllStructGetData($tbuffer, 1)
- If StringRight($stext, 2) = @CRLF Then $stext = StringTrimRight($stext, 2)
- EndIf
- DllCall("kernel32.dll", "handle", "LocalFree", "handle", $pbuffer)
- EndIf
- Return SetError($_icurrenterror, $_icurrentextended, $stext)
- EndFunc
- Func _winapi_messagebeep($itype = 1)
- Local $isound
- Switch $itype
- Case 1
- $isound = 0
- Case 2
- $isound = 16
- Case 3
- $isound = 32
- Case 4
- $isound = 48
- Case 5
- $isound = 64
- Case Else
- $isound = -1
- EndSwitch
- Local $aresult = DllCall("user32.dll", "bool", "MessageBeep", "uint", $isound)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_msgbox($iflags, $stitle, $stext)
- BlockInput(0)
- MsgBox($iflags, $stitle, $stext & " ")
- EndFunc
- Func _winapi_setlasterror($ierrorcode, Const $_icurrenterror = @error, Const $_icurrentextended = @extended)
- DllCall("kernel32.dll", "none", "SetLastError", "dword", $ierrorcode)
- Return SetError($_icurrenterror, $_icurrentextended, NULL )
- EndFunc
- Func _winapi_showerror($stext, $bexit = True)
- BlockInput(0)
- MsgBox($mb_systemmodal, "Error", $stext & " ")
- If $bexit Then Exit
- EndFunc
- Func _winapi_showlasterror($stext = "", $babort = False, $ilanguage = 0, Const $_icurrenterror = @error, Const $_icurrentextended = @extended)
- Local $serror
- Local $ilasterror = _winapi_getlasterror()
- While 1
- $serror = _winapi_geterrormessage($ilasterror, $ilanguage)
- If @error AND $ilanguage Then
- $ilanguage = 0
- Else
- ExitLoop
- EndIf
- WEnd
- If StringStripWS($stext, $str_stripleading + $str_striptrailing) Then
- $stext &= @CRLF & @CRLF
- Else
- $stext = ""
- EndIf
- _winapi_msgbox(BitOR(262144, BitShift(16, -2 * (NOT $ilasterror))), $ilasterror, $stext & $serror)
- If $ilasterror Then
- _winapi_setlasterror($ilasterror)
- If $babort Then
- Exit $ilasterror
- EndIf
- EndIf
- Return SetError($_icurrenterror, $_icurrentextended, 1)
- EndFunc
- Func _winapi_showmsg($stext)
- _winapi_msgbox($mb_systemmodal, "Information", $stext)
- EndFunc
- Func __comerrorformating(ByRef $ocomerror, $sprefix = @TAB)
- Local Const $str_striptrailing = 2
- Local $serror = "COM Error encountered in " & @ScriptName & " (" & $ocomerror.scriptline & ") :" & @CRLF & $sprefix & "Number " & @TAB & "= 0x" & Hex($ocomerror.number, 8) & " (" & $ocomerror.number & ")" & @CRLF & $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)
- Return $serror
- EndFunc
- Global Const $prov_rsa_full = 1
- Global Const $prov_rsa_aes = 24
- Global Const $crypt_verifycontext = -268435456
- Global Const $hp_hashsize = 4
- Global Const $hp_hashval = 2
- Global Const $crypt_exportable = 1
- Global Const $crypt_userdata = 1
- Global Const $kp_algid = 7
- Global Const $calg_md2 = 32769
- Global Const $calg_md4 = 32770
- Global Const $calg_md5 = 32771
- Global Const $calg_sha1 = 32772
- Global Const $calg_sha_256 = 32780
- Global Const $calg_sha_384 = 32781
- Global Const $calg_sha_512 = 32782
- Global Const $calg_3des = 26115
- Global Const $calg_aes_128 = 26126
- Global Const $calg_aes_192 = 26127
- Global Const $calg_aes_256 = 26128
- Global Const $calg_des = 26113
- Global Const $calg_rc2 = 26114
- Global Const $calg_rc4 = 26625
- Global Const $calg_userkey = 0
- Global $__g_acryptinternaldata[3]
- Func _crypt_startup()
- If __crypt_refcount() = 0 Then
- Local $hadvapi32 = DllOpen("Advapi32.dll")
- If $hadvapi32 = -1 Then Return SetError(1001, 0, False)
- __crypt_dllhandleset($hadvapi32)
- Local $iproviderid = $prov_rsa_aes
- Local $aret = DllCall(__crypt_dllhandle(), "bool", "CryptAcquireContext", "handle*", 0, "ptr", 0, "ptr", 0, "dword", $iproviderid, "dword", $crypt_verifycontext)
- If @error OR NOT $aret[0] Then
- Local $ierror = @error + 1002, $iextended = @extended
- If NOT $aret[0] Then $iextended = _winapi_getlasterror()
- DllClose(__crypt_dllhandle())
- Return SetError($ierror, $iextended, False)
- Else
- __crypt_contextset($aret[1])
- EndIf
- EndIf
- __crypt_refcountinc()
- Return True
- EndFunc
- Func _crypt_shutdown()
- __crypt_refcountdec()
- If __crypt_refcount() = 0 Then
- DllCall(__crypt_dllhandle(), "bool", "CryptReleaseContext", "handle", __crypt_context(), "dword", 0)
- DllClose(__crypt_dllhandle())
- EndIf
- EndFunc
- Func _crypt_derivekey($vpassword, $ialgid, $ihashpasswordid = $calg_md5)
- Local $aret = 0, $tbuff = 0, $hcrypthash = 0, $ierror = 0, $iextended = 0, $vreturn = 0
- _crypt_startup()
- If @error Then Return SetError(@error, @extended, -1)
- Do
- $aret = DllCall(__crypt_dllhandle(), "bool", "CryptCreateHash", "handle", __crypt_context(), "uint", $ihashpasswordid, "ptr", 0, "dword", 0, "handle*", 0)
- If @error OR NOT $aret[0] Then
- $ierror = @error + 10
- $iextended = @extended
- If NOT $aret[0] Then $iextended = _winapi_getlasterror()
- $vreturn = -1
- ExitLoop
- EndIf
- $hcrypthash = $aret[5]
- $tbuff = DllStructCreate("byte[" & BinaryLen($vpassword) & "]")
- DllStructSetData($tbuff, 1, $vpassword)
- $aret = DllCall(__crypt_dllhandle(), "bool", "CryptHashData", "handle", $hcrypthash, "struct*", $tbuff, "dword", DllStructGetSize($tbuff), "dword", $crypt_userdata)
- If @error OR NOT $aret[0] Then
- $ierror = @error + 20
- $iextended = @extended
- If NOT $aret[0] Then $iextended = _winapi_getlasterror()
- $vreturn = -1
- ExitLoop
- EndIf
- $aret = DllCall(__crypt_dllhandle(), "bool", "CryptDeriveKey", "handle", __crypt_context(), "uint", $ialgid, "handle", $hcrypthash, "dword", $crypt_exportable, "handle*", 0)
- If @error OR NOT $aret[0] Then
- $ierror = @error + 30
- $iextended = @extended
- If NOT $aret[0] Then $iextended = _winapi_getlasterror()
- $vreturn = -1
- ExitLoop
- EndIf
- $vreturn = $aret[5]
- Until True
- If $hcrypthash <> 0 Then DllCall(__crypt_dllhandle(), "bool", "CryptDestroyHash", "handle", $hcrypthash)
- Return SetError($ierror, $iextended, $vreturn)
- EndFunc
- Func _crypt_destroykey($hcryptkey)
- Local $aret = DllCall(__crypt_dllhandle(), "bool", "CryptDestroyKey", "handle", $hcryptkey)
- Local $ierror = @error, $iextended = @extended
- If NOT $aret[0] Then $iextended = _winapi_getlasterror()
- _crypt_shutdown()
- If $ierror OR NOT $aret[0] Then
- Return SetError($ierror + 10, $iextended, False)
- Else
- Return True
- EndIf
- EndFunc
- Func _crypt_encryptdata($vdata, $vcryptkey, $ialgid, $bfinal = True)
- Switch $ialgid
- Case $calg_userkey
- Local $icalgused = __crypt_getcalgfromcryptkey($vcryptkey)
- If @error Then Return SetError(@error, @extended, -1)
- If $icalgused = $calg_rc4 Then ContinueCase
- Case $calg_rc4
- If BinaryLen($vdata) = 0 Then Return SetError(0, 0, Binary(""))
- EndSwitch
- Local $ireqbuffsize = 0, $aret = 0, $tbuff = 0, $ierror = 0, $iextended = 0, $vreturn = 0
- _crypt_startup()
- If @error Then Return SetError(@error, @extended, -1)
- Do
- If $ialgid <> $calg_userkey Then
- $vcryptkey = _crypt_derivekey($vcryptkey, $ialgid)
- If @error Then
- $ierror = @error
- $iextended = @extended
- $vreturn = -1
- ExitLoop
- EndIf
- EndIf
- $aret = DllCall(__crypt_dllhandle(), "bool", "CryptEncrypt", "handle", $vcryptkey, "handle", 0, "bool", $bfinal, "dword", 0, "ptr", 0, "dword*", BinaryLen($vdata), "dword", 0)
- If @error OR NOT $aret[0] Then
- $ierror = @error + 50
- $iextended = @extended
- If NOT $aret[0] Then $iextended = _winapi_getlasterror()
- $vreturn = -1
- ExitLoop
- EndIf
- $ireqbuffsize = $aret[6]
- $tbuff = DllStructCreate("byte[" & $ireqbuffsize + 1 & "]")
- DllStructSetData($tbuff, 1, $vdata)
- $aret = DllCall(__crypt_dllhandle(), "bool", "CryptEncrypt", "handle", $vcryptkey, "handle", 0, "bool", $bfinal, "dword", 0, "struct*", $tbuff, "dword*", BinaryLen($vdata), "dword", $ireqbuffsize)
- If @error OR NOT $aret[0] Then
- $ierror = @error + 60
- $iextended = @extended
- If NOT $aret[0] Then $iextended = _winapi_getlasterror()
- $vreturn = -1
- ExitLoop
- EndIf
- $vreturn = BinaryMid(DllStructGetData($tbuff, 1), 1, $ireqbuffsize)
- Until True
- If $ialgid <> $calg_userkey Then _crypt_destroykey($vcryptkey)
- _crypt_shutdown()
- Return SetError($ierror, $iextended, $vreturn)
- EndFunc
- Func _crypt_decryptdata($vdata, $vcryptkey, $ialgid, $bfinal = True)
- Switch $ialgid
- Case $calg_userkey
- Local $icalgused = __crypt_getcalgfromcryptkey($vcryptkey)
- If @error Then Return SetError(@error, @extended, -1)
- If $icalgused = $calg_rc4 Then ContinueCase
- Case $calg_rc4
- If BinaryLen($vdata) = 0 Then Return SetError(0, 0, Binary(""))
- EndSwitch
- Local $aret = 0, $tbuff = 0, $ttempstruct = 0, $ierror = 0, $iextended = 0, $iplaintextsize = 0, $vreturn = 0
- _crypt_startup()
- If @error Then Return SetError(@error, @extended, -1)
- Do
- If $ialgid <> $calg_userkey Then
- $vcryptkey = _crypt_derivekey($vcryptkey, $ialgid)
- If @error Then
- $ierror = @error
- $iextended = @extended
- $vreturn = -1
- ExitLoop
- EndIf
- EndIf
- $tbuff = DllStructCreate("byte[" & BinaryLen($vdata) + 1000 & "]")
- If BinaryLen($vdata) > 0 Then DllStructSetData($tbuff, 1, $vdata)
- $aret = DllCall(__crypt_dllhandle(), "bool", "CryptDecrypt", "handle", $vcryptkey, "handle", 0, "bool", $bfinal, "dword", 0, "struct*", $tbuff, "dword*", BinaryLen($vdata))
- If @error OR NOT $aret[0] Then
- $ierror = @error + 70
- $iextended = @extended
- If NOT $aret[0] Then $iextended = _winapi_getlasterror()
- $vreturn = -1
- ExitLoop
- EndIf
- $iplaintextsize = $aret[6]
- $ttempstruct = DllStructCreate("byte[" & $iplaintextsize + 1 & "]", DllStructGetPtr($tbuff))
- $vreturn = BinaryMid(DllStructGetData($ttempstruct, 1), 1, $iplaintextsize)
- Until True
- If $ialgid <> $calg_userkey Then _crypt_destroykey($vcryptkey)
- _crypt_shutdown()
- Return SetError($ierror, $iextended, $vreturn)
- EndFunc
- Func _crypt_hashdata($vdata, $ialgid, $bfinal = True, $hcrypthash = 0)
- Local $aret = 0, $tbuff = 0, $ierror = 0, $iextended = 0, $ihashsize = 0, $vreturn = 0
- _crypt_startup()
- If @error Then Return SetError(@error, @extended, -1)
- Do
- If $hcrypthash = 0 Then
- $aret = DllCall(__crypt_dllhandle(), "bool", "CryptCreateHash", "handle", __crypt_context(), "uint", $ialgid, "ptr", 0, "dword", 0, "handle*", 0)
- If @error OR NOT $aret[0] Then
- $ierror = @error + 10
- $iextended = @extended
- If NOT $aret[0] Then $iextended = _winapi_getlasterror()
- $vreturn = -1
- ExitLoop
- EndIf
- $hcrypthash = $aret[5]
- EndIf
- $tbuff = DllStructCreate("byte[" & BinaryLen($vdata) & "]")
- DllStructSetData($tbuff, 1, $vdata)
- $aret = DllCall(__crypt_dllhandle(), "bool", "CryptHashData", "handle", $hcrypthash, "struct*", $tbuff, "dword", DllStructGetSize($tbuff), "dword", $crypt_userdata)
- If @error OR NOT $aret[0] Then
- $ierror = @error + 20
- $iextended = @extended
- If NOT $aret[0] Then $iextended = _winapi_getlasterror()
- $vreturn = -1
- ExitLoop
- EndIf
- If $bfinal Then
- $aret = DllCall(__crypt_dllhandle(), "bool", "CryptGetHashParam", "handle", $hcrypthash, "dword", $hp_hashsize, "dword*", 0, "dword*", 4, "dword", 0)
- If @error OR NOT $aret[0] Then
- $ierror = @error + 30
- $iextended = @extended
- If NOT $aret[0] Then $iextended = _winapi_getlasterror()
- $vreturn = -1
- ExitLoop
- EndIf
- $ihashsize = $aret[3]
- $tbuff = DllStructCreate("byte[" & $ihashsize & "]")
- $aret = DllCall(__crypt_dllhandle(), "bool", "CryptGetHashParam", "handle", $hcrypthash, "dword", $hp_hashval, "struct*", $tbuff, "dword*", $ihashsize, "dword", 0)
- If @error OR NOT $aret[0] Then
- $ierror = @error + 40
- $iextended = @extended
- If NOT $aret[0] Then $iextended = _winapi_getlasterror()
- $vreturn = -1
- ExitLoop
- EndIf
- $vreturn = DllStructGetData($tbuff, 1)
- Else
- $vreturn = $hcrypthash
- EndIf
- Until True
- If $hcrypthash <> 0 AND $bfinal Then DllCall(__crypt_dllhandle(), "bool", "CryptDestroyHash", "handle", $hcrypthash)
- _crypt_shutdown()
- Return SetError($ierror, $iextended, $vreturn)
- EndFunc
- Func _crypt_hashfile($sfilepath, $ialgid)
- Local $dtempdata = 0, $hfile = 0, $hhashobject = 0, $ierror = 0, $iextended = 0, $vreturn = 0
- _crypt_startup()
- If @error Then Return SetError(@error, @extended, -1)
- Do
- $hfile = FileOpen($sfilepath, $fo_binary)
- If $hfile = -1 Then
- $ierror = 1
- $iextended = _winapi_getlasterror()
- $vreturn = -1
- ExitLoop
- EndIf
- Do
- $dtempdata = FileRead($hfile, 512 * 1024)
- If @error Then
- $vreturn = _crypt_hashdata($dtempdata, $ialgid, True, $hhashobject)
- If @error Then
- $ierror = @error
- $iextended = @extended
- $vreturn = -1
- ExitLoop 2
- EndIf
- ExitLoop 2
- Else
- $hhashobject = _crypt_hashdata($dtempdata, $ialgid, False, $hhashobject)
- If @error Then
- $ierror = @error + 100
- $iextended = @extended
- $vreturn = -1
- ExitLoop 2
- EndIf
- EndIf
- Until False
- Until True
- _crypt_shutdown()
- If $hfile <> -1 Then FileClose($hfile)
- Return SetError($ierror, $iextended, $vreturn)
- EndFunc
- Func _crypt_encryptfile($ssourcefile, $sdestinationfile, $vcryptkey, $ialgid)
- Local $dtempdata = 0, $hinfile = 0, $houtfile = 0, $ierror = 0, $iextended = 0, $ifilesize = FileGetSize($ssourcefile), $iread = 0, $breturn = True
- _crypt_startup()
- If @error Then Return SetError(@error, @extended, -1)
- Do
- If $ialgid <> $calg_userkey Then
- $vcryptkey = _crypt_derivekey($vcryptkey, $ialgid)
- If @error Then
- $ierror = @error
- $iextended = @extended
- $breturn = False
- ExitLoop
- EndIf
- EndIf
- $hinfile = FileOpen($ssourcefile, $fo_binary)
- If $hinfile = -1 Then
- $ierror = 2
- $iextended = _winapi_getlasterror()
- $breturn = False
- ExitLoop
- EndIf
- $houtfile = FileOpen($sdestinationfile, $fo_overwrite + $fo_createpath + $fo_binary)
- If $houtfile = -1 Then
- $ierror = 3
- $iextended = _winapi_getlasterror()
- $breturn = False
- ExitLoop
- EndIf
- Do
- $dtempdata = FileRead($hinfile, 1024 * 1024)
- $iread += BinaryLen($dtempdata)
- If $iread = $ifilesize Then
- $dtempdata = _crypt_encryptdata($dtempdata, $vcryptkey, $calg_userkey, True)
- If @error Then
- $ierror = @error + 400
- $iextended = @extended
- $breturn = False
- EndIf
- FileWrite($houtfile, $dtempdata)
- ExitLoop 2
- Else
- $dtempdata = _crypt_encryptdata($dtempdata, $vcryptkey, $calg_userkey, False)
- If @error Then
- $ierror = @error + 500
- $iextended = @extended
- $breturn = False
- ExitLoop 2
- EndIf
- FileWrite($houtfile, $dtempdata)
- EndIf
- Until False
- Until True
- If $ialgid <> $calg_userkey Then _crypt_destroykey($vcryptkey)
- _crypt_shutdown()
- If $hinfile <> -1 Then FileClose($hinfile)
- If $houtfile <> -1 Then FileClose($houtfile)
- Return SetError($ierror, $iextended, $breturn)
- EndFunc
- Func _crypt_decryptfile($ssourcefile, $sdestinationfile, $vcryptkey, $ialgid)
- Local $dtempdata = 0, $hinfile = 0, $houtfile = 0, $ierror = 0, $iextended = 0, $ifilesize = FileGetSize($ssourcefile), $iread = 0, $breturn = True
- _crypt_startup()
- If @error Then Return SetError(@error, @extended, -1)
- Do
- If $ialgid <> $calg_userkey Then
- $vcryptkey = _crypt_derivekey($vcryptkey, $ialgid)
- If @error Then
- $ierror = @error
- $iextended = @extended
- $breturn = False
- ExitLoop
- EndIf
- EndIf
- $hinfile = FileOpen($ssourcefile, $fo_binary)
- If $hinfile = -1 Then
- $ierror = 2
- $iextended = _winapi_getlasterror()
- $breturn = False
- ExitLoop
- EndIf
- $houtfile = FileOpen($sdestinationfile, $fo_overwrite + $fo_createpath + $fo_binary)
- If $houtfile = -1 Then
- $ierror = 3
- $iextended = _winapi_getlasterror()
- $breturn = False
- ExitLoop
- EndIf
- Do
- $dtempdata = FileRead($hinfile, 1024 * 1024)
- $iread += BinaryLen($dtempdata)
- If $iread = $ifilesize Then
- $dtempdata = _crypt_decryptdata($dtempdata, $vcryptkey, $calg_userkey, True)
- If @error Then
- $ierror = @error + 400
- $iextended = @extended
- $breturn = False
- EndIf
- FileWrite($houtfile, $dtempdata)
- ExitLoop 2
- Else
- $dtempdata = _crypt_decryptdata($dtempdata, $vcryptkey, $calg_userkey, False)
- If @error Then
- $ierror = @error + 500
- $iextended = @extended
- $breturn = False
- ExitLoop 2
- EndIf
- FileWrite($houtfile, $dtempdata)
- EndIf
- Until False
- Until True
- If $ialgid <> $calg_userkey Then _crypt_destroykey($vcryptkey)
- _crypt_shutdown()
- If $hinfile <> -1 Then FileClose($hinfile)
- If $houtfile <> -1 Then FileClose($houtfile)
- Return SetError($ierror, $iextended, $breturn)
- EndFunc
- Func _crypt_genrandom($pbuffer, $isize)
- _crypt_startup()
- If @error Then Return SetError(@error, @extended, False)
- Local $aret = DllCall(__crypt_dllhandle(), "bool", "CryptGenRandom", "handle", __crypt_context(), "dword", $isize, "struct*", $pbuffer)
- Local $ierror = @error, $iextended = @extended
- If NOT $aret[0] Then $iextended = _winapi_getlasterror()
- _crypt_shutdown()
- If $ierror OR (NOT $aret[0]) Then
- Return SetError($ierror + 10, $iextended, False)
- Else
- Return True
- EndIf
- EndFunc
- Func __crypt_refcount()
- Return $__g_acryptinternaldata[0]
- EndFunc
- Func __crypt_refcountinc()
- $__g_acryptinternaldata[0] += 1
- EndFunc
- Func __crypt_refcountdec()
- If $__g_acryptinternaldata[0] > 0 Then $__g_acryptinternaldata[0] -= 1
- EndFunc
- Func __crypt_dllhandle()
- Return $__g_acryptinternaldata[1]
- EndFunc
- Func __crypt_dllhandleset($hadvapi32)
- $__g_acryptinternaldata[1] = $hadvapi32
- EndFunc
- Func __crypt_context()
- Return $__g_acryptinternaldata[2]
- EndFunc
- Func __crypt_contextset($hcryptcontext)
- $__g_acryptinternaldata[2] = $hcryptcontext
- EndFunc
- Func __crypt_getcalgfromcryptkey($vcryptkey)
- Local $talgid = DllStructCreate("uint")
- Local $aret = DllCall(__crypt_dllhandle(), "bool", "CryptGetKeyParam", "handle", $vcryptkey, "dword", $kp_algid, "struct*", $talgid, "dword*", DllStructGetSize($talgid), "dword", 0)
- Local $ierror = @error, $iextended = @extended
- If NOT $aret[0] Then $iextended = _winapi_getlasterror()
- If $ierror OR NOT $aret[0] Then
- Return SetError($ierror + 80, $iextended, $crypt_userdata)
- Else
- Return DllStructGetData($talgid, 1)
- EndIf
- EndFunc
- Global Const $dts_shortdateformat = 0
- Global Const $dts_updown = 1
- Global Const $dts_shownone = 2
- Global Const $dts_longdateformat = 4
- Global Const $dts_timeformat = 9
- Global Const $dts_rightalign = 32
- Global Const $dts_shortdatecenturyformat = 12
- Global Const $dts_appcanparse = 16
- Global Const $dmw_longname = 0
- Global Const $dmw_shortname = 1
- Global Const $dmw_locale_longname = 2
- Global Const $dmw_locale_shortname = 3
- Global Const $gdt_error = -1
- Global Const $gdt_valid = 0
- Global Const $gdt_none = 1
- Global Const $gdtr_min = 1
- Global Const $gdtr_max = 2
- Global Const $mcht_nowhere = 0
- Global Const $mcht_title = 65536
- Global Const $mcht_calendar = 131072
- Global Const $mcht_todaylink = 196608
- Global Const $mcht_next = 16777216
- Global Const $mcht_prev = 33554432
- Global Const $mcht_titlebk = 65536
- Global Const $mcht_titlemonth = 65537
- Global Const $mcht_titleyear = 65538
- Global Const $mcht_titlebtnnext = 16842755
- Global Const $mcht_titlebtnprev = 33619971
- Global Const $mcht_calendarbk = 131072
- Global Const $mcht_calendardate = 131073
- Global Const $mcht_calendarday = 131074
- Global Const $mcht_calendarweeknum = 131075
- Global Const $mcht_calendardatenext = 16908288
- Global Const $mcht_calendardateprev = 33685504
- Global Const $mcs_daystate = 1
- Global Const $mcs_multiselect = 2
- Global Const $mcs_weeknumbers = 4
- Global Const $mcs_notodaycircle = 8
- Global Const $mcs_notoday = 16
- Global Const $mcs_notrailingdates = 64
- Global Const $mcs_shortdaysofweek = 128
- Global Const $mcs_noselchangeonnav = 256
- Global Const $mcm_first = 4096
- Global Const $mcm_getcalendarborder = ($mcm_first + 31)
- Global Const $mcm_getcalendarcount = ($mcm_first + 23)
- Global Const $mcm_getcalendargridinfo = ($mcm_first + 24)
- Global Const $mcm_getcalid = ($mcm_first + 27)
- Global Const $mcm_getcolor = ($mcm_first + 11)
- Global Const $mcm_getcurrentview = ($mcm_first + 22)
- Global Const $mcm_getcursel = ($mcm_first + 1)
- Global Const $mcm_getfirstdayofweek = ($mcm_first + 16)
- Global Const $mcm_getmaxselcount = ($mcm_first + 3)
- Global Const $mcm_getmaxtodaywidth = ($mcm_first + 21)
- Global Const $mcm_getminreqrect = ($mcm_first + 9)
- Global Const $mcm_getmonthdelta = ($mcm_first + 19)
- Global Const $mcm_getmonthrange = ($mcm_first + 7)
- Global Const $mcm_getrange = ($mcm_first + 17)
- Global Const $mcm_getselrange = ($mcm_first + 5)
- Global Const $mcm_gettoday = ($mcm_first + 13)
- Global Const $mcm_getunicodeformat = 8192 + 6
- Global Const $mcm_hittest = ($mcm_first + 14)
- Global Const $mcm_setcalendarborder = ($mcm_first + 30)
- Global Const $mcm_setcalid = ($mcm_first + 28)
- Global Const $mcm_setcolor = ($mcm_first + 10)
- Global Const $mcm_setcurrentview = ($mcm_first + 32)
- Global Const $mcm_setcursel = ($mcm_first + 2)
- Global Const $mcm_setdaystate = ($mcm_first + 8)
- Global Const $mcm_setfirstdayofweek = ($mcm_first + 15)
- Global Const $mcm_setmaxselcount = ($mcm_first + 4)
- Global Const $mcm_setmonthdelta = ($mcm_first + 20)
- Global Const $mcm_setrange = ($mcm_first + 18)
- Global Const $mcm_setselrange = ($mcm_first + 6)
- Global Const $mcm_settoday = ($mcm_first + 12)
- Global Const $mcm_setunicodeformat = 8192 + 5
- Global Const $mcm_sizerecttomin = ($mcm_first + 29)
- Global Const $mcn_first = -746
- Global Const $mcn_selchange = ($mcn_first - 3)
- Global Const $mcn_getdaystate = ($mcn_first - 1)
- Global Const $mcn_select = ($mcn_first)
- Global Const $mcn_viewchange = ($mcn_first - 4)
- Global Const $mcsc_background = 0
- Global Const $mcsc_monthbk = 4
- Global Const $mcsc_text = 1
- Global Const $mcsc_titlebk = 2
- Global Const $mcsc_titletext = 3
- Global Const $mcsc_trailingtext = 5
- Global Const $dtm_first = 4096
- Global Const $dtm_getsystemtime = $dtm_first + 1
- Global Const $dtm_setsystemtime = $dtm_first + 2
- Global Const $dtm_getrange = $dtm_first + 3
- Global Const $dtm_setrange = $dtm_first + 4
- Global Const $dtm_setformat = $dtm_first + 5
- Global Const $dtm_setmccolor = $dtm_first + 6
- Global Const $dtm_getmccolor = $dtm_first + 7
- Global Const $dtm_getmonthcal = $dtm_first + 8
- Global Const $dtm_setmcfont = $dtm_first + 9
- Global Const $dtm_getmcfont = $dtm_first + 10
- Global Const $dtm_setformatw = $dtm_first + 50
- Global Const $dtn_first = -740
- Global Const $dtn_first2 = -753
- Global Const $dtn_datetimechange = $dtn_first2 - 6
- Global Const $dtn_userstring = $dtn_first2 - 5
- Global Const $dtn_wmkeydown = $dtn_first2 - 4
- Global Const $dtn_format = $dtn_first2 - 3
- Global Const $dtn_formatquery = $dtn_first2 - 2
- Global Const $dtn_dropdown = $dtn_first2 - 1
- Global Const $dtn_closeup = $dtn_first2 + 0
- Global Const $dtn_userstringw = $dtn_first - 5
- Global Const $dtn_wmkeydownw = $dtn_first - 4
- Global Const $dtn_formatw = $dtn_first - 3
- Global Const $dtn_formatqueryw = $dtn_first - 2
- Global Const $gui_ss_default_date = $dts_longdateformat
- Global Const $gui_ss_default_monthcal = 0
- Global Const $gmem_fixed = 0
- Global Const $gmem_moveable = 2
- Global Const $gmem_nocompact = 16
- Global Const $gmem_nodiscard = 32
- Global Const $gmem_zeroinit = 64
- Global Const $gmem_modify = 128
- Global Const $gmem_discardable = 256
- Global Const $gmem_not_banked = 4096
- Global Const $gmem_share = 8192
- Global Const $gmem_ddeshare = 8192
- Global Const $gmem_notify = 16384
- Global Const $gmem_lower = 4096
- Global Const $gmem_valid_flags = 32626
- Global Const $gmem_invalid_handle = 32768
- Global Const $gptr = BitOR($gmem_fixed, $gmem_zeroinit)
- Global Const $ghnd = BitOR($gmem_moveable, $gmem_zeroinit)
- Global Const $mem_commit = 4096
- Global Const $mem_reserve = 8192
- Global Const $mem_top_down = 1048576
- Global Const $mem_shared = 134217728
- Global Const $page_noaccess = 1
- Global Const $page_readonly = 2
- Global Const $page_readwrite = 4
- Global Const $page_execute = 16
- Global Const $page_execute_read = 32
- Global Const $page_execute_readwrite = 64
- Global Const $page_execute_writecopy = 128
- Global Const $page_guard = 256
- Global Const $page_nocache = 512
- Global Const $page_writecombine = 1024
- Global Const $page_writecopy = 8
- Global Const $mem_decommit = 16384
- Global Const $mem_release = 32768
- Global Enum $mem_load, $mem_totalphysram, $mem_availphysram, $mem_totalpagefile, $mem_availpagefile, $mem_totalvirtual, $mem_availvirtual
- Global Const $process_terminate = 1
- Global Const $process_create_thread = 2
- Global Const $process_set_sessionid = 4
- Global Const $process_vm_operation = 8
- Global Const $process_vm_read = 16
- Global Const $process_vm_write = 32
- Global Const $process_dup_handle = 64
- Global Const $process_create_process = 128
- Global Const $process_set_quota = 256
- Global Const $process_set_information = 512
- Global Const $process_query_information = 1024
- Global Const $process_query_limited_information = 4096
- Global Const $process_suspend_resume = 2048
- Global Const $process_all_access = 2035711
- Global Const $se_assignprimarytoken_name = "SeAssignPrimaryTokenPrivilege"
- Global Const $se_audit_name = "SeAuditPrivilege"
- Global Const $se_backup_name = "SeBackupPrivilege"
- Global Const $se_change_notify_name = "SeChangeNotifyPrivilege"
- Global Const $se_create_global_name = "SeCreateGlobalPrivilege"
- Global Const $se_create_pagefile_name = "SeCreatePagefilePrivilege"
- Global Const $se_create_permanent_name = "SeCreatePermanentPrivilege"
- Global Const $se_create_symbolic_link_name = "SeCreateSymbolicLinkPrivilege"
- Global Const $se_create_token_name = "SeCreateTokenPrivilege"
- Global Const $se_debug_name = "SeDebugPrivilege"
- Global Const $se_enable_delegation_name = "SeEnableDelegationPrivilege"
- Global Const $se_impersonate_name = "SeImpersonatePrivilege"
- Global Const $se_inc_base_priority_name = "SeIncreaseBasePriorityPrivilege"
- Global Const $se_inc_working_set_name = "SeIncreaseWorkingSetPrivilege"
- Global Const $se_increase_quota_name = "SeIncreaseQuotaPrivilege"
- Global Const $se_load_driver_name = "SeLoadDriverPrivilege"
- Global Const $se_lock_memory_name = "SeLockMemoryPrivilege"
- Global Const $se_machine_account_name = "SeMachineAccountPrivilege"
- Global Const $se_manage_volume_name = "SeManageVolumePrivilege"
- Global Const $se_prof_single_process_name = "SeProfileSingleProcessPrivilege"
- Global Const $se_relabel_name = "SeRelabelPrivilege"
- Global Const $se_remote_shutdown_name = "SeRemoteShutdownPrivilege"
- Global Const $se_restore_name = "SeRestorePrivilege"
- Global Const $se_security_name = "SeSecurityPrivilege"
- Global Const $se_shutdown_name = "SeShutdownPrivilege"
- Global Const $se_sync_agent_name = "SeSyncAgentPrivilege"
- Global Const $se_system_environment_name = "SeSystemEnvironmentPrivilege"
- Global Const $se_system_profile_name = "SeSystemProfilePrivilege"
- Global Const $se_systemtime_name = "SeSystemtimePrivilege"
- Global Const $se_take_ownership_name = "SeTakeOwnershipPrivilege"
- Global Const $se_tcb_name = "SeTcbPrivilege"
- Global Const $se_time_zone_name = "SeTimeZonePrivilege"
- Global Const $se_trusted_credman_access_name = "SeTrustedCredManAccessPrivilege"
- Global Const $se_unsolicited_input_name = "SeUnsolicitedInputPrivilege"
- Global Const $se_undock_name = "SeUndockPrivilege"
- Global Const $se_privilege_enabled_by_default = 1
- Global Const $se_privilege_enabled = 2
- Global Const $se_privilege_removed = 4
- Global Const $se_privilege_used_for_access = -2147483648
- Global Const $se_group_mandatory = 1
- Global Const $se_group_enabled_by_default = 2
- Global Const $se_group_enabled = 4
- Global Const $se_group_owner = 8
- Global Const $se_group_use_for_deny_only = 16
- Global Const $se_group_integrity = 32
- Global Const $se_group_integrity_enabled = 64
- Global Const $se_group_resource = 536870912
- Global Const $se_group_logon_id = -1073741824
- Global Enum $tokenprimary = 1, $tokenimpersonation
- Global Enum $securityanonymous = 0, $securityidentification, $securityimpersonation, $securitydelegation
- 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
- Global Const $token_assign_primary = 1
- Global Const $token_duplicate = 2
- Global Const $token_impersonate = 4
- Global Const $token_query = 8
- Global Const $token_query_source = 16
- Global Const $token_adjust_privileges = 32
- Global Const $token_adjust_groups = 64
- Global Const $token_adjust_default = 128
- Global Const $token_adjust_sessionid = 256
- Global Const $token_all_access = 983551
- Global Const $token_read = 131080
- Global Const $token_write = 131296
- Global Const $token_execute = 131072
- Global Const $token_has_traverse_privilege = 1
- Global Const $token_has_backup_privilege = 2
- Global Const $token_has_restore_privilege = 4
- Global Const $token_has_admin_group = 8
- Global Const $token_is_restricted = 16
- Global Const $token_session_not_referenced = 32
- Global Const $token_sandbox_inert = 64
- Global Const $token_has_impersonate_privilege = 128
- Global Const $rights_delete = 65536
- Global Const $read_control = 131072
- Global Const $write_dac = 262144
- Global Const $write_owner = 524288
- Global Const $synchronize = 1048576
- Global Const $access_system_security = 16777216
- Global Const $standard_rights_required = 983040
- Global Const $standard_rights_read = $read_control
- Global Const $standard_rights_write = $read_control
- Global Const $standard_rights_execute = $read_control
- Global Const $standard_rights_all = 2031616
- Global Const $specific_rights_all = 65535
- Global Enum $not_used_access = 0, $grant_access, $set_access, $deny_access, $revoke_access, $set_audit_success, $set_audit_failure
- Global Enum $trustee_is_unknown = 0, $trustee_is_user, $trustee_is_group, $trustee_is_domain, $trustee_is_alias, $trustee_is_well_known_group, $trustee_is_deleted, $trustee_is_invalid, $trustee_is_computer
- Global Const $logon_with_profile = 1
- Global Const $logon_netcredentials_only = 2
- Global Enum $sidtypeuser = 1, $sidtypegroup, $sidtypedomain, $sidtypealias, $sidtypewellknowngroup, $sidtypedeletedaccount, $sidtypeinvalid, $sidtypeunknown, $sidtypecomputer, $sidtypelabel
- Global Const $sid_administrators = "S-1-5-32-544"
- Global Const $sid_users = "S-1-5-32-545"
- Global Const $sid_guests = "S-1-5-32-546"
- Global Const $sid_account_operators = "S-1-5-32-548"
- Global Const $sid_server_operators = "S-1-5-32-549"
- Global Const $sid_print_operators = "S-1-5-32-550"
- Global Const $sid_backup_operators = "S-1-5-32-551"
- Global Const $sid_replicator = "S-1-5-32-552"
- Global Const $sid_owner = "S-1-3-0"
- Global Const $sid_everyone = "S-1-1-0"
- Global Const $sid_network = "S-1-5-2"
- Global Const $sid_interactive = "S-1-5-4"
- Global Const $sid_system = "S-1-5-18"
- Global Const $sid_authenticated_users = "S-1-5-11"
- Global Const $sid_schannel_authentication = "S-1-5-64-14"
- Global Const $sid_digest_authentication = "S-1-5-64-21"
- Global Const $sid_nt_service = "S-1-5-80"
- Global Const $sid_untrusted_mandatory_level = "S-1-16-0"
- Global Const $sid_low_mandatory_level = "S-1-16-4096"
- Global Const $sid_medium_mandatory_level = "S-1-16-8192"
- Global Const $sid_medium_plus_mandatory_level = "S-1-16-8448"
- Global Const $sid_high_mandatory_level = "S-1-16-12288"
- Global Const $sid_system_mandatory_level = "S-1-16-16384"
- Global Const $sid_protected_process_mandatory_level = "S-1-16-20480"
- Global Const $sid_secure_process_mandatory_level = "S-1-16-28672"
- Global Const $sid_all_services = "S-1-5-80-0"
- Func _security__adjusttokenprivileges($htoken, $bdisableall, $tnewstate, $ibufferlen, $tprevstate = 0, $prequired = 0)
- Local $acall = DllCall("advapi32.dll", "bool", "AdjustTokenPrivileges", "handle", $htoken, "bool", $bdisableall, "struct*", $tnewstate, "dword", $ibufferlen, "struct*", $tprevstate, "struct*", $prequired)
- If @error Then Return SetError(@error, @extended, False)
- Return NOT ($acall[0] = 0)
- EndFunc
- Func _security__createprocesswithtoken($htoken, $ilogonflags, $scommandline, $icreationflags, $scurdir, $tstartupinfo, $tprocess_information)
- 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)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, False)
- Return True
- EndFunc
- Func _security__duplicatetokenex($hexistingtoken, $idesiredaccess, $iimpersonationlevel, $itokentype)
- Local $acall = DllCall("advapi32.dll", "bool", "DuplicateTokenEx", "handle", $hexistingtoken, "dword", $idesiredaccess, "struct*", 0, "int", $iimpersonationlevel, "int", $itokentype, "handle*", 0)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
- Return $acall[6]
- EndFunc
- Func _security__getaccountsid($saccount, $ssystem = "")
- Local $aacct = _security__lookupaccountname($saccount, $ssystem)
- If @error Then Return SetError(@error, @extended, 0)
- If IsArray($aacct) Then Return _security__stringsidtosid($aacct[0])
- Return ""
- EndFunc
- Func _security__getlengthsid($psid)
- If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, @extended, 0)
- Local $acall = DllCall("advapi32.dll", "dword", "GetLengthSid", "struct*", $psid)
- If @error Then Return SetError(@error, @extended, 0)
- Return $acall[0]
- EndFunc
- Func _security__gettokeninformation($htoken, $iclass)
- Local $acall = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $htoken, "int", $iclass, "struct*", 0, "dword", 0, "dword*", 0)
- If @error OR NOT $acall[5] Then Return SetError(@error + 10, @extended, 0)
- Local $ilen = $acall[5]
- Local $tbuffer = DllStructCreate("byte[" & $ilen & "]")
- $acall = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $htoken, "int", $iclass, "struct*", $tbuffer, "dword", DllStructGetSize($tbuffer), "dword*", 0)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
- Return $tbuffer
- EndFunc
- Func _security__impersonateself($ilevel = $securityimpersonation)
- Local $acall = DllCall("advapi32.dll", "bool", "ImpersonateSelf", "int", $ilevel)
- If @error Then Return SetError(@error, @extended, False)
- Return NOT ($acall[0] = 0)
- EndFunc
- Func _security__isvalidsid($psid)
- Local $acall = DllCall("advapi32.dll", "bool", "IsValidSid", "struct*", $psid)
- If @error Then Return SetError(@error, @extended, False)
- Return NOT ($acall[0] = 0)
- EndFunc
- Func _security__lookupaccountname($saccount, $ssystem = "")
- Local $tdata = DllStructCreate("byte SID[256]")
- Local $acall = DllCall("advapi32.dll", "bool", "LookupAccountNameW", "wstr", $ssystem, "wstr", $saccount, "struct*", $tdata, "dword*", DllStructGetSize($tdata), "wstr", "", "dword*", DllStructGetSize($tdata), "int*", 0)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
- Local $aacct[3]
- $aacct[0] = _security__sidtostringsid(DllStructGetPtr($tdata, "SID"))
- $aacct[1] = $acall[5]
- $aacct[2] = $acall[7]
- Return $aacct
- EndFunc
- Func _security__lookupaccountsid($vsid, $ssystem = "")
- Local $psid, $aacct[3]
- If IsString($vsid) Then
- $psid = _security__stringsidtosid($vsid)
- Else
- $psid = $vsid
- EndIf
- If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, @extended, 0)
- Local $stypesystem = "ptr"
- If $ssystem Then $stypesystem = "wstr"
- Local $acall = DllCall("advapi32.dll", "bool", "LookupAccountSidW", $stypesystem, $ssystem, "struct*", $psid, "wstr", "", "dword*", 65536, "wstr", "", "dword*", 65536, "int*", 0)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
- Local $aacct[3]
- $aacct[0] = $acall[3]
- $aacct[1] = $acall[5]
- $aacct[2] = $acall[7]
- Return $aacct
- EndFunc
- Func _security__lookupprivilegevalue($ssystem, $sname)
- Local $acall = DllCall("advapi32.dll", "bool", "LookupPrivilegeValueW", "wstr", $ssystem, "wstr", $sname, "int64*", 0)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
- Return $acall[3]
- EndFunc
- Func _security__openprocesstoken($hprocess, $iaccess)
- Local $acall = DllCall("advapi32.dll", "bool", "OpenProcessToken", "handle", $hprocess, "dword", $iaccess, "handle*", 0)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
- Return $acall[3]
- EndFunc
- Func _security__openthreadtoken($iaccess, $hthread = 0, $bopenasself = False)
- If $hthread = 0 Then
- Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentThread")
- If @error Then Return SetError(@error + 10, @extended, 0)
- $hthread = $aresult[0]
- EndIf
- Local $acall = DllCall("advapi32.dll", "bool", "OpenThreadToken", "handle", $hthread, "dword", $iaccess, "bool", $bopenasself, "handle*", 0)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
- Return $acall[4]
- EndFunc
- Func _security__openthreadtokenex($iaccess, $hthread = 0, $bopenasself = False)
- Local $htoken = _security__openthreadtoken($iaccess, $hthread, $bopenasself)
- If $htoken = 0 Then
- Local Const $error_no_token = 1008
- If _winapi_getlasterror() <> $error_no_token Then Return SetError(20, _winapi_getlasterror(), 0)
- If NOT _security__impersonateself() Then Return SetError(@error + 10, _winapi_getlasterror(), 0)
- $htoken = _security__openthreadtoken($iaccess, $hthread, $bopenasself)
- If $htoken = 0 Then Return SetError(@error, _winapi_getlasterror(), 0)
- EndIf
- Return $htoken
- EndFunc
- Func _security__setprivilege($htoken, $sprivilege, $benable)
- Local $iluid = _security__lookupprivilegevalue("", $sprivilege)
- If $iluid = 0 Then Return SetError(@error + 10, @extended, False)
- Local Const $tagtoken_privileges = "dword Count;align 4;int64 LUID;dword Attributes"
- Local $tcurrstate = DllStructCreate($tagtoken_privileges)
- Local $icurrstate = DllStructGetSize($tcurrstate)
- Local $tprevstate = DllStructCreate($tagtoken_privileges)
- Local $iprevstate = DllStructGetSize($tprevstate)
- Local $trequired = DllStructCreate("int Data")
- DllStructSetData($tcurrstate, "Count", 1)
- DllStructSetData($tcurrstate, "LUID", $iluid)
- If NOT _security__adjusttokenprivileges($htoken, False, $tcurrstate, $icurrstate, $tprevstate, $trequired) Then Return SetError(2, @error, False)
- DllStructSetData($tprevstate, "Count", 1)
- DllStructSetData($tprevstate, "LUID", $iluid)
- Local $iattributes = DllStructGetData($tprevstate, "Attributes")
- If $benable Then
- $iattributes = BitOR($iattributes, $se_privilege_enabled)
- Else
- $iattributes = BitAND($iattributes, BitNOT($se_privilege_enabled))
- EndIf
- DllStructSetData($tprevstate, "Attributes", $iattributes)
- If NOT _security__adjusttokenprivileges($htoken, False, $tprevstate, $iprevstate, $tcurrstate, $trequired) Then Return SetError(3, @error, False)
- Return True
- EndFunc
- Func _security__settokeninformation($htoken, $itokeninformation, $vtokeninformation, $itokeninformationlength)
- Local $acall = DllCall("advapi32.dll", "bool", "SetTokenInformation", "handle", $htoken, "int", $itokeninformation, "struct*", $vtokeninformation, "dword", $itokeninformationlength)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, False)
- Return True
- EndFunc
- Func _security__sidtostringsid($psid)
- If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, 0, "")
- Local $acall = DllCall("advapi32.dll", "bool", "ConvertSidToStringSidW", "struct*", $psid, "ptr*", 0)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, "")
- Local $pstringsid = $acall[2]
- Local $alen = DllCall("kernel32.dll", "int", "lstrlenW", "struct*", $pstringsid)
- Local $ssid = DllStructGetData(DllStructCreate("wchar Text[" & $alen[0] + 1 & "]", $pstringsid), "Text")
- DllCall("kernel32.dll", "handle", "LocalFree", "handle", $pstringsid)
- Return $ssid
- EndFunc
- Func _security__sidtypestr($itype)
- Switch $itype
- Case $sidtypeuser
- Return "User"
- Case $sidtypegroup
- Return "Group"
- Case $sidtypedomain
- Return "Domain"
- Case $sidtypealias
- Return "Alias"
- Case $sidtypewellknowngroup
- Return "Well Known Group"
- Case $sidtypedeletedaccount
- Return "Deleted Account"
- Case $sidtypeinvalid
- Return "Invalid"
- Case $sidtypeunknown
- Return "Unknown Type"
- Case $sidtypecomputer
- Return "Computer"
- Case $sidtypelabel
- Return "A mandatory integrity label SID"
- Case Else
- Return "Unknown SID Type"
- EndSwitch
- EndFunc
- Func _security__stringsidtosid($ssid)
- Local $acall = DllCall("advapi32.dll", "bool", "ConvertStringSidToSidW", "wstr", $ssid, "ptr*", 0)
- If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
- Local $psid = $acall[2]
- Local $tbuffer = DllStructCreate("byte Data[" & _security__getlengthsid($psid) & "]", $psid)
- Local $tsid = DllStructCreate("byte Data[" & DllStructGetSize($tbuffer) & "]")
- DllStructSetData($tsid, "Data", DllStructGetData($tbuffer, "Data"))
- DllCall("kernel32.dll", "handle", "LocalFree", "handle", $psid)
- Return $tsid
- EndFunc
- Global Const $tagpoint = "struct;long X;long Y;endstruct"
- Global Const $tagrect = "struct;long Left;long Top;long Right;long Bottom;endstruct"
- Global Const $tagsize = "struct;long X;long Y;endstruct"
- Global Const $tagmargins = "int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight"
- Global Const $tagfiletime = "struct;dword Lo;dword Hi;endstruct"
- Global Const $tagsystemtime = "struct;word Year;word Month;word Dow;word Day;word Hour;word Minute;word Second;word MSeconds;endstruct"
- Global Const $tagtime_zone_information = "struct;long Bias;wchar StdName[32];word StdDate[8];long StdBias;wchar DayName[32];word DayDate[8];long DayBias;endstruct"
- Global Const $tagnmhdr = "struct;hwnd hWndFrom;uint_ptr IDFrom;INT Code;endstruct"
- Global Const $tagcomboboxexitem = "uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;int SelectedImage;int OverlayImage;" & "int Indent;lparam Param"
- Global Const $tagnmcbedragbegin = $tagnmhdr & ";int ItemID;wchar szText[260]"
- Global Const $tagnmcbeendedit = $tagnmhdr & ";bool fChanged;int NewSelection;wchar szText[260];int Why"
- Global Const $tagnmcomboboxex = $tagnmhdr & ";uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;" & "int SelectedImage;int OverlayImage;int Indent;lparam Param"
- 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"
- Global Const $tagnmdatetimechange = $tagnmhdr & ";dword Flag;" & $tagsystemtime
- Global Const $tagnmdatetimeformat = $tagnmhdr & ";ptr Format;" & $tagsystemtime & ";ptr pDisplay;wchar Display[64]"
- Global Const $tagnmdatetimeformatquery = $tagnmhdr & ";ptr Format;struct;long SizeX;long SizeY;endstruct"
- Global Const $tagnmdatetimekeydown = $tagnmhdr & ";int VirtKey;ptr Format;" & $tagsystemtime
- Global Const $tagnmdatetimestring = $tagnmhdr & ";ptr UserString;" & $tagsystemtime & ";dword Flags"
- 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"
- Global Const $taggdip_effectparams_blur = "float Radius; bool ExpandEdge"
- Global Const $taggdip_effectparams_brightnesscontrast = "int BrightnessLevel; int ContrastLevel"
- Global Const $taggdip_effectparams_colorbalance = "int CyanRed; int MagentaGreen; int YellowBlue"
- Global Const $taggdip_effectparams_colorcurve = "int Adjustment; int Channel; int AdjustValue"
- Global Const $taggdip_effectparams_colorlut = "byte LutB[256]; byte LutG[256]; byte LutR[256]; byte LutA[256]"
- Global Const $taggdip_effectparams_huesaturationlightness = "int HueLevel; int SaturationLevel; int LightnessLevel"
- Global Const $taggdip_effectparams_levels = "int Highlight; int Midtone; int Shadow"
- Global Const $taggdip_effectparams_redeyecorrection = "uint NumberOfAreas; ptr Areas"
- Global Const $taggdip_effectparams_sharpen = "float Radius; float Amount"
- Global Const $taggdip_effectparams_tint = "int Hue; int Amount"
- Global Const $taggdipbitmapdata = "uint Width;uint Height;int Stride;int Format;ptr Scan0;uint_ptr Reserved"
- Global Const $taggdipcolormatrix = "float m[25]"
- Global Const $taggdipencoderparam = "struct;byte GUID[16];ulong NumberOfValues;ulong Type;ptr Values;endstruct"
- Global Const $taggdipencoderparams = "uint Count;" & $taggdipencoderparam
- Global Const $taggdiprectf = "struct;float X;float Y;float Width;float Height;endstruct"
- Global Const $taggdipstartupinput = "uint Version;ptr Callback;bool NoThread;bool NoCodecs"
- Global Const $taggdipstartupoutput = "ptr HookProc;ptr UnhookProc"
- Global Const $taggdipimagecodecinfo = "byte CLSID[16];byte FormatID[16];ptr CodecName;ptr DllName;ptr FormatDesc;ptr FileExt;" & "ptr MimeType;dword Flags;dword Version;dword SigCount;dword SigSize;ptr SigPattern;ptr SigMask"
- Global Const $taggdippencoderparams = "uint Count;byte Params[1]"
- Global Const $taghditem = "uint Mask;int XY;ptr Text;handle hBMP;int TextMax;int Fmt;lparam Param;int Image;int Order;uint Type;ptr pFilter;uint State"
- Global Const $tagnmhddispinfo = $tagnmhdr & ";int Item;uint Mask;ptr Text;int TextMax;int Image;lparam lParam"
- Global Const $tagnmhdfilterbtnclick = $tagnmhdr & ";int Item;" & $tagrect
- Global Const $tagnmheader = $tagnmhdr & ";int Item;int Button;ptr pItem"
- Global Const $taggetipaddress = "byte Field4;byte Field3;byte Field2;byte Field1"
- Global Const $tagnmipaddress = $tagnmhdr & ";int Field;int Value"
- Global Const $taglvfindinfo = "struct;uint Flags;ptr Text;lparam Param;" & $tagpoint & ";uint Direction;endstruct"
- Global Const $taglvhittestinfo = $tagpoint & ";uint Flags;int Item;int SubItem;int iGroup"
- 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"
- Global Const $tagnmlistview = $tagnmhdr & ";int Item;int SubItem;uint NewState;uint OldState;uint Changed;" & "struct;long ActionX;long ActionY;endstruct;lparam Param"
- 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"
- Global Const $tagnmlvdispinfo = $tagnmhdr & ";" & $taglvitem
- Global Const $tagnmlvfinditem = $tagnmhdr & ";int Start;" & $taglvfindinfo
- Global Const $tagnmlvgetinfotip = $tagnmhdr & ";dword Flags;ptr Text;int TextMax;int Item;int SubItem;lparam lParam"
- Global Const $tagnmitemactivate = $tagnmhdr & ";int Index;int SubItem;uint NewState;uint OldState;uint Changed;" & $tagpoint & ";lparam lParam;uint KeyFlags"
- Global Const $tagnmlvkeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
- Global Const $tagnmlvscroll = $tagnmhdr & ";int DX;int DY"
- Global Const $tagmchittestinfo = "uint Size;" & $tagpoint & ";uint Hit;" & $tagsystemtime & ";" & $tagrect & ";int iOffset;int iRow;int iCol"
- Global Const $tagmcmonthrange = "word MinYear;word MinMonth;word MinDOW;word MinDay;word MinHour;word MinMinute;word MinSecond;" & "word MinMSeconds;word MaxYear;word MaxMonth;word MaxDOW;word MaxDay;word MaxHour;word MaxMinute;word MaxSecond;" & "word MaxMSeconds;short Span"
- Global Const $tagmcrange = "word MinYear;word MinMonth;word MinDOW;word MinDay;word MinHour;word MinMinute;word MinSecond;" & "word MinMSeconds;word MaxYear;word MaxMonth;word MaxDOW;word MaxDay;word MaxHour;word MaxMinute;word MaxSecond;" & "word MaxMSeconds;short MinSet;short MaxSet"
- 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"
- Global Const $tagnmdaystate = $tagnmhdr & ";" & $tagsystemtime & ";int DayState;ptr pDayState"
- 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"
- Global Const $tagnmobjectnotify = $tagnmhdr & ";int Item;ptr piid;ptr pObject;long Result;dword dwFlags"
- Global Const $tagnmtckeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
- Global Const $tagtvitem = "struct;uint Mask;handle hItem;uint State;uint StateMask;ptr Text;int TextMax;int Image;int SelectedImage;" & "int Children;lparam Param;endstruct"
- Global Const $tagtvitemex = "struct;" & $tagtvitem & ";int Integral;uint uStateEx;hwnd hwnd;int iExpandedImage;int iReserved;endstruct"
- Global Const $tagnmtreeview = $tagnmhdr & ";uint Action;" & "struct;uint OldMask;handle OldhItem;uint OldState;uint OldStateMask;" & "ptr OldText;int 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"
- Global Const $tagnmtvcustomdraw = "struct;" & $tagnmhdr & ";dword DrawStage;handle HDC;" & $tagrect & ";dword_ptr ItemSpec;uint ItemState;lparam ItemParam;endstruct" & ";dword ClrText;dword ClrTextBk;int Level"
- Global Const $tagnmtvdispinfo = $tagnmhdr & ";" & $tagtvitem
- Global Const $tagnmtvgetinfotip = $tagnmhdr & ";ptr Text;int TextMax;handle hItem;lparam lParam"
- Global Const $tagnmtvitemchange = $tagnmhdr & ";uint Changed;handle hItem;uint StateNew;uint StateOld;lparam lParam;"
- Global Const $tagtvhittestinfo = $tagpoint & ";uint Flags;handle Item"
- Global Const $tagnmtvkeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
- Global Const $tagnmmouse = $tagnmhdr & ";dword_ptr ItemSpec;dword_ptr ItemData;" & $tagpoint & ";lparam HitInfo"
- Global Const $tagtoken_privileges = "dword Count;align 4;int64 LUID;dword Attributes"
- Global Const $tagimageinfo = "handle hBitmap;handle hMask;int Unused1;int Unused2;" & $tagrect
- Global Const $tagmenuinfo = "dword Size;INT Mask;dword Style;uint YMax;handle hBack;dword ContextHelpID;ulong_ptr MenuData"
- 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"
- 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")
- Global Const $tagnmrebarautobreak = $tagnmhdr & ";uint uBand;uint wID;lparam lParam;uint uMsg;uint fStyleCurrent;bool fAutoBreak"
- Global Const $tagnmrbautosize = $tagnmhdr & ";bool fChanged;" & "struct;long TargetLeft;long TargetTop;long TargetRight;long TargetBottom;endstruct;" & "struct;long ActualLeft;long ActualTop;long ActualRight;long ActualBottom;endstruct"
- Global Const $tagnmrebar = $tagnmhdr & ";dword dwMask;uint uBand;uint fStyle;uint wID;lparam lParam"
- Global Const $tagnmrebarchevron = $tagnmhdr & ";uint uBand;uint wID;lparam lParam;" & $tagrect & ";lparam lParamNM"
- 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"
- Global Const $tagcolorscheme = "dword Size;dword BtnHighlight;dword BtnShadow"
- 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
- Global Const $tagnmtbhotitem = $tagnmhdr & ";int idOld;int idNew;dword dwFlags"
- Global Const $tagtbbutton = "int Bitmap;int Command;byte State;byte Style;dword_ptr Param;int_ptr String"
- Global Const $tagtbbuttoninfo = "uint Size;dword Mask;int Command;int Image;byte State;byte Style;word CX;dword_ptr Param;ptr Text;int TextMax"
- Global Const $tagnetresource = "dword Scope;dword Type;dword DisplayType;dword Usage;ptr LocalName;ptr RemoteName;ptr Comment;ptr Provider"
- Global Const $tagoverlapped = "ulong_ptr Internal;ulong_ptr InternalHigh;struct;dword Offset;dword OffsetHigh;endstruct;handle hEvent"
- Global Const $tagopenfilename = "dword StructSize;hwnd hwndOwner;handle hInstance;ptr lpstrFilter;ptr lpstrCustomFilter;" & "dword nMaxCustFilter;dword nFilterIndex;ptr lpstrFile;dword nMaxFile;ptr lpstrFileTitle;dword nMaxFileTitle;" & "ptr lpstrInitialDir;ptr lpstrTitle;dword Flags;word nFileOffset;word nFileExtension;ptr lpstrDefExt;lparam lCustData;" & "ptr lpfnHook;ptr lpTemplateName;ptr pvReserved;dword dwReserved;dword FlagsEx"
- 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"
- Global Const $tagbitmapinfo = $tagbitmapinfoheader & ";dword biRGBQuad[1]"
- Global Const $tagblendfunction = "byte Op;byte Flags;byte Alpha;byte Format"
- Global Const $tagguid = "struct;ulong Data1;ushort Data2;ushort Data3;byte Data4[8];endstruct"
- Global Const $tagwindowplacement = "uint length;uint flags;uint showCmd;long ptMinPosition[2];long ptMaxPosition[2];long rcNormalPosition[4]"
- Global Const $tagwindowpos = "hwnd hWnd;hwnd InsertAfter;int X;int Y;int CX;int CY;uint Flags"
- Global Const $tagscrollinfo = "uint cbSize;uint fMask;int nMin;int nMax;uint nPage;int nPos;int nTrackPos"
- Global Const $tagscrollbarinfo = "dword cbSize;" & $tagrect & ";int dxyLineButton;int xyThumbTop;" & "int xyThumbBottom;int reserved;dword rgstate[6]"
- 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"
- Global Const $tagkbdllhookstruct = "dword vkCode;dword scanCode;dword flags;dword time;ulong_ptr dwExtraInfo"
- Global Const $tagprocess_information = "handle hProcess;handle hThread;dword ProcessID;dword ThreadID"
- Global Const $tagstartupinfo = "dword Size;ptr Reserved1;ptr Desktop;ptr Title;dword X;dword Y;dword XSize;dword YSize;dword XCountChars;" & "dword YCountChars;dword FillAttribute;dword Flags;word ShowWindow;word Reserved2;ptr Reserved3;handle StdInput;" & "handle StdOutput;handle StdError"
- Global Const $tagsecurity_attributes = "dword Length;ptr Descriptor;bool InheritHandle"
- 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]"
- 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"
- Global Const $tagmemmap = "handle hProc;ulong_ptr Size;ptr Mem"
- Func _memfree(ByRef $tmemmap)
- Local $pmemory = DllStructGetData($tmemmap, "Mem")
- Local $hprocess = DllStructGetData($tmemmap, "hProc")
- Local $bresult = _memvirtualfreeex($hprocess, $pmemory, 0, $mem_release)
- DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hprocess)
- If @error Then Return SetError(@error, @extended, False)
- Return $bresult
- EndFunc
- Func _memglobalalloc($ibytes, $iflags = 0)
- Local $aresult = DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", $iflags, "ulong_ptr", $ibytes)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _memglobalfree($hmemory)
- Local $aresult = DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", $hmemory)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _memgloballock($hmemory)
- Local $aresult = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", $hmemory)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _memglobalsize($hmemory)
- Local $aresult = DllCall("kernel32.dll", "ulong_ptr", "GlobalSize", "handle", $hmemory)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _memglobalunlock($hmemory)
- Local $aresult = DllCall("kernel32.dll", "bool", "GlobalUnlock", "handle", $hmemory)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _meminit($hwnd, $isize, ByRef $tmemmap)
- Local $aresult = DllCall("user32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $hwnd, "dword*", 0)
- If @error Then Return SetError(@error + 10, @extended, 0)
- Local $iprocessid = $aresult[2]
- If $iprocessid = 0 Then Return SetError(1, 0, 0)
- Local $iaccess = BitOR($process_vm_operation, $process_vm_read, $process_vm_write)
- Local $hprocess = __mem_openprocess($iaccess, False, $iprocessid, True)
- Local $ialloc = BitOR($mem_reserve, $mem_commit)
- Local $pmemory = _memvirtualallocex($hprocess, 0, $isize, $ialloc, $page_readwrite)
- If $pmemory = 0 Then Return SetError(2, 0, 0)
- $tmemmap = DllStructCreate($tagmemmap)
- DllStructSetData($tmemmap, "hProc", $hprocess)
- DllStructSetData($tmemmap, "Size", $isize)
- DllStructSetData($tmemmap, "Mem", $pmemory)
- Return $pmemory
- EndFunc
- Func _memmovememory($psource, $pdest, $ilength)
- DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pdest, "struct*", $psource, "ulong_ptr", $ilength)
- If @error Then Return SetError(@error, @extended)
- EndFunc
- Func _memread(ByRef $tmemmap, $psrce, $pdest, $isize)
- Local $aresult = DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", DllStructGetData($tmemmap, "hProc"), "ptr", $psrce, "struct*", $pdest, "ulong_ptr", $isize, "ulong_ptr*", 0)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _memwrite(ByRef $tmemmap, $psrce, $pdest = 0, $isize = 0, $ssrce = "struct*")
- If $pdest = 0 Then $pdest = DllStructGetData($tmemmap, "Mem")
- If $isize = 0 Then $isize = DllStructGetData($tmemmap, "Size")
- Local $aresult = DllCall("kernel32.dll", "bool", "WriteProcessMemory", "handle", DllStructGetData($tmemmap, "hProc"), "ptr", $pdest, $ssrce, $psrce, "ulong_ptr", $isize, "ulong_ptr*", 0)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _memvirtualalloc($paddress, $isize, $iallocation, $iprotect)
- Local $aresult = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", $paddress, "ulong_ptr", $isize, "dword", $iallocation, "dword", $iprotect)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _memvirtualallocex($hprocess, $paddress, $isize, $iallocation, $iprotect)
- Local $aresult = DllCall("kernel32.dll", "ptr", "VirtualAllocEx", "handle", $hprocess, "ptr", $paddress, "ulong_ptr", $isize, "dword", $iallocation, "dword", $iprotect)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _memvirtualfree($paddress, $isize, $ifreetype)
- Local $aresult = DllCall("kernel32.dll", "bool", "VirtualFree", "ptr", $paddress, "ulong_ptr", $isize, "dword", $ifreetype)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _memvirtualfreeex($hprocess, $paddress, $isize, $ifreetype)
- Local $aresult = DllCall("kernel32.dll", "bool", "VirtualFreeEx", "handle", $hprocess, "ptr", $paddress, "ulong_ptr", $isize, "dword", $ifreetype)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func __mem_openprocess($iaccess, $binherit, $ipid, $bdebugpriv = False)
- Local $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $binherit, "dword", $ipid)
- If @error Then Return SetError(@error, @extended, 0)
- If $aresult[0] Then Return $aresult[0]
- If NOT $bdebugpriv Then Return SetError(100, 0, 0)
- Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
- If @error Then Return SetError(@error + 10, @extended, 0)
- _security__setprivilege($htoken, "SeDebugPrivilege", True)
- Local $ierror = @error
- Local $iextended = @extended
- Local $iret = 0
- If NOT @error Then
- $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $binherit, "dword", $ipid)
- $ierror = @error
- $iextended = @extended
- If $aresult[0] Then $iret = $aresult[0]
- _security__setprivilege($htoken, "SeDebugPrivilege", False)
- If @error Then
- $ierror = @error + 20
- $iextended = @extended
- EndIf
- Else
- $ierror = @error + 30
- EndIf
- DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $htoken)
- Return SetError($ierror, $iextended, $iret)
- EndFunc
- Global Const $opt_coordsrelative = 0
- Global Const $opt_coordsabsolute = 1
- Global Const $opt_coordsclient = 2
- Global Const $opt_errorsilent = 0
- Global Const $opt_errorfatal = 1
- Global Const $opt_capsnostore = 0
- Global Const $opt_capsstore = 1
- Global Const $opt_matchstart = 1
- Global Const $opt_matchany = 2
- Global Const $opt_matchexact = 3
- Global Const $opt_matchadvanced = 4
- Global Const $ccs_top = 1
- Global Const $ccs_nomovey = 2
- Global Const $ccs_bottom = 3
- Global Const $ccs_noresize = 4
- Global Const $ccs_noparentalign = 8
- Global Const $ccs_nohilite = 16
- Global Const $ccs_adjustable = 32
- Global Const $ccs_nodivider = 64
- Global Const $ccs_vert = 128
- Global Const $ccs_left = 129
- Global Const $ccs_nomovex = 130
- Global Const $ccs_right = 131
- Global Const $dt_drivetype = 1
- Global Const $dt_ssdstatus = 2
- Global Const $dt_bustype = 3
- Global Const $proxy_ie = 0
- Global Const $proxy_none = 1
- Global Const $proxy_specified = 2
- Global Const $objid_window = 0
- Global Const $objid_titlebar = -2
- Global Const $objid_sizegrip = -7
- Global Const $objid_caret = -8
- Global Const $objid_cursor = -9
- Global Const $objid_alert = -10
- Global Const $objid_sound = -11
- Global Const $dlg_centerontop = 0
- Global Const $dlg_notitle = 1
- Global Const $dlg_notontop = 2
- Global Const $dlg_textleft = 4
- Global Const $dlg_textright = 8
- Global Const $dlg_moveable = 16
- Global Const $dlg_textvcenter = 32
- Global Const $idc_unknown = 0
- Global Const $idc_appstarting = 1
- Global Const $idc_arrow = 2
- Global Const $idc_cross = 3
- Global Const $idc_hand = 32649
- Global Const $idc_help = 4
- Global Const $idc_ibeam = 5
- Global Const $idc_icon = 6
- Global Const $idc_no = 7
- Global Const $idc_size = 8
- Global Const $idc_sizeall = 9
- Global Const $idc_sizenesw = 10
- Global Const $idc_sizens = 11
- Global Const $idc_sizenwse = 12
- Global Const $idc_sizewe = 13
- Global Const $idc_uparrow = 14
- Global Const $idc_wait = 15
- Global Const $idi_application = 32512
- Global Const $idi_asterisk = 32516
- Global Const $idi_exclamation = 32515
- Global Const $idi_hand = 32513
- Global Const $idi_question = 32514
- Global Const $idi_winlogo = 32517
- Global Const $idi_shield = 32518
- Global Const $idi_error = $idi_hand
- Global Const $idi_information = $idi_asterisk
- Global Const $idi_warning = $idi_exclamation
- Global Const $sd_logoff = 0
- Global Const $sd_shutdown = 1
- Global Const $sd_reboot = 2
- Global Const $sd_force = 4
- Global Const $sd_powerdown = 8
- Global Const $sd_forcehung = 16
- Global Const $sd_standby = 32
- Global Const $sd_hibernate = 64
- Global Const $stdin_child = 1
- Global Const $stdout_child = 2
- Global Const $stderr_child = 4
- Global Const $stderr_merged = 8
- Global Const $stdio_inherit_parent = 16
- Global Const $run_create_new_console = 65536
- Global Const $ubound_dimensions = 0
- Global Const $ubound_rows = 1
- Global Const $ubound_columns = 2
- Global Const $mouseeventf_absolute = 32768
- Global Const $mouseeventf_move = 1
- Global Const $mouseeventf_leftdown = 2
- Global Const $mouseeventf_leftup = 4
- Global Const $mouseeventf_rightdown = 8
- Global Const $mouseeventf_rightup = 16
- Global Const $mouseeventf_middledown = 32
- Global Const $mouseeventf_middleup = 64
- Global Const $mouseeventf_wheel = 2048
- Global Const $mouseeventf_xdown = 128
- Global Const $mouseeventf_xup = 256
- Global Const $reg_none = 0
- Global Const $reg_sz = 1
- Global Const $reg_expand_sz = 2
- Global Const $reg_binary = 3
- Global Const $reg_dword = 4
- Global Const $reg_dword_little_endian = 4
- Global Const $reg_dword_big_endian = 5
- Global Const $reg_link = 6
- Global Const $reg_multi_sz = 7
- Global Const $reg_resource_list = 8
- Global Const $reg_full_resource_descriptor = 9
- Global Const $reg_resource_requirements_list = 10
- Global Const $reg_qword = 11
- Global Const $reg_qword_little_endian = 11
- Global Const $hwnd_bottom = 1
- Global Const $hwnd_notopmost = -2
- Global Const $hwnd_top = 0
- Global Const $hwnd_topmost = -1
- Global Const $swp_nosize = 1
- Global Const $swp_nomove = 2
- Global Const $swp_nozorder = 4
- Global Const $swp_noredraw = 8
- Global Const $swp_noactivate = 16
- Global Const $swp_framechanged = 32
- Global Const $swp_drawframe = 32
- Global Const $swp_showwindow = 64
- Global Const $swp_hidewindow = 128
- Global Const $swp_nocopybits = 256
- Global Const $swp_noownerzorder = 512
- Global Const $swp_noreposition = 512
- Global Const $swp_nosendchanging = 1024
- Global Const $swp_defererase = 8192
- Global Const $swp_asyncwindowpos = 16384
- Global Const $keyword_default = 1
- Global Const $keyword_null = 2
- Global Const $declared_local = -1
- Global Const $declared_unknown = 0
- Global Const $declared_global = 1
- Global Const $assign_create = 0
- Global Const $assign_forcelocal = 1
- Global Const $assign_forceglobal = 2
- Global Const $assign_existfail = 4
- Global Const $bi_enable = 0
- Global Const $bi_disable = 1
- Global Const $break_enable = 1
- Global Const $break_disable = 0
- Global Const $cdtray_open = "open"
- Global Const $cdtray_closed = "closed"
- Global Const $send_default = 0
- Global Const $send_raw = 1
- Global Const $dir_default = 0
- Global Const $dir_extended = 1
- Global Const $dir_norecurse = 2
- Global Const $dir_remove = 1
- Global Const $dt_all = "ALL"
- Global Const $dt_cdrom = "CDROM"
- Global Const $dt_removable = "REMOVABLE"
- Global Const $dt_fixed = "FIXED"
- Global Const $dt_network = "NETWORK"
- Global Const $dt_ramdisk = "RAMDISK"
- Global Const $dt_unknown = "UNKNOWN"
- Global Const $dt_undefined = 1
- Global Const $dt_fat = "FAT"
- Global Const $dt_fat32 = "FAT32"
- Global Const $dt_exfat = "exFAT"
- Global Const $dt_ntfs = "NTFS"
- Global Const $dt_nwfs = "NWFS"
- Global Const $dt_cdfs = "CDFS"
- Global Const $dt_udf = "UDF"
- Global Const $dma_default = 0
- Global Const $dma_persistent = 1
- Global Const $dma_authentication = 8
- Global Const $ds_unknown = "UNKNOWN"
- Global Const $ds_ready = "READY"
- Global Const $ds_notready = "NOTREADY"
- Global Const $ds_invalid = "INVALID"
- Global Const $mouse_click_left = "left"
- Global Const $mouse_click_right = "right"
- Global Const $mouse_click_middle = "middle"
- Global Const $mouse_click_main = "main"
- Global Const $mouse_click_menu = "menu"
- Global Const $mouse_click_primary = "primary"
- Global Const $mouse_click_secondary = "secondary"
- Global Const $mouse_wheel_up = "up"
- Global Const $mouse_wheel_down = "down"
- Global Const $number_auto = 0
- Global Const $number_32bit = 1
- Global Const $number_64bit = 2
- Global Const $number_double = 3
- Global Const $obj_name = 1
- Global Const $obj_string = 2
- Global Const $obj_progid = 3
- Global Const $obj_file = 4
- Global Const $obj_module = 5
- Global Const $obj_clsid = 6
- Global Const $obj_iid = 7
- Global Const $exitclose_normal = 0
- Global Const $exitclose_byexit = 1
- Global Const $exitclose_byclick = 2
- Global Const $exitclose_bylogoff = 3
- Global Const $exitclose_byshutdown = 4
- Global Const $process_stats_memory = 0
- Global Const $process_stats_io = 1
- Global Const $process_low = 0
- Global Const $process_belownormal = 1
- Global Const $process_normal = 2
- Global Const $process_abovenormal = 3
- Global Const $process_high = 4
- Global Const $process_realtime = 5
- Global Const $run_logon_noprofile = 0
- Global Const $run_logon_profile = 1
- Global Const $run_logon_network = 2
- Global Const $run_logon_inherit = 4
- Global Const $sound_nowait = 0
- Global Const $sound_wait = 1
- Global Const $shex_open = "open"
- Global Const $shex_edit = "edit"
- Global Const $shex_print = "print"
- Global Const $shex_properties = "properties"
- Global Const $tcp_data_default = 0
- Global Const $tcp_data_binary = 1
- Global Const $udp_open_default = 0
- Global Const $udp_open_broadcast = 1
- Global Const $udp_data_default = 0
- Global Const $udp_data_binary = 1
- Global Const $udp_data_array = 2
- Global Const $tip_noicon = 0
- Global Const $tip_infoicon = 1
- Global Const $tip_warningicon = 2
- Global Const $tip_erroricon = 3
- Global Const $tip_balloon = 1
- Global Const $tip_center = 2
- Global Const $tip_forcevisible = 4
- Global Const $windows_noontop = 0
- Global Const $windows_ontop = 1
- Global Const $win_state_exists = 1
- Global Const $win_state_visible = 2
- Global Const $win_state_enabled = 4
- Global Const $win_state_active = 8
- Global Const $win_state_minimized = 16
- Global Const $win_state_maximized = 32
- #Region Global Variables and Constants
- Global $__g_venum, $__g_vext = 0
- Global $__g_irgbmode = 1
- Global Const $tagosversioninfo = "struct;dword OSVersionInfoSize;dword MajorVersion;dword MinorVersion;dword BuildNumber;dword PlatformId;wchar CSDVersion[128];endstruct"
- Global Const $image_bitmap = 0
- Global Const $image_icon = 1
- Global Const $image_cursor = 2
- Global Const $image_enhmetafile = 3
- Global Const $lr_defaultcolor = 0
- Global Const $lr_monochrome = 1
- Global Const $lr_color = 2
- Global Const $lr_copyreturnorg = 4
- Global Const $lr_copydeleteorg = 8
- Global Const $lr_loadfromfile = 16
- Global Const $lr_loadtransparent = 32
- Global Const $lr_defaultsize = 64
- Global Const $lr_vgacolor = 128
- Global Const $lr_loadmap3dcolors = 4096
- Global Const $lr_createdibsection = 8192
- Global Const $lr_copyfromresource = 16384
- Global Const $lr_shared = 32768
- Global Const $__tagcursorinfo = "dword Size;dword Flags;handle hCursor;" & "struct;long X;long Y;endstruct"
- Global Const $__winver = __winver()
- #EndRegion Global Variables and Constants
- #Region Functions list
- #EndRegion Functions list
- #Region Public Functions
- Func _winapi_createfile($sfilename, $icreation, $iaccess = 4, $ishare = 0, $iattributes = 0, $tsecurity = 0)
- Local $ida = 0, $ism = 0, $icd = 0, $ifa = 0
- If BitAND($iaccess, 1) <> 0 Then $ida = BitOR($ida, $generic_execute)
- If BitAND($iaccess, 2) <> 0 Then $ida = BitOR($ida, $generic_read)
- If BitAND($iaccess, 4) <> 0 Then $ida = BitOR($ida, $generic_write)
- If BitAND($ishare, 1) <> 0 Then $ism = BitOR($ism, $file_share_delete)
- If BitAND($ishare, 2) <> 0 Then $ism = BitOR($ism, $file_share_read)
- If BitAND($ishare, 4) <> 0 Then $ism = BitOR($ism, $file_share_write)
- Switch $icreation
- Case 0
- $icd = $create_new
- Case 1
- $icd = $create_always
- Case 2
- $icd = $open_existing
- Case 3
- $icd = $open_always
- Case 4
- $icd = $truncate_existing
- EndSwitch
- If BitAND($iattributes, 1) <> 0 Then $ifa = BitOR($ifa, $file_attribute_archive)
- If BitAND($iattributes, 2) <> 0 Then $ifa = BitOR($ifa, $file_attribute_hidden)
- If BitAND($iattributes, 4) <> 0 Then $ifa = BitOR($ifa, $file_attribute_readonly)
- If BitAND($iattributes, 8) <> 0 Then $ifa = BitOR($ifa, $file_attribute_system)
- Local $aresult = DllCall("kernel32.dll", "handle", "CreateFileW", "wstr", $sfilename, "dword", $ida, "dword", $ism, "struct*", $tsecurity, "dword", $icd, "dword", $ifa, "ptr", 0)
- If @error OR ($aresult[0] = Ptr(-1)) Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_freelibrary($hmodule)
- Local $aresult = DllCall("kernel32.dll", "bool", "FreeLibrary", "handle", $hmodule)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_getcursorinfo()
- Local $tcursor = DllStructCreate($__tagcursorinfo)
- Local $icursor = DllStructGetSize($tcursor)
- DllStructSetData($tcursor, "Size", $icursor)
- Local $aret = DllCall("user32.dll", "bool", "GetCursorInfo", "struct*", $tcursor)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
- Local $acursor[5]
- $acursor[0] = True
- $acursor[1] = DllStructGetData($tcursor, "Flags") <> 0
- $acursor[2] = DllStructGetData($tcursor, "hCursor")
- $acursor[3] = DllStructGetData($tcursor, "X")
- $acursor[4] = DllStructGetData($tcursor, "Y")
- Return $acursor
- EndFunc
- Func _winapi_getdlgctrlid($hwnd)
- Local $aresult = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hwnd)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getmodulehandle($smodulename)
- Local $smodulenametype = "wstr"
- If $smodulename = "" Then
- $smodulename = 0
- $smodulenametype = "ptr"
- EndIf
- Local $aresult = DllCall("kernel32.dll", "handle", "GetModuleHandleW", $smodulenametype, $smodulename)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getstring($pstring, $bunicode = True)
- Local $ilength = _winapi_strlen($pstring, $bunicode)
- If @error OR NOT $ilength Then Return SetError(@error + 10, @extended, "")
- Local $tstring = DllStructCreate(($bunicode ? "wchar" : "char") & "[" & ($ilength + 1) & "]", $pstring)
- If @error Then Return SetError(@error, @extended, "")
- Return SetExtended($ilength, DllStructGetData($tstring, 1))
- EndFunc
- Func _winapi_iswow64process($ipid = 0)
- If NOT $ipid Then $ipid = @AutoItPID
- Local $hprocess = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", ($__winver < 1536 ? 1024 : 4096), "bool", 0, "dword", $ipid)
- If @error OR NOT $hprocess[0] Then Return SetError(@error + 20, @extended, False)
- Local $aret = DllCall("kernel32.dll", "bool", "IsWow64Process", "handle", $hprocess[0], "bool*", 0)
- If __checkerrorclosehandle($aret, $hprocess[0]) Then Return SetError(@error, @extended, False)
- Return $aret[2]
- EndFunc
- Func _winapi_loadimage($hinstance, $simage, $itype, $ixdesired, $iydesired, $iload)
- Local $aresult, $simagetype = "int"
- If IsString($simage) Then $simagetype = "wstr"
- $aresult = DllCall("user32.dll", "handle", "LoadImageW", "handle", $hinstance, $simagetype, $simage, "uint", $itype, "int", $ixdesired, "int", $iydesired, "uint", $iload)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_loadlibrary($sfilename)
- Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryW", "wstr", $sfilename)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_pathisdirectory($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsDirectoryW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_readfile($hfile, $pbuffer, $itoread, ByRef $iread, $toverlapped = 0)
- Local $aresult = DllCall("kernel32.dll", "bool", "ReadFile", "handle", $hfile, "struct*", $pbuffer, "dword", $itoread, "dword*", 0, "struct*", $toverlapped)
- If @error Then Return SetError(@error, @extended, False)
- $iread = $aresult[4]
- Return $aresult[0]
- EndFunc
- Func _winapi_strlen($pstring, $bunicode = True)
- Local $w = ""
- If $bunicode Then $w = "W"
- Local $aret = DllCall("kernel32.dll", "int", "lstrlen" & $w, "struct*", $pstring)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_switchcolor($icolor)
- If $icolor = -1 Then Return $icolor
- Return BitOR(BitAND($icolor, 65280), BitShift(BitAND($icolor, 255), -16), BitShift(BitAND($icolor, 16711680), 16))
- EndFunc
- Func _winapi_writefile($hfile, $pbuffer, $itowrite, ByRef $iwritten, $toverlapped = 0)
- Local $aresult = DllCall("kernel32.dll", "bool", "WriteFile", "handle", $hfile, "struct*", $pbuffer, "dword", $itowrite, "dword*", 0, "struct*", $toverlapped)
- If @error Then Return SetError(@error, @extended, False)
- $iwritten = $aresult[4]
- Return $aresult[0]
- EndFunc
- #EndRegion Public Functions
- #Region Internal Functions
- Func __checkerrorarraybounds(Const ByRef $adata, ByRef $istart, ByRef $iend, $ndim = 1, $idim = $ubound_dimensions)
- If NOT IsArray($adata) Then Return SetError(1, 0, 1)
- If UBound($adata, $idim) <> $ndim Then Return SetError(2, 0, 1)
- If $istart < 0 Then $istart = 0
- Local $iubound = UBound($adata) - 1
- If $iend < 1 OR $iend > $iubound Then $iend = $iubound
- If $istart > $iend Then Return SetError(4, 0, 1)
- Return 0
- EndFunc
- Func __checkerrorclosehandle($aret, $hfile, $blasterror = False, $icurerr = @error, $icurext = @extended)
- If NOT $icurerr AND NOT $aret[0] Then $icurerr = 10
- Local $alasterror = DllCall("kernel32.dll", "dword", "GetLastError")
- DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hfile)
- If $icurerr Then DllCall("kernel32.dll", "none", "SetLastError", "dword", $alasterror[0])
- If $blasterror Then $icurext = $alasterror[0]
- Return SetError($icurerr, $icurext, $icurerr)
- EndFunc
- Func __dll($spath, $bpin = False)
- Local $aret = DllCall("kernel32.dll", "bool", "GetModuleHandleExW", "dword", ($bpin ? 1 : 2), "wstr", $spath, "ptr*", 0)
- If NOT $aret[3] Then
- Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryW", "wstr", $spath)
- If NOT $aresult[0] Then Return 0
- EndIf
- Return 1
- EndFunc
- Func __enumwindowsproc($hwnd, $bvisible)
- Local $aresult
- If $bvisible Then
- $aresult = DllCall("user32.dll", "bool", "IsWindowVisible", "hwnd", $hwnd)
- If NOT $aresult[0] Then
- Return 1
- EndIf
- EndIf
- __inc($__g_venum)
- $__g_venum[$__g_venum[0][0]][0] = $hwnd
- $aresult = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $hwnd, "wstr", "", "int", 4096)
- $__g_venum[$__g_venum[0][0]][1] = $aresult[2]
- Return 1
- EndFunc
- Func __fatalexit($icode, $stext = "")
- If $stext Then MsgBox($mb_systemmodal, "AutoIt", $stext)
- DllCall("kernel32.dll", "none", "FatalExit", "int", $icode)
- EndFunc
- Func __inc(ByRef $adata, $iincrement = 100)
- Select
- Case UBound($adata, $ubound_columns)
- If $iincrement < 0 Then
- ReDim $adata[$adata[0][0] + 1][UBound($adata, $ubound_columns)]
- Else
- $adata[0][0] += 1
- If $adata[0][0] > UBound($adata) - 1 Then
- ReDim $adata[$adata[0][0] + $iincrement][UBound($adata, $ubound_columns)]
- EndIf
- EndIf
- Case UBound($adata, $ubound_rows)
- If $iincrement < 0 Then
- ReDim $adata[$adata[0] + 1]
- Else
- $adata[0] += 1
- If $adata[0] > UBound($adata) - 1 Then
- ReDim $adata[$adata[0] + $iincrement]
- EndIf
- EndIf
- Case Else
- Return 0
- EndSelect
- Return 1
- EndFunc
- Func __rgb($icolor)
- If $__g_irgbmode Then
- $icolor = _winapi_switchcolor($icolor)
- EndIf
- Return $icolor
- EndFunc
- Func __winver()
- Local $tosvi = DllStructCreate($tagosversioninfo)
- DllStructSetData($tosvi, 1, DllStructGetSize($tosvi))
- Local $aret = DllCall("kernel32.dll", "bool", "GetVersionExW", "struct*", $tosvi)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
- Return BitOR(BitShift(DllStructGetData($tosvi, 2), -8), DllStructGetData($tosvi, 3))
- EndFunc
- #EndRegion Internal Functions
- #Region Global Variables and Constants
- Global Const $duplicate_close_source = 1
- Global Const $duplicate_same_access = 2
- Global Const $obj_bitmap = 7
- Global Const $obj_brush = 2
- Global Const $obj_colorspace = 14
- Global Const $obj_dc = 3
- Global Const $obj_enhmetadc = 12
- Global Const $obj_enhmetafile = 13
- Global Const $obj_extpen = 11
- Global Const $obj_font = 6
- Global Const $obj_memdc = 10
- Global Const $obj_metadc = 4
- Global Const $obj_metafile = 9
- Global Const $obj_pal = 5
- Global Const $obj_pen = 1
- Global Const $obj_region = 8
- Global Const $null_brush = 5
- Global Const $null_pen = 8
- Global Const $black_brush = 4
- Global Const $dkgray_brush = 3
- Global Const $dc_brush = 18
- Global Const $gray_brush = 2
- Global Const $hollow_brush = $null_brush
- Global Const $ltgray_brush = 1
- Global Const $white_brush = 0
- Global Const $black_pen = 7
- Global Const $dc_pen = 19
- Global Const $white_pen = 6
- Global Const $ansi_fixed_font = 11
- Global Const $ansi_var_font = 12
- Global Const $device_default_font = 14
- Global Const $default_gui_font = 17
- Global Const $oem_fixed_font = 10
- Global Const $system_font = 13
- Global Const $system_fixed_font = 16
- Global Const $default_palette = 15
- #EndRegion Global Variables and Constants
- #Region Functions list
- #EndRegion Functions list
- #Region Public Functions
- Func _winapi_closehandle($hobject)
- Local $aresult = DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hobject)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_deleteobject($hobject)
- Local $aresult = DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hobject)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_duplicatehandle($hsourceprocesshandle, $hsourcehandle, $htargetprocesshandle, $idesiredaccess, $iinherithandle, $ioptions)
- Local $aresult = DllCall("kernel32.dll", "bool", "DuplicateHandle", "handle", $hsourceprocesshandle, "handle", $hsourcehandle, "handle", $htargetprocesshandle, "handle*", 0, "dword", $idesiredaccess, "bool", $iinherithandle, "dword", $ioptions)
- If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, 0)
- Return $aresult[4]
- EndFunc
- Func _winapi_getcurrentobject($hdc, $itype)
- Local $aret = DllCall("gdi32.dll", "handle", "GetCurrentObject", "handle", $hdc, "uint", $itype)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getcurrentprocess()
- Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentProcess")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getobject($hobject, $isize, $pobject)
- Local $aresult = DllCall("gdi32.dll", "int", "GetObjectW", "handle", $hobject, "int", $isize, "struct*", $pobject)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_getobjectinfobyhandle($hobject)
- Local $tagpublic_object_basic_information = "ulong Attributes;ulong GrantedAcess;ulong HandleCount;ulong PointerCount;ulong Reserved[10]"
- Local $tpobi = DllStructCreate($tagpublic_object_basic_information)
- Local $aret = DllCall("ntdll.dll", "long", "ZwQueryObject", "handle", $hobject, "uint", 0, "struct*", $tpobi, "ulong", DllStructGetSize($tpobi), "ptr", 0)
- If @error Then Return SetError(@error, @extended, 0)
- If $aret[0] Then Return SetError(10, $aret[0], 0)
- Local $aresult[4]
- For $i = 0 To 3
- $aresult[$i] = DllStructGetData($tpobi, $i + 1)
- Next
- Return $aresult
- EndFunc
- Func _winapi_getobjectnamebyhandle($hobject)
- Local $tagunicode_string = "struct;ushort Length;ushort MaximumLength;ptr Buffer;endstruct"
- Local $tagpublic_object_type_information = "struct;" & $tagunicode_string & ";ulong Reserved[22];endstruct"
- Local $tpoti = DllStructCreate($tagpublic_object_type_information & ";byte[32]")
- Local $aret = DllCall("ntdll.dll", "long", "ZwQueryObject", "handle", $hobject, "uint", 2, "struct*", $tpoti, "ulong", DllStructGetSize($tpoti), "ulong*", 0)
- If @error Then Return SetError(@error, @extended, "")
- If $aret[0] Then Return SetError(10, $aret[0], "")
- Local $pdata = DllStructGetData($tpoti, 3)
- If NOT $pdata Then Return SetError(11, 0, "")
- Return _winapi_getstring($pdata)
- EndFunc
- Func _winapi_getobjecttype($hobject)
- Local $aret = DllCall("gdi32.dll", "dword", "GetObjectType", "handle", $hobject)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getstdhandle($istdhandle)
- If $istdhandle < 0 OR $istdhandle > 2 Then Return SetError(2, 0, -1)
- Local Const $ahandle[3] = [-10, -11, -12]
- Local $aresult = DllCall("kernel32.dll", "handle", "GetStdHandle", "dword", $ahandle[$istdhandle])
- If @error Then Return SetError(@error, @extended, -1)
- Return $aresult[0]
- EndFunc
- Func _winapi_getstockobject($iobject)
- Local $aresult = DllCall("gdi32.dll", "handle", "GetStockObject", "int", $iobject)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_selectobject($hdc, $hgdiobj)
- Local $aresult = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hdc, "handle", $hgdiobj)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_sethandleinformation($hobject, $imask, $iflags)
- Local $aresult = DllCall("kernel32.dll", "bool", "SetHandleInformation", "handle", $hobject, "dword", $imask, "dword", $iflags)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- #EndRegion Public Functions
- Global Const $linguistic_ignorecase = 16
- Global Const $linguistic_ignorediacritic = 32
- Global Const $norm_ignorecase = 1
- Global Const $norm_ignorekanatype = 65536
- Global Const $norm_ignorenonspace = 2
- Global Const $norm_ignoresymbols = 4
- Global Const $norm_ignorewidth = 131072
- Global Const $norm_linguistic_casing = 134217728
- Global Const $sort_digitsasnumbers = 8
- Global Const $sort_stringsort = 4096
- Global Const $cstr_less_than = 1
- Global Const $cstr_equal = 2
- Global Const $cstr_greater_than = 3
- Global Const $mui_language_id = 4
- Global Const $mui_language_name = 8
- Global Const $date_autolayout = 64
- Global Const $date_longdate = 2
- Global Const $date_ltrreading = 16
- Global Const $date_shortdate = 1
- Global Const $date_rtlreading = 32
- Global Const $date_use_alt_calendar = 4
- Global Const $date_yearmonth = 8
- Global Const $geo_nation = 1
- Global Const $geo_latitude = 2
- Global Const $geo_longitude = 3
- Global Const $geo_iso2 = 4
- Global Const $geo_iso3 = 5
- Global Const $geo_rfc1766 = 6
- Global Const $geo_lcid = 7
- Global Const $geo_friendlyname = 8
- Global Const $geo_officialname = 9
- Global Const $geo_timezones = 10
- Global Const $geo_officiallanguages = 11
- Global Const $geo_iso_un_number = 12
- Global Const $geo_parent = 13
- Global Const $locale_ilanguage = 1
- Global Const $locale_slanguage = 2
- Global Const $locale_senglanguage = 4097
- Global Const $locale_sabbrevlangname = 3
- Global Const $locale_snativelangname = 4
- Global Const $locale_icountry = 5
- Global Const $locale_scountry = 6
- Global Const $locale_sengcountry = 4098
- Global Const $locale_sabbrevctryname = 7
- Global Const $locale_snativectryname = 8
- Global Const $locale_idefaultlanguage = 9
- Global Const $locale_idefaultcountry = 10
- Global Const $locale_idefaultcodepage = 11
- Global Const $locale_idefaultansicodepage = 4100
- Global Const $locale_idefaultmaccodepage = 4113
- Global Const $locale_slist = 12
- Global Const $locale_imeasure = 13
- Global Const $locale_sdecimal = 14
- Global Const $locale_sthousand = 15
- Global Const $locale_sgrouping = 16
- Global Const $locale_idigits = 17
- Global Const $locale_ilzero = 18
- Global Const $locale_inegnumber = 4112
- Global Const $locale_snativedigits = 19
- Global Const $locale_scurrency = 20
- Global Const $locale_sintlsymbol = 21
- Global Const $locale_smondecimalsep = 22
- Global Const $locale_smonthousandsep = 23
- Global Const $locale_smongrouping = 24
- Global Const $locale_icurrdigits = 25
- Global Const $locale_iintlcurrdigits = 26
- Global Const $locale_icurrency = 27
- Global Const $locale_inegcurr = 28
- Global Const $locale_sdate = 29
- Global Const $locale_stime = 30
- Global Const $locale_sshortdate = 31
- Global Const $locale_slongdate = 32
- Global Const $locale_stimeformat = 4099
- Global Const $locale_idate = 33
- Global Const $locale_ildate = 34
- Global Const $locale_itime = 35
- Global Const $locale_itimemarkposn = 4101
- Global Const $locale_icentury = 36
- Global Const $locale_itlzero = 37
- Global Const $locale_idaylzero = 38
- Global Const $locale_imonlzero = 39
- Global Const $locale_s1159 = 40
- Global Const $locale_s2359 = 41
- Global Const $locale_icalendartype = 4105
- Global Const $locale_ioptionalcalendar = 4107
- Global Const $locale_ifirstdayofweek = 4108
- Global Const $locale_ifirstweekofyear = 4109
- Global Const $locale_sdayname1 = 42
- Global Const $locale_sdayname2 = 43
- Global Const $locale_sdayname3 = 44
- Global Const $locale_sdayname4 = 45
- Global Const $locale_sdayname5 = 46
- Global Const $locale_sdayname6 = 47
- Global Const $locale_sdayname7 = 48
- Global Const $locale_sabbrevdayname1 = 49
- Global Const $locale_sabbrevdayname2 = 50
- Global Const $locale_sabbrevdayname3 = 51
- Global Const $locale_sabbrevdayname4 = 52
- Global Const $locale_sabbrevdayname5 = 53
- Global Const $locale_sabbrevdayname6 = 54
- Global Const $locale_sabbrevdayname7 = 55
- Global Const $locale_smonthname1 = 56
- Global Const $locale_smonthname2 = 57
- Global Const $locale_smonthname3 = 58
- Global Const $locale_smonthname4 = 59
- Global Const $locale_smonthname5 = 60
- Global Const $locale_smonthname6 = 61
- Global Const $locale_smonthname7 = 62
- Global Const $locale_smonthname8 = 63
- Global Const $locale_smonthname9 = 64
- Global Const $locale_smonthname10 = 65
- Global Const $locale_smonthname11 = 66
- Global Const $locale_smonthname12 = 67
- Global Const $locale_smonthname13 = 4110
- Global Const $locale_sabbrevmonthname1 = 68
- Global Const $locale_sabbrevmonthname2 = 69
- Global Const $locale_sabbrevmonthname3 = 70
- Global Const $locale_sabbrevmonthname4 = 71
- Global Const $locale_sabbrevmonthname5 = 72
- Global Const $locale_sabbrevmonthname6 = 73
- Global Const $locale_sabbrevmonthname7 = 74
- Global Const $locale_sabbrevmonthname8 = 75
- Global Const $locale_sabbrevmonthname9 = 76
- Global Const $locale_sabbrevmonthname10 = 77
- Global Const $locale_sabbrevmonthname11 = 78
- Global Const $locale_sabbrevmonthname12 = 79
- Global Const $locale_sabbrevmonthname13 = 4111
- Global Const $locale_spositivesign = 80
- Global Const $locale_snegativesign = 81
- Global Const $locale_ipossignposn = 82
- Global Const $locale_inegsignposn = 83
- Global Const $locale_ipossymprecedes = 84
- Global Const $locale_ipossepbyspace = 85
- Global Const $locale_inegsymprecedes = 86
- Global Const $locale_inegsepbyspace = 87
- Global Const $locale_fontsignature = 88
- Global Const $locale_siso639langname = 89
- Global Const $locale_siso3166ctryname = 90
- Global Const $locale_idefaultebcdiccodepage = 4114
- Global Const $locale_ipapersize = 4106
- Global Const $locale_sengcurrname = 4103
- Global Const $locale_snativecurrname = 4104
- Global Const $locale_syearmonth = 4102
- Global Const $locale_ssortname = 4115
- Global Const $locale_idigitsubstitution = 4116
- Global Const $locale_custom_default = 3072
- Global Const $locale_custom_ui_default = 5120
- Global Const $locale_custom_unspecified = 4096
- Global Const $locale_invariant = 127
- Global Const $locale_system_default = 2048
- Global Const $locale_user_default = 1024
- Global Const $time_force24hourformat = 8
- Global Const $time_nominutesorseconds = 1
- Global Const $time_noseconds = 2
- Global Const $time_notimemarker = 4
- Global Const $lcid_installed = 1
- Global Const $lcid_supported = 2
- #Region Global Variables and Constants
- Global Const $tagnumberfmt = "uint NumDigits;uint LeadingZero;uint Grouping;ptr DecimalSep;ptr ThousandSep;uint NegativeOrder"
- #EndRegion Global Variables and Constants
- #Region Functions list
- #EndRegion Functions list
- #Region Public Functions
- Func _winapi_comparestring($ilcid, $sstring1, $sstring2, $iflags = 0)
- Local $aret = DllCall("kernel32.dll", "int", "CompareStringW", "dword", $ilcid, "dword", $iflags, "wstr", $sstring1, "int", -1, "wstr", $sstring2, "int", -1)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_createnumberformatinfo($inumdigits, $ileadingzero, $igrouping, $sdecimalsep, $sthousandsep, $inegativeorder)
- Local $tfmt = DllStructCreate($tagnumberfmt & ";wchar[" & (StringLen($sdecimalsep) + 1) & "];wchar[" & (StringLen($sthousandsep) + 1) & "]")
- DllStructSetData($tfmt, 1, $inumdigits)
- DllStructSetData($tfmt, 2, $ileadingzero)
- DllStructSetData($tfmt, 3, $igrouping)
- DllStructSetData($tfmt, 4, DllStructGetPtr($tfmt, 7))
- DllStructSetData($tfmt, 5, DllStructGetPtr($tfmt, 8))
- DllStructSetData($tfmt, 6, $inegativeorder)
- DllStructSetData($tfmt, 7, $sdecimalsep)
- DllStructSetData($tfmt, 8, $sthousandsep)
- Return $tfmt
- EndFunc
- Func _winapi_enumsystemgeoid()
- Local $henumproc = DllCallbackRegister("__EnumGeoIDProc", "bool", "long")
- Dim $__g_venum[101] = [0]
- Local $aret = DllCall("kernel32.dll", "bool", "EnumSystemGeoID", "dword", 16, "long", 0, "ptr", DllCallbackGetPtr($henumproc))
- If @error OR NOT $aret[0] OR NOT $__g_venum[0] Then
- $__g_venum = @error + 10
- EndIf
- DllCallbackFree($henumproc)
- If $__g_venum Then Return SetError($__g_venum, 0, 0)
- __inc($__g_venum, -1)
- Return $__g_venum
- EndFunc
- Func _winapi_enumsystemlocales($iflag)
- Local $henumproc = DllCallbackRegister("__EnumLocalesProc", "bool", "ptr")
- Dim $__g_venum[101] = [0]
- Local $aret = DllCall("kernel32.dll", "bool", "EnumSystemLocalesW", "ptr", DllCallbackGetPtr($henumproc), "dword", $iflag)
- If @error OR NOT $aret[0] OR NOT $__g_venum[0] Then
- $__g_venum = @error + 10
- EndIf
- DllCallbackFree($henumproc)
- If $__g_venum Then Return SetError($__g_venum, 0, 0)
- __inc($__g_venum, -1)
- Return $__g_venum
- EndFunc
- Func _winapi_enumuilanguages($iflag = 0)
- Local $henumproc = DllCallbackRegister("__EnumUILanguagesProc", "bool", "ptr;long_ptr")
- Local $iid = 1
- If $__winver >= 1536 Then
- If BitAND($iflag, 8) Then
- $iid = 0
- EndIf
- Else
- $iflag = 0
- EndIf
- Dim $__g_venum[101] = [0]
- Local $aret = DllCall("kernel32.dll", "bool", "EnumUILanguagesW", "ptr", DllCallbackGetPtr($henumproc), "dword", $iflag, "long_ptr", $iid)
- If @error OR NOT $aret[0] OR NOT $__g_venum[0] Then
- $__g_venum = @error + 10
- EndIf
- DllCallbackFree($henumproc)
- If $__g_venum Then Return SetError($__g_venum, 0, 0)
- __inc($__g_venum, -1)
- Return $__g_venum
- EndFunc
- Func _winapi_getdateformat($ilcid = 0, $tsystemtime = 0, $iflags = 0, $sformat = "")
- If NOT $ilcid Then $ilcid = 1024
- Local $stypeofformat = "wstr"
- If NOT StringStripWS($sformat, $str_stripleading + $str_striptrailing) Then
- $stypeofformat = "ptr"
- $sformat = 0
- EndIf
- Local $aret = DllCall("kernel32.dll", "int", "GetDateFormatW", "dword", $ilcid, "dword", $iflags, "struct*", $tsystemtime, $stypeofformat, $sformat, "wstr", "", "int", 2048)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return $aret[5]
- EndFunc
- Func _winapi_getdurationformat($ilcid, $iduration, $sformat = "")
- If NOT $ilcid Then $ilcid = 1024
- Local $pst, $ival
- If IsDllStruct($iduration) Then
- $pst = DllStructGetPtr($iduration)
- $ival = 0
- Else
- $pst = 0
- $ival = $iduration
- EndIf
- Local $stypeofformat = "wstr"
- If NOT StringStripWS($sformat, $str_stripleading + $str_striptrailing) Then
- $stypeofformat = "ptr"
- $sformat = 0
- EndIf
- Local $aret = DllCall("kernel32.dll", "int", "GetDurationFormat", "dword", $ilcid, "dword", 0, "ptr", $pst, "uint64", $ival, $stypeofformat, $sformat, "wstr", "", "int", 2048)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return $aret[6]
- EndFunc
- Func _winapi_getgeoinfo($igeoid, $itype, $ilanguage = 0)
- Local $aret = DllCall("kernel32.dll", "int", "GetGeoInfoW", "long", $igeoid, "dword", $itype, "wstr", "", "int", 4096, "word", $ilanguage)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
- Return $aret[3]
- EndFunc
- Func _winapi_getlocaleinfo($ilcid, $itype)
- Local $aret = DllCall("kernel32.dll", "int", "GetLocaleInfoW", "dword", $ilcid, "dword", $itype, "wstr", "", "int", 2048)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
- Return $aret[3]
- EndFunc
- Func _winapi_getnumberformat($ilcid, $snumber, $tnumberfmt = 0)
- If NOT $ilcid Then $ilcid = 1024
- Local $aret = DllCall("kernel32.dll", "int", "GetNumberFormatW", "dword", $ilcid, "dword", 0, "wstr", $snumber, "struct*", $tnumberfmt, "wstr", "", "int", 2048)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return $aret[5]
- EndFunc
- Func _winapi_getsystemdefaultlangid()
- Local $aret = DllCall("kernel32.dll", "word", "GetSystemDefaultLangID")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getsystemdefaultlcid()
- Local $aret = DllCall("kernel32.dll", "dword", "GetSystemDefaultLCID")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getsystemdefaultuilanguage()
- Local $aret = DllCall("kernel32.dll", "word", "GetSystemDefaultUILanguage")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getthreadlocale()
- Local $aret = DllCall("kernel32.dll", "dword", "GetThreadLocale")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getthreaduilanguage()
- Local $aret = DllCall("kernel32.dll", "word", "GetThreadUILanguage")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_gettimeformat($ilcid = 0, $tsystemtime = 0, $iflags = 0, $sformat = "")
- If NOT $ilcid Then $ilcid = 1024
- Local $stypeofformat = "wstr"
- If NOT StringStripWS($sformat, $str_stripleading + $str_striptrailing) Then
- $stypeofformat = "ptr"
- $sformat = 0
- EndIf
- Local $aret = DllCall("kernel32.dll", "int", "GetTimeFormatW", "dword", $ilcid, "dword", $iflags, "struct*", $tsystemtime, $stypeofformat, $sformat, "wstr", "", "int", 2048)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
- Return $aret[5]
- EndFunc
- Func _winapi_getuserdefaultlangid()
- Local $aret = DllCall("kernel32.dll", "word", "GetUserDefaultLangID")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getuserdefaultlcid()
- Local $aret = DllCall("kernel32.dll", "dword", "GetUserDefaultLCID")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getuserdefaultuilanguage()
- Local $aret = DllCall("kernel32.dll", "word", "GetUserDefaultUILanguage")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getusergeoid()
- Local $aret = DllCall("kernel32.dll", "long", "GetUserGeoID", "uint", 16)
- If @error Then Return SetError(@error, @extended, -1)
- Return $aret[0]
- EndFunc
- Func _winapi_isvalidlocale($ilcid, $iflag = 0)
- Local $aret = DllCall("kernel32.dll", "bool", "IsValidLocale", "dword", $ilcid, "dword", $iflag)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_setlocaleinfo($ilcid, $itype, $sdata)
- Local $aret = DllCall("kernel32.dll", "bool", "SetLocaleInfoW", "dword", $ilcid, "dword", $itype, "wstr", $sdata)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_setthreadlocale($ilcid)
- Local $aret = DllCall("kernel32.dll", "bool", "SetThreadLocale", "dword", $ilcid)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_setthreaduilanguage($ilanguage)
- Local $aret = DllCall("kernel32.dll", "word", "SetThreadUILanguage", "word", $ilanguage)
- If @error Then Return SetError(@error, @extended, False)
- Return ($aret[0] = $aret[1])
- EndFunc
- Func _winapi_setusergeoid($igeoid)
- Local $aret = DllCall("kernel32.dll", "bool", "SetUserGeoID", "long", $igeoid)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- #EndRegion Public Functions
- #Region Internal Functions
- Func __enumgeoidproc($iid)
- __inc($__g_venum)
- $__g_venum[$__g_venum[0]] = $iid
- Return 1
- EndFunc
- Func __enumlocalesproc($plocale)
- __inc($__g_venum)
- $__g_venum[$__g_venum[0]] = Dec(DllStructGetData(DllStructCreate("wchar[" & (_winapi_strlen($plocale) + 1) & "]", $plocale), 1))
- Return 1
- EndFunc
- Func __enumuilanguagesproc($planguage, $iid)
- __inc($__g_venum)
- $__g_venum[$__g_venum[0]] = DllStructGetData(DllStructCreate("wchar[" & (_winapi_strlen($planguage) + 1) & "]", $planguage), 1)
- If $iid Then
- $__g_venum[$__g_venum[0]] = Dec($__g_venum[$__g_venum[0]])
- EndIf
- Return 1
- EndFunc
- #EndRegion Internal Functions
- Func _dateadd($stype, $inumber, $sdate)
- Local $astimepart[4]
- Local $asdatepart[4]
- Local $ijuliandate
- $stype = StringLeft($stype, 1)
- If StringInStr("D,M,Y,w,h,n,s", $stype) = 0 OR $stype = "" Then
- Return SetError(1, 0, 0)
- EndIf
- If NOT StringIsInt($inumber) Then
- Return SetError(2, 0, 0)
- EndIf
- If NOT _dateisvalid($sdate) Then
- Return SetError(3, 0, 0)
- EndIf
- _datetimesplit($sdate, $asdatepart, $astimepart)
- If $stype = "d" OR $stype = "w" Then
- If $stype = "w" Then $inumber = $inumber * 7
- $ijuliandate = _datetodayvalue($asdatepart[1], $asdatepart[2], $asdatepart[3]) + $inumber
- _dayvaluetodate($ijuliandate, $asdatepart[1], $asdatepart[2], $asdatepart[3])
- EndIf
- If $stype = "m" Then
- $asdatepart[2] = $asdatepart[2] + $inumber
- While $asdatepart[2] > 12
- $asdatepart[2] = $asdatepart[2] - 12
- $asdatepart[1] = $asdatepart[1] + 1
- WEnd
- While $asdatepart[2] < 1
- $asdatepart[2] = $asdatepart[2] + 12
- $asdatepart[1] = $asdatepart[1] - 1
- WEnd
- EndIf
- If $stype = "y" Then
- $asdatepart[1] = $asdatepart[1] + $inumber
- EndIf
- If $stype = "h" OR $stype = "n" OR $stype = "s" Then
- Local $itimeval = _timetoticks($astimepart[1], $astimepart[2], $astimepart[3]) / 1000
- If $stype = "h" Then $itimeval = $itimeval + $inumber * 3600
- If $stype = "n" Then $itimeval = $itimeval + $inumber * 60
- If $stype = "s" Then $itimeval = $itimeval + $inumber
- Local $iday2add = Int($itimeval / (24 * 60 * 60))
- $itimeval = $itimeval - $iday2add * 24 * 60 * 60
- If $itimeval < 0 Then
- $iday2add = $iday2add - 1
- $itimeval = $itimeval + 24 * 60 * 60
- EndIf
- $ijuliandate = _datetodayvalue($asdatepart[1], $asdatepart[2], $asdatepart[3]) + $iday2add
- _dayvaluetodate($ijuliandate, $asdatepart[1], $asdatepart[2], $asdatepart[3])
- _tickstotime($itimeval * 1000, $astimepart[1], $astimepart[2], $astimepart[3])
- EndIf
- Local $inumdays = _daysinmonth($asdatepart[1])
- If $inumdays[$asdatepart[2]] < $asdatepart[3] Then $asdatepart[3] = $inumdays[$asdatepart[2]]
- $sdate = $asdatepart[1] & "/" & StringRight("0" & $asdatepart[2], 2) & "/" & StringRight("0" & $asdatepart[3], 2)
- If $astimepart[0] > 0 Then
- If $astimepart[0] > 2 Then
- $sdate = $sdate & " " & StringRight("0" & $astimepart[1], 2) & ":" & StringRight("0" & $astimepart[2], 2) & ":" & StringRight("0" & $astimepart[3], 2)
- Else
- $sdate = $sdate & " " & StringRight("0" & $astimepart[1], 2) & ":" & StringRight("0" & $astimepart[2], 2)
- EndIf
- EndIf
- Return $sdate
- EndFunc
- Func _datedayofweek($idaynum, $iformat = Default)
- Local Const $monday_is_no1 = 128
- If $iformat = Default Then $iformat = 0
- $idaynum = Int($idaynum)
- If $idaynum < 1 OR $idaynum > 7 Then Return SetError(1, 0, "")
- Local $tsystemtime = DllStructCreate($tagsystemtime)
- DllStructSetData($tsystemtime, "Year", BitAND($iformat, $monday_is_no1) ? 2007 : 2006)
- DllStructSetData($tsystemtime, "Month", 1)
- DllStructSetData($tsystemtime, "Day", $idaynum)
- Return _winapi_getdateformat(BitAND($iformat, $dmw_locale_longname) ? $locale_user_default : $locale_invariant, $tsystemtime, 0, BitAND($iformat, $dmw_shortname) ? "ddd" : "dddd")
- EndFunc
- Func _datedaysinmonth($iyear, $imonthnum)
- $imonthnum = Int($imonthnum)
- $iyear = Int($iyear)
- Return __dateismonth($imonthnum) AND __dateisyear($iyear) ? _daysinmonth($iyear)[$imonthnum] : SetError(1, 0, 0)
- EndFunc
- Func _datediff($stype, $sstartdate, $senddate)
- $stype = StringLeft($stype, 1)
- If StringInStr("d,m,y,w,h,n,s", $stype) = 0 OR $stype = "" Then
- Return SetError(1, 0, 0)
- EndIf
- If NOT _dateisvalid($sstartdate) Then
- Return SetError(2, 0, 0)
- EndIf
- If NOT _dateisvalid($senddate) Then
- Return SetError(3, 0, 0)
- EndIf
- Local $asstartdatepart[4], $asstarttimepart[4], $asenddatepart[4], $asendtimepart[4]
- _datetimesplit($sstartdate, $asstartdatepart, $asstarttimepart)
- _datetimesplit($senddate, $asenddatepart, $asendtimepart)
- Local $adaysdiff = _datetodayvalue($asenddatepart[1], $asenddatepart[2], $asenddatepart[3]) - _datetodayvalue($asstartdatepart[1], $asstartdatepart[2], $asstartdatepart[3])
- Local $itimediff, $iyeardiff, $istarttimeinsecs, $iendtimeinsecs
- If $asstarttimepart[0] > 1 AND $asendtimepart[0] > 1 Then
- $istarttimeinsecs = $asstarttimepart[1] * 3600 + $asstarttimepart[2] * 60 + $asstarttimepart[3]
- $iendtimeinsecs = $asendtimepart[1] * 3600 + $asendtimepart[2] * 60 + $asendtimepart[3]
- $itimediff = $iendtimeinsecs - $istarttimeinsecs
- If $itimediff < 0 Then
- $adaysdiff = $adaysdiff - 1
- $itimediff = $itimediff + 24 * 60 * 60
- EndIf
- Else
- $itimediff = 0
- EndIf
- Select
- Case $stype = "d"
- Return $adaysdiff
- Case $stype = "m"
- $iyeardiff = $asenddatepart[1] - $asstartdatepart[1]
- Local $imonthdiff = $asenddatepart[2] - $asstartdatepart[2] + $iyeardiff * 12
- If $asenddatepart[3] < $asstartdatepart[3] Then $imonthdiff = $imonthdiff - 1
- $istarttimeinsecs = $asstarttimepart[1] * 3600 + $asstarttimepart[2] * 60 + $asstarttimepart[3]
- $iendtimeinsecs = $asendtimepart[1] * 3600 + $asendtimepart[2] * 60 + $asendtimepart[3]
- $itimediff = $iendtimeinsecs - $istarttimeinsecs
- If $asenddatepart[3] = $asstartdatepart[3] AND $itimediff < 0 Then $imonthdiff = $imonthdiff - 1
- Return $imonthdiff
- Case $stype = "y"
- $iyeardiff = $asenddatepart[1] - $asstartdatepart[1]
- If $asenddatepart[2] < $asstartdatepart[2] Then $iyeardiff = $iyeardiff - 1
- If $asenddatepart[2] = $asstartdatepart[2] AND $asenddatepart[3] < $asstartdatepart[3] Then $iyeardiff = $iyeardiff - 1
- $istarttimeinsecs = $asstarttimepart[1] * 3600 + $asstarttimepart[2] * 60 + $asstarttimepart[3]
- $iendtimeinsecs = $asendtimepart[1] * 3600 + $asendtimepart[2] * 60 + $asendtimepart[3]
- $itimediff = $iendtimeinsecs - $istarttimeinsecs
- If $asenddatepart[2] = $asstartdatepart[2] AND $asenddatepart[3] = $asstartdatepart[3] AND $itimediff < 0 Then $iyeardiff = $iyeardiff - 1
- Return $iyeardiff
- Case $stype = "w"
- Return Int($adaysdiff / 7)
- Case $stype = "h"
- Return $adaysdiff * 24 + Int($itimediff / 3600)
- Case $stype = "n"
- Return $adaysdiff * 24 * 60 + Int($itimediff / 60)
- Case $stype = "s"
- Return $adaysdiff * 24 * 60 * 60 + $itimediff
- EndSelect
- EndFunc
- Func _dateisleapyear($iyear)
- If StringIsInt($iyear) Then
- Select
- Case Mod($iyear, 4) = 0 AND Mod($iyear, 100) <> 0
- Return 1
- Case Mod($iyear, 400) = 0
- Return 1
- Case Else
- Return 0
- EndSelect
- EndIf
- Return SetError(1, 0, 0)
- EndFunc
- Func __dateismonth($inumber)
- $inumber = Int($inumber)
- Return $inumber >= 1 AND $inumber <= 12
- EndFunc
- Func _dateisvalid($sdate)
- Local $asdatepart[4], $astimepart[4]
- _datetimesplit($sdate, $asdatepart, $astimepart)
- If NOT StringIsInt($asdatepart[1]) Then Return 0
- If NOT StringIsInt($asdatepart[2]) Then Return 0
- If NOT StringIsInt($asdatepart[3]) Then Return 0
- $asdatepart[1] = Int($asdatepart[1])
- $asdatepart[2] = Int($asdatepart[2])
- $asdatepart[3] = Int($asdatepart[3])
- Local $inumdays = _daysinmonth($asdatepart[1])
- If $asdatepart[1] < 1000 OR $asdatepart[1] > 2999 Then Return 0
- If $asdatepart[2] < 1 OR $asdatepart[2] > 12 Then Return 0
- If $asdatepart[3] < 1 OR $asdatepart[3] > $inumdays[$asdatepart[2]] Then Return 0
- If $astimepart[0] < 1 Then Return 1
- If $astimepart[0] < 2 Then Return 0
- If $astimepart[0] = 2 Then $astimepart[3] = "00"
- If NOT StringIsInt($astimepart[1]) Then Return 0
- If NOT StringIsInt($astimepart[2]) Then Return 0
- If NOT StringIsInt($astimepart[3]) Then Return 0
- $astimepart[1] = Int($astimepart[1])
- $astimepart[2] = Int($astimepart[2])
- $astimepart[3] = Int($astimepart[3])
- If $astimepart[1] < 0 OR $astimepart[1] > 23 Then Return 0
- If $astimepart[2] < 0 OR $astimepart[2] > 59 Then Return 0
- If $astimepart[3] < 0 OR $astimepart[3] > 59 Then Return 0
- Return 1
- EndFunc
- Func __dateisyear($inumber)
- Return StringLen($inumber) = 4
- EndFunc
- Func _datelastweekdaynum($iweekdaynum)
- Select
- Case NOT StringIsInt($iweekdaynum)
- Return SetError(1, 0, 0)
- Case $iweekdaynum < 1 OR $iweekdaynum > 7
- Return SetError(2, 0, 0)
- Case Else
- Local $ilastweekdaynum
- If $iweekdaynum = 1 Then
- $ilastweekdaynum = 7
- Else
- $ilastweekdaynum = $iweekdaynum - 1
- EndIf
- Return $ilastweekdaynum
- EndSelect
- EndFunc
- Func _datelastmonthnum($imonthnum)
- Select
- Case NOT StringIsInt($imonthnum)
- Return SetError(1, 0, 0)
- Case NOT __dateismonth($imonthnum)
- Return SetError(2, 0, 0)
- Case Else
- Local $ilastmonthnum
- If $imonthnum = 1 Then
- $ilastmonthnum = 12
- Else
- $ilastmonthnum = $imonthnum - 1
- EndIf
- $ilastmonthnum = StringFormat("%02d", $ilastmonthnum)
- Return $ilastmonthnum
- EndSelect
- EndFunc
- Func _datelastmonthyear($imonthnum, $iyear)
- Select
- Case NOT StringIsInt($imonthnum) OR NOT StringIsInt($iyear)
- Return SetError(1, 0, 0)
- Case NOT __dateismonth($imonthnum)
- Return SetError(2, 0, 0)
- Case Else
- Local $ilastyear
- If $imonthnum = 1 Then
- $ilastyear = $iyear - 1
- Else
- $ilastyear = $iyear
- EndIf
- $ilastyear = StringFormat("%04d", $ilastyear)
- Return $ilastyear
- EndSelect
- EndFunc
- Func _datenextweekdaynum($iweekdaynum)
- Select
- Case NOT StringIsInt($iweekdaynum)
- Return SetError(1, 0, 0)
- Case $iweekdaynum < 1 OR $iweekdaynum > 7
- Return SetError(2, 0, 0)
- Case Else
- Local $inextweekdaynum
- If $iweekdaynum = 7 Then
- $inextweekdaynum = 1
- Else
- $inextweekdaynum = $iweekdaynum + 1
- EndIf
- Return $inextweekdaynum
- EndSelect
- EndFunc
- Func _datenextmonthnum($imonthnum)
- Select
- Case NOT StringIsInt($imonthnum)
- Return SetError(1, 0, 0)
- Case NOT __dateismonth($imonthnum)
- Return SetError(2, 0, 0)
- Case Else
- Local $inextmonthnum
- If $imonthnum = 12 Then
- $inextmonthnum = 1
- Else
- $inextmonthnum = $imonthnum + 1
- EndIf
- $inextmonthnum = StringFormat("%02d", $inextmonthnum)
- Return $inextmonthnum
- EndSelect
- EndFunc
- Func _datenextmonthyear($imonthnum, $iyear)
- Select
- Case NOT StringIsInt($imonthnum) OR NOT StringIsInt($iyear)
- Return SetError(1, 0, 0)
- Case NOT __dateismonth($imonthnum)
- Return SetError(2, 0, 0)
- Case Else
- Local $inextyear
- If $imonthnum = 12 Then
- $inextyear = $iyear + 1
- Else
- $inextyear = $iyear
- EndIf
- $inextyear = StringFormat("%04d", $inextyear)
- Return $inextyear
- EndSelect
- EndFunc
- Func _datetimeformat($sdate, $stype)
- Local $asdatepart[4], $astimepart[4]
- Local $stempdate = "", $stemptime = ""
- Local $sam, $spm, $stempstring = ""
- If NOT _dateisvalid($sdate) Then
- Return SetError(1, 0, "")
- EndIf
- If $stype < 0 OR $stype > 5 OR NOT IsInt($stype) Then
- Return SetError(2, 0, "")
- EndIf
- _datetimesplit($sdate, $asdatepart, $astimepart)
- Switch $stype
- Case 0
- $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_sshortdate)
- If NOT @error AND NOT ($stempstring = "") Then
- $stempdate = $stempstring
- Else
- $stempdate = "M/d/yyyy"
- EndIf
- If $astimepart[0] > 1 Then
- $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_stimeformat)
- If NOT @error AND NOT ($stempstring = "") Then
- $stemptime = $stempstring
- Else
- $stemptime = "h:mm:ss tt"
- EndIf
- EndIf
- Case 1
- $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_slongdate)
- If NOT @error AND NOT ($stempstring = "") Then
- $stempdate = $stempstring
- Else
- $stempdate = "dddd, MMMM dd, yyyy"
- EndIf
- Case 2
- $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_sshortdate)
- If NOT @error AND NOT ($stempstring = "") Then
- $stempdate = $stempstring
- Else
- $stempdate = "M/d/yyyy"
- EndIf
- Case 3
- If $astimepart[0] > 1 Then
- $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_stimeformat)
- If NOT @error AND NOT ($stempstring = "") Then
- $stemptime = $stempstring
- Else
- $stemptime = "h:mm:ss tt"
- EndIf
- EndIf
- Case 4
- If $astimepart[0] > 1 Then
- $stemptime = "hh:mm"
- EndIf
- Case 5
- If $astimepart[0] > 1 Then
- $stemptime = "hh:mm:ss"
- EndIf
- EndSwitch
- If $stempdate <> "" Then
- $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_sdate)
- If NOT @error AND NOT ($stempstring = "") Then
- $stempdate = StringReplace($stempdate, "/", $stempstring)
- EndIf
- Local $iwday = _datetodayofweek($asdatepart[1], $asdatepart[2], $asdatepart[3])
- $asdatepart[3] = StringRight("0" & $asdatepart[3], 2)
- $asdatepart[2] = StringRight("0" & $asdatepart[2], 2)
- $stempdate = StringReplace($stempdate, "d", "@")
- $stempdate = StringReplace($stempdate, "m", "#")
- $stempdate = StringReplace($stempdate, "y", "&")
- $stempdate = StringReplace($stempdate, "@@@@", _datedayofweek($iwday, 0))
- $stempdate = StringReplace($stempdate, "@@@", _datedayofweek($iwday, 1))
- $stempdate = StringReplace($stempdate, "@@", $asdatepart[3])
- $stempdate = StringReplace($stempdate, "@", StringReplace(StringLeft($asdatepart[3], 1), "0", "") & StringRight($asdatepart[3], 1))
- $stempdate = StringReplace($stempdate, "####", _datetomonth($asdatepart[2], 0))
- $stempdate = StringReplace($stempdate, "###", _datetomonth($asdatepart[2], 1))
- $stempdate = StringReplace($stempdate, "##", $asdatepart[2])
- $stempdate = StringReplace($stempdate, "#", StringReplace(StringLeft($asdatepart[2], 1), "0", "") & StringRight($asdatepart[2], 1))
- $stempdate = StringReplace($stempdate, "&&&&", $asdatepart[1])
- $stempdate = StringReplace($stempdate, "&&", StringRight($asdatepart[1], 2))
- EndIf
- If $stemptime <> "" Then
- $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_s1159)
- If NOT @error AND NOT ($stempstring = "") Then
- $sam = $stempstring
- Else
- $sam = "AM"
- EndIf
- $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_s2359)
- If NOT @error AND NOT ($stempstring = "") Then
- $spm = $stempstring
- Else
- $spm = "PM"
- EndIf
- $stempstring = _winapi_getlocaleinfo($locale_user_default, $locale_stime)
- If NOT @error AND NOT ($stempstring = "") Then
- $stemptime = StringReplace($stemptime, ":", $stempstring)
- EndIf
- If StringInStr($stemptime, "tt") Then
- If $astimepart[1] < 12 Then
- $stemptime = StringReplace($stemptime, "tt", $sam)
- If $astimepart[1] = 0 Then $astimepart[1] = 12
- Else
- $stemptime = StringReplace($stemptime, "tt", $spm)
- If $astimepart[1] > 12 Then $astimepart[1] = $astimepart[1] - 12
- EndIf
- EndIf
- $astimepart[1] = StringRight("0" & $astimepart[1], 2)
- $astimepart[2] = StringRight("0" & $astimepart[2], 2)
- $astimepart[3] = StringRight("0" & $astimepart[3], 2)
- $stemptime = StringReplace($stemptime, "hh", StringFormat("%02d", $astimepart[1]))
- $stemptime = StringReplace($stemptime, "h", StringReplace(StringLeft($astimepart[1], 1), "0", "") & StringRight($astimepart[1], 1))
- $stemptime = StringReplace($stemptime, "mm", StringFormat("%02d", $astimepart[2]))
- $stemptime = StringReplace($stemptime, "ss", StringFormat("%02d", $astimepart[3]))
- $stempdate = StringStripWS($stempdate & " " & $stemptime, $str_stripleading + $str_striptrailing)
- EndIf
- Return $stempdate
- EndFunc
- Func _datetimesplit($sdate, ByRef $adatepart, ByRef $itimepart)
- Local $sdatetime = StringSplit($sdate, " T")
- If $sdatetime[0] > 0 Then $adatepart = StringSplit($sdatetime[1], "/-.")
- If $sdatetime[0] > 1 Then
- $itimepart = StringSplit($sdatetime[2], ":")
- If UBound($itimepart) < 4 Then ReDim $itimepart[4]
- Else
- Dim $itimepart[4]
- EndIf
- If UBound($adatepart) < 4 Then ReDim $adatepart[4]
- For $x = 1 To 3
- If StringIsInt($adatepart[$x]) Then
- $adatepart[$x] = Int($adatepart[$x])
- Else
- $adatepart[$x] = -1
- EndIf
- If StringIsInt($itimepart[$x]) Then
- $itimepart[$x] = Int($itimepart[$x])
- Else
- $itimepart[$x] = 0
- EndIf
- Next
- Return 1
- EndFunc
- Func _datetodayofweek($iyear, $imonth, $iday)
- If NOT _dateisvalid($iyear & "/" & $imonth & "/" & $iday) Then
- Return SetError(1, 0, "")
- EndIf
- Local $i_factora = Int((14 - $imonth) / 12)
- Local $i_factory = $iyear - $i_factora
- Local $i_factorm = $imonth + (12 * $i_factora) - 2
- Local $i_factord = Mod($iday + $i_factory + Int($i_factory / 4) - Int($i_factory / 100) + Int($i_factory / 400) + Int((31 * $i_factorm) / 12), 7)
- Return $i_factord + 1
- EndFunc
- Func _datetodayofweekiso($iyear, $imonth, $iday)
- Local $idow = _datetodayofweek($iyear, $imonth, $iday)
- If @error Then
- Return SetError(1, 0, "")
- EndIf
- If $idow >= 2 Then Return $idow - 1
- Return 7
- EndFunc
- Func _datetodayvalue($iyear, $imonth, $iday)
- If NOT _dateisvalid(StringFormat("%04d/%02d/%02d", $iyear, $imonth, $iday)) Then
- Return SetError(1, 0, "")
- EndIf
- If $imonth < 3 Then
- $imonth = $imonth + 12
- $iyear = $iyear - 1
- EndIf
- Local $i_factora = Int($iyear / 100)
- Local $i_factorb = Int($i_factora / 4)
- Local $i_factorc = 2 - $i_factora + $i_factorb
- Local $i_factore = Int(1461 * ($iyear + 4716) / 4)
- Local $i_factorf = Int(153 * ($imonth + 1) / 5)
- Local $ijuliandate = $i_factorc + $iday + $i_factore + $i_factorf - 1524.5
- Return $ijuliandate
- EndFunc
- Func _datetomonth($imonnum, $iformat = Default)
- If $iformat = Default Then $iformat = 0
- $imonnum = Int($imonnum)
- If NOT __dateismonth($imonnum) Then Return SetError(1, 0, "")
- Local $tsystemtime = DllStructCreate($tagsystemtime)
- DllStructSetData($tsystemtime, "Year", @YEAR)
- DllStructSetData($tsystemtime, "Month", $imonnum)
- DllStructSetData($tsystemtime, "Day", 1)
- Return _winapi_getdateformat(BitAND($iformat, $dmw_locale_longname) ? $locale_user_default : $locale_invariant, $tsystemtime, 0, BitAND($iformat, $dmw_shortname) ? "MMM" : "MMMM")
- EndFunc
- Func _dayvaluetodate($ijuliandate, ByRef $iyear, ByRef $imonth, ByRef $iday)
- If $ijuliandate < 0 OR NOT IsNumber($ijuliandate) Then
- Return SetError(1, 0, 0)
- EndIf
- Local $i_factorz = Int($ijuliandate + 0.5)
- Local $i_factorw = Int(($i_factorz - 1867216.25) / 36524.25)
- Local $i_factorx = Int($i_factorw / 4)
- Local $i_factora = $i_factorz + 1 + $i_factorw - $i_factorx
- Local $i_factorb = $i_factora + 1524
- Local $i_factorc = Int(($i_factorb - 122.1) / 365.25)
- Local $i_factord = Int(365.25 * $i_factorc)
- Local $i_factore = Int(($i_factorb - $i_factord) / 30.6001)
- Local $i_factorf = Int(30.6001 * $i_factore)
- $iday = $i_factorb - $i_factord - $i_factorf
- If $i_factore - 1 < 13 Then
- $imonth = $i_factore - 1
- Else
- $imonth = $i_factore - 13
- EndIf
- If $imonth < 3 Then
- $iyear = $i_factorc - 4715
- Else
- $iyear = $i_factorc - 4716
- EndIf
- $iyear = StringFormat("%04d", $iyear)
- $imonth = StringFormat("%02d", $imonth)
- $iday = StringFormat("%02d", $iday)
- Return $iyear & "/" & $imonth & "/" & $iday
- EndFunc
- Func _date_juliandayno($iyear, $imonth, $iday)
- Local $sfulldate = StringFormat("%04d/%02d/%02d", $iyear, $imonth, $iday)
- If NOT _dateisvalid($sfulldate) Then
- Return SetError(1, 0, "")
- EndIf
- Local $ijday = 0
- Local $aidaysinmonth = _daysinmonth($iyear)
- For $icntr = 1 To $imonth - 1
- $ijday = $ijday + $aidaysinmonth[$icntr]
- Next
- $ijday = ($iyear * 1000) + ($ijday + $iday)
- Return $ijday
- EndFunc
- Func _juliantodate($ijday, $ssep = "/")
- Local $iyear = Int($ijday / 1000)
- Local $idays = Mod($ijday, 1000)
- Local $imaxdays = 365
- If _dateisleapyear($iyear) Then $imaxdays = 366
- If $idays > $imaxdays Then
- Return SetError(1, 0, "")
- EndIf
- Local $aidaysinmonth = _daysinmonth($iyear)
- Local $imonth = 1
- While $idays > $aidaysinmonth[$imonth]
- $idays = $idays - $aidaysinmonth[$imonth]
- $imonth = $imonth + 1
- WEnd
- Return StringFormat("%04d%s%02d%s%02d", $iyear, $ssep, $imonth, $ssep, $idays)
- EndFunc
- Func _now()
- Return _datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, 0)
- EndFunc
- Func _nowcalc()
- Return @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC
- EndFunc
- Func _nowcalcdate()
- Return @YEAR & "/" & @MON & "/" & @MDAY
- EndFunc
- Func _nowdate()
- Return _datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY, 0)
- EndFunc
- Func _nowtime($stype = 3)
- If $stype < 3 OR $stype > 5 Then $stype = 3
- Return _datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, $stype)
- EndFunc
- Func _setdate($iday, $imonth = 0, $iyear = 0)
- If $iyear = 0 Then $iyear = @YEAR
- If $imonth = 0 Then $imonth = @MON
- If NOT _dateisvalid($iyear & "/" & $imonth & "/" & $iday) Then Return 1
- Local $tsystemtime = DllStructCreate($tagsystemtime)
- DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsystemtime)
- If @error Then Return SetError(@error, @extended, 0)
- DllStructSetData($tsystemtime, "Day", $iday)
- If $imonth > 0 Then DllStructSetData($tsystemtime, "Month", $imonth)
- If $iyear > 0 Then DllStructSetData($tsystemtime, "Year", $iyear)
- Local $ireturn = _date_time_setlocaltime($tsystemtime)
- If @error Then Return SetError(@error + 10, @extended, 0)
- Return Int($ireturn)
- EndFunc
- Func _settime($ihour, $iminute, $isecond = 0, $imseconds = 0)
- If $ihour < 0 OR $ihour > 23 Then Return 1
- If $iminute < 0 OR $iminute > 59 Then Return 1
- If $isecond < 0 OR $isecond > 59 Then Return 1
- If $imseconds < 0 OR $imseconds > 999 Then Return 1
- Local $tsystemtime = DllStructCreate($tagsystemtime)
- DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsystemtime)
- If @error Then Return SetError(@error, @extended, 0)
- DllStructSetData($tsystemtime, "Hour", $ihour)
- DllStructSetData($tsystemtime, "Minute", $iminute)
- If $isecond > 0 Then DllStructSetData($tsystemtime, "Second", $isecond)
- If $imseconds > 0 Then DllStructSetData($tsystemtime, "MSeconds", $imseconds)
- Local $ireturn = _date_time_setlocaltime($tsystemtime)
- If @error Then Return SetError(@error + 10, @extended, 0)
- Return Int($ireturn)
- EndFunc
- Func _tickstotime($iticks, ByRef $ihours, ByRef $imins, ByRef $isecs)
- If Number($iticks) > 0 Then
- $iticks = Int($iticks / 1000)
- $ihours = Int($iticks / 3600)
- $iticks = Mod($iticks, 3600)
- $imins = Int($iticks / 60)
- $isecs = Mod($iticks, 60)
- Return 1
- ElseIf Number($iticks) = 0 Then
- $ihours = 0
- $iticks = 0
- $imins = 0
- $isecs = 0
- Return 1
- Else
- Return SetError(1, 0, 0)
- EndIf
- EndFunc
- Func _timetoticks($ihours = @HOUR, $imins = @MIN, $isecs = @SEC)
- If StringIsInt($ihours) AND StringIsInt($imins) AND StringIsInt($isecs) Then
- Local $iticks = 1000 * ((3600 * $ihours) + (60 * $imins) + $isecs)
- Return $iticks
- Else
- Return SetError(1, 0, 0)
- EndIf
- EndFunc
- Func _weeknumberiso($iyear = @YEAR, $imonth = @MON, $iday = @MDAY)
- If $iday > 31 OR $iday < 1 Then
- Return SetError(1, 0, -1)
- ElseIf NOT __dateismonth($imonth) Then
- Return SetError(2, 0, -1)
- ElseIf $iyear < 1 OR $iyear > 2999 Then
- Return SetError(3, 0, -1)
- EndIf
- Local $idow = _datetodayofweekiso($iyear, $imonth, $iday) - 1
- Local $idow0101 = _datetodayofweekiso($iyear, 1, 1) - 1
- If ($imonth = 1 AND 3 < $idow0101 AND $idow0101 < 7 - ($iday - 1)) Then
- $idow = $idow0101 - 1
- $idow0101 = _datetodayofweekiso($iyear - 1, 1, 1) - 1
- $imonth = 12
- $iday = 31
- $iyear = $iyear - 1
- ElseIf ($imonth = 12 AND 30 - ($iday - 1) < _datetodayofweekiso($iyear + 1, 1, 1) - 1 AND _datetodayofweekiso($iyear + 1, 1, 1) - 1 < 4) Then
- Return 1
- EndIf
- Return Int((_datetodayofweekiso($iyear, 1, 1) - 1 < 4) + 4 * ($imonth - 1) + (2 * ($imonth - 1) + ($iday - 1) + $idow0101 - $idow + 6) * 36 / 256)
- EndFunc
- Func _weeknumber($iyear = @YEAR, $imonth = @MON, $iday = @MDAY, $iweekstart = 1)
- If $iday > 31 OR $iday < 1 Then
- Return SetError(1, 0, -1)
- ElseIf NOT __dateismonth($imonth) Then
- Return SetError(3, 0, -1)
- ElseIf $iyear < 1 OR $iyear > 2999 Then
- Return SetError(4, 0, -1)
- ElseIf $iweekstart < 1 OR $iweekstart > 2 Then
- Return SetError(2, 0, -1)
- EndIf
- Local $istartweek1, $iendweek1
- Local $idow0101 = _datetodayofweekiso($iyear, 1, 1)
- Local $idate = $iyear & "/" & $imonth & "/" & $iday
- If $iweekstart = 1 Then
- If $idow0101 = 6 Then
- $istartweek1 = 0
- Else
- $istartweek1 = -1 * $idow0101 - 1
- EndIf
- $iendweek1 = $istartweek1 + 6
- Else
- $istartweek1 = $idow0101 * -1
- $iendweek1 = $istartweek1 + 6
- EndIf
- Local $istartweek1ny
- Local $iendweek1date = _dateadd("d", $iendweek1, $iyear & "/01/01")
- Local $idow0101ny = _datetodayofweekiso($iyear + 1, 1, 1)
- If $iweekstart = 1 Then
- If $idow0101ny = 6 Then
- $istartweek1ny = 0
- Else
- $istartweek1ny = -1 * $idow0101ny - 1
- EndIf
- Else
- $istartweek1ny = $idow0101ny * -1
- EndIf
- Local $istartweek1dateny = _dateadd("d", $istartweek1ny, $iyear + 1 & "/01/01")
- Local $icurrdatediff = _datediff("d", $iendweek1date, $idate) - 1
- Local $icurrdatediffny = _datediff("d", $istartweek1dateny, $idate)
- If $icurrdatediff >= 0 AND $icurrdatediffny < 0 Then Return 2 + Int($icurrdatediff / 7)
- If $icurrdatediff < 0 OR $icurrdatediffny >= 0 Then Return 1
- EndFunc
- Func _daysinmonth($iyear)
- Local $adays = [12, 31, (_dateisleapyear($iyear) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
- Return $adays
- EndFunc
- Func __date_time_clonesystemtime($psystemtime)
- Local $tsystemtime1 = DllStructCreate($tagsystemtime, $psystemtime)
- Local $tsystemtime2 = DllStructCreate($tagsystemtime)
- DllStructSetData($tsystemtime2, "Month", DllStructGetData($tsystemtime1, "Month"))
- DllStructSetData($tsystemtime2, "Day", DllStructGetData($tsystemtime1, "Day"))
- DllStructSetData($tsystemtime2, "Year", DllStructGetData($tsystemtime1, "Year"))
- DllStructSetData($tsystemtime2, "Hour", DllStructGetData($tsystemtime1, "Hour"))
- DllStructSetData($tsystemtime2, "Minute", DllStructGetData($tsystemtime1, "Minute"))
- DllStructSetData($tsystemtime2, "Second", DllStructGetData($tsystemtime1, "Second"))
- DllStructSetData($tsystemtime2, "MSeconds", DllStructGetData($tsystemtime1, "MSeconds"))
- DllStructSetData($tsystemtime2, "DOW", DllStructGetData($tsystemtime1, "DOW"))
- Return $tsystemtime2
- EndFunc
- Func _date_time_comparefiletime($tfiletime1, $tfiletime2)
- Local $aresult = DllCall("kernel32.dll", "long", "CompareFileTime", "struct*", $tfiletime1, "struct*", $tfiletime2)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _date_time_dosdatetimetofiletime($ifatdate, $ifattime)
- Local $ttime = DllStructCreate($tagfiletime)
- Local $aresult = DllCall("kernel32.dll", "bool", "DosDateTimeToFileTime", "word", $ifatdate, "word", $ifattime, "struct*", $ttime)
- If @error Then Return SetError(@error, @extended, 0)
- Return SetExtended($aresult[0], $ttime)
- EndFunc
- Func _date_time_dosdatetoarray($idosdate)
- Local $adate[3]
- $adate[0] = BitAND($idosdate, 31)
- $adate[1] = BitAND(BitShift($idosdate, 5), 15)
- $adate[2] = BitAND(BitShift($idosdate, 9), 63) + 1980
- Return $adate
- EndFunc
- Func _date_time_dosdatetimetoarray($idosdate, $idostime)
- Local $adate[6]
- $adate[0] = BitAND($idosdate, 31)
- $adate[1] = BitAND(BitShift($idosdate, 5), 15)
- $adate[2] = BitAND(BitShift($idosdate, 9), 63) + 1980
- $adate[5] = BitAND($idostime, 31) * 2
- $adate[4] = BitAND(BitShift($idostime, 5), 63)
- $adate[3] = BitAND(BitShift($idostime, 11), 31)
- Return $adate
- EndFunc
- Func _date_time_dosdatetimetostr($idosdate, $idostime)
- Local $adate = _date_time_dosdatetimetoarray($idosdate, $idostime)
- Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $adate[0], $adate[1], $adate[2], $adate[3], $adate[4], $adate[5])
- EndFunc
- Func _date_time_dosdatetostr($idosdate)
- Local $adate = _date_time_dosdatetoarray($idosdate)
- Return StringFormat("%02d/%02d/%04d", $adate[0], $adate[1], $adate[2])
- EndFunc
- Func _date_time_dostimetoarray($idostime)
- Local $atime[3]
- $atime[2] = BitAND($idostime, 31) * 2
- $atime[1] = BitAND(BitShift($idostime, 5), 63)
- $atime[0] = BitAND(BitShift($idostime, 11), 31)
- Return $atime
- EndFunc
- Func _date_time_dostimetostr($idostime)
- Local $atime = _date_time_dostimetoarray($idostime)
- Return StringFormat("%02d:%02d:%02d", $atime[0], $atime[1], $atime[2])
- EndFunc
- Func _date_time_encodefiletime($imonth, $iday, $iyear, $ihour = 0, $iminute = 0, $isecond = 0, $imseconds = 0)
- Local $tsystemtime = _date_time_encodesystemtime($imonth, $iday, $iyear, $ihour, $iminute, $isecond, $imseconds)
- Return _date_time_systemtimetofiletime($tsystemtime)
- EndFunc
- Func _date_time_encodesystemtime($imonth, $iday, $iyear, $ihour = 0, $iminute = 0, $isecond = 0, $imseconds = 0)
- Local $tsystemtime = DllStructCreate($tagsystemtime)
- DllStructSetData($tsystemtime, "Month", $imonth)
- DllStructSetData($tsystemtime, "Day", $iday)
- DllStructSetData($tsystemtime, "Year", $iyear)
- DllStructSetData($tsystemtime, "Hour", $ihour)
- DllStructSetData($tsystemtime, "Minute", $iminute)
- DllStructSetData($tsystemtime, "Second", $isecond)
- DllStructSetData($tsystemtime, "MSeconds", $imseconds)
- Return $tsystemtime
- EndFunc
- Func _date_time_filetimetoarray(ByRef $tfiletime)
- If ((DllStructGetData($tfiletime, 1) + DllStructGetData($tfiletime, 2)) = 0) Then Return SetError(10, 0, 0)
- Local $tsystemtime = _date_time_filetimetosystemtime($tfiletime)
- If @error Then Return SetError(@error, @extended, 0)
- Return _date_time_systemtimetoarray($tsystemtime)
- EndFunc
- Func _date_time_filetimetostr(ByRef $tfiletime, $ifmt = 0)
- Local $adate = _date_time_filetimetoarray($tfiletime)
- If @error Then Return SetError(@error, @extended, "")
- If $ifmt Then
- Return StringFormat("%04d/%02d/%02d %02d:%02d:%02d", $adate[2], $adate[0], $adate[1], $adate[3], $adate[4], $adate[5])
- Else
- Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $adate[0], $adate[1], $adate[2], $adate[3], $adate[4], $adate[5])
- EndIf
- EndFunc
- Func _date_time_filetimetodosdatetime($tfiletime)
- Local $adate[2]
- Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToDosDateTime", "struct*", $tfiletime, "word*", 0, "word*", 0)
- If @error Then Return SetError(@error, @extended, $adate)
- $adate[0] = $aresult[2]
- $adate[1] = $aresult[3]
- Return SetExtended($aresult[0], $adate)
- EndFunc
- Func _date_time_filetimetolocalfiletime($tfiletime)
- Local $tlocal = DllStructCreate($tagfiletime)
- Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToLocalFileTime", "struct*", $tfiletime, "struct*", $tlocal)
- If @error Then Return SetError(@error, @extended, 0)
- Return SetExtended($aresult[0], $tlocal)
- EndFunc
- Func _date_time_filetimetosystemtime($tfiletime)
- Local $tsysttime = DllStructCreate($tagsystemtime)
- Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToSystemTime", "struct*", $tfiletime, "struct*", $tsysttime)
- If @error Then Return SetError(@error, @extended, 0)
- Return SetExtended($aresult[0], $tsysttime)
- EndFunc
- Func _date_time_getfiletime($hfile)
- Local $adate[3]
- $adate[0] = DllStructCreate($tagfiletime)
- $adate[1] = DllStructCreate($tagfiletime)
- $adate[2] = DllStructCreate($tagfiletime)
- Local $aresult = DllCall("kernel32.dll", "bool", "GetFileTime", "handle", $hfile, "struct*", $adate[0], "struct*", $adate[1], "struct*", $adate[2])
- If @error Then Return SetError(@error, @extended, 0)
- Return SetExtended($aresult[0], $adate)
- EndFunc
- Func _date_time_getlocaltime()
- Local $tsysttime = DllStructCreate($tagsystemtime)
- DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsysttime)
- If @error Then Return SetError(@error, @extended, 0)
- Return $tsysttime
- EndFunc
- Func _date_time_getsystemtime()
- Local $tsysttime = DllStructCreate($tagsystemtime)
- DllCall("kernel32.dll", "none", "GetSystemTime", "struct*", $tsysttime)
- If @error Then Return SetError(@error, @extended, 0)
- Return $tsysttime
- EndFunc
- Func _date_time_getsystemtimeadjustment()
- Local $ainfo[3]
- Local $aresult = DllCall("kernel32.dll", "bool", "GetSystemTimeAdjustment", "dword*", 0, "dword*", 0, "bool*", 0)
- If @error Then Return SetError(@error, @extended, 0)
- $ainfo[0] = $aresult[1]
- $ainfo[1] = $aresult[2]
- $ainfo[2] = $aresult[3] <> 0
- Return SetExtended($aresult[0], $ainfo)
- EndFunc
- Func _date_time_getsystemtimeasfiletime()
- Local $tfiletime = DllStructCreate($tagfiletime)
- DllCall("kernel32.dll", "none", "GetSystemTimeAsFileTime", "struct*", $tfiletime)
- If @error Then Return SetError(@error, @extended, 0)
- Return $tfiletime
- EndFunc
- Func _date_time_getsystemtimes()
- Local $ainfo[3]
- $ainfo[0] = DllStructCreate($tagfiletime)
- $ainfo[1] = DllStructCreate($tagfiletime)
- $ainfo[2] = DllStructCreate($tagfiletime)
- Local $aresult = DllCall("kernel32.dll", "bool", "GetSystemTimes", "struct*", $ainfo[0], "struct*", $ainfo[1], "struct*", $ainfo[2])
- If @error Then Return SetError(@error, @extended, 0)
- Return SetExtended($aresult[0], $ainfo)
- EndFunc
- Func _date_time_gettickcount()
- Local $aresult = DllCall("kernel32.dll", "dword", "GetTickCount")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _date_time_gettimezoneinformation()
- Local $ttimezone = DllStructCreate($tagtime_zone_information)
- Local $aresult = DllCall("kernel32.dll", "dword", "GetTimeZoneInformation", "struct*", $ttimezone)
- If @error OR $aresult[0] = -1 Then Return SetError(@error, @extended, 0)
- Local $ainfo[8]
- $ainfo[0] = $aresult[0]
- $ainfo[1] = DllStructGetData($ttimezone, "Bias")
- $ainfo[2] = DllStructGetData($ttimezone, "StdName")
- $ainfo[3] = __date_time_clonesystemtime(DllStructGetPtr($ttimezone, "StdDate"))
- $ainfo[4] = DllStructGetData($ttimezone, "StdBias")
- $ainfo[5] = DllStructGetData($ttimezone, "DayName")
- $ainfo[6] = __date_time_clonesystemtime(DllStructGetPtr($ttimezone, "DayDate"))
- $ainfo[7] = DllStructGetData($ttimezone, "DayBias")
- Return $ainfo
- EndFunc
- Func _date_time_localfiletimetofiletime($tlocaltime)
- Local $tfiletime = DllStructCreate($tagfiletime)
- Local $aresult = DllCall("kernel32.dll", "bool", "LocalFileTimeToFileTime", "struct*", $tlocaltime, "struct*", $tfiletime)
- If @error Then Return SetError(@error, @extended, 0)
- Return SetExtended($aresult[0], $tfiletime)
- EndFunc
- Func _date_time_setfiletime($hfile, $tcreatetime, $tlastaccess, $tlastwrite)
- Local $aresult = DllCall("kernel32.dll", "bool", "SetFileTime", "handle", $hfile, "struct*", $tcreatetime, "struct*", $tlastaccess, "struct*", $tlastwrite)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _date_time_setlocaltime($tsystemtime)
- Local $aresult = DllCall("kernel32.dll", "bool", "SetLocalTime", "struct*", $tsystemtime)
- If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, False)
- $aresult = DllCall("kernel32.dll", "bool", "SetLocalTime", "struct*", $tsystemtime)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _date_time_setsystemtime($tsystemtime)
- Local $aresult = DllCall("kernel32.dll", "bool", "SetSystemTime", "struct*", $tsystemtime)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _date_time_setsystemtimeadjustment($iadjustment, $bdisabled)
- Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
- If @error Then Return SetError(@error + 10, @extended, False)
- _security__setprivilege($htoken, "SeSystemtimePrivilege", True)
- Local $ierror = @error
- Local $ilasterror = @extended
- Local $bret = False
- If NOT @error Then
- Local $aresult = DllCall("kernel32.dll", "bool", "SetSystemTimeAdjustment", "dword", $iadjustment, "bool", $bdisabled)
- If @error Then
- $ierror = @error
- $ilasterror = @extended
- ElseIf $aresult[0] Then
- $bret = True
- Else
- $ierror = 20
- $ilasterror = _winapi_getlasterror()
- EndIf
- _security__setprivilege($htoken, "SeSystemtimePrivilege", False)
- If NOT $ierror AND @error Then $ierror = 22
- EndIf
- _winapi_closehandle($htoken)
- Return SetError($ierror, $ilasterror, $bret)
- EndFunc
- Func _date_time_settimezoneinformation($ibias, $sstdname, $tstddate, $istdbias, $sdayname, $tdaydate, $idaybias)
- Local $tzoneinfo = DllStructCreate($tagtime_zone_information)
- DllStructSetData($tzoneinfo, "Bias", $ibias)
- DllStructSetData($tzoneinfo, "StdName", $sstdname)
- _memmovememory($tstddate, DllStructGetPtr($tzoneinfo, "StdDate"), DllStructGetSize($tstddate))
- DllStructSetData($tzoneinfo, "StdBias", $istdbias)
- DllStructSetData($tzoneinfo, "DayName", $sdayname)
- _memmovememory($tdaydate, DllStructGetPtr($tzoneinfo, "DayDate"), DllStructGetSize($tdaydate))
- DllStructSetData($tzoneinfo, "DayBias", $idaybias)
- Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
- If @error Then Return SetError(@error + 10, @extended, False)
- _security__setprivilege($htoken, "SeTimeZonePrivilege", True)
- Local $ierror = @error
- Local $ilasterror = @extended
- Local $bret = False
- If NOT @error Then
- Local $aresult = DllCall("kernel32.dll", "bool", "SetTimeZoneInformation", "struct*", $tzoneinfo)
- If @error Then
- $ierror = @error
- $ilasterror = @extended
- ElseIf $aresult[0] Then
- $ilasterror = 0
- $bret = True
- Else
- $ierror = 20
- $ilasterror = _winapi_getlasterror()
- EndIf
- _security__setprivilege($htoken, "SeTimeZonePrivilege", False)
- If NOT $ierror AND @error Then $ierror = 22
- EndIf
- _winapi_closehandle($htoken)
- Return SetError($ierror, $ilasterror, $bret)
- EndFunc
- Func _date_time_systemtimetoarray(ByRef $tsystemtime)
- Local $ainfo[8]
- $ainfo[0] = DllStructGetData($tsystemtime, "Month")
- $ainfo[1] = DllStructGetData($tsystemtime, "Day")
- $ainfo[2] = DllStructGetData($tsystemtime, "Year")
- $ainfo[3] = DllStructGetData($tsystemtime, "Hour")
- $ainfo[4] = DllStructGetData($tsystemtime, "Minute")
- $ainfo[5] = DllStructGetData($tsystemtime, "Second")
- $ainfo[6] = DllStructGetData($tsystemtime, "MSeconds")
- $ainfo[7] = DllStructGetData($tsystemtime, "DOW")
- Return $ainfo
- EndFunc
- Func _date_time_systemtimetodatestr(ByRef $tsystemtime, $ifmt = 0)
- Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
- If @error Then Return SetError(@error, @extended, "")
- If $ifmt Then
- Return StringFormat("%04d/%02d/%02d", $ainfo[2], $ainfo[0], $ainfo[1])
- Else
- Return StringFormat("%02d/%02d/%04d", $ainfo[0], $ainfo[1], $ainfo[2])
- EndIf
- EndFunc
- Func _date_time_systemtimetodatetimestr(ByRef $tsystemtime, $ifmt = 0)
- Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
- If @error Then Return SetError(@error, @extended, "")
- If $ifmt Then
- Return StringFormat("%04d/%02d/%02d %02d:%02d:%02d", $ainfo[2], $ainfo[0], $ainfo[1], $ainfo[3], $ainfo[4], $ainfo[5])
- Else
- Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $ainfo[0], $ainfo[1], $ainfo[2], $ainfo[3], $ainfo[4], $ainfo[5])
- EndIf
- EndFunc
- Func _date_time_systemtimetofiletime($tsystemtime)
- Local $tfiletime = DllStructCreate($tagfiletime)
- Local $aresult = DllCall("kernel32.dll", "bool", "SystemTimeToFileTime", "struct*", $tsystemtime, "struct*", $tfiletime)
- If @error Then Return SetError(@error, @extended, 0)
- Return SetExtended($aresult[0], $tfiletime)
- EndFunc
- Func _date_time_systemtimetotimestr(ByRef $tsystemtime)
- Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
- Return StringFormat("%02d:%02d:%02d", $ainfo[3], $ainfo[4], $ainfo[5])
- EndFunc
- Func _date_time_systemtimetotzspecificlocaltime($tutc, $ttimezone = 0)
- Local $tlocaltime = DllStructCreate($tagsystemtime)
- Local $aresult = DllCall("kernel32.dll", "bool", "SystemTimeToTzSpecificLocalTime", "struct*", $ttimezone, "struct*", $tutc, "struct*", $tlocaltime)
- If @error Then Return SetError(@error, @extended, 0)
- Return SetExtended($aresult[0], $tlocaltime)
- EndFunc
- Func _date_time_tzspecificlocaltimetosystemtime($tlocaltime, $ttimezone = 0)
- Local $tutc = DllStructCreate($tagsystemtime)
- Local $aresult = DllCall("kernel32.dll", "bool", "TzSpecificLocalTimeToSystemTime", "struct*", $ttimezone, "struct*", $tlocaltime, "struct*", $tutc)
- If @error Then Return SetError(@error, @extended, 0)
- Return SetExtended($aresult[0], $tutc)
- EndFunc
- Global Const $backup_alternate_data = 4
- Global Const $backup_data = 1
- Global Const $backup_ea_data = 2
- Global Const $backup_link = 5
- Global Const $backup_object_id = 7
- Global Const $backup_property_data = 6
- Global Const $backup_reparse_data = 8
- Global Const $backup_security_data = 3
- Global Const $backup_sparse_block = 9
- Global Const $backup_txfs_data = 10
- Global Const $copy_file_allow_decrypted_destination = 8
- Global Const $copy_file_copy_symlink = 2048
- Global Const $copy_file_fail_if_exists = 1
- Global Const $copy_file_no_buffering = 4096
- Global Const $copy_file_open_source_for_write = 4
- Global Const $copy_file_restartable = 2
- Global Const $move_file_copy_allowed = 2
- Global Const $move_file_create_hardlink = 16
- Global Const $move_file_delay_until_reboot = 4
- Global Const $move_file_fail_if_not_trackable = 32
- Global Const $move_file_replace_existing = 1
- Global Const $move_file_write_through = 8
- Global Const $progress_continue = 0
- Global Const $progress_cancel = 1
- Global Const $progress_stop = 2
- Global Const $progress_quiet = 3
- Global Const $file_append_data = 4
- Global Const $file_delete_child = 64
- Global Const $file_execute = 32
- Global Const $file_read_attributes = 128
- Global Const $file_read_data = 1
- Global Const $file_read_ea = 8
- Global Const $file_write_attributes = 256
- Global Const $file_write_data = 2
- Global Const $file_write_ea = 16
- Global Const $file_add_file = $file_write_data
- Global Const $file_add_subdirectory = $file_append_data
- Global Const $file_create_pipe_instance = $file_append_data
- Global Const $file_list_directory = $file_read_data
- Global Const $file_traverse = $file_execute
- Global Const $file_all_access = 2032127
- Global Const $file_flag_backup_semantics = 33554432
- Global Const $file_flag_delete_on_close = 67108864
- Global Const $file_flag_no_buffering = 536870912
- Global Const $file_flag_open_no_recall = 1048576
- Global Const $file_flag_open_reparse_point = 2097152
- Global Const $file_flag_overlapped = 1073741824
- Global Const $file_flag_posix_semantics = 1048576
- Global Const $file_flag_random_access = 268435456
- Global Const $file_flag_sequential_scan = 134217728
- Global Const $file_flag_write_through = -2147483648
- Global Const $security_anonymous = 0
- Global Const $security_context_tracking = 262144
- Global Const $security_delegation = 196608
- Global Const $security_effective_only = 524288
- Global Const $security_identification = 65536
- Global Const $security_impersonation = 131072
- Global Const $sec_commit = 134217728
- Global Const $sec_image = 16777216
- Global Const $sec_large_pages = -2147483648
- Global Const $sec_nocache = 268435456
- Global Const $sec_reserve = 67108864
- Global Const $sec_writecombine = 1073741824
- Global Const $section_extend_size = 16
- Global Const $section_map_execute = 8
- Global Const $section_map_read = 4
- Global Const $section_map_write = 2
- Global Const $section_query = 1
- Global Const $section_all_access = 2031647
- Global Const $file_map_copy = 1
- Global Const $file_map_execute = 32
- Global Const $file_map_read = 4
- Global Const $file_map_write = 2
- Global Const $file_map_all_access = $section_all_access
- Global Const $ddd_exact_match_on_remove = 4
- Global Const $ddd_no_broadcast_system = 8
- Global Const $ddd_raw_target_path = 1
- Global Const $ddd_remove_definition = 2
- Global Const $fsctl_allow_extended_dasd_io = 589955
- Global Const $fsctl_create_or_get_object_id = 590016
- Global Const $fsctl_create_usn_journal = 590055
- Global Const $fsctl_delete_object_id = 589984
- Global Const $fsctl_delete_reparse_point = 589996
- Global Const $fsctl_delete_usn_journal = 590072
- Global Const $fsctl_dismount_volume = 589856
- Global Const $fsctl_dump_property_data = 589975
- Global Const $fsctl_enable_upgrade = 622800
- Global Const $fsctl_encryption_fsctl_io = 590043
- Global Const $fsctl_enum_usn_data = 590003
- Global Const $fsctl_extend_volume = 590064
- Global Const $fsctl_filesystem_get_statistics = 589920
- Global Const $fsctl_find_files_by_sid = 589967
- Global Const $fsctl_get_compression = 589884
- Global Const $fsctl_get_ntfs_file_record = 589928
- Global Const $fsctl_get_ntfs_volume_data = 589924
- Global Const $fsctl_get_object_id = 589980
- Global Const $fsctl_get_reparse_point = 589992
- Global Const $fsctl_get_retrieval_pointers = 589939
- Global Const $fsctl_get_volume_bitmap = 589935
- Global Const $fsctl_hsm_data = 639251
- Global Const $fsctl_hsm_msg = 639240
- Global Const $fsctl_invalidate_volumes = 589908
- Global Const $fsctl_is_pathname_valid = 589868
- Global Const $fsctl_is_volume_dirty = 589944
- Global Const $fsctl_is_volume_mounted = 589864
- Global Const $fsctl_lock_volume = 589848
- Global Const $fsctl_mark_as_system_hive = 589903
- Global Const $fsctl_mark_handle = 590076
- Global Const $fsctl_mark_volume_dirty = 589872
- Global Const $fsctl_move_file = 589940
- Global Const $fsctl_opbatch_ack_close_pending = 589840
- Global Const $fsctl_oplock_break_ack_no_2 = 589904
- Global Const $fsctl_oplock_break_acknowledge = 589836
- Global Const $fsctl_oplock_break_notify = 589844
- Global Const $fsctl_query_allocated_ranges = 606415
- Global Const $fsctl_query_fat_bpb = 589912
- Global Const $fsctl_query_retrieval_pointers = 589883
- Global Const $fsctl_query_usn_journal = 590068
- Global Const $fsctl_read_file_usn_data = 590059
- Global Const $fsctl_read_property_data = 589959
- Global Const $fsctl_read_raw_encrypted = 590051
- Global Const $fsctl_read_usn_journal = 590011
- Global Const $fsctl_recall_file = 590103
- Global Const $fsctl_request_batch_oplock = 589832
- Global Const $fsctl_request_filter_oplock = 589916
- Global Const $fsctl_request_oplock_level_1 = 589824
- Global Const $fsctl_request_oplock_level_2 = 589828
- Global Const $fsctl_security_id_check = 606391
- Global Const $fsctl_set_compression = 639040
- Global Const $fsctl_set_encryption = 590039
- Global Const $fsctl_set_object_id = 589976
- Global Const $fsctl_set_object_id_extended = 590012
- Global Const $fsctl_set_reparse_point = 589988
- Global Const $fsctl_set_sparse = 590020
- Global Const $fsctl_set_zero_data = 622792
- Global Const $fsctl_sis_copyfile = 590080
- Global Const $fsctl_sis_link_files = 639236
- Global Const $fsctl_unlock_volume = 589852
- Global Const $fsctl_write_property_data = 589963
- Global Const $fsctl_write_raw_encrypted = 590047
- Global Const $fsctl_write_usn_close_record = 590063
- Global Const $ioctl_aacs_end_session = 3363020
- Global Const $ioctl_aacs_generate_binding_nonce = 3395824
- Global Const $ioctl_aacs_get_certificate = 3363028
- Global Const $ioctl_aacs_get_challenge_key = 3363032
- Global Const $ioctl_aacs_read_binding_nonce = 3363052
- Global Const $ioctl_aacs_read_media_id = 3363048
- Global Const $ioctl_aacs_read_media_key_block = 3363012
- Global Const $ioctl_aacs_read_media_key_block_size = 3363008
- Global Const $ioctl_aacs_read_serial_number = 3363044
- Global Const $ioctl_aacs_read_volume_id = 3363040
- Global Const $ioctl_aacs_send_certificate = 3363024
- Global Const $ioctl_aacs_send_challenge_key = 3363036
- Global Const $ioctl_aacs_start_session = 3363016
- Global Const $ioctl_ata_pass_through = 315436
- Global Const $ioctl_ata_pass_through_direct = 315440
- Global Const $ioctl_cdrom_check_verify = 149504
- Global Const $ioctl_cdrom_disk_type = 131136
- Global Const $ioctl_cdrom_eject_media = 149512
- Global Const $ioctl_cdrom_find_new_devices = 149528
- Global Const $ioctl_cdrom_get_configuration = 147544
- Global Const $ioctl_cdrom_get_control = 147508
- Global Const $ioctl_cdrom_get_drive_geometry = 147532
- Global Const $ioctl_cdrom_get_drive_geometry_ex = 147536
- Global Const $ioctl_cdrom_get_last_session = 147512
- Global Const $ioctl_cdrom_get_volume = 147476
- Global Const $ioctl_cdrom_load_media = 149516
- Global Const $ioctl_cdrom_media_removal = 149508
- Global Const $ioctl_cdrom_pause_audio = 147468
- Global Const $ioctl_cdrom_play_audio_msf = 147480
- Global Const $ioctl_cdrom_raw_read = 147518
- Global Const $ioctl_cdrom_read_q_channel = 147500
- Global Const $ioctl_cdrom_read_toc = 147456
- Global Const $ioctl_cdrom_read_toc_ex = 147540
- Global Const $ioctl_cdrom_release = 149524
- Global Const $ioctl_cdrom_reserve = 149520
- Global Const $ioctl_cdrom_resume_audio = 147472
- Global Const $ioctl_cdrom_seek_audio_msf = 147460
- Global Const $ioctl_cdrom_set_volume = 147496
- Global Const $ioctl_cdrom_stop_audio = 147464
- Global Const $ioctl_cdrom_unload_driver = 151560
- Global Const $ioctl_disk_check_verify = 477184
- Global Const $ioctl_disk_controller_number = 458820
- Global Const $ioctl_disk_create_disk = 507992
- Global Const $ioctl_disk_delete_drive_layout = 508160
- Global Const $ioctl_disk_eject_media = 477192
- Global Const $ioctl_disk_find_new_devices = 477208
- Global Const $ioctl_disk_format_tracks = 507928
- Global Const $ioctl_disk_format_tracks_ex = 507948
- Global Const $ioctl_disk_get_cache_information = 475348
- Global Const $ioctl_disk_get_drive_geometry = 458752
- Global Const $ioctl_disk_get_drive_geometry_ex = 458912
- Global Const $ioctl_disk_get_drive_layout = 475148
- Global Const $ioctl_disk_get_drive_layout_ex = 458832
- Global Const $ioctl_disk_get_length_info = 475228
- Global Const $ioctl_disk_get_media_types = 461824
- Global Const $ioctl_disk_get_partition_info = 475140
- Global Const $ioctl_disk_get_partition_info_ex = 458824
- Global Const $ioctl_disk_get_write_cache_state = 475356
- Global Const $ioctl_disk_grow_partition = 508112
- Global Const $ioctl_disk_histogram_data = 458804
- Global Const $ioctl_disk_histogram_reset = 458808
- Global Const $ioctl_disk_histogram_structure = 458800
- Global Const $ioctl_disk_internal_clear_verify = 459783
- Global Const $ioctl_disk_internal_set_notify = 459784
- Global Const $ioctl_disk_internal_set_verify = 459779
- Global Const $ioctl_disk_is_writable = 458788
- Global Const $ioctl_disk_load_media = 477196
- Global Const $ioctl_disk_logging = 458792
- Global Const $ioctl_disk_media_removal = 477188
- Global Const $ioctl_disk_performance = 458784
- Global Const $ioctl_disk_performance_off = 458848
- Global Const $ioctl_disk_reassign_blocks = 507932
- Global Const $ioctl_disk_release = 477204
- Global Const $ioctl_disk_request_data = 458816
- Global Const $ioctl_disk_request_structure = 458812
- Global Const $ioctl_disk_reserve = 477200
- Global Const $ioctl_disk_set_cache_information = 508120
- Global Const $ioctl_disk_set_drive_layout = 507920
- Global Const $ioctl_disk_set_drive_layout_ex = 507988
- Global Const $ioctl_disk_set_partition_info = 507912
- Global Const $ioctl_disk_set_partition_info_ex = 507980
- Global Const $ioctl_disk_update_drive_size = 508104
- Global Const $ioctl_disk_update_properties = 459072
- Global Const $ioctl_disk_verify = 458772
- Global Const $ioctl_dvd_end_session = 3362828
- Global Const $ioctl_dvd_get_region = 3362836
- Global Const $ioctl_dvd_read_key = 3362820
- Global Const $ioctl_dvd_read_structure = 3363136
- Global Const $ioctl_dvd_send_key = 3362824
- Global Const $ioctl_dvd_send_key2 = 3395608
- Global Const $ioctl_dvd_set_read_ahead = 3362832
- Global Const $ioctl_dvd_start_session = 3362816
- Global Const $ioctl_mountdev_link_created = 5046288
- Global Const $ioctl_mountdev_link_deleted = 5046292
- Global Const $ioctl_mountdev_query_stable_guid = 5046296
- Global Const $ioctl_mountdev_query_suggested_link_name = 5046284
- Global Const $ioctl_mountdev_query_unique_id = 5046272
- Global Const $ioctl_mountdev_unique_id_change_notify = 5046276
- Global Const $ioctl_mountmgr_auto_dl_assignments = 7192596
- Global Const $ioctl_mountmgr_change_notify = 7159840
- Global Const $ioctl_mountmgr_check_unprocessed_volumes = 7159848
- Global Const $ioctl_mountmgr_create_point = 7192576
- Global Const $ioctl_mountmgr_delete_points = 7192580
- Global Const $ioctl_mountmgr_delete_points_dbonly = 7192588
- Global Const $ioctl_mountmgr_keep_links_when_offline = 7192612
- Global Const $ioctl_mountmgr_next_drive_letter = 7192592
- Global Const $ioctl_mountmgr_query_dos_volume_path = 7143472
- Global Const $ioctl_mountmgr_query_dos_volume_paths = 7143476
- Global Const $ioctl_mountmgr_query_points = 7143432
- Global Const $ioctl_mountmgr_volume_arrival_notification = 7159852
- Global Const $ioctl_mountmgr_volume_mount_point_created = 7192600
- Global Const $ioctl_mountmgr_volume_mount_point_deleted = 7192604
- Global Const $ioctl_scsi_get_inquiry_data = 266252
- Global Const $ioctl_scsi_get_capabilities = 266256
- Global Const $ioctl_scsi_get_address = 266264
- Global Const $ioctl_scsi_miniport = 315400
- Global Const $ioctl_scsi_pass_through = 315396
- Global Const $ioctl_scsi_pass_through_direct = 315412
- Global Const $ioctl_scsi_rescan_bus = 266268
- Global Const $ioctl_storage_break_reservation = 2969620
- Global Const $ioctl_storage_check_verify = 2967552
- Global Const $ioctl_storage_check_verify2 = 2951168
- Global Const $ioctl_storage_eject_media = 2967560
- Global Const $ioctl_storage_ejection_control = 2951488
- Global Const $ioctl_storage_find_new_devices = 2967576
- Global Const $ioctl_storage_get_device_number = 2953344
- Global Const $ioctl_storage_get_hotplug_info = 2952212
- Global Const $ioctl_storage_get_media_serial_number = 2952208
- Global Const $ioctl_storage_get_media_types = 2952192
- Global Const $ioctl_storage_get_media_types_ex = 2952196
- Global Const $ioctl_storage_load_media = 2967564
- Global Const $ioctl_storage_load_media2 = 2951180
- Global Const $ioctl_storage_manage_data_set_attributes = 2987012
- Global Const $ioctl_storage_mcn_control = 2951492
- Global Const $ioctl_storage_media_removal = 2967556
- Global Const $ioctl_storage_persistent_reserve_in = 2969624
- Global Const $ioctl_storage_persistent_reserve_out = 2969628
- Global Const $ioctl_storage_predict_failure = 2953472
- Global Const $ioctl_storage_query_property = 2954240
- Global Const $ioctl_storage_release = 2967572
- Global Const $ioctl_storage_reserve = 2967568
- Global Const $ioctl_storage_reset_bus = 2969600
- Global Const $ioctl_storage_reset_device = 2969604
- Global Const $ioctl_storage_set_hotplug_info = 3001368
- Global Const $ioctl_storage_set_read_ahead = 2966528
- Global Const $ioctl_volume_get_gpt_attributes = 5636152
- Global Const $ioctl_volume_get_volume_disk_extents = 5636096
- Global Const $ioctl_volume_is_clustered = 5636144
- Global Const $ioctl_volume_is_io_capable = 5636116
- Global Const $ioctl_volume_is_offline = 5636112
- Global Const $ioctl_volume_is_partition = 5636136
- Global Const $ioctl_volume_logical_to_physical = 5636128
- Global Const $ioctl_volume_offline = 5685260
- Global Const $ioctl_volume_online = 5685256
- Global Const $ioctl_volume_physical_to_logical = 5636132
- Global Const $ioctl_volume_query_failover_set = 5636120
- Global Const $ioctl_volume_query_volume_number = 5636124
- Global Const $ioctl_volume_read_plex = 5652526
- Global Const $ioctl_volume_set_gpt_attributes = 5636148
- Global Const $ioctl_volume_supports_online_offline = 5636100
- Global Const $smart_get_version = 475264
- Global Const $smart_rcv_drive_data = 508040
- Global Const $smart_send_drive_command = 508036
- Global Const $file_encryptable = 0
- Global Const $file_is_encrypted = 1
- Global Const $file_read_only = 8
- Global Const $file_root_dir = 3
- Global Const $file_system_attr = 2
- Global Const $file_system_dir = 4
- Global Const $file_system_not_support = 6
- Global Const $file_unknown = 5
- Global Const $file_user_disallowed = 7
- Global Const $scs_32bit_binary = 0
- Global Const $scs_64bit_binary = 6
- Global Const $scs_dos_binary = 1
- Global Const $scs_os216_binary = 5
- Global Const $scs_pif_binary = 3
- Global Const $scs_posix_binary = 4
- Global Const $scs_wow_binary = 2
- Global Const $drive_bus_type_unknown = 0
- Global Const $drive_bus_type_scsi = 1
- Global Const $drive_bus_type_atapi = 2
- Global Const $drive_bus_type_ata = 3
- Global Const $drive_bus_type_1394 = 4
- Global Const $drive_bus_type_ssa = 5
- Global Const $drive_bus_type_fibre = 6
- Global Const $drive_bus_type_usb = 7
- Global Const $drive_bus_type_raid = 8
- Global Const $drive_bus_type_iscsi = 9
- Global Const $drive_bus_type_sas = 10
- Global Const $drive_bus_type_sata = 11
- Global Const $drive_bus_type_sd = 12
- Global Const $drive_bus_type_mmc = 13
- Global Const $drive_unknown = 0
- Global Const $drive_no_root_dir = 1
- Global Const $drive_removable = 2
- Global Const $drive_fixed = 3
- Global Const $drive_remote = 4
- Global Const $drive_cdrom = 5
- Global Const $drive_ramdisk = 6
- Global Const $file_type_char = 2
- Global Const $file_type_disk = 1
- Global Const $file_type_pipe = 3
- Global Const $file_type_remote = 32768
- Global Const $file_type_unknown = 0
- Global Const $file_name_normalized = 0
- Global Const $file_name_opened = 8
- Global Const $volume_name_dos = 0
- Global Const $volume_name_guid = 1
- Global Const $volume_name_none = 4
- Global Const $volume_name_nt = 2
- Global Const $image_file_machine_unknown = 0
- Global Const $image_file_machine_am33 = 467
- Global Const $image_file_machine_amd64 = 34404
- Global Const $image_file_machine_arm = 448
- Global Const $image_file_machine_ebc = 3772
- Global Const $image_file_machine_i386 = 332
- Global Const $image_file_machine_ia64 = 512
- Global Const $image_file_machine_m32r = 36929
- Global Const $image_file_machine_mips16 = 614
- Global Const $image_file_machine_mipsfpu = 870
- Global Const $image_file_machine_mipsfpu16 = 1126
- Global Const $image_file_machine_powerpc = 496
- Global Const $image_file_machine_powerpcfp = 497
- Global Const $image_file_machine_r4000 = 358
- Global Const $image_file_machine_sh3 = 418
- Global Const $image_file_machine_sh3dsp = 419
- Global Const $image_file_machine_sh4 = 422
- Global Const $image_file_machine_sh5 = 424
- Global Const $image_file_machine_thumb = 450
- Global Const $image_file_machine_wcemipsv2 = 361
- Global Const $file_case_preserved_names = 2
- Global Const $file_case_sensitive_search = 1
- Global Const $file_file_compression = 16
- Global Const $file_named_streams = 262144
- Global Const $file_persistent_acls = 8
- Global Const $file_read_only_volume = 524288
- Global Const $file_sequential_write_once = 1048576
- Global Const $file_supports_encryption = 131072
- Global Const $file_supports_extended_attributes = 8388608
- Global Const $file_supports_hard_links = 4194304
- Global Const $file_supports_object_ids = 65536
- Global Const $file_supports_open_by_file_id = 16777216
- Global Const $file_supports_reparse_points = 128
- Global Const $file_supports_sparse_files = 64
- Global Const $file_supports_transactions = 2097152
- Global Const $file_supports_usn_journal = 33554432
- Global Const $file_unicode_on_disk = 4
- Global Const $file_volume_is_compressed = 32768
- Global Const $file_volume_quotas = 32
- Global Const $file_device_8042_port = 39
- Global Const $file_device_acpi = 50
- Global Const $file_device_battery = 41
- Global Const $file_device_beep = 1
- Global Const $file_device_bus_extender = 42
- Global Const $file_device_cd_rom = 2
- Global Const $file_device_cd_rom_file_system = 3
- Global Const $file_device_changer = 48
- Global Const $file_device_controller = 4
- Global Const $file_device_datalink = 5
- Global Const $file_device_dfs = 6
- Global Const $file_device_dfs_file_system = 53
- Global Const $file_device_dfs_volume = 54
- Global Const $file_device_disk = 7
- Global Const $file_device_disk_file_system = 8
- Global Const $file_device_dvd = 51
- Global Const $file_device_file_system = 9
- Global Const $file_device_fips = 58
- Global Const $file_device_fullscreen_video = 52
- Global Const $file_device_inport_port = 10
- Global Const $file_device_keyboard = 11
- Global Const $file_device_ks = 47
- Global Const $file_device_ksec = 57
- Global Const $file_device_mailslot = 12
- Global Const $file_device_mass_storage = 45
- Global Const $file_device_midi_in = 13
- Global Const $file_device_midi_out = 14
- Global Const $file_device_modem = 43
- Global Const $file_device_mouse = 15
- Global Const $file_device_multi_unc_provider = 16
- Global Const $file_device_named_pipe = 17
- Global Const $file_device_network = 18
- Global Const $file_device_network_browser = 19
- Global Const $file_device_network_file_system = 20
- Global Const $file_device_network_redirector = 40
- Global Const $file_device_null = 21
- Global Const $file_device_parallel_port = 22
- Global Const $file_device_physical_netcard = 23
- Global Const $file_device_printer = 24
- Global Const $file_device_scanner = 25
- Global Const $file_device_screen = 28
- Global Const $file_device_serenum = 55
- Global Const $file_device_serial_mouse_port = 26
- Global Const $file_device_serial_port = 27
- Global Const $file_device_smartcard = 49
- Global Const $file_device_smb = 46
- Global Const $file_device_sound = 29
- Global Const $file_device_streams = 30
- Global Const $file_device_tape = 31
- Global Const $file_device_tape_file_system = 32
- Global Const $file_device_termsrv = 56
- Global Const $file_device_transport = 33
- Global Const $file_device_unknown = 34
- Global Const $file_device_vdm = 44
- Global Const $file_device_video = 35
- Global Const $file_device_virtual_disk = 36
- Global Const $file_device_wave_in = 37
- Global Const $file_device_wave_out = 38
- Global Const $file_any_access = 0
- Global Const $file_special_access = $file_any_access
- Global Const $file_read_access = 1
- Global Const $file_write_access = 2
- Global Const $method_buffered = 0
- Global Const $method_in_direct = 1
- Global Const $method_out_direct = 2
- Global Const $method_neither = 3
- Global Const $file_notify_change_file_name = 1
- Global Const $file_notify_change_dir_name = 2
- Global Const $file_notify_change_attributes = 4
- Global Const $file_notify_change_size = 8
- Global Const $file_notify_change_last_write = 16
- Global Const $file_notify_change_last_access = 32
- Global Const $file_notify_change_creation = 64
- Global Const $file_notify_change_security = 256
- Global Const $file_action_added = 1
- Global Const $file_action_removed = 2
- Global Const $file_action_modified = 3
- Global Const $file_action_renamed_old_name = 4
- Global Const $file_action_renamed_new_name = 5
- Global Const $replacefile_write_through = 1
- Global Const $replacefile_ignore_merge_errors = 2
- Global Const $replacefile_ignore_acl_errors = 4
- Global Const $base_search_path_enable_safe_searchmode = 1
- Global Const $base_search_path_disable_safe_searchmode = 65536
- Global Const $base_search_path_permanent = 32768
- #Region Global Variables and Constants
- #EndRegion Global Variables and Constants
- #Region Functions list
- #EndRegion Functions list
- #Region Public Functions
- Func _winapi_chartooem($sstr)
- Local $aret = DllCall("user32.dll", "bool", "CharToOemW", "wstr", $sstr, "wstr", "")
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
- Return $aret[2]
- EndFunc
- Func _winapi_clienttoscreen($hwnd, ByRef $tpoint)
- Local $aret = DllCall("user32.dll", "bool", "ClientToScreen", "hwnd", $hwnd, "struct*", $tpoint)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
- Return $tpoint
- EndFunc
- Func _winapi_dwordtofloat($ivalue)
- Local $tdword = DllStructCreate("dword")
- Local $tfloat = DllStructCreate("float", DllStructGetPtr($tdword))
- DllStructSetData($tdword, 1, $ivalue)
- Return DllStructGetData($tfloat, 1)
- EndFunc
- Func _winapi_dwordtoint($ivalue)
- Local $tdata = DllStructCreate("int")
- DllStructSetData($tdata, 1, $ivalue)
- Return DllStructGetData($tdata, 1)
- EndFunc
- Func _winapi_floattodword($ivalue)
- Local $tfloat = DllStructCreate("float")
- Local $tdword = DllStructCreate("dword", DllStructGetPtr($tfloat))
- DllStructSetData($tfloat, 1, $ivalue)
- Return DllStructGetData($tdword, 1)
- EndFunc
- Func _winapi_floattoint($nfloat)
- Local $tfloat = DllStructCreate("float")
- Local $tint = DllStructCreate("int", DllStructGetPtr($tfloat))
- DllStructSetData($tfloat, 1, $nfloat)
- Return DllStructGetData($tint, 1)
- EndFunc
- Func _winapi_getxyfrompoint(ByRef $tpoint, ByRef $ix, ByRef $iy)
- $ix = DllStructGetData($tpoint, "X")
- $iy = DllStructGetData($tpoint, "Y")
- EndFunc
- Func _winapi_guidfromstring($sguid)
- Local $tguid = DllStructCreate($tagguid)
- _winapi_guidfromstringex($sguid, $tguid)
- If @error Then Return SetError(@error + 10, @extended, 0)
- Return $tguid
- EndFunc
- Func _winapi_guidfromstringex($sguid, $tguid)
- Local $aresult = DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $sguid, "struct*", $tguid)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_hashdata($pmemory, $isize, $ilength = 32)
- If ($ilength <= 0) OR ($ilength > 256) Then Return SetError(11, 0, 0)
- Local $tdata = DllStructCreate("byte[" & $ilength & "]")
- Local $aret = DllCall("shlwapi.dll", "uint", "HashData", "struct*", $pmemory, "dword", $isize, "struct*", $tdata, "dword", $ilength)
- If @error Then Return SetError(@error, @extended, 0)
- If $aret[0] Then Return SetError(10, $aret[0], 0)
- Return DllStructGetData($tdata, 1)
- EndFunc
- Func _winapi_hashstring($sstring, $bcasesensitive = True, $ilength = 32)
- Local $ilengths = StringLen($sstring)
- If NOT $ilengths OR ($ilength > 256) Then Return SetError(12, 0, 0)
- Local $tstring = DllStructCreate("wchar[" & ($ilengths + 1) & "]")
- If NOT $bcasesensitive Then
- $sstring = StringLower($sstring)
- EndIf
- DllStructSetData($tstring, 1, $sstring)
- Local $shash = _winapi_hashdata($tstring, 2 * $ilengths, $ilength)
- If @error Then Return SetError(@error, @extended, 0)
- Return $shash
- EndFunc
- Func _winapi_hibyte($ivalue)
- Return BitAND(BitShift($ivalue, 8), 255)
- EndFunc
- Func _winapi_hidword($ivalue)
- Local $tint64 = DllStructCreate("int64")
- Local $tqword = DllStructCreate("dword;dword", DllStructGetPtr($tint64))
- DllStructSetData($tint64, 1, $ivalue)
- Return DllStructGetData($tqword, 2)
- EndFunc
- Func _winapi_hiword($ilong)
- Return BitShift($ilong, 16)
- EndFunc
- Func _winapi_inttodword($ivalue)
- Local $tdata = DllStructCreate("dword")
- DllStructSetData($tdata, 1, $ivalue)
- Return DllStructGetData($tdata, 1)
- EndFunc
- Func _winapi_inttofloat($iint)
- Local $tint = DllStructCreate("int")
- Local $tfloat = DllStructCreate("float", DllStructGetPtr($tint))
- DllStructSetData($tint, 1, $iint)
- Return DllStructGetData($tfloat, 1)
- EndFunc
- Func _winapi_lobyte($ivalue)
- Return BitAND($ivalue, 255)
- EndFunc
- Func _winapi_lodword($ivalue)
- Local $tint64 = DllStructCreate("int64")
- Local $tqword = DllStructCreate("dword;dword", DllStructGetPtr($tint64))
- DllStructSetData($tint64, 1, $ivalue)
- Return DllStructGetData($tqword, 1)
- EndFunc
- Func _winapi_loword($ilong)
- Return BitAND($ilong, 65535)
- EndFunc
- Func _winapi_longmid($ivalue, $istart, $icount)
- Return BitAND(BitShift($ivalue, $istart), BitOR(BitShift(BitShift(2147483647, 32 - ($icount + 1)), 1), BitShift(1, -($icount - 1))))
- EndFunc
- Func _winapi_makelangid($ilngidprimary, $ilngidsub)
- Return BitOR(BitShift($ilngidsub, -10), $ilngidprimary)
- EndFunc
- Func _winapi_makelcid($ilngid, $isortid)
- Return BitOR(BitShift($isortid, -16), $ilngid)
- EndFunc
- Func _winapi_makelong($ilo, $ihi)
- Return BitOR(BitShift($ihi, -16), BitAND($ilo, 65535))
- EndFunc
- Func _winapi_makeqword($ilodword, $ihidword)
- Local $tint64 = DllStructCreate("uint64")
- Local $tdwords = DllStructCreate("dword;dword", DllStructGetPtr($tint64))
- DllStructSetData($tdwords, 1, $ilodword)
- DllStructSetData($tdwords, 2, $ihidword)
- Return DllStructGetData($tint64, 1)
- EndFunc
- Func _winapi_makeword($ilo, $ihi)
- Local $tword = DllStructCreate("ushort")
- Local $tbyte = DllStructCreate("byte;byte", DllStructGetPtr($tword))
- DllStructSetData($tbyte, 1, $ihi)
- DllStructSetData($tbyte, 2, $ilo)
- Return DllStructGetData($tword, 1)
- EndFunc
- Func _winapi_multibytetowidechar($vtext, $icodepage = 0, $iflags = 0, $bretstring = False)
- Local $stexttype = "str"
- If NOT IsString($vtext) Then $stexttype = "struct*"
- Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, $stexttype, $vtext, "int", -1, "ptr", 0, "int", 0)
- If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
- Local $iout = $aresult[0]
- Local $tout = DllStructCreate("wchar[" & $iout & "]")
- $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, $stexttype, $vtext, "int", -1, "struct*", $tout, "int", $iout)
- If @error OR NOT $aresult[0] Then Return SetError(@error + 20, @extended, 0)
- If $bretstring Then Return DllStructGetData($tout, 1)
- Return $tout
- EndFunc
- Func _winapi_multibytetowidecharex($stext, $ptext, $icodepage = 0, $iflags = 0)
- Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, "STR", $stext, "int", -1, "struct*", $ptext, "int", (StringLen($stext) + 1) * 2)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_oemtochar($sstr)
- Local $aret = DllCall("user32.dll", "bool", "OemToChar", "str", $sstr, "str", "")
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
- Return $aret[2]
- EndFunc
- Func _winapi_pointfromrect(ByRef $trect, $bcenter = True)
- Local $ix1 = DllStructGetData($trect, "Left")
- Local $iy1 = DllStructGetData($trect, "Top")
- Local $ix2 = DllStructGetData($trect, "Right")
- Local $iy2 = DllStructGetData($trect, "Bottom")
- If $bcenter Then
- $ix1 = $ix1 + (($ix2 - $ix1) / 2)
- $iy1 = $iy1 + (($iy2 - $iy1) / 2)
- EndIf
- Local $tpoint = DllStructCreate($tagpoint)
- DllStructSetData($tpoint, "X", $ix1)
- DllStructSetData($tpoint, "Y", $iy1)
- Return $tpoint
- EndFunc
- Func _winapi_primarylangid($ilngid)
- Return BitAND($ilngid, 1023)
- EndFunc
- Func _winapi_screentoclient($hwnd, ByRef $tpoint)
- Local $aresult = DllCall("user32.dll", "bool", "ScreenToClient", "hwnd", $hwnd, "struct*", $tpoint)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_shorttoword($ivalue)
- Return BitAND($ivalue, 65535)
- EndFunc
- Func _winapi_strformatbytesize($isize)
- Local $aret = DllCall("shlwapi.dll", "ptr", "StrFormatByteSizeW", "int64", $isize, "wstr", "", "uint", 1024)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
- Return $aret[2]
- EndFunc
- Func _winapi_strformatbytesizeex($isize)
- Local $asymbol = DllCall("kernel32.dll", "int", "GetLocaleInfoW", "dword", 1024, "dword", 15, "wstr", "", "int", 2048)
- If @error Then Return SetError(@error + 10, @extended, "")
- Local $ssize = _winapi_strformatbytesize(0)
- If @error Then Return SetError(@error, @extended, "")
- Return StringReplace($ssize, "0", StringRegExpReplace(Number($isize), "(?<=\d)(?=(\d{3})+\z)", $asymbol[3]))
- EndFunc
- Func _winapi_strformatkbsize($isize)
- Local $aret = DllCall("shlwapi.dll", "ptr", "StrFormatKBSizeW", "int64", $isize, "wstr", "", "uint", 1024)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
- Return $aret[2]
- EndFunc
- Func _winapi_strfromtimeinterval($itime, $idigits = 7)
- Local $aret = DllCall("shlwapi.dll", "int", "StrFromTimeIntervalW", "wstr", "", "uint", 1024, "dword", $itime, "int", $idigits)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
- Return StringStripWS($aret[1], $str_stripleading + $str_striptrailing)
- EndFunc
- Func _winapi_stringfromguid($tguid)
- Local $aresult = DllCall("ole32.dll", "int", "StringFromGUID2", "struct*", $tguid, "wstr", "", "int", 40)
- If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, "")
- Return SetExtended($aresult[0], $aresult[2])
- EndFunc
- Func _winapi_sublangid($ilngid)
- Return BitShift($ilngid, 10)
- EndFunc
- Func _winapi_swapdword($ivalue)
- Local $tstruct1 = DllStructCreate("dword;dword")
- Local $tstruct2 = DllStructCreate("byte[4];byte[4]", DllStructGetPtr($tstruct1))
- DllStructSetData($tstruct1, 1, $ivalue)
- For $i = 1 To 4
- DllStructSetData($tstruct2, 2, DllStructGetData($tstruct2, 1, 5 - $i), $i)
- Next
- Return DllStructGetData($tstruct1, 2)
- EndFunc
- Func _winapi_swapqword($ivalue)
- Local $tstruct1 = DllStructCreate("int64;int64")
- Local $tstruct2 = DllStructCreate("byte[8];byte[8]", DllStructGetPtr($tstruct1))
- DllStructSetData($tstruct1, 1, $ivalue)
- For $i = 1 To 8
- DllStructSetData($tstruct2, 2, DllStructGetData($tstruct2, 1, 9 - $i), $i)
- Next
- Return DllStructGetData($tstruct1, 2)
- EndFunc
- Func _winapi_swapword($ivalue)
- Local $tstruct1 = DllStructCreate("word;word")
- Local $tstruct2 = DllStructCreate("byte[2];byte[2]", DllStructGetPtr($tstruct1))
- DllStructSetData($tstruct1, 1, $ivalue)
- For $i = 1 To 2
- DllStructSetData($tstruct2, 2, DllStructGetData($tstruct2, 1, 3 - $i), $i)
- Next
- Return DllStructGetData($tstruct1, 2)
- EndFunc
- Func _winapi_widechartomultibyte($vunicode, $icodepage = 0, $bretnostruct = True, $bretbinary = False)
- Local $sunicodetype = "wstr"
- If NOT IsString($vunicode) Then $sunicodetype = "struct*"
- Local $aresult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $icodepage, "dword", 0, $sunicodetype, $vunicode, "int", -1, "ptr", 0, "int", 0, "ptr", 0, "ptr", 0)
- If @error OR NOT $aresult[0] Then Return SetError(@error + 20, @extended, "")
- Local $tmultibyte = DllStructCreate((($bretbinary) ? ("byte") : ("char")) & "[" & $aresult[0] & "]")
- $aresult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $icodepage, "dword", 0, $sunicodetype, $vunicode, "int", -1, "struct*", $tmultibyte, "int", $aresult[0], "ptr", 0, "ptr", 0)
- If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
- If $bretnostruct Then Return DllStructGetData($tmultibyte, 1)
- Return $tmultibyte
- EndFunc
- Func _winapi_wordtoshort($ivalue)
- If BitAND($ivalue, 32768) Then
- Return BitOR($ivalue, -32768)
- EndIf
- Return BitAND($ivalue, 32767)
- EndFunc
- #EndRegion Public Functions
- #Region Global Variables and Constants
- Global $__g_hheap = 0
- #EndRegion Global Variables and Constants
- #Region Functions list
- #EndRegion Functions list
- #Region Public Functions
- Func _winapi_createbuffer($ilength, $pbuffer = 0, $babort = True)
- $pbuffer = __heaprealloc($pbuffer, $ilength, 0, $babort)
- If @error Then Return SetError(@error, @extended, 0)
- Return $pbuffer
- EndFunc
- Func _winapi_createbufferfromstruct($tstruct, $pbuffer = 0, $babort = True)
- If NOT IsDllStruct($tstruct) Then Return SetError(1, 0, 0)
- $pbuffer = __heaprealloc($pbuffer, DllStructGetSize($tstruct), 0, $babort)
- If @error Then Return SetError(@error + 100, @extended, 0)
- _winapi_movememory($pbuffer, $tstruct, DllStructGetSize($tstruct))
- Return $pbuffer
- EndFunc
- Func _winapi_createstring($sstring, $pstring = 0, $ilength = -1, $bunicode = True, $babort = True)
- $ilength = Number($ilength)
- If $ilength >= 0 Then
- $sstring = StringLeft($sstring, $ilength)
- Else
- $ilength = StringLen($sstring)
- EndIf
- Local $isize = $ilength + 1
- If $bunicode Then
- $isize *= 2
- EndIf
- $pstring = __heaprealloc($pstring, $isize, 0, $babort)
- If @error Then Return SetError(@error, @extended, 0)
- DllStructSetData(DllStructCreate(($bunicode ? "wchar" : "char") & "[" & ($ilength + 1) & "]", $pstring), 1, $sstring)
- Return SetExtended($ilength, $pstring)
- EndFunc
- Func _winapi_equalmemory($psource1, $psource2, $ilength)
- If _winapi_isbadreadptr($psource1, $ilength) Then Return SetError(11, @extended, 0)
- If _winapi_isbadreadptr($psource2, $ilength) Then Return SetError(12, @extended, 0)
- Local $aret = DllCall("ntdll.dll", "ulong_ptr", "RtlCompareMemory", "struct*", $psource1, "struct*", $psource2, "ulong_ptr", $ilength)
- If @error Then Return SetError(@error, @extended, 0)
- Return Number($aret[0] = $ilength)
- EndFunc
- Func _winapi_fillmemory($pmemory, $ilength, $ivalue = 0)
- If _winapi_isbadwriteptr($pmemory, $ilength) Then Return SetError(11, @extended, 0)
- DllCall("ntdll.dll", "none", "RtlFillMemory", "struct*", $pmemory, "ulong_ptr", $ilength, "byte", $ivalue)
- If @error Then Return SetError(@error, @extended, 0)
- Return 1
- EndFunc
- Func _winapi_freememory($pmemory)
- If NOT __heapfree($pmemory, 1) Then Return SetError(@error, @extended, 0)
- Return 1
- EndFunc
- Func _winapi_getmemorysize($pmemory)
- Local $iresult = __heapsize($pmemory, 1)
- If @error Then Return SetError(@error, @extended, 0)
- Return $iresult
- EndFunc
- Func _winapi_globalmemorystatus()
- Local Const $tagmemorystatusex = "dword Length;dword MemoryLoad;" & "uint64 TotalPhys;uint64 AvailPhys;uint64 TotalPageFile;uint64 AvailPageFile;" & "uint64 TotalVirtual;uint64 AvailVirtual;uint64 AvailExtendedVirtual"
- Local $tmem = DllStructCreate($tagmemorystatusex)
- DllStructSetData($tmem, 1, DllStructGetSize($tmem))
- Local $aret = DllCall("kernel32.dll", "bool", "GlobalMemoryStatusEx", "struct*", $tmem)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
- Local $amem[7]
- $amem[0] = DllStructGetData($tmem, 2)
- $amem[1] = DllStructGetData($tmem, 3)
- $amem[2] = DllStructGetData($tmem, 4)
- $amem[3] = DllStructGetData($tmem, 5)
- $amem[4] = DllStructGetData($tmem, 6)
- $amem[5] = DllStructGetData($tmem, 7)
- $amem[6] = DllStructGetData($tmem, 8)
- Return $amem
- EndFunc
- Func _winapi_isbadcodeptr($paddress)
- Local $aret = DllCall("kernel32.dll", "bool", "IsBadCodePtr", "struct*", $paddress)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_isbadreadptr($paddress, $ilength)
- Local $aret = DllCall("kernel32.dll", "bool", "IsBadReadPtr", "struct*", $paddress, "uint_ptr", $ilength)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_isbadstringptr($paddress, $ilength)
- Local $aret = DllCall("kernel32.dll", "bool", "IsBadStringPtr", "struct*", $paddress, "uint_ptr", $ilength)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_isbadwriteptr($paddress, $ilength)
- Local $aret = DllCall("kernel32.dll", "bool", "IsBadWritePtr", "struct*", $paddress, "uint_ptr", $ilength)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_ismemory($pmemory)
- Local $bresult = __heapvalidate($pmemory)
- Return SetError(@error, @extended, $bresult)
- EndFunc
- Func _winapi_localfree($hmemory)
- Local $aresult = DllCall("kernel32.dll", "handle", "LocalFree", "handle", $hmemory)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_movememory($pdestination, $psource, $ilength)
- If _winapi_isbadreadptr($psource, $ilength) Then Return SetError(10, @extended, 0)
- If _winapi_isbadwriteptr($pdestination, $ilength) Then Return SetError(11, @extended, 0)
- DllCall("ntdll.dll", "none", "RtlMoveMemory", "struct*", $pdestination, "struct*", $psource, "ulong_ptr", $ilength)
- If @error Then Return SetError(@error, @extended, 0)
- Return 1
- EndFunc
- Func _winapi_readprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isize, ByRef $iread)
- Local $aresult = DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $hprocess, "ptr", $pbaseaddress, "struct*", $pbuffer, "ulong_ptr", $isize, "ulong_ptr*", 0)
- If @error Then Return SetError(@error, @extended, False)
- $iread = $aresult[5]
- Return $aresult[0]
- EndFunc
- Func _winapi_writeprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isize, ByRef $iwritten, $sbuffer = "ptr")
- Local $aresult = DllCall("kernel32.dll", "bool", "WriteProcessMemory", "handle", $hprocess, "ptr", $pbaseaddress, $sbuffer, $pbuffer, "ulong_ptr", $isize, "ulong_ptr*", 0)
- If @error Then Return SetError(@error, @extended, False)
- $iwritten = $aresult[5]
- Return $aresult[0]
- EndFunc
- Func _winapi_zeromemory($pmemory, $ilength)
- If _winapi_isbadwriteptr($pmemory, $ilength) Then Return SetError(11, @extended, 0)
- DllCall("ntdll.dll", "none", "RtlZeroMemory", "struct*", $pmemory, "ulong_ptr", $ilength)
- If @error Then Return SetError(@error, @extended, 0)
- Return 1
- EndFunc
- #EndRegion Public Functions
- #Region Internal Functions
- Func __heapalloc($isize, $babort = False)
- Local $aret
- If NOT $__g_hheap Then
- $aret = DllCall("kernel32.dll", "handle", "HeapCreate", "dword", 0, "ulong_ptr", 0, "ulong_ptr", 0)
- If @error OR NOT $aret[0] Then __fatalexit(1, "Error allocating memory.")
- $__g_hheap = $aret[0]
- EndIf
- $aret = DllCall("kernel32.dll", "ptr", "HeapAlloc", "handle", $__g_hheap, "dword", 8, "ulong_ptr", $isize)
- If @error OR NOT $aret[0] Then
- If $babort Then __fatalexit(1, "Error allocating memory.")
- Return SetError(@error + 30, @extended, 0)
- EndIf
- Return $aret[0]
- EndFunc
- Func __heapfree(ByRef $pmemory, $bcheck = False, $icurerr = @error, $icurext = @extended)
- If $bcheck AND (NOT __heapvalidate($pmemory)) Then Return SetError(@error, @extended, 0)
- Local $aret = DllCall("kernel32.dll", "int", "HeapFree", "handle", $__g_hheap, "dword", 0, "ptr", $pmemory)
- If @error OR NOT $aret[0] Then Return SetError(@error + 40, @extended, 0)
- $pmemory = 0
- Return SetError($icurerr, $icurext, 1)
- EndFunc
- Func __heaprealloc($pmemory, $isize, $bamount = False, $babort = False)
- Local $aret, $pret
- If __heapvalidate($pmemory) Then
- If $bamount AND (__heapsize($pmemory) >= $isize) Then Return SetExtended(1, Ptr($pmemory))
- $aret = DllCall("kernel32.dll", "ptr", "HeapReAlloc", "handle", $__g_hheap, "dword", 8, "ptr", $pmemory, "ulong_ptr", $isize)
- If @error OR NOT $aret[0] Then
- If $babort Then __fatalexit(1, "Error allocating memory.")
- Return SetError(@error + 20, @extended, Ptr($pmemory))
- EndIf
- $pret = $aret[0]
- Else
- $pret = __heapalloc($isize, $babort)
- If @error Then Return SetError(@error, @extended, 0)
- EndIf
- Return $pret
- EndFunc
- Func __heapsize($pmemory, $bcheck = False)
- If $bcheck AND (NOT __heapvalidate($pmemory)) Then Return SetError(@error, @extended, 0)
- Local $aret = DllCall("kernel32.dll", "ulong_ptr", "HeapSize", "handle", $__g_hheap, "dword", 0, "ptr", $pmemory)
- If @error OR ($aret[0] = Ptr(-1)) Then Return SetError(@error + 50, @extended, 0)
- Return $aret[0]
- EndFunc
- Func __heapvalidate($pmemory)
- If (NOT $__g_hheap) OR (NOT Ptr($pmemory)) Then Return SetError(9, 0, False)
- Local $aret = DllCall("kernel32.dll", "int", "HeapValidate", "handle", $__g_hheap, "dword", 0, "ptr", $pmemory)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- #EndRegion Internal Functions
- Global Const $snd_application = 128
- Global Const $snd_alias = 65536
- Global Const $snd_alias_id = 1114112
- Global Const $snd_async = 1
- Global Const $snd_filename = 131072
- Global Const $snd_loop = 8
- Global Const $snd_memory = 4
- Global Const $snd_nodefault = 2
- Global Const $snd_nostop = 16
- Global Const $snd_nowait = 8192
- Global Const $snd_purge = 64
- Global Const $snd_resource = 262148
- Global Const $snd_sentry = 524288
- Global Const $snd_sync = 0
- Global Const $snd_system = 2097152
- Global Const $snd_system_nostop = 2097168
- Global Const $snd_alias_systemasterisk = "SystemAsterisk"
- Global Const $snd_alias_systemdefault = "SystemDefault"
- Global Const $snd_alias_systemexclamation = "SystemExclamation"
- Global Const $snd_alias_systemexit = "SystemExit"
- Global Const $snd_alias_systemhand = "SystemHand"
- Global Const $snd_alias_systemquestion = "SystemQuestion"
- Global Const $snd_alias_systemstart = "SystemStart"
- Global Const $snd_alias_systemwelcome = "SystemWelcome"
- #Region Global Variables and Constants
- #EndRegion Global Variables and Constants
- #Region Functions list
- #EndRegion Functions list
- #Region Public Functions
- Func _winapi_arraytostruct(Const ByRef $adata, $istart = 0, $iend = -1)
- If __checkerrorarraybounds($adata, $istart, $iend) Then Return SetError(@error + 10, @extended, 0)
- Local $tagstruct = ""
- For $i = $istart To $iend
- $tagstruct &= "wchar[" & (StringLen($adata[$i]) + 1) & "];"
- Next
- Local $tdata = DllStructCreate($tagstruct & "wchar[1]")
- Local $icount = 1
- For $i = $istart To $iend
- DllStructSetData($tdata, $icount, $adata[$i])
- $icount += 1
- Next
- DllStructSetData($tdata, $icount, ChrW(0))
- Return $tdata
- EndFunc
- Func _winapi_createmargins($ileftwidth, $irightwidth, $itopheight, $ibottomheight)
- Local $tmargins = DllStructCreate($tagmargins)
- DllStructSetData($tmargins, 1, $ileftwidth)
- DllStructSetData($tmargins, 2, $irightwidth)
- DllStructSetData($tmargins, 3, $itopheight)
- DllStructSetData($tmargins, 4, $ibottomheight)
- Return $tmargins
- EndFunc
- Func _winapi_createpoint($ix, $iy)
- Local $tpoint = DllStructCreate($tagpoint)
- DllStructSetData($tpoint, 1, $ix)
- DllStructSetData($tpoint, 2, $iy)
- Return $tpoint
- EndFunc
- Func _winapi_createrect($ileft, $itop, $iright, $ibottom)
- Local $trect = DllStructCreate($tagrect)
- DllStructSetData($trect, 1, $ileft)
- DllStructSetData($trect, 2, $itop)
- DllStructSetData($trect, 3, $iright)
- DllStructSetData($trect, 4, $ibottom)
- Return $trect
- EndFunc
- Func _winapi_createrectex($ix, $iy, $iwidth, $iheight)
- Local $trect = DllStructCreate($tagrect)
- DllStructSetData($trect, 1, $ix)
- DllStructSetData($trect, 2, $iy)
- DllStructSetData($trect, 3, $ix + $iwidth)
- DllStructSetData($trect, 4, $iy + $iheight)
- Return $trect
- EndFunc
- Func _winapi_createsize($iwidth, $iheight)
- Local $tsize = DllStructCreate($tagsize)
- DllStructSetData($tsize, 1, $iwidth)
- DllStructSetData($tsize, 2, $iheight)
- Return $tsize
- EndFunc
- Func _winapi_copystruct($tstruct, $sstruct = "")
- Local $isize = DllStructGetSize($tstruct)
- If NOT $isize Then Return SetError(1, 0, 0)
- Local $tresult
- If NOT StringStripWS($sstruct, $str_stripleading + $str_striptrailing + $str_stripspaces) Then
- $tresult = DllStructCreate("byte[" & $isize & "]")
- Else
- $tresult = DllStructCreate($sstruct)
- EndIf
- If DllStructGetSize($tresult) < $isize Then Return SetError(2, 0, 0)
- _winapi_movememory($tresult, $tstruct, $isize)
- Return $tresult
- EndFunc
- Func _winapi_getextended()
- Return $__g_vext
- EndFunc
- Func _winapi_getmousepos($btoclient = False, $hwnd = 0)
- Local $imode = Opt("MouseCoordMode", 1)
- Local $apos = MouseGetPos()
- Opt("MouseCoordMode", $imode)
- Local $tpoint = DllStructCreate($tagpoint)
- DllStructSetData($tpoint, "X", $apos[0])
- DllStructSetData($tpoint, "Y", $apos[1])
- If $btoclient AND NOT _winapi_screentoclient($hwnd, $tpoint) Then Return SetError(@error + 20, @extended, 0)
- Return $tpoint
- EndFunc
- Func _winapi_getmouseposx($btoclient = False, $hwnd = 0)
- Local $tpoint = _winapi_getmousepos($btoclient, $hwnd)
- If @error Then Return SetError(@error, @extended, 0)
- Return DllStructGetData($tpoint, "X")
- EndFunc
- Func _winapi_getmouseposy($btoclient = False, $hwnd = 0)
- Local $tpoint = _winapi_getmousepos($btoclient, $hwnd)
- If @error Then Return SetError(@error, @extended, 0)
- Return DllStructGetData($tpoint, "Y")
- EndFunc
- Func _winapi_muldiv($inumber, $inumerator, $idenominator)
- Local $aresult = DllCall("kernel32.dll", "int", "MulDiv", "int", $inumber, "int", $inumerator, "int", $idenominator)
- If @error Then Return SetError(@error, @extended, -1)
- Return $aresult[0]
- EndFunc
- Func _winapi_playsound($ssound, $iflags = $snd_system_nostop, $hinstance = 0)
- Local $stypeofsound = "ptr"
- If $ssound Then
- If IsString($ssound) Then
- $stypeofsound = "wstr"
- EndIf
- Else
- $ssound = 0
- $iflags = 0
- EndIf
- Local $aret = DllCall("winmm.dll", "bool", "PlaySoundW", $stypeofsound, $ssound, "handle", $hinstance, "dword", $iflags)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_stringlena(Const ByRef $tstring)
- Local $aresult = DllCall("kernel32.dll", "int", "lstrlenA", "struct*", $tstring)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_stringlenw(Const ByRef $tstring)
- Local $aresult = DllCall("kernel32.dll", "int", "lstrlenW", "struct*", $tstring)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aresult[0]
- EndFunc
- Func _winapi_structtoarray(ByRef $tstruct, $iitems = 0)
- Local $isize = 2 * Floor(DllStructGetSize($tstruct) / 2)
- Local $pstruct = DllStructGetPtr($tstruct)
- If NOT $isize OR NOT $pstruct Then Return SetError(1, 0, 0)
- Local $tdata, $ilength, $ioffset = 0
- Local $aresult[101] = [0]
- While 1
- $ilength = _winapi_strlen($pstruct + $ioffset)
- If NOT $ilength Then
- ExitLoop
- EndIf
- If 2 * (1 + $ilength) + $ioffset > $isize Then Return SetError(3, 0, 0)
- $tdata = DllStructCreate("wchar[" & (1 + $ilength) & "]", $pstruct + $ioffset)
- If @error Then Return SetError(@error + 10, 0, 0)
- __inc($aresult)
- $aresult[$aresult[0]] = DllStructGetData($tdata, 1)
- If $aresult[0] = $iitems Then
- ExitLoop
- EndIf
- $ioffset += 2 * (1 + $ilength)
- If $ioffset >= $isize Then Return SetError(3, 0, 0)
- WEnd
- If NOT $aresult[0] Then Return SetError(2, 0, 0)
- __inc($aresult, -1)
- Return $aresult
- EndFunc
- Func _winapi_unionstruct($tstruct1, $tstruct2, $sstruct = "")
- Local $asize[2] = [DllStructGetSize($tstruct1), DllStructGetSize($tstruct2)]
- If NOT $asize[0] OR NOT $asize[1] Then Return SetError(1, 0, 0)
- Local $tresult
- If NOT StringStripWS($sstruct, $str_stripleading + $str_striptrailing + $str_stripspaces) Then
- $tresult = DllStructCreate("byte[" & ($asize[0] + $asize[1]) & "]")
- Else
- $tresult = DllStructCreate($sstruct)
- EndIf
- If DllStructGetSize($tresult) < ($asize[0] + $asize[1]) Then Return SetError(2, 0, 0)
- _winapi_movememory($tresult, $tstruct1, $asize[0])
- _winapi_movememory(DllStructGetPtr($tresult) + $asize[0], $tstruct2, $asize[1])
- Return $tresult
- EndFunc
- #EndRegion Public Functions
- Global Const $url_scheme_invalid = -1
- Global Const $url_scheme_unknown = 0
- Global Const $url_scheme_ftp = 1
- Global Const $url_scheme_http = 2
- Global Const $url_scheme_gopher = 3
- Global Const $url_scheme_mailto = 4
- Global Const $url_scheme_news = 5
- Global Const $url_scheme_nntp = 6
- Global Const $url_scheme_telnet = 7
- Global Const $url_scheme_wais = 8
- Global Const $url_scheme_file = 9
- Global Const $url_scheme_mk = 10
- Global Const $url_scheme_https = 11
- Global Const $url_scheme_shell = 12
- Global Const $url_scheme_snews = 13
- Global Const $url_scheme_local = 14
- Global Const $url_scheme_javascript = 15
- Global Const $url_scheme_vbscript = 16
- Global Const $url_scheme_about = 17
- Global Const $url_scheme_res = 18
- Global Const $url_scheme_msshellrooted = 19
- Global Const $url_scheme_msshellidlist = 20
- Global Const $url_scheme_mshelp = 21
- Global Const $url_scheme_msshelldevice = 22
- Global Const $url_scheme_wildcard = 23
- Global Const $url_scheme_search_ms = 24
- Global Const $url_scheme_search = 25
- Global Const $url_scheme_knownfolder = 26
- Global Const $gct_invalid = 0
- Global Const $gct_lfnchar = 1
- Global Const $gct_separator = 8
- Global Const $gct_shortchar = 2
- Global Const $gct_wild = 4
- Global Const $url_apply_default = 1
- Global Const $url_apply_guessscheme = 2
- Global Const $url_apply_guessfile = 4
- Global Const $url_apply_forceapply = 8
- Global Const $url_dont_simplify = 134217728
- Global Const $url_escape_as_utf8 = 262144
- Global Const $url_escape_percent = 4096
- Global Const $url_escape_spaces_only = 67108864
- Global Const $url_escape_unsafe = 536870912
- Global Const $url_no_meta = 134217728
- Global Const $url_pluggable_protocol = 1073741824
- Global Const $url_unescape = 268435456
- Global Const $url_part_hostname = 2
- Global Const $url_part_password = 4
- Global Const $url_part_port = 5
- Global Const $url_part_query = 6
- Global Const $url_part_scheme = 1
- Global Const $url_part_username = 3
- Global Const $urlis_appliable = 4
- Global Const $urlis_directory = 5
- Global Const $urlis_fileurl = 3
- Global Const $urlis_hasquery = 6
- Global Const $urlis_nohistory = 2
- Global Const $urlis_opaque = 1
- Global Const $urlis_url = 0
- #Region Functions list
- #EndRegion Functions list
- #Region Public Functions
- Func _winapi_commandlinetoargv($scmd)
- Local $aresult[1] = [0]
- $scmd = StringStripWS($scmd, $str_stripleading + $str_striptrailing)
- If NOT $scmd Then
- Return $aresult
- EndIf
- Local $aret = DllCall("shell32.dll", "ptr", "CommandLineToArgvW", "wstr", $scmd, "int*", 0)
- If @error OR NOT $aret[0] OR (NOT $aret[2]) Then Return SetError(@error + 10, @extended, 0)
- Local $tptr = DllStructCreate("ptr[" & $aret[2] & "]", $aret[0])
- Dim $aresult[$aret[2] + 1] = [$aret[2]]
- For $i = 1 To $aret[2]
- $aresult[$i] = _winapi_getstring(DllStructGetData($tptr, 1, $i))
- Next
- DllCall("kernel32.dll", "handle", "LocalFree", "handle", $aret[0])
- Return $aresult
- EndFunc
- Func _winapi_isnameinexpression($sstring, $spattern, $bcasesensitive = False)
- If NOT $bcasesensitive Then $spattern = StringUpper($spattern)
- Local $tus1 = __us($spattern)
- Local $tus2 = __us($sstring)
- Local $aret = DllCall("ntdll.dll", "boolean", "RtlIsNameInExpression", "struct*", $tus1, "struct*", $tus2, "boolean", NOT $bcasesensitive, "ptr", 0)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_parseurl($surl)
- Local $tagparsedurl = "dword Size;ptr Protocol;uint cchProtocol;ptr Suffix;uint cchSuffix;uint Scheme"
- Local $tpurl = DllStructCreate($tagparsedurl)
- DllStructSetData($tpurl, 1, DllStructGetSize($tpurl))
- Local $turl = DllStructCreate("wchar[4096]")
- DllStructSetData($turl, 1, $surl)
- Local $aret = DllCall("shlwapi.dll", "long", "ParseURLW", "struct*", $turl, "struct*", $tpurl)
- If @error Then Return SetError(@error, @extended, "")
- If $aret[0] Then Return SetError(10, $aret[0], "")
- Local $aresult[3]
- $aresult[0] = DllStructGetData(DllStructCreate("wchar[" & DllStructGetData($tpurl, 3) & "]", DllStructGetData($tpurl, 2)), 1)
- $aresult[1] = DllStructGetData(DllStructCreate("wchar[" & DllStructGetData($tpurl, 5) & "]", DllStructGetData($tpurl, 4)), 1)
- $aresult[2] = DllStructGetData($tpurl, 6)
- Return $aresult
- EndFunc
- Func _winapi_parseusername($suser)
- If NOT __dll("credui.dll") Then Return SetError(103, 0, 0)
- Local $aret = DllCall("credui.dll", "dword", "CredUIParseUserNameW", "wstr", $suser, "wstr", "", "ulong", 4096, "wstr", "", "ulong", 4096)
- If @error Then Return SetError(@error, @extended, 0)
- Switch $aret[0]
- Case 0
- Case 1315
- If StringStripWS($suser, $str_stripleading + $str_striptrailing) Then
- $aret[2] = $suser
- $aret[4] = ""
- Else
- ContinueCase
- EndIf
- Case Else
- Return SetError(10, $aret[0], 0)
- EndSwitch
- Local $aresult[2]
- $aresult[0] = $aret[4]
- $aresult[1] = $aret[2]
- Return $aresult
- EndFunc
- Func _winapi_pathaddbackslash($sfilepath)
- Local $tpath = DllStructCreate("wchar[260]")
- DllStructSetData($tpath, 1, $sfilepath)
- Local $aret = DllCall("shlwapi.dll", "ptr", "PathAddBackslashW", "struct*", $tpath)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return DllStructGetData($tpath, 1)
- EndFunc
- Func _winapi_pathaddextension($sfilepath, $sext = "")
- Local $tpath = DllStructCreate("wchar[260]")
- DllStructSetData($tpath, 1, $sfilepath)
- Local $stypeofext = "wstr"
- If NOT StringStripWS($sext, $str_stripleading + $str_striptrailing) Then
- $stypeofext = "ptr"
- $sext = 0
- EndIf
- Local $aret = DllCall("shlwapi.dll", "bool", "PathAddExtensionW", "struct*", $tpath, $stypeofext, $sext)
- If @error Then Return SetError(@error, @extended, "")
- Return SetExtended($aret[0], DllStructGetData($tpath, 1))
- EndFunc
- Func _winapi_pathappend($sfilepath, $smore)
- Local $tpath = DllStructCreate("wchar[260]")
- DllStructSetData($tpath, 1, $sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathAppendW", "struct*", $tpath, "wstr", $smore)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return DllStructGetData($tpath, 1)
- EndFunc
- Func _winapi_pathbuildroot($idrive)
- Local $aret = DllCall("shlwapi.dll", "ptr", "PathBuildRootW", "wstr", "", "int", $idrive)
- If @error Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_pathcanonicalize($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathCanonicalizeW", "wstr", "", "wstr", $sfilepath)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, $sfilepath)
- Return $aret[1]
- EndFunc
- Func _winapi_pathcommonprefix($spath1, $spath2)
- Local $aret = DllCall("shlwapi.dll", "int", "PathCommonPrefixW", "wstr", $spath1, "wstr", $spath2, "wstr", "")
- If @error Then Return SetError(@error, @extended, "")
- Return SetExtended($aret[0], $aret[3])
- EndFunc
- Func _winapi_pathcompactpath($hwnd, $sfilepath, $iwidth = 0)
- If $iwidth < 1 Then
- Local $trect = DllStructCreate($tagrect)
- DllCall("user32.dll", "bool", "GetClientRect", "hwnd", $hwnd, "struct*", $trect)
- $iwidth += DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left")
- EndIf
- Local $aret = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hwnd)
- If @error OR NOT $aret[0] Then Return SetError(@error + 20, @extended, $sfilepath)
- Local $hdc = $aret[0]
- Local Const $wm_getfont = 49
- $aret = DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hwnd, "uint", $wm_getfont, "wparam", 0, "lparam", 0)
- Local $hback = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hdc, "handle", $aret[0])
- Local $ierror = 0
- $aret = DllCall("shlwapi.dll", "bool", "PathCompactPathW", "handle", $hdc, "wstr", $sfilepath, "int", $iwidth)
- If @error OR NOT $aret[0] Then $ierror = @error + 10
- DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hdc, "handle", $hback[0])
- DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hwnd, "handle", $hdc)
- If $ierror Then Return SetError($ierror, 0, $sfilepath)
- Return $aret[2]
- EndFunc
- Func _winapi_pathcompactpathex($sfilepath, $imax)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathCompactPathExW", "wstr", "", "wstr", $sfilepath, "uint", $imax + 1, "dword", 0)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, $sfilepath)
- Return $aret[1]
- EndFunc
- Func _winapi_pathcreatefromurl($surl)
- Local $aret = DllCall("shlwapi.dll", "long", "PathCreateFromUrlW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", 0)
- If @error Then Return SetError(@error, @extended, "")
- If $aret[0] Then Return SetError(10, $aret[0], "")
- Return $aret[2]
- EndFunc
- Func _winapi_pathfindextension($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "wstr", "PathFindExtensionW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, "")
- Return $aret[0]
- EndFunc
- Func _winapi_pathfindfilename($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "wstr", "PathFindFileNameW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, $sfilepath)
- Return $aret[0]
- EndFunc
- Func _winapi_pathfindnextcomponent($sfilepath)
- Local $tpath = DllStructCreate("wchar[" & (StringLen($sfilepath) + 1) & "]")
- DllStructSetData($tpath, 1, $sfilepath)
- Local $aret = DllCall("shlwapi.dll", "ptr", "PathFindNextComponentW", "struct*", $tpath)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
- Return _winapi_getstring($aret[0])
- EndFunc
- Func _winapi_pathfindonpath(Const $sfilepath, $aextrapaths = "", Const $spathdelimiter = @LF)
- Local $iextracount = 0
- If IsString($aextrapaths) Then
- If StringLen($aextrapaths) Then
- $aextrapaths = StringSplit($aextrapaths, $spathdelimiter, $str_entiresplit + $str_nocount)
- $iextracount = UBound($aextrapaths, $ubound_rows)
- EndIf
- ElseIf IsArray($aextrapaths) Then
- $iextracount = UBound($aextrapaths)
- EndIf
- Local $tpaths, $tpathptrs
- If $iextracount Then
- Local $tagstruct = ""
- For $path In $aextrapaths
- $tagstruct &= "wchar[" & StringLen($path) + 1 & "];"
- Next
- $tpaths = DllStructCreate($tagstruct)
- $tpathptrs = DllStructCreate("ptr[" & $iextracount + 1 & "]")
- For $i = 1 To $iextracount
- DllStructSetData($tpaths, $i, $aextrapaths[$i - 1])
- DllStructSetData($tpathptrs, 1, DllStructGetPtr($tpaths, $i), $i)
- Next
- DllStructSetData($tpathptrs, 1, Ptr(0), $iextracount + 1)
- EndIf
- Local $aresult = DllCall("shlwapi.dll", "bool", "PathFindOnPathW", "wstr", $sfilepath, "struct*", $tpathptrs)
- If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, $sfilepath)
- Return $aresult[1]
- EndFunc
- Func _winapi_pathgetargs($sfilepath)
- Local $tpath = DllStructCreate("wchar[" & (StringLen($sfilepath) + 1) & "]")
- DllStructSetData($tpath, 1, $sfilepath)
- Local $aret = DllCall("shlwapi.dll", "ptr", "PathGetArgsW", "struct*", $tpath)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return _winapi_getstring($aret[0])
- EndFunc
- Func _winapi_pathgetchartype($schar)
- Local $aret = DllCall("shlwapi.dll", "uint", "PathGetCharTypeW", "word", AscW($schar))
- If @error Then Return SetError(@error, @extended, -1)
- Return $aret[0]
- EndFunc
- Func _winapi_pathgetdrivenumber($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "int", "PathGetDriveNumberW", "wstr", $sfilepath)
- If @error OR ($aret[0] = -1) Then Return SetError(@error, @extended, "")
- Return Chr($aret[0] + 65) & ":"
- EndFunc
- Func _winapi_pathiscontenttype($sfilepath, $stype)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsContentTypeW", "wstr", $sfilepath, "wstr", $stype)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathisexe($sfilepath)
- Local $aret = DllCall("shell32.dll", "bool", "PathIsExe", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathisfilespec($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsFileSpecW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathislfnfilespec($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsLFNFileSpecW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathisrelative($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsRelativeW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathisroot($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsRootW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathissameroot($spath1, $spath2)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsSameRootW", "wstr", $spath1, "wstr", $spath2)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathissystemfolder($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsSystemFolderW", "wstr", $sfilepath, "dword", 0)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathisunc($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsUNCW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathisuncserver($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsUNCServerW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathisuncservershare($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsUNCServerShareW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathmakesystemfolder($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathMakeSystemFolderW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathmatchspec($sfilepath, $sspec)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathMatchSpecW", "wstr", $sfilepath, "wstr", $sspec)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathparseiconlocation($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "int", "PathParseIconLocationW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, 0)
- Local $aresult[2]
- $aresult[0] = $aret[1]
- $aresult[1] = $aret[0]
- Return $aresult
- EndFunc
- Func _winapi_pathrelativepathto($spathfrom, $bdirfrom, $spathto, $bdirto)
- If $bdirfrom Then
- $bdirfrom = 16
- EndIf
- If $bdirto Then
- $bdirto = 16
- EndIf
- Local $aret = DllCall("shlwapi.dll", "bool", "PathRelativePathToW", "wstr", "", "wstr", $spathfrom, "dword", $bdirfrom, "wstr", $spathto, "dword", $bdirto)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_pathremoveargs($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "none", "PathRemoveArgsW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_pathremovebackslash($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "ptr", "PathRemoveBackslashW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_pathremoveextension($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "none", "PathRemoveExtensionW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_pathremovefilespec($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathRemoveFileSpecW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, "")
- Return SetExtended($aret[0], $aret[1])
- EndFunc
- Func _winapi_pathrenameextension($sfilepath, $sext)
- Local $tpath = DllStructCreate("wchar[260]")
- DllStructSetData($tpath, 1, $sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathRenameExtensionW", "struct*", $tpath, "wstr", $sext)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return DllStructGetData($tpath, 1)
- EndFunc
- Func _winapi_pathsearchandqualify($sfilepath, $bexists = False)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathSearchAndQualifyW", "wstr", $sfilepath, "wstr", "", "int", 4096)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
- If $bexists AND NOT FileExists($aret[2]) Then Return SetError(20, 0, "")
- Return $aret[2]
- EndFunc
- Func _winapi_pathskiproot($sfilepath)
- Local $tpath = DllStructCreate("wchar[" & (StringLen($sfilepath) + 1) & "]")
- DllStructSetData($tpath, 1, $sfilepath)
- Local $aret = DllCall("shlwapi.dll", "ptr", "PathSkipRootW", "struct*", $tpath)
- If @error Then Return SetError(@error, @extended, "")
- If NOT $aret[0] Then Return $sfilepath
- Return _winapi_getstring($aret[0])
- EndFunc
- Func _winapi_pathstrippath($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "none", "PathStripPathW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_pathstriptoroot($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathStripToRootW", "wstr", $sfilepath)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_pathundecorate($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "none", "PathUndecorateW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_pathunexpandenvstrings($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathUnExpandEnvStringsW", "wstr", $sfilepath, "wstr", "", "uint", 4096)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return $aret[2]
- EndFunc
- Func _winapi_pathunmakesystemfolder($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathUnmakeSystemFolderW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_pathunquotespaces($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "none", "PathUnquoteSpacesW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_pathyetanothermakeuniquename($sfilepath)
- Local $aret = DllCall("shell32.dll", "int", "PathYetAnotherMakeUniqueName", "wstr", "", "wstr", $sfilepath, "ptr", 0, "ptr", 0)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_shellgetimagelist($bsmall = False)
- Local $plarge, $psmall, $tptr = DllStructCreate("ptr")
- If $bsmall Then
- $plarge = 0
- $psmall = DllStructGetPtr($tptr)
- Else
- $plarge = DllStructGetPtr($tptr)
- $psmall = 0
- EndIf
- Local $aret = DllCall("shell32.dll", "int", "Shell_GetImageLists", "ptr", $plarge, "ptr", $psmall)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
- Return DllStructGetData($tptr, 1)
- EndFunc
- Func _winapi_urlapplyscheme($surl, $iflags = 1)
- Local $aret = DllCall("shlwapi.dll", "long", "UrlApplySchemeW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", $iflags)
- If @error Then Return SetError(@error, @extended, "")
- If $aret[0] Then Return SetError(10, $aret[0], "")
- Return $aret[2]
- EndFunc
- Func _winapi_urlcanonicalize($surl, $iflags)
- Local $aret = DllCall("shlwapi.dll", "long", "UrlCanonicalizeW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", $iflags)
- If @error Then Return SetError(@error, @extended, "")
- If $aret[0] Then Return SetError(10, $aret[0], "")
- Return $aret[2]
- EndFunc
- Func _winapi_urlcombine($surl, $spart, $iflags = 0)
- Local $aret = DllCall("shlwapi.dll", "long", "UrlCombineW", "wstr", $surl, "wstr", $spart, "wstr", "", "dword*", 4096, "dword", $iflags)
- If @error Then Return SetError(@error, @extended, "")
- If $aret[0] Then Return SetError(10, $aret[0], "")
- Return $aret[3]
- EndFunc
- Func _winapi_urlcompare($surl1, $surl2, $bignoreslash = False)
- Local $aret = DllCall("shlwapi.dll", "int", "UrlCompareW", "wstr", $surl1, "wstr", $surl2, "bool", $bignoreslash)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_urlcreatefrompath($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "long", "UrlCreateFromPathW", "wstr", $sfilepath, "wstr", "", "dword*", 4096, "dword", 0)
- If @error Then Return SetError(@error, @extended, "")
- If $aret[0] < 0 OR $aret[0] > 1 Then
- Return SetError(10, $aret[0], "")
- EndIf
- Return $aret[2]
- EndFunc
- Func _winapi_urlfixup($surl)
- Local $aret = DllCall("shlwapi.dll", "long", "UrlFixupW", "wstr", $surl, "wstr", "", "dword", 4096)
- If @error Then Return SetError(@error, @extended, "")
- If $aret[0] Then Return SetError(10, $aret[0], "")
- Return $aret[2]
- EndFunc
- Func _winapi_urlgetpart($surl, $ipart)
- Local $aret = DllCall("shlwapi.dll", "long", "UrlGetPartW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", $ipart, "dword", 0)
- If @error Then Return SetError(@error, @extended, "")
- If $aret[0] Then Return SetError(10, $aret[0], "")
- Return $aret[2]
- EndFunc
- Func _winapi_urlhash($surl, $ilength = 32)
- If $ilength <= 0 OR $ilength > 256 Then Return SetError(256, 0, 0)
- Local $tdata = DllStructCreate("byte[" & $ilength & "]")
- Local $aret = DllCall("shlwapi.dll", "long", "UrlHashW", "wstr", $surl, "struct*", $tdata, "dword", $ilength)
- If @error Then Return SetError(@error + 10, @extended, 0)
- If $aret[0] Then Return SetError(10, $aret[0], 0)
- Return DllStructGetData($tdata, 1)
- EndFunc
- Func _winapi_urlis($surl, $itype = 0)
- Local $aret = DllCall("shlwapi.dll", "bool", "UrlIsW", "wstr", $surl, "uint", $itype)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- #EndRegion Public Functions
- #Region Internal Functions
- Func __us($sstring, $ilength = 0)
- If $ilength Then
- $sstring = StringLeft($sstring, $ilength)
- Else
- $ilength = StringLen($sstring)
- EndIf
- Local $tus = DllStructCreate("ushort;ushort;ptr;wchar[" & ($ilength + 1) & "]")
- DllStructSetData($tus, 1, 2 * StringLen($sstring))
- DllStructSetData($tus, 2, 2 * $ilength)
- DllStructSetData($tus, 3, DllStructGetPtr($tus, 4))
- DllStructSetData($tus, 4, $sstring)
- Return $tus
- EndFunc
- #EndRegion Internal Functions
- #Region Global Variables and Constants
- Global $__g_iheapsize = 8388608
- Global Const $tagfileinfo = "uint64 CreationTime;uint64 LastAccessTime;uint64 LastWriteTime;uint64 ChangeTime;dword Attributes"
- Global Const $tagfile_id_descriptor = "dword Size;uint Type;" & $tagguid
- Global Const $tagwin32_find_stream_data = "int64 StreamSize;wchar StreamName[296]"
- Global Const $tagwin32_stream_id = "dword StreamId;dword StreamAttributes;int64 Size;dword StreamNameSize;wchar StreamName[1]"
- #EndRegion Global Variables and Constants
- #Region Functions list
- #EndRegion Functions list
- #Region Public Functions
- Func _winapi_backupread($hfile, $pbuffer, $ilength, ByRef $ibytes, ByRef $pcontext, $bsecurity = False)
- $ibytes = 0
- Local $aret = DllCall("kernel32.dll", "bool", "BackupRead", "handle", $hfile, "struct*", $pbuffer, "dword", $ilength, "dword*", 0, "bool", 0, "bool", $bsecurity, "ptr*", $pcontext)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, False)
- $ibytes = $aret[4]
- $pcontext = $aret[7]
- Return $aret[0]
- EndFunc
- Func _winapi_backupreadabort(ByRef $pcontext)
- Local $aret = DllCall("kernel32.dll", "bool", "BackupRead", "handle", 0, "ptr", 0, "dword", 0, "dword*", 0, "bool", 1, "bool", 0, "ptr*", $pcontext)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, False)
- $pcontext = $aret[7]
- Return $aret[0]
- EndFunc
- Func _winapi_backupseek($hfile, $iseek, ByRef $ibytes, ByRef $pcontext)
- $ibytes = 0
- Local $aret = DllCall("kernel32.dll", "bool", "BackupSeek", "handle", $hfile, "dword", _winapi_lodword($iseek), "dword", _winapi_hidword($iseek), "dword*", 0, "dword*", 0, "ptr*", $pcontext)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, False)
- $ibytes = __winapi_makeqword($aret[4], $aret[5])
- $pcontext = $aret[6]
- Return $aret[0]
- EndFunc
- Func _winapi_backupwrite($hfile, $pbuffer, $ilength, ByRef $ibytes, ByRef $pcontext, $bsecurity = False)
- $ibytes = 0
- Local $aret = DllCall("kernel32.dll", "bool", "BackupWrite", "handle", $hfile, "struct*", $pbuffer, "dword", $ilength, "dword*", 0, "bool", 0, "bool", $bsecurity, "ptr*", $pcontext)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, False)
- $ibytes = $aret[4]
- $pcontext = $aret[7]
- Return $aret[0]
- EndFunc
- Func _winapi_backupwriteabort(ByRef $pcontext)
- Local $aret = DllCall("kernel32.dll", "bool", "BackupWrite", "handle", 0, "ptr", 0, "dword", 0, "dword*", 0, "bool", 1, "bool", 0, "ptr*", $pcontext)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, False)
- $pcontext = $aret[7]
- Return $aret[0]
- EndFunc
- Func _winapi_copyfileex($sexistingfile, $snewfile, $iflags = 0, $pprogressproc = 0, $pdata = 0)
- Local $aret = DllCall("kernel32.dll", "bool", "CopyFileExW", "wstr", $sexistingfile, "wstr", $snewfile, "ptr", $pprogressproc, "struct*", $pdata, "bool*", 0, "dword", $iflags)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_createdirectory($sdir, $tsecurity = 0)
- Local $aret = DllCall("kernel32.dll", "bool", "CreateDirectoryW", "wstr", $sdir, "struct*", $tsecurity)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_createdirectoryex($snewdir, $stemplatedir, $tsecurity = 0)
- Local $aret = DllCall("kernel32.dll", "bool", "CreateDirectoryExW", "wstr", $stemplatedir, "wstr", $snewdir, "struct*", $tsecurity)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_createfileex($sfilepath, $icreation, $iaccess = 0, $ishare = 0, $iflagsandattributes = 0, $tsecurity = 0, $htemplate = 0)
- Local $aret = DllCall("kernel32.dll", "handle", "CreateFileW", "wstr", $sfilepath, "dword", $iaccess, "dword", $ishare, "struct*", $tsecurity, "dword", $icreation, "dword", $iflagsandattributes, "handle", $htemplate)
- If @error Then Return SetError(@error, @extended, 0)
- If $aret[0] = Ptr(-1) Then Return SetError(10, _winapi_getlasterror(), 0)
- Return $aret[0]
- EndFunc
- Func _winapi_createfilemapping($hfile, $isize = 0, $sname = "", $iprotect = 4, $tsecurity = 0)
- Local $stypeofname = "wstr"
- If NOT StringStripWS($sname, $str_stripleading + $str_striptrailing) Then
- $stypeofname = "ptr"
- $sname = 0
- EndIf
- Local $aret = DllCall("kernel32.dll", "handle", "CreateFileMappingW", "handle", $hfile, "struct*", $tsecurity, "dword", $iprotect, "dword", _winapi_hidword($isize), "dword", _winapi_lodword($isize), $stypeofname, $sname)
- If @error Then Return SetError(@error, @extended, 0)
- Return SetExtended(_winapi_getlasterror(), $aret[0])
- EndFunc
- Func _winapi_createhardlink($snewfile, $sexistingfile)
- Local $aret = DllCall("kernel32.dll", "bool", "CreateHardLinkW", "wstr", $snewfile, "wstr", $sexistingfile, "ptr", 0)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_createobjectid($sfilepath)
- Local $hfile = _winapi_createfileex($sfilepath, $open_existing, 0, $file_share_readwrite, $file_flag_backup_semantics)
- If @error Then Return SetError(@error + 20, @extended, 0)
- Local $tfoid = DllStructCreate("byte[16];byte[48]")
- Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 590016, "ptr", 0, "dword", 0, "struct*", $tfoid, "dword", DllStructGetSize($tfoid), "dword*", 0, "ptr", 0)
- If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, 0)
- Local $tguid = DllStructCreate($tagguid)
- _winapi_movememory($tguid, $tfoid, 16)
- Return $tguid
- EndFunc
- Func _winapi_createsymboliclink($ssymlink, $starget, $bdirectory = False)
- If $bdirectory Then
- $bdirectory = 1
- EndIf
- Local $aret = DllCall("kernel32.dll", "boolean", "CreateSymbolicLinkW", "wstr", $ssymlink, "wstr", $starget, "dword", $bdirectory)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_decryptfile($sfilepath)
- Local $aret = DllCall("advapi32.dll", "bool", "DecryptFileW", "wstr", $sfilepath, "dword", 0)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_definedosdevice($sdevice, $iflags, $sfilepath = "")
- Local $stypeofpath = "wstr"
- If NOT StringStripWS($sfilepath, $str_stripleading + $str_striptrailing) Then
- $stypeofpath = "ptr"
- $sfilepath = 0
- EndIf
- Local $aret = DllCall("kernel32.dll", "bool", "DefineDosDeviceW", "dword", $iflags, "wstr", $sdevice, $stypeofpath, $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_deletefile($sfilepath)
- Local $aret = DllCall("kernel32.dll", "bool", "DeleteFileW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_deleteobjectid($sfilepath)
- Local $hfile = _winapi_createfileex($sfilepath, $open_existing, $generic_write, $file_share_readwrite, $file_flag_backup_semantics)
- If @error Then Return SetError(@error + 20, @extended, 0)
- Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 589984, "ptr", 0, "dword", 0, "ptr", 0, "dword", 0, "dword*", 0, "ptr", 0)
- If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, 0)
- Return 1
- EndFunc
- Func _winapi_deletevolumemountpoint($smountedpath)
- Local $aret = DllCall("kernel32.dll", "bool", "DeleteVolumeMountPointW", "wstr", $smountedpath)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_deviceiocontrol($hdevice, $icontrolcode, $pinbuffer = 0, $iinbuffersize = 0, $poutbuffer = 0, $ioutbuffersize = 0)
- Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hdevice, "dword", $icontrolcode, "struct*", $pinbuffer, "dword", $iinbuffersize, "struct*", $poutbuffer, "dword", $ioutbuffersize, "dword*", 0, "ptr", 0)
- If @error Then Return SetError(@error, @extended, False)
- Return SetExtended($aret[7], $aret[0])
- EndFunc
- Func _winapi_duplicateencryptioninfofile($ssrcfilepath, $sdestfilepath, $icreation = 2, $iattributes = 0, $tsecurity = 0)
- Local $aret = DllCall("advapi32.dll", "dword", "DuplicateEncryptionInfoFile", "wstr", $ssrcfilepath, "wstr", $sdestfilepath, "dword", $icreation, "dword", $iattributes, "struct*", $tsecurity)
- If @error Then Return SetError(@error, @extended, 0)
- If $aret[0] Then Return SetError(10, $aret[0], 0)
- Return 1
- EndFunc
- Func _winapi_ejectmedia($sdrive)
- Local $hfile = _winapi_createfileex("\\.\" & $sdrive, $open_existing, $generic_read, $file_share_readwrite)
- If @error Then Return SetError(@error + 20, @extended, 0)
- Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 2967560, "ptr", 0, "dword", 0, "ptr", 0, "dword", 0, "dword*", 0, "ptr", 0)
- If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, 0)
- Return 1
- EndFunc
- Func _winapi_encryptfile($sfilepath)
- Local $aret = DllCall("advapi32.dll", "bool", "EncryptFileW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_encryptiondisable($sdir, $bdisable)
- Local $aret = DllCall("advapi32.dll", "bool", "EncryptionDisable", "wstr", $sdir, "bool", $bdisable)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_enumfiles($sdir, $iflag = 0, $stemplate = "", $bexclude = False)
- Local $aret = 0, $ierror = 0
- Local $adata[501][7] = [[0]]
- Local $hdir = _winapi_createfileex($sdir, $open_existing, 1, $file_share_any, $file_flag_backup_semantics)
- If @error Then Return SetError(@error + 20, @extended, 0)
- Local $pbuffer = __heapalloc($__g_iheapsize)
- If @error Then
- $ierror = @error
- Else
- Local $tiosb = DllStructCreate("ptr;ulong_ptr")
- $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)
- If @error OR $aret[0] Then
- $ierror = @error + 40
- EndIf
- EndIf
- DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hdir)
- If $ierror Then
- __heapfree($pbuffer, 1)
- If IsArray($aret) Then
- Return SetError(10, $aret[0], 0)
- Else
- Return SetError($ierror, 0, 0)
- EndIf
- EndIf
- Local $tfdi, $iattrib, $starget, $ilength = 0, $ioffset = 0
- Do
- $ilength += $ioffset
- $tfdi = DllStructCreate("ulong;ulong;int64;int64;int64;int64;int64;int64;ulong;ulong;wchar[" & (DllStructGetData(DllStructCreate("ulong", $pbuffer + $ilength + 60), 1) / 2) & "]", $pbuffer + $ilength)
- $starget = DllStructGetData($tfdi, 11)
- $iattrib = DllStructGetData($tfdi, 9)
- $ioffset = DllStructGetData($tfdi, 1)
- Switch $starget
- Case ".", ".."
- ContinueLoop
- Case Else
- Switch $iflag
- Case 1, 2
- If BitAND($iattrib, 16) Then
- If $iflag = 1 Then
- ContinueLoop
- EndIf
- Else
- If $iflag = 2 Then
- ContinueLoop
- EndIf
- EndIf
- EndSwitch
- If $stemplate Then
- $aret = DllCall("shlwapi.dll", "int", "PathMatchSpecW", "wstr", $starget, "wstr", $stemplate)
- If @error OR ($aret[0] AND $bexclude) OR (NOT $aret[0] AND NOT $bexclude) Then
- ContinueLoop
- EndIf
- EndIf
- EndSwitch
- __inc($adata, 500)
- $adata[$adata[0][0]][0] = $starget
- $adata[$adata[0][0]][1] = DllStructGetData($tfdi, 3)
- $adata[$adata[0][0]][2] = DllStructGetData($tfdi, 4)
- $adata[$adata[0][0]][3] = DllStructGetData($tfdi, 5)
- $adata[$adata[0][0]][4] = DllStructGetData($tfdi, 7)
- $adata[$adata[0][0]][5] = DllStructGetData($tfdi, 8)
- $adata[$adata[0][0]][6] = $iattrib
- Until NOT $ioffset
- __heapfree($pbuffer)
- __inc($adata, -1)
- Return $adata
- EndFunc
- Func _winapi_enumfilestreams($sfilepath)
- Local $tdata = DllStructCreate("byte[32768]")
- Local $pdata = DllStructGetPtr($tdata)
- Local $adata[101][2] = [[0]]
- Local $hfile = _winapi_createfileex($sfilepath, $open_existing, 0, $file_share_readwrite, $file_flag_backup_semantics)
- If @error Then Return SetError(@error + 20, @extended, 0)
- Local $ierror = 0
- Local $tiosb = DllStructCreate("ptr;ulong_ptr")
- Local $aret = DllCall("ntdll.dll", "long", "ZwQueryInformationFile", "handle", $hfile, "struct*", $tiosb, "ptr", $pdata, "ulong", 32768, "uint", 22)
- If @error Then $ierror = @error
- DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hfile)
- If $ierror Then Return SetError($ierror, 0, 0)
- If $aret[0] Then Return SetError(10, $aret[0], 0)
- Local $tfsi, $ilength = 0, $ioffset = 0
- Do
- $ilength += $ioffset
- $tfsi = DllStructCreate("ulong;ulong;int64;int64;wchar[" & (DllStructGetData(DllStructCreate("ulong", $pdata + $ilength + 4), 1) / 2) & "]", $pdata + $ilength)
- __inc($adata)
- $adata[$adata[0][0]][0] = DllStructGetData($tfsi, 5)
- $adata[$adata[0][0]][1] = DllStructGetData($tfsi, 3)
- $ioffset = DllStructGetData($tfsi, 1)
- Until NOT $ioffset
- __inc($adata, -1)
- Return $adata
- EndFunc
- Func _winapi_enumhardlinks($sfilepath)
- Local $tdata = DllStructCreate("byte[32768]")
- Local $pdata = DllStructGetPtr($tdata)
- Local $hfile = _winapi_createfileex($sfilepath, $open_existing, 0, $file_share_readwrite)
- If @error Then Return SetError(@error + 20, @extended, 0)
- Local $ierror = 0
- Local $tiosb = DllStructCreate("ptr;ulong_ptr")
- Local $aret = DllCall("ntdll.dll", "long", "ZwQueryInformationFile", "handle", $hfile, "struct*", $tiosb, "ptr", $pdata, "ulong", 32768, "uint", 46)
- If @error OR $aret[0] Then
- $ierror = @error + 10
- DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hfile)
- If $aret Then Return SetError($ierror, 0, 0)
- If $aret[0] Then Return SetError(10, $ierror, 0)
- EndIf
- Local $icount = DllStructGetData(DllStructCreate("ulong;ulong", $pdata), 2)
- Local $adata[$icount + 1] = [$icount]
- Local $tflei, $hpath, $spath, $ilength = 8
- For $i = 1 To $icount
- $tflei = DllStructCreate("ulong;int64;ulong;wchar[" & (DllStructGetData(DllStructCreate("ulong", $pdata + $ilength + 16), 1)) & "]", $pdata + $ilength)
- $ierror = 0
- Do
- $hpath = _winapi_openfilebyid($hfile, DllStructGetData($tflei, 2), 1048704, $file_share_readwrite, $file_flag_backup_semantics)
- If @error Then
- $ierror = @error + 100
- ExitLoop
- EndIf
- $spath = _winapi_getfinalpathnamebyhandleex($hpath)
- If @error Then
- $ierror = @error + 200
- ExitLoop
- EndIf
- Until 1
- If $hpath Then
- DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hpath)
- EndIf
- If $ierror Then ExitLoop
- $adata[$i] = _winapi_pathappend($spath, DllStructGetData($tflei, 4))
- $ilength += DllStructGetData($tflei, 1)
- Next
- DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hfile)
- If $ierror Then Return SetError($ierror, 0, 0)
- Return $adata
- EndFunc
- Func _winapi_fileencryptionstatus($sfilepath)
- Local $aret = DllCall("advapi32.dll", "bool", "FileEncryptionStatusW", "wstr", $sfilepath, "dword*", 0)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, -1)
- Return $aret[2]
- EndFunc
- Func _winapi_fileexists($sfilepath)
- If NOT FileExists($sfilepath) Then Return 0
- If _winapi_pathisdirectory($sfilepath) Then Return SetExtended(1, 0)
- Return 1
- EndFunc
- Func _winapi_fileinuse($sfilepath)
- Local $hfile = _winapi_createfileex($sfilepath, $open_existing, $generic_read)
- If @error Then
- If @extended = 32 Then Return 1
- Return SetError(@error, @extended, 0)
- EndIf
- DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hfile)
- Return 0
- EndFunc
- Func _winapi_findclose($hsearch)
- Local $aret = DllCall("kernel32.dll", "bool", "FindClose", "handle", $hsearch)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_findclosechangenotification($hchange)
- Local $aret = DllCall("kernel32.dll", "bool", "FindCloseChangeNotification", "handle", $hchange)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_findfirstchangenotification($sdirectory, $iflags, $bsubtree = False)
- Local $aret = DllCall("kernel32.dll", "handle", "FindFirstChangeNotificationW", "wstr", $sdirectory, "bool", $bsubtree, "dword", $iflags)
- If @error OR ($aret[0] = Ptr(-1)) Then Return SetError(@error + 10, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_findfirstfile($sfilepath, $tdata)
- Local $aret = DllCall("kernel32.dll", "handle", "FindFirstFileW", "wstr", $sfilepath, "struct*", $tdata)
- If @error Then Return SetError(@error, @extended, 0)
- If $aret[0] = Ptr(-1) Then Return SetError(10, _winapi_getlasterror(), 0)
- Return $aret[0]
- EndFunc
- Func _winapi_findfirstfilename($sfilepath, ByRef $slink)
- $slink = ""
- Local $aret = DllCall("kernel32.dll", "handle", "FindFirstFileNameW", "wstr", $sfilepath, "dword", 0, "dword*", 4096, "wstr", "")
- If @error OR ($aret[0] = Ptr(-1)) Then Return SetError(@error + 10, @extended, 0)
- $slink = $aret[4]
- Return $aret[0]
- EndFunc
- Func _winapi_findfirststream($sfilepath, $tdata)
- Local $aret = DllCall("kernel32.dll", "handle", "FindFirstStreamW", "wstr", $sfilepath, "uint", 0, "struct*", $tdata, "dword", 0)
- If @error Then Return SetError(@error, @extended, 0)
- If $aret[0] = Ptr(-1) Then Return SetError(10, _winapi_getlasterror(), 0)
- Return $aret[0]
- EndFunc
- Func _winapi_findnextchangenotification($hchange)
- Local $aret = DllCall("kernel32.dll", "bool", "FindNextChangeNotification", "handle", $hchange)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_findnextfile($hsearch, $tdata)
- Local $aret = DllCall("kernel32.dll", "bool", "FindNextFileW", "handle", $hsearch, "struct*", $tdata)
- If @error Then Return SetError(@error, @extended, False)
- If NOT $aret[0] Then Return SetError(10, _winapi_getlasterror(), 0)
- Return $aret[0]
- EndFunc
- Func _winapi_findnextfilename($hsearch, ByRef $slink)
- $slink = ""
- Local $aret = DllCall("kernel32.dll", "bool", "FindNextFileNameW", "handle", $hsearch, "dword*", 4096, "wstr", "")
- If @error Then Return SetError(@error, @extended, False)
- If NOT $aret[0] Then Return SetError(10, _winapi_getlasterror(), 0)
- $slink = $aret[3]
- Return $aret[0]
- EndFunc
- Func _winapi_findnextstream($hsearch, $tdata)
- Local $aret = DllCall("kernel32.dll", "bool", "FindNextStreamW", "handle", $hsearch, "struct*", $tdata)
- If @error Then Return SetError(@error, @extended, False)
- If NOT $aret[0] Then Return SetError(10, _winapi_getlasterror(), 0)
- Return $aret[0]
- EndFunc
- Func _winapi_flushfilebuffers($hfile)
- Local $aresult = DllCall("kernel32.dll", "bool", "FlushFileBuffers", "handle", $hfile)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_flushviewoffile($paddress, $ibytes = 0)
- Local $aret = DllCall("kernel32.dll", "bool", "FlushViewOfFile", "struct*", $paddress, "dword", $ibytes)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getbinarytype($sfilepath)
- Local $aret = DllCall("kernel32.dll", "int", "GetBinaryTypeW", "wstr", $sfilepath, "dword*", 0)
- If @error Then Return SetError(@error, @extended, 0)
- If NOT $aret[0] Then $aret[2] = 0
- Return SetExtended($aret[2], $aret[0])
- EndFunc
- Func _winapi_getcdtype($sdrive)
- Local $hfile = _winapi_createfileex("\\.\" & $sdrive, $open_existing, $generic_readwrite, $file_share_readwrite)
- If @error Then Return SetError(@error + 20, @extended, 0)
- 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"
- Local $tspt = DllStructCreate($tagscsi_pass_through & ";byte Hdr[8]")
- Local $tcdb = DllStructCreate("byte;byte;byte[2];byte[3];byte[2];byte;byte[2];byte[4]", DllStructGetPtr($tspt, "Cdb"))
- Local $thdr = DllStructCreate("byte[4];byte;byte;byte[2]", DllStructGetPtr($tspt, "Hdr"))
- Local $isize = DllStructGetPtr($tspt, "Hdr") - DllStructGetPtr($tspt)
- DllStructSetData($tspt, "Length", $isize)
- DllStructSetData($tspt, "ScsiStatus", 0)
- DllStructSetData($tspt, "PathId", 0)
- DllStructSetData($tspt, "TargetId", 0)
- DllStructSetData($tspt, "Lun", 0)
- DllStructSetData($tspt, "CdbLength", 12)
- DllStructSetData($tspt, "SenseInfoLength", 0)
- DllStructSetData($tspt, "DataIn", 1)
- DllStructSetData($tspt, "DataTransferLength", 8)
- DllStructSetData($tspt, "TimeOutValue", 86400)
- DllStructSetData($tspt, "DataBufferOffset", $isize)
- DllStructSetData($tspt, "SenseInfoOffset", 0)
- DllStructSetData($tcdb, 1, 70)
- DllStructSetData($tcdb, 2, 0)
- DllStructSetData($tcdb, 3, 0, 1)
- DllStructSetData($tcdb, 3, 0, 2)
- DllStructSetData($tcdb, 5, 0, 1)
- DllStructSetData($tcdb, 5, 8, 2)
- DllStructSetData($tcdb, 6, 0)
- DllStructSetData($tcdb, 7, 0, 1)
- DllStructSetData($tcdb, 7, 0, 2)
- Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 315396, "struct*", $tspt, "dword", $isize, "struct*", $tspt, "dword", DllStructGetSize($tspt), "dword*", 0, "ptr", 0)
- If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, 0)
- Return BitOR(BitShift(DllStructGetData($thdr, 4, 1), -8), DllStructGetData($thdr, 4, 2))
- EndFunc
- Func _winapi_getcompressedfilesize($sfilepath)
- Local $aret = DllCall("kernel32.dll", "dword", "GetCompressedFileSizeW", "wstr", $sfilepath, "dword*", 0)
- If @error Then Return SetError(@error, @extended, 0)
- If $aret[0] = -1 Then
- Local $ilasterror = _winapi_getlasterror()
- If $aret[2] = 0 Then Return SetError(10, $ilasterror, 0)
- If $ilasterror Then Return SetError(11, $ilasterror, 0)
- EndIf
- Return __winapi_makeqword($aret[0], $aret[2])
- EndFunc
- Func _winapi_getcompression($sfilepath)
- Local $hfile = _winapi_createfileex($sfilepath, $open_existing, $generic_read, $file_share_readwrite, $file_flag_backup_semantics)
- If @error Then Return SetError(@error + 20, @extended, 0)
- Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 589884, "ptr", 0, "dword", 0, "ushort*", 0, "dword", 2, "dword*", 0, "ptr", 0)
- If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, -1)
- Return $aret[5]
- EndFunc
- Func _winapi_getcurrentdirectory()
- Local $aret = DllCall("kernel32.dll", "dword", "GetCurrentDirectoryW", "dword", 4096, "wstr", "")
- If @error Then Return SetError(@error, @extended, "")
- Return SetExtended($aret[0], $aret[2])
- EndFunc
- Func _winapi_getdiskfreespaceex($sdrive)
- Local $aret = DllCall("kernel32.dll", "bool", "GetDiskFreeSpaceEx", "str", $sdrive, "int64*", 0, "int64*", 0, "int64*", 0)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
- Local $aresult[3]
- For $i = 0 To 2
- $aresult[$i] = $aret[$i + 2]
- Next
- Return $aresult
- EndFunc
- Func _winapi_getdrivebustype($sdrive)
- Local $hfile = _winapi_createfileex("\\.\" & $sdrive, $open_existing, 0, $file_share_readwrite)
- If @error Then Return SetError(@error + 20, @extended, -1)
- Local $tagstorage_property_query = "ulong PropertyId;ulong QueryType;byte AdditionalParameters[1]"
- Local $tspq = DllStructCreate($tagstorage_property_query)
- 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]")
- DllStructSetData($tspq, "PropertyId", 0)
- DllStructSetData($tspq, "QueryType", 0)
- 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)
- If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, -1)
- Return DllStructGetData($tsdd, "BusType")
- EndFunc
- Func _winapi_getdrivegeometryex($idrive)
- Local $hfile = _winapi_createfileex("\\.\PhysicalDrive" & $idrive, $open_existing, 0, $file_share_readwrite)
- If @error Then Return SetError(@error + 20, @extended, 0)
- Local $tdgex = DllStructCreate("uint64;dword;dword;dword;dword;uint64")
- Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 458912, "ptr", 0, "dword", 0, "struct*", $tdgex, "dword", DllStructGetSize($tdgex), "dword*", 0, "ptr", 0)
- If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, 0)
- Local $aresult[6]
- For $i = 0 To 5
- $aresult[$i] = DllStructGetData($tdgex, $i + 1)
- Next
- Return $aresult
- EndFunc
- Func _winapi_getdrivenumber($sdrive)
- Local $hfile = _winapi_createfileex("\\.\" & $sdrive, $open_existing, 0, $file_share_readwrite)
- If @error Then Return SetError(@error + 20, @extended, 0)
- Local $tsdn = DllStructCreate("dword;ulong;ulong")
- Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 2953344, "ptr", 0, "dword", 0, "struct*", $tsdn, "dword", DllStructGetSize($tsdn), "dword*", 0, "ptr", 0)
- If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, 0)
- Local $aresult[3]
- For $i = 0 To 2
- $aresult[$i] = DllStructGetData($tsdn, $i + 1)
- Next
- Return $aresult
- EndFunc
- Func _winapi_getdrivetype($sdrive = "")
- Local $itypeofdrive = "str"
- If NOT StringStripWS($sdrive, $str_stripleading + $str_striptrailing) Then
- $itypeofdrive = "ptr"
- $sdrive = 0
- EndIf
- Local $aret = DllCall("kernel32.dll", "uint", "GetDriveType", $itypeofdrive, $sdrive)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getfileattributes($sfilepath)
- Local $aret = DllCall("kernel32.dll", "dword", "GetFileAttributesW", "wstr", $sfilepath)
- If @error OR ($aret[0] = 4294967295) Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getfileid($hfile)
- Local $tiosb = DllStructCreate("ptr;ulong_ptr")
- Local $aret = DllCall("ntdll.dll", "long", "ZwQueryInformationFile", "handle", $hfile, "struct*", $tiosb, "int64*", 0, "ulong", 8, "uint", 6)
- If @error Then Return SetError(@error, @extended, 0)
- If $aret[0] Then Return SetError(10, $aret[0], 0)
- Return $aret[3]
- EndFunc
- Func _winapi_getfileinformationbyhandle($hfile)
- Local $tbhfi = DllStructCreate("dword;dword[2];dword[2];dword[2];dword;dword;dword;dword;dword;dword")
- Local $aret = DllCall("kernel32.dll", "bool", "GetFileInformationByHandle", "handle", $hfile, "struct*", $tbhfi)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
- Local $aresult[8]
- $aresult[0] = DllStructGetData($tbhfi, 1)
- For $i = 1 To 3
- If DllStructGetData($tbhfi, $i + 1) Then
- $aresult[$i] = DllStructCreate($tagfiletime)
- _winapi_movememory($aresult[$i], DllStructGetPtr($tbhfi, $i + 1), 8)
- Else
- $aresult[$i] = 0
- EndIf
- Next
- $aresult[4] = DllStructGetData($tbhfi, 5)
- $aresult[5] = __winapi_makeqword(DllStructGetData($tbhfi, 7), DllStructGetData($tbhfi, 6))
- $aresult[6] = DllStructGetData($tbhfi, 8)
- $aresult[7] = __winapi_makeqword(DllStructGetData($tbhfi, 9), DllStructGetData($tbhfi, 10))
- Return $aresult
- EndFunc
- Func _winapi_getfileinformationbyhandleex($hfile)
- Local $tfi = DllStructCreate($tagfileinfo)
- Local $tiosb = DllStructCreate("ptr;ulong_ptr")
- Local $aret = DllCall("ntdll.dll", "long", "ZwQueryInformationFile", "handle", $hfile, "struct*", $tiosb, "struct*", $tfi, "ulong", DllStructGetSize($tfi), "uint", 4)
- If @error Then Return SetError(@error, @extended, 0)
- If $aret[0] Then Return SetError(10, $aret[0], 0)
- Return $tfi
- EndFunc
- Func _winapi_getfilepointerex($hfile)
- Local $tiosb = DllStructCreate("ptr;ulong_ptr")
- Local $aret = DllCall("ntdll.dll", "long", "ZwQueryInformationFile", "handle", $hfile, "struct*", $tiosb, "int64*", 0, "ulong", 8, "uint", 14)
- If @error Then Return SetError(@error, @extended, "")
- If $aret[0] Then Return SetError(10, $aret[0], "")
- Return $aret[3]
- EndFunc
- Func _winapi_getfilesizeex($hfile)
- Local $aresult = DllCall("kernel32.dll", "bool", "GetFileSizeEx", "handle", $hfile, "int64*", 0)
- If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, -1)
- Return $aresult[2]
- EndFunc
- Func _winapi_getfilesizeondisk($sfilepath)
- Local $isize = FileGetSize($sfilepath)
- If @error Then Return SetError(@error + 10, @extended, 0)
- Local $aret = DllCall("kernel32.dll", "bool", "GetDiskFreeSpaceW", "wstr", _winapi_pathstriptoroot(_winapi_getfullpathname($sfilepath)), "dword*", 0, "dword*", 0, "dword*", 0, "dword*", 0)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, 0)
- Return Ceiling($isize / ($aret[2] * $aret[3])) * ($aret[2] * $aret[3])
- EndFunc
- Func _winapi_getfiletitle($sfilepath)
- Local $aret = DllCall("comdlg32.dll", "short", "GetFileTitleW", "wstr", $sfilepath, "wstr", "", "word", 4096)
- If @error OR $aret[0] Then Return SetError(@error, @extended, "")
- Return $aret[2]
- EndFunc
- Func _winapi_getfiletype($hfile)
- Local $aret = DllCall("kernel32.dll", "dword", "GetFileType", "handle", $hfile)
- If @error Then Return SetError(@error, @extended, -1)
- Local $ilasterror = _winapi_getlasterror()
- If NOT $aret[0] AND $ilasterror Then Return SetError(10, $ilasterror, -1)
- Return $aret[0]
- EndFunc
- Func _winapi_getfinalpathnamebyhandle($hfile)
- Local $tfni = DllStructCreate("ulong;wchar[4096]")
- Local $tiosb = DllStructCreate("ptr;ulong_ptr")
- Local $aret = DllCall("ntdll.dll", "long", "ZwQueryInformationFile", "handle", $hfile, "struct*", $tiosb, "struct*", $tfni, "ulong", DllStructGetSize($tfni), "uint", 9)
- If @error Then Return SetError(@error, @extended, "")
- If $aret[0] Then Return SetError(10, $aret[0], "")
- Local $ilength = DllStructGetData($tfni, 1)
- If NOT $ilength Then Return SetError(12, 0, "")
- Return DllStructGetData(DllStructCreate("wchar[" & ($ilength / 2) & "]", DllStructGetPtr($tfni, 2)), 1)
- EndFunc
- Func _winapi_getfinalpathnamebyhandleex($hfile, $iflags = 0)
- Local $aret = DllCall("kernel32.dll", "dword", "GetFinalPathNameByHandleW", "handle", $hfile, "wstr", "", "dword", 4096, "dword", $iflags)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
- Return $aret[2]
- EndFunc
- Func _winapi_getfullpathname($sfilepath)
- Local $aret = DllCall("kernel32.dll", "dword", "GetFullPathNameW", "wstr", $sfilepath, "dword", 4096, "wstr", "", "ptr", 0)
- If @error OR NOT $aret[0] Then Return SetError(@error, @extended, "")
- Return $aret[3]
- EndFunc
- Func _winapi_getlogicaldrives()
- Local $aret = DllCall("kernel32.dll", "dword", "GetLogicalDrives")
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_getobjectid($sfilepath)
- Local $hfile = _winapi_createfileex($sfilepath, $open_existing, 0, $file_share_readwrite, $file_flag_backup_semantics)
- If @error Then Return SetError(@error + 20, @extended, 0)
- Local $tfoid = DllStructCreate("byte[16];byte[48]")
- Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 589980, "ptr", 0, "dword", 0, "struct*", $tfoid, "dword", DllStructGetSize($tfoid), "dword*", 0, "ptr", 0)
- If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, 0)
- Local $tguid = DllStructCreate($tagguid)
- _winapi_movememory($tguid, $tfoid, 16)
- Return $tguid
- EndFunc
- Func _winapi_getoverlappedresult($hfile, $toverlapped, ByRef $ibytes, $bwait = False)
- Local $aresult = DllCall("kernel32.dll", "bool", "GetOverlappedResult", "handle", $hfile, "struct*", $toverlapped, "dword*", 0, "bool", $bwait)
- If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, False)
- $ibytes = $aresult[3]
- Return $aresult[0]
- EndFunc
- Func _winapi_getpetype($sfilepath)
- Local $tdata = DllStructCreate("ushort[2]")
- Local $tuint = DllStructCreate("uint", DllStructGetPtr($tdata))
- Local $hfile = _winapi_createfileex($sfilepath, $open_existing, $generic_read, $file_share_readwrite)
- If @error Then Return SetError(@error + 20, @extended, 0)
- Local $ierror = 0, $ival
- Do
- Local $aret = DllCall("kernel32.dll", "bool", "ReadFile", "handle", $hfile, "struct*", $tdata, "dword", 2, "dword*", 0, "ptr", 0)
- If @error OR (NOT $aret[0]) OR ($aret[4] <> 2) Then
- $ierror = @error + 30
- ExitLoop
- EndIf
- $ival = DllStructGetData($tdata, 1, 1)
- If $ival <> 23117 Then
- $ierror = 3
- ExitLoop
- EndIf
- If NOT _winapi_setfilepointerex($hfile, 60) Then
- $ierror = @error + 40
- ExitLoop
- EndIf
- $aret = DllCall("kernel32.dll", "bool", "ReadFile", "handle", $hfile, "struct*", $tdata, "dword", 4, "dword*", 0, "ptr", 0)
- If @error OR (NOT $aret[0]) OR ($aret[4] <> 4) Then
- $ierror = @error + 50
- ExitLoop
- EndIf
- If NOT _winapi_setfilepointerex($hfile, DllStructGetData($tuint, 1)) Then
- $ierror = @error + 60
- ExitLoop
- EndIf
- $aret = DllCall("kernel32.dll", "bool", "ReadFile", "handle", $hfile, "struct*", $tdata, "dword", 4, "dword*", 0, "ptr", 0)
- If @error OR (NOT $aret[0]) OR ($aret[4] <> 4) Then
- $ierror = @error + 70
- ExitLoop
- EndIf
- $ival = DllStructGetData($tuint, 1)
- If $ival <> 17744 Then
- $ierror = 4
- ExitLoop
- EndIf
- $aret = DllCall("kernel32.dll", "bool", "ReadFile", "handle", $hfile, "struct*", $tdata, "dword", 2, "dword*", 0, "ptr", 0)
- If @error OR (NOT $aret[0]) OR ($aret[4] <> 2) Then
- $ierror = @error + 80
- ExitLoop
- EndIf
- $ival = DllStructGetData($tdata, 1, 1)
- Until 1
- DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hfile)
- If $ierror Then Return SetError($ierror, 0, 0)
- Return $ival
- EndFunc
- Func _winapi_getprofilesdirectory()
- Local $aret = DllCall("userenv.dll", "bool", "GetProfilesDirectoryW", "wstr", "", "dword*", 4096)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
- Return $aret[1]
- EndFunc
- Func _winapi_gettempfilename($sfilepath, $sprefix = "")
- Local $aret = DllCall("kernel32.dll", "uint", "GetTempFileNameW", "wstr", $sfilepath, "wstr", $sprefix, "uint", 0, "wstr", "")
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
- Return $aret[4]
- EndFunc
- Func _winapi_getvolumeinformation($sroot = "")
- Local $stypeofroot = "wstr"
- If NOT StringStripWS($sroot, $str_stripleading + $str_striptrailing) Then
- $stypeofroot = "ptr"
- $sroot = 0
- EndIf
- Local $aret = DllCall("kernel32.dll", "bool", "GetVolumeInformationW", $stypeofroot, $sroot, "wstr", "", "dword", 4096, "dword*", 0, "dword*", 0, "dword*", 0, "wstr", "", "dword", 4096)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
- Local $aresult[5]
- For $i = 0 To 4
- Switch $i
- Case 0
- $aresult[$i] = $aret[2]
- Case Else
- $aresult[$i] = $aret[$i + 3]
- EndSwitch
- Next
- Return $aresult
- EndFunc
- Func _winapi_getvolumeinformationbyhandle($hfile)
- Local $aret = DllCall("kernel32.dll", "bool", "GetVolumeInformationByHandleW", "handle", $hfile, "wstr", "", "dword", 4096, "dword*", 0, "dword*", 0, "dword*", 0, "wstr", "", "dword", 4096)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
- Local $aresult[5]
- For $i = 0 To 4
- Switch $i
- Case 0
- $aresult[$i] = $aret[2]
- Case Else
- $aresult[$i] = $aret[$i + 3]
- EndSwitch
- Next
- Return $aresult
- EndFunc
- Func _winapi_getvolumenameforvolumemountpoint($smountedpath)
- Local $aret = DllCall("kernel32.dll", "bool", "GetVolumeNameForVolumeMountPointW", "wstr", $smountedpath, "wstr", "", "dword", 80)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
- Return $aret[2]
- EndFunc
- Func _winapi_ioctl($idevicetype, $ifunction, $imethod, $iaccess)
- Return BitOR(BitShift($idevicetype, -16), BitShift($iaccess, -14), BitShift($ifunction, -2), $imethod)
- EndFunc
- Func _winapi_isdooropen($sdrive)
- Local $hfile = _winapi_createfileex("\\.\" & $sdrive, $open_existing, $generic_readwrite, $file_share_readwrite)
- If @error Then Return SetError(@error + 20, @extended, False)
- 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]")
- Local $tcdb = DllStructCreate("byte;byte;byte[6];byte[2];byte;byte;byte[4]", DllStructGetPtr($tspt, "Cdb"))
- Local $thdr = DllStructCreate("byte;byte;byte[3];byte;byte[2]", DllStructGetPtr($tspt, "Hdr"))
- Local $isize = DllStructGetPtr($tspt, "Hdr") - DllStructGetPtr($tspt)
- DllStructSetData($tspt, "Length", $isize)
- DllStructSetData($tspt, "ScsiStatus", 0)
- DllStructSetData($tspt, "PathId", 0)
- DllStructSetData($tspt, "TargetId", 0)
- DllStructSetData($tspt, "Lun", 0)
- DllStructSetData($tspt, "CdbLength", 12)
- DllStructSetData($tspt, "SenseInfoLength", 0)
- DllStructSetData($tspt, "DataIn", 1)
- DllStructSetData($tspt, "DataTransferLength", 8)
- DllStructSetData($tspt, "TimeOutValue", 86400)
- DllStructSetData($tspt, "DataBufferOffset", $isize)
- DllStructSetData($tspt, "SenseInfoOffset", 0)
- DllStructSetData($tcdb, 1, 189)
- DllStructSetData($tcdb, 2, 0)
- DllStructSetData($tcdb, 4, 0, 1)
- DllStructSetData($tcdb, 4, 8, 2)
- DllStructSetData($tcdb, 5, 0)
- DllStructSetData($tcdb, 6, 0)
- Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 315396, "struct*", $tspt, "dword", $isize, "struct*", $tspt, "dword", DllStructGetSize($tspt), "dword*", 0, "ptr", 0)
- If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, False)
- Return (BitAND(DllStructGetData($thdr, 2), 16) = 16)
- EndFunc
- Func _winapi_ispathshared($sfilepath)
- If NOT __dll("ntshrui.dll") Then Return SetError(103, 0, 0)
- Local $aret = DllCall("ntshrui.dll", "bool", "IsPathSharedW", "wstr", _winapi_pathremovebackslash($sfilepath), "int", 1)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_iswritable($sdrive)
- DriveGetFileSystem($sdrive)
- If @error Then Return SetError(40 + @error, _winapi_getlasterror(), 0)
- Local $hfile = _winapi_createfileex("\\.\" & $sdrive, $open_existing, 0, $file_share_readwrite)
- If @error Then Return SetError(@error + 20, @extended, 0)
- Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 458788, "ptr", 0, "dword", 0, "ptr", 0, "dword", 0, "dword*", 0, "ptr", 0)
- Local Const $error_write_protect = 19
- If __checkerrorclosehandle($aret, $hfile, 1) <> 10 AND @extended = $error_write_protect Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_loadmedia($sdrive)
- Local $hfile = _winapi_createfileex("\\.\" & $sdrive, $open_existing, $generic_read, $file_share_readwrite)
- If @error Then Return SetError(@error + 20, @extended, False)
- Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 2967564, "ptr", 0, "dword", 0, "ptr", 0, "dword", 0, "dword*", 0, "ptr", 0)
- If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_lockdevice($sdrive, $block)
- Local $hfile = _winapi_createfileex("\\.\" & $sdrive, $open_existing, $generic_readwrite, $file_share_readwrite)
- If @error Then Return SetError(@error + 20, @extended, False)
- Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 2967556, "boolean*", $block, "dword", 1, "ptr", 0, "dword", 0, "dword*", 0, "ptr", 0)
- If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_lockfile($hfile, $ioffset, $ilength)
- 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))
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_mapviewoffile($hmapping, $ioffset = 0, $ibytes = 0, $iaccess = 6)
- Local $aret = DllCall("kernel32.dll", "ptr", "MapViewOfFile", "handle", $hmapping, "dword", $iaccess, "dword", _winapi_hidword($ioffset), "dword", _winapi_lodword($ioffset), "ulong_ptr", $ibytes)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_movefileex($sexistingfile, $snewfile, $iflags = 0, $pprogressproc = 0, $pdata = 0)
- Local $stypeofnewfile = "wstr"
- If NOT StringStripWS($snewfile, $str_stripleading + $str_striptrailing) Then
- $stypeofnewfile = "ptr"
- $snewfile = 0
- EndIf
- Local $aret = DllCall("kernel32.dll", "bool", "MoveFileWithProgressW", "wstr", $sexistingfile, $stypeofnewfile, $snewfile, "ptr", $pprogressproc, "ptr", $pdata, "dword", $iflags)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_openfilebyid($hfile, $vid, $iaccess = 0, $ishare = 0, $iflags = 0)
- Local $tfidd = DllStructCreate("dword;uint;int64;int64")
- Local $hobj, $aret, $itype, $ierror = 0
- Select
- Case IsString($vid)
- $aret = DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $vid, "ptr", DllStructGetPtr($tfidd, 3))
- If @error OR $aret[0] Then
- Return SetError(@error + 30, 0, 0)
- EndIf
- $itype = 1
- Case IsDllStruct($vid)
- If NOT _winapi_movememory(DllStructGetPtr($tfidd, 3), DllStructGetPtr($vid), 16) Then
- Return SetError(@error + 40, 0, 0)
- EndIf
- $itype = 1
- Case Else
- DllStructSetData($tfidd, 3, $vid)
- $itype = 0
- EndSelect
- DllStructSetData($tfidd, 1, DllStructGetSize($tfidd))
- DllStructSetData($tfidd, 2, $itype)
- If IsString($hfile) Then
- $hobj = _winapi_createfileex($hfile, $open_existing, 0, $file_share_readwrite, $file_flag_backup_semantics)
- If @error Then Return SetError(@error + 20, @extended, 0)
- Else
- $hobj = $hfile
- EndIf
- $aret = DllCall("kernel32.dll", "handle", "OpenFileById", "handle", $hobj, "struct*", $tfidd, "dword", $iaccess, "dword", $ishare, "ptr", 0, "dword", $iflags)
- If @error OR ($aret[0] = Ptr(-1)) Then $ierror = @error + 10
- If IsString($hfile) Then
- DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hobj)
- EndIf
- If $ierror Then Return SetError($ierror, 0, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_openfilemapping($sname, $iaccess = 6, $binherit = False)
- Local $aret = DllCall("kernel32.dll", "handle", "OpenFileMappingW", "dword", $iaccess, "bool", $binherit, "wstr", $sname)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_pathisdirectoryempty($sfilepath)
- Local $aret = DllCall("shlwapi.dll", "bool", "PathIsDirectoryEmptyW", "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_querydosdevice($sdevice)
- Local $stypeofdevice = "wstr"
- If NOT StringStripWS($sdevice, $str_stripleading + $str_striptrailing) Then
- $stypeofdevice = "ptr"
- $sdevice = 0
- EndIf
- Local $tdata = DllStructCreate("wchar[16384]")
- Local $aret = DllCall("kernel32.dll", "dword", "QueryDosDeviceW", $stypeofdevice, $sdevice, "struct*", $tdata, "dword", 16384)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
- Local $aresult = _winapi_structtoarray($tdata)
- If IsString($sdevice) Then
- $aresult = $aresult[1]
- EndIf
- Return $aresult
- EndFunc
- Func _winapi_readdirectorychanges($hdirectory, $ifilter, $pbuffer, $ilength, $bsubtree = 0)
- 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)
- If @error OR NOT $aret[0] OR (NOT $aret[6]) Then Return SetError(@error + 10, @extended, 0)
- $pbuffer = $aret[2]
- Local $adata[101][2] = [[0]]
- Local $tfni, $ibuffer = 0, $ioffset = 0
- Do
- $ibuffer += $ioffset
- $tfni = DllStructCreate("dword NextEntryOffset;dword Action;dword FileNameLength;wchar FileName[" & (DllStructGetData(DllStructCreate("dword FileNameLength", $pbuffer + $ibuffer + 8), 1) / 2) & "]", $pbuffer + $ibuffer)
- __inc($adata)
- $adata[$adata[0][0]][0] = DllStructGetData($tfni, "FileName")
- $adata[$adata[0][0]][1] = DllStructGetData($tfni, "Action")
- $ioffset = DllStructGetData($tfni, "NextEntryOffset")
- Until NOT $ioffset
- __inc($adata, -1)
- Return $adata
- EndFunc
- Func _winapi_removedirectory($sdirpath)
- Local $aret = DllCall("kernel32.dll", "bool", "RemoveDirectoryW", "wstr", $sdirpath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_reopenfile($hfile, $iaccess, $ishare, $iflags = 0)
- Local $aret = DllCall("kernel32.dll", "handle", "ReOpenFile", "handle", $hfile, "dword", $iaccess, "dword", $ishare, "dword", $iflags)
- If @error OR ($aret[0] = Ptr(-1)) Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_replacefile($sreplacedfile, $sreplacementfile, $sbackupfile = "", $iflags = 0)
- Local $stypeofbackupfile = "wstr"
- If NOT StringStripWS($sbackupfile, $str_stripleading + $str_striptrailing) Then
- $stypeofbackupfile = "ptr"
- $sbackupfile = 0
- EndIf
- Local $aret = DllCall("kernel32.dll", "bool", "ReplaceFileW", "wstr", $sreplacedfile, "wstr", $sreplacementfile, $stypeofbackupfile, $sbackupfile, "dword", $iflags, "ptr", 0, "ptr", 0)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_searchpath($sfilepath, $ssearchpath = "")
- Local $stypeofpath = "wstr"
- If NOT StringStripWS($ssearchpath, $str_stripleading + $str_striptrailing) Then
- $stypeofpath = "ptr"
- $ssearchpath = 0
- EndIf
- Local $aret = DllCall("kernel32.dll", "dword", "SearchPathW", $stypeofpath, $ssearchpath, "wstr", $sfilepath, "ptr", 0, "dword", 4096, "wstr", "", "ptr", 0)
- If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, "")
- Return $aret[5]
- EndFunc
- Func _winapi_setcompression($sfilepath, $icompression)
- Local $hfile = _winapi_createfileex($sfilepath, $open_existing, $generic_readwrite, $file_share_readwrite, $file_flag_backup_semantics)
- If @error Then Return SetError(@error + 20, @extended, 0)
- Local $aret = DllCall("kernel32.dll", "bool", "DeviceIoControl", "handle", $hfile, "dword", 639040, "ushort*", $icompression, "dword", 2, "ptr", 0, "dword", 0, "dword*", 0, "ptr", 0)
- If __checkerrorclosehandle($aret, $hfile) Then Return SetError(@error, @extended, 0)
- Return 1
- EndFunc
- Func _winapi_setcurrentdirectory($sdir)
- Local $aret = DllCall("kernel32.dll", "int", "SetCurrentDirectoryW", "wstr", $sdir)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_setendoffile($hfile)
- Local $aresult = DllCall("kernel32.dll", "bool", "SetEndOfFile", "handle", $hfile)
- If @error Then Return SetError(@error, @extended, False)
- Return $aresult[0]
- EndFunc
- Func _winapi_setfileattributes($sfilepath, $iattributes)
- Local $aret = DllCall("kernel32.dll", "int", "SetFileAttributesW", "wstr", $sfilepath, "dword", $iattributes)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_setfileinformationbyhandleex($hfile, $tfileinfo)
- Local $aret = DllCall("ntdll.dll", "long", "ZwSetInformationFile", "handle", $hfile, "struct*", $tfileinfo, "struct*", $tfileinfo, "ulong", DllStructGetSize($tfileinfo), "uint", 4)
- If @error Then Return SetError(@error, @extended, 0)
- If $aret[0] Then Return SetError(10, $aret[0], 0)
- Return 1
- EndFunc
- Func _winapi_setfilepointer($hfile, $ipos, $imethod = 0)
- Local $aresult = DllCall("kernel32.dll", "INT", "SetFilePointer", "handle", $hfile, "long", $ipos, "ptr", 0, "long", $imethod)
- If @error Then Return SetError(@error, @extended, -1)
- Return $aresult[0]
- EndFunc
- Func _winapi_setfilepointerex($hfile, $ipos, $imethod = 0)
- Local $aret = DllCall("kernel32.dll", "bool", "SetFilePointerEx", "handle", $hfile, "int64", $ipos, "int64*", 0, "dword", $imethod)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_setfileshortname($hfile, $sshortname)
- Local $aret = DllCall("kernel32.dll", "bool", "SetFileShortNameW", "handle", $hfile, "wstr", $sshortname)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_setfilevaliddata($hfile, $ilength)
- Local $aret = DllCall("kernel32.dll", "bool", "SetFileValidData", "handle", $hfile, "int64", $ilength)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_setsearchpathmode($iflags)
- Local $aret = DllCall("kernel32.dll", "bool", "SetSearchPathMode", "dword", $iflags)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_setvolumemountpoint($sfilepath, $sguid)
- Local $aret = DllCall("kernel32.dll", "bool", "SetVolumeMountPointW", "wstr", $sfilepath, "wstr", $sguid)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_sfcisfileprotected($sfilepath)
- If NOT __dll("sfc.dll") Then Return SetError(103, 0, False)
- Local $aret = DllCall("sfc.dll", "bool", "SfcIsFileProtected", "handle", 0, "wstr", $sfilepath)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_unlockfile($hfile, $ioffset, $ilength)
- 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))
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- Func _winapi_unmapviewoffile($paddress)
- Local $aret = DllCall("kernel32.dll", "bool", "UnmapViewOfFile", "ptr", $paddress)
- If @error Then Return SetError(@error, @extended, False)
- Return $aret[0]
- EndFunc
- Func _winapi_wow64enablewow64fsredirection($benable)
- Local $aret = DllCall("kernel32.dll", "boolean", "Wow64EnableWow64FsRedirection", "boolean", $benable)
- If @error Then Return SetError(@error, @extended, 0)
- Return $aret[0]
- EndFunc
- #EndRegion Public Functions
- #Region Internal Functions
- Func __winapi_makeqword($ilodword, $ihidword)
- Local $tint64 = DllStructCreate("uint64")
- Local $tdwords = DllStructCreate("dword;dword", DllStructGetPtr($tint64))
- DllStructSetData($tdwords, 1, $ilodword)
- DllStructSetData($tdwords, 2, $ihidword)
- Return DllStructGetData($tint64, 1)
- EndFunc
- #EndRegion Internal Functions
- #Region
- #AutoIt3Wrapper_Icon=game file\Gui\image.ico
- #EndRegion
- $downverread = FileRead("game file\down_version.txt")
- $currverread = FileRead("game file\current_version.txt")
- $works_till = _dateadd("m", 1, _nowcalcdate())
- $read_wrktill = RegRead("HKEY_CURRENT_USER\Software\Nitro", "WrkTill")
- $today = _dateadd("m", 0, _nowcalcdate())
- $today_read = RegRead("HKEY_CURRENT_USER\Software\Nitro", "Today")
- $diff = _datediff("d", $today_read, $read_wrktill)
- Func adddate()
- RegWrite("HKEY_CURRENT_USER\Software\Nitro\", "WrkTill", "REG_SZ", $works_till)
- EndFunc
- Func addtodaydate()
- RegWrite("HKEY_CURRENT_USER\Software\Nitro\", "Today", "REG_SZ", $today)
- EndFunc
- addtodaydate()
- FileRecycle("C:\Riot Games\League of Legends\Config\game.cfg")
- FileRecycle("C:\Riot Games\League of Legends\Config\PersistedSettings.json")
- FileCopy("game.cfg", "C:\Riot Games\League of Legends\Config\game.cfg", $fc_overwrite)
- FileCopy("PersistedSettings.json", "C:\Riot Games\League of Legends\Config\PersistedSettings.json", $fc_overwrite)
- If $diff < 1 Then
- If $diff < 1 Then
- RegDelete("HKEY_CURRENT_USER\Software\Nitro\WrkTill")
- If FileExists("game file\Gui\old gui\errors\Sillyre Bot.exe") Then
- FileRecycle("game file\Gui\old gui\errors\Sillyre Bot.exe")
- Sleep(350)
- FileRecycleEmpty()
- Sleep(500)
- Sleep(5000)
- EndIf
- EndIf
- If FileExists("game file\Gui\settings.txt") Then
- FileRecycle("game file\Gui\settings.txt")
- FileRecycleEmpty()
- EndIf
- Sleep(2500)
- MsgBox(0, "License", "Your software has expired / hasn't been activated yet.")
- ShellExecute("https://selly.gg/p/28d4dc19")
- MsgBox(0, "License", "To use this tool, purchase the key in the link opened and enter it in the box after this.")
- $key = InputBox("License Key", "Please enter your license key bellow:")
- If $key = "" Then
- Exit
- EndIf
- If $key = " " Then
- Exit
- EndIf
- If $key = "A" Then
- Exit
- EndIf
- If $key = "B" Then
- Exit
- EndIf
- If $key = "C" Then
- Exit
- EndIf
- If $key = "D" Then
- Exit
- EndIf
- If $key = "E" Then
- Exit
- EndIf
- If $key = "F" Then
- Exit
- EndIf
- If $key = "G" Then
- Exit
- EndIf
- If $key = "H" Then
- Exit
- EndIf
- If $key = "I" Then
- Exit
- EndIf
- If $key = "J" Then
- Exit
- EndIf
- If $key = "K" Then
- Exit
- EndIf
- If $key = "L" Then
- Exit
- EndIf
- If $key = "M" Then
- Exit
- EndIf
- If $key = "N" Then
- Exit
- EndIf
- If $key = "O" Then
- Exit
- EndIf
- If $key = "P" Then
- Exit
- EndIf
- If $key = "Q" Then
- Exit
- EndIf
- If $key = "R" Then
- Exit
- EndIf
- If $key = "S" Then
- Exit
- EndIf
- If $key = "T" Then
- Exit
- EndIf
- If $key = "U" Then
- Exit
- EndIf
- If $key = "W" Then
- Exit
- EndIf
- If $key = "X" Then
- Exit
- EndIf
- If $key = "Y" Then
- Exit
- EndIf
- If $key = "Z" Then
- Exit
- EndIf
- If $key = "V" Then
- Exit
- EndIf
- If $key = "0" Then
- Exit
- EndIf
- If $key = "1" Then
- Exit
- EndIf
- If $key = "2" Then
- Exit
- EndIf
- If $key = "3" Then
- Exit
- EndIf
- If $key = "4" Then
- Exit
- EndIf
- If $key = "5" Then
- Exit
- EndIf
- If $key = "6" Then
- Exit
- EndIf
- If $key = "7" Then
- Exit
- EndIf
- If $key = "8" Then
- Exit
- EndIf
- If $key = "9" Then
- Exit
- EndIf
- If $key = "10" Then
- Exit
- EndIf
- If @error = 1 Then
- Exit
- EndIf
- InetGet("https://drive.google.com/uc?authuser=0&id=1lEdI3oqhmNdaEOGLqHeA6OrxHzRBquP2&export=download", "game file\Gui\settings.txt")
- Sleep(2000)
- $file = "game file\Gui\settings.txt"
- $read = FileRead($file)
- If @error = -1 Then
- MsgBox(0, "Error", "Could not connect to licensing server - Contact Sillyre#8184 on Discord for help.")
- Exit
- Else
- Sleep(1500)
- If StringRegExp($read, $key) Then
- adddate()
- MsgBox(0, "Activation", "Your Sillyre Bot license if now valid until: " & $works_till & ". Enjoy botting.")
- If NOT FileExists("game file\Gui\old gui\errors\Sillyre Bot.exe") Then
- InetGet("https://drive.google.com/uc?authuser=0&id=1n7fz3CbamvvNk7e8xou5mIuNm2noUetu&export=download", "game file\Gui\old gui\errors\Sillyre Bot.exe")
- Sleep(10000)
- Else
- ShellExecute("game file\Gui\old gui\errors\Sillyre Bot.exe")
- EndIf
- Else
- MsgBox(0, "Activation", "The key you entered seems incorrect - check if you copied the key correctly.")
- If FileExists("game file\Gui\settings.txt") Then
- FileRecycle("game file\Gui\settings.txt")
- FileRecycleEmpty()
- EndIf
- Exit
- EndIf
- EndIf
- FileClose($file)
- Else
- #Region UPDATER 2.0
- $downverread = FileRead("game file\down_version.txt")
- $currverread = FileRead("game file\current_version.txt")
- If FileExists("game file\down_version.txt") Then
- FileRecycle("game file\down_version.txt")
- Sleep(200)
- InetGet("https://drive.google.com/uc?authuser=0&id=1kmUT69GRqIPhm40xx7S5nwxxTmw9UXfJ&export=download", "game file\down_version.txt")
- Else
- InetGet("https://drive.google.com/uc?authuser=0&id=1kmUT69GRqIPhm40xx7S5nwxxTmw9UXfJ&export=download", "game file\down_version.txt")
- EndIf
- If NOT FileExists("game file\current_version.txt") Then
- FileWriteLine("game file\current_version.txt", "1.0.0")
- EndIf
- If $currverread < $downverread Then
- MsgBox(64, "Updater", "The bot will now update to version " & $downverread & ". Give it a few moments.")
- FileRecycle("game file\Gui\old gui\errors\Sillyre Bot.exe")
- FileRecycleEmpty()
- InetGet("https://drive.google.com/uc?authuser=0&id=1n7fz3CbamvvNk7e8xou5mIuNm2noUetu&export=download", "game file\Gui\old gui\errors\Sillyre Bot.exe")
- FileRecycle("game file\current_version.txt")
- Sleep(50)
- FileWriteLine("game file\current_version.txt", $downverread)
- EndIf
- If NOT FileExists("game file\Gui\old gui\errors\Sillyre Bot.exe") Then
- InetGet("https://drive.google.com/uc?authuser=0&id=1n7fz3CbamvvNk7e8xou5mIuNm2noUetu&export=download", "game file\Gui\old gui\errors\Sillyre Bot.exe")
- EndIf
- #EndRegion
- ShellExecute("game file\Gui\old gui\errors\Sillyre Bot.exe")
- EndIf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement