Advertisement
Guest User

Guard1000

a guest
May 21st, 2014
635
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 335.08 KB | None | 0 0
  1. #NoTrayIcon
  2.  
  3. Func _winapi_getlasterror($ierror = @error, $iextended = @extended)
  4.     Local $aresult = DllCall("kernel32.dll", "dword", "GetLastError")
  5.     Return SetError($ierror, $iextended, $aresult[0])
  6. EndFunc
  7.  
  8. Func _winapi_setlasterror($ierrorcode, $ierror = @error, $iextended = @extended)
  9.     DllCall("kernel32.dll", "none", "SetLastError", "dword", $ierrorcode)
  10.     Return SetError($ierror, $iextended, NULL )
  11. EndFunc
  12.  
  13. Global Const $fc_nooverwrite = 0
  14. Global Const $fc_overwrite = 1
  15. Global Const $fc_createpath = 8
  16. Global Const $ft_modified = 0
  17. Global Const $ft_created = 1
  18. Global Const $ft_accessed = 2
  19. Global Const $fo_read = 0
  20. Global Const $fo_append = 1
  21. Global Const $fo_overwrite = 2
  22. Global Const $fo_createpath = 8
  23. Global Const $fo_binary = 16
  24. Global Const $fo_unicode = 32
  25. Global Const $fo_utf16_le = 32
  26. Global Const $fo_utf16_be = 64
  27. Global Const $fo_utf8 = 128
  28. Global Const $fo_utf8_nobom = 256
  29. Global Const $fo_utf8_full = 16384
  30. Global Const $eof = -1
  31. Global Const $fd_filemustexist = 1
  32. Global Const $fd_pathmustexist = 2
  33. Global Const $fd_multiselect = 4
  34. Global Const $fd_promptcreatenew = 8
  35. Global Const $fd_promptoverwrite = 16
  36. Global Const $create_new = 1
  37. Global Const $create_always = 2
  38. Global Const $open_existing = 3
  39. Global Const $open_always = 4
  40. Global Const $truncate_existing = 5
  41. Global Const $invalid_set_file_pointer = -1
  42. Global Const $file_begin = 0
  43. Global Const $file_current = 1
  44. Global Const $file_end = 2
  45. Global Const $file_attribute_readonly = 1
  46. Global Const $file_attribute_hidden = 2
  47. Global Const $file_attribute_system = 4
  48. Global Const $file_attribute_directory = 16
  49. Global Const $file_attribute_archive = 32
  50. Global Const $file_attribute_device = 64
  51. Global Const $file_attribute_normal = 128
  52. Global Const $file_attribute_temporary = 256
  53. Global Const $file_attribute_sparse_file = 512
  54. Global Const $file_attribute_reparse_point = 1024
  55. Global Const $file_attribute_compressed = 2048
  56. Global Const $file_attribute_offline = 4096
  57. Global Const $file_attribute_not_content_indexed = 8192
  58. Global Const $file_attribute_encrypted = 16384
  59. Global Const $file_share_read = 1
  60. Global Const $file_share_write = 2
  61. Global Const $file_share_delete = 4
  62. Global Const $file_share_readwrite = BitOR($file_share_read, $file_share_write)
  63. Global Const $file_share_any = BitOR($file_share_read, $file_share_write, $file_share_delete)
  64. Global Const $generic_all = 268435456
  65. Global Const $generic_execute = 536870912
  66. Global Const $generic_write = 1073741824
  67. Global Const $generic_read = -2147483648
  68. Global Const $generic_readwrite = BitOR($generic_read, $generic_write)
  69. Global Const $tagpoint = "struct;long X;long Y;endstruct"
  70. Global Const $tagrect = "struct;long Left;long Top;long Right;long Bottom;endstruct"
  71. Global Const $tagsize = "struct;long X;long Y;endstruct"
  72. Global Const $tagmargins = "int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight"
  73. Global Const $tagfiletime = "struct;dword Lo;dword Hi;endstruct"
  74. Global Const $tagsystemtime = "struct;word Year;word Month;word Dow;word Day;word Hour;word Minute;word Second;word MSeconds;endstruct"
  75. Global Const $tagtime_zone_information = "struct;long Bias;wchar StdName[32];word StdDate[8];long StdBias;wchar DayName[32];word DayDate[8];long DayBias;endstruct"
  76. Global Const $tagnmhdr = "struct;hwnd hWndFrom;uint_ptr IDFrom;INT Code;endstruct"
  77. Global Const $tagcomboboxexitem = "uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;int SelectedImage;int OverlayImage;" & "int Indent;lparam Param"
  78. Global Const $tagnmcbedragbegin = $tagnmhdr & ";int ItemID;wchar szText[260]"
  79. Global Const $tagnmcbeendedit = $tagnmhdr & ";bool fChanged;int NewSelection;wchar szText[260];int Why"
  80. Global Const $tagnmcomboboxex = $tagnmhdr & ";uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;" & "int SelectedImage;int OverlayImage;int Indent;lparam Param"
  81. 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"
  82. Global Const $tagnmdatetimechange = $tagnmhdr & ";dword Flag;" & $tagsystemtime
  83. Global Const $tagnmdatetimeformat = $tagnmhdr & ";ptr Format;" & $tagsystemtime & ";ptr pDisplay;wchar Display[64]"
  84. Global Const $tagnmdatetimeformatquery = $tagnmhdr & ";ptr Format;struct;long SizeX;long SizeY;endstruct"
  85. Global Const $tagnmdatetimekeydown = $tagnmhdr & ";int VirtKey;ptr Format;" & $tagsystemtime
  86. Global Const $tagnmdatetimestring = $tagnmhdr & ";ptr UserString;" & $tagsystemtime & ";dword Flags"
  87. 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"
  88. Global Const $taggdip_effectparams_blur = "float Radius; bool ExpandEdge"
  89. Global Const $taggdip_effectparams_brightnesscontrast = "int BrightnessLevel; int ContrastLevel"
  90. Global Const $taggdip_effectparams_colorbalance = "int CyanRed; int MagentaGreen; int YellowBlue"
  91. Global Const $taggdip_effectparams_colorcurve = "int Adjustment; int Channel; int AdjustValue"
  92. Global Const $taggdip_effectparams_colorlut = "byte LutB[256]; byte LutG[256]; byte LutR[256]; byte LutA[256]"
  93. Global Const $taggdip_effectparams_huesaturationlightness = "int HueLevel; int SaturationLevel; int LightnessLevel"
  94. Global Const $taggdip_effectparams_levels = "int Highlight; int Midtone; int Shadow"
  95. Global Const $taggdip_effectparams_redeyecorrection = "uint NumberOfAreas; ptr Areas"
  96. Global Const $taggdip_effectparams_sharpen = "float Radius; float Amount"
  97. Global Const $taggdip_effectparams_tint = "int Hue; int Amount"
  98. Global Const $taggdipbitmapdata = "uint Width;uint Height;int Stride;int Format;ptr Scan0;uint_ptr Reserved"
  99. Global Const $taggdipcolormatrix = "float m[25]"
  100. Global Const $taggdipencoderparam = "struct;byte GUID[16];ulong NumberOfValues;ulong Type;ptr Values;endstruct"
  101. Global Const $taggdipencoderparams = "uint Count;" & $taggdipencoderparam
  102. Global Const $taggdiprectf = "struct;float X;float Y;float Width;float Height;endstruct"
  103. Global Const $taggdipstartupinput = "uint Version;ptr Callback;bool NoThread;bool NoCodecs"
  104. Global Const $taggdipstartupoutput = "ptr HookProc;ptr UnhookProc"
  105. 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"
  106. Global Const $taggdippencoderparams = "uint Count;byte Params[1]"
  107. 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"
  108. Global Const $tagnmhddispinfo = $tagnmhdr & ";int Item;uint Mask;ptr Text;int TextMax;int Image;lparam lParam"
  109. Global Const $tagnmhdfilterbtnclick = $tagnmhdr & ";int Item;" & $tagrect
  110. Global Const $tagnmheader = $tagnmhdr & ";int Item;int Button;ptr pItem"
  111. Global Const $taggetipaddress = "byte Field4;byte Field3;byte Field2;byte Field1"
  112. Global Const $tagnmipaddress = $tagnmhdr & ";int Field;int Value"
  113. Global Const $taglvfindinfo = "struct;uint Flags;ptr Text;lparam Param;" & $tagpoint & ";uint Direction;endstruct"
  114. Global Const $taglvhittestinfo = $tagpoint & ";uint Flags;int Item;int SubItem;int iGroup"
  115. Global Const $taglvitem = "struct;uint Mask;int Item;int SubItem;uint State;uint StateMask;ptr Text;int TextMax;int Image;lparam Param;" & "int Indent;int GroupID;uint Columns;ptr pColumns;ptr piColFmt;int iGroup;endstruct"
  116. Global Const $tagnmlistview = $tagnmhdr & ";int Item;int SubItem;uint NewState;uint OldState;uint Changed;" & "struct;long ActionX;long ActionY;endstruct;lparam Param"
  117. Global Const $tagnmlvcustomdraw = "struct;" & $tagnmhdr & ";dword dwDrawStage;handle hdc;" & $tagrect & ";dword_ptr dwItemSpec;uint uItemState;lparam lItemlParam;endstruct" & ";dword clrText;dword clrTextBk;int iSubItem;dword dwItemType;dword clrFace;int iIconEffect;" & "int iIconPhase;int iPartId;int iStateId;struct;long TextLeft;long TextTop;long TextRight;long TextBottom;endstruct;uint uAlign"
  118. Global Const $tagnmlvdispinfo = $tagnmhdr & ";" & $taglvitem
  119. Global Const $tagnmlvfinditem = $tagnmhdr & ";int Start;" & $taglvfindinfo
  120. Global Const $tagnmlvgetinfotip = $tagnmhdr & ";dword Flags;ptr Text;int TextMax;int Item;int SubItem;lparam lParam"
  121. Global Const $tagnmitemactivate = $tagnmhdr & ";int Index;int SubItem;uint NewState;uint OldState;uint Changed;" & $tagpoint & ";lparam lParam;uint KeyFlags"
  122. Global Const $tagnmlvkeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
  123. Global Const $tagnmlvscroll = $tagnmhdr & ";int DX;int DY"
  124. Global Const $tagmchittestinfo = "uint Size;" & $tagpoint & ";uint Hit;" & $tagsystemtime & ";" & $tagrect & ";int iOffset;int iRow;int iCol"
  125. 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"
  126. 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"
  127. 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"
  128. Global Const $tagnmdaystate = $tagnmhdr & ";" & $tagsystemtime & ";int DayState;ptr pDayState"
  129. Global Const $tagnmselchange = $tagnmhdr & ";struct;word BegYear;word BegMonth;word BegDOW;word BegDay;word BegHour;word BegMinute;word BegSecond;word BegMSeconds;endstruct;" & "struct;word EndYear;word EndMonth;word EndDOW;word EndDay;word EndHour;word EndMinute;word EndSecond;word EndMSeconds;endstruct"
  130. Global Const $tagnmobjectnotify = $tagnmhdr & ";int Item;ptr piid;ptr pObject;long Result;dword dwFlags"
  131. Global Const $tagnmtckeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
  132. Global Const $tagtvitem = "struct;uint Mask;handle hItem;uint State;uint StateMask;ptr Text;int TextMax;int Image;int SelectedImage;" & "int Children;lparam Param;endstruct"
  133. Global Const $tagtvitemex = "struct;" & $tagtvitem & ";int Integral;uint uStateEx;hwnd hwnd;int iExpandedImage;int iReserved;endstruct"
  134. Global Const $tagnmtreeview = $tagnmhdr & ";uint Action;" & "struct;uint OldMask;handle OldhItem;uint OldState;uint OldStateMask;" & "ptr OldText;int OldTextMax;int OldImage;int OldSelectedImage;int OldChildren;lparam OldParam;endstruct;" & "struct;uint NewMask;handle NewhItem;uint NewState;uint NewStateMask;" & "ptr NewText;int NewTextMax;int NewImage;int NewSelectedImage;int NewChildren;lparam NewParam;endstruct;" & "struct;long PointX;long PointY;endstruct"
  135. Global Const $tagnmtvcustomdraw = "struct;" & $tagnmhdr & ";dword DrawStage;handle HDC;" & $tagrect & ";dword_ptr ItemSpec;uint ItemState;lparam ItemParam;endstruct" & ";dword ClrText;dword ClrTextBk;int Level"
  136. Global Const $tagnmtvdispinfo = $tagnmhdr & ";" & $tagtvitem
  137. Global Const $tagnmtvgetinfotip = $tagnmhdr & ";ptr Text;int TextMax;handle hItem;lparam lParam"
  138. Global Const $tagtvhittestinfo = $tagpoint & ";uint Flags;handle Item"
  139. Global Const $tagnmtvkeydown = "align 1;" & $tagnmhdr & ";word VKey;uint Flags"
  140. Global Const $tagnmmouse = $tagnmhdr & ";dword_ptr ItemSpec;dword_ptr ItemData;" & $tagpoint & ";lparam HitInfo"
  141. Global Const $tagtoken_privileges = "dword Count;align 4;int64 LUID;dword Attributes"
  142. Global Const $tagimageinfo = "handle hBitmap;handle hMask;int Unused1;int Unused2;" & $tagrect
  143. Global Const $tagmenuinfo = "dword Size;INT Mask;dword Style;uint YMax;handle hBack;dword ContextHelpID;ulong_ptr MenuData"
  144. 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"
  145. Global Const $tagrebarbandinfo = "uint cbSize;uint fMask;uint fStyle;dword clrFore;dword clrBack;ptr lpText;uint cch;" & "int iImage;hwnd hwndChild;uint cxMinChild;uint cyMinChild;uint cx;handle hbmBack;uint wID;uint cyChild;uint cyMaxChild;" & "uint cyIntegral;uint cxIdeal;lparam lParam;uint cxHeader" & ((@OSVersion = "WIN_XP") ? "" : ";" & $tagrect & ";uint uChevronState")
  146. Global Const $tagnmrebarautobreak = $tagnmhdr & ";uint uBand;uint wID;lparam lParam;uint uMsg;uint fStyleCurrent;bool fAutoBreak"
  147. Global Const $tagnmrbautosize = $tagnmhdr & ";bool fChanged;" & "struct;long TargetLeft;long TargetTop;long TargetRight;long TargetBottom;endstruct;" & "struct;long ActualLeft;long ActualTop;long ActualRight;long ActualBottom;endstruct"
  148. Global Const $tagnmrebar = $tagnmhdr & ";dword dwMask;uint uBand;uint fStyle;uint wID;lparam lParam"
  149. Global Const $tagnmrebarchevron = $tagnmhdr & ";uint uBand;uint wID;lparam lParam;" & $tagrect & ";lparam lParamNM"
  150. Global Const $tagnmrebarchildsize = $tagnmhdr & ";uint uBand;uint wID;" & "struct;long CLeft;long CTop;long CRight;long CBottom;endstruct;" & "struct;long BLeft;long BTop;long BRight;long BBottom;endstruct"
  151. Global Const $tagcolorscheme = "dword Size;dword BtnHighlight;dword BtnShadow"
  152. Global Const $tagnmtoolbar = $tagnmhdr & ";int iItem;" & "struct;int iBitmap;int idCommand;byte fsState;byte fsStyle;dword_ptr dwData;int_ptr iString;endstruct" & ";int cchText;ptr pszText;" & $tagrect
  153. Global Const $tagnmtbhotitem = $tagnmhdr & ";int idOld;int idNew;dword dwFlags"
  154. Global Const $tagtbbutton = "int Bitmap;int Command;byte State;byte Style;dword_ptr Param;int_ptr String"
  155. Global Const $tagtbbuttoninfo = "uint Size;dword Mask;int Command;int Image;byte State;byte Style;word CX;dword_ptr Param;ptr Text;int TextMax"
  156. Global Const $tagnetresource = "dword Scope;dword Type;dword DisplayType;dword Usage;ptr LocalName;ptr RemoteName;ptr Comment;ptr Provider"
  157. Global Const $tagoverlapped = "ulong_ptr Internal;ulong_ptr InternalHigh;struct;dword Offset;dword OffsetHigh;endstruct;handle hEvent"
  158. 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"
  159. Global Const $tagbitmapinfoheader = "struct;dword biSize;long biWidth;long biHeight;word biPlanes;word biBitCount;" & "dword biCompression;dword biSizeImage;long biXPelsPerMeter;long biYPelsPerMeter;dword biClrUsed;dword biClrImportant;endstruct"
  160. Global Const $tagbitmapinfo = $tagbitmapinfoheader & ";dword biRGBQuad[1]"
  161. Global Const $tagblendfunction = "byte Op;byte Flags;byte Alpha;byte Format"
  162. Global Const $tagguid = "struct;ulong Data1;ushort Data2;ushort Data3;byte Data4[8];endstruct"
  163. Global Const $tagwindowplacement = "uint length;uint flags;uint showCmd;long ptMinPosition[2];long ptMaxPosition[2];long rcNormalPosition[4]"
  164. Global Const $tagwindowpos = "hwnd hWnd;hwnd InsertAfter;int X;int Y;int CX;int CY;uint Flags"
  165. Global Const $tagscrollinfo = "uint cbSize;uint fMask;int nMin;int nMax;uint nPage;int nPos;int nTrackPos"
  166. Global Const $tagscrollbarinfo = "dword cbSize;" & $tagrect & ";int dxyLineButton;int xyThumbTop;" & "int xyThumbBottom;int reserved;dword rgstate[6]"
  167. Global Const $taglogfont = "struct;long Height;long Width;long Escapement;long Orientation;long Weight;byte Italic;byte Underline;" & "byte Strikeout;byte CharSet;byte OutPrecision;byte ClipPrecision;byte Quality;byte PitchAndFamily;wchar FaceName[32];endstruct"
  168. Global Const $tagkbdllhookstruct = "dword vkCode;dword scanCode;dword flags;dword time;ulong_ptr dwExtraInfo"
  169. Global Const $tagprocess_information = "handle hProcess;handle hThread;dword ProcessID;dword ThreadID"
  170. 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"
  171. Global Const $tagsecurity_attributes = "dword Length;ptr Descriptor;bool InheritHandle"
  172. 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]"
  173. Global Const $tagtextmetric = "long tmHeight;long tmAscent;long tmDescent;long tmInternalLeading;long tmExternalLeading;" & "long tmAveCharWidth;long tmMaxCharWidth;long tmWeight;long tmOverhang;long tmDigitizedAspectX;long tmDigitizedAspectY;" & "wchar tmFirstChar;wchar tmLastChar;wchar tmDefaultChar;wchar tmBreakChar;byte tmItalic;byte tmUnderlined;byte tmStruckOut;" & "byte tmPitchAndFamily;byte tmCharSet"
  174. Global Const $gmem_fixed = 0
  175. Global Const $gmem_moveable = 2
  176. Global Const $gmem_nocompact = 16
  177. Global Const $gmem_nodiscard = 32
  178. Global Const $gmem_zeroinit = 64
  179. Global Const $gmem_modify = 128
  180. Global Const $gmem_discardable = 256
  181. Global Const $gmem_not_banked = 4096
  182. Global Const $gmem_share = 8192
  183. Global Const $gmem_ddeshare = 8192
  184. Global Const $gmem_notify = 16384
  185. Global Const $gmem_lower = 4096
  186. Global Const $gmem_valid_flags = 32626
  187. Global Const $gmem_invalid_handle = 32768
  188. Global Const $gptr = BitOR($gmem_fixed, $gmem_zeroinit)
  189. Global Const $ghnd = BitOR($gmem_moveable, $gmem_zeroinit)
  190. Global Const $mem_commit = 4096
  191. Global Const $mem_reserve = 8192
  192. Global Const $mem_top_down = 1048576
  193. Global Const $mem_shared = 134217728
  194. Global Const $page_noaccess = 1
  195. Global Const $page_readonly = 2
  196. Global Const $page_readwrite = 4
  197. Global Const $page_execute = 16
  198. Global Const $page_execute_read = 32
  199. Global Const $page_execute_readwrite = 64
  200. Global Const $page_execute_writecopy = 128
  201. Global Const $page_guard = 256
  202. Global Const $page_nocache = 512
  203. Global Const $page_writecombine = 1024
  204. Global Const $page_writecopy = 8
  205. Global Const $mem_decommit = 16384
  206. Global Const $mem_release = 32768
  207. Global Const $process_terminate = 1
  208. Global Const $process_create_thread = 2
  209. Global Const $process_set_sessionid = 4
  210. Global Const $process_vm_operation = 8
  211. Global Const $process_vm_read = 16
  212. Global Const $process_vm_write = 32
  213. Global Const $process_dup_handle = 64
  214. Global Const $process_create_process = 128
  215. Global Const $process_set_quota = 256
  216. Global Const $process_set_information = 512
  217. Global Const $process_query_information = 1024
  218. Global Const $process_query_limited_information = 4096
  219. Global Const $process_suspend_resume = 2048
  220. Global Const $process_all_access = 2035711
  221. Global Const $se_assignprimarytoken_name = "SeAssignPrimaryTokenPrivilege"
  222. Global Const $se_audit_name = "SeAuditPrivilege"
  223. Global Const $se_backup_name = "SeBackupPrivilege"
  224. Global Const $se_change_notify_name = "SeChangeNotifyPrivilege"
  225. Global Const $se_create_global_name = "SeCreateGlobalPrivilege"
  226. Global Const $se_create_pagefile_name = "SeCreatePagefilePrivilege"
  227. Global Const $se_create_permanent_name = "SeCreatePermanentPrivilege"
  228. Global Const $se_create_symbolic_link_name = "SeCreateSymbolicLinkPrivilege"
  229. Global Const $se_create_token_name = "SeCreateTokenPrivilege"
  230. Global Const $se_debug_name = "SeDebugPrivilege"
  231. Global Const $se_enable_delegation_name = "SeEnableDelegationPrivilege"
  232. Global Const $se_impersonate_name = "SeImpersonatePrivilege"
  233. Global Const $se_inc_base_priority_name = "SeIncreaseBasePriorityPrivilege"
  234. Global Const $se_inc_working_set_name = "SeIncreaseWorkingSetPrivilege"
  235. Global Const $se_increase_quota_name = "SeIncreaseQuotaPrivilege"
  236. Global Const $se_load_driver_name = "SeLoadDriverPrivilege"
  237. Global Const $se_lock_memory_name = "SeLockMemoryPrivilege"
  238. Global Const $se_machine_account_name = "SeMachineAccountPrivilege"
  239. Global Const $se_manage_volume_name = "SeManageVolumePrivilege"
  240. Global Const $se_prof_single_process_name = "SeProfileSingleProcessPrivilege"
  241. Global Const $se_relabel_name = "SeRelabelPrivilege"
  242. Global Const $se_remote_shutdown_name = "SeRemoteShutdownPrivilege"
  243. Global Const $se_restore_name = "SeRestorePrivilege"
  244. Global Const $se_security_name = "SeSecurityPrivilege"
  245. Global Const $se_shutdown_name = "SeShutdownPrivilege"
  246. Global Const $se_sync_agent_name = "SeSyncAgentPrivilege"
  247. Global Const $se_system_environment_name = "SeSystemEnvironmentPrivilege"
  248. Global Const $se_system_profile_name = "SeSystemProfilePrivilege"
  249. Global Const $se_systemtime_name = "SeSystemtimePrivilege"
  250. Global Const $se_take_ownership_name = "SeTakeOwnershipPrivilege"
  251. Global Const $se_tcb_name = "SeTcbPrivilege"
  252. Global Const $se_time_zone_name = "SeTimeZonePrivilege"
  253. Global Const $se_trusted_credman_access_name = "SeTrustedCredManAccessPrivilege"
  254. Global Const $se_unsolicited_input_name = "SeUnsolicitedInputPrivilege"
  255. Global Const $se_undock_name = "SeUndockPrivilege"
  256. Global Const $se_privilege_enabled_by_default = 1
  257. Global Const $se_privilege_enabled = 2
  258. Global Const $se_privilege_removed = 4
  259. Global Const $se_privilege_used_for_access = -2147483648
  260. Global Const $se_group_mandatory = 1
  261. Global Const $se_group_enabled_by_default = 2
  262. Global Const $se_group_enabled = 4
  263. Global Const $se_group_owner = 8
  264. Global Const $se_group_use_for_deny_only = 16
  265. Global Const $se_group_integrity = 32
  266. Global Const $se_group_integrity_enabled = 64
  267. Global Const $se_group_resource = 536870912
  268. Global Const $se_group_logon_id = -1073741824
  269. Global Enum $tokenprimary = 1, $tokenimpersonation
  270. Global Enum $securityanonymous = 0, $securityidentification, $securityimpersonation, $securitydelegation
  271. Global Enum $tokenuser = 1, $tokengroups, $tokenprivileges, $tokenowner, $tokenprimarygroup, $tokendefaultdacl, $tokensource, $tokentype, $tokenimpersonationlevel, $tokenstatistics, $tokenrestrictedsids, $tokensessionid, $tokengroupsandprivileges, $tokensessionreference, $tokensandboxinert, $tokenauditpolicy, $tokenorigin, $tokenelevationtype, $tokenlinkedtoken, $tokenelevation, $tokenhasrestrictions, $tokenaccessinformation, $tokenvirtualizationallowed, $tokenvirtualizationenabled, $tokenintegritylevel, $tokenuiaccess, $tokenmandatorypolicy, $tokenlogonsid
  272. Global Const $token_assign_primary = 1
  273. Global Const $token_duplicate = 2
  274. Global Const $token_impersonate = 4
  275. Global Const $token_query = 8
  276. Global Const $token_query_source = 16
  277. Global Const $token_adjust_privileges = 32
  278. Global Const $token_adjust_groups = 64
  279. Global Const $token_adjust_default = 128
  280. Global Const $token_adjust_sessionid = 256
  281. Global Const $token_all_access = 983551
  282. Global Const $token_read = 131080
  283. Global Const $token_write = 131296
  284. Global Const $token_execute = 131072
  285. Global Const $token_has_traverse_privilege = 1
  286. Global Const $token_has_backup_privilege = 2
  287. Global Const $token_has_restore_privilege = 4
  288. Global Const $token_has_admin_group = 8
  289. Global Const $token_is_restricted = 16
  290. Global Const $token_session_not_referenced = 32
  291. Global Const $token_sandbox_inert = 64
  292. Global Const $token_has_impersonate_privilege = 128
  293. Global Const $rights_delete = 65536
  294. Global Const $read_control = 131072
  295. Global Const $write_dac = 262144
  296. Global Const $write_owner = 524288
  297. Global Const $synchronize = 1048576
  298. Global Const $access_system_security = 16777216
  299. Global Const $standard_rights_required = 983040
  300. Global Const $standard_rights_read = $read_control
  301. Global Const $standard_rights_write = $read_control
  302. Global Const $standard_rights_execute = $read_control
  303. Global Const $standard_rights_all = 2031616
  304. Global Const $specific_rights_all = 65535
  305. Global Enum $not_used_access = 0, $grant_access, $set_access, $deny_access, $revoke_access, $set_audit_success, $set_audit_failure
  306. Global Enum $trustee_is_unknown = 0, $trustee_is_user, $trustee_is_group, $trustee_is_domain, $trustee_is_alias, $trustee_is_well_known_group, $trustee_is_deleted, $trustee_is_invalid, $trustee_is_computer
  307. Global Const $logon_with_profile = 1
  308. Global Const $logon_netcredentials_only = 2
  309. Global Enum $sidtypeuser = 1, $sidtypegroup, $sidtypedomain, $sidtypealias, $sidtypewellknowngroup, $sidtypedeletedaccount, $sidtypeinvalid, $sidtypeunknown, $sidtypecomputer, $sidtypelabel
  310. Global Const $sid_administrators = "S-1-5-32-544"
  311. Global Const $sid_users = "S-1-5-32-545"
  312. Global Const $sid_guests = "S-1-5-32-546"
  313. Global Const $sid_account_operators = "S-1-5-32-548"
  314. Global Const $sid_server_operators = "S-1-5-32-549"
  315. Global Const $sid_print_operators = "S-1-5-32-550"
  316. Global Const $sid_backup_operators = "S-1-5-32-551"
  317. Global Const $sid_replicator = "S-1-5-32-552"
  318. Global Const $sid_owner = "S-1-3-0"
  319. Global Const $sid_everyone = "S-1-1-0"
  320. Global Const $sid_network = "S-1-5-2"
  321. Global Const $sid_interactive = "S-1-5-4"
  322. Global Const $sid_system = "S-1-5-18"
  323. Global Const $sid_authenticated_users = "S-1-5-11"
  324. Global Const $sid_schannel_authentication = "S-1-5-64-14"
  325. Global Const $sid_digest_authentication = "S-1-5-64-21"
  326. Global Const $sid_nt_service = "S-1-5-80"
  327. Global Const $sid_untrusted_mandatory_level = "S-1-16-0"
  328. Global Const $sid_low_mandatory_level = "S-1-16-4096"
  329. Global Const $sid_medium_mandatory_level = "S-1-16-8192"
  330. Global Const $sid_medium_plus_mandatory_level = "S-1-16-8448"
  331. Global Const $sid_high_mandatory_level = "S-1-16-12288"
  332. Global Const $sid_system_mandatory_level = "S-1-16-16384"
  333. Global Const $sid_protected_process_mandatory_level = "S-1-16-20480"
  334. Global Const $sid_secure_process_mandatory_level = "S-1-16-28672"
  335. Global Const $sid_all_services = "S-1-5-80-0"
  336.  
  337. Func _security__adjusttokenprivileges($htoken, $fdisableall, $pnewstate, $ibufferlen, $pprevstate = 0, $prequired = 0)
  338.     Local $acall = DllCall("advapi32.dll", "bool", "AdjustTokenPrivileges", "handle", $htoken, "bool", $fdisableall, "struct*", $pnewstate, "dword", $ibufferlen, "struct*", $pprevstate, "struct*", $prequired)
  339.     If @error Then Return SetError(@error, @extended, False)
  340.     Return NOT ($acall[0] = 0)
  341. EndFunc
  342.  
  343. Func _security__createprocesswithtoken($htoken, $ilogonflags, $scommandline, $icreationflags, $scurdir, $tstartupinfo, $tprocess_information)
  344.     Local $acall = DllCall("advapi32.dll", "bool", "CreateProcessWithTokenW", "handle", $htoken, "dword", $ilogonflags, "ptr", 0, "wstr", $scommandline, "dword", $icreationflags, "struct*", 0, "wstr", $scurdir, "struct*", $tstartupinfo, "struct*", $tprocess_information)
  345.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, False)
  346.     Return True
  347. EndFunc
  348.  
  349. Func _security__duplicatetokenex($hexistingtoken, $idesiredaccess, $iimpersonationlevel, $itokentype)
  350.     Local $acall = DllCall("advapi32.dll", "bool", "DuplicateTokenEx", "handle", $hexistingtoken, "dword", $idesiredaccess, "struct*", 0, "int", $iimpersonationlevel, "int", $itokentype, "handle*", 0)
  351.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  352.     Return $acall[6]
  353. EndFunc
  354.  
  355. Func _security__getaccountsid($saccount, $ssystem = "")
  356.     Local $aacct = _security__lookupaccountname($saccount, $ssystem)
  357.     If @error Then Return SetError(@error, @extended, 0)
  358.     If IsArray($aacct) Then Return _security__stringsidtosid($aacct[0])
  359.     Return ""
  360. EndFunc
  361.  
  362. Func _security__getlengthsid($psid)
  363.     If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, @extended, 0)
  364.     Local $acall = DllCall("advapi32.dll", "dword", "GetLengthSid", "struct*", $psid)
  365.     If @error Then Return SetError(@error, @extended, 0)
  366.     Return $acall[0]
  367. EndFunc
  368.  
  369. Func _security__gettokeninformation($htoken, $iclass)
  370.     Local $acall = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $htoken, "int", $iclass, "struct*", 0, "dword", 0, "dword*", 0)
  371.     If @error OR NOT $acall[5] Then Return SetError(@error + 10, @extended, 0)
  372.     Local $ilen = $acall[5]
  373.     Local $tbuffer = DllStructCreate("byte[" & $ilen & "]")
  374.     $acall = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $htoken, "int", $iclass, "struct*", $tbuffer, "dword", DllStructGetSize($tbuffer), "dword*", 0)
  375.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  376.     Return $tbuffer
  377. EndFunc
  378.  
  379. Func _security__impersonateself($ilevel = $securityimpersonation)
  380.     Local $acall = DllCall("advapi32.dll", "bool", "ImpersonateSelf", "int", $ilevel)
  381.     If @error Then Return SetError(@error, @extended, False)
  382.     Return NOT ($acall[0] = 0)
  383. EndFunc
  384.  
  385. Func _security__isvalidsid($psid)
  386.     Local $acall = DllCall("advapi32.dll", "bool", "IsValidSid", "struct*", $psid)
  387.     If @error Then Return SetError(@error, @extended, False)
  388.     Return NOT ($acall[0] = 0)
  389. EndFunc
  390.  
  391. Func _security__lookupaccountname($saccount, $ssystem = "")
  392.     Local $tdata = DllStructCreate("byte SID[256]")
  393.     Local $acall = DllCall("advapi32.dll", "bool", "LookupAccountNameW", "wstr", $ssystem, "wstr", $saccount, "struct*", $tdata, "dword*", DllStructGetSize($tdata), "wstr", "", "dword*", DllStructGetSize($tdata), "int*", 0)
  394.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  395.     Local $aacct[3]
  396.     $aacct[0] = _security__sidtostringsid(DllStructGetPtr($tdata, "SID"))
  397.     $aacct[1] = $acall[5]
  398.     $aacct[2] = $acall[7]
  399.     Return $aacct
  400. EndFunc
  401.  
  402. Func _security__lookupaccountsid($vsid, $ssystem = "")
  403.     Local $psid, $aacct[3]
  404.     If IsString($vsid) Then
  405.         $psid = _security__stringsidtosid($vsid)
  406.     Else
  407.         $psid = $vsid
  408.     EndIf
  409.     If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, @extended, 0)
  410.     Local $typesystem = "ptr"
  411.     If $ssystem Then $typesystem = "wstr"
  412.     Local $acall = DllCall("advapi32.dll", "bool", "LookupAccountSidW", $typesystem, $ssystem, "struct*", $psid, "wstr", "", "dword*", 65536, "wstr", "", "dword*", 65536, "int*", 0)
  413.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  414.     Local $aacct[3]
  415.     $aacct[0] = $acall[3]
  416.     $aacct[1] = $acall[5]
  417.     $aacct[2] = $acall[7]
  418.     Return $aacct
  419. EndFunc
  420.  
  421. Func _security__lookupprivilegevalue($ssystem, $sname)
  422.     Local $acall = DllCall("advapi32.dll", "bool", "LookupPrivilegeValueW", "wstr", $ssystem, "wstr", $sname, "int64*", 0)
  423.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  424.     Return $acall[3]
  425. EndFunc
  426.  
  427. Func _security__openprocesstoken($hprocess, $iaccess)
  428.     Local $acall = DllCall("advapi32.dll", "bool", "OpenProcessToken", "handle", $hprocess, "dword", $iaccess, "handle*", 0)
  429.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  430.     Return $acall[3]
  431. EndFunc
  432.  
  433. Func _security__openthreadtoken($iaccess, $hthread = 0, $fopenasself = False)
  434.     If $hthread = 0 Then
  435.         Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentThread")
  436.         If @error Then Return SetError(@error + 10, @extended, 0)
  437.         $hthread = $aresult[0]
  438.     EndIf
  439.     Local $acall = DllCall("advapi32.dll", "bool", "OpenThreadToken", "handle", $hthread, "dword", $iaccess, "bool", $fopenasself, "handle*", 0)
  440.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  441.     Return $acall[4]
  442. EndFunc
  443.  
  444. Func _security__openthreadtokenex($iaccess, $hthread = 0, $fopenasself = False)
  445.     Local $htoken = _security__openthreadtoken($iaccess, $hthread, $fopenasself)
  446.     If $htoken = 0 Then
  447.         Local Const $error_no_token = 1008
  448.         If _winapi_getlasterror() <> $error_no_token Then Return SetError(20, _winapi_getlasterror(), 0)
  449.         If NOT _security__impersonateself() Then Return SetError(@error + 10, _winapi_getlasterror(), 0)
  450.         $htoken = _security__openthreadtoken($iaccess, $hthread, $fopenasself)
  451.         If $htoken = 0 Then Return SetError(@error, _winapi_getlasterror(), 0)
  452.     EndIf
  453.     Return $htoken
  454. EndFunc
  455.  
  456. Func _security__setprivilege($htoken, $sprivilege, $fenable)
  457.     Local $iluid = _security__lookupprivilegevalue("", $sprivilege)
  458.     If $iluid = 0 Then Return SetError(@error + 10, @extended, False)
  459.     Local Const $tagtoken_privileges = "dword Count;align 4;int64 LUID;dword Attributes"
  460.     Local $tcurrstate = DllStructCreate($tagtoken_privileges)
  461.     Local $icurrstate = DllStructGetSize($tcurrstate)
  462.     Local $tprevstate = DllStructCreate($tagtoken_privileges)
  463.     Local $iprevstate = DllStructGetSize($tprevstate)
  464.     Local $trequired = DllStructCreate("int Data")
  465.     DllStructSetData($tcurrstate, "Count", 1)
  466.     DllStructSetData($tcurrstate, "LUID", $iluid)
  467.     If NOT _security__adjusttokenprivileges($htoken, False, $tcurrstate, $icurrstate, $tprevstate, $trequired) Then Return SetError(2, @error, False)
  468.     DllStructSetData($tprevstate, "Count", 1)
  469.     DllStructSetData($tprevstate, "LUID", $iluid)
  470.     Local $iattributes = DllStructGetData($tprevstate, "Attributes")
  471.     If $fenable Then
  472.         $iattributes = BitOR($iattributes, $se_privilege_enabled)
  473.     Else
  474.         $iattributes = BitAND($iattributes, BitNOT($se_privilege_enabled))
  475.     EndIf
  476.     DllStructSetData($tprevstate, "Attributes", $iattributes)
  477.     If NOT _security__adjusttokenprivileges($htoken, False, $tprevstate, $iprevstate, $tcurrstate, $trequired) Then Return SetError(3, @error, False)
  478.     Return True
  479. EndFunc
  480.  
  481. Func _security__settokeninformation($htoken, $itokeninformation, $vtokeninformation, $itokeninformationlength)
  482.     Local $acall = DllCall("advapi32.dll", "bool", "SetTokenInformation", "handle", $htoken, "int", $itokeninformation, "struct*", $vtokeninformation, "dword", $itokeninformationlength)
  483.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, False)
  484.     Return True
  485. EndFunc
  486.  
  487. Func _security__sidtostringsid($psid)
  488.     If NOT _security__isvalidsid($psid) Then Return SetError(@error + 10, 0, "")
  489.     Local $acall = DllCall("advapi32.dll", "bool", "ConvertSidToStringSidW", "struct*", $psid, "ptr*", 0)
  490.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, "")
  491.     Local $pstringsid = $acall[2]
  492.     Local $alen = DllCall("kernel32.dll", "int", "lstrlenW", "struct*", $pstringsid)
  493.     Local $ssid = DllStructGetData(DllStructCreate("wchar Text[" & $alen[0] + 1 & "]", $pstringsid), "Text")
  494.     DllCall("kernel32.dll", "handle", "LocalFree", "handle", $pstringsid)
  495.     Return $ssid
  496. EndFunc
  497.  
  498. Func _security__sidtypestr($itype)
  499.     Switch $itype
  500.         Case $sidtypeuser
  501.             Return "User"
  502.         Case $sidtypegroup
  503.             Return "Group"
  504.         Case $sidtypedomain
  505.             Return "Domain"
  506.         Case $sidtypealias
  507.             Return "Alias"
  508.         Case $sidtypewellknowngroup
  509.             Return "Well Known Group"
  510.         Case $sidtypedeletedaccount
  511.             Return "Deleted Account"
  512.         Case $sidtypeinvalid
  513.             Return "Invalid"
  514.         Case $sidtypeunknown
  515.             Return "Unknown Type"
  516.         Case $sidtypecomputer
  517.             Return "Computer"
  518.         Case $sidtypelabel
  519.             Return "A mandatory integrity label SID"
  520.         Case Else
  521.             Return "Unknown SID Type"
  522.     EndSwitch
  523. EndFunc
  524.  
  525. Func _security__stringsidtosid($ssid)
  526.     Local $acall = DllCall("advapi32.dll", "bool", "ConvertStringSidToSidW", "wstr", $ssid, "ptr*", 0)
  527.     If @error OR NOT $acall[0] Then Return SetError(@error, @extended, 0)
  528.     Local $psid = $acall[2]
  529.     Local $tbuffer = DllStructCreate("byte Data[" & _security__getlengthsid($psid) & "]", $psid)
  530.     Local $tsid = DllStructCreate("byte Data[" & DllStructGetSize($tbuffer) & "]")
  531.     DllStructSetData($tsid, "Data", DllStructGetData($tbuffer, "Data"))
  532.     DllCall("kernel32.dll", "handle", "LocalFree", "handle", $psid)
  533.     Return $tsid
  534. EndFunc
  535.  
  536. Global Const $tagmemmap = "handle hProc;ulong_ptr Size;ptr Mem"
  537.  
  538. Func _memfree(ByRef $tmemmap)
  539.     Local $pmemory = DllStructGetData($tmemmap, "Mem")
  540.     Local $hprocess = DllStructGetData($tmemmap, "hProc")
  541.     Local $bresult = _memvirtualfreeex($hprocess, $pmemory, 0, $mem_release)
  542.     DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hprocess)
  543.     If @error Then Return SetError(@error, @extended, False)
  544.     Return $bresult
  545. EndFunc
  546.  
  547. Func _memglobalalloc($ibytes, $iflags = 0)
  548.     Local $aresult = DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", $iflags, "ulong_ptr", $ibytes)
  549.     If @error Then Return SetError(@error, @extended, 0)
  550.     Return $aresult[0]
  551. EndFunc
  552.  
  553. Func _memglobalfree($hmem)
  554.     Local $aresult = DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", $hmem)
  555.     If @error Then Return SetError(@error, @extended, False)
  556.     Return $aresult[0]
  557. EndFunc
  558.  
  559. Func _memgloballock($hmem)
  560.     Local $aresult = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", $hmem)
  561.     If @error Then Return SetError(@error, @extended, 0)
  562.     Return $aresult[0]
  563. EndFunc
  564.  
  565. Func _memglobalsize($hmem)
  566.     Local $aresult = DllCall("kernel32.dll", "ulong_ptr", "GlobalSize", "handle", $hmem)
  567.     If @error Then Return SetError(@error, @extended, 0)
  568.     Return $aresult[0]
  569. EndFunc
  570.  
  571. Func _memglobalunlock($hmem)
  572.     Local $aresult = DllCall("kernel32.dll", "bool", "GlobalUnlock", "handle", $hmem)
  573.     If @error Then Return SetError(@error, @extended, 0)
  574.     Return $aresult[0]
  575. EndFunc
  576.  
  577. Func _meminit($hwnd, $isize, ByRef $tmemmap)
  578.     Local $aresult = DllCall("User32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $hwnd, "dword*", 0)
  579.     If @error Then Return SetError(@error + 10, @extended, 0)
  580.     Local $iprocessid = $aresult[2]
  581.     If $iprocessid = 0 Then Return SetError(1, 0, 0)
  582.     Local $iaccess = BitOR($process_vm_operation, $process_vm_read, $process_vm_write)
  583.     Local $hprocess = __mem_openprocess($iaccess, False, $iprocessid, True)
  584.     Local $ialloc = BitOR($mem_reserve, $mem_commit)
  585.     Local $pmemory = _memvirtualallocex($hprocess, 0, $isize, $ialloc, $page_readwrite)
  586.     If $pmemory = 0 Then Return SetError(2, 0, 0)
  587.     $tmemmap = DllStructCreate($tagmemmap)
  588.     DllStructSetData($tmemmap, "hProc", $hprocess)
  589.     DllStructSetData($tmemmap, "Size", $isize)
  590.     DllStructSetData($tmemmap, "Mem", $pmemory)
  591.     Return $pmemory
  592. EndFunc
  593.  
  594. Func _memmovememory($psource, $pdest, $ilength)
  595.     DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pdest, "struct*", $psource, "ulong_ptr", $ilength)
  596.     If @error Then Return SetError(@error, @extended)
  597. EndFunc
  598.  
  599. Func _memread(ByRef $tmemmap, $psrce, $pdest, $isize)
  600.     Local $aresult = DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", DllStructGetData($tmemmap, "hProc"), "ptr", $psrce, "struct*", $pdest, "ulong_ptr", $isize, "ulong_ptr*", 0)
  601.     If @error Then Return SetError(@error, @extended, False)
  602.     Return $aresult[0]
  603. EndFunc
  604.  
  605. Func _memwrite(ByRef $tmemmap, $psrce, $pdest = 0, $isize = 0, $ssrce = "struct*")
  606.     If $pdest = 0 Then $pdest = DllStructGetData($tmemmap, "Mem")
  607.     If $isize = 0 Then $isize = DllStructGetData($tmemmap, "Size")
  608.     Local $aresult = DllCall("kernel32.dll", "bool", "WriteProcessMemory", "handle", DllStructGetData($tmemmap, "hProc"), "ptr", $pdest, $ssrce, $psrce, "ulong_ptr", $isize, "ulong_ptr*", 0)
  609.     If @error Then Return SetError(@error, @extended, False)
  610.     Return $aresult[0]
  611. EndFunc
  612.  
  613. Func _memvirtualalloc($paddress, $isize, $iallocation, $iprotect)
  614.     Local $aresult = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", $paddress, "ulong_ptr", $isize, "dword", $iallocation, "dword", $iprotect)
  615.     If @error Then Return SetError(@error, @extended, 0)
  616.     Return $aresult[0]
  617. EndFunc
  618.  
  619. Func _memvirtualallocex($hprocess, $paddress, $isize, $iallocation, $iprotect)
  620.     Local $aresult = DllCall("kernel32.dll", "ptr", "VirtualAllocEx", "handle", $hprocess, "ptr", $paddress, "ulong_ptr", $isize, "dword", $iallocation, "dword", $iprotect)
  621.     If @error Then Return SetError(@error, @extended, 0)
  622.     Return $aresult[0]
  623. EndFunc
  624.  
  625. Func _memvirtualfree($paddress, $isize, $ifreetype)
  626.     Local $aresult = DllCall("kernel32.dll", "bool", "VirtualFree", "ptr", $paddress, "ulong_ptr", $isize, "dword", $ifreetype)
  627.     If @error Then Return SetError(@error, @extended, False)
  628.     Return $aresult[0]
  629. EndFunc
  630.  
  631. Func _memvirtualfreeex($hprocess, $paddress, $isize, $ifreetype)
  632.     Local $aresult = DllCall("kernel32.dll", "bool", "VirtualFreeEx", "handle", $hprocess, "ptr", $paddress, "ulong_ptr", $isize, "dword", $ifreetype)
  633.     If @error Then Return SetError(@error, @extended, False)
  634.     Return $aresult[0]
  635. EndFunc
  636.  
  637. Func __mem_openprocess($iaccess, $finherit, $iprocessid, $fdebugpriv = False)
  638.     Local $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $finherit, "dword", $iprocessid)
  639.     If @error Then Return SetError(@error + 10, @extended, 0)
  640.     If $aresult[0] Then Return $aresult[0]
  641.     If NOT $fdebugpriv Then Return 0
  642.     Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
  643.     If @error Then Return SetError(@error + 20, @extended, 0)
  644.     _security__setprivilege($htoken, "SeDebugPrivilege", True)
  645.     Local $ierror = @error
  646.     Local $ilasterror = @extended
  647.     Local $iret = 0
  648.     If NOT @error Then
  649.         $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $finherit, "dword", $iprocessid)
  650.         $ierror = @error
  651.         $ilasterror = @extended
  652.         If $aresult[0] Then $iret = $aresult[0]
  653.         _security__setprivilege($htoken, "SeDebugPrivilege", False)
  654.         If @error Then
  655.             $ierror = @error + 30
  656.             $ilasterror = @extended
  657.         EndIf
  658.     Else
  659.         $ierror = @error + 40
  660.     EndIf
  661.     DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $htoken)
  662.     Return SetError($ierror, $ilasterror, $iret)
  663. EndFunc
  664.  
  665. Global Const $hgdi_error = Ptr(-1)
  666. Global Const $invalid_handle_value = Ptr(-1)
  667. Global Const $clr_invalid = -1
  668. Global Const $null_brush = 5
  669. Global Const $null_pen = 8
  670. Global Const $black_brush = 4
  671. Global Const $dkgray_brush = 3
  672. Global Const $dc_brush = 18
  673. Global Const $gray_brush = 2
  674. Global Const $hollow_brush = $null_brush
  675. Global Const $ltgray_brush = 1
  676. Global Const $white_brush = 0
  677. Global Const $black_pen = 7
  678. Global Const $dc_pen = 19
  679. Global Const $white_pen = 6
  680. Global Const $ansi_fixed_font = 11
  681. Global Const $ansi_var_font = 12
  682. Global Const $device_default_font = 14
  683. Global Const $default_gui_font = 17
  684. Global Const $oem_fixed_font = 10
  685. Global Const $system_font = 13
  686. Global Const $system_fixed_font = 16
  687. Global Const $default_palette = 15
  688. Global Const $mb_precomposed = 1
  689. Global Const $mb_composite = 2
  690. Global Const $mb_useglyphchars = 4
  691. Global Const $ulw_alpha = 2
  692. Global Const $ulw_colorkey = 1
  693. Global Const $ulw_opaque = 4
  694. Global Const $ulw_ex_noresize = 8
  695. Global Const $wh_callwndproc = 4
  696. Global Const $wh_callwndprocret = 12
  697. Global Const $wh_cbt = 5
  698. Global Const $wh_debug = 9
  699. Global Const $wh_foregroundidle = 11
  700. Global Const $wh_getmessage = 3
  701. Global Const $wh_journalplayback = 1
  702. Global Const $wh_journalrecord = 0
  703. Global Const $wh_keyboard = 2
  704. Global Const $wh_keyboard_ll = 13
  705. Global Const $wh_mouse = 7
  706. Global Const $wh_mouse_ll = 14
  707. Global Const $wh_msgfilter = -1
  708. Global Const $wh_shell = 10
  709. Global Const $wh_sysmsgfilter = 6
  710. Global Const $wpf_asyncwindowplacement = 4
  711. Global Const $wpf_restoretomaximized = 2
  712. Global Const $wpf_setminposition = 1
  713. Global Const $kf_extended = 256
  714. Global Const $kf_altdown = 8192
  715. Global Const $kf_up = 32768
  716. Global Const $llkhf_extended = BitShift($kf_extended, 8)
  717. Global Const $llkhf_injected = 16
  718. Global Const $llkhf_altdown = BitShift($kf_altdown, 8)
  719. Global Const $llkhf_up = BitShift($kf_up, 8)
  720. Global Const $ofn_allowmultiselect = 512
  721. Global Const $ofn_createprompt = 8192
  722. Global Const $ofn_dontaddtorecent = 33554432
  723. Global Const $ofn_enablehook = 32
  724. Global Const $ofn_enableincludenotify = 4194304
  725. Global Const $ofn_enablesizing = 8388608
  726. Global Const $ofn_enabletemplate = 64
  727. Global Const $ofn_enabletemplatehandle = 128
  728. Global Const $ofn_explorer = 524288
  729. Global Const $ofn_extensiondifferent = 1024
  730. Global Const $ofn_filemustexist = 4096
  731. Global Const $ofn_forceshowhidden = 268435456
  732. Global Const $ofn_hidereadonly = 4
  733. Global Const $ofn_longnames = 2097152
  734. Global Const $ofn_nochangedir = 8
  735. Global Const $ofn_nodereferencelinks = 1048576
  736. Global Const $ofn_nolongnames = 262144
  737. Global Const $ofn_nonetworkbutton = 131072
  738. Global Const $ofn_noreadonlyreturn = 32768
  739. Global Const $ofn_notestfilecreate = 65536
  740. Global Const $ofn_novalidate = 256
  741. Global Const $ofn_overwriteprompt = 2
  742. Global Const $ofn_pathmustexist = 2048
  743. Global Const $ofn_readonly = 1
  744. Global Const $ofn_shareaware = 16384
  745. Global Const $ofn_showhelp = 16
  746. Global Const $ofn_ex_noplacesbar = 1
  747. Global Const $tmpf_fixed_pitch = 1
  748. Global Const $tmpf_vector = 2
  749. Global Const $tmpf_truetype = 4
  750. Global Const $tmpf_device = 8
  751. Global Const $duplicate_close_source = 1
  752. Global Const $duplicate_same_access = 2
  753. Global Const $di_mask = 1
  754. Global Const $di_image = 2
  755. Global Const $di_normal = 3
  756. Global Const $di_compat = 4
  757. Global Const $di_defaultsize = 8
  758. Global Const $di_nomirror = 16
  759. Global Const $display_device_attached_to_desktop = 1
  760. Global Const $display_device_multi_driver = 2
  761. Global Const $display_device_primary_device = 4
  762. Global Const $display_device_mirroring_driver = 8
  763. Global Const $display_device_vga_compatible = 16
  764. Global Const $display_device_removable = 32
  765. Global Const $display_device_disconnect = 33554432
  766. Global Const $display_device_remote = 67108864
  767. Global Const $display_device_modespruned = 134217728
  768. Global Const $flashw_caption = 1
  769. Global Const $flashw_tray = 2
  770. Global Const $flashw_timer = 4
  771. Global Const $flashw_timernofg = 12
  772. Global Const $format_message_allocate_buffer = 256
  773. Global Const $format_message_ignore_inserts = 512
  774. Global Const $format_message_from_string = 1024
  775. Global Const $format_message_from_hmodule = 2048
  776. Global Const $format_message_from_system = 4096
  777. Global Const $format_message_argument_array = 8192
  778. Global Const $gw_hwndfirst = 0
  779. Global Const $gw_hwndlast = 1
  780. Global Const $gw_hwndnext = 2
  781. Global Const $gw_hwndprev = 3
  782. Global Const $gw_owner = 4
  783. Global Const $gw_child = 5
  784. Global Const $gwl_wndproc = -4
  785. Global Const $gwl_hinstance = -6
  786. Global Const $gwl_hwndparent = -8
  787. Global Const $gwl_id = -12
  788. Global Const $gwl_style = -16
  789. Global Const $gwl_exstyle = -20
  790. Global Const $gwl_userdata = -21
  791. Global Const $std_cut = 0
  792. Global Const $std_copy = 1
  793. Global Const $std_paste = 2
  794. Global Const $std_undo = 3
  795. Global Const $std_redow = 4
  796. Global Const $std_delete = 5
  797. Global Const $std_filenew = 6
  798. Global Const $std_fileopen = 7
  799. Global Const $std_filesave = 8
  800. Global Const $std_printpre = 9
  801. Global Const $std_properties = 10
  802. Global Const $std_help = 11
  803. Global Const $std_find = 12
  804. Global Const $std_replace = 13
  805. Global Const $std_print = 14
  806. Global Const $image_bitmap = 0
  807. Global Const $image_icon = 1
  808. Global Const $image_cursor = 2
  809. Global Const $image_enhmetafile = 3
  810. Global Const $kb_sendspecial = 0
  811. Global Const $kb_sendraw = 1
  812. Global Const $kb_capsoff = 0
  813. Global Const $kb_capson = 1
  814. Global Const $dont_resolve_dll_references = 1
  815. Global Const $load_library_as_datafile = 2
  816. Global Const $load_with_altered_search_path = 8
  817. Global Const $load_ignore_code_authz_level = 16
  818. Global Const $load_library_as_datafile_exclusive = 64
  819. Global Const $load_library_as_image_resource = 32
  820. Global Const $load_library_search_application_dir = 512
  821. Global Const $load_library_search_default_dirs = 4096
  822. Global Const $load_library_search_dll_load_dir = 256
  823. Global Const $load_library_search_system32 = 2048
  824. Global Const $load_library_search_user_dirs = 1024
  825. Global Const $s_ok = 0
  826. Global Const $e_abort = -2147467260
  827. Global Const $e_accessdenied = -2147024891
  828. Global Const $e_fail = -2147467259
  829. Global Const $e_handle = -2147024890
  830. Global Const $e_invalidarg = -2147024809
  831. Global Const $e_nointerface = -2147467262
  832. Global Const $e_notimpl = -2147467263
  833. Global Const $e_outofmemory = -2147024882
  834. Global Const $e_pointer = -2147467261
  835. Global Const $e_unexpected = -2147418113
  836. Global Const $lr_defaultcolor = 0
  837. Global Const $lr_monochrome = 1
  838. Global Const $lr_color = 2
  839. Global Const $lr_copyreturnorg = 4
  840. Global Const $lr_copydeleteorg = 8
  841. Global Const $lr_loadfromfile = 16
  842. Global Const $lr_loadtransparent = 32
  843. Global Const $lr_defaultsize = 64
  844. Global Const $lr_vgacolor = 128
  845. Global Const $lr_loadmap3dcolors = 4096
  846. Global Const $lr_createdibsection = 8192
  847. Global Const $lr_copyfromresource = 16384
  848. Global Const $lr_shared = 32768
  849. Global Const $obm_trtype = 32732
  850. Global Const $obm_lfarrowi = 32734
  851. Global Const $obm_rgarrowi = 32735
  852. Global Const $obm_dnarrowi = 32736
  853. Global Const $obm_uparrowi = 32737
  854. Global Const $obm_combo = 32738
  855. Global Const $obm_mnarrow = 32739
  856. Global Const $obm_lfarrowd = 32740
  857. Global Const $obm_rgarrowd = 32741
  858. Global Const $obm_dnarrowd = 32742
  859. Global Const $obm_uparrowd = 32743
  860. Global Const $obm_restored = 32744
  861. Global Const $obm_zoomd = 32745
  862. Global Const $obm_reduced = 32746
  863. Global Const $obm_restore = 32747
  864. Global Const $obm_zoom = 32748
  865. Global Const $obm_reduce = 32749
  866. Global Const $obm_lfarrow = 32750
  867. Global Const $obm_rgarrow = 32751
  868. Global Const $obm_dnarrow = 32752
  869. Global Const $obm_uparrow = 32753
  870. Global Const $obm_close = 32754
  871. Global Const $obm_old_restore = 32755
  872. Global Const $obm_old_zoom = 32756
  873. Global Const $obm_old_reduce = 32757
  874. Global Const $obm_btncorners = 32758
  875. Global Const $obm_checkboxes = 32759
  876. Global Const $obm_check = 32760
  877. Global Const $obm_btsize = 32761
  878. Global Const $obm_old_lfarrow = 32762
  879. Global Const $obm_old_rgarrow = 32763
  880. Global Const $obm_old_dnarrow = 32764
  881. Global Const $obm_old_uparrow = 32765
  882. Global Const $obm_size = 32766
  883. Global Const $obm_old_close = 32767
  884. Global Const $oic_sample = 32512
  885. Global Const $oic_hand = 32513
  886. Global Const $oic_ques = 32514
  887. Global Const $oic_bang = 32515
  888. Global Const $oic_note = 32516
  889. Global Const $oic_winlogo = 32517
  890. Global Const $oic_warning = $oic_bang
  891. Global Const $oic_error = $oic_hand
  892. Global Const $oic_information = $oic_note
  893.  
  894. Func _sendmessage($hwnd, $imsg, $wparam = 0, $lparam = 0, $ireturn = 0, $wparamtype = "wparam", $lparamtype = "lparam", $sreturntype = "lresult")
  895.     Local $aresult = DllCall("user32.dll", $sreturntype, "SendMessageW", "hwnd", $hwnd, "uint", $imsg, $wparamtype, $wparam, $lparamtype, $lparam)
  896.     If @error Then Return SetError(@error, @extended, "")
  897.     If $ireturn >= 0 AND $ireturn <= 4 Then Return $aresult[$ireturn]
  898.     Return $aresult
  899. EndFunc
  900.  
  901. Func _sendmessagea($hwnd, $imsg, $wparam = 0, $lparam = 0, $ireturn = 0, $wparamtype = "wparam", $lparamtype = "lparam", $sreturntype = "lresult")
  902.     Local $aresult = DllCall("user32.dll", $sreturntype, "SendMessageA", "hwnd", $hwnd, "uint", $imsg, $wparamtype, $wparam, $lparamtype, $lparam)
  903.     If @error Then Return SetError(@error, @extended, "")
  904.     If $ireturn >= 0 AND $ireturn <= 4 Then Return $aresult[$ireturn]
  905.     Return $aresult
  906. EndFunc
  907.  
  908. Global $__gainprocess_winapi[64][2] = [[0, 0]]
  909. Global $__gawinlist_winapi[64][2] = [[0, 0]]
  910. Global Const $__winapiconstant_wm_setfont = 48
  911. Global Const $__winapiconstant_fw_normal = 400
  912. Global Const $__winapiconstant_default_charset = 1
  913. Global Const $__winapiconstant_out_default_precis = 0
  914. Global Const $__winapiconstant_clip_default_precis = 0
  915. Global Const $__winapiconstant_default_quality = 0
  916. Global Const $__winapiconstant_logpixelsx = 88
  917. Global Const $__winapiconstant_logpixelsy = 90
  918. Global Const $tagcursorinfo = "dword Size;dword Flags;handle hCursor;" & $tagpoint
  919. Global Const $tagdisplay_device = "dword Size;wchar Name[32];wchar String[128];dword Flags;wchar ID[128];wchar Key[128]"
  920. Global Const $tagflashwinfo = "uint Size;hwnd hWnd;dword Flags;uint Count;dword TimeOut"
  921. Global Const $tagiconinfo = "bool Icon;dword XHotSpot;dword YHotSpot;handle hMask;handle hColor"
  922. Global Const $tagmemorystatusex = "dword Length;dword MemoryLoad;" & "uint64 TotalPhys;uint64 AvailPhys;uint64 TotalPageFile;uint64 AvailPageFile;" & "uint64 TotalVirtual;uint64 AvailVirtual;uint64 AvailExtendedVirtual"
  923.  
  924. Func _winapi_attachconsole($iprocessid = -1)
  925.     Local $aresult = DllCall("kernel32.dll", "bool", "AttachConsole", "dword", $iprocessid)
  926.     If @error Then Return SetError(@error, @extended, False)
  927.     Return $aresult[0]
  928. EndFunc
  929.  
  930. Func _winapi_attachthreadinput($iattach, $iattachto, $fattach)
  931.     Local $aresult = DllCall("user32.dll", "bool", "AttachThreadInput", "dword", $iattach, "dword", $iattachto, "bool", $fattach)
  932.     If @error Then Return SetError(@error, @extended, False)
  933.     Return $aresult[0]
  934. EndFunc
  935.  
  936. Func _winapi_beep($ifreq = 500, $iduration = 1000)
  937.     Local $aresult = DllCall("kernel32.dll", "bool", "Beep", "dword", $ifreq, "dword", $iduration)
  938.     If @error Then Return SetError(@error, @extended, False)
  939.     Return $aresult[0]
  940. EndFunc
  941.  
  942. Func _winapi_bitblt($hdestdc, $ixdest, $iydest, $iwidth, $iheight, $hsrcdc, $ixsrc, $iysrc, $irop)
  943.     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)
  944.     If @error Then Return SetError(@error, @extended, False)
  945.     Return $aresult[0]
  946. EndFunc
  947.  
  948. Func _winapi_callnexthookex($hhk, $icode, $wparam, $lparam)
  949.     Local $aresult = DllCall("user32.dll", "lresult", "CallNextHookEx", "handle", $hhk, "int", $icode, "wparam", $wparam, "lparam", $lparam)
  950.     If @error Then Return SetError(@error, @extended, -1)
  951.     Return $aresult[0]
  952. EndFunc
  953.  
  954. Func _winapi_callwindowproc($lpprevwndfunc, $hwnd, $msg, $wparam, $lparam)
  955.     Local $aresult = DllCall("user32.dll", "lresult", "CallWindowProc", "ptr", $lpprevwndfunc, "hwnd", $hwnd, "uint", $msg, "wparam", $wparam, "lparam", $lparam)
  956.     If @error Then Return SetError(@error, @extended, -1)
  957.     Return $aresult[0]
  958. EndFunc
  959.  
  960. Func _winapi_clienttoscreen($hwnd, ByRef $tpoint)
  961.     Local $aret = DllCall("user32.dll", "bool", "ClientToScreen", "hwnd", $hwnd, "struct*", $tpoint)
  962.     If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  963.     Return $tpoint
  964. EndFunc
  965.  
  966. Func _winapi_closehandle($hobject)
  967.     Local $aresult = DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hobject)
  968.     If @error Then Return SetError(@error, @extended, False)
  969.     Return $aresult[0]
  970. EndFunc
  971.  
  972. Func _winapi_combinergn($hrgndest, $hrgnsrc1, $hrgnsrc2, $icombinemode)
  973.     Local $aresult = DllCall("gdi32.dll", "int", "CombineRgn", "handle", $hrgndest, "handle", $hrgnsrc1, "handle", $hrgnsrc2, "int", $icombinemode)
  974.     If @error Then Return SetError(@error, @extended, 0)
  975.     Return $aresult[0]
  976. EndFunc
  977.  
  978. Func _winapi_commdlgextendederror()
  979.     Local Const $cderr_dialogfailure = 65535
  980.     Local Const $cderr_findresfailure = 6
  981.     Local Const $cderr_initialization = 2
  982.     Local Const $cderr_loadresfailure = 7
  983.     Local Const $cderr_loadstrfailure = 5
  984.     Local Const $cderr_lockresfailure = 8
  985.     Local Const $cderr_memallocfailure = 9
  986.     Local Const $cderr_memlockfailure = 10
  987.     Local Const $cderr_nohinstance = 4
  988.     Local Const $cderr_nohook = 11
  989.     Local Const $cderr_notemplate = 3
  990.     Local Const $cderr_registermsgfail = 12
  991.     Local Const $cderr_structsize = 1
  992.     Local Const $fnerr_buffertoosmall = 12291
  993.     Local Const $fnerr_invalidfilename = 12290
  994.     Local Const $fnerr_subclassfailure = 12289
  995.     Local $aresult = DllCall("comdlg32.dll", "dword", "CommDlgExtendedError")
  996.     If NOT @error Then
  997.         Switch $aresult[0]
  998.             Case $cderr_dialogfailure
  999.                 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.")
  1000.             Case $cderr_findresfailure
  1001.                 Return SetError($aresult[0], 0, "The common dialog box function failed to find a specified resource.")
  1002.             Case $cderr_initialization
  1003.                 Return SetError($aresult[0], 0, "The common dialog box function failed during initialization." & @LF & "This error often occurs when sufficient memory is not available.")
  1004.             Case $cderr_loadresfailure
  1005.                 Return SetError($aresult[0], 0, "The common dialog box function failed to load a specified resource.")
  1006.             Case $cderr_loadstrfailure
  1007.                 Return SetError($aresult[0], 0, "The common dialog box function failed to load a specified string.")
  1008.             Case $cderr_lockresfailure
  1009.                 Return SetError($aresult[0], 0, "The common dialog box function failed to lock a specified resource.")
  1010.             Case $cderr_memallocfailure
  1011.                 Return SetError($aresult[0], 0, "The common dialog box function was unable to allocate memory for internal structures.")
  1012.             Case $cderr_memlockfailure
  1013.                 Return SetError($aresult[0], 0, "The common dialog box function was unable to lock the memory associated with a handle.")
  1014.             Case $cderr_nohinstance
  1015.                 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.")
  1016.             Case $cderr_nohook
  1017.                 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.")
  1018.             Case $cderr_notemplate
  1019.                 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.")
  1020.             Case $cderr_registermsgfail
  1021.                 Return SetError($aresult[0], 0, "The RegisterWindowMessage function returned an error code when it was called by the common dialog box function.")
  1022.             Case $cderr_structsize
  1023.                 Return SetError($aresult[0], 0, "The lStructSize member of the initialization structure for the corresponding common dialog box is invalid")
  1024.             Case $fnerr_buffertoosmall
  1025.                 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.")
  1026.             Case $fnerr_invalidfilename
  1027.                 Return SetError($aresult[0], 0, "A file name is invalid.")
  1028.             Case $fnerr_subclassfailure
  1029.                 Return SetError($aresult[0], 0, "An attempt to subclass a list box failed because sufficient memory was not available.")
  1030.         EndSwitch
  1031.     EndIf
  1032.     Return SetError(@error, @extended, "0x" & Hex($aresult[0]))
  1033. EndFunc
  1034.  
  1035. Func _winapi_copyicon($hicon)
  1036.     Local $aresult = DllCall("user32.dll", "handle", "CopyIcon", "handle", $hicon)
  1037.     If @error Then Return SetError(@error, @extended, 0)
  1038.     Return $aresult[0]
  1039. EndFunc
  1040.  
  1041. Func _winapi_createbitmap($iwidth, $iheight, $iplanes = 1, $ibitsperpel = 1, $pbits = 0)
  1042.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateBitmap", "int", $iwidth, "int", $iheight, "uint", $iplanes, "uint", $ibitsperpel, "ptr", $pbits)
  1043.     If @error Then Return SetError(@error, @extended, 0)
  1044.     Return $aresult[0]
  1045. EndFunc
  1046.  
  1047. Func _winapi_createcompatiblebitmap($hdc, $iwidth, $iheight)
  1048.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateCompatibleBitmap", "handle", $hdc, "int", $iwidth, "int", $iheight)
  1049.     If @error Then Return SetError(@error, @extended, 0)
  1050.     Return $aresult[0]
  1051. EndFunc
  1052.  
  1053. Func _winapi_createcompatibledc($hdc)
  1054.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateCompatibleDC", "handle", $hdc)
  1055.     If @error Then Return SetError(@error, @extended, 0)
  1056.     Return $aresult[0]
  1057. EndFunc
  1058.  
  1059. Func _winapi_createevent($pattributes = 0, $fmanualreset = True, $finitialstate = True, $sname = "")
  1060.     Local $snametype = "wstr"
  1061.     If $sname = "" Then
  1062.         $sname = 0
  1063.         $snametype = "ptr"
  1064.     EndIf
  1065.     Local $aresult = DllCall("kernel32.dll", "handle", "CreateEventW", "ptr", $pattributes, "bool", $fmanualreset, "bool", $finitialstate, $snametype, $sname)
  1066.     If @error Then Return SetError(@error, @extended, 0)
  1067.     Return $aresult[0]
  1068. EndFunc
  1069.  
  1070. Func _winapi_createfile($sfilename, $icreation, $iaccess = 4, $ishare = 0, $iattributes = 0, $psecurity = 0)
  1071.     Local $ida = 0, $ism = 0, $icd = 0, $ifa = 0
  1072.     If BitAND($iaccess, 1) <> 0 Then $ida = BitOR($ida, $generic_execute)
  1073.     If BitAND($iaccess, 2) <> 0 Then $ida = BitOR($ida, $generic_read)
  1074.     If BitAND($iaccess, 4) <> 0 Then $ida = BitOR($ida, $generic_write)
  1075.     If BitAND($ishare, 1) <> 0 Then $ism = BitOR($ism, $file_share_delete)
  1076.     If BitAND($ishare, 2) <> 0 Then $ism = BitOR($ism, $file_share_read)
  1077.     If BitAND($ishare, 4) <> 0 Then $ism = BitOR($ism, $file_share_write)
  1078.     Switch $icreation
  1079.         Case 0
  1080.             $icd = $create_new
  1081.         Case 1
  1082.             $icd = $create_always
  1083.         Case 2
  1084.             $icd = $open_existing
  1085.         Case 3
  1086.             $icd = $open_always
  1087.         Case 4
  1088.             $icd = $truncate_existing
  1089.     EndSwitch
  1090.     If BitAND($iattributes, 1) <> 0 Then $ifa = BitOR($ifa, $file_attribute_archive)
  1091.     If BitAND($iattributes, 2) <> 0 Then $ifa = BitOR($ifa, $file_attribute_hidden)
  1092.     If BitAND($iattributes, 4) <> 0 Then $ifa = BitOR($ifa, $file_attribute_readonly)
  1093.     If BitAND($iattributes, 8) <> 0 Then $ifa = BitOR($ifa, $file_attribute_system)
  1094.     Local $aresult = DllCall("kernel32.dll", "handle", "CreateFileW", "wstr", $sfilename, "dword", $ida, "dword", $ism, "ptr", $psecurity, "dword", $icd, "dword", $ifa, "ptr", 0)
  1095.     If @error OR ($aresult[0] = $invalid_handle_value) Then Return SetError(@error, @extended, 0)
  1096.     Return $aresult[0]
  1097. EndFunc
  1098.  
  1099. 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")
  1100.     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)
  1101.     If @error Then Return SetError(@error, @extended, 0)
  1102.     Return $aresult[0]
  1103. EndFunc
  1104.  
  1105. Func _winapi_createfontindirect($tlogfont)
  1106.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateFontIndirectW", "struct*", $tlogfont)
  1107.     If @error Then Return SetError(@error, @extended, 0)
  1108.     Return $aresult[0]
  1109. EndFunc
  1110.  
  1111. Func _winapi_createpen($ipenstyle, $iwidth, $ncolor)
  1112.     Local $aresult = DllCall("gdi32.dll", "handle", "CreatePen", "int", $ipenstyle, "int", $iwidth, "INT", $ncolor)
  1113.     If @error Then Return SetError(@error, @extended, 0)
  1114.     Return $aresult[0]
  1115. EndFunc
  1116.  
  1117. Func _winapi_createprocess($sappname, $scommand, $psecurity, $pthread, $finherit, $iflags, $penviron, $sdir, $pstartupinfo, $pprocess)
  1118.     Local $tcommand = 0
  1119.     Local $sappnametype = "wstr", $sdirtype = "wstr"
  1120.     If $sappname = "" Then
  1121.         $sappnametype = "ptr"
  1122.         $sappname = 0
  1123.     EndIf
  1124.     If $scommand <> "" Then
  1125.         $tcommand = DllStructCreate("wchar Text[" & 260 + 1 & "]")
  1126.         DllStructSetData($tcommand, "Text", $scommand)
  1127.     EndIf
  1128.     If $sdir = "" Then
  1129.         $sdirtype = "ptr"
  1130.         $sdir = 0
  1131.     EndIf
  1132.     Local $aresult = DllCall("kernel32.dll", "bool", "CreateProcessW", $sappnametype, $sappname, "struct*", $tcommand, "ptr", $psecurity, "ptr", $pthread, "bool", $finherit, "dword", $iflags, "ptr", $penviron, $sdirtype, $sdir, "ptr", $pstartupinfo, "ptr", $pprocess)
  1133.     If @error Then Return SetError(@error, @extended, False)
  1134.     Return $aresult[0]
  1135. EndFunc
  1136.  
  1137. Func _winapi_createrectrgn($ileftrect, $itoprect, $irightrect, $ibottomrect)
  1138.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateRectRgn", "int", $ileftrect, "int", $itoprect, "int", $irightrect, "int", $ibottomrect)
  1139.     If @error Then Return SetError(@error, @extended, 0)
  1140.     Return $aresult[0]
  1141. EndFunc
  1142.  
  1143. Func _winapi_createroundrectrgn($ileftrect, $itoprect, $irightrect, $ibottomrect, $iwidthellipse, $iheightellipse)
  1144.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateRoundRectRgn", "int", $ileftrect, "int", $itoprect, "int", $irightrect, "int", $ibottomrect, "int", $iwidthellipse, "int", $iheightellipse)
  1145.     If @error Then Return SetError(@error, @extended, 0)
  1146.     Return $aresult[0]
  1147. EndFunc
  1148.  
  1149. Func _winapi_createsolidbitmap($hwnd, $icolor, $iwidth, $iheight, $brgb = 1)
  1150.     Local $hdc = _winapi_getdc($hwnd)
  1151.     Local $hdestdc = _winapi_createcompatibledc($hdc)
  1152.     Local $hbitmap = _winapi_createcompatiblebitmap($hdc, $iwidth, $iheight)
  1153.     Local $hold = _winapi_selectobject($hdestdc, $hbitmap)
  1154.     Local $trect = DllStructCreate($tagrect)
  1155.     DllStructSetData($trect, 1, 0)
  1156.     DllStructSetData($trect, 2, 0)
  1157.     DllStructSetData($trect, 3, $iwidth)
  1158.     DllStructSetData($trect, 4, $iheight)
  1159.     If $brgb Then
  1160.         $icolor = BitOR(BitAND($icolor, 65280), BitShift(BitAND($icolor, 255), -16), BitShift(BitAND($icolor, 16711680), 16))
  1161.     EndIf
  1162.     Local $hbrush = _winapi_createsolidbrush($icolor)
  1163.     If NOT _winapi_fillrect($hdestdc, $trect, $hbrush) Then
  1164.         _winapi_deleteobject($hbitmap)
  1165.         $hbitmap = 0
  1166.     EndIf
  1167.     _winapi_deleteobject($hbrush)
  1168.     _winapi_releasedc($hwnd, $hdc)
  1169.     _winapi_selectobject($hdestdc, $hold)
  1170.     _winapi_deletedc($hdestdc)
  1171.     If NOT $hbitmap Then Return SetError(1, 0, 0)
  1172.     Return $hbitmap
  1173. EndFunc
  1174.  
  1175. Func _winapi_createsolidbrush($ncolor)
  1176.     Local $aresult = DllCall("gdi32.dll", "handle", "CreateSolidBrush", "INT", $ncolor)
  1177.     If @error Then Return SetError(@error, @extended, 0)
  1178.     Return $aresult[0]
  1179. EndFunc
  1180.  
  1181. Func _winapi_createwindowex($iexstyle, $sclass, $sname, $istyle, $ix, $iy, $iwidth, $iheight, $hparent, $hmenu = 0, $hinstance = 0, $pparam = 0)
  1182.     If $hinstance = 0 Then $hinstance = _winapi_getmodulehandle("")
  1183.     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)
  1184.     If @error Then Return SetError(@error, @extended, 0)
  1185.     Return $aresult[0]
  1186. EndFunc
  1187.  
  1188. Func _winapi_defwindowproc($hwnd, $imsg, $iwparam, $ilparam)
  1189.     Local $aresult = DllCall("user32.dll", "lresult", "DefWindowProc", "hwnd", $hwnd, "uint", $imsg, "wparam", $iwparam, "lparam", $ilparam)
  1190.     If @error Then Return SetError(@error, @extended, 0)
  1191.     Return $aresult[0]
  1192. EndFunc
  1193.  
  1194. Func _winapi_deletedc($hdc)
  1195.     Local $aresult = DllCall("gdi32.dll", "bool", "DeleteDC", "handle", $hdc)
  1196.     If @error Then Return SetError(@error, @extended, False)
  1197.     Return $aresult[0]
  1198. EndFunc
  1199.  
  1200. Func _winapi_deleteobject($hobject)
  1201.     Local $aresult = DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hobject)
  1202.     If @error Then Return SetError(@error, @extended, False)
  1203.     Return $aresult[0]
  1204. EndFunc
  1205.  
  1206. Func _winapi_destroyicon($hicon)
  1207.     Local $aresult = DllCall("user32.dll", "bool", "DestroyIcon", "handle", $hicon)
  1208.     If @error Then Return SetError(@error, @extended, False)
  1209.     Return $aresult[0]
  1210. EndFunc
  1211.  
  1212. Func _winapi_destroywindow($hwnd)
  1213.     Local $aresult = DllCall("user32.dll", "bool", "DestroyWindow", "hwnd", $hwnd)
  1214.     If @error Then Return SetError(@error, @extended, False)
  1215.     Return $aresult[0]
  1216. EndFunc
  1217.  
  1218. Func _winapi_drawedge($hdc, $ptrrect, $nedgetype, $grfflags)
  1219.     Local $aresult = DllCall("user32.dll", "bool", "DrawEdge", "handle", $hdc, "ptr", $ptrrect, "uint", $nedgetype, "uint", $grfflags)
  1220.     If @error Then Return SetError(@error, @extended, False)
  1221.     Return $aresult[0]
  1222. EndFunc
  1223.  
  1224. Func _winapi_drawframecontrol($hdc, $ptrrect, $ntype, $nstate)
  1225.     Local $aresult = DllCall("user32.dll", "bool", "DrawFrameControl", "handle", $hdc, "ptr", $ptrrect, "uint", $ntype, "uint", $nstate)
  1226.     If @error Then Return SetError(@error, @extended, False)
  1227.     Return $aresult[0]
  1228. EndFunc
  1229.  
  1230. Func _winapi_drawicon($hdc, $ix, $iy, $hicon)
  1231.     Local $aresult = DllCall("user32.dll", "bool", "DrawIcon", "handle", $hdc, "int", $ix, "int", $iy, "handle", $hicon)
  1232.     If @error Then Return SetError(@error, @extended, False)
  1233.     Return $aresult[0]
  1234. EndFunc
  1235.  
  1236. Func _winapi_drawiconex($hdc, $ix, $iy, $hicon, $iwidth = 0, $iheight = 0, $istep = 0, $hbrush = 0, $iflags = 3)
  1237.     Local $ioptions
  1238.     Switch $iflags
  1239.         Case 1
  1240.             $ioptions = $di_mask
  1241.         Case 2
  1242.             $ioptions = $di_image
  1243.         Case 3
  1244.             $ioptions = $di_normal
  1245.         Case 4
  1246.             $ioptions = $di_compat
  1247.         Case 5
  1248.             $ioptions = $di_defaultsize
  1249.         Case Else
  1250.             $ioptions = $di_nomirror
  1251.     EndSwitch
  1252.     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)
  1253.     If @error Then Return SetError(@error, @extended, False)
  1254.     Return $aresult[0]
  1255. EndFunc
  1256.  
  1257. Func _winapi_drawline($hdc, $ix1, $iy1, $ix2, $iy2)
  1258.     _winapi_moveto($hdc, $ix1, $iy1)
  1259.     If @error Then Return SetError(@error, @extended, False)
  1260.     _winapi_lineto($hdc, $ix2, $iy2)
  1261.     If @error Then Return SetError(@error + 10, @extended, False)
  1262.     Return True
  1263. EndFunc
  1264.  
  1265. Func _winapi_drawtext($hdc, $stext, ByRef $trect, $iflags)
  1266.     Local $aresult = DllCall("user32.dll", "int", "DrawTextW", "handle", $hdc, "wstr", $stext, "int", -1, "struct*", $trect, "uint", $iflags)
  1267.     If @error Then Return SetError(@error, @extended, 0)
  1268.     Return $aresult[0]
  1269. EndFunc
  1270.  
  1271. Func _winapi_duplicatehandle($hsourceprocesshandle, $hsourcehandle, $htargetprocesshandle, $idesiredaccess, $finherithandle, $ioptions)
  1272.     Local $aresult = DllCall("kernel32.dll", "bool", "DuplicateHandle", "handle", $hsourceprocesshandle, "handle", $hsourcehandle, "handle", $htargetprocesshandle, "handle*", 0, "dword", $idesiredaccess, "bool", $finherithandle, "dword", $ioptions)
  1273.     If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, 0)
  1274.     Return $aresult[4]
  1275. EndFunc
  1276.  
  1277. Func _winapi_enablewindow($hwnd, $fenable = True)
  1278.     Local $aresult = DllCall("user32.dll", "bool", "EnableWindow", "hwnd", $hwnd, "bool", $fenable)
  1279.     If @error Then Return SetError(@error, @extended, False)
  1280.     Return $aresult[0]
  1281. EndFunc
  1282.  
  1283. Func _winapi_enumdisplaydevices($sdevice, $idevnum)
  1284.     Local $tname = 0, $iflags = 0, $adevice[5]
  1285.     If $sdevice <> "" Then
  1286.         $tname = DllStructCreate("wchar Text[" & StringLen($sdevice) + 1 & "]")
  1287.         DllStructSetData($tname, "Text", $sdevice)
  1288.     EndIf
  1289.     Local $tdevice = DllStructCreate($tagdisplay_device)
  1290.     Local $idevice = DllStructGetSize($tdevice)
  1291.     DllStructSetData($tdevice, "Size", $idevice)
  1292.     Local $aret = DllCall("user32.dll", "bool", "EnumDisplayDevicesW", "struct*", $tname, "dword", $idevnum, "struct*", $tdevice, "dword", 1)
  1293.     If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  1294.     Local $in = DllStructGetData($tdevice, "Flags")
  1295.     If BitAND($in, $display_device_attached_to_desktop) <> 0 Then $iflags = BitOR($iflags, 1)
  1296.     If BitAND($in, $display_device_primary_device) <> 0 Then $iflags = BitOR($iflags, 2)
  1297.     If BitAND($in, $display_device_mirroring_driver) <> 0 Then $iflags = BitOR($iflags, 4)
  1298.     If BitAND($in, $display_device_vga_compatible) <> 0 Then $iflags = BitOR($iflags, 8)
  1299.     If BitAND($in, $display_device_removable) <> 0 Then $iflags = BitOR($iflags, 16)
  1300.     If BitAND($in, $display_device_modespruned) <> 0 Then $iflags = BitOR($iflags, 32)
  1301.     $adevice[0] = True
  1302.     $adevice[1] = DllStructGetData($tdevice, "Name")
  1303.     $adevice[2] = DllStructGetData($tdevice, "String")
  1304.     $adevice[3] = $iflags
  1305.     $adevice[4] = DllStructGetData($tdevice, "ID")
  1306.     Return $adevice
  1307. EndFunc
  1308.  
  1309. Func _winapi_enumwindows($fvisible = True, $hwnd = Default)
  1310.     __winapi_enumwindowsinit()
  1311.     If $hwnd = Default Then $hwnd = _winapi_getdesktopwindow()
  1312.     __winapi_enumwindowschild($hwnd, $fvisible)
  1313.     Return $__gawinlist_winapi
  1314. EndFunc
  1315.  
  1316. Func __winapi_enumwindowsadd($hwnd, $sclass = "")
  1317.     If $sclass = "" Then $sclass = _winapi_getclassname($hwnd)
  1318.     $__gawinlist_winapi[0][0] += 1
  1319.     Local $icount = $__gawinlist_winapi[0][0]
  1320.     If $icount >= $__gawinlist_winapi[0][1] Then
  1321.         ReDim $__gawinlist_winapi[$icount + 64][2]
  1322.         $__gawinlist_winapi[0][1] += 64
  1323.     EndIf
  1324.     $__gawinlist_winapi[$icount][0] = $hwnd
  1325.     $__gawinlist_winapi[$icount][1] = $sclass
  1326. EndFunc
  1327.  
  1328. Func __winapi_enumwindowschild($hwnd, $fvisible = True)
  1329.     $hwnd = _winapi_getwindow($hwnd, $gw_child)
  1330.     While $hwnd <> 0
  1331.         If (NOT $fvisible) OR _winapi_iswindowvisible($hwnd) Then
  1332.             __winapi_enumwindowsadd($hwnd)
  1333.             __winapi_enumwindowschild($hwnd, $fvisible)
  1334.         EndIf
  1335.         $hwnd = _winapi_getwindow($hwnd, $gw_hwndnext)
  1336.     WEnd
  1337. EndFunc
  1338.  
  1339. Func __winapi_enumwindowsinit()
  1340.     ReDim $__gawinlist_winapi[64][2]
  1341.     $__gawinlist_winapi[0][0] = 0
  1342.     $__gawinlist_winapi[0][1] = 64
  1343. EndFunc
  1344.  
  1345. Func _winapi_enumwindowspopup()
  1346.     __winapi_enumwindowsinit()
  1347.     Local $hwnd = _winapi_getwindow(_winapi_getdesktopwindow(), $gw_child)
  1348.     Local $sclass
  1349.     While $hwnd <> 0
  1350.         If _winapi_iswindowvisible($hwnd) Then
  1351.             $sclass = _winapi_getclassname($hwnd)
  1352.             If $sclass = "#32768" Then
  1353.                 __winapi_enumwindowsadd($hwnd)
  1354.             ElseIf $sclass = "ToolbarWindow32" Then
  1355.                 __winapi_enumwindowsadd($hwnd)
  1356.             ElseIf $sclass = "ToolTips_Class32" Then
  1357.                 __winapi_enumwindowsadd($hwnd)
  1358.             ElseIf $sclass = "BaseBar" Then
  1359.                 __winapi_enumwindowschild($hwnd)
  1360.             EndIf
  1361.         EndIf
  1362.         $hwnd = _winapi_getwindow($hwnd, $gw_hwndnext)
  1363.     WEnd
  1364.     Return $__gawinlist_winapi
  1365. EndFunc
  1366.  
  1367. Func _winapi_enumwindowstop()
  1368.     __winapi_enumwindowsinit()
  1369.     Local $hwnd = _winapi_getwindow(_winapi_getdesktopwindow(), $gw_child)
  1370.     While $hwnd <> 0
  1371.         If _winapi_iswindowvisible($hwnd) Then __winapi_enumwindowsadd($hwnd)
  1372.         $hwnd = _winapi_getwindow($hwnd, $gw_hwndnext)
  1373.     WEnd
  1374.     Return $__gawinlist_winapi
  1375. EndFunc
  1376.  
  1377. Func _winapi_expandenvironmentstrings($sstring)
  1378.     Local $aresult = DllCall("kernel32.dll", "dword", "ExpandEnvironmentStringsW", "wstr", $sstring, "wstr", "", "dword", 4096)
  1379.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
  1380.     Return $aresult[2]
  1381. EndFunc
  1382.  
  1383. Func _winapi_extracticonex($sfile, $iindex, $plarge, $psmall, $iicons)
  1384.     Local $aresult = DllCall("shell32.dll", "uint", "ExtractIconExW", "wstr", $sfile, "int", $iindex, "struct*", $plarge, "struct*", $psmall, "uint", $iicons)
  1385.     If @error Then Return SetError(@error, @extended, 0)
  1386.     Return $aresult[0]
  1387. EndFunc
  1388.  
  1389. Func _winapi_fatalappexit($smessage)
  1390.     DllCall("kernel32.dll", "none", "FatalAppExitW", "uint", 0, "wstr", $smessage)
  1391.     If @error Then Return SetError(@error, @extended)
  1392. EndFunc
  1393.  
  1394. Func _winapi_fillrect($hdc, $ptrrect, $hbrush)
  1395.     Local $aresult
  1396.     If IsPtr($hbrush) Then
  1397.         $aresult = DllCall("user32.dll", "int", "FillRect", "handle", $hdc, "struct*", $ptrrect, "handle", $hbrush)
  1398.     Else
  1399.         $aresult = DllCall("user32.dll", "int", "FillRect", "handle", $hdc, "struct*", $ptrrect, "dword_ptr", $hbrush)
  1400.     EndIf
  1401.     If @error Then Return SetError(@error, @extended, False)
  1402.     Return $aresult[0]
  1403. EndFunc
  1404.  
  1405. Func _winapi_findexecutable($sfilename, $sdirectory = "")
  1406.     Local $aresult = DllCall("shell32.dll", "INT", "FindExecutableW", "wstr", $sfilename, "wstr", $sdirectory, "wstr", "")
  1407.     If @error Then Return SetError(@error, @extended, "")
  1408.     If $aresult[0] <= 32 Then Return SetError(10, $aresult[0], "")
  1409.     Return SetExtended($aresult[0], $aresult[3])
  1410. EndFunc
  1411.  
  1412. Func _winapi_findwindow($sclassname, $swindowname)
  1413.     Local $aresult = DllCall("user32.dll", "hwnd", "FindWindowW", "wstr", $sclassname, "wstr", $swindowname)
  1414.     If @error Then Return SetError(@error, @extended, 0)
  1415.     Return $aresult[0]
  1416. EndFunc
  1417.  
  1418. Func _winapi_flashwindow($hwnd, $finvert = True)
  1419.     Local $aresult = DllCall("user32.dll", "bool", "FlashWindow", "hwnd", $hwnd, "bool", $finvert)
  1420.     If @error Then Return SetError(@error, @extended, False)
  1421.     Return $aresult[0]
  1422. EndFunc
  1423.  
  1424. Func _winapi_flashwindowex($hwnd, $iflags = 3, $icount = 3, $itimeout = 0)
  1425.     Local $tflash = DllStructCreate($tagflashwinfo)
  1426.     Local $iflash = DllStructGetSize($tflash)
  1427.     Local $imode = 0
  1428.     If BitAND($iflags, 1) <> 0 Then $imode = BitOR($imode, $flashw_caption)
  1429.     If BitAND($iflags, 2) <> 0 Then $imode = BitOR($imode, $flashw_tray)
  1430.     If BitAND($iflags, 4) <> 0 Then $imode = BitOR($imode, $flashw_timer)
  1431.     If BitAND($iflags, 8) <> 0 Then $imode = BitOR($imode, $flashw_timernofg)
  1432.     DllStructSetData($tflash, "Size", $iflash)
  1433.     DllStructSetData($tflash, "hWnd", $hwnd)
  1434.     DllStructSetData($tflash, "Flags", $imode)
  1435.     DllStructSetData($tflash, "Count", $icount)
  1436.     DllStructSetData($tflash, "Timeout", $itimeout)
  1437.     Local $aresult = DllCall("user32.dll", "bool", "FlashWindowEx", "struct*", $tflash)
  1438.     If @error Then Return SetError(@error, @extended, False)
  1439.     Return $aresult[0]
  1440. EndFunc
  1441.  
  1442. Func _winapi_floattoint($nfloat)
  1443.     Local $tfloat = DllStructCreate("float")
  1444.     Local $tint = DllStructCreate("int", DllStructGetPtr($tfloat))
  1445.     DllStructSetData($tfloat, 1, $nfloat)
  1446.     Return DllStructGetData($tint, 1)
  1447. EndFunc
  1448.  
  1449. Func _winapi_flushfilebuffers($hfile)
  1450.     Local $aresult = DllCall("kernel32.dll", "bool", "FlushFileBuffers", "handle", $hfile)
  1451.     If @error Then Return SetError(@error, @extended, False)
  1452.     Return $aresult[0]
  1453. EndFunc
  1454.  
  1455. Func _winapi_formatmessage($iflags, $psource, $imessageid, $ilanguageid, ByRef $pbuffer, $isize, $varguments)
  1456.     Local $sbuffertype = "struct*"
  1457.     If IsString($pbuffer) Then $sbuffertype = "wstr"
  1458.     Local $aresult = DllCall("Kernel32.dll", "dword", "FormatMessageW", "dword", $iflags, "ptr", $psource, "dword", $imessageid, "dword", $ilanguageid, $sbuffertype, $pbuffer, "dword", $isize, "ptr", $varguments)
  1459.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
  1460.     If $sbuffertype = "wstr" Then $pbuffer = $aresult[5]
  1461.     Return $aresult[0]
  1462. EndFunc
  1463.  
  1464. Func _winapi_framerect($hdc, $ptrrect, $hbrush)
  1465.     Local $aresult = DllCall("user32.dll", "int", "FrameRect", "handle", $hdc, "ptr", $ptrrect, "handle", $hbrush)
  1466.     If @error Then Return SetError(@error, @extended, False)
  1467.     Return $aresult[0]
  1468. EndFunc
  1469.  
  1470. Func _winapi_freelibrary($hmodule)
  1471.     Local $aresult = DllCall("kernel32.dll", "bool", "FreeLibrary", "handle", $hmodule)
  1472.     If @error Then Return SetError(@error, @extended, False)
  1473.     Return $aresult[0]
  1474. EndFunc
  1475.  
  1476. Func _winapi_getancestor($hwnd, $iflags = 1)
  1477.     Local $aresult = DllCall("user32.dll", "hwnd", "GetAncestor", "hwnd", $hwnd, "uint", $iflags)
  1478.     If @error Then Return SetError(@error, @extended, 0)
  1479.     Return $aresult[0]
  1480. EndFunc
  1481.  
  1482. Func _winapi_getasynckeystate($ikey)
  1483.     Local $aresult = DllCall("user32.dll", "short", "GetAsyncKeyState", "int", $ikey)
  1484.     If @error Then Return SetError(@error, @extended, 0)
  1485.     Return $aresult[0]
  1486. EndFunc
  1487.  
  1488. Func _winapi_getbkmode($hdc)
  1489.     Local $aresult = DllCall("gdi32.dll", "int", "GetBkMode", "handle", $hdc)
  1490.     If @error Then Return SetError(@error, @extended, 0)
  1491.     Return $aresult[0]
  1492. EndFunc
  1493.  
  1494. Func _winapi_getclassname($hwnd)
  1495.     If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  1496.     Local $aresult = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $hwnd, "wstr", "", "int", 4096)
  1497.     If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, "")
  1498.     Return SetExtended($aresult[0], $aresult[2])
  1499. EndFunc
  1500.  
  1501. Func _winapi_getclientheight($hwnd)
  1502.     Local $trect = _winapi_getclientrect($hwnd)
  1503.     If @error Then Return SetError(@error, @extended, 0)
  1504.     Return DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top")
  1505. EndFunc
  1506.  
  1507. Func _winapi_getclientwidth($hwnd)
  1508.     Local $trect = _winapi_getclientrect($hwnd)
  1509.     If @error Then Return SetError(@error, @extended, 0)
  1510.     Return DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left")
  1511. EndFunc
  1512.  
  1513. Func _winapi_getclientrect($hwnd)
  1514.     Local $trect = DllStructCreate($tagrect)
  1515.     Local $aret = DllCall("user32.dll", "bool", "GetClientRect", "hwnd", $hwnd, "struct*", $trect)
  1516.     If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  1517.     Return $trect
  1518. EndFunc
  1519.  
  1520. Func _winapi_getcurrentprocess()
  1521.     Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentProcess")
  1522.     If @error Then Return SetError(@error, @extended, 0)
  1523.     Return $aresult[0]
  1524. EndFunc
  1525.  
  1526. Func _winapi_getcurrentprocessid()
  1527.     Local $aresult = DllCall("kernel32.dll", "dword", "GetCurrentProcessId")
  1528.     If @error Then Return SetError(@error, @extended, 0)
  1529.     Return $aresult[0]
  1530. EndFunc
  1531.  
  1532. Func _winapi_getcurrentthread()
  1533.     Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentThread")
  1534.     If @error Then Return SetError(@error, @extended, 0)
  1535.     Return $aresult[0]
  1536. EndFunc
  1537.  
  1538. Func _winapi_getcurrentthreadid()
  1539.     Local $aresult = DllCall("kernel32.dll", "dword", "GetCurrentThreadId")
  1540.     If @error Then Return SetError(@error, @extended, 0)
  1541.     Return $aresult[0]
  1542. EndFunc
  1543.  
  1544. Func _winapi_getcursorinfo()
  1545.     Local $tcursor = DllStructCreate($tagcursorinfo)
  1546.     Local $icursor = DllStructGetSize($tcursor)
  1547.     DllStructSetData($tcursor, "Size", $icursor)
  1548.     Local $aret = DllCall("user32.dll", "bool", "GetCursorInfo", "struct*", $tcursor)
  1549.     If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  1550.     Local $acursor[5]
  1551.     $acursor[0] = True
  1552.     $acursor[1] = DllStructGetData($tcursor, "Flags") <> 0
  1553.     $acursor[2] = DllStructGetData($tcursor, "hCursor")
  1554.     $acursor[3] = DllStructGetData($tcursor, "X")
  1555.     $acursor[4] = DllStructGetData($tcursor, "Y")
  1556.     Return $acursor
  1557. EndFunc
  1558.  
  1559. Func _winapi_getdc($hwnd)
  1560.     Local $aresult = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hwnd)
  1561.     If @error Then Return SetError(@error, @extended, 0)
  1562.     Return $aresult[0]
  1563. EndFunc
  1564.  
  1565. Func _winapi_getdesktopwindow()
  1566.     Local $aresult = DllCall("user32.dll", "hwnd", "GetDesktopWindow")
  1567.     If @error Then Return SetError(@error, @extended, 0)
  1568.     Return $aresult[0]
  1569. EndFunc
  1570.  
  1571. Func _winapi_getdevicecaps($hdc, $iindex)
  1572.     Local $aresult = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hdc, "int", $iindex)
  1573.     If @error Then Return SetError(@error, @extended, 0)
  1574.     Return $aresult[0]
  1575. EndFunc
  1576.  
  1577. Func _winapi_getdibits($hdc, $hbmp, $istartscan, $iscanlines, $pbits, $pbi, $iusage)
  1578.     Local $aresult = DllCall("gdi32.dll", "int", "GetDIBits", "handle", $hdc, "handle", $hbmp, "uint", $istartscan, "uint", $iscanlines, "ptr", $pbits, "ptr", $pbi, "uint", $iusage)
  1579.     If @error Then Return SetError(@error, @extended, False)
  1580.     Return $aresult[0]
  1581. EndFunc
  1582.  
  1583. Func _winapi_getdlgctrlid($hwnd)
  1584.     Local $aresult = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hwnd)
  1585.     If @error Then Return SetError(@error, @extended, 0)
  1586.     Return $aresult[0]
  1587. EndFunc
  1588.  
  1589. Func _winapi_getdlgitem($hwnd, $iitemid)
  1590.     Local $aresult = DllCall("user32.dll", "hwnd", "GetDlgItem", "hwnd", $hwnd, "int", $iitemid)
  1591.     If @error Then Return SetError(@error, @extended, 0)
  1592.     Return $aresult[0]
  1593. EndFunc
  1594.  
  1595. Func _winapi_getfilesizeex($hfile)
  1596.     Local $aresult = DllCall("kernel32.dll", "bool", "GetFileSizeEx", "handle", $hfile, "int64*", 0)
  1597.     If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, -1)
  1598.     Return $aresult[2]
  1599. EndFunc
  1600.  
  1601. Func _winapi_getfocus()
  1602.     Local $aresult = DllCall("user32.dll", "hwnd", "GetFocus")
  1603.     If @error Then Return SetError(@error, @extended, 0)
  1604.     Return $aresult[0]
  1605. EndFunc
  1606.  
  1607. Func _winapi_getforegroundwindow()
  1608.     Local $aresult = DllCall("user32.dll", "hwnd", "GetForegroundWindow")
  1609.     If @error Then Return SetError(@error, @extended, 0)
  1610.     Return $aresult[0]
  1611. EndFunc
  1612.  
  1613. Func _winapi_getguiresources($iflag = 0, $hprocess = -1)
  1614.     If $hprocess = -1 Then $hprocess = _winapi_getcurrentprocess()
  1615.     Local $aresult = DllCall("user32.dll", "dword", "GetGuiResources", "handle", $hprocess, "dword", $iflag)
  1616.     If @error Then Return SetError(@error, @extended, 0)
  1617.     Return $aresult[0]
  1618. EndFunc
  1619.  
  1620. Func _winapi_geticoninfo($hicon)
  1621.     Local $tinfo = DllStructCreate($tagiconinfo)
  1622.     Local $aret = DllCall("user32.dll", "bool", "GetIconInfo", "handle", $hicon, "struct*", $tinfo)
  1623.     If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  1624.     Local $aicon[6]
  1625.     $aicon[0] = True
  1626.     $aicon[1] = DllStructGetData($tinfo, "Icon") <> 0
  1627.     $aicon[2] = DllStructGetData($tinfo, "XHotSpot")
  1628.     $aicon[3] = DllStructGetData($tinfo, "YHotSpot")
  1629.     $aicon[4] = DllStructGetData($tinfo, "hMask")
  1630.     $aicon[5] = DllStructGetData($tinfo, "hColor")
  1631.     Return $aicon
  1632. EndFunc
  1633.  
  1634. Func _winapi_getlasterrormessage()
  1635.     Local $ilasterror = _winapi_getlasterror()
  1636.     Local $tbufferptr = DllStructCreate("ptr")
  1637.     Local $ncount = _winapi_formatmessage(BitOR($format_message_allocate_buffer, $format_message_from_system), 0, $ilasterror, 0, $tbufferptr, 0, 0)
  1638.     If @error Then Return SetError(@error, 0, "")
  1639.     Local $stext = ""
  1640.     Local $pbuffer = DllStructGetData($tbufferptr, 1)
  1641.     If $pbuffer Then
  1642.         If $ncount > 0 Then
  1643.             Local $tbuffer = DllStructCreate("wchar[" & ($ncount + 1) & "]", $pbuffer)
  1644.             $stext = DllStructGetData($tbuffer, 1)
  1645.         EndIf
  1646.         _winapi_localfree($pbuffer)
  1647.     EndIf
  1648.     Return $stext
  1649. EndFunc
  1650.  
  1651. Func _winapi_getlayeredwindowattributes($hwnd, ByRef $i_transcolor, ByRef $transparency, $ascolorref = False)
  1652.     $i_transcolor = -1
  1653.     $transparency = -1
  1654.     Local $aresult = DllCall("user32.dll", "bool", "GetLayeredWindowAttributes", "hwnd", $hwnd, "INT*", $i_transcolor, "byte*", $transparency, "dword*", 0)
  1655.     If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, 0)
  1656.     If NOT $ascolorref Then
  1657.         $aresult[2] = Int(BinaryMid($aresult[2], 3, 1) & BinaryMid($aresult[2], 2, 1) & BinaryMid($aresult[2], 1, 1))
  1658.     EndIf
  1659.     $i_transcolor = $aresult[2]
  1660.     $transparency = $aresult[3]
  1661.     Return $aresult[4]
  1662. EndFunc
  1663.  
  1664. Func _winapi_getmodulehandle($smodulename)
  1665.     Local $smodulenametype = "wstr"
  1666.     If $smodulename = "" Then
  1667.         $smodulename = 0
  1668.         $smodulenametype = "ptr"
  1669.     EndIf
  1670.     Local $aresult = DllCall("kernel32.dll", "handle", "GetModuleHandleW", $smodulenametype, $smodulename)
  1671.     If @error Then Return SetError(@error, @extended, 0)
  1672.     Return $aresult[0]
  1673. EndFunc
  1674.  
  1675. Func _winapi_getmousepos($ftoclient = False, $hwnd = 0)
  1676.     Local $imode = Opt("MouseCoordMode", 1)
  1677.     Local $apos = MouseGetPos()
  1678.     Opt("MouseCoordMode", $imode)
  1679.     Local $tpoint = DllStructCreate($tagpoint)
  1680.     DllStructSetData($tpoint, "X", $apos[0])
  1681.     DllStructSetData($tpoint, "Y", $apos[1])
  1682.     If $ftoclient AND NOT _winapi_screentoclient($hwnd, $tpoint) Then Return SetError(@error + 20, @extended, 0)
  1683.     Return $tpoint
  1684. EndFunc
  1685.  
  1686. Func _winapi_getmouseposx($ftoclient = False, $hwnd = 0)
  1687.     Local $tpoint = _winapi_getmousepos($ftoclient, $hwnd)
  1688.     If @error Then Return SetError(@error, @extended, 0)
  1689.     Return DllStructGetData($tpoint, "X")
  1690. EndFunc
  1691.  
  1692. Func _winapi_getmouseposy($ftoclient = False, $hwnd = 0)
  1693.     Local $tpoint = _winapi_getmousepos($ftoclient, $hwnd)
  1694.     If @error Then Return SetError(@error, @extended, 0)
  1695.     Return DllStructGetData($tpoint, "Y")
  1696. EndFunc
  1697.  
  1698. Func _winapi_getobject($hobject, $isize, $pobject)
  1699.     Local $aresult = DllCall("gdi32.dll", "int", "GetObjectW", "handle", $hobject, "int", $isize, "ptr", $pobject)
  1700.     If @error Then Return SetError(@error, @extended, 0)
  1701.     Return $aresult[0]
  1702. EndFunc
  1703.  
  1704. Func _winapi_getopenfilename($stitle = "", $sfilter = "All files (*.*)", $sinitaldir = ".", $sdefaultfile = "", $sdefaultext = "", $ifilterindex = 1, $iflags = 0, $iflagsex = 0, $hwndowner = 0)
  1705.     Local $ipathlen = 4096
  1706.     Local $inulls = 0
  1707.     Local $tofn = DllStructCreate($tagopenfilename)
  1708.     Local $afiles[1] = [0]
  1709.     Local $iflag = $iflags
  1710.     Local $asflines = StringSplit($sfilter, "|")
  1711.     Local $asfilter[$asflines[0] * 2 + 1]
  1712.     Local $istart, $ifinal, $stfilter
  1713.     $asfilter[0] = $asflines[0] * 2
  1714.     For $i = 1 To $asflines[0]
  1715.         $istart = StringInStr($asflines[$i], "(", 0, 1)
  1716.         $ifinal = StringInStr($asflines[$i], ")", 0, -1)
  1717.         $asfilter[$i * 2 - 1] = StringStripWS(StringLeft($asflines[$i], $istart - 1), 3)
  1718.         $asfilter[$i * 2] = StringStripWS(StringTrimRight(StringTrimLeft($asflines[$i], $istart), StringLen($asflines[$i]) - $ifinal + 1), 3)
  1719.         $stfilter &= "wchar[" & StringLen($asfilter[$i * 2 - 1]) + 1 & "];wchar[" & StringLen($asfilter[$i * 2]) + 1 & "];"
  1720.     Next
  1721.     Local $ttitle = DllStructCreate("wchar Title[" & StringLen($stitle) + 1 & "]")
  1722.     Local $tinitialdir = DllStructCreate("wchar InitDir[" & StringLen($sinitaldir) + 1 & "]")
  1723.     Local $tfilter = DllStructCreate($stfilter & "wchar")
  1724.     Local $tpath = DllStructCreate("wchar Path[" & $ipathlen & "]")
  1725.     Local $textn = DllStructCreate("wchar Extension[" & StringLen($sdefaultext) + 1 & "]")
  1726.     For $i = 1 To $asfilter[0]
  1727.         DllStructSetData($tfilter, $i, $asfilter[$i])
  1728.     Next
  1729.     DllStructSetData($ttitle, "Title", $stitle)
  1730.     DllStructSetData($tinitialdir, "InitDir", $sinitaldir)
  1731.     DllStructSetData($tpath, "Path", $sdefaultfile)
  1732.     DllStructSetData($textn, "Extension", $sdefaultext)
  1733.     DllStructSetData($tofn, "StructSize", DllStructGetSize($tofn))
  1734.     DllStructSetData($tofn, "hwndOwner", $hwndowner)
  1735.     DllStructSetData($tofn, "lpstrFilter", DllStructGetPtr($tfilter))
  1736.     DllStructSetData($tofn, "nFilterIndex", $ifilterindex)
  1737.     DllStructSetData($tofn, "lpstrFile", DllStructGetPtr($tpath))
  1738.     DllStructSetData($tofn, "nMaxFile", $ipathlen)
  1739.     DllStructSetData($tofn, "lpstrInitialDir", DllStructGetPtr($tinitialdir))
  1740.     DllStructSetData($tofn, "lpstrTitle", DllStructGetPtr($ttitle))
  1741.     DllStructSetData($tofn, "Flags", $iflag)
  1742.     DllStructSetData($tofn, "lpstrDefExt", DllStructGetPtr($textn))
  1743.     DllStructSetData($tofn, "FlagsEx", $iflagsex)
  1744.     Local $ares = DllCall("comdlg32.dll", "bool", "GetOpenFileNameW", "struct*", $tofn)
  1745.     If @error OR NOT $ares[0] Then Return SetError(@error + 10, @extended, $afiles)
  1746.     If BitAND($iflags, $ofn_allowmultiselect) = $ofn_allowmultiselect AND BitAND($iflags, $ofn_explorer) = $ofn_explorer Then
  1747.         For $x = 1 To $ipathlen
  1748.             If DllStructGetData($tpath, "Path", $x) = Chr(0) Then
  1749.                 DllStructSetData($tpath, "Path", "|", $x)
  1750.                 $inulls += 1
  1751.             Else
  1752.                 $inulls = 0
  1753.             EndIf
  1754.             If $inulls = 2 Then ExitLoop
  1755.         Next
  1756.         DllStructSetData($tpath, "Path", Chr(0), $x - 1)
  1757.         $afiles = StringSplit(DllStructGetData($tpath, "Path"), "|")
  1758.         If $afiles[0] = 1 Then Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  1759.         Return StringSplit(DllStructGetData($tpath, "Path"), "|")
  1760.     ElseIf BitAND($iflags, $ofn_allowmultiselect) = $ofn_allowmultiselect Then
  1761.         $afiles = StringSplit(DllStructGetData($tpath, "Path"), " ")
  1762.         If $afiles[0] = 1 Then Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  1763.         Return StringSplit(StringReplace(DllStructGetData($tpath, "Path"), " ", "|"), "|")
  1764.     Else
  1765.         Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  1766.     EndIf
  1767. EndFunc
  1768.  
  1769. Func _winapi_getoverlappedresult($hfile, $poverlapped, ByRef $ibytes, $fwait = False)
  1770.     Local $aresult = DllCall("kernel32.dll", "bool", "GetOverlappedResult", "handle", $hfile, "ptr", $poverlapped, "dword*", 0, "bool", $fwait)
  1771.     If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, False)
  1772.     $ibytes = $aresult[3]
  1773.     Return $aresult[0]
  1774. EndFunc
  1775.  
  1776. Func _winapi_getparent($hwnd)
  1777.     Local $aresult = DllCall("user32.dll", "hwnd", "GetParent", "hwnd", $hwnd)
  1778.     If @error Then Return SetError(@error, @extended, 0)
  1779.     Return $aresult[0]
  1780. EndFunc
  1781.  
  1782. Func _winapi_getprocaddress($hmodule, $vname)
  1783.     Local $stype = "str"
  1784.     If IsNumber($vname) Then $stype = "word"
  1785.     Local $aresult = DllCall("kernel32.dll", "ptr", "GetProcAddress", "handle", $hmodule, $stype, $vname)
  1786.     If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, 0)
  1787.     Return $aresult[0]
  1788. EndFunc
  1789.  
  1790. Func _winapi_getprocessaffinitymask($hprocess)
  1791.     Local $aresult = DllCall("kernel32.dll", "bool", "GetProcessAffinityMask", "handle", $hprocess, "dword_ptr*", 0, "dword_ptr*", 0)
  1792.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
  1793.     Local $amask[3]
  1794.     $amask[0] = True
  1795.     $amask[1] = $aresult[2]
  1796.     $amask[2] = $aresult[3]
  1797.     Return $amask
  1798. EndFunc
  1799.  
  1800. Func _winapi_getsavefilename($stitle = "", $sfilter = "All files (*.*)", $sinitaldir = ".", $sdefaultfile = "", $sdefaultext = "", $ifilterindex = 1, $iflags = 0, $iflagsex = 0, $hwndowner = 0)
  1801.     Local $ipathlen = 4096
  1802.     Local $tofn = DllStructCreate($tagopenfilename)
  1803.     Local $afiles[1] = [0]
  1804.     Local $iflag = $iflags
  1805.     Local $asflines = StringSplit($sfilter, "|")
  1806.     Local $asfilter[$asflines[0] * 2 + 1]
  1807.     Local $istart, $ifinal, $stfilter
  1808.     $asfilter[0] = $asflines[0] * 2
  1809.     For $i = 1 To $asflines[0]
  1810.         $istart = StringInStr($asflines[$i], "(", 0, 1)
  1811.         $ifinal = StringInStr($asflines[$i], ")", 0, -1)
  1812.         $asfilter[$i * 2 - 1] = StringStripWS(StringLeft($asflines[$i], $istart - 1), 3)
  1813.         $asfilter[$i * 2] = StringStripWS(StringTrimRight(StringTrimLeft($asflines[$i], $istart), StringLen($asflines[$i]) - $ifinal + 1), 3)
  1814.         $stfilter &= "wchar[" & StringLen($asfilter[$i * 2 - 1]) + 1 & "];wchar[" & StringLen($asfilter[$i * 2]) + 1 & "];"
  1815.     Next
  1816.     Local $ttitle = DllStructCreate("wchar Title[" & StringLen($stitle) + 1 & "]")
  1817.     Local $tinitialdir = DllStructCreate("wchar InitDir[" & StringLen($sinitaldir) + 1 & "]")
  1818.     Local $tfilter = DllStructCreate($stfilter & "wchar")
  1819.     Local $tpath = DllStructCreate("wchar Path[" & $ipathlen & "]")
  1820.     Local $textn = DllStructCreate("wchar Extension[" & StringLen($sdefaultext) + 1 & "]")
  1821.     For $i = 1 To $asfilter[0]
  1822.         DllStructSetData($tfilter, $i, $asfilter[$i])
  1823.     Next
  1824.     DllStructSetData($ttitle, "Title", $stitle)
  1825.     DllStructSetData($tinitialdir, "InitDir", $sinitaldir)
  1826.     DllStructSetData($tpath, "Path", $sdefaultfile)
  1827.     DllStructSetData($textn, "Extension", $sdefaultext)
  1828.     DllStructSetData($tofn, "StructSize", DllStructGetSize($tofn))
  1829.     DllStructSetData($tofn, "hwndOwner", $hwndowner)
  1830.     DllStructSetData($tofn, "lpstrFilter", DllStructGetPtr($tfilter))
  1831.     DllStructSetData($tofn, "nFilterIndex", $ifilterindex)
  1832.     DllStructSetData($tofn, "lpstrFile", DllStructGetPtr($tpath))
  1833.     DllStructSetData($tofn, "nMaxFile", $ipathlen)
  1834.     DllStructSetData($tofn, "lpstrInitialDir", DllStructGetPtr($tinitialdir))
  1835.     DllStructSetData($tofn, "lpstrTitle", DllStructGetPtr($ttitle))
  1836.     DllStructSetData($tofn, "Flags", $iflag)
  1837.     DllStructSetData($tofn, "lpstrDefExt", DllStructGetPtr($textn))
  1838.     DllStructSetData($tofn, "FlagsEx", $iflagsex)
  1839.     Local $ares = DllCall("comdlg32.dll", "bool", "GetSaveFileNameW", "struct*", $tofn)
  1840.     If @error OR NOT $ares[0] Then Return SetError(@error + 10, @extended, $afiles)
  1841.     Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
  1842. EndFunc
  1843.  
  1844. Func _winapi_getstockobject($iobject)
  1845.     Local $aresult = DllCall("gdi32.dll", "handle", "GetStockObject", "int", $iobject)
  1846.     If @error Then Return SetError(@error, @extended, 0)
  1847.     Return $aresult[0]
  1848. EndFunc
  1849.  
  1850. Func _winapi_getstdhandle($istdhandle)
  1851.     If $istdhandle < 0 OR $istdhandle > 2 Then Return SetError(2, 0, -1)
  1852.     Local Const $ahandle[3] = [-10, -11, -12]
  1853.     Local $aresult = DllCall("kernel32.dll", "handle", "GetStdHandle", "dword", $ahandle[$istdhandle])
  1854.     If @error Then Return SetError(@error, @extended, -1)
  1855.     Return $aresult[0]
  1856. EndFunc
  1857.  
  1858. Func _winapi_getsyscolor($iindex)
  1859.     Local $aresult = DllCall("user32.dll", "INT", "GetSysColor", "int", $iindex)
  1860.     If @error Then Return SetError(@error, @extended, 0)
  1861.     Return $aresult[0]
  1862. EndFunc
  1863.  
  1864. Func _winapi_getsyscolorbrush($iindex)
  1865.     Local $aresult = DllCall("user32.dll", "handle", "GetSysColorBrush", "int", $iindex)
  1866.     If @error Then Return SetError(@error, @extended, 0)
  1867.     Return $aresult[0]
  1868. EndFunc
  1869.  
  1870. Func _winapi_getsystemmetrics($iindex)
  1871.     Local $aresult = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $iindex)
  1872.     If @error Then Return SetError(@error, @extended, 0)
  1873.     Return $aresult[0]
  1874. EndFunc
  1875.  
  1876. Func _winapi_gettextextentpoint32($hdc, $stext)
  1877.     Local $tsize = DllStructCreate($tagsize)
  1878.     Local $isize = StringLen($stext)
  1879.     Local $aret = DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hdc, "wstr", $stext, "int", $isize, "struct*", $tsize)
  1880.     If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  1881.     Return $tsize
  1882. EndFunc
  1883.  
  1884. Func _winapi_gettextmetrics($hdc)
  1885.     Local $ttextmetric = DllStructCreate($tagtextmetric)
  1886.     Local $ret = DllCall("gdi32.dll", "bool", "GetTextMetricsW", "handle", $hdc, "struct*", $ttextmetric)
  1887.     If @error OR NOT $ret[0] Then Return SetError(@error + 10, @extended, 0)
  1888.     Return $ttextmetric
  1889. EndFunc
  1890.  
  1891. Func _winapi_getwindow($hwnd, $icmd)
  1892.     Local $aresult = DllCall("user32.dll", "hwnd", "GetWindow", "hwnd", $hwnd, "uint", $icmd)
  1893.     If @error Then Return SetError(@error, @extended, 0)
  1894.     Return $aresult[0]
  1895. EndFunc
  1896.  
  1897. Func _winapi_getwindowdc($hwnd)
  1898.     Local $aresult = DllCall("user32.dll", "handle", "GetWindowDC", "hwnd", $hwnd)
  1899.     If @error Then Return SetError(@error, @extended, 0)
  1900.     Return $aresult[0]
  1901. EndFunc
  1902.  
  1903. Func _winapi_getwindowheight($hwnd)
  1904.     Local $trect = _winapi_getwindowrect($hwnd)
  1905.     If @error Then Return SetError(@error, @extended, 0)
  1906.     Return DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top")
  1907. EndFunc
  1908.  
  1909. Func _winapi_getwindowlong($hwnd, $iindex)
  1910.     Local $sfuncname = "GetWindowLongW"
  1911.     If @AutoItX64 Then $sfuncname = "GetWindowLongPtrW"
  1912.     Local $aresult = DllCall("user32.dll", "long_ptr", $sfuncname, "hwnd", $hwnd, "int", $iindex)
  1913.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
  1914.     Return $aresult[0]
  1915. EndFunc
  1916.  
  1917. Func _winapi_getwindowplacement($hwnd)
  1918.     Local $twindowplacement = DllStructCreate($tagwindowplacement)
  1919.     DllStructSetData($twindowplacement, "length", DllStructGetSize($twindowplacement))
  1920.     Local $aret = DllCall("user32.dll", "bool", "GetWindowPlacement", "hwnd", $hwnd, "struct*", $twindowplacement)
  1921.     If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  1922.     Return $twindowplacement
  1923. EndFunc
  1924.  
  1925. Func _winapi_getwindowrect($hwnd)
  1926.     Local $trect = DllStructCreate($tagrect)
  1927.     Local $aret = DllCall("user32.dll", "bool", "GetWindowRect", "hwnd", $hwnd, "struct*", $trect)
  1928.     If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  1929.     Return $trect
  1930. EndFunc
  1931.  
  1932. Func _winapi_getwindowrgn($hwnd, $hrgn)
  1933.     Local $aresult = DllCall("user32.dll", "int", "GetWindowRgn", "hwnd", $hwnd, "handle", $hrgn)
  1934.     If @error Then Return SetError(@error, @extended, 0)
  1935.     Return $aresult[0]
  1936. EndFunc
  1937.  
  1938. Func _winapi_getwindowtext($hwnd)
  1939.     Local $aresult = DllCall("user32.dll", "int", "GetWindowTextW", "hwnd", $hwnd, "wstr", "", "int", 4096)
  1940.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
  1941.     Return SetExtended($aresult[0], $aresult[2])
  1942. EndFunc
  1943.  
  1944. Func _winapi_getwindowthreadprocessid($hwnd, ByRef $ipid)
  1945.     Local $aresult = DllCall("user32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $hwnd, "dword*", 0)
  1946.     If @error Then Return SetError(@error, @extended, 0)
  1947.     $ipid = $aresult[2]
  1948.     Return $aresult[0]
  1949. EndFunc
  1950.  
  1951. Func _winapi_getwindowwidth($hwnd)
  1952.     Local $trect = _winapi_getwindowrect($hwnd)
  1953.     If @error Then Return SetError(@error, @extended, 0)
  1954.     Return DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left")
  1955. EndFunc
  1956.  
  1957. Func _winapi_getxyfrompoint(ByRef $tpoint, ByRef $ix, ByRef $iy)
  1958.     $ix = DllStructGetData($tpoint, "X")
  1959.     $iy = DllStructGetData($tpoint, "Y")
  1960. EndFunc
  1961.  
  1962. Func _winapi_globalmemorystatus()
  1963.     Local $tmem = DllStructCreate($tagmemorystatusex)
  1964.     DllStructSetData($tmem, 1, DllStructGetSize($tmem))
  1965.     Local $aret = DllCall("kernel32.dll", "bool", "GlobalMemoryStatusEx", "struct*", $tmem)
  1966.     If @error OR NOT $aret[0] Then Return SetError(@error + 10, @extended, 0)
  1967.     Local $amem[7]
  1968.     $amem[0] = DllStructGetData($tmem, 2)
  1969.     $amem[1] = DllStructGetData($tmem, 3)
  1970.     $amem[2] = DllStructGetData($tmem, 4)
  1971.     $amem[3] = DllStructGetData($tmem, 5)
  1972.     $amem[4] = DllStructGetData($tmem, 6)
  1973.     $amem[5] = DllStructGetData($tmem, 7)
  1974.     $amem[6] = DllStructGetData($tmem, 8)
  1975.     Return $amem
  1976. EndFunc
  1977.  
  1978. Func _winapi_guidfromstring($sguid)
  1979.     Local $tguid = DllStructCreate($tagguid)
  1980.     _winapi_guidfromstringex($sguid, $tguid)
  1981.     If @error Then Return SetError(@error + 10, @extended, 0)
  1982.     Return $tguid
  1983. EndFunc
  1984.  
  1985. Func _winapi_guidfromstringex($sguid, $pguid)
  1986.     Local $aresult = DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $sguid, "struct*", $pguid)
  1987.     If @error Then Return SetError(@error, @extended, False)
  1988.     Return $aresult[0]
  1989. EndFunc
  1990.  
  1991. Func _winapi_hiword($ilong)
  1992.     Return BitShift($ilong, 16)
  1993. EndFunc
  1994.  
  1995. Func _winapi_inprocess($hwnd, ByRef $hlastwnd)
  1996.     If $hwnd = $hlastwnd Then Return True
  1997.     For $ii = $__gainprocess_winapi[0][0] To 1 Step -1
  1998.         If $hwnd = $__gainprocess_winapi[$ii][0] Then
  1999.             If $__gainprocess_winapi[$ii][1] Then
  2000.                 $hlastwnd = $hwnd
  2001.                 Return True
  2002.             Else
  2003.                 Return False
  2004.             EndIf
  2005.         EndIf
  2006.     Next
  2007.     Local $iprocessid
  2008.     _winapi_getwindowthreadprocessid($hwnd, $iprocessid)
  2009.     Local $icount = $__gainprocess_winapi[0][0] + 1
  2010.     If $icount >= 64 Then $icount = 1
  2011.     $__gainprocess_winapi[0][0] = $icount
  2012.     $__gainprocess_winapi[$icount][0] = $hwnd
  2013.     $__gainprocess_winapi[$icount][1] = ($iprocessid = @AutoItPID)
  2014.     Return $__gainprocess_winapi[$icount][1]
  2015. EndFunc
  2016.  
  2017. Func _winapi_inttofloat($iint)
  2018.     Local $tint = DllStructCreate("int")
  2019.     Local $tfloat = DllStructCreate("float", DllStructGetPtr($tint))
  2020.     DllStructSetData($tint, 1, $iint)
  2021.     Return DllStructGetData($tfloat, 1)
  2022. EndFunc
  2023.  
  2024. Func _winapi_isclassname($hwnd, $sclassname)
  2025.     Local $sseparator = Opt("GUIDataSeparatorChar")
  2026.     Local $aclassname = StringSplit($sclassname, $sseparator)
  2027.     If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  2028.     Local $sclasscheck = _winapi_getclassname($hwnd)
  2029.     For $x = 1 To UBound($aclassname) - 1
  2030.         If StringUpper(StringMid($sclasscheck, 1, StringLen($aclassname[$x]))) = StringUpper($aclassname[$x]) Then Return True
  2031.     Next
  2032.     Return False
  2033. EndFunc
  2034.  
  2035. Func _winapi_iswindow($hwnd)
  2036.     Local $aresult = DllCall("user32.dll", "bool", "IsWindow", "hwnd", $hwnd)
  2037.     If @error Then Return SetError(@error, @extended, 0)
  2038.     Return $aresult[0]
  2039. EndFunc
  2040.  
  2041. Func _winapi_iswindowvisible($hwnd)
  2042.     Local $aresult = DllCall("user32.dll", "bool", "IsWindowVisible", "hwnd", $hwnd)
  2043.     If @error Then Return SetError(@error, @extended, 0)
  2044.     Return $aresult[0]
  2045. EndFunc
  2046.  
  2047. Func _winapi_invalidaterect($hwnd, $trect = 0, $ferase = True)
  2048.     Local $aresult = DllCall("user32.dll", "bool", "InvalidateRect", "hwnd", $hwnd, "struct*", $trect, "bool", $ferase)
  2049.     If @error Then Return SetError(@error, @extended, False)
  2050.     Return $aresult[0]
  2051. EndFunc
  2052.  
  2053. Func _winapi_lineto($hdc, $ix, $iy)
  2054.     Local $aresult = DllCall("gdi32.dll", "bool", "LineTo", "handle", $hdc, "int", $ix, "int", $iy)
  2055.     If @error Then Return SetError(@error, @extended, False)
  2056.     Return $aresult[0]
  2057. EndFunc
  2058.  
  2059. Func _winapi_loadbitmap($hinstance, $sbitmap)
  2060.     Local $sbitmaptype = "int"
  2061.     If IsString($sbitmap) Then $sbitmaptype = "wstr"
  2062.     Local $aresult = DllCall("user32.dll", "handle", "LoadBitmapW", "handle", $hinstance, $sbitmaptype, $sbitmap)
  2063.     If @error Then Return SetError(@error, @extended, 0)
  2064.     Return $aresult[0]
  2065. EndFunc
  2066.  
  2067. Func _winapi_loadimage($hinstance, $simage, $itype, $ixdesired, $iydesired, $iload)
  2068.     Local $aresult, $simagetype = "int"
  2069.     If IsString($simage) Then $simagetype = "wstr"
  2070.     $aresult = DllCall("user32.dll", "handle", "LoadImageW", "handle", $hinstance, $simagetype, $simage, "uint", $itype, "int", $ixdesired, "int", $iydesired, "uint", $iload)
  2071.     If @error Then Return SetError(@error, @extended, 0)
  2072.     Return $aresult[0]
  2073. EndFunc
  2074.  
  2075. Func _winapi_loadlibrary($sfilename)
  2076.     Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryW", "wstr", $sfilename)
  2077.     If @error Then Return SetError(@error, @extended, 0)
  2078.     Return $aresult[0]
  2079. EndFunc
  2080.  
  2081. Func _winapi_loadlibraryex($sfilename, $iflags = 0)
  2082.     Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryExW", "wstr", $sfilename, "ptr", 0, "dword", $iflags)
  2083.     If @error Then Return SetError(@error, @extended, 0)
  2084.     Return $aresult[0]
  2085. EndFunc
  2086.  
  2087. Func _winapi_loadshell32icon($iiconid)
  2088.     Local $ticons = DllStructCreate("ptr Data")
  2089.     Local $iicons = _winapi_extracticonex("shell32.dll", $iiconid, 0, $ticons, 1)
  2090.     If @error Then Return SetError(@error, @extended, 0)
  2091.     If $iicons <= 0 Then Return SetError(10, 0, 0)
  2092.     Return DllStructGetData($ticons, "Data")
  2093. EndFunc
  2094.  
  2095. Func _winapi_loadstring($hinstance, $istringid)
  2096.     Local $aresult = DllCall("user32.dll", "int", "LoadStringW", "handle", $hinstance, "uint", $istringid, "wstr", "", "int", 4096)
  2097.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
  2098.     Return SetExtended($aresult[0], $aresult[3])
  2099. EndFunc
  2100.  
  2101. Func _winapi_localfree($hmem)
  2102.     Local $aresult = DllCall("kernel32.dll", "handle", "LocalFree", "handle", $hmem)
  2103.     If @error Then Return SetError(@error, @extended, False)
  2104.     Return $aresult[0]
  2105. EndFunc
  2106.  
  2107. Func _winapi_loword($ilong)
  2108.     Return BitAND($ilong, 65535)
  2109. EndFunc
  2110.  
  2111. Func _winapi_makelangid($lgidprimary, $lgidsub)
  2112.     Return BitOR(BitShift($lgidsub, -10), $lgidprimary)
  2113. EndFunc
  2114.  
  2115. Func _winapi_makelcid($lgid, $srtid)
  2116.     Return BitOR(BitShift($srtid, -16), $lgid)
  2117. EndFunc
  2118.  
  2119. Func _winapi_makelong($ilo, $ihi)
  2120.     Return BitOR(BitShift($ihi, -16), BitAND($ilo, 65535))
  2121. EndFunc
  2122.  
  2123. Func _winapi_makeqword($lodword, $hidword)
  2124.     Local $tint64 = DllStructCreate("uint64")
  2125.     Local $tdwords = DllStructCreate("dword;dword", DllStructGetPtr($tint64))
  2126.     DllStructSetData($tdwords, 1, $lodword)
  2127.     DllStructSetData($tdwords, 2, $hidword)
  2128.     Return DllStructGetData($tint64, 1)
  2129. EndFunc
  2130.  
  2131. Func _winapi_messagebeep($itype = 1)
  2132.     Local $isound
  2133.     Switch $itype
  2134.         Case 1
  2135.             $isound = 0
  2136.         Case 2
  2137.             $isound = 16
  2138.         Case 3
  2139.             $isound = 32
  2140.         Case 4
  2141.             $isound = 48
  2142.         Case 5
  2143.             $isound = 64
  2144.         Case Else
  2145.             $isound = -1
  2146.     EndSwitch
  2147.     Local $aresult = DllCall("user32.dll", "bool", "MessageBeep", "uint", $isound)
  2148.     If @error Then Return SetError(@error, @extended, False)
  2149.     Return $aresult[0]
  2150. EndFunc
  2151.  
  2152. Func _winapi_msgbox($iflags, $stitle, $stext)
  2153.     BlockInput(0)
  2154.     MsgBox($iflags, $stitle, $stext & "      ")
  2155. EndFunc
  2156.  
  2157. Func _winapi_mouse_event($iflags, $ix = 0, $iy = 0, $idata = 0, $iextrainfo = 0)
  2158.     DllCall("user32.dll", "none", "mouse_event", "dword", $iflags, "dword", $ix, "dword", $iy, "dword", $idata, "ulong_ptr", $iextrainfo)
  2159.     If @error Then Return SetError(@error, @extended)
  2160. EndFunc
  2161.  
  2162. Func _winapi_moveto($hdc, $ix, $iy)
  2163.     Local $aresult = DllCall("gdi32.dll", "bool", "MoveToEx", "handle", $hdc, "int", $ix, "int", $iy, "ptr", 0)
  2164.     If @error Then Return SetError(@error, @extended, False)
  2165.     Return $aresult[0]
  2166. EndFunc
  2167.  
  2168. Func _winapi_movewindow($hwnd, $ix, $iy, $iwidth, $iheight, $frepaint = True)
  2169.     Local $aresult = DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hwnd, "int", $ix, "int", $iy, "int", $iwidth, "int", $iheight, "bool", $frepaint)
  2170.     If @error Then Return SetError(@error, @extended, False)
  2171.     Return $aresult[0]
  2172. EndFunc
  2173.  
  2174. Func _winapi_muldiv($inumber, $inumerator, $idenominator)
  2175.     Local $aresult = DllCall("kernel32.dll", "int", "MulDiv", "int", $inumber, "int", $inumerator, "int", $idenominator)
  2176.     If @error Then Return SetError(@error, @extended, -1)
  2177.     Return $aresult[0]
  2178. EndFunc
  2179.  
  2180. Func _winapi_multibytetowidechar($stext, $icodepage = 0, $iflags = 0, $bretstring = False)
  2181.     Local $stexttype = "str"
  2182.     If NOT IsString($stext) Then $stexttype = "struct*"
  2183.     Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, $stexttype, $stext, "int", -1, "ptr", 0, "int", 0)
  2184.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, 0)
  2185.     Local $iout = $aresult[0]
  2186.     Local $tout = DllStructCreate("wchar[" & $iout & "]")
  2187.     $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, $stexttype, $stext, "int", -1, "struct*", $tout, "int", $iout)
  2188.     If @error OR NOT $aresult[0] Then Return SetError(@error + 20, @extended, 0)
  2189.     If $bretstring Then Return DllStructGetData($tout, 1)
  2190.     Return $tout
  2191. EndFunc
  2192.  
  2193. Func _winapi_multibytetowidecharex($stext, $ptext, $icodepage = 0, $iflags = 0)
  2194.     Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, "STR", $stext, "int", -1, "struct*", $ptext, "int", (StringLen($stext) + 1) * 2)
  2195.     If @error Then Return SetError(@error, @extended, False)
  2196.     Return $aresult[0]
  2197. EndFunc
  2198.  
  2199. Func _winapi_openprocess($iaccess, $finherit, $iprocessid, $fdebugpriv = False)
  2200.     Local $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $finherit, "dword", $iprocessid)
  2201.     If @error Then Return SetError(@error, @extended, 0)
  2202.     If $aresult[0] Then Return $aresult[0]
  2203.     If NOT $fdebugpriv Then Return SetError(100, 0, 0)
  2204.     Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
  2205.     If @error Then Return SetError(@error + 10, @extended, 0)
  2206.     _security__setprivilege($htoken, "SeDebugPrivilege", True)
  2207.     Local $ierror = @error
  2208.     Local $iextended = @extended
  2209.     Local $iret = 0
  2210.     If NOT @error Then
  2211.         $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $finherit, "dword", $iprocessid)
  2212.         $ierror = @error
  2213.         $iextended = @extended
  2214.         If $aresult[0] Then $iret = $aresult[0]
  2215.         _security__setprivilege($htoken, "SeDebugPrivilege", False)
  2216.         If @error Then
  2217.             $ierror = @error + 20
  2218.             $iextended = @extended
  2219.         EndIf
  2220.     Else
  2221.         $ierror = @error + 30
  2222.     EndIf
  2223.     _winapi_closehandle($htoken)
  2224.     Return SetError($ierror, $iextended, $iret)
  2225. EndFunc
  2226.  
  2227. Func __winapi_parsefiledialogpath($spath)
  2228.     Local $afiles[3]
  2229.     $afiles[0] = 2
  2230.     Local $stemp = StringMid($spath, 1, StringInStr($spath, "\", 0, -1) - 1)
  2231.     $afiles[1] = $stemp
  2232.     $afiles[2] = StringMid($spath, StringInStr($spath, "\", 0, -1) + 1)
  2233.     Return $afiles
  2234. EndFunc
  2235.  
  2236. Func _winapi_pathfindonpath(Const $szfile, $aextrapaths = "", Const $szpathdelimiter = @LF)
  2237.     Local $iextracount = 0
  2238.     If IsString($aextrapaths) Then
  2239.         If StringLen($aextrapaths) Then
  2240.             $aextrapaths = StringSplit($aextrapaths, $szpathdelimiter, 1 + 2)
  2241.             $iextracount = UBound($aextrapaths, 1)
  2242.         EndIf
  2243.     ElseIf IsArray($aextrapaths) Then
  2244.         $iextracount = UBound($aextrapaths)
  2245.     EndIf
  2246.     Local $tpaths, $tpathptrs
  2247.     If $iextracount Then
  2248.         Local $szstruct = ""
  2249.         For $path In $aextrapaths
  2250.             $szstruct &= "wchar[" & StringLen($path) + 1 & "];"
  2251.         Next
  2252.         $tpaths = DllStructCreate($szstruct)
  2253.         $tpathptrs = DllStructCreate("ptr[" & $iextracount + 1 & "]")
  2254.         For $i = 1 To $iextracount
  2255.             DllStructSetData($tpaths, $i, $aextrapaths[$i - 1])
  2256.             DllStructSetData($tpathptrs, 1, DllStructGetPtr($tpaths, $i), $i)
  2257.         Next
  2258.         DllStructSetData($tpathptrs, 1, Ptr(0), $iextracount + 1)
  2259.     EndIf
  2260.     Local $aresult = DllCall("shlwapi.dll", "bool", "PathFindOnPathW", "wstr", $szfile, "struct*", $tpathptrs)
  2261.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, $szfile)
  2262.     Return $aresult[1]
  2263. EndFunc
  2264.  
  2265. Func _winapi_pointfromrect(ByRef $trect, $fcenter = True)
  2266.     Local $ix1 = DllStructGetData($trect, "Left")
  2267.     Local $iy1 = DllStructGetData($trect, "Top")
  2268.     Local $ix2 = DllStructGetData($trect, "Right")
  2269.     Local $iy2 = DllStructGetData($trect, "Bottom")
  2270.     If $fcenter Then
  2271.         $ix1 = $ix1 + (($ix2 - $ix1) / 2)
  2272.         $iy1 = $iy1 + (($iy2 - $iy1) / 2)
  2273.     EndIf
  2274.     Local $tpoint = DllStructCreate($tagpoint)
  2275.     DllStructSetData($tpoint, "X", $ix1)
  2276.     DllStructSetData($tpoint, "Y", $iy1)
  2277.     Return $tpoint
  2278. EndFunc
  2279.  
  2280. Func _winapi_postmessage($hwnd, $imsg, $iwparam, $ilparam)
  2281.     Local $aresult = DllCall("user32.dll", "bool", "PostMessage", "hwnd", $hwnd, "uint", $imsg, "wparam", $iwparam, "lparam", $ilparam)
  2282.     If @error Then Return SetError(@error, @extended, False)
  2283.     Return $aresult[0]
  2284. EndFunc
  2285.  
  2286. Func _winapi_primarylangid($lgid)
  2287.     Return BitAND($lgid, 1023)
  2288. EndFunc
  2289.  
  2290. Func _winapi_ptinrect(ByRef $trect, ByRef $tpoint)
  2291.     Local $aresult = DllCall("user32.dll", "bool", "PtInRect", "struct*", $trect, "struct", $tpoint)
  2292.     If @error Then Return SetError(@error, @extended, False)
  2293.     Return $aresult[0]
  2294. EndFunc
  2295.  
  2296. Func _winapi_readfile($hfile, $pbuffer, $itoread, ByRef $iread, $poverlapped = 0)
  2297.     Local $aresult = DllCall("kernel32.dll", "bool", "ReadFile", "handle", $hfile, "ptr", $pbuffer, "dword", $itoread, "dword*", 0, "ptr", $poverlapped)
  2298.     If @error Then Return SetError(@error, @extended, False)
  2299.     $iread = $aresult[4]
  2300.     Return $aresult[0]
  2301. EndFunc
  2302.  
  2303. Func _winapi_readprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isize, ByRef $iread)
  2304.     Local $aresult = DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $hprocess, "ptr", $pbaseaddress, "ptr", $pbuffer, "ulong_ptr", $isize, "ulong_ptr*", 0)
  2305.     If @error Then Return SetError(@error, @extended, False)
  2306.     $iread = $aresult[5]
  2307.     Return $aresult[0]
  2308. EndFunc
  2309.  
  2310. Func _winapi_rectisempty(ByRef $trect)
  2311.     Return (DllStructGetData($trect, "Left") = 0) AND (DllStructGetData($trect, "Top") = 0) AND (DllStructGetData($trect, "Right") = 0) AND (DllStructGetData($trect, "Bottom") = 0)
  2312. EndFunc
  2313.  
  2314. Func _winapi_redrawwindow($hwnd, $trect = 0, $hregion = 0, $iflags = 5)
  2315.     Local $aresult = DllCall("user32.dll", "bool", "RedrawWindow", "hwnd", $hwnd, "struct*", $trect, "handle", $hregion, "uint", $iflags)
  2316.     If @error Then Return SetError(@error, @extended, False)
  2317.     Return $aresult[0]
  2318. EndFunc
  2319.  
  2320. Func _winapi_registerwindowmessage($smessage)
  2321.     Local $aresult = DllCall("user32.dll", "uint", "RegisterWindowMessageW", "wstr", $smessage)
  2322.     If @error Then Return SetError(@error, @extended, 0)
  2323.     Return $aresult[0]
  2324. EndFunc
  2325.  
  2326. Func _winapi_releasecapture()
  2327.     Local $aresult = DllCall("user32.dll", "bool", "ReleaseCapture")
  2328.     If @error Then Return SetError(@error, @extended, False)
  2329.     Return $aresult[0]
  2330. EndFunc
  2331.  
  2332. Func _winapi_releasedc($hwnd, $hdc)
  2333.     Local $aresult = DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hwnd, "handle", $hdc)
  2334.     If @error Then Return SetError(@error, @extended, False)
  2335.     Return $aresult[0]
  2336. EndFunc
  2337.  
  2338. Func _winapi_screentoclient($hwnd, ByRef $tpoint)
  2339.     Local $aresult = DllCall("user32.dll", "bool", "ScreenToClient", "hwnd", $hwnd, "struct*", $tpoint)
  2340.     If @error Then Return SetError(@error, @extended, False)
  2341.     Return $aresult[0]
  2342. EndFunc
  2343.  
  2344. Func _winapi_selectobject($hdc, $hgdiobj)
  2345.     Local $aresult = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hdc, "handle", $hgdiobj)
  2346.     If @error Then Return SetError(@error, @extended, False)
  2347.     Return $aresult[0]
  2348. EndFunc
  2349.  
  2350. Func _winapi_setbkcolor($hdc, $icolor)
  2351.     Local $aresult = DllCall("gdi32.dll", "INT", "SetBkColor", "handle", $hdc, "INT", $icolor)
  2352.     If @error Then Return SetError(@error, @extended, -1)
  2353.     Return $aresult[0]
  2354. EndFunc
  2355.  
  2356. Func _winapi_setbkmode($hdc, $ibkmode)
  2357.     Local $aresult = DllCall("gdi32.dll", "int", "SetBkMode", "handle", $hdc, "int", $ibkmode)
  2358.     If @error Then Return SetError(@error, @extended, 0)
  2359.     Return $aresult[0]
  2360. EndFunc
  2361.  
  2362. Func _winapi_setcapture($hwnd)
  2363.     Local $aresult = DllCall("user32.dll", "hwnd", "SetCapture", "hwnd", $hwnd)
  2364.     If @error Then Return SetError(@error, @extended, 0)
  2365.     Return $aresult[0]
  2366. EndFunc
  2367.  
  2368. Func _winapi_setcursor($hcursor)
  2369.     Local $aresult = DllCall("user32.dll", "handle", "SetCursor", "handle", $hcursor)
  2370.     If @error Then Return SetError(@error, @extended, 0)
  2371.     Return $aresult[0]
  2372. EndFunc
  2373.  
  2374. Func _winapi_setdefaultprinter($sprinter)
  2375.     Local $aresult = DllCall("winspool.drv", "bool", "SetDefaultPrinterW", "wstr", $sprinter)
  2376.     If @error Then Return SetError(@error, @extended, False)
  2377.     Return $aresult[0]
  2378. EndFunc
  2379.  
  2380. Func _winapi_setdibits($hdc, $hbmp, $istartscan, $iscanlines, $pbits, $pbmi, $icoloruse = 0)
  2381.     Local $aresult = DllCall("gdi32.dll", "int", "SetDIBits", "handle", $hdc, "handle", $hbmp, "uint", $istartscan, "uint", $iscanlines, "ptr", $pbits, "ptr", $pbmi, "INT", $icoloruse)
  2382.     If @error Then Return SetError(@error, @extended, False)
  2383.     Return $aresult[0]
  2384. EndFunc
  2385.  
  2386. Func _winapi_setendoffile($hfile)
  2387.     Local $aresult = DllCall("kernel32.dll", "bool", "SetEndOfFile", "handle", $hfile)
  2388.     If @error Then Return SetError(@error, @extended, False)
  2389.     Return $aresult[0]
  2390. EndFunc
  2391.  
  2392. Func _winapi_setevent($hevent)
  2393.     Local $aresult = DllCall("kernel32.dll", "bool", "SetEvent", "handle", $hevent)
  2394.     If @error Then Return SetError(@error, @extended, False)
  2395.     Return $aresult[0]
  2396. EndFunc
  2397.  
  2398. Func _winapi_setfilepointer($hfile, $ipos, $imethod = 0)
  2399.     Local $aresult = DllCall("kernel32.dll", "INT", "SetFilePointer", "handle", $hfile, "long", $ipos, "ptr", 0, "long", $imethod)
  2400.     If @error Then Return SetError(@error, @extended, -1)
  2401.     Return $aresult[0]
  2402. EndFunc
  2403.  
  2404. Func _winapi_setfocus($hwnd)
  2405.     Local $aresult = DllCall("user32.dll", "hwnd", "SetFocus", "hwnd", $hwnd)
  2406.     If @error Then Return SetError(@error, @extended, 0)
  2407.     Return $aresult[0]
  2408. EndFunc
  2409.  
  2410. Func _winapi_setfont($hwnd, $hfont, $fredraw = True)
  2411.     _sendmessage($hwnd, $__winapiconstant_wm_setfont, $hfont, $fredraw, 0, "hwnd")
  2412. EndFunc
  2413.  
  2414. Func _winapi_sethandleinformation($hobject, $imask, $iflags)
  2415.     Local $aresult = DllCall("kernel32.dll", "bool", "SetHandleInformation", "handle", $hobject, "dword", $imask, "dword", $iflags)
  2416.     If @error Then Return SetError(@error, @extended, False)
  2417.     Return $aresult[0]
  2418. EndFunc
  2419.  
  2420. Func _winapi_setlayeredwindowattributes($hwnd, $i_transcolor, $transparency = 255, $dwflags = 3, $iscolorref = False)
  2421.     If $dwflags = Default OR $dwflags = "" OR $dwflags < 0 Then $dwflags = 3
  2422.     If NOT $iscolorref Then
  2423.         $i_transcolor = Int(BinaryMid($i_transcolor, 3, 1) & BinaryMid($i_transcolor, 2, 1) & BinaryMid($i_transcolor, 1, 1))
  2424.     EndIf
  2425.     Local $aresult = DllCall("user32.dll", "bool", "SetLayeredWindowAttributes", "hwnd", $hwnd, "INT", $i_transcolor, "byte", $transparency, "dword", $dwflags)
  2426.     If @error Then Return SetError(@error, @extended, False)
  2427.     Return $aresult[0]
  2428. EndFunc
  2429.  
  2430. Func _winapi_setparent($hwndchild, $hwndparent)
  2431.     Local $aresult = DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $hwndchild, "hwnd", $hwndparent)
  2432.     If @error Then Return SetError(@error, @extended, 0)
  2433.     Return $aresult[0]
  2434. EndFunc
  2435.  
  2436. Func _winapi_setprocessaffinitymask($hprocess, $imask)
  2437.     Local $aresult = DllCall("kernel32.dll", "bool", "SetProcessAffinityMask", "handle", $hprocess, "ulong_ptr", $imask)
  2438.     If @error Then Return SetError(@error, @extended, False)
  2439.     Return $aresult[0]
  2440. EndFunc
  2441.  
  2442. Func _winapi_setsyscolors($velements, $vcolors)
  2443.     Local $isearray = IsArray($velements), $iscarray = IsArray($vcolors)
  2444.     Local $ielementnum
  2445.     If NOT $iscarray AND NOT $isearray Then
  2446.         $ielementnum = 1
  2447.     ElseIf $iscarray OR $isearray Then
  2448.         If NOT $iscarray OR NOT $isearray Then Return SetError(-1, -1, False)
  2449.         If UBound($velements) <> UBound($vcolors) Then Return SetError(-1, -1, False)
  2450.         $ielementnum = UBound($velements)
  2451.     EndIf
  2452.     Local $telements = DllStructCreate("int Element[" & $ielementnum & "]")
  2453.     Local $tcolors = DllStructCreate("INT NewColor[" & $ielementnum & "]")
  2454.     If NOT $isearray Then
  2455.         DllStructSetData($telements, "Element", $velements, 1)
  2456.     Else
  2457.         For $x = 0 To $ielementnum - 1
  2458.             DllStructSetData($telements, "Element", $velements[$x], $x + 1)
  2459.         Next
  2460.     EndIf
  2461.     If NOT $iscarray Then
  2462.         DllStructSetData($tcolors, "NewColor", $vcolors, 1)
  2463.     Else
  2464.         For $x = 0 To $ielementnum - 1
  2465.             DllStructSetData($tcolors, "NewColor", $vcolors[$x], $x + 1)
  2466.         Next
  2467.     EndIf
  2468.     Local $aresult = DllCall("user32.dll", "bool", "SetSysColors", "int", $ielementnum, "struct*", $telements, "struct*", $tcolors)
  2469.     If @error Then Return SetError(@error, @extended, False)
  2470.     Return $aresult[0]
  2471. EndFunc
  2472.  
  2473. Func _winapi_settextcolor($hdc, $icolor)
  2474.     Local $aresult = DllCall("gdi32.dll", "INT", "SetTextColor", "handle", $hdc, "INT", $icolor)
  2475.     If @error Then Return SetError(@error, @extended, -1)
  2476.     Return $aresult[0]
  2477. EndFunc
  2478.  
  2479. Func _winapi_setwindowlong($hwnd, $iindex, $ivalue)
  2480.     _winapi_setlasterror(0)
  2481.     Local $sfuncname = "SetWindowLongW"
  2482.     If @AutoItX64 Then $sfuncname = "SetWindowLongPtrW"
  2483.     Local $aresult = DllCall("user32.dll", "long_ptr", $sfuncname, "hwnd", $hwnd, "int", $iindex, "long_ptr", $ivalue)
  2484.     If @error Then Return SetError(@error, @extended, 0)
  2485.     Return $aresult[0]
  2486. EndFunc
  2487.  
  2488. Func _winapi_setwindowplacement($hwnd, $pwindowplacement)
  2489.     Local $aresult = DllCall("user32.dll", "bool", "SetWindowPlacement", "hwnd", $hwnd, "ptr", $pwindowplacement)
  2490.     If @error Then Return SetError(@error, @extended, False)
  2491.     Return $aresult[0]
  2492. EndFunc
  2493.  
  2494. Func _winapi_setwindowpos($hwnd, $hafter, $ix, $iy, $icx, $icy, $iflags)
  2495.     Local $aresult = DllCall("user32.dll", "bool", "SetWindowPos", "hwnd", $hwnd, "hwnd", $hafter, "int", $ix, "int", $iy, "int", $icx, "int", $icy, "uint", $iflags)
  2496.     If @error Then Return SetError(@error, @extended, False)
  2497.     Return $aresult[0]
  2498. EndFunc
  2499.  
  2500. Func _winapi_setwindowrgn($hwnd, $hrgn, $bredraw = True)
  2501.     Local $aresult = DllCall("user32.dll", "int", "SetWindowRgn", "hwnd", $hwnd, "handle", $hrgn, "bool", $bredraw)
  2502.     If @error Then Return SetError(@error, @extended, False)
  2503.     Return $aresult[0]
  2504. EndFunc
  2505.  
  2506. Func _winapi_setwindowshookex($idhook, $lpfn, $hmod, $dwthreadid = 0)
  2507.     Local $aresult = DllCall("user32.dll", "handle", "SetWindowsHookEx", "int", $idhook, "ptr", $lpfn, "handle", $hmod, "dword", $dwthreadid)
  2508.     If @error Then Return SetError(@error, @extended, 0)
  2509.     Return $aresult[0]
  2510. EndFunc
  2511.  
  2512. Func _winapi_setwindowtext($hwnd, $stext)
  2513.     Local $aresult = DllCall("user32.dll", "bool", "SetWindowTextW", "hwnd", $hwnd, "wstr", $stext)
  2514.     If @error Then Return SetError(@error, @extended, False)
  2515.     Return $aresult[0]
  2516. EndFunc
  2517.  
  2518. Func _winapi_showcursor($fshow)
  2519.     Local $aresult = DllCall("user32.dll", "int", "ShowCursor", "bool", $fshow)
  2520.     If @error Then Return SetError(@error, @extended, 0)
  2521.     Return $aresult[0]
  2522. EndFunc
  2523.  
  2524. Func _winapi_showerror($stext, $fexit = True)
  2525.     _winapi_msgbox(266256, "Error", $stext)
  2526.     If $fexit Then Exit
  2527. EndFunc
  2528.  
  2529. Func _winapi_showmsg($stext)
  2530.     _winapi_msgbox(64 + 4096, "Information", $stext)
  2531. EndFunc
  2532.  
  2533. Func _winapi_showwindow($hwnd, $icmdshow = 5)
  2534.     Local $aresult = DllCall("user32.dll", "bool", "ShowWindow", "hwnd", $hwnd, "int", $icmdshow)
  2535.     If @error Then Return SetError(@error, @extended, False)
  2536.     Return $aresult[0]
  2537. EndFunc
  2538.  
  2539. Func _winapi_stringfromguid($pguid)
  2540.     Local $aresult = DllCall("ole32.dll", "int", "StringFromGUID2", "struct*", $pguid, "wstr", "", "int", 40)
  2541.     If @error OR NOT $aresult[0] Then Return SetError(@error, @extended, "")
  2542.     Return SetExtended($aresult[0], $aresult[2])
  2543. EndFunc
  2544.  
  2545. Func _winapi_stringlena($tstring)
  2546.     Local $aresult = DllCall("kernel32.dll", "int", "lstrlenA", "struct*", $tstring)
  2547.     If @error Then Return SetError(@error, @extended, 0)
  2548.     Return $aresult[0]
  2549. EndFunc
  2550.  
  2551. Func _winapi_stringlenw(Const ByRef $tstring)
  2552.     Local $aresult = DllCall("kernel32.dll", "int", "lstrlenW", "struct*", $tstring)
  2553.     If @error Then Return SetError(@error, @extended, 0)
  2554.     Return $aresult[0]
  2555. EndFunc
  2556.  
  2557. Func _winapi_sublangid($lgid)
  2558.     Return BitShift($lgid, 10)
  2559. EndFunc
  2560.  
  2561. Func _winapi_systemparametersinfo($iaction, $iparam = 0, $vparam = 0, $iwinini = 0)
  2562.     Local $aresult = DllCall("user32.dll", "bool", "SystemParametersInfoW", "uint", $iaction, "uint", $iparam, "ptr", $vparam, "uint", $iwinini)
  2563.     If @error Then Return SetError(@error, @extended, False)
  2564.     Return $aresult[0]
  2565. EndFunc
  2566.  
  2567. Func _winapi_twipsperpixelx()
  2568.     Local $lngdc, $twipsperpixelx
  2569.     $lngdc = _winapi_getdc(0)
  2570.     $twipsperpixelx = 1440 / _winapi_getdevicecaps($lngdc, $__winapiconstant_logpixelsx)
  2571.     _winapi_releasedc(0, $lngdc)
  2572.     Return $twipsperpixelx
  2573. EndFunc
  2574.  
  2575. Func _winapi_twipsperpixely()
  2576.     Local $lngdc, $twipsperpixely
  2577.     $lngdc = _winapi_getdc(0)
  2578.     $twipsperpixely = 1440 / _winapi_getdevicecaps($lngdc, $__winapiconstant_logpixelsy)
  2579.     _winapi_releasedc(0, $lngdc)
  2580.     Return $twipsperpixely
  2581. EndFunc
  2582.  
  2583. Func _winapi_unhookwindowshookex($hhk)
  2584.     Local $aresult = DllCall("user32.dll", "bool", "UnhookWindowsHookEx", "handle", $hhk)
  2585.     If @error Then Return SetError(@error, @extended, False)
  2586.     Return $aresult[0]
  2587. EndFunc
  2588.  
  2589. Func _winapi_updatelayeredwindow($hwnd, $hdcdest, $pptdest, $psize, $hdcsrce, $pptsrce, $irgb, $pblend, $iflags)
  2590.     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)
  2591.     If @error Then Return SetError(@error, @extended, False)
  2592.     Return $aresult[0]
  2593. EndFunc
  2594.  
  2595. Func _winapi_updatewindow($hwnd)
  2596.     Local $aresult = DllCall("user32.dll", "bool", "UpdateWindow", "hwnd", $hwnd)
  2597.     If @error Then Return SetError(@error, @extended, False)
  2598.     Return $aresult[0]
  2599. EndFunc
  2600.  
  2601. Func _winapi_waitforinputidle($hprocess, $itimeout = -1)
  2602.     Local $aresult = DllCall("user32.dll", "dword", "WaitForInputIdle", "handle", $hprocess, "dword", $itimeout)
  2603.     If @error Then Return SetError(@error, @extended, False)
  2604.     Return $aresult[0]
  2605. EndFunc
  2606.  
  2607. Func _winapi_waitformultipleobjects($icount, $phandles, $fwaitall = False, $itimeout = -1)
  2608.     Local $aresult = DllCall("kernel32.dll", "INT", "WaitForMultipleObjects", "dword", $icount, "ptr", $phandles, "bool", $fwaitall, "dword", $itimeout)
  2609.     If @error Then Return SetError(@error, @extended, -1)
  2610.     Return $aresult[0]
  2611. EndFunc
  2612.  
  2613. Func _winapi_waitforsingleobject($hhandle, $itimeout = -1)
  2614.     Local $aresult = DllCall("kernel32.dll", "INT", "WaitForSingleObject", "handle", $hhandle, "dword", $itimeout)
  2615.     If @error Then Return SetError(@error, @extended, -1)
  2616.     Return $aresult[0]
  2617. EndFunc
  2618.  
  2619. Func _winapi_widechartomultibyte($punicode, $icodepage = 0, $bretstring = True)
  2620.     Local $sunicodetype = "wstr"
  2621.     If NOT IsString($punicode) Then $sunicodetype = "struct*"
  2622.     Local $aresult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $icodepage, "dword", 0, $sunicodetype, $punicode, "int", -1, "ptr", 0, "int", 0, "ptr", 0, "ptr", 0)
  2623.     If @error OR NOT $aresult[0] Then Return SetError(@error + 20, @extended, "")
  2624.     Local $tmultibyte = DllStructCreate("char[" & $aresult[0] & "]")
  2625.     $aresult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $icodepage, "dword", 0, $sunicodetype, $punicode, "int", -1, "struct*", $tmultibyte, "int", $aresult[0], "ptr", 0, "ptr", 0)
  2626.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, "")
  2627.     If $bretstring Then Return DllStructGetData($tmultibyte, 1)
  2628.     Return $tmultibyte
  2629. EndFunc
  2630.  
  2631. Func _winapi_windowfrompoint(ByRef $tpoint)
  2632.     Local $aresult = DllCall("user32.dll", "hwnd", "WindowFromPoint", "struct", $tpoint)
  2633.     If @error Then Return SetError(@error, @extended, 0)
  2634.     Return $aresult[0]
  2635. EndFunc
  2636.  
  2637. Func _winapi_writeconsole($hconsole, $stext)
  2638.     Local $aresult = DllCall("kernel32.dll", "bool", "WriteConsoleW", "handle", $hconsole, "wstr", $stext, "dword", StringLen($stext), "dword*", 0, "ptr", 0)
  2639.     If @error Then Return SetError(@error, @extended, False)
  2640.     Return $aresult[0]
  2641. EndFunc
  2642.  
  2643. Func _winapi_writefile($hfile, $pbuffer, $itowrite, ByRef $iwritten, $poverlapped = 0)
  2644.     Local $aresult = DllCall("kernel32.dll", "bool", "WriteFile", "handle", $hfile, "ptr", $pbuffer, "dword", $itowrite, "dword*", 0, "ptr", $poverlapped)
  2645.     If @error Then Return SetError(@error, @extended, False)
  2646.     $iwritten = $aresult[4]
  2647.     Return $aresult[0]
  2648. EndFunc
  2649.  
  2650. Func _winapi_writeprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isize, ByRef $iwritten, $sbuffer = "ptr")
  2651.     Local $aresult = DllCall("kernel32.dll", "bool", "WriteProcessMemory", "handle", $hprocess, "ptr", $pbaseaddress, $sbuffer, $pbuffer, "ulong_ptr", $isize, "ulong_ptr*", 0)
  2652.     If @error Then Return SetError(@error, @extended, False)
  2653.     $iwritten = $aresult[5]
  2654.     Return $aresult[0]
  2655. EndFunc
  2656.  
  2657. Func _dateadd($stype, $ivaltoadd, $sdate)
  2658.     Local $astimepart[4]
  2659.     Local $asdatepart[4]
  2660.     Local $ijuliandate
  2661.     $stype = StringLeft($stype, 1)
  2662.     If StringInStr("D,M,Y,w,h,n,s", $stype) = 0 OR $stype = "" Then
  2663.         Return SetError(1, 0, 0)
  2664.     EndIf
  2665.     If NOT StringIsInt($ivaltoadd) Then
  2666.         Return SetError(2, 0, 0)
  2667.     EndIf
  2668.     If NOT _dateisvalid($sdate) Then
  2669.         Return SetError(3, 0, 0)
  2670.     EndIf
  2671.     _datetimesplit($sdate, $asdatepart, $astimepart)
  2672.     If $stype = "d" OR $stype = "w" Then
  2673.         If $stype = "w" Then $ivaltoadd = $ivaltoadd * 7
  2674.         $ijuliandate = _datetodayvalue($asdatepart[1], $asdatepart[2], $asdatepart[3]) + $ivaltoadd
  2675.         _dayvaluetodate($ijuliandate, $asdatepart[1], $asdatepart[2], $asdatepart[3])
  2676.     EndIf
  2677.     If $stype = "m" Then
  2678.         $asdatepart[2] = $asdatepart[2] + $ivaltoadd
  2679.         While $asdatepart[2] > 12
  2680.             $asdatepart[2] = $asdatepart[2] - 12
  2681.             $asdatepart[1] = $asdatepart[1] + 1
  2682.         WEnd
  2683.         While $asdatepart[2] < 1
  2684.             $asdatepart[2] = $asdatepart[2] + 12
  2685.             $asdatepart[1] = $asdatepart[1] - 1
  2686.         WEnd
  2687.     EndIf
  2688.     If $stype = "y" Then
  2689.         $asdatepart[1] = $asdatepart[1] + $ivaltoadd
  2690.     EndIf
  2691.     If $stype = "h" OR $stype = "n" OR $stype = "s" Then
  2692.         Local $itimeval = _timetoticks($astimepart[1], $astimepart[2], $astimepart[3]) / 1000
  2693.         If $stype = "h" Then $itimeval = $itimeval + $ivaltoadd * 3600
  2694.         If $stype = "n" Then $itimeval = $itimeval + $ivaltoadd * 60
  2695.         If $stype = "s" Then $itimeval = $itimeval + $ivaltoadd
  2696.         Local $day2add = Int($itimeval / (24 * 60 * 60))
  2697.         $itimeval = $itimeval - $day2add * 24 * 60 * 60
  2698.         If $itimeval < 0 Then
  2699.             $day2add = $day2add - 1
  2700.             $itimeval = $itimeval + 24 * 60 * 60
  2701.         EndIf
  2702.         $ijuliandate = _datetodayvalue($asdatepart[1], $asdatepart[2], $asdatepart[3]) + $day2add
  2703.         _dayvaluetodate($ijuliandate, $asdatepart[1], $asdatepart[2], $asdatepart[3])
  2704.         _tickstotime($itimeval * 1000, $astimepart[1], $astimepart[2], $astimepart[3])
  2705.     EndIf
  2706.     Local $inumdays = _daysinmonth($asdatepart[1])
  2707.     If $inumdays[$asdatepart[2]] < $asdatepart[3] Then $asdatepart[3] = $inumdays[$asdatepart[2]]
  2708.     $sdate = $asdatepart[1] & "/" & StringRight("0" & $asdatepart[2], 2) & "/" & StringRight("0" & $asdatepart[3], 2)
  2709.     If $astimepart[0] > 0 Then
  2710.         If $astimepart[0] > 2 Then
  2711.             $sdate = $sdate & " " & StringRight("0" & $astimepart[1], 2) & ":" & StringRight("0" & $astimepart[2], 2) & ":" & StringRight("0" & $astimepart[3], 2)
  2712.         Else
  2713.             $sdate = $sdate & " " & StringRight("0" & $astimepart[1], 2) & ":" & StringRight("0" & $astimepart[2], 2)
  2714.         EndIf
  2715.     EndIf
  2716.     Return ($sdate)
  2717. EndFunc
  2718.  
  2719. Func _datedayofweek($idaynum, $ishort = 0)
  2720.     Local Const $adayofweek[8] = ["", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
  2721.     Select
  2722.         Case NOT StringIsInt($idaynum) OR NOT StringIsInt($ishort)
  2723.             Return SetError(1, 0, "")
  2724.         Case $idaynum < 1 OR $idaynum > 7
  2725.             Return SetError(2, 0, "")
  2726.         Case Else
  2727.             Select
  2728.                 Case $ishort = 0
  2729.                     Return $adayofweek[$idaynum]
  2730.                 Case $ishort = 1
  2731.                     Return StringLeft($adayofweek[$idaynum], 3)
  2732.                 Case Else
  2733.                     Return SetError(3, 0, "")
  2734.             EndSelect
  2735.     EndSelect
  2736. EndFunc
  2737.  
  2738. Func _datedaysinmonth($iyear, $imonthnum)
  2739.     If __dateismonth($imonthnum) AND __dateisyear($iyear) Then
  2740.         Local $ainumdays = _daysinmonth($iyear)
  2741.         Return $ainumdays[$imonthnum]
  2742.     EndIf
  2743.     Return SetError(1, 0, 0)
  2744. EndFunc
  2745.  
  2746. Func _datediff($stype, $sstartdate, $senddate)
  2747.     $stype = StringLeft($stype, 1)
  2748.     If StringInStr("d,m,y,w,h,n,s", $stype) = 0 OR $stype = "" Then
  2749.         Return SetError(1, 0, 0)
  2750.     EndIf
  2751.     If NOT _dateisvalid($sstartdate) Then
  2752.         Return SetError(2, 0, 0)
  2753.     EndIf
  2754.     If NOT _dateisvalid($senddate) Then
  2755.         Return SetError(3, 0, 0)
  2756.     EndIf
  2757.     Local $asstartdatepart[4], $asstarttimepart[4], $asenddatepart[4], $asendtimepart[4]
  2758.     _datetimesplit($sstartdate, $asstartdatepart, $asstarttimepart)
  2759.     _datetimesplit($senddate, $asenddatepart, $asendtimepart)
  2760.     Local $adaysdiff = _datetodayvalue($asenddatepart[1], $asenddatepart[2], $asenddatepart[3]) - _datetodayvalue($asstartdatepart[1], $asstartdatepart[2], $asstartdatepart[3])
  2761.     Local $itimediff, $iyeardiff, $istarttimeinsecs, $iendtimeinsecs
  2762.     If $asstarttimepart[0] > 1 AND $asendtimepart[0] > 1 Then
  2763.         $istarttimeinsecs = $asstarttimepart[1] * 3600 + $asstarttimepart[2] * 60 + $asstarttimepart[3]
  2764.         $iendtimeinsecs = $asendtimepart[1] * 3600 + $asendtimepart[2] * 60 + $asendtimepart[3]
  2765.         $itimediff = $iendtimeinsecs - $istarttimeinsecs
  2766.         If $itimediff < 0 Then
  2767.             $adaysdiff = $adaysdiff - 1
  2768.             $itimediff = $itimediff + 24 * 60 * 60
  2769.         EndIf
  2770.     Else
  2771.         $itimediff = 0
  2772.     EndIf
  2773.     Select
  2774.         Case $stype = "d"
  2775.             Return ($adaysdiff)
  2776.         Case $stype = "m"
  2777.             $iyeardiff = $asenddatepart[1] - $asstartdatepart[1]
  2778.             Local $imonthdiff = $asenddatepart[2] - $asstartdatepart[2] + $iyeardiff * 12
  2779.             If $asenddatepart[3] < $asstartdatepart[3] Then $imonthdiff = $imonthdiff - 1
  2780.             $istarttimeinsecs = $asstarttimepart[1] * 3600 + $asstarttimepart[2] * 60 + $asstarttimepart[3]
  2781.             $iendtimeinsecs = $asendtimepart[1] * 3600 + $asendtimepart[2] * 60 + $asendtimepart[3]
  2782.             $itimediff = $iendtimeinsecs - $istarttimeinsecs
  2783.             If $asenddatepart[3] = $asstartdatepart[3] AND $itimediff < 0 Then $imonthdiff = $imonthdiff - 1
  2784.             Return ($imonthdiff)
  2785.         Case $stype = "y"
  2786.             $iyeardiff = $asenddatepart[1] - $asstartdatepart[1]
  2787.             If $asenddatepart[2] < $asstartdatepart[2] Then $iyeardiff = $iyeardiff - 1
  2788.             If $asenddatepart[2] = $asstartdatepart[2] AND $asenddatepart[3] < $asstartdatepart[3] Then $iyeardiff = $iyeardiff - 1
  2789.             $istarttimeinsecs = $asstarttimepart[1] * 3600 + $asstarttimepart[2] * 60 + $asstarttimepart[3]
  2790.             $iendtimeinsecs = $asendtimepart[1] * 3600 + $asendtimepart[2] * 60 + $asendtimepart[3]
  2791.             $itimediff = $iendtimeinsecs - $istarttimeinsecs
  2792.             If $asenddatepart[2] = $asstartdatepart[2] AND $asenddatepart[3] = $asstartdatepart[3] AND $itimediff < 0 Then $iyeardiff = $iyeardiff - 1
  2793.             Return ($iyeardiff)
  2794.         Case $stype = "w"
  2795.             Return (Int($adaysdiff / 7))
  2796.         Case $stype = "h"
  2797.             Return ($adaysdiff * 24 + Int($itimediff / 3600))
  2798.         Case $stype = "n"
  2799.             Return ($adaysdiff * 24 * 60 + Int($itimediff / 60))
  2800.         Case $stype = "s"
  2801.             Return ($adaysdiff * 24 * 60 * 60 + $itimediff)
  2802.     EndSelect
  2803. EndFunc
  2804.  
  2805. Func _dateisleapyear($iyear)
  2806.     If StringIsInt($iyear) Then
  2807.         Select
  2808.             Case Mod($iyear, 4) = 0 AND Mod($iyear, 100) <> 0
  2809.                 Return 1
  2810.             Case Mod($iyear, 400) = 0
  2811.                 Return 1
  2812.             Case Else
  2813.                 Return 0
  2814.         EndSelect
  2815.     EndIf
  2816.     Return SetError(1, 0, 0)
  2817. EndFunc
  2818.  
  2819. Func __dateismonth($inumber)
  2820.     If StringIsInt($inumber) Then
  2821.         If $inumber >= 1 AND $inumber <= 12 Then
  2822.             Return 1
  2823.         Else
  2824.             Return 0
  2825.         EndIf
  2826.     EndIf
  2827.     Return 0
  2828. EndFunc
  2829.  
  2830. Func _dateisvalid($sdate)
  2831.     Local $asdatepart[4], $astimepart[4]
  2832.     Local $sdatetime = StringSplit($sdate, " T")
  2833.     If $sdatetime[0] > 0 Then $asdatepart = StringSplit($sdatetime[1], "/-.")
  2834.     If UBound($asdatepart) <> 4 Then Return (0)
  2835.     If $asdatepart[0] <> 3 Then Return (0)
  2836.     If NOT StringIsInt($asdatepart[1]) Then Return (0)
  2837.     If NOT StringIsInt($asdatepart[2]) Then Return (0)
  2838.     If NOT StringIsInt($asdatepart[3]) Then Return (0)
  2839.     $asdatepart[1] = Number($asdatepart[1])
  2840.     $asdatepart[2] = Number($asdatepart[2])
  2841.     $asdatepart[3] = Number($asdatepart[3])
  2842.     Local $inumdays = _daysinmonth($asdatepart[1])
  2843.     If $asdatepart[1] < 1000 OR $asdatepart[1] > 2999 Then Return (0)
  2844.     If $asdatepart[2] < 1 OR $asdatepart[2] > 12 Then Return (0)
  2845.     If $asdatepart[3] < 1 OR $asdatepart[3] > $inumdays[$asdatepart[2]] Then Return (0)
  2846.     If $sdatetime[0] > 1 Then
  2847.         $astimepart = StringSplit($sdatetime[2], ":")
  2848.         If UBound($astimepart) < 4 Then ReDim $astimepart[4]
  2849.     Else
  2850.         Dim $astimepart[4]
  2851.     EndIf
  2852.     If $astimepart[0] < 1 Then Return (1)
  2853.     If $astimepart[0] < 2 Then Return (0)
  2854.     If $astimepart[0] = 2 Then $astimepart[3] = "00"
  2855.     If NOT StringIsInt($astimepart[1]) Then Return (0)
  2856.     If NOT StringIsInt($astimepart[2]) Then Return (0)
  2857.     If NOT StringIsInt($astimepart[3]) Then Return (0)
  2858.     $astimepart[1] = Number($astimepart[1])
  2859.     $astimepart[2] = Number($astimepart[2])
  2860.     $astimepart[3] = Number($astimepart[3])
  2861.     If $astimepart[1] < 0 OR $astimepart[1] > 23 Then Return (0)
  2862.     If $astimepart[2] < 0 OR $astimepart[2] > 59 Then Return (0)
  2863.     If $astimepart[3] < 0 OR $astimepart[3] > 59 Then Return (0)
  2864.     Return 1
  2865. EndFunc
  2866.  
  2867. Func __dateisyear($inumber)
  2868.     If StringIsInt($inumber) Then
  2869.         If StringLen($inumber) = 4 Then
  2870.             Return 1
  2871.         Else
  2872.             Return 0
  2873.         EndIf
  2874.     EndIf
  2875.     Return 0
  2876. EndFunc
  2877.  
  2878. Func _datelastweekdaynum($iweekdaynum)
  2879.     Select
  2880.         Case NOT StringIsInt($iweekdaynum)
  2881.             Return SetError(1, 0, 0)
  2882.         Case $iweekdaynum < 1 OR $iweekdaynum > 7
  2883.             Return SetError(2, 0, 0)
  2884.         Case Else
  2885.             Local $ilastweekdaynum
  2886.             If $iweekdaynum = 1 Then
  2887.                 $ilastweekdaynum = 7
  2888.             Else
  2889.                 $ilastweekdaynum = $iweekdaynum - 1
  2890.             EndIf
  2891.             Return $ilastweekdaynum
  2892.     EndSelect
  2893. EndFunc
  2894.  
  2895. Func _datelastmonthnum($imonthnum)
  2896.     Select
  2897.         Case NOT StringIsInt($imonthnum)
  2898.             Return SetError(1, 0, 0)
  2899.         Case $imonthnum < 1 OR $imonthnum > 12
  2900.             Return SetError(2, 0, 0)
  2901.         Case Else
  2902.             Local $ilastmonthnum
  2903.             If $imonthnum = 1 Then
  2904.                 $ilastmonthnum = 12
  2905.             Else
  2906.                 $ilastmonthnum = $imonthnum - 1
  2907.             EndIf
  2908.             $ilastmonthnum = StringFormat("%02d", $ilastmonthnum)
  2909.             Return $ilastmonthnum
  2910.     EndSelect
  2911. EndFunc
  2912.  
  2913. Func _datelastmonthyear($imonthnum, $iyear)
  2914.     Select
  2915.         Case NOT StringIsInt($imonthnum) OR NOT StringIsInt($iyear)
  2916.             Return SetError(1, 0, 0)
  2917.         Case $imonthnum < 1 OR $imonthnum > 12
  2918.             Return SetError(2, 0, 0)
  2919.         Case Else
  2920.             Local $ilastyear
  2921.             If $imonthnum = 1 Then
  2922.                 $ilastyear = $iyear - 1
  2923.             Else
  2924.                 $ilastyear = $iyear
  2925.             EndIf
  2926.             $ilastyear = StringFormat("%04d", $ilastyear)
  2927.             Return $ilastyear
  2928.     EndSelect
  2929. EndFunc
  2930.  
  2931. Func _datenextweekdaynum($iweekdaynum)
  2932.     Select
  2933.         Case NOT StringIsInt($iweekdaynum)
  2934.             Return SetError(1, 0, 0)
  2935.         Case $iweekdaynum < 1 OR $iweekdaynum > 7
  2936.             Return SetError(2, 0, 0)
  2937.         Case Else
  2938.             Local $inextweekdaynum
  2939.             If $iweekdaynum = 7 Then
  2940.                 $inextweekdaynum = 1
  2941.             Else
  2942.                 $inextweekdaynum = $iweekdaynum + 1
  2943.             EndIf
  2944.             Return $inextweekdaynum
  2945.     EndSelect
  2946. EndFunc
  2947.  
  2948. Func _datenextmonthnum($imonthnum)
  2949.     Select
  2950.         Case NOT StringIsInt($imonthnum)
  2951.             Return SetError(1, 0, 0)
  2952.         Case $imonthnum < 1 OR $imonthnum > 12
  2953.             Return SetError(2, 0, 0)
  2954.         Case Else
  2955.             Local $inextmonthnum
  2956.             If $imonthnum = 12 Then
  2957.                 $inextmonthnum = 1
  2958.             Else
  2959.                 $inextmonthnum = $imonthnum + 1
  2960.             EndIf
  2961.             $inextmonthnum = StringFormat("%02d", $inextmonthnum)
  2962.             Return $inextmonthnum
  2963.     EndSelect
  2964. EndFunc
  2965.  
  2966. Func _datenextmonthyear($imonthnum, $iyear)
  2967.     Select
  2968.         Case NOT StringIsInt($imonthnum) OR NOT StringIsInt($iyear)
  2969.             Return SetError(1, 0, 0)
  2970.         Case $imonthnum < 1 OR $imonthnum > 12
  2971.             Return SetError(2, 0, 0)
  2972.         Case Else
  2973.             Local $inextyear
  2974.             If $imonthnum = 12 Then
  2975.                 $inextyear = $iyear + 1
  2976.             Else
  2977.                 $inextyear = $iyear
  2978.             EndIf
  2979.             $inextyear = StringFormat("%04d", $inextyear)
  2980.             Return $inextyear
  2981.     EndSelect
  2982. EndFunc
  2983.  
  2984. Func _datetimeformat($sdate, $stype)
  2985.     Local $asdatepart[4], $astimepart[4]
  2986.     Local $stempdate = "", $stemptime = ""
  2987.     Local $sam, $spm, $lngx
  2988.     If NOT _dateisvalid($sdate) Then
  2989.         Return SetError(1, 0, "")
  2990.     EndIf
  2991.     If $stype < 0 OR $stype > 5 OR NOT IsInt($stype) Then
  2992.         Return SetError(2, 0, "")
  2993.     EndIf
  2994.     _datetimesplit($sdate, $asdatepart, $astimepart)
  2995.     Switch $stype
  2996.         Case 0
  2997.             $lngx = DllCall("kernel32.dll", "int", "GetLocaleInfoW", "dword", 1024, "dword", 31, "wstr", "", "int", 255)
  2998.             If NOT @error AND $lngx[0] <> 0 Then
  2999.                 $stempdate = $lngx[3]
  3000.             Else
  3001.                 $stempdate = "M/d/yyyy"
  3002.             EndIf
  3003.             If $astimepart[0] > 1 Then
  3004.                 $lngx = DllCall("kernel32.dll", "int", "GetLocaleInfoW", "dword", 1024, "dword", 4099, "wstr", "", "int", 255)
  3005.                 If NOT @error AND $lngx[0] <> 0 Then
  3006.                     $stemptime = $lngx[3]
  3007.                 Else
  3008.                     $stemptime = "h:mm:ss tt"
  3009.                 EndIf
  3010.             EndIf
  3011.         Case 1
  3012.             $lngx = DllCall("kernel32.dll", "int", "GetLocaleInfoW", "dword", 1024, "dword", 32, "wstr", "", "int", 255)
  3013.             If NOT @error AND $lngx[0] <> 0 Then
  3014.                 $stempdate = $lngx[3]
  3015.             Else
  3016.                 $stempdate = "dddd, MMMM dd, yyyy"
  3017.             EndIf
  3018.         Case 2
  3019.             $lngx = DllCall("kernel32.dll", "int", "GetLocaleInfoW", "dword", 1024, "dword", 31, "wstr", "", "int", 255)
  3020.             If NOT @error AND $lngx[0] <> 0 Then
  3021.                 $stempdate = $lngx[3]
  3022.             Else
  3023.                 $stempdate = "M/d/yyyy"
  3024.             EndIf
  3025.         Case 3
  3026.             If $astimepart[0] > 1 Then
  3027.                 $lngx = DllCall("kernel32.dll", "int", "GetLocaleInfoW", "dword", 1024, "dword", 4099, "wstr", "", "int", 255)
  3028.                 If NOT @error AND $lngx[0] <> 0 Then
  3029.                     $stemptime = $lngx[3]
  3030.                 Else
  3031.                     $stemptime = "h:mm:ss tt"
  3032.                 EndIf
  3033.             EndIf
  3034.         Case 4
  3035.             If $astimepart[0] > 1 Then
  3036.                 $stemptime = "hh:mm"
  3037.             EndIf
  3038.         Case 5
  3039.             If $astimepart[0] > 1 Then
  3040.                 $stemptime = "hh:mm:ss"
  3041.             EndIf
  3042.     EndSwitch
  3043.     If $stempdate <> "" Then
  3044.         $lngx = DllCall("kernel32.dll", "int", "GetLocaleInfoW", "dword", 1024, "dword", 29, "wstr", "", "int", 255)
  3045.         If NOT @error AND $lngx[0] <> 0 Then
  3046.             $stempdate = StringReplace($stempdate, "/", $lngx[3])
  3047.         EndIf
  3048.         Local $iwday = _datetodayofweek($asdatepart[1], $asdatepart[2], $asdatepart[3])
  3049.         $asdatepart[3] = StringRight("0" & $asdatepart[3], 2)
  3050.         $asdatepart[2] = StringRight("0" & $asdatepart[2], 2)
  3051.         $stempdate = StringReplace($stempdate, "d", "@")
  3052.         $stempdate = StringReplace($stempdate, "m", "#")
  3053.         $stempdate = StringReplace($stempdate, "y", "&")
  3054.         $stempdate = StringReplace($stempdate, "@@@@", _datedayofweek($iwday, 0))
  3055.         $stempdate = StringReplace($stempdate, "@@@", _datedayofweek($iwday, 1))
  3056.         $stempdate = StringReplace($stempdate, "@@", $asdatepart[3])
  3057.         $stempdate = StringReplace($stempdate, "@", StringReplace(StringLeft($asdatepart[3], 1), "0", "") & StringRight($asdatepart[3], 1))
  3058.         $stempdate = StringReplace($stempdate, "####", _datetomonth($asdatepart[2], 0))
  3059.         $stempdate = StringReplace($stempdate, "###", _datetomonth($asdatepart[2], 1))
  3060.         $stempdate = StringReplace($stempdate, "##", $asdatepart[2])
  3061.         $stempdate = StringReplace($stempdate, "#", StringReplace(StringLeft($asdatepart[2], 1), "0", "") & StringRight($asdatepart[2], 1))
  3062.         $stempdate = StringReplace($stempdate, "&&&&", $asdatepart[1])
  3063.         $stempdate = StringReplace($stempdate, "&&", StringRight($asdatepart[1], 2))
  3064.     EndIf
  3065.     If $stemptime <> "" Then
  3066.         $lngx = DllCall("kernel32.dll", "int", "GetLocaleInfoW", "dword", 1024, "dword", 40, "wstr", "", "int", 255)
  3067.         If NOT @error AND $lngx[0] <> 0 Then
  3068.             $sam = $lngx[3]
  3069.         Else
  3070.             $sam = "AM"
  3071.         EndIf
  3072.         $lngx = DllCall("kernel32.dll", "int", "GetLocaleInfoW", "dword", 1024, "dword", 41, "wstr", "", "int", 255)
  3073.         If NOT @error AND $lngx[0] <> 0 Then
  3074.             $spm = $lngx[3]
  3075.         Else
  3076.             $spm = "PM"
  3077.         EndIf
  3078.         $lngx = DllCall("kernel32.dll", "int", "GetLocaleInfoW", "dword", 1024, "dword", 30, "wstr", "", "int", 255)
  3079.         If NOT @error AND $lngx[0] <> 0 Then
  3080.             $stemptime = StringReplace($stemptime, ":", $lngx[3])
  3081.         EndIf
  3082.         If StringInStr($stemptime, "tt") Then
  3083.             If $astimepart[1] < 12 Then
  3084.                 $stemptime = StringReplace($stemptime, "tt", $sam)
  3085.                 If $astimepart[1] = 0 Then $astimepart[1] = 12
  3086.             Else
  3087.                 $stemptime = StringReplace($stemptime, "tt", $spm)
  3088.                 If $astimepart[1] > 12 Then $astimepart[1] = $astimepart[1] - 12
  3089.             EndIf
  3090.         EndIf
  3091.         $astimepart[1] = StringRight("0" & $astimepart[1], 2)
  3092.         $astimepart[2] = StringRight("0" & $astimepart[2], 2)
  3093.         $astimepart[3] = StringRight("0" & $astimepart[3], 2)
  3094.         $stemptime = StringReplace($stemptime, "hh", StringFormat("%02d", $astimepart[1]))
  3095.         $stemptime = StringReplace($stemptime, "h", StringReplace(StringLeft($astimepart[1], 1), "0", "") & StringRight($astimepart[1], 1))
  3096.         $stemptime = StringReplace($stemptime, "mm", StringFormat("%02d", $astimepart[2]))
  3097.         $stemptime = StringReplace($stemptime, "ss", StringFormat("%02d", $astimepart[3]))
  3098.         $stempdate = StringStripWS($stempdate & " " & $stemptime, 3)
  3099.     EndIf
  3100.     Return $stempdate
  3101. EndFunc
  3102.  
  3103. Func _datetimesplit($sdate, ByRef $asdatepart, ByRef $itimepart)
  3104.     Local $sdatetime = StringSplit($sdate, " T")
  3105.     If $sdatetime[0] > 0 Then $asdatepart = StringSplit($sdatetime[1], "/-.")
  3106.     If $sdatetime[0] > 1 Then
  3107.         $itimepart = StringSplit($sdatetime[2], ":")
  3108.         If UBound($itimepart) < 4 Then ReDim $itimepart[4]
  3109.     Else
  3110.         Dim $itimepart[4]
  3111.     EndIf
  3112.     If UBound($asdatepart) < 4 Then ReDim $asdatepart[4]
  3113.     For $x = 1 To 3
  3114.         If StringIsInt($asdatepart[$x]) Then
  3115.             $asdatepart[$x] = Number($asdatepart[$x])
  3116.         Else
  3117.             $asdatepart[$x] = -1
  3118.         EndIf
  3119.         If StringIsInt($itimepart[$x]) Then
  3120.             $itimepart[$x] = Number($itimepart[$x])
  3121.         Else
  3122.             $itimepart[$x] = 0
  3123.         EndIf
  3124.     Next
  3125.     Return 1
  3126. EndFunc
  3127.  
  3128. Func _datetodayofweek($iyear, $imonth, $iday)
  3129.     If NOT _dateisvalid($iyear & "/" & $imonth & "/" & $iday) Then
  3130.         Return SetError(1, 0, "")
  3131.     EndIf
  3132.     Local $i_afactor = Int((14 - $imonth) / 12)
  3133.     Local $i_yfactor = $iyear - $i_afactor
  3134.     Local $i_mfactor = $imonth + (12 * $i_afactor) - 2
  3135.     Local $i_dfactor = Mod($iday + $i_yfactor + Int($i_yfactor / 4) - Int($i_yfactor / 100) + Int($i_yfactor / 400) + Int((31 * $i_mfactor) / 12), 7)
  3136.     Return ($i_dfactor + 1)
  3137. EndFunc
  3138.  
  3139. Func _datetodayofweekiso($iyear, $imonth, $iday)
  3140.     Local $idow = _datetodayofweek($iyear, $imonth, $iday)
  3141.     If @error Then
  3142.         Return SetError(1, 0, "")
  3143.     EndIf
  3144.     If $idow >= 2 Then Return $idow - 1
  3145.     Return 7
  3146. EndFunc
  3147.  
  3148. Func _datetodayvalue($iyear, $imonth, $iday)
  3149.     If NOT _dateisvalid(StringFormat("%04d/%02d/%02d", $iyear, $imonth, $iday)) Then
  3150.         Return SetError(1, 0, "")
  3151.     EndIf
  3152.     If $imonth < 3 Then
  3153.         $imonth = $imonth + 12
  3154.         $iyear = $iyear - 1
  3155.     EndIf
  3156.     Local $i_afactor = Int($iyear / 100)
  3157.     Local $i_bfactor = Int($i_afactor / 4)
  3158.     Local $i_cfactor = 2 - $i_afactor + $i_bfactor
  3159.     Local $i_efactor = Int(1461 * ($iyear + 4716) / 4)
  3160.     Local $i_ffactor = Int(153 * ($imonth + 1) / 5)
  3161.     Local $ijuliandate = $i_cfactor + $iday + $i_efactor + $i_ffactor - 1524.5
  3162.     Return ($ijuliandate)
  3163. EndFunc
  3164.  
  3165. Func _datetomonth($imonth, $ishort = 0)
  3166.     Local $amonthnumber[13] = ["", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
  3167.     Local $amonthnumberabbrev[13] = ["", "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"]
  3168.     Select
  3169.         Case NOT StringIsInt($imonth)
  3170.             Return SetError(1, 0, "")
  3171.         Case $imonth < 1 OR $imonth > 12
  3172.             Return SetError(2, 0, "")
  3173.         Case Else
  3174.             Select
  3175.                 Case $ishort = 0
  3176.                     Return $amonthnumber[$imonth]
  3177.                 Case $ishort = 1
  3178.                     Return $amonthnumberabbrev[$imonth]
  3179.                 Case Else
  3180.                     Return SetError(3, 0, "")
  3181.             EndSelect
  3182.     EndSelect
  3183. EndFunc
  3184.  
  3185. Func _dayvaluetodate($ijuliandate, ByRef $iyear, ByRef $imonth, ByRef $iday)
  3186.     If $ijuliandate < 0 OR NOT IsNumber($ijuliandate) Then
  3187.         Return SetError(1, 0, 0)
  3188.     EndIf
  3189.     Local $i_zfactor = Int($ijuliandate + 0.5)
  3190.     Local $i_wfactor = Int(($i_zfactor - 1867216.25) / 36524.25)
  3191.     Local $i_xfactor = Int($i_wfactor / 4)
  3192.     Local $i_afactor = $i_zfactor + 1 + $i_wfactor - $i_xfactor
  3193.     Local $i_bfactor = $i_afactor + 1524
  3194.     Local $i_cfactor = Int(($i_bfactor - 122.1) / 365.25)
  3195.     Local $i_dfactor = Int(365.25 * $i_cfactor)
  3196.     Local $i_efactor = Int(($i_bfactor - $i_dfactor) / 30.6001)
  3197.     Local $i_ffactor = Int(30.6001 * $i_efactor)
  3198.     $iday = $i_bfactor - $i_dfactor - $i_ffactor
  3199.     If $i_efactor - 1 < 13 Then
  3200.         $imonth = $i_efactor - 1
  3201.     Else
  3202.         $imonth = $i_efactor - 13
  3203.     EndIf
  3204.     If $imonth < 3 Then
  3205.         $iyear = $i_cfactor - 4715
  3206.     Else
  3207.         $iyear = $i_cfactor - 4716
  3208.     EndIf
  3209.     $iyear = StringFormat("%04d", $iyear)
  3210.     $imonth = StringFormat("%02d", $imonth)
  3211.     $iday = StringFormat("%02d", $iday)
  3212.     Return $iyear & "/" & $imonth & "/" & $iday
  3213. EndFunc
  3214.  
  3215. Func _date_juliandayno($iyear, $imonth, $iday)
  3216.     Local $sfulldate = StringFormat("%04d/%02d/%02d", $iyear, $imonth, $iday)
  3217.     If NOT _dateisvalid($sfulldate) Then
  3218.         Return SetError(1, 0, "")
  3219.     EndIf
  3220.     Local $ijday = 0
  3221.     Local $aidaysinmonth = _daysinmonth($iyear)
  3222.     For $icntr = 1 To $imonth - 1
  3223.         $ijday = $ijday + $aidaysinmonth[$icntr]
  3224.     Next
  3225.     $ijday = ($iyear * 1000) + ($ijday + $iday)
  3226.     Return $ijday
  3227. EndFunc
  3228.  
  3229. Func _juliantodate($ijday, $ssep = "/")
  3230.     Local $iyear = Int($ijday / 1000)
  3231.     Local $idays = Mod($ijday, 1000)
  3232.     Local $imaxdays = 365
  3233.     If _dateisleapyear($iyear) Then $imaxdays = 366
  3234.     If $idays > $imaxdays Then
  3235.         Return SetError(1, 0, "")
  3236.     EndIf
  3237.     Local $aidaysinmonth = _daysinmonth($iyear)
  3238.     Local $imonth = 1
  3239.     While $idays > $aidaysinmonth[$imonth]
  3240.         $idays = $idays - $aidaysinmonth[$imonth]
  3241.         $imonth = $imonth + 1
  3242.     WEnd
  3243.     Return StringFormat("%04d%s%02d%s%02d", $iyear, $ssep, $imonth, $ssep, $idays)
  3244. EndFunc
  3245.  
  3246. Func _now()
  3247.     Return (_datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, 0))
  3248. EndFunc
  3249.  
  3250. Func _nowcalc()
  3251.     Return (@YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC)
  3252. EndFunc
  3253.  
  3254. Func _nowcalcdate()
  3255.     Return (@YEAR & "/" & @MON & "/" & @MDAY)
  3256. EndFunc
  3257.  
  3258. Func _nowdate()
  3259.     Return (_datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY, 0))
  3260. EndFunc
  3261.  
  3262. Func _nowtime($stype = 3)
  3263.     If $stype < 3 OR $stype > 5 Then $stype = 3
  3264.     Return (_datetimeformat(@YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, $stype))
  3265. EndFunc
  3266.  
  3267. Func _setdate($iday, $imonth = 0, $iyear = 0)
  3268.     If $iyear = 0 Then $iyear = @YEAR
  3269.     If $imonth = 0 Then $imonth = @MON
  3270.     If NOT _dateisvalid($iyear & "/" & $imonth & "/" & $iday) Then Return 1
  3271.     Local $tsystemtime = DllStructCreate($tagsystemtime)
  3272.     DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsystemtime)
  3273.     If @error Then Return SetError(@error, @extended, 0)
  3274.     DllStructSetData($tsystemtime, 4, $iday)
  3275.     If $imonth > 0 Then DllStructSetData($tsystemtime, 2, $imonth)
  3276.     If $iyear > 0 Then DllStructSetData($tsystemtime, 1, $iyear)
  3277.     Local $iretval = _date_time_setlocaltime($tsystemtime)
  3278.     If @error Then Return SetError(@error + 10, @extended, 0)
  3279.     Return Int($iretval)
  3280. EndFunc
  3281.  
  3282. Func _settime($ihour, $iminute, $isecond = 0)
  3283.     If $ihour < 0 OR $ihour > 23 Then Return 1
  3284.     If $iminute < 0 OR $iminute > 59 Then Return 1
  3285.     If $isecond < 0 OR $isecond > 59 Then Return 1
  3286.     Local $tsystemtime = DllStructCreate($tagsystemtime)
  3287.     DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsystemtime)
  3288.     If @error Then Return SetError(@error, @extended, 0)
  3289.     DllStructSetData($tsystemtime, 5, $ihour)
  3290.     DllStructSetData($tsystemtime, 6, $iminute)
  3291.     If $isecond > 0 Then DllStructSetData($tsystemtime, 7, $isecond)
  3292.     Local $iretval = _date_time_setlocaltime($tsystemtime)
  3293.     If @error Then Return SetError(@error + 10, @extended, 0)
  3294.     Return Int($iretval)
  3295. EndFunc
  3296.  
  3297. Func _tickstotime($iticks, ByRef $ihours, ByRef $imins, ByRef $isecs)
  3298.     If Number($iticks) > 0 Then
  3299.         $iticks = Int($iticks / 1000)
  3300.         $ihours = Int($iticks / 3600)
  3301.         $iticks = Mod($iticks, 3600)
  3302.         $imins = Int($iticks / 60)
  3303.         $isecs = Mod($iticks, 60)
  3304.         Return 1
  3305.     ElseIf Number($iticks) = 0 Then
  3306.         $ihours = 0
  3307.         $iticks = 0
  3308.         $imins = 0
  3309.         $isecs = 0
  3310.         Return 1
  3311.     Else
  3312.         Return SetError(1, 0, 0)
  3313.     EndIf
  3314. EndFunc
  3315.  
  3316. Func _timetoticks($ihours = @HOUR, $imins = @MIN, $isecs = @SEC)
  3317.     If StringIsInt($ihours) AND StringIsInt($imins) AND StringIsInt($isecs) Then
  3318.         Local $iticks = 1000 * ((3600 * $ihours) + (60 * $imins) + $isecs)
  3319.         Return $iticks
  3320.     Else
  3321.         Return SetError(1, 0, 0)
  3322.     EndIf
  3323. EndFunc
  3324.  
  3325. Func _weeknumberiso($iyear = @YEAR, $imonth = @MON, $iday = @MDAY)
  3326.     If $iday > 31 OR $iday < 1 Then
  3327.         Return SetError(1, 0, -1)
  3328.     ElseIf $imonth > 12 OR $imonth < 1 Then
  3329.         Return SetError(2, 0, -1)
  3330.     ElseIf $iyear < 1 OR $iyear > 2999 Then
  3331.         Return SetError(3, 0, -1)
  3332.     EndIf
  3333.     Local $idow = _datetodayofweekiso($iyear, $imonth, $iday) - 1
  3334.     Local $idow0101 = _datetodayofweekiso($iyear, 1, 1) - 1
  3335.     If ($imonth = 1 AND 3 < $idow0101 AND $idow0101 < 7 - ($iday - 1)) Then
  3336.         $idow = $idow0101 - 1
  3337.         $idow0101 = _datetodayofweekiso($iyear - 1, 1, 1) - 1
  3338.         $imonth = 12
  3339.         $iday = 31
  3340.         $iyear = $iyear - 1
  3341.     ElseIf ($imonth = 12 AND 30 - ($iday - 1) < _datetodayofweekiso($iyear + 1, 1, 1) - 1 AND _datetodayofweekiso($iyear + 1, 1, 1) - 1 < 4) Then
  3342.         Return 1
  3343.     EndIf
  3344.     Return Int((_datetodayofweekiso($iyear, 1, 1) - 1 < 4) + 4 * ($imonth - 1) + (2 * ($imonth - 1) + ($iday - 1) + $idow0101 - $idow + 6) * 36 / 256)
  3345. EndFunc
  3346.  
  3347. Func _weeknumber($iyear = @YEAR, $imonth = @MON, $iday = @MDAY, $iweekstart = 1)
  3348.     If $iday > 31 OR $iday < 1 Then
  3349.         Return SetError(1, 0, -1)
  3350.     ElseIf $imonth > 12 OR $imonth < 1 Then
  3351.         Return SetError(3, 0, -1)
  3352.     ElseIf $iyear < 1 OR $iyear > 2999 Then
  3353.         Return SetError(4, 0, -1)
  3354.     ElseIf $iweekstart < 1 OR $iweekstart > 2 Then
  3355.         Return SetError(2, 0, -1)
  3356.     EndIf
  3357.     Local $istartweek1, $iendweek1
  3358.     Local $idow0101 = _datetodayofweekiso($iyear, 1, 1)
  3359.     Local $idate = $iyear & "/" & $imonth & "/" & $iday
  3360.     If $iweekstart = 1 Then
  3361.         If $idow0101 = 6 Then
  3362.             $istartweek1 = 0
  3363.         Else
  3364.             $istartweek1 = -1 * $idow0101 - 1
  3365.         EndIf
  3366.         $iendweek1 = $istartweek1 + 6
  3367.     Else
  3368.         $istartweek1 = $idow0101 * -1
  3369.         $iendweek1 = $istartweek1 + 6
  3370.     EndIf
  3371.     Local $istartweek1ny
  3372.     Local $iendweek1date = _dateadd("d", $iendweek1, $iyear & "/01/01")
  3373.     Local $idow0101ny = _datetodayofweekiso($iyear + 1, 1, 1)
  3374.     If $iweekstart = 1 Then
  3375.         If $idow0101ny = 6 Then
  3376.             $istartweek1ny = 0
  3377.         Else
  3378.             $istartweek1ny = -1 * $idow0101ny - 1
  3379.         EndIf
  3380.     Else
  3381.         $istartweek1ny = $idow0101ny * -1
  3382.     EndIf
  3383.     Local $istartweek1dateny = _dateadd("d", $istartweek1ny, $iyear + 1 & "/01/01")
  3384.     Local $icurrdatediff = _datediff("d", $iendweek1date, $idate) - 1
  3385.     Local $icurrdatediffny = _datediff("d", $istartweek1dateny, $idate)
  3386.     If $icurrdatediff >= 0 AND $icurrdatediffny < 0 Then Return 2 + Int($icurrdatediff / 7)
  3387.     If $icurrdatediff < 0 OR $icurrdatediffny >= 0 Then Return 1
  3388. EndFunc
  3389.  
  3390. Func _daysinmonth($iyear)
  3391.     Local $aidays[13] = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
  3392.     If _dateisleapyear($iyear) Then $aidays[2] = 29
  3393.     Return $aidays
  3394. EndFunc
  3395.  
  3396. Func __date_time_clonesystemtime($psystemtime)
  3397.     Local $tsystemtime1 = DllStructCreate($tagsystemtime, $psystemtime)
  3398.     Local $tsystemtime2 = DllStructCreate($tagsystemtime)
  3399.     DllStructSetData($tsystemtime2, "Month", DllStructGetData($tsystemtime1, "Month"))
  3400.     DllStructSetData($tsystemtime2, "Day", DllStructGetData($tsystemtime1, "Day"))
  3401.     DllStructSetData($tsystemtime2, "Year", DllStructGetData($tsystemtime1, "Year"))
  3402.     DllStructSetData($tsystemtime2, "Hour", DllStructGetData($tsystemtime1, "Hour"))
  3403.     DllStructSetData($tsystemtime2, "Minute", DllStructGetData($tsystemtime1, "Minute"))
  3404.     DllStructSetData($tsystemtime2, "Second", DllStructGetData($tsystemtime1, "Second"))
  3405.     DllStructSetData($tsystemtime2, "MSeconds", DllStructGetData($tsystemtime1, "MSeconds"))
  3406.     DllStructSetData($tsystemtime2, "DOW", DllStructGetData($tsystemtime1, "DOW"))
  3407.     Return $tsystemtime2
  3408. EndFunc
  3409.  
  3410. Func _date_time_comparefiletime($pfiletime1, $pfiletime2)
  3411.     Local $aresult = DllCall("kernel32.dll", "long", "CompareFileTime", "ptr", $pfiletime1, "ptr", $pfiletime2)
  3412.     If @error Then Return SetError(@error, @extended, 0)
  3413.     Return $aresult[0]
  3414. EndFunc
  3415.  
  3416. Func _date_time_dosdatetimetofiletime($ifatdate, $ifattime)
  3417.     Local $ttime = DllStructCreate($tagfiletime)
  3418.     Local $aresult = DllCall("kernel32.dll", "bool", "DosDateTimeToFileTime", "word", $ifatdate, "word", $ifattime, "struct*", $ttime)
  3419.     If @error Then Return SetError(@error, @extended, 0)
  3420.     Return SetExtended($aresult[0], $ttime)
  3421. EndFunc
  3422.  
  3423. Func _date_time_dosdatetoarray($idosdate)
  3424.     Local $adate[3]
  3425.     $adate[0] = BitAND($idosdate, 31)
  3426.     $adate[1] = BitAND(BitShift($idosdate, 5), 15)
  3427.     $adate[2] = BitAND(BitShift($idosdate, 9), 63) + 1980
  3428.     Return $adate
  3429. EndFunc
  3430.  
  3431. Func _date_time_dosdatetimetoarray($idosdate, $idostime)
  3432.     Local $adate[6]
  3433.     $adate[0] = BitAND($idosdate, 31)
  3434.     $adate[1] = BitAND(BitShift($idosdate, 5), 15)
  3435.     $adate[2] = BitAND(BitShift($idosdate, 9), 63) + 1980
  3436.     $adate[5] = BitAND($idostime, 31) * 2
  3437.     $adate[4] = BitAND(BitShift($idostime, 5), 63)
  3438.     $adate[3] = BitAND(BitShift($idostime, 11), 31)
  3439.     Return $adate
  3440. EndFunc
  3441.  
  3442. Func _date_time_dosdatetimetostr($idosdate, $idostime)
  3443.     Local $adate = _date_time_dosdatetimetoarray($idosdate, $idostime)
  3444.     Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $adate[0], $adate[1], $adate[2], $adate[3], $adate[4], $adate[5])
  3445. EndFunc
  3446.  
  3447. Func _date_time_dosdatetostr($idosdate)
  3448.     Local $adate = _date_time_dosdatetoarray($idosdate)
  3449.     Return StringFormat("%02d/%02d/%04d", $adate[0], $adate[1], $adate[2])
  3450. EndFunc
  3451.  
  3452. Func _date_time_dostimetoarray($idostime)
  3453.     Local $atime[3]
  3454.     $atime[2] = BitAND($idostime, 31) * 2
  3455.     $atime[1] = BitAND(BitShift($idostime, 5), 63)
  3456.     $atime[0] = BitAND(BitShift($idostime, 11), 31)
  3457.     Return $atime
  3458. EndFunc
  3459.  
  3460. Func _date_time_dostimetostr($idostime)
  3461.     Local $atime = _date_time_dostimetoarray($idostime)
  3462.     Return StringFormat("%02d:%02d:%02d", $atime[0], $atime[1], $atime[2])
  3463. EndFunc
  3464.  
  3465. Func _date_time_encodefiletime($imonth, $iday, $iyear, $ihour = 0, $iminute = 0, $isecond = 0, $imseconds = 0)
  3466.     Local $tsystemtime = _date_time_encodesystemtime($imonth, $iday, $iyear, $ihour, $iminute, $isecond, $imseconds)
  3467.     Return _date_time_systemtimetofiletime($tsystemtime)
  3468. EndFunc
  3469.  
  3470. Func _date_time_encodesystemtime($imonth, $iday, $iyear, $ihour = 0, $iminute = 0, $isecond = 0, $imseconds = 0)
  3471.     Local $tsystemtime = DllStructCreate($tagsystemtime)
  3472.     DllStructSetData($tsystemtime, "Month", $imonth)
  3473.     DllStructSetData($tsystemtime, "Day", $iday)
  3474.     DllStructSetData($tsystemtime, "Year", $iyear)
  3475.     DllStructSetData($tsystemtime, "Hour", $ihour)
  3476.     DllStructSetData($tsystemtime, "Minute", $iminute)
  3477.     DllStructSetData($tsystemtime, "Second", $isecond)
  3478.     DllStructSetData($tsystemtime, "MSeconds", $imseconds)
  3479.     Return $tsystemtime
  3480. EndFunc
  3481.  
  3482. Func _date_time_filetimetoarray(ByRef $tfiletime)
  3483.     If ((DllStructGetData($tfiletime, 1) + DllStructGetData($tfiletime, 2)) = 0) Then Return SetError(10, 0, 0)
  3484.     Local $tsystemtime = _date_time_filetimetosystemtime($tfiletime)
  3485.     If @error Then Return SetError(@error, @extended, 0)
  3486.     Return _date_time_systemtimetoarray($tsystemtime)
  3487. EndFunc
  3488.  
  3489. Func _date_time_filetimetostr(ByRef $tfiletime, $bfmt = 0)
  3490.     Local $adate = _date_time_filetimetoarray($tfiletime)
  3491.     If @error Then Return SetError(@error, @extended, "")
  3492.     If $bfmt Then
  3493.         Return StringFormat("%04d/%02d/%02d %02d:%02d:%02d", $adate[2], $adate[0], $adate[1], $adate[3], $adate[4], $adate[5])
  3494.     Else
  3495.         Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $adate[0], $adate[1], $adate[2], $adate[3], $adate[4], $adate[5])
  3496.     EndIf
  3497. EndFunc
  3498.  
  3499. Func _date_time_filetimetodosdatetime($pfiletime)
  3500.     Local $adate[2]
  3501.     Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToDosDateTime", "ptr", $pfiletime, "word*", 0, "word*", 0)
  3502.     If @error Then Return SetError(@error, @extended, $adate)
  3503.     $adate[0] = $aresult[2]
  3504.     $adate[1] = $aresult[3]
  3505.     Return SetExtended($aresult[0], $adate)
  3506. EndFunc
  3507.  
  3508. Func _date_time_filetimetolocalfiletime($pfiletime)
  3509.     Local $tlocal = DllStructCreate($tagfiletime)
  3510.     Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToLocalFileTime", "struct*", $pfiletime, "struct*", $tlocal)
  3511.     If @error Then Return SetError(@error, @extended, 0)
  3512.     Return SetExtended($aresult[0], $tlocal)
  3513. EndFunc
  3514.  
  3515. Func _date_time_filetimetosystemtime($pfiletime)
  3516.     Local $tsysttime = DllStructCreate($tagsystemtime)
  3517.     Local $aresult = DllCall("kernel32.dll", "bool", "FileTimeToSystemTime", "struct*", $pfiletime, "struct*", $tsysttime)
  3518.     If @error Then Return SetError(@error, @extended, 0)
  3519.     Return SetExtended($aresult[0], $tsysttime)
  3520. EndFunc
  3521.  
  3522. Func _date_time_getfiletime($hfile)
  3523.     Local $adate[3]
  3524.     $adate[0] = DllStructCreate($tagfiletime)
  3525.     $adate[1] = DllStructCreate($tagfiletime)
  3526.     $adate[2] = DllStructCreate($tagfiletime)
  3527.     Local $aresult = DllCall("Kernel32.dll", "bool", "GetFileTime", "handle", $hfile, "struct*", $adate[0], "struct*", $adate[1], "struct*", $adate[2])
  3528.     If @error Then Return SetError(@error, @extended, 0)
  3529.     Return SetExtended($aresult[0], $adate)
  3530. EndFunc
  3531.  
  3532. Func _date_time_getlocaltime()
  3533.     Local $tsysttime = DllStructCreate($tagsystemtime)
  3534.     DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tsysttime)
  3535.     If @error Then Return SetError(@error, @extended, 0)
  3536.     Return $tsysttime
  3537. EndFunc
  3538.  
  3539. Func _date_time_getsystemtime()
  3540.     Local $tsysttime = DllStructCreate($tagsystemtime)
  3541.     DllCall("kernel32.dll", "none", "GetSystemTime", "struct*", $tsysttime)
  3542.     If @error Then Return SetError(@error, @extended, 0)
  3543.     Return $tsysttime
  3544. EndFunc
  3545.  
  3546. Func _date_time_getsystemtimeadjustment()
  3547.     Local $ainfo[3]
  3548.     Local $aresult = DllCall("kernel32.dll", "bool", "GetSystemTimeAdjustment", "dword*", 0, "dword*", 0, "bool*", 0)
  3549.     If @error Then Return SetError(@error, @extended, 0)
  3550.     $ainfo[0] = $aresult[1]
  3551.     $ainfo[1] = $aresult[2]
  3552.     $ainfo[2] = $aresult[3] <> 0
  3553.     Return SetExtended($aresult[0], $ainfo)
  3554. EndFunc
  3555.  
  3556. Func _date_time_getsystemtimeasfiletime()
  3557.     Local $tfiletime = DllStructCreate($tagfiletime)
  3558.     DllCall("kernel32.dll", "none", "GetSystemTimeAsFileTime", "struct*", $tfiletime)
  3559.     If @error Then Return SetError(@error, @extended, 0)
  3560.     Return $tfiletime
  3561. EndFunc
  3562.  
  3563. Func _date_time_getsystemtimes()
  3564.     Local $ainfo[3]
  3565.     $ainfo[0] = DllStructCreate($tagfiletime)
  3566.     $ainfo[1] = DllStructCreate($tagfiletime)
  3567.     $ainfo[2] = DllStructCreate($tagfiletime)
  3568.     Local $aresult = DllCall("kernel32.dll", "bool", "GetSystemTimes", "struct*", $ainfo[0], "struct*", $ainfo[1], "struct*", $ainfo[2])
  3569.     If @error Then Return SetError(@error, @extended, 0)
  3570.     Return SetExtended($aresult[0], $ainfo)
  3571. EndFunc
  3572.  
  3573. Func _date_time_gettickcount()
  3574.     Local $aresult = DllCall("kernel32.dll", "dword", "GetTickCount")
  3575.     If @error Then Return SetError(@error, @extended, 0)
  3576.     Return $aresult[0]
  3577. EndFunc
  3578.  
  3579. Func _date_time_gettimezoneinformation()
  3580.     Local $ttimezone = DllStructCreate($tagtime_zone_information)
  3581.     Local $aresult = DllCall("kernel32.dll", "dword", "GetTimeZoneInformation", "struct*", $ttimezone)
  3582.     If @error OR $aresult[0] = -1 Then Return SetError(@error, @extended, 0)
  3583.     Local $ainfo[8]
  3584.     $ainfo[0] = $aresult[0]
  3585.     $ainfo[1] = DllStructGetData($ttimezone, "Bias")
  3586.     $ainfo[2] = _winapi_widechartomultibyte(DllStructGetPtr($ttimezone, "StdName"))
  3587.     $ainfo[3] = __date_time_clonesystemtime(DllStructGetPtr($ttimezone, "StdDate"))
  3588.     $ainfo[4] = DllStructGetData($ttimezone, "StdBias")
  3589.     $ainfo[5] = _winapi_widechartomultibyte(DllStructGetPtr($ttimezone, "DayName"))
  3590.     $ainfo[6] = __date_time_clonesystemtime(DllStructGetPtr($ttimezone, "DayDate"))
  3591.     $ainfo[7] = DllStructGetData($ttimezone, "DayBias")
  3592.     Return $ainfo
  3593. EndFunc
  3594.  
  3595. Func _date_time_localfiletimetofiletime($plocaltime)
  3596.     Local $tfiletime = DllStructCreate($tagfiletime)
  3597.     Local $aresult = DllCall("kernel32.dll", "bool", "LocalFileTimeToFileTime", "ptr", $plocaltime, "struct*", $tfiletime)
  3598.     If @error Then Return SetError(@error, @extended, 0)
  3599.     Return SetExtended($aresult[0], $tfiletime)
  3600. EndFunc
  3601.  
  3602. Func _date_time_setfiletime($hfile, $pcreatetime, $plastaccess, $plastwrite)
  3603.     Local $aresult = DllCall("kernel32.dll", "bool", "SetFileTime", "handle", $hfile, "ptr", $pcreatetime, "ptr", $plastaccess, "ptr", $plastwrite)
  3604.     If @error Then Return SetError(@error, @extended, False)
  3605.     Return $aresult[0]
  3606. EndFunc
  3607.  
  3608. Func _date_time_setlocaltime($psystemtime)
  3609.     Local $aresult = DllCall("kernel32.dll", "bool", "SetLocalTime", "struct*", $psystemtime)
  3610.     If @error OR NOT $aresult[0] Then Return SetError(@error + 10, @extended, False)
  3611.     $aresult = DllCall("kernel32.dll", "bool", "SetLocalTime", "struct*", $psystemtime)
  3612.     If @error Then Return SetError(@error, @extended, False)
  3613.     Return $aresult[0]
  3614. EndFunc
  3615.  
  3616. Func _date_time_setsystemtime($psystemtime)
  3617.     Local $aresult = DllCall("kernel32.dll", "bool", "SetSystemTime", "ptr", $psystemtime)
  3618.     If @error Then Return SetError(@error, @extended, False)
  3619.     Return $aresult[0]
  3620. EndFunc
  3621.  
  3622. Func _date_time_setsystemtimeadjustment($iadjustment, $fdisabled)
  3623.     Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
  3624.     If @error Then Return SetError(@error + 10, @extended, False)
  3625.     _security__setprivilege($htoken, "SeSystemtimePrivilege", True)
  3626.     Local $ierror = @error
  3627.     Local $ilasterror = @extended
  3628.     Local $iret = False
  3629.     If NOT @error Then
  3630.         Local $aresult = DllCall("kernel32.dll", "bool", "SetSystemTimeAdjustment", "dword", $iadjustment, "bool", $fdisabled)
  3631.         If @error Then
  3632.             $ierror = @error
  3633.             $ilasterror = @extended
  3634.         ElseIf $aresult[0] Then
  3635.             $iret = True
  3636.         Else
  3637.             $ierror = 20
  3638.             $ilasterror = _winapi_getlasterror()
  3639.         EndIf
  3640.         _security__setprivilege($htoken, "SeSystemtimePrivilege", False)
  3641.         If NOT $ierror AND @error Then $ierror = 22
  3642.     EndIf
  3643.     _winapi_closehandle($htoken)
  3644.     Return SetError($ierror, $ilasterror, $iret)
  3645. EndFunc
  3646.  
  3647. Func _date_time_settimezoneinformation($ibias, $sstdname, $tstddate, $istdbias, $sdayname, $tdaydate, $idaybias)
  3648.     Local $tstdname = _winapi_multibytetowidechar($sstdname)
  3649.     Local $tdayname = _winapi_multibytetowidechar($sdayname)
  3650.     Local $tzoneinfo = DllStructCreate($tagtime_zone_information)
  3651.     DllStructSetData($tzoneinfo, "Bias", $ibias)
  3652.     DllStructSetData($tzoneinfo, "StdName", DllStructGetData($tstdname, 1))
  3653.     _memmovememory($tstddate, DllStructGetPtr($tzoneinfo, "StdDate"), DllStructGetSize($tstddate))
  3654.     DllStructSetData($tzoneinfo, "StdBias", $istdbias)
  3655.     DllStructSetData($tzoneinfo, "DayName", DllStructGetData($tdayname, 1))
  3656.     _memmovememory($tdaydate, DllStructGetPtr($tzoneinfo, "DayDate"), DllStructGetSize($tdaydate))
  3657.     DllStructSetData($tzoneinfo, "DayBias", $idaybias)
  3658.     Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
  3659.     If @error Then Return SetError(@error + 10, @extended, False)
  3660.     _security__setprivilege($htoken, "SeSystemtimePrivilege", True)
  3661.     Local $ierror = @error
  3662.     Local $ilasterror = @extended
  3663.     Local $iret = False
  3664.     If NOT @error Then
  3665.         Local $aresult = DllCall("kernel32.dll", "bool", "SetTimeZoneInformation", "struct*", $tzoneinfo)
  3666.         If @error Then
  3667.             $ierror = @error
  3668.             $ilasterror = @extended
  3669.         ElseIf $aresult[0] Then
  3670.             $ilasterror = 0
  3671.             $iret = True
  3672.         Else
  3673.             $ierror = 20
  3674.             $ilasterror = _winapi_getlasterror()
  3675.         EndIf
  3676.         _security__setprivilege($htoken, "SeSystemtimePrivilege", False)
  3677.         If NOT $ierror AND @error Then $ierror = 22
  3678.     EndIf
  3679.     _winapi_closehandle($htoken)
  3680.     Return SetError($ierror, $ilasterror, $iret)
  3681. EndFunc
  3682.  
  3683. Func _date_time_systemtimetoarray(ByRef $tsystemtime)
  3684.     Local $ainfo[8]
  3685.     $ainfo[0] = DllStructGetData($tsystemtime, "Month")
  3686.     $ainfo[1] = DllStructGetData($tsystemtime, "Day")
  3687.     $ainfo[2] = DllStructGetData($tsystemtime, "Year")
  3688.     $ainfo[3] = DllStructGetData($tsystemtime, "Hour")
  3689.     $ainfo[4] = DllStructGetData($tsystemtime, "Minute")
  3690.     $ainfo[5] = DllStructGetData($tsystemtime, "Second")
  3691.     $ainfo[6] = DllStructGetData($tsystemtime, "MSeconds")
  3692.     $ainfo[7] = DllStructGetData($tsystemtime, "DOW")
  3693.     Return $ainfo
  3694. EndFunc
  3695.  
  3696. Func _date_time_systemtimetodatestr(ByRef $tsystemtime, $bfmt = 0)
  3697.     Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
  3698.     If @error Then Return SetError(@error, @extended, "")
  3699.     If $bfmt Then
  3700.         Return StringFormat("%04d/%02d/%02d", $ainfo[2], $ainfo[0], $ainfo[1])
  3701.     Else
  3702.         Return StringFormat("%02d/%02d/%04d", $ainfo[0], $ainfo[1], $ainfo[2])
  3703.     EndIf
  3704. EndFunc
  3705.  
  3706. Func _date_time_systemtimetodatetimestr(ByRef $tsystemtime, $bfmt = 0)
  3707.     Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
  3708.     If @error Then Return SetError(@error, @extended, "")
  3709.     If $bfmt Then
  3710.         Return StringFormat("%04d/%02d/%02d %02d:%02d:%02d", $ainfo[2], $ainfo[0], $ainfo[1], $ainfo[3], $ainfo[4], $ainfo[5])
  3711.     Else
  3712.         Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $ainfo[0], $ainfo[1], $ainfo[2], $ainfo[3], $ainfo[4], $ainfo[5])
  3713.     EndIf
  3714. EndFunc
  3715.  
  3716. Func _date_time_systemtimetofiletime($psystemtime)
  3717.     Local $tfiletime = DllStructCreate($tagfiletime)
  3718.     Local $aresult = DllCall("kernel32.dll", "bool", "SystemTimeToFileTime", "struct*", $psystemtime, "struct*", $tfiletime)
  3719.     If @error Then Return SetError(@error, @extended, 0)
  3720.     Return SetExtended($aresult[0], $tfiletime)
  3721. EndFunc
  3722.  
  3723. Func _date_time_systemtimetotimestr(ByRef $tsystemtime)
  3724.     Local $ainfo = _date_time_systemtimetoarray($tsystemtime)
  3725.     Return StringFormat("%02d:%02d:%02d", $ainfo[3], $ainfo[4], $ainfo[5])
  3726. EndFunc
  3727.  
  3728. Func _date_time_systemtimetotzspecificlocaltime($putc, $ptimezone = 0)
  3729.     Local $tlocaltime = DllStructCreate($tagsystemtime)
  3730.     Local $aresult = DllCall("kernel32.dll", "bool", "SystemTimeToTzSpecificLocalTime", "ptr", $ptimezone, "ptr", $putc, "struct*", $tlocaltime)
  3731.     If @error Then Return SetError(@error, @extended, 0)
  3732.     Return SetExtended($aresult[0], $tlocaltime)
  3733. EndFunc
  3734.  
  3735. Func _date_time_tzspecificlocaltimetosystemtime($plocaltime, $ptimezone = 0)
  3736.     Local $tutc = DllStructCreate($tagsystemtime)
  3737.     Local $aresult = DllCall("kernel32.dll", "ptr", "TzSpecificLocalTimeToSystemTime", "ptr", $ptimezone, "ptr", $plocaltime, "struct*", $tutc)
  3738.     If @error Then Return SetError(@error, @extended, 0)
  3739.     Return SetExtended($aresult[0], $tutc)
  3740. EndFunc
  3741.  
  3742. Global $__ghwininet_ftp = -1
  3743. Global $__ghcallback_ftp, $__gbcallback_set = False
  3744. Global Const $internet_open_type_direct = 1
  3745. Global Const $internet_open_type_preconfig = 0
  3746. Global Const $internet_open_type_preconfig_with_no_autoproxy = 4
  3747. Global Const $internet_open_type_proxy = 3
  3748. Global Const $ftp_transfer_type_unknown = 0
  3749. Global Const $ftp_transfer_type_ascii = 1
  3750. Global Const $ftp_transfer_type_binary = 2
  3751. Global Const $internet_flag_passive = 134217728
  3752. Global Const $internet_flag_transfer_ascii = $ftp_transfer_type_ascii
  3753. Global Const $internet_flag_transfer_binary = $ftp_transfer_type_binary
  3754. Global Const $internet_default_ftp_port = 21
  3755. Global Const $internet_service_ftp = 1
  3756. Global Const $internet_flag_hyperlink = 1024
  3757. Global Const $internet_flag_need_file = 16
  3758. Global Const $internet_flag_no_cache_write = 67108864
  3759. Global Const $internet_flag_reload = -2147483648
  3760. Global Const $internet_flag_resynchronize = 2048
  3761. Global Const $internet_flag_async = 268435456
  3762. Global Const $internet_flag_from_cache = 16777216
  3763. Global Const $internet_flag_offline = $internet_flag_from_cache
  3764. Global Const $internet_status_closing_connection = 50
  3765. Global Const $internet_status_connection_closed = 51
  3766. Global Const $internet_status_connecting_to_server = 20
  3767. Global Const $internet_status_connected_to_server = 21
  3768. Global Const $internet_status_ctl_response_received = 42
  3769. Global Const $internet_status_intermediate_response = 120
  3770. Global Const $internet_status_prefetch = 43
  3771. Global Const $internet_status_redirect = 110
  3772. Global Const $internet_status_request_complete = 100
  3773. Global Const $internet_status_handle_created = 60
  3774. Global Const $internet_status_handle_closing = 70
  3775. Global Const $internet_status_sending_request = 30
  3776. Global Const $internet_status_request_sent = 31
  3777. Global Const $internet_status_receiving_response = 40
  3778. Global Const $internet_status_response_received = 41
  3779. Global Const $internet_status_state_change = 200
  3780. Global Const $internet_status_resolving_name = 10
  3781. Global Const $internet_status_name_resolved = 11
  3782.  
  3783. Func _ftp_close($l_internetsession)
  3784.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  3785.     Local $ai_internetclosehandle = DllCall($__ghwininet_ftp, "bool", "InternetCloseHandle", "handle", $l_internetsession)
  3786.     If @error OR $ai_internetclosehandle[0] = 0 Then Return SetError(-1, _winapi_getlasterror(), 0)
  3787.     If $__gbcallback_set = True Then DllCallbackFree($__ghcallback_ftp)
  3788.     Return $ai_internetclosehandle[0]
  3789. EndFunc
  3790.  
  3791. Func _ftp_command($l_ftpsession, $s_ftpcommand, $l_flags = $ftp_transfer_type_ascii, $l_expectresponse = 0, $l_context = 0)
  3792.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  3793.     Local $ai_ftpcommand = DllCall($__ghwininet_ftp, "bool", "FtpCommandW", "handle", $l_ftpsession, "bool", $l_expectresponse, "dword", $l_flags, "wstr", $s_ftpcommand, "dword_ptr", $l_context, "ptr*", 0)
  3794.     If @error OR $ai_ftpcommand[0] = 0 Then Return SetError(-1, _winapi_getlasterror(), 0)
  3795.     Return SetError(0, $ai_ftpcommand[6], $ai_ftpcommand[0])
  3796. EndFunc
  3797.  
  3798. Func _ftp_connect($l_internetsession, $s_servername, $s_username, $s_password, $i_passive = 0, $i_serverport = 0, $l_service = $internet_service_ftp, $l_flags = 0, $l_context = 0)
  3799.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  3800.     If $i_passive == 1 Then $l_flags = BitOR($l_flags, $internet_flag_passive)
  3801.     Local $ai_internetconnect = DllCall($__ghwininet_ftp, "hwnd", "InternetConnectW", "handle", $l_internetsession, "wstr", $s_servername, "ushort", $i_serverport, "wstr", $s_username, "wstr", $s_password, "dword", $l_service, "dword", $l_flags, "dword_ptr", $l_context)
  3802.     If @error OR $ai_internetconnect[0] = 0 Then Return SetError(-1, _winapi_getlasterror(), 0)
  3803.     Return $ai_internetconnect[0]
  3804. EndFunc
  3805.  
  3806. Func _ftp_decodeinternetstatus($dwinternetstatus)
  3807.     Switch $dwinternetstatus
  3808.         Case $internet_status_closing_connection
  3809.             Return "Closing connection ..."
  3810.         Case $internet_status_connection_closed
  3811.             Return "Connection closed"
  3812.         Case $internet_status_connecting_to_server
  3813.             Return "Connecting to server ..."
  3814.         Case $internet_status_connected_to_server
  3815.             Return "Connected to server"
  3816.         Case $internet_status_ctl_response_received
  3817.             Return "CTL esponse received"
  3818.         Case $internet_status_intermediate_response
  3819.             Return "Intermediate response"
  3820.         Case $internet_status_prefetch
  3821.             Return "Prefetch"
  3822.         Case $internet_status_redirect
  3823.             Return "Redirect"
  3824.         Case $internet_status_request_complete
  3825.             Return "Request complete"
  3826.         Case $internet_status_handle_created
  3827.             Return "Handle created"
  3828.         Case $internet_status_handle_closing
  3829.             Return "Handle closing ..."
  3830.         Case $internet_status_sending_request
  3831.             Return "Sending request ..."
  3832.         Case $internet_status_request_sent
  3833.             Return "Request sent"
  3834.         Case $internet_status_receiving_response
  3835.             Return "Receiving response ..."
  3836.         Case $internet_status_response_received
  3837.             Return "Response received"
  3838.         Case $internet_status_state_change
  3839.             Return "State change"
  3840.         Case $internet_status_resolving_name
  3841.             Return "Resolving name ..."
  3842.         Case $internet_status_name_resolved
  3843.             Return "Name resolved"
  3844.         Case Else
  3845.             Return "UNKNOWN status = " & $dwinternetstatus
  3846.     EndSwitch
  3847. EndFunc
  3848.  
  3849. Func _ftp_dircreate($l_ftpsession, $s_remote)
  3850.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  3851.     Local $ai_ftpmakedir = DllCall($__ghwininet_ftp, "bool", "FtpCreateDirectoryW", "handle", $l_ftpsession, "wstr", $s_remote)
  3852.     If @error OR $ai_ftpmakedir[0] = 0 Then Return SetError(-1, _winapi_getlasterror(), 0)
  3853.     Return $ai_ftpmakedir[0]
  3854. EndFunc
  3855.  
  3856. Func _ftp_dirdelete($l_ftpsession, $s_remote)
  3857.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  3858.     Local $ai_ftpdeldir = DllCall($__ghwininet_ftp, "bool", "FtpRemoveDirectoryW", "handle", $l_ftpsession, "wstr", $s_remote)
  3859.     If @error OR $ai_ftpdeldir[0] = 0 Then Return SetError(-1, _winapi_getlasterror(), 0)
  3860.     Return $ai_ftpdeldir[0]
  3861. EndFunc
  3862.  
  3863. Func _ftp_dirgetcurrent($l_ftpsession)
  3864.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  3865.     Local $ai_ftpgetcurrentdir = DllCall($__ghwininet_ftp, "bool", "FtpGetCurrentDirectoryW", "handle", $l_ftpsession, "wstr", "", "dword*", 260)
  3866.     If @error OR $ai_ftpgetcurrentdir[0] = 0 Then Return SetError(-1, _winapi_getlasterror(), 0)
  3867.     Return $ai_ftpgetcurrentdir[2]
  3868. EndFunc
  3869.  
  3870. Func _ftp_dirputcontents($l_internetsession, $s_localfolder, $s_remotefolder, $b_recursiveput, $l_context = 0)
  3871.     If StringRight($s_localfolder, 1) == "\" Then $s_localfolder = StringTrimRight($s_localfolder, 1)
  3872.     Local $search = FileFindFirstFile($s_localfolder & "\*.*")
  3873.     If $search = -1 Then Return SetError(1, 0, 0)
  3874.     Local $file
  3875.     While 1
  3876.         $file = FileFindNextFile($search)
  3877.         If @error Then ExitLoop
  3878.         If StringInStr(FileGetAttrib($s_localfolder & "\" & $file), "D") Then
  3879.             _ftp_dircreate($l_internetsession, $s_remotefolder & "/" & $file)
  3880.             If $b_recursiveput Then
  3881.                 _ftp_dirputcontents($l_internetsession, $s_localfolder & "\" & $file, $s_remotefolder & "/" & $file, $b_recursiveput, $l_context)
  3882.             EndIf
  3883.         Else
  3884.             _ftp_fileput($l_internetsession, $s_localfolder & "\" & $file, $s_remotefolder & "/" & $file, 0, $l_context)
  3885.         EndIf
  3886.     WEnd
  3887.     FileClose($search)
  3888.     Return 1
  3889. EndFunc
  3890.  
  3891. Func _ftp_dirsetcurrent($l_ftpsession, $s_remote)
  3892.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  3893.     Local $ai_ftpsetcurrentdir = DllCall($__ghwininet_ftp, "bool", "FtpSetCurrentDirectoryW", "handle", $l_ftpsession, "wstr", $s_remote)
  3894.     If @error OR $ai_ftpsetcurrentdir[0] = 0 Then Return SetError(-1, _winapi_getlasterror(), 0)
  3895.     Return $ai_ftpsetcurrentdir[0]
  3896. EndFunc
  3897.  
  3898. Func _ftp_fileclose($l_internetsession)
  3899.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  3900.     Local $ai_internetclosehandle = DllCall($__ghwininet_ftp, "bool", "InternetCloseHandle", "handle", $l_internetsession)
  3901.     If @error OR $ai_internetclosehandle[0] = 0 Then Return SetError(-1, _winapi_getlasterror(), 0)
  3902.     Return $ai_internetclosehandle[0]
  3903. EndFunc
  3904.  
  3905. Func _ftp_filedelete($l_ftpsession, $s_remotefile)
  3906.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  3907.     Local $ai_ftpputfile = DllCall($__ghwininet_ftp, "bool", "FtpDeleteFileW", "handle", $l_ftpsession, "wstr", $s_remotefile)
  3908.     If @error OR $ai_ftpputfile[0] = 0 Then Return SetError(-1, _winapi_getlasterror(), 0)
  3909.     Return $ai_ftpputfile[0]
  3910. EndFunc
  3911.  
  3912. Func _ftp_fileget($l_ftpsession, $s_remotefile, $s_localfile, $ffailifexists = False, $dwflagsandattributes = 0, $l_flags = $ftp_transfer_type_unknown, $l_context = 0)
  3913.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  3914.     Local $ai_ftpgetfile = DllCall($__ghwininet_ftp, "bool", "FtpGetFileW", "handle", $l_ftpsession, "wstr", $s_remotefile, "wstr", $s_localfile, "bool", $ffailifexists, "dword", $dwflagsandattributes, "dword", $l_flags, "dword_ptr", $l_context)
  3915.     If @error OR $ai_ftpgetfile[0] = 0 Then Return SetError(-1, _winapi_getlasterror(), 0)
  3916.     Return $ai_ftpgetfile[0]
  3917. EndFunc
  3918.  
  3919. Func _ftp_filegetsize($l_ftpsession, $s_filename)
  3920.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  3921.     Local $ai_ftpgetsizehandle = DllCall($__ghwininet_ftp, "handle", "FtpOpenFileW", "handle", $l_ftpsession, "wstr", $s_filename, "dword", $generic_read, "dword", $internet_flag_no_cache_write + $internet_flag_transfer_binary, "dword_ptr", 0)
  3922.     If @error OR $ai_ftpgetsizehandle[0] = 0 Then Return SetError(-1, _winapi_getlasterror(), 0)
  3923.     Local $ai_ftpgetfilesize = DllCall($__ghwininet_ftp, "dword", "FtpGetFileSize", "handle", $ai_ftpgetsizehandle[0], "dword*", 0)
  3924.     If @error OR $ai_ftpgetfilesize[0] = 0 Then
  3925.         Local $lasterror = _winapi_getlasterror()
  3926.         DllCall($__ghwininet_ftp, "bool", "InternetCloseHandle", "handle", $ai_ftpgetsizehandle[0])
  3927.         Return SetError(-1, $lasterror, 0)
  3928.     EndIf
  3929.     DllCall($__ghwininet_ftp, "bool", "InternetCloseHandle", "handle", $ai_ftpgetsizehandle[0])
  3930.     Return _winapi_makeqword($ai_ftpgetfilesize[0], $ai_ftpgetfilesize[2])
  3931. EndFunc
  3932.  
  3933. Func _ftp_fileopen($hconnect, $lpszfilename, $dwaccess = $generic_read, $dwflags = $internet_flag_transfer_binary, $dwcontext = 0)
  3934.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  3935.     Local $ai_ftpopenfile = DllCall($__ghwininet_ftp, "handle", "FtpOpenFileW", "handle", $hconnect, "wstr", $lpszfilename, "dword", $dwaccess, "dword", $dwflags, "dword_ptr", $dwcontext)
  3936.     If @error OR $ai_ftpopenfile[0] == 0 Then Return SetError(-1, _winapi_getlasterror(), 0)
  3937.     Return $ai_ftpopenfile[0]
  3938. EndFunc
  3939.  
  3940. Func _ftp_fileput($l_ftpsession, $s_localfile, $s_remotefile, $l_flags = 0, $l_context = 0)
  3941.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  3942.     Local $ai_ftpputfile = DllCall($__ghwininet_ftp, "bool", "FtpPutFileW", "handle", $l_ftpsession, "wstr", $s_localfile, "wstr", $s_remotefile, "dword", $l_flags, "dword_ptr", $l_context)
  3943.     If @error OR $ai_ftpputfile[0] = 0 Then Return SetError(-1, _winapi_getlasterror(), 0)
  3944.     Return $ai_ftpputfile[0]
  3945. EndFunc
  3946.  
  3947. Func _ftp_fileread($h_file, $dwnumberofbytestoread)
  3948.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  3949.     Local $lpbuffer = DllStructCreate("byte[" & $dwnumberofbytestoread & "]")
  3950.     Local $ai_ftpreadfile = DllCall($__ghwininet_ftp, "bool", "InternetReadFile", "handle", $h_file, "struct*", $lpbuffer, "dword", $dwnumberofbytestoread, "dword*", 0)
  3951.     If @error Then Return SetError(1, _winapi_getlasterror(), 0)
  3952.     Local $lpdwnumberofbytesread = $ai_ftpreadfile[4]
  3953.     If $lpdwnumberofbytesread == 0 AND $ai_ftpreadfile[0] == 1 Then
  3954.         Return SetError(-1, 0, 0)
  3955.     ElseIf $ai_ftpreadfile[0] == 0 Then
  3956.         Return SetError(2, _winapi_getlasterror(), 0)
  3957.     EndIf
  3958.     Local $s_fileread
  3959.     If $dwnumberofbytestoread > $lpdwnumberofbytesread Then
  3960.         $s_fileread = BinaryMid(DllStructGetData($lpbuffer, 1), 1, $lpdwnumberofbytesread)
  3961.     Else
  3962.         $s_fileread = DllStructGetData($lpbuffer, 1)
  3963.     EndIf
  3964.     Return SetError(0, $lpdwnumberofbytesread, $s_fileread)
  3965. EndFunc
  3966.  
  3967. Func _ftp_filerename($l_ftpsession, $s_existing, $s_new)
  3968.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  3969.     Local $ai_ftprenamefile = DllCall($__ghwininet_ftp, "bool", "FtpRenameFileW", "handle", $l_ftpsession, "wstr", $s_existing, "wstr", $s_new)
  3970.     If @error OR $ai_ftprenamefile[0] = 0 Then Return SetError(-1, _winapi_getlasterror(), 0)
  3971.     Return $ai_ftprenamefile[0]
  3972. EndFunc
  3973.  
  3974. Func _ftp_filetimelohitostr($lodword, $hidword, $bfmt = 0)
  3975.     Local $tfiletime = DllStructCreate($tagfiletime)
  3976.     If NOT $lodword AND NOT $hidword Then Return SetError(1, 0, "")
  3977.     DllStructSetData($tfiletime, 1, $lodword)
  3978.     DllStructSetData($tfiletime, 2, $hidword)
  3979.     Local $date = _date_time_filetimetostr($tfiletime, $bfmt)
  3980.     Return SetError(@error, @extended, $date)
  3981. EndFunc
  3982.  
  3983. Func _ftp_findfileclose($h_handle)
  3984.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  3985.     Local $ai_ftpputfile = DllCall($__ghwininet_ftp, "bool", "InternetCloseHandle", "handle", $h_handle)
  3986.     If @error OR $ai_ftpputfile[0] = 0 Then Return SetError(-1, _winapi_getlasterror(), "")
  3987.     Return $ai_ftpputfile[0]
  3988. EndFunc
  3989.  
  3990. Func _ftp_findfilefirst($l_ftpsession, $s_remotepath, ByRef $h_handle, $l_flags = 0, $l_context = 0)
  3991.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  3992.     Local $l_dllstruct = DllStructCreate($tagwin32_find_data)
  3993.     If @error Then Return SetError(-3, 0, "")
  3994.     Local $a_ftpfilelist[1]
  3995.     $a_ftpfilelist[0] = 0
  3996.     Local $ai_ftpfirstfile = DllCall($__ghwininet_ftp, "handle", "FtpFindFirstFileW", "handle", $l_ftpsession, "wstr", $s_remotepath, "struct*", $l_dllstruct, "dword", $l_flags, "dword_ptr", $l_context)
  3997.     If @error OR $ai_ftpfirstfile[0] = 0 Then Return SetError(-1, _winapi_getlasterror(), $ai_ftpfirstfile)
  3998.     $h_handle = $ai_ftpfirstfile[0]
  3999.     Local $a_ftpfilelist[12]
  4000.     $a_ftpfilelist[0] = 11
  4001.     $a_ftpfilelist[1] = DllStructGetData($l_dllstruct, "dwFileAttributes")
  4002.     $a_ftpfilelist[2] = DllStructGetData($l_dllstruct, "ftCreationTime", 1)
  4003.     $a_ftpfilelist[3] = DllStructGetData($l_dllstruct, "ftCreationTime", 2)
  4004.     $a_ftpfilelist[4] = DllStructGetData($l_dllstruct, "ftLastAccessTime", 1)
  4005.     $a_ftpfilelist[5] = DllStructGetData($l_dllstruct, "ftLastAccessTime", 2)
  4006.     $a_ftpfilelist[6] = DllStructGetData($l_dllstruct, "ftLastWriteTime", 1)
  4007.     $a_ftpfilelist[7] = DllStructGetData($l_dllstruct, "ftLastWriteTime", 2)
  4008.     $a_ftpfilelist[8] = DllStructGetData($l_dllstruct, "nFileSizeHigh")
  4009.     $a_ftpfilelist[9] = DllStructGetData($l_dllstruct, "nFileSizeLow")
  4010.     $a_ftpfilelist[10] = DllStructGetData($l_dllstruct, "cFileName")
  4011.     $a_ftpfilelist[11] = DllStructGetData($l_dllstruct, "cAlternateFileName")
  4012.     Return $a_ftpfilelist
  4013. EndFunc
  4014.  
  4015. Func _ftp_findfilenext($h_handle)
  4016.     Local $l_dllstruct = DllStructCreate($tagwin32_find_data)
  4017.     Local $a_ftpfilelist[1]
  4018.     $a_ftpfilelist[0] = 0
  4019.     Local $ai_ftpputfile = DllCall($__ghwininet_ftp, "bool", "InternetFindNextFileW", "handle", $h_handle, "struct*", $l_dllstruct)
  4020.     If @error OR $ai_ftpputfile[0] = 0 Then Return SetError(-1, _winapi_getlasterror(), $a_ftpfilelist)
  4021.     Local $a_ftpfilelist[12]
  4022.     $a_ftpfilelist[0] = 11
  4023.     $a_ftpfilelist[1] = DllStructGetData($l_dllstruct, "dwFileAttributes")
  4024.     $a_ftpfilelist[2] = DllStructGetData($l_dllstruct, "ftCreationTime", 1)
  4025.     $a_ftpfilelist[3] = DllStructGetData($l_dllstruct, "ftCreationTime", 2)
  4026.     $a_ftpfilelist[4] = DllStructGetData($l_dllstruct, "ftLastAccessTime", 1)
  4027.     $a_ftpfilelist[5] = DllStructGetData($l_dllstruct, "ftLastAccessTime", 2)
  4028.     $a_ftpfilelist[6] = DllStructGetData($l_dllstruct, "ftLastWriteTime", 1)
  4029.     $a_ftpfilelist[7] = DllStructGetData($l_dllstruct, "ftLastWriteTime", 2)
  4030.     $a_ftpfilelist[8] = DllStructGetData($l_dllstruct, "nFileSizeHigh")
  4031.     $a_ftpfilelist[9] = DllStructGetData($l_dllstruct, "nFileSizeLow")
  4032.     $a_ftpfilelist[10] = DllStructGetData($l_dllstruct, "cFileName")
  4033.     $a_ftpfilelist[11] = DllStructGetData($l_dllstruct, "cAlternateFileName")
  4034.     Return $a_ftpfilelist
  4035. EndFunc
  4036.  
  4037. Func _ftp_getlastresponseinfo(ByRef $dwerror, ByRef $szmessage)
  4038.     Local $ai_lastresponseinfo = DllCall($__ghwininet_ftp, "bool", "InternetGetLastResponseInfoW", "dword*", 0, "wstr", "", "dword*", 4096)
  4039.     If @error OR $ai_lastresponseinfo[0] = 0 Then Return SetError(-1, _winapi_getlasterror(), 0)
  4040.     $dwerror = $ai_lastresponseinfo[1]
  4041.     $szmessage = $ai_lastresponseinfo[2]
  4042.     Return $ai_lastresponseinfo[0]
  4043. EndFunc
  4044.  
  4045. Func _ftp_listtoarray($l_ftpsession, $return_type = 0, $l_flags = $internet_flag_no_cache_write, $l_context = 0)
  4046.     Local $aarray[1]
  4047.     $aarray[0] = 0
  4048.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, $aarray)
  4049.     $aarray = __ftp_listtoarray($l_ftpsession, $return_type, $l_flags, 0, 1, $l_context)
  4050.     Return SetError(@error, @extended, $aarray)
  4051. EndFunc
  4052.  
  4053. Func _ftp_listtoarray2d($l_ftpsession, $return_type = 0, $l_flags = $internet_flag_no_cache_write, $l_context = 0)
  4054.     Local $aarray[1][1]
  4055.     $aarray[0][0] = 0
  4056.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, $aarray)
  4057.     $aarray = __ftp_listtoarray($l_ftpsession, $return_type, $l_flags, 0, 2, $l_context)
  4058.     Return SetError(@error, @extended, $aarray)
  4059. EndFunc
  4060.  
  4061. Func _ftp_listtoarrayex($l_ftpsession, $return_type = 0, $l_flags = $internet_flag_no_cache_write, $b_fmt = 1, $l_context = 0)
  4062.     Local $aarray[1][1]
  4063.     $aarray[0][0] = 0
  4064.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, $aarray)
  4065.     $aarray = __ftp_listtoarray($l_ftpsession, $return_type, $l_flags, $b_fmt, 6, $l_context)
  4066.     Return SetError(@error, @extended, $aarray)
  4067. EndFunc
  4068.  
  4069. Func _ftp_open($s_agent, $l_accesstype = $internet_open_type_direct, $s_proxyname = "", $s_proxybypass = "", $l_flags = 0)
  4070.     If $__ghwininet_ftp = -1 Then __ftp_init()
  4071.     Local $ai_internetopen = DllCall($__ghwininet_ftp, "handle", "InternetOpenW", "wstr", $s_agent, "dword", $l_accesstype, "wstr", $s_proxyname, "wstr", $s_proxybypass, "dword", $l_flags)
  4072.     If @error OR $ai_internetopen[0] = 0 Then Return SetError(-1, _winapi_getlasterror(), 0)
  4073.     Return $ai_internetopen[0]
  4074. EndFunc
  4075.  
  4076. Func _ftp_progressdownload($l_ftpsession, $s_localfile, $s_remotefile, $functiontocall = "")
  4077.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  4078.     Local $fhandle = FileOpen($s_localfile, $fo_overwrite + $fo_binary)
  4079.     If $fhandle < 0 Then Return SetError(-1, 0, 0)
  4080.     Local $ai_ftpopenfile = DllCall($__ghwininet_ftp, "handle", "FtpOpenFileW", "handle", $l_ftpsession, "wstr", $s_remotefile, "dword", $generic_read, "dword", $ftp_transfer_type_binary, "dword_ptr", 0)
  4081.     If @error OR $ai_ftpopenfile[0] = 0 Then Return SetError(-3, _winapi_getlasterror(), 0)
  4082.     Local $ai_ftpgetfilesize = DllCall($__ghwininet_ftp, "dword", "FtpGetFileSize", "handle", $ai_ftpopenfile[0], "dword*", 0)
  4083.     If @error Then Return SetError(-2, _winapi_getlasterror(), 0)
  4084.     If $functiontocall = "" Then ProgressOn("FTP Download", "Downloading " & $s_localfile)
  4085.     Local $glen = _winapi_makeqword($ai_ftpgetfilesize[0], $ai_ftpgetfilesize[2])
  4086.     Local Const $chunksize = 256 * 1024
  4087.     Local $last = Mod($glen, $chunksize)
  4088.     Local $parts = Ceiling($glen / $chunksize)
  4089.     Local $buffer = DllStructCreate("byte[" & $chunksize & "]")
  4090.     Local $ai_internetclosehandle, $ai_ftpread, $out, $ret, $lasterror
  4091.     Local $x = $chunksize
  4092.     Local $done = 0
  4093.     For $i = 1 To $parts
  4094.         If $i = $parts AND $last > 0 Then
  4095.             $x = $last
  4096.         EndIf
  4097.         $ai_ftpread = DllCall($__ghwininet_ftp, "bool", "InternetReadFile", "handle", $ai_ftpopenfile[0], "struct*", $buffer, "dword", $x, "dword*", $out)
  4098.         If @error OR $ai_ftpread[0] = 0 Then
  4099.             $lasterror = _winapi_getlasterror()
  4100.             $ai_internetclosehandle = DllCall($__ghwininet_ftp, "bool", "InternetCloseHandle", "handle", $ai_ftpopenfile[0])
  4101.             FileClose($fhandle)
  4102.             If $functiontocall = "" Then ProgressOff()
  4103.             Return SetError(-4, $lasterror, 0)
  4104.         EndIf
  4105.         $ret = FileWrite($fhandle, BinaryMid(DllStructGetData($buffer, 1), 1, $ai_ftpread[4]))
  4106.         If NOT $ret Then
  4107.             $lasterror = _winapi_getlasterror()
  4108.             $ai_internetclosehandle = DllCall($__ghwininet_ftp, "bool", "InternetCloseHandle", "handle", $ai_ftpopenfile[0])
  4109.             FileClose($fhandle)
  4110.             FileDelete($s_localfile)
  4111.             If $functiontocall = "" Then ProgressOff()
  4112.             Return SetError(-7, $lasterror, 0)
  4113.         EndIf
  4114.         $done += $ai_ftpread[4]
  4115.         If $functiontocall = "" Then
  4116.             ProgressSet(($done / $glen) * 100)
  4117.         Else
  4118.             $ret = Call($functiontocall, ($done / $glen) * 100)
  4119.             If $ret <= 0 Then
  4120.                 $lasterror = @error
  4121.                 $ai_internetclosehandle = DllCall($__ghwininet_ftp, "bool", "InternetCloseHandle", "handle", $ai_ftpopenfile[0])
  4122.                 FileClose($fhandle)
  4123.                 FileDelete($s_localfile)
  4124.                 If $functiontocall = "" Then ProgressOff()
  4125.                 Return SetError(-6, $lasterror, $ret)
  4126.             EndIf
  4127.         EndIf
  4128.         Sleep(10)
  4129.     Next
  4130.     FileClose($fhandle)
  4131.     If $functiontocall = "" Then ProgressOff()
  4132.     $ai_internetclosehandle = DllCall($__ghwininet_ftp, "bool", "InternetCloseHandle", "handle", $ai_ftpopenfile[0])
  4133.     If @error OR $ai_internetclosehandle[0] = 0 Then
  4134.         Return SetError(-5, _winapi_getlasterror(), 0)
  4135.     EndIf
  4136.     Return 1
  4137. EndFunc
  4138.  
  4139. Func _ftp_progressupload($l_ftpsession, $s_localfile, $s_remotefile, $functiontocall = "")
  4140.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  4141.     Local $fhandle = FileOpen($s_localfile, $fo_binary)
  4142.     If @error Then Return SetError(-1, _winapi_getlasterror(), 0)
  4143.     Local $ai_ftpopenfile = DllCall($__ghwininet_ftp, "handle", "FtpOpenFileW", "handle", $l_ftpsession, "wstr", $s_remotefile, "dword", $generic_write, "dword", $ftp_transfer_type_binary, "dword_ptr", 0)
  4144.     If @error OR $ai_ftpopenfile[0] = 0 Then Return SetError(-3, _winapi_getlasterror(), 0)
  4145.     If $functiontocall = "" Then ProgressOn("FTP Upload", "Uploading " & $s_localfile)
  4146.     Local $glen = FileGetSize($s_localfile)
  4147.     Local Const $chunksize = 256 * 1024
  4148.     Local $last = Mod($glen, $chunksize)
  4149.     Local $parts = Ceiling($glen / $chunksize)
  4150.     Local $buffer = DllStructCreate("byte[" & $chunksize & "]")
  4151.     Local $ai_internetclosehandle, $ai_ftpwrite, $out, $ret, $lasterror
  4152.     Local $x = $chunksize
  4153.     Local $done = 0
  4154.     For $i = 1 To $parts
  4155.         If $i = $parts AND $last > 0 Then
  4156.             $x = $last
  4157.         EndIf
  4158.         DllStructSetData($buffer, 1, FileRead($fhandle, $x))
  4159.         $ai_ftpwrite = DllCall($__ghwininet_ftp, "bool", "InternetWriteFile", "handle", $ai_ftpopenfile[0], "struct*", $buffer, "dword", $x, "dword*", $out)
  4160.         If @error OR $ai_ftpwrite[0] = 0 Then
  4161.             $lasterror = _winapi_getlasterror()
  4162.             $ai_internetclosehandle = DllCall($__ghwininet_ftp, "bool", "InternetCloseHandle", "handle", $ai_ftpopenfile[0])
  4163.             FileClose($fhandle)
  4164.             If $functiontocall = "" Then ProgressOff()
  4165.             Return SetError(-4, $lasterror, 0)
  4166.         EndIf
  4167.         $done += $x
  4168.         If $functiontocall = "" Then
  4169.             ProgressSet(($done / $glen) * 100)
  4170.         Else
  4171.             $ret = Call($functiontocall, ($done / $glen) * 100)
  4172.             If $ret <= 0 Then
  4173.                 $lasterror = @error
  4174.                 $ai_internetclosehandle = DllCall($__ghwininet_ftp, "bool", "InternetCloseHandle", "handle", $ai_ftpopenfile[0])
  4175.                 DllCall($__ghwininet_ftp, "bool", "FtpDeleteFileW", "handle", $l_ftpsession, "wstr", $s_remotefile)
  4176.                 FileClose($fhandle)
  4177.                 If $functiontocall = "" Then ProgressOff()
  4178.                 Return SetError(-6, $lasterror, $ret)
  4179.             EndIf
  4180.         EndIf
  4181.         Sleep(10)
  4182.     Next
  4183.     FileClose($fhandle)
  4184.     If $functiontocall = "" Then ProgressOff()
  4185.     $ai_internetclosehandle = DllCall($__ghwininet_ftp, "bool", "InternetCloseHandle", "handle", $ai_ftpopenfile[0])
  4186.     If @error OR $ai_internetclosehandle[0] = 0 Then Return SetError(-5, _winapi_getlasterror(), 0)
  4187.     Return 1
  4188. EndFunc
  4189.  
  4190. Func _ftp_setstatuscallback($l_internetsession, $sfunctionname)
  4191.     If $__ghwininet_ftp = -1 Then Return SetError(-2, 0, 0)
  4192.     Local $callback_register = DllCallbackRegister($sfunctionname, "none", "ptr;ptr;dword;ptr;dword")
  4193.     If NOT $callback_register Then Return SetError(-1, 0, 0)
  4194.     Local $ah_callbackfunction = DllCall("wininet.dll", "ptr", "InternetSetStatusCallback", "ptr", $l_internetsession, "ulong_ptr", DllCallbackGetPtr($callback_register))
  4195.     If @error Then Return SetError(-3, 0, 0)
  4196.     If $ah_callbackfunction[0] = Ptr(-1) Then Return SetError(-4, 0, 0)
  4197.     $__gbcallback_set = True
  4198.     $__ghcallback_ftp = $callback_register
  4199.     Return $ah_callbackfunction[1]
  4200. EndFunc
  4201.  
  4202. Func __ftp_listtoarray($l_ftpsession, $return_type, $l_flags, $bfmt, $arraycount, $l_context)
  4203.     If $arraycount = 1 Then
  4204.         Local $filearray[1], $directoryarray[1]
  4205.         $filearray[0] = 0
  4206.     Else
  4207.         Local $filearray[1][$arraycount], $directoryarray[1][$arraycount]
  4208.         $filearray[0][0] = 0
  4209.     EndIf
  4210.     If $return_type < 0 OR $return_type > 2 Then Return SetError(3, 0, $filearray)
  4211.     Local $twin32_find_data = DllStructCreate($tagwin32_find_data)
  4212.     Local $lasterror
  4213.     Local $callfindfirst = DllCall($__ghwininet_ftp, "handle", "FtpFindFirstFileW", "handle", $l_ftpsession, "wstr", "", "struct*", $twin32_find_data, "dword", $l_flags, "dword_ptr", $l_context)
  4214.     If @error OR NOT $callfindfirst[0] Then
  4215.         $lasterror = _winapi_getlasterror()
  4216.         If $lasterror = 12003 Then
  4217.             Local $dwerror, $szmessage
  4218.             _ftp_getlastresponseinfo($dwerror, $szmessage)
  4219.             $lasterror = $dwerror
  4220.         EndIf
  4221.         Return SetError(1, $lasterror, $filearray)
  4222.     EndIf
  4223.     Local $directoryindex = 0, $fileindex = 0
  4224.     Local $tfiletime, $isdir, $callfindnext
  4225.     Do
  4226.         $isdir = BitAND(DllStructGetData($twin32_find_data, "dwFileAttributes"), $file_attribute_directory) = $file_attribute_directory
  4227.         If $isdir AND ($return_type <> 2) Then
  4228.             $directoryindex += 1
  4229.             If $arraycount = 1 Then
  4230.                 If UBound($directoryarray) < $directoryindex + 1 Then ReDim $directoryarray[$directoryindex * 2]
  4231.                 $directoryarray[$directoryindex] = DllStructGetData($twin32_find_data, "cFileName")
  4232.             Else
  4233.                 If UBound($directoryarray) < $directoryindex + 1 Then ReDim $directoryarray[$directoryindex * 2][$arraycount]
  4234.                 $directoryarray[$directoryindex][0] = DllStructGetData($twin32_find_data, "cFileName")
  4235.                 $directoryarray[$directoryindex][1] = _winapi_makeqword(DllStructGetData($twin32_find_data, "nFileSizeLow"), DllStructGetData($twin32_find_data, "nFileSizeHigh"))
  4236.                 If $arraycount = 6 Then
  4237.                     $directoryarray[$directoryindex][2] = DllStructGetData($twin32_find_data, "dwFileAttributes")
  4238.                     $tfiletime = DllStructCreate($tagfiletime, DllStructGetPtr($twin32_find_data, "ftLastWriteTime"))
  4239.                     $directoryarray[$directoryindex][3] = _date_time_filetimetostr($tfiletime, $bfmt)
  4240.                     $tfiletime = DllStructCreate($tagfiletime, DllStructGetPtr($twin32_find_data, "ftCreationTime"))
  4241.                     $directoryarray[$directoryindex][4] = _date_time_filetimetostr($tfiletime, $bfmt)
  4242.                     $tfiletime = DllStructCreate($tagfiletime, DllStructGetPtr($twin32_find_data, "ftLastAccessTime"))
  4243.                     $directoryarray[$directoryindex][5] = _date_time_filetimetostr($tfiletime, $bfmt)
  4244.                 EndIf
  4245.             EndIf
  4246.         ElseIf NOT $isdir AND $return_type <> 1 Then
  4247.             $fileindex += 1
  4248.             If $arraycount = 1 Then
  4249.                 If UBound($filearray) < $fileindex + 1 Then ReDim $filearray[$fileindex * 2]
  4250.                 $filearray[$fileindex] = DllStructGetData($twin32_find_data, "cFileName")
  4251.             Else
  4252.                 If UBound($filearray) < $fileindex + 1 Then ReDim $filearray[$fileindex * 2][$arraycount]
  4253.                 $filearray[$fileindex][0] = DllStructGetData($twin32_find_data, "cFileName")
  4254.                 $filearray[$fileindex][1] = _winapi_makeqword(DllStructGetData($twin32_find_data, "nFileSizeLow"), DllStructGetData($twin32_find_data, "nFileSizeHigh"))
  4255.                 If $arraycount = 6 Then
  4256.                     $filearray[$fileindex][2] = DllStructGetData($twin32_find_data, "dwFileAttributes")
  4257.                     $tfiletime = DllStructCreate($tagfiletime, DllStructGetPtr($twin32_find_data, "ftLastWriteTime"))
  4258.                     $filearray[$fileindex][3] = _date_time_filetimetostr($tfiletime, $bfmt)
  4259.                     $tfiletime = DllStructCreate($tagfiletime, DllStructGetPtr($twin32_find_data, "ftCreationTime"))
  4260.                     $filearray[$fileindex][4] = _date_time_filetimetostr($tfiletime, $bfmt)
  4261.                     $tfiletime = DllStructCreate($tagfiletime, DllStructGetPtr($twin32_find_data, "ftLastAccessTime"))
  4262.                     $filearray[$fileindex][5] = _date_time_filetimetostr($tfiletime, $bfmt)
  4263.                 EndIf
  4264.             EndIf
  4265.         EndIf
  4266.         $callfindnext = DllCall($__ghwininet_ftp, "bool", "InternetFindNextFileW", "handle", $callfindfirst[0], "struct*", $twin32_find_data)
  4267.         If @error Then
  4268.             $lasterror = _winapi_getlasterror()
  4269.             DllCall($__ghwininet_ftp, "bool", "InternetCloseHandle", "handle", $callfindfirst[0])
  4270.             Return SetError(2, $lasterror, $filearray)
  4271.         EndIf
  4272.     Until NOT $callfindnext[0]
  4273.     DllCall($__ghwininet_ftp, "bool", "InternetCloseHandle", "handle", $callfindfirst[0])
  4274.     If $arraycount = 1 Then
  4275.         $directoryarray[0] = $directoryindex
  4276.         $filearray[0] = $fileindex
  4277.     Else
  4278.         $directoryarray[0][0] = $directoryindex
  4279.         $filearray[0][0] = $fileindex
  4280.     EndIf
  4281.     Switch $return_type
  4282.         Case 0
  4283.             If $arraycount = 1 Then
  4284.                 ReDim $directoryarray[$directoryarray[0] + $filearray[0] + 1]
  4285.                 For $i = 1 To $fileindex
  4286.                     $directoryarray[$directoryarray[0] + $i] = $filearray[$i]
  4287.                 Next
  4288.                 $directoryarray[0] += $filearray[0]
  4289.             Else
  4290.                 ReDim $directoryarray[$directoryarray[0][0] + $filearray[0][0] + 1][$arraycount]
  4291.                 For $i = 1 To $fileindex
  4292.                     For $j = 0 To $arraycount - 1
  4293.                         $directoryarray[$directoryarray[0][0] + $i][$j] = $filearray[$i][$j]
  4294.                     Next
  4295.                 Next
  4296.                 $directoryarray[0][0] += $filearray[0][0]
  4297.             EndIf
  4298.             Return $directoryarray
  4299.         Case 1
  4300.             If $arraycount = 1 Then
  4301.                 ReDim $directoryarray[$directoryindex + 1]
  4302.             Else
  4303.                 ReDim $directoryarray[$directoryindex + 1][$arraycount]
  4304.             EndIf
  4305.             Return $directoryarray
  4306.         Case 2
  4307.             If $arraycount = 1 Then
  4308.                 ReDim $filearray[$fileindex + 1]
  4309.             Else
  4310.                 ReDim $filearray[$fileindex + 1][$arraycount]
  4311.             EndIf
  4312.             Return $filearray
  4313.     EndSwitch
  4314. EndFunc
  4315.  
  4316. Func __ftp_init()
  4317.     $__ghwininet_ftp = DllOpen("wininet.dll")
  4318. EndFunc
  4319.  
  4320. Global Const $fw_dontcare = 0
  4321. Global Const $fw_thin = 100
  4322. Global Const $fw_extralight = 200
  4323. Global Const $fw_ultralight = 200
  4324. Global Const $fw_light = 300
  4325. Global Const $fw_normal = 400
  4326. Global Const $fw_regular = 400
  4327. Global Const $fw_medium = 500
  4328. Global Const $fw_semibold = 600
  4329. Global Const $fw_demibold = 600
  4330. Global Const $fw_bold = 700
  4331. Global Const $fw_extrabold = 800
  4332. Global Const $fw_ultrabold = 800
  4333. Global Const $fw_heavy = 900
  4334. Global Const $fw_black = 900
  4335. Global Const $cf_effects = 256
  4336. Global Const $cf_printerfonts = 2
  4337. Global Const $cf_screenfonts = 1
  4338. Global Const $cf_noscriptsel = 8388608
  4339. Global Const $cf_inittologfontstruct = 64
  4340. Global Const $logpixelsx = 88
  4341. Global Const $logpixelsy = 90
  4342. Global Const $ansi_charset = 0
  4343. Global Const $arabic_charset = 178
  4344. Global Const $baltic_charset = 186
  4345. Global Const $chinesebig5_charset = 136
  4346. Global Const $default_charset = 1
  4347. Global Const $easteurope_charset = 238
  4348. Global Const $gb2312_charset = 134
  4349. Global Const $greek_charset = 161
  4350. Global Const $hangeul_charset = 129
  4351. Global Const $hebrew_charset = 177
  4352. Global Const $johab_charset = 130
  4353. Global Const $mac_charset = 77
  4354. Global Const $oem_charset = 255
  4355. Global Const $russian_charset = 204
  4356. Global Const $shiftjis_charset = 128
  4357. Global Const $symbol_charset = 2
  4358. Global Const $thai_charset = 222
  4359. Global Const $turkish_charset = 162
  4360. Global Const $vietnamese_charset = 163
  4361. Global Const $out_character_precis = 2
  4362. Global Const $out_default_precis = 0
  4363. Global Const $out_device_precis = 5
  4364. Global Const $out_outline_precis = 8
  4365. Global Const $out_ps_only_precis = 10
  4366. Global Const $out_raster_precis = 6
  4367. Global Const $out_string_precis = 1
  4368. Global Const $out_stroke_precis = 3
  4369. Global Const $out_tt_only_precis = 7
  4370. Global Const $out_tt_precis = 4
  4371. Global Const $clip_character_precis = 1
  4372. Global Const $clip_default_precis = 0
  4373. Global Const $clip_dfa_disable = 48
  4374. Global Const $clip_embedded = 128
  4375. Global Const $clip_lh_angles = 16
  4376. Global Const $clip_mask = 15
  4377. Global Const $clip_dfa_override = 64
  4378. Global Const $clip_stroke_precis = 2
  4379. Global Const $clip_tt_always = 32
  4380. Global Const $antialiased_quality = 4
  4381. Global Const $default_quality = 0
  4382. Global Const $draft_quality = 1
  4383. Global Const $nonantialiased_quality = 3
  4384. Global Const $proof_quality = 2
  4385. Global Const $cleartype_quality = 5
  4386. Global Const $default_pitch = 0
  4387. Global Const $fixed_pitch = 1
  4388. Global Const $variable_pitch = 2
  4389. Global Const $ff_decorative = 80
  4390. Global Const $ff_dontcare = 0
  4391. Global Const $ff_modern = 48
  4392. Global Const $ff_roman = 16
  4393. Global Const $ff_script = 64
  4394. Global Const $ff_swiss = 32
  4395. Global Const $fs_regular = 0
  4396. Global Const $fs_bold = 1
  4397. Global Const $fs_italic = 2
  4398. Global Const $__miscconstant_cc_anycolor = 256
  4399. Global Const $__miscconstant_cc_fullopen = 2
  4400. Global Const $__miscconstant_cc_rgbinit = 1
  4401. Global Const $tagchoosecolor = "dword Size;hwnd hWndOwnder;handle hInstance;dword rgbResult;ptr CustColors;dword Flags;lparam lCustData;" & "ptr lpfnHook;ptr lpTemplateName"
  4402. Global Const $tagchoosefont = "dword Size;hwnd hWndOwner;handle hDC;ptr LogFont;int PointSize;dword Flags;dword rgbColors;lparam CustData;" & "ptr fnHook;ptr TemplateName;handle hInstance;ptr szStyle;word FontType;int SizeMin;int SizeMax"
  4403.  
  4404. Func _choosecolor($ireturntype = 0, $icolorref = 0, $ireftype = 0, $hwndownder = 0)
  4405.     Local $custcolors = "dword[16]"
  4406.     Local $tchoose = DllStructCreate($tagchoosecolor)
  4407.     Local $tcc = DllStructCreate($custcolors)
  4408.     If $ireftype = 1 Then
  4409.         $icolorref = Int($icolorref)
  4410.     ElseIf $ireftype = 2 Then
  4411.         $icolorref = Hex(String($icolorref), 6)
  4412.         $icolorref = "0x" & StringMid($icolorref, 5, 2) & StringMid($icolorref, 3, 2) & StringMid($icolorref, 1, 2)
  4413.     EndIf
  4414.     DllStructSetData($tchoose, "Size", DllStructGetSize($tchoose))
  4415.     DllStructSetData($tchoose, "hWndOwnder", $hwndownder)
  4416.     DllStructSetData($tchoose, "rgbResult", $icolorref)
  4417.     DllStructSetData($tchoose, "CustColors", DllStructGetPtr($tcc))
  4418.     DllStructSetData($tchoose, "Flags", BitOR($__miscconstant_cc_anycolor, $__miscconstant_cc_fullopen, $__miscconstant_cc_rgbinit))
  4419.     Local $aresult = DllCall("comdlg32.dll", "bool", "ChooseColor", "struct*", $tchoose)
  4420.     If @error Then Return SetError(@error, @extended, -1)
  4421.     If $aresult[0] = 0 Then Return SetError(-3, -3, -1)
  4422.     Local $color_picked = DllStructGetData($tchoose, "rgbResult")
  4423.     If $ireturntype = 1 Then
  4424.         Return "0x" & Hex(String($color_picked), 6)
  4425.     ElseIf $ireturntype = 2 Then
  4426.         $color_picked = Hex(String($color_picked), 6)
  4427.         Return "0x" & StringMid($color_picked, 5, 2) & StringMid($color_picked, 3, 2) & StringMid($color_picked, 1, 2)
  4428.     ElseIf $ireturntype = 0 Then
  4429.         Return $color_picked
  4430.     Else
  4431.         Return SetError(-4, -4, -1)
  4432.     EndIf
  4433. EndFunc
  4434.  
  4435. Func _choosefont($sfontname = "Courier New", $ipointsize = 10, $icolorref = 0, $ifontweight = 0, $iitalic = False, $iunderline = False, $istrikethru = False, $hwndowner = 0)
  4436.     Local $italic = 0, $underline = 0, $strikeout = 0
  4437.     Local $lngdc = __misc_getdc(0)
  4438.     Local $lfheight = Round(($ipointsize * __misc_getdevicecaps($lngdc, $logpixelsx)) / 72, 0)
  4439.     __misc_releasedc(0, $lngdc)
  4440.     Local $tchoosefont = DllStructCreate($tagchoosefont)
  4441.     Local $tlogfont = DllStructCreate($taglogfont)
  4442.     DllStructSetData($tchoosefont, "Size", DllStructGetSize($tchoosefont))
  4443.     DllStructSetData($tchoosefont, "hWndOwner", $hwndowner)
  4444.     DllStructSetData($tchoosefont, "LogFont", DllStructGetPtr($tlogfont))
  4445.     DllStructSetData($tchoosefont, "PointSize", $ipointsize)
  4446.     DllStructSetData($tchoosefont, "Flags", BitOR($cf_screenfonts, $cf_printerfonts, $cf_effects, $cf_inittologfontstruct, $cf_noscriptsel))
  4447.     DllStructSetData($tchoosefont, "rgbColors", $icolorref)
  4448.     DllStructSetData($tchoosefont, "FontType", 0)
  4449.     DllStructSetData($tlogfont, "Height", $lfheight)
  4450.     DllStructSetData($tlogfont, "Weight", $ifontweight)
  4451.     DllStructSetData($tlogfont, "Italic", $iitalic)
  4452.     DllStructSetData($tlogfont, "Underline", $iunderline)
  4453.     DllStructSetData($tlogfont, "Strikeout", $istrikethru)
  4454.     DllStructSetData($tlogfont, "FaceName", $sfontname)
  4455.     Local $aresult = DllCall("comdlg32.dll", "bool", "ChooseFontW", "struct*", $tchoosefont)
  4456.     If @error Then Return SetError(@error, @extended, -1)
  4457.     If $aresult[0] = 0 Then Return SetError(-3, -3, -1)
  4458.     Local $fontname = DllStructGetData($tlogfont, "FaceName")
  4459.     If StringLen($fontname) = 0 AND StringLen($sfontname) > 0 Then $fontname = $sfontname
  4460.     If DllStructGetData($tlogfont, "Italic") Then $italic = 2
  4461.     If DllStructGetData($tlogfont, "Underline") Then $underline = 4
  4462.     If DllStructGetData($tlogfont, "Strikeout") Then $strikeout = 8
  4463.     Local $attributes = BitOR($italic, $underline, $strikeout)
  4464.     Local $size = DllStructGetData($tchoosefont, "PointSize") / 10
  4465.     Local $colorref = DllStructGetData($tchoosefont, "rgbColors")
  4466.     Local $weight = DllStructGetData($tlogfont, "Weight")
  4467.     Local $color_picked = Hex(String($colorref), 6)
  4468.     Return StringSplit($attributes & "," & $fontname & "," & $size & "," & $weight & "," & $colorref & "," & "0x" & $color_picked & "," & "0x" & StringMid($color_picked, 5, 2) & StringMid($color_picked, 3, 2) & StringMid($color_picked, 1, 2), ",")
  4469. EndFunc
  4470.  
  4471. Func _clipputfile($sfile, $sseparator = "|")
  4472.     Local Const $gmem_moveable = 2, $cf_hdrop = 15
  4473.     $sfile &= $sseparator & $sseparator
  4474.     Local $nglobmemsize = 2 * (StringLen($sfile) + 20)
  4475.     Local $aresult = DllCall("user32.dll", "bool", "OpenClipboard", "hwnd", 0)
  4476.     If @error OR $aresult[0] = 0 Then Return SetError(1, _winapi_getlasterror(), False)
  4477.     Local $ierror = 0, $ilasterror = 0
  4478.     $aresult = DllCall("user32.dll", "bool", "EmptyClipboard")
  4479.     If @error OR NOT $aresult[0] Then
  4480.         $ierror = 2
  4481.         $ilasterror = _winapi_getlasterror()
  4482.     Else
  4483.         $aresult = DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", $gmem_moveable, "ulong_ptr", $nglobmemsize)
  4484.         If @error OR NOT $aresult[0] Then
  4485.             $ierror = 3
  4486.             $ilasterror = _winapi_getlasterror()
  4487.         Else
  4488.             Local $hglobal = $aresult[0]
  4489.             $aresult = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", $hglobal)
  4490.             If @error OR NOT $aresult[0] Then
  4491.                 $ierror = 4
  4492.                 $ilasterror = _winapi_getlasterror()
  4493.             Else
  4494.                 Local $hlock = $aresult[0]
  4495.                 Local $dropfiles = DllStructCreate("dword pFiles;" & $tagpoint & ";bool fNC;bool fWide;wchar[" & StringLen($sfile) + 1 & "]", $hlock)
  4496.                 If @error Then Return SetError(5, 6, False)
  4497.                 Local $tempstruct = DllStructCreate("dword;long;long;bool;bool")
  4498.                 DllStructSetData($dropfiles, "pFiles", DllStructGetSize($tempstruct))
  4499.                 DllStructSetData($dropfiles, "X", 0)
  4500.                 DllStructSetData($dropfiles, "Y", 0)
  4501.                 DllStructSetData($dropfiles, "fNC", 0)
  4502.                 DllStructSetData($dropfiles, "fWide", 1)
  4503.                 DllStructSetData($dropfiles, 6, $sfile)
  4504.                 For $i = 1 To StringLen($sfile)
  4505.                     If DllStructGetData($dropfiles, 6, $i) = $sseparator Then DllStructSetData($dropfiles, 6, Chr(0), $i)
  4506.                 Next
  4507.                 $aresult = DllCall("user32.dll", "handle", "SetClipboardData", "uint", $cf_hdrop, "handle", $hglobal)
  4508.                 If @error OR NOT $aresult[0] Then
  4509.                     $ierror = 6
  4510.                     $ilasterror = _winapi_getlasterror()
  4511.                 EndIf
  4512.                 $aresult = DllCall("kernel32.dll", "bool", "GlobalUnlock", "handle", $hglobal)
  4513.                 If (@error OR NOT $aresult[0]) AND NOT $ierror AND _winapi_getlasterror() Then
  4514.                     $ierror = 8
  4515.                     $ilasterror = _winapi_getlasterror()
  4516.                 EndIf
  4517.             EndIf
  4518.             $aresult = DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", $hglobal)
  4519.             If (@error OR $aresult[0]) AND NOT $ierror Then
  4520.                 $ierror = 9
  4521.                 $ilasterror = _winapi_getlasterror()
  4522.             EndIf
  4523.         EndIf
  4524.     EndIf
  4525.     $aresult = DllCall("user32.dll", "bool", "CloseClipboard")
  4526.     If (@error OR NOT $aresult[0]) AND NOT $ierror Then Return SetError(7, _winapi_getlasterror(), False)
  4527.     If $ierror Then Return SetError($ierror, $ilasterror, False)
  4528.     Return True
  4529. EndFunc
  4530.  
  4531. Func _iif($ftest, $vtrueval, $vfalseval)
  4532.     Return $ftest ? $vtrueval : $vfalseval
  4533. EndFunc
  4534.  
  4535. Func _mousetrap($ileft = 0, $itop = 0, $iright = 0, $ibottom = 0)
  4536.     Local $areturn = 0
  4537.     If $ileft = Default Then $ileft = 0
  4538.     If $itop = Default Then $itop = 0
  4539.     If $iright = Default Then $iright = 0
  4540.     If $ibottom = Default Then $ibottom = 0
  4541.     If @NumParams = 0 Then
  4542.         $areturn = DllCall("user32.dll", "bool", "ClipCursor", "ptr", 0)
  4543.         If @error OR NOT $areturn[0] Then Return SetError(1, _winapi_getlasterror(), False)
  4544.     Else
  4545.         If @NumParams = 2 Then
  4546.             $iright = $ileft + 1
  4547.             $ibottom = $itop + 1
  4548.         EndIf
  4549.         Local $trect = DllStructCreate($tagrect)
  4550.         DllStructSetData($trect, "Left", $ileft)
  4551.         DllStructSetData($trect, "Top", $itop)
  4552.         DllStructSetData($trect, "Right", $iright)
  4553.         DllStructSetData($trect, "Bottom", $ibottom)
  4554.         $areturn = DllCall("user32.dll", "bool", "ClipCursor", "struct*", $trect)
  4555.         If @error OR NOT $areturn[0] Then Return SetError(2, _winapi_getlasterror(), False)
  4556.     EndIf
  4557.     Return True
  4558. EndFunc
  4559.  
  4560. Func _singleton($soccurencename, $iflag = 0)
  4561.     Local Const $error_already_exists = 183
  4562.     Local Const $security_descriptor_revision = 1
  4563.     Local $tsecurityattributes = 0
  4564.     If BitAND($iflag, 2) Then
  4565.         Local $tsecuritydescriptor = DllStructCreate("byte;byte;word;ptr[4]")
  4566.         Local $aret = DllCall("advapi32.dll", "bool", "InitializeSecurityDescriptor", "struct*", $tsecuritydescriptor, "dword", $security_descriptor_revision)
  4567.         If @error Then Return SetError(@error, @extended, 0)
  4568.         If $aret[0] Then
  4569.             $aret = DllCall("advapi32.dll", "bool", "SetSecurityDescriptorDacl", "struct*", $tsecuritydescriptor, "bool", 1, "ptr", 0, "bool", 0)
  4570.             If @error Then Return SetError(@error, @extended, 0)
  4571.             If $aret[0] Then
  4572.                 $tsecurityattributes = DllStructCreate($tagsecurity_attributes)
  4573.                 DllStructSetData($tsecurityattributes, 1, DllStructGetSize($tsecurityattributes))
  4574.                 DllStructSetData($tsecurityattributes, 2, DllStructGetPtr($tsecuritydescriptor))
  4575.                 DllStructSetData($tsecurityattributes, 3, 0)
  4576.             EndIf
  4577.         EndIf
  4578.     EndIf
  4579.     Local $handle = DllCall("kernel32.dll", "handle", "CreateMutexW", "struct*", $tsecurityattributes, "bool", 1, "wstr", $soccurencename)
  4580.     If @error Then Return SetError(@error, @extended, 0)
  4581.     Local $lasterror = DllCall("kernel32.dll", "dword", "GetLastError")
  4582.     If @error Then Return SetError(@error, @extended, 0)
  4583.     If $lasterror[0] = $error_already_exists Then
  4584.         If BitAND($iflag, 1) Then
  4585.             DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $handle[0])
  4586.             If @error Then Return SetError(@error, @extended, 0)
  4587.             Return SetError($lasterror[0], $lasterror[0], 0)
  4588.         Else
  4589.             Exit -1
  4590.         EndIf
  4591.     EndIf
  4592.     Return $handle[0]
  4593. EndFunc
  4594.  
  4595. Func _ispressed($shexkey, $vdll = "user32.dll")
  4596.     Local $a_r = DllCall($vdll, "short", "GetAsyncKeyState", "int", "0x" & $shexkey)
  4597.     If @error Then Return SetError(@error, @extended, False)
  4598.     Return BitAND($a_r[0], 32768) <> 0
  4599. EndFunc
  4600.  
  4601. Func _versioncompare($sversion1, $sversion2)
  4602.     If $sversion1 = $sversion2 Then Return 0
  4603.     Local $aversion1 = StringSplit($sversion1, ".,"), $aversion2 = StringSplit($sversion2, ".,")
  4604.     If UBound($aversion1) <> UBound($aversion2) OR UBound($aversion1) = 0 Then
  4605.         If $sversion1 > $sversion2 Then
  4606.             Return SetExtended(1, 1)
  4607.         ElseIf $sversion1 < $sversion2 Then
  4608.             Return SetExtended(1, -1)
  4609.         EndIf
  4610.     Else
  4611.         For $i = 1 To UBound($aversion1) - 1
  4612.             If StringIsDigit($aversion1[$i]) AND StringIsDigit($aversion2[$i]) Then
  4613.                 If Number($aversion1[$i]) > Number($aversion2[$i]) Then
  4614.                     Return SetExtended(2, 1)
  4615.                 ElseIf Number($aversion1[$i]) < Number($aversion2[$i]) Then
  4616.                     Return SetExtended(2, -1)
  4617.                 EndIf
  4618.             Else
  4619.                 If $aversion1[$i] > $aversion2[$i] Then
  4620.                     Return SetExtended(1, 1)
  4621.                 ElseIf $aversion1[$i] < $aversion2[$i] Then
  4622.                     Return SetExtended(1, -1)
  4623.                 EndIf
  4624.             EndIf
  4625.         Next
  4626.     EndIf
  4627.     Return SetError(2, 0, 0)
  4628. EndFunc
  4629.  
  4630. Func __misc_getdc($hwnd)
  4631.     Local $aresult = DllCall("User32.dll", "handle", "GetDC", "hwnd", $hwnd)
  4632.     If @error OR NOT $aresult[0] Then Return SetError(1, _winapi_getlasterror(), 0)
  4633.     Return $aresult[0]
  4634. EndFunc
  4635.  
  4636. Func __misc_getdevicecaps($hdc, $iindex)
  4637.     Local $aresult = DllCall("GDI32.dll", "int", "GetDeviceCaps", "handle", $hdc, "int", $iindex)
  4638.     If @error Then Return SetError(@error, @extended, 0)
  4639.     Return $aresult[0]
  4640. EndFunc
  4641.  
  4642. Func __misc_releasedc($hwnd, $hdc)
  4643.     Local $aresult = DllCall("User32.dll", "int", "ReleaseDC", "hwnd", $hwnd, "handle", $hdc)
  4644.     If @error Then Return SetError(@error, @extended, False)
  4645.     Return $aresult[0] <> 0
  4646. EndFunc
  4647.  
  4648. Global Const $__dlg_wm_user = 1024
  4649. Global Const $bif_browsefilejunctions = 65536
  4650. Global Const $bif_browseforcomputer = 4096
  4651. Global Const $bif_browseforprinter = 8192
  4652. Global Const $bif_browseincludefiles = 16384
  4653. Global Const $bif_browseincludeurls = 128
  4654. Global Const $bif_dontgobelowdomain = 2
  4655. Global Const $bif_editbox = 16
  4656. Global Const $bif_newdialogstyle = 64
  4657. Global Const $bif_nonewfolderbutton = 512
  4658. Global Const $bif_notranslatetargets = 1024
  4659. Global Const $bif_returnfsancestors = 8
  4660. Global Const $bif_returnonlyfsdirs = 1
  4661. Global Const $bif_shareable = 32768
  4662. Global Const $bif_statustext = 4
  4663. Global Const $bif_usenewui = BitOR($bif_editbox, $bif_newdialogstyle)
  4664. Global Const $bif_uahint = 256
  4665. Global Const $bif_validate = 32
  4666. Global Const $bffm_initialized = 1
  4667. Global Const $bffm_iunknown = 5
  4668. Global Const $bffm_selchanged = 2
  4669. Global Const $bffm_validatefailed = 4
  4670. Global Const $bffm_setstatustexta = $__dlg_wm_user + 100
  4671. Global Const $bffm_enableok = $__dlg_wm_user + 101
  4672. Global Const $bffm_setselectiona = $__dlg_wm_user + 102
  4673. Global Const $bffm_setselectionw = $__dlg_wm_user + 103
  4674. Global Const $bffm_setstatustextw = $__dlg_wm_user + 104
  4675. Global Const $bffm_setoktext = $__dlg_wm_user + 105
  4676. Global Const $bffm_setexpanded = $__dlg_wm_user + 106
  4677. Global Const $cderr_dialogfailure = 65535
  4678. Global Const $cderr_findresfailure = 6
  4679. Global Const $cderr_initialization = 2
  4680. Global Const $cderr_loadresfailure = 7
  4681. Global Const $cderr_loadstrfailure = 5
  4682. Global Const $cderr_lockresfailure = 8
  4683. Global Const $cderr_memallocfailure = 9
  4684. Global Const $cderr_memlockfailure = 10
  4685. Global Const $cderr_nohinstance = 4
  4686. Global Const $cderr_nohook = 11
  4687. Global Const $cderr_notemplate = 3
  4688. Global Const $cderr_registermsgfail = 12
  4689. Global Const $cderr_structsize = 1
  4690. Global Const $pderr_createicfailure = 4106
  4691. Global Const $pderr_defaultdifferent = 4108
  4692. Global Const $pderr_dndmmismatch = 4105
  4693. Global Const $pderr_getdevmodefail = 4101
  4694. Global Const $pderr_initfailure = 4102
  4695. Global Const $pderr_loaddrvfailure = 4100
  4696. Global Const $pderr_nodefaultprn = 4104
  4697. Global Const $pderr_nodevices = 4103
  4698. Global Const $pderr_parsefailure = 4098
  4699. Global Const $pderr_printernotfound = 4107
  4700. Global Const $pderr_retdeffailure = 4099
  4701. Global Const $pderr_setupfailure = 4097
  4702. Global Const $cferr_maxlessthanmin = 8194
  4703. Global Const $cferr_nofonts = 8193
  4704. Global Const $fnerr_buffertoosmall = 12291
  4705. Global Const $fnerr_invalidfilename = 12290
  4706. Global Const $fnerr_subclassfailure = 12289
  4707. Global Const $frerr_bufferlengthzero = 16385
  4708. Global Const $fr_dialogterm = 64
  4709. Global Const $fr_down = 1
  4710. Global Const $fr_enablehook = 256
  4711. Global Const $fr_enabletemplate = 512
  4712. Global Const $fr_enabletemplatehandle = 8192
  4713. Global Const $fr_findnext = 8
  4714. Global Const $fr_hideupdown = 16384
  4715. Global Const $fr_hidematchcase = 32768
  4716. Global Const $fr_hidewholeword = 65536
  4717. Global Const $fr_matchcase = 4
  4718. Global Const $fr_nomatchcase = 2048
  4719. Global Const $fr_noupdown = 1024
  4720. Global Const $fr_nowholeword = 4096
  4721. Global Const $fr_replace = 16
  4722. Global Const $fr_replaceall = 32
  4723. Global Const $fr_showhelp = 128
  4724. Global Const $fr_wholeword = 2
  4725. Global Const $shfmt_id_default = 65535
  4726. Global Const $shfmt_opt_full = 0
  4727. Global Const $shfmt_opt_quickformat = 1
  4728. Global Const $shfmt_opt_sysonly = 2
  4729. Global Const $shfmt_error = -1
  4730. Global Const $shfmt_cancel = -2
  4731. Global Const $shfmt_noformat = -3
  4732. Global Const $cdm_first = $__dlg_wm_user + 100
  4733. Global Const $cdm_getspec = $cdm_first
  4734. Global Const $cdm_getfilepath = $cdm_first + 1
  4735. Global Const $cdm_getfolderpath = $cdm_first + 2
  4736. Global Const $cdm_getfolderidlist = $cdm_first + 3
  4737. Global Const $cdm_setcontroltext = $cdm_first + 4
  4738. Global Const $cdm_hidecontrol = $cdm_first + 5
  4739. Global Const $cdm_setdefext = $cdm_first + 6
  4740. Global Const $cdm_last = $__dlg_wm_user + 200
  4741. Global Const $cdn_first = -601
  4742. Global Const $cdn_initdone = $cdn_first
  4743. Global Const $cdn_selchange = $cdn_first - 1
  4744. Global Const $cdn_folderchange = $cdn_first - 2
  4745. Global Const $cdn_shareviolation = $cdn_first - 3
  4746. Global Const $cdn_help = $cdn_first - 4
  4747. Global Const $cdn_fileok = $cdn_first - 5
  4748. Global Const $cdn_typechange = $cdn_first - 6
  4749. Global Const $cdn_includeitem = $cdn_first - 7
  4750. Global Const $cdn_last = -699
  4751. Global Const $psd_defaultminmargins = 0
  4752. Global Const $psd_disablemargins = 16
  4753. Global Const $psd_disableorientation = 256
  4754. Global Const $psd_disablepagepainting = 524288
  4755. Global Const $psd_disablepaper = 512
  4756. Global Const $psd_disableprinter = 32
  4757. Global Const $psd_enablepagepainthook = 262144
  4758. Global Const $psd_enablepagesetuphook = 8192
  4759. Global Const $psd_enablepagesetuptemplate = 32768
  4760. Global Const $psd_enablepagesetuptemplatehandle = 131072
  4761. Global Const $psd_inhundredthsofmillimeters = 8
  4762. Global Const $psd_inthousandthsofinches = 4
  4763. Global Const $psd_margins = 2
  4764. Global Const $psd_minmargins = 1
  4765. Global Const $psd_nonetworkbutton = 2097152
  4766. Global Const $psd_nowarning = 128
  4767. Global Const $psd_returndefault = 1024
  4768. Global Const $psd_showhelp = 2048
  4769. Global Const $wm_psd_pagesetupdlg = $__dlg_wm_user
  4770. Global Const $wm_psd_fullpagerect = $__dlg_wm_user + 1
  4771. Global Const $wm_psd_minmarginrect = $__dlg_wm_user + 2
  4772. Global Const $wm_psd_marginrect = $__dlg_wm_user + 3
  4773. Global Const $wm_psd_greektextrect = $__dlg_wm_user + 4
  4774. Global Const $wm_psd_envstamprect = $__dlg_wm_user + 5
  4775. Global Const $wm_psd_yafullpagerect = $__dlg_wm_user + 6
  4776. Global Const $pd_allpages = 0
  4777. Global Const $pd_collate = 16
  4778. Global Const $pd_currentpage = 4194304
  4779. Global Const $pd_disableprinttofile = 524288
  4780. Global Const $pd_enableprinthook = 4096
  4781. Global Const $pd_enableprinttemplate = 16384
  4782. Global Const $pd_enableprinttemplatehandle = 65536
  4783. Global Const $pd_enablesetuphook = 8192
  4784. Global Const $pd_enablesetuptemplate = 32768
  4785. Global Const $pd_enablesetuptemplatehandle = 131072
  4786. Global Const $pd_exclusionflags = 16777216
  4787. Global Const $pd_hideprinttofile = 1048576
  4788. Global Const $pd_nocurrentpage = 8388608
  4789. Global Const $pd_nonetworkbutton = 2097152
  4790. Global Const $pd_nopagenums = 8
  4791. Global Const $pd_noselection = 4
  4792. Global Const $pd_nowarning = 128
  4793. Global Const $pd_pagenums = 2
  4794. Global Const $pd_printsetup = 64
  4795. Global Const $pd_printtofile = 32
  4796. Global Const $pd_returndc = 256
  4797. Global Const $pd_returndefault = 1024
  4798. Global Const $pd_returnic = 512
  4799. Global Const $pd_selection = 1
  4800. Global Const $pd_showhelp = 2048
  4801. Global Const $pd_usedevmodecopies = 262144
  4802. Global Const $pd_usedevmodecopiesandcollate = $pd_usedevmodecopies
  4803. Global Const $pd_uselargetemplate = 268435456
  4804. Global Const $pd_result_apply = 2
  4805. Global Const $pd_result_cancel = 0
  4806. Global Const $pd_result_print = 1
  4807. Global Const $ewx_logoff = 0
  4808. Global Const $ewx_poweroff = 8
  4809. Global Const $ewx_reboot = 2
  4810. Global Const $ewx_shutdown = 1
  4811. Global Const $ewx_force = 4
  4812. Global Const $ewx_forceifhung = 16
  4813. Global Const $oaif_allow_registration = 1
  4814. Global Const $oaif_register_ext = 2
  4815. Global Const $oaif_exec = 4
  4816. Global Const $oaif_force_registration = 8
  4817. Global Const $oaif_hide_registration = 32
  4818. Global Const $oaif_url_protocol = 64
  4819. Global Const $credui_flags_always_show_ui = 128
  4820. Global Const $credui_flags_complete_username = 2048
  4821. Global Const $credui_flags_do_not_persist = 2
  4822. Global Const $credui_flags_exclude_certificates = 8
  4823. Global Const $credui_flags_expect_confirmation = 131072
  4824. Global Const $credui_flags_generic_credentials = 262144
  4825. Global Const $credui_flags_incorrect_password = 1
  4826. Global Const $credui_flags_keep_username = 1048576
  4827. Global Const $credui_flags_password_only_ok = 512
  4828. Global Const $credui_flags_persist = 4096
  4829. Global Const $credui_flags_request_administrator = 4
  4830. Global Const $credui_flags_require_certificate = 16
  4831. Global Const $credui_flags_require_smartcard = 256
  4832. Global Const $credui_flags_server_credential = 16384
  4833. Global Const $credui_flags_show_save_check_box = 64
  4834. Global Const $credui_flags_username_target_credentials = 524288
  4835. Global Const $credui_flags_validate_username = 1024
  4836. Global Const $creduiwin_authpackage_only = 16
  4837. Global Const $creduiwin_checkbox = 2
  4838. Global Const $creduiwin_enumerate_admins = 256
  4839. Global Const $creduiwin_enumerate_current_user = 512
  4840. Global Const $creduiwin_generic = 1
  4841. Global Const $creduiwin_in_cred_only = 32
  4842. Global Const $creduiwin_secure_prompt = 4096
  4843. Global Const $creduiwin_pack_32_wow = 268435456
  4844. Global Const $creduiwin_preprompting = 8192
  4845. Global Const $dllver_platform_windows = 1
  4846. Global Const $dllver_platform_nt = 2
  4847. Global Const $shcne_allevents = 2147483647
  4848. Global Const $shcne_assocchanged = 134217728
  4849. Global Const $shcne_attributes = 2048
  4850. Global Const $shcne_create = 2
  4851. Global Const $shcne_delete = 4
  4852. Global Const $shcne_driveadd = 256
  4853. Global Const $shcne_driveaddgui = 65536
  4854. Global Const $shcne_driveremoved = 128
  4855. Global Const $shcne_extended_event = 67108864
  4856. Global Const $shcne_freespace = 262144
  4857. Global Const $shcne_mediainserted = 32
  4858. Global Const $shcne_mediaremoved = 64
  4859. Global Const $shcne_mkdir = 8
  4860. Global Const $shcne_netshare = 512
  4861. Global Const $shcne_netunshare = 1024
  4862. Global Const $shcne_renamefolder = 131072
  4863. Global Const $shcne_renameitem = 1
  4864. Global Const $shcne_rmdir = 16
  4865. Global Const $shcne_serverdisconnect = 16384
  4866. Global Const $shcne_updatedir = 4096
  4867. Global Const $shcne_updateimage = 32768
  4868. Global Const $shcne_updateitem = 8192
  4869. Global Const $shcne_diskevents = 145439
  4870. Global Const $shcne_globalevents = 201687520
  4871. Global Const $shcne_interrupt = -2147483648
  4872. Global Const $shcnf_dword = 3
  4873. Global Const $shcnf_idlist = 0
  4874. Global Const $shcnf_path = 1
  4875. Global Const $shcnf_printer = 2
  4876. Global Const $shcnf_flush = 4096
  4877. Global Const $shcnf_flushnowait = 8192
  4878. Global Const $shcnf_notifyrecursive = 65536
  4879. Global Const $shcnrf_interruptlevel = 1
  4880. Global Const $shcnrf_shelllevel = 2
  4881. Global Const $shcnrf_recursiveinterrupt = 4096
  4882. Global Const $shcnrf_newdelivery = 32768
  4883. Global Const $sherb_noconfirmation = 1
  4884. Global Const $sherb_noprogressui = 2
  4885. Global Const $sherb_nosound = 4
  4886. Global Const $sherb_no_ui = BitOR($sherb_noconfirmation, $sherb_noprogressui, $sherb_nosound)
  4887. Global Const $see_mask_default = 0
  4888. Global Const $see_mask_classname = 1
  4889. Global Const $see_mask_classkey = 3
  4890. Global Const $see_mask_idlist = 4
  4891. Global Const $see_mask_invokeidlist = 12
  4892. Global Const $see_mask_icon = 16
  4893. Global Const $see_mask_hotkey = 32
  4894. Global Const $see_mask_nocloseprocess = 64
  4895. Global Const $see_mask_connectnetdrv = 128
  4896. Global Const $see_mask_noasync = 256
  4897. Global Const $see_mask_flag_ddewait = $see_mask_noasync
  4898. Global Const $see_mask_doenvsubst = 512
  4899. Global Const $see_mask_flag_no_ui = 1024
  4900. Global Const $see_mask_unicode = 16384
  4901. Global Const $see_mask_no_console = 32768
  4902. Global Const $see_mask_asyncok = 1048576
  4903. Global Const $see_mask_noqueryclassstore = 16777216
  4904. Global Const $see_mask_hmonitor = 2097152
  4905. Global Const $see_mask_nozonechecks = 8388608
  4906. Global Const $see_mask_waitforinputidle = 33554432
  4907. Global Const $see_mask_flag_log_usage = 67108864
  4908. Global Const $se_err_accessdenied = 5
  4909. Global Const $se_err_associncomplete = 27
  4910. Global Const $se_err_ddebusy = 30
  4911. Global Const $se_err_ddefail = 29
  4912. Global Const $se_err_ddetimeout = 28
  4913. Global Const $se_err_dllnotfound = 32
  4914. Global Const $se_err_fnf = 2
  4915. Global Const $se_err_noassoc = 31
  4916. Global Const $se_err_oom = 8
  4917. Global Const $se_err_pnf = 3
  4918. Global Const $se_err_share = 26
  4919. Global Const $fo_copy = 2
  4920. Global Const $fo_delete = 3
  4921. Global Const $fo_move = 1
  4922. Global Const $fo_rename = 4
  4923. Global Const $fof_allowundo = 64
  4924. Global Const $fof_confirmmouse = 2
  4925. Global Const $fof_filesonly = 128
  4926. Global Const $fof_multidestfiles = 1
  4927. Global Const $fof_noconfirmation = 16
  4928. Global Const $fof_noconfirmmkdir = 512
  4929. Global Const $fof_no_connected_elements = 8192
  4930. Global Const $fof_nocopysecurityattribs = 2048
  4931. Global Const $fof_noerrorui = 1024
  4932. Global Const $fof_norecursereparse = 32768
  4933. Global Const $fof_norecursion = 4096
  4934. Global Const $fof_renameoncollision = 8
  4935. Global Const $fof_silent = 4
  4936. Global Const $fof_simpleprogress = 256
  4937. Global Const $fof_wantmappinghandle = 32
  4938. Global Const $fof_wantnukewarning = 16384
  4939. Global Const $fof_no_ui = BitOR($fof_noconfirmation, $fof_noconfirmmkdir, $fof_noerrorui, $fof_silent)
  4940. Global Const $shgfi_addoverlays = 32
  4941. Global Const $shgfi_attr_specified = 131072
  4942. Global Const $shgfi_attributes = 2048
  4943. Global Const $shgfi_displayname = 512
  4944. Global Const $shgfi_exetype = 8192
  4945. Global Const $shgfi_icon = 256
  4946. Global Const $shgfi_iconlocation = 4096
  4947. Global Const $shgfi_largeicon = 0
  4948. Global Const $shgfi_linkoverlay = 32768
  4949. Global Const $shgfi_openicon = 2
  4950. Global Const $shgfi_overlayindex = 64
  4951. Global Const $shgfi_pidl = 8
  4952. Global Const $shgfi_selected = 65536
  4953. Global Const $shgfi_shelliconsize = 4
  4954. Global Const $shgfi_smallicon = 1
  4955. Global Const $shgfi_sysiconindex = 16384
  4956. Global Const $shgfi_typename = 1024
  4957. Global Const $shgfi_usefileattributes = 16
  4958. Global Const $sfgao_cancopy = 1
  4959. Global Const $sfgao_canmove = 2
  4960. Global Const $sfgao_canlink = 4
  4961. Global Const $sfgao_storage = 8
  4962. Global Const $sfgao_canrename = 16
  4963. Global Const $sfgao_candelete = 32
  4964. Global Const $sfgao_haspropsheet = 64
  4965. Global Const $sfgao_droptarget = 256
  4966. Global Const $sfgao_capabilitymask = BitOR($sfgao_cancopy, $sfgao_canmove, $sfgao_canlink, $sfgao_canrename, $sfgao_candelete, $sfgao_haspropsheet, $sfgao_droptarget)
  4967. Global Const $sfgao_system = 4096
  4968. Global Const $sfgao_encrypted = 8192
  4969. Global Const $sfgao_isslow = 16384
  4970. Global Const $sfgao_ghosted = 32768
  4971. Global Const $sfgao_link = 65536
  4972. Global Const $sfgao_share = 131072
  4973. Global Const $sfgao_readonly = 262144
  4974. Global Const $sfgao_hidden = 524288
  4975. Global Const $sfgao_displayattrmask = BitOR($sfgao_isslow, $sfgao_ghosted, $sfgao_link, $sfgao_share, $sfgao_readonly, $sfgao_hidden)
  4976. Global Const $sfgao_nonenumerated = 1048576
  4977. Global Const $sfgao_newcontent = 2097152
  4978. Global Const $sfgao_stream = 4194304
  4979. Global Const $sfgao_storageancestor = 8388608
  4980. Global Const $sfgao_validate = 16777216
  4981. Global Const $sfgao_removable = 33554432
  4982. Global Const $sfgao_compressed = 67108864
  4983. Global Const $sfgao_browsable = 134217728
  4984. Global Const $sfgao_filesysancestor = 268435456
  4985. Global Const $sfgao_folder = 536870912
  4986. Global Const $sfgao_filesystem = 1073741824
  4987. Global Const $sfgao_storagecapmask = BitOR($sfgao_storage, $sfgao_link, $sfgao_readonly, $sfgao_stream, $sfgao_storageancestor, $sfgao_filesysancestor, $sfgao_folder, $sfgao_filesystem)
  4988. Global Const $sfgao_hassubfolder = -2147483648
  4989. Global Const $sfgao_contentsmask = $sfgao_hassubfolder
  4990. Global Const $sfgao_pkeysfgaomask = BitOR($sfgao_isslow, $sfgao_readonly, $sfgao_hassubfolder, $sfgao_validate)
  4991. Global Const $ido_shgioi_default = 268435452
  4992. Global Const $ido_shgioi_link = 268435454
  4993. Global Const $ido_shgioi_share = 268435455
  4994. Global Const $ido_shgioi_slowfile = 268435453
  4995. Global Const $fcsm_viewid = 1
  4996. Global Const $fcsm_webviewtemplate = 2
  4997. Global Const $fcsm_infotip = 4
  4998. Global Const $fcsm_clsid = 8
  4999. Global Const $fcsm_iconfile = 16
  5000. Global Const $fcsm_logo = 32
  5001. Global Const $fcsm_flags = 64
  5002. Global Const $fcs_read = 1
  5003. Global Const $fcs_forcewrite = 2
  5004. Global Const $fcs_write = BitOR($fcs_read, $fcs_forcewrite)
  5005. Global Const $ssf_autocheckselect = 8388608
  5006. Global Const $ssf_desktophtml = 512
  5007. Global Const $ssf_dontprettypath = 2048
  5008. Global Const $ssf_doubleclickinwebview = 128
  5009. Global Const $ssf_hideicons = 16384
  5010. Global Const $ssf_iconsonly = 16777216
  5011. Global Const $ssf_mapnetdrvbutton = 4096
  5012. Global Const $ssf_noconfirmrecycle = 32768
  5013. Global Const $ssf_nonetcrawling = 1048576
  5014. Global Const $ssf_sepprocess = 524288
  5015. Global Const $ssf_showallobjects = 1
  5016. Global Const $ssf_showcompcolor = 8
  5017. Global Const $ssf_showextensions = 2
  5018. Global Const $ssf_showinfotip = 8192
  5019. Global Const $ssf_showsuperhidden = 262144
  5020. Global Const $ssf_showsysfiles = 32
  5021. Global Const $ssf_showtypeoverlay = 33554432
  5022. Global Const $ssf_startpanelon = 2097152
  5023. Global Const $ssf_win95classic = 1024
  5024. Global Const $ssf_webview = 131072
  5025. Global Const $csidl_admintools = 48
  5026. Global Const $csidl_altstartup = 29
  5027. Global Const $csidl_appdata = 26
  5028. Global Const $csidl_bitbucket = 10
  5029. Global Const $csidl_cdburn_area = 59
  5030. Global Const $csidl_common_admintools = 47
  5031. Global Const $csidl_common_altstartup = 30
  5032. Global Const $csidl_common_appdata = 35
  5033. Global Const $csidl_common_desktopdirectory = 25
  5034. Global Const $csidl_common_documents = 46
  5035. Global Const $csidl_common_favorites = 31
  5036. Global Const $csidl_common_music = 53
  5037. Global Const $csidl_common_pictures = 54
  5038. Global Const $csidl_common_programs = 23
  5039. Global Const $csidl_common_startmenu = 22
  5040. Global Const $csidl_common_startup = 24
  5041. Global Const $csidl_common_templates = 45
  5042. Global Const $csidl_common_video = 55
  5043. Global Const $csidl_computersnearme = 61
  5044. Global Const $csidl_connections = 49
  5045. Global Const $csidl_controls = 3
  5046. Global Const $csidl_cookies = 33
  5047. Global Const $csidl_desktop = 0
  5048. Global Const $csidl_desktopdirectory = 16
  5049. Global Const $csidl_drives = 17
  5050. Global Const $csidl_favorites = 6
  5051. Global Const $csidl_fonts = 20
  5052. Global Const $csidl_internet_cache = 32
  5053. Global Const $csidl_history = 34
  5054. Global Const $csidl_local_appdata = 28
  5055. Global Const $csidl_mymusic = 13
  5056. Global Const $csidl_mypictures = 39
  5057. Global Const $csidl_myvideo = 14
  5058. Global Const $csidl_nethood = 19
  5059. Global Const $csidl_personal = 5
  5060. Global Const $csidl_printers = 4
  5061. Global Const $csidl_printhood = 27
  5062. Global Const $csidl_profile = 40
  5063. Global Const $csidl_program_files = 38
  5064. Global Const $csidl_program_files_common = 43
  5065. Global Const $csidl_program_files_commonx86 = 44
  5066. Global Const $csidl_program_filesx86 = 42
  5067. Global Const $csidl_programs = 2
  5068. Global Const $csidl_recent = 8
  5069. Global Const $csidl_sendto = 9
  5070. Global Const $csidl_startmenu = 11
  5071. Global Const $csidl_startup = 7
  5072. Global Const $csidl_system = 37
  5073. Global Const $csidl_systemx86 = 41
  5074. Global Const $csidl_templates = 21
  5075. Global Const $csidl_windows = 36
  5076. Global Const $siid_docnoassoc = 0
  5077. Global Const $siid_docassoc = 1
  5078. Global Const $siid_application = 2
  5079. Global Const $siid_folder = 3
  5080. Global Const $siid_folderopen = 4
  5081. Global Const $siid_drive525 = 5
  5082. Global Const $siid_drive35 = 6
  5083. Global Const $siid_driveremove = 7
  5084. Global Const $siid_drivefixed = 8
  5085. Global Const $siid_drivenet = 9
  5086. Global Const $siid_drivenetdisabled = 10
  5087. Global Const $siid_drivecd = 11
  5088. Global Const $siid_driveram = 12
  5089. Global Const $siid_world = 13
  5090. Global Const $siid_server = 15
  5091. Global Const $siid_printer = 16
  5092. Global Const $siid_mynetwork = 17
  5093. Global Const $siid_find = 22
  5094. Global Const $siid_help = 23
  5095. Global Const $siid_share = 28
  5096. Global Const $siid_link = 29
  5097. Global Const $siid_slowfile = 30
  5098. Global Const $siid_recycler = 31
  5099. Global Const $siid_recyclerfull = 32
  5100. Global Const $siid_mediacdaudio = 40
  5101. Global Const $siid_lock = 47
  5102. Global Const $siid_autolist = 49
  5103. Global Const $siid_printernet = 50
  5104. Global Const $siid_servershare = 51
  5105. Global Const $siid_printerfax = 52
  5106. Global Const $siid_printerfaxnet = 53
  5107. Global Const $siid_printerfile = 54
  5108. Global Const $siid_stack = 55
  5109. Global Const $siid_mediasvcd = 56
  5110. Global Const $siid_stuffedfolder = 57
  5111. Global Const $siid_driveunknown = 58
  5112. Global Const $siid_drivedvd = 59
  5113. Global Const $siid_mediadvd = 60
  5114. Global Const $siid_mediadvdram = 61
  5115. Global Const $siid_mediadvdrw = 62
  5116. Global Const $siid_mediadvdr = 63
  5117. Global Const $siid_mediadvdrom = 64
  5118. Global Const $siid_mediacdaudioplus = 65
  5119. Global Const $siid_mediacdrw = 66
  5120. Global Const $siid_mediacdr = 67
  5121. Global Const $siid_mediacdburn = 68
  5122. Global Const $siid_mediablankcd = 69
  5123. Global Const $siid_mediacdrom = 70
  5124. Global Const $siid_audiofiles = 71
  5125. Global Const $siid_imagefiles = 72
  5126. Global Const $siid_videofiles = 73
  5127. Global Const $siid_mixedfiles = 74
  5128. Global Const $siid_folderback = 75
  5129. Global Const $siid_folderfront = 76
  5130. Global Const $siid_shield = 77
  5131. Global Const $siid_warning = 78
  5132. Global Const $siid_info = 79
  5133. Global Const $siid_error = 80
  5134. Global Const $siid_key = 81
  5135. Global Const $siid_software = 82
  5136. Global Const $siid_rename = 83
  5137. Global Const $siid_delete = 84
  5138. Global Const $siid_mediaaudiodvd = 85
  5139. Global Const $siid_mediamoviedvd = 86
  5140. Global Const $siid_mediaenhancedcd = 87
  5141. Global Const $siid_mediaenhanceddvd = 88
  5142. Global Const $siid_mediahddvd = 89
  5143. Global Const $siid_mediabluray = 90
  5144. Global Const $siid_mediavcd = 91
  5145. Global Const $siid_mediadvdplusr = 92
  5146. Global Const $siid_mediadvdplusrw = 93
  5147. Global Const $siid_desktoppc = 94
  5148. Global Const $siid_mobilepc = 95
  5149. Global Const $siid_users = 96
  5150. Global Const $siid_mediasmartmedia = 97
  5151. Global Const $siid_mediacompactflash = 98
  5152. Global Const $siid_devicecellphone = 99
  5153. Global Const $siid_devicecamera = 100
  5154. Global Const $siid_devicevideocamera = 101
  5155. Global Const $siid_deviceaudioplayer = 102
  5156. Global Const $siid_networkconnect = 103
  5157. Global Const $siid_internet = 104
  5158. Global Const $siid_zipfile = 105
  5159. Global Const $siid_settings = 106
  5160. Global Const $siid_drivehddvd = 132
  5161. Global Const $siid_drivebd = 133
  5162. Global Const $siid_mediahddvdrom = 134
  5163. Global Const $siid_mediahddvdr = 135
  5164. Global Const $siid_mediahddvdram = 136
  5165. Global Const $siid_mediabdrom = 137
  5166. Global Const $siid_mediabdr = 138
  5167. Global Const $siid_mediabdre = 139
  5168. Global Const $siid_clustereddrive = 140
  5169. Global Const $siid_max_icons = 174
  5170. Global Const $shgsi_iconlocation = 0
  5171. Global Const $shgsi_icon = $shgfi_icon
  5172. Global Const $shgsi_sysiconindex = $shgfi_sysiconindex
  5173. Global Const $shgsi_linkoverlay = $shgfi_linkoverlay
  5174. Global Const $shgsi_selected = $shgfi_selected
  5175. Global Const $shgsi_largeicon = $shgfi_largeicon
  5176. Global Const $shgsi_smallicon = $shgfi_smallicon
  5177. Global Const $shgsi_shelliconsize = $shgfi_shelliconsize
  5178. Global Const $nim_add = 0
  5179. Global Const $nim_modify = 1
  5180. Global Const $nim_delete = 2
  5181. Global Const $nim_setfocus = 3
  5182. Global Const $nim_setversion = 4
  5183. Global Const $nif_message = 1
  5184. Global Const $nif_icon = 2
  5185. Global Const $nif_tip = 4
  5186. Global Const $nif_state = 8
  5187. Global Const $nif_info = 16
  5188. Global Const $nif_guid = 32
  5189. Global Const $nif_realtime = 64
  5190. Global Const $nif_showtip = 128
  5191. Global Const $nis_hidden = 1
  5192. Global Const $nis_sharedicon = 2
  5193. Global Const $niif_none = 0
  5194. Global Const $niif_info = 1
  5195. Global Const $niif_warning = 2
  5196. Global Const $niif_error = 3
  5197. Global Const $niif_user = 4
  5198. Global Const $niif_nosound = 16
  5199. Global Const $niif_large_icon = 16
  5200. Global Const $niif_respect_quiet_time = 128
  5201. Global Const $niif_icon_mask = 15
  5202. Global Const $shop_printername = 1
  5203. Global Const $shop_filepath = 2
  5204. Global Const $shop_volumeguid = 4
  5205. Global Const $ofasi_edit = 1
  5206. Global Const $ofasi_opendesktop = 2
  5207. Global Const $quns_not_present = 1
  5208. Global Const $quns_busy = 2
  5209. Global Const $quns_running_d3d_full_screen = 3
  5210. Global Const $quns_presentation_mode = 4
  5211. Global Const $quns_accepts_notifications = 5
  5212. Global Const $quns_quiet_time = 6
  5213. Global Const $rest_norun = 1
  5214. Global Const $rest_noclose = 2
  5215. Global Const $rest_nosaveset = 3
  5216. Global Const $rest_nofilemenu = 4
  5217. Global Const $rest_nosetfolders = 5
  5218. Global Const $rest_nosettaskbar = 6
  5219. Global Const $rest_nodesktop = 7
  5220. Global Const $rest_nofind = 8
  5221. Global Const $rest_nodrives = 9
  5222. Global Const $rest_nodriveautorun = 10
  5223. Global Const $rest_nodrivetypeautorun = 11
  5224. Global Const $rest_nonethood = 12
  5225. Global Const $rest_startbanner = 13
  5226. Global Const $rest_restrictrun = 14
  5227. Global Const $rest_noprintertabs = 15
  5228. Global Const $rest_noprinterdelete = 16
  5229. Global Const $rest_noprinteradd = 17
  5230. Global Const $rest_nostartmenusubfolders = 18
  5231. Global Const $rest_mydocsonnet = 19
  5232. Global Const $rest_noexittodos = 20
  5233. Global Const $rest_enforceshellextsecurity = 21
  5234. Global Const $rest_linkresolveignorelinkinfo = 22
  5235. Global Const $rest_nocommongroups = 23
  5236. Global Const $rest_separatedesktopprocess = 24
  5237. Global Const $rest_noweb = 25
  5238. Global Const $rest_notraycontextmenu = 26
  5239. Global Const $rest_noviewcontextmenu = 27
  5240. Global Const $rest_nonetconnectdisconnect = 28
  5241. Global Const $rest_startmenulogoff = 29
  5242. Global Const $rest_nosettingsassist = 30
  5243. Global Const $rest_nointerneticon = 31
  5244. Global Const $rest_norecentdocshistory = 32
  5245. Global Const $rest_norecentdocsmenu = 33
  5246. Global Const $rest_noactivedesktop = 34
  5247. Global Const $rest_noactivedesktopchanges = 35
  5248. Global Const $rest_nofavoritesmenu = 36
  5249. Global Const $rest_clearrecentdocsonexit = 37
  5250. Global Const $rest_classicshell = 38
  5251. Global Const $rest_nocustomizewebview = 39
  5252. Global Const $rest_nohtmlwallpaper = 40
  5253. Global Const $rest_nochangingwallpaper = 41
  5254. Global Const $rest_nodeskcomp = 42
  5255. Global Const $rest_noadddeskcomp = 43
  5256. Global Const $rest_nodeldeskcomp = 44
  5257. Global Const $rest_noclosedeskcomp = 45
  5258. Global Const $rest_noclose_dragdropband = 46
  5259. Global Const $rest_nomovingband = 47
  5260. Global Const $rest_noeditdeskcomp = 48
  5261. Global Const $rest_noresolvesearch = 49
  5262. Global Const $rest_noresolvetrack = 50
  5263. Global Const $rest_forcecopyaclwithfile = 51
  5264. Global Const $rest_nologo3channelnotify = 52
  5265. Global Const $rest_noforgetsoftwareupdate = 53
  5266. Global Const $rest_nosetactivedesktop = 54
  5267. Global Const $rest_noupdatewindows = 55
  5268. Global Const $rest_nochangestarmenu = 56
  5269. Global Const $rest_nofolderoptions = 57
  5270. Global Const $rest_hasfindcomputers = 58
  5271. Global Const $rest_intellimenus = 59
  5272. Global Const $rest_rundlgmemcheckbox = 60
  5273. Global Const $rest_arp_showpostsetup = 61
  5274. Global Const $rest_nocsc = 62
  5275. Global Const $rest_nocontrolpanel = 63
  5276. Global Const $rest_enumworkgroup = 64
  5277. Global Const $rest_arp_noarp = 65
  5278. Global Const $rest_arp_noremovepage = 66
  5279. Global Const $rest_arp_noaddpage = 67
  5280. Global Const $rest_arp_nowinsetuppage = 68
  5281. Global Const $rest_greymsiads = 69
  5282. Global Const $rest_nochangemappeddrivelabel = 70
  5283. Global Const $rest_nochangemappeddrivecomment = 71
  5284. Global Const $rest_maxrecentdocs = 72
  5285. Global Const $rest_nonetworkconnections = 73
  5286. Global Const $rest_forcestartmenulogoff = 74
  5287. Global Const $rest_nowebview = 75
  5288. Global Const $rest_nocustomizethisfolder = 76
  5289. Global Const $rest_noencryption = 77
  5290. Global Const $rest_dontshowsuperhidden = 78
  5291. Global Const $rest_noshellsearchbutton = 79
  5292. Global Const $rest_nohardwaretab = 80
  5293. Global Const $rest_norunasinstallprompt = 81
  5294. Global Const $rest_promptrunasinstallnetpath = 82
  5295. Global Const $rest_nomanagemycomputerverb = 83
  5296. Global Const $rest_norecentdocsnethood = 84
  5297. Global Const $rest_disallowrun = 85
  5298. Global Const $rest_nowelcomescreen = 86
  5299. Global Const $rest_restrictcpl = 87
  5300. Global Const $rest_disallowcpl = 88
  5301. Global Const $rest_nosmballoontip = 89
  5302. Global Const $rest_nosmhelp = 90
  5303. Global Const $rest_nowinkeys = 91
  5304. Global Const $rest_noencryptonmove = 92
  5305. Global Const $rest_nolocalmachinerun = 93
  5306. Global Const $rest_nocurrentuserrun = 94
  5307. Global Const $rest_nolocalmachinerunonce = 95
  5308. Global Const $rest_nocurrentuserrunonce = 96
  5309. Global Const $rest_forceactivedesktopon = 97
  5310. Global Const $rest_nocomputersnearme = 98
  5311. Global Const $rest_noviewondrive = 99
  5312. Global Const $rest_nonetcrawl = 100
  5313. Global Const $rest_noshareddocuments = 101
  5314. Global Const $rest_nosmmydocs = 102
  5315. Global Const $rest_nosmmypics = 103
  5316. Global Const $rest_allowbitbuckdrives = 104
  5317. Global Const $rest_nonlegacyshellmode = 105
  5318. Global Const $rest_nocontrolpanelbarricade = 106
  5319. Global Const $rest_nostartpage = 107
  5320. Global Const $rest_noautotraynotify = 108
  5321. Global Const $rest_notaskgrouping = 109
  5322. Global Const $rest_nocdburning = 110
  5323. Global Const $rest_mycompnoprop = 111
  5324. Global Const $rest_mydocsnoprop = 112
  5325. Global Const $rest_nostartpanel = 113
  5326. Global Const $rest_nodisplayappearancepage = 114
  5327. Global Const $rest_nothemestab = 115
  5328. Global Const $rest_novisualstylechoice = 116
  5329. Global Const $rest_nosizechoice = 117
  5330. Global Const $rest_nocolorchoice = 118
  5331. Global Const $rest_setvisualstyle = 119
  5332. Global Const $rest_startrunnohomepath = 120
  5333. Global Const $rest_nousernameinstartpanel = 121
  5334. Global Const $rest_nomycomputericon = 122
  5335. Global Const $rest_nosmnetworkplaces = 123
  5336. Global Const $rest_nosmpinnedlist = 124
  5337. Global Const $rest_nosmmymusic = 125
  5338. Global Const $rest_nosmejectpc = 126
  5339. Global Const $rest_nosmmoreprograms = 127
  5340. Global Const $rest_nosmmfuprograms = 128
  5341. Global Const $rest_notrayitemsdisplay = 129
  5342. Global Const $rest_notoolbarsontaskbar = 130
  5343. Global Const $rest_nosmconfigureprograms = 131
  5344. Global Const $rest_hideclock = 132
  5345. Global Const $rest_nolowdiskspacechecks = 133
  5346. Global Const $rest_noentirenetwork = 134
  5347. Global Const $rest_nodesktopcleanup = 135
  5348. Global Const $rest_bitbucknukeondelete = 136
  5349. Global Const $rest_bitbuckconfirmdelete = 137
  5350. Global Const $rest_bitbucknoprop = 138
  5351. Global Const $rest_nodispbackground = 139
  5352. Global Const $rest_nodispscreensavepg = 140
  5353. Global Const $rest_nodispsettingspg = 141
  5354. Global Const $rest_nodispscreensavepreview = 142
  5355. Global Const $rest_nodisplaycpl = 143
  5356. Global Const $rest_hiderunasverb = 144
  5357. Global Const $rest_nothumbnailcache = 145
  5358. Global Const $rest_nostrcmplogical = 146
  5359. Global Const $rest_nopublishwizard = 147
  5360. Global Const $rest_noonlineprintswizard = 148
  5361. Global Const $rest_nowebservices = 149
  5362. Global Const $rest_allowunhashedwebview = 150
  5363. Global Const $rest_allowlegacywebview = 151
  5364. Global Const $rest_revertwebviewsecurity = 152
  5365. Global Const $rest_inheritconsolehandles = 153
  5366. Global Const $rest_sortmaxitemcount = 154
  5367. Global Const $rest_noremoterecursiveevents = 155
  5368. Global Const $rest_noremotechangenotify = 156
  5369. Global Const $rest_nosimplenetidlist = 157
  5370. Global Const $rest_noenumentirenetwork = 158
  5371. Global Const $rest_nodetailsthumbnailonnetwork = 159
  5372. Global Const $rest_nointernetopenwith = 160
  5373. Global Const $rest_allowlegacylmzbehavior = 161
  5374. Global Const $rest_dontretrybadnetname = 162
  5375. Global Const $rest_allowfileclsidjunctions = 163
  5376. Global Const $rest_noupnpinstall = 164
  5377. Global Const $rest_arp_dontgrouppatches = 165
  5378. Global Const $rest_arp_nochooseprogramspage = 166
  5379. Global Const $rest_nodisconnect = 167
  5380. Global Const $rest_nosecurity = 168
  5381. Global Const $rest_nofileassociate = 169
  5382. Global Const $rest_allowcommenttoggle = 170
  5383. Global Const $rest_usedesktopinicache = 171
  5384. Global Const $gil_dontcache = 16
  5385. Global Const $gil_notfilename = 8
  5386. Global Const $gil_perclass = 4
  5387. Global Const $gil_perinstance = 2
  5388. Global Const $gil_simulatedoc = 1
  5389. Global Const $gil_shield = 512
  5390. Global Const $gil_forcenoshield = 1024
  5391. Global Const $folderid_addnewprograms = "{DE61D971-5EBC-4F02-A3A9-6C82895E5C04}"
  5392. Global Const $folderid_admintools = "{724EF170-A42D-4FEF-9F26-B60E846FBA4F}"
  5393. Global Const $folderid_appupdates = "{A305CE99-F527-492B-8B1A-7E76FA98D6E4}"
  5394. Global Const $folderid_cdburning = "{9E52AB10-F80D-49DF-ACB8-4330F5687855}"
  5395. Global Const $folderid_changeremoveprograms = "{DF7266AC-9274-4867-8D55-3BD661DE872D}"
  5396. Global Const $folderid_commonadmintools = "{D0384E7D-BAC3-4797-8F14-CBA229B392B5}"
  5397. Global Const $folderid_commonoemlinks = "{C1BAE2D0-10DF-4334-BEDD-7AA20B227A9D}"
  5398. Global Const $folderid_commonprograms = "{0139D44E-6AFE-49F2-8690-3DAFCAE6FFB8}"
  5399. Global Const $folderid_commonstartmenu = "{A4115719-D62E-491D-AA7C-E74B8BE3B067}"
  5400. Global Const $folderid_commonstartup = "{82A5EA35-D9CD-47C5-9629-E15D2F714E6E}"
  5401. Global Const $folderid_commontemplates = "{B94237E7-57AC-4347-9151-B08C6C32D1F7}"
  5402. Global Const $folderid_computerfolder = "{0AC0837C-BBF8-452A-850D-79D08E667CA7}"
  5403. Global Const $folderid_conflictfolder = "{4BFEFB45-347D-4006-A5BE-AC0CB0567192}"
  5404. Global Const $folderid_connectionsfolder = "{6F0CD92B-2E97-45D1-88FF-B0D186B8DEDD}"
  5405. Global Const $folderid_contacts = "{56784854-C6CB-462B-8169-88E350ACB882}"
  5406. Global Const $folderid_controlpanelfolder = "{82A74AEB-AEB4-465C-A014-D097EE346D63}"
  5407. Global Const $folderid_cookies = "{2B0F765D-C0E9-4171-908E-08A611B84FF6}"
  5408. Global Const $folderid_desktop = "{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}"
  5409. Global Const $folderid_devicemetadatastore = "{5CE4A5E9-E4EB-479D-B89F-130C02886155}"
  5410. Global Const $folderid_documentslibrary = "{7B0DB17D-9CD2-4A93-9733-46CC89022E7C}"
  5411. Global Const $folderid_downloads = "{374DE290-123F-4565-9164-39C4925E467B}"
  5412. Global Const $folderid_favorites = "{1777F761-68AD-4D8A-87BD-30B759FA33DD}"
  5413. Global Const $folderid_fonts = "{FD228CB7-AE11-4AE3-864C-16F3910AB8FE}"
  5414. Global Const $folderid_games = "{CAC52C1A-B53D-4EDC-92D7-6B2E8AC19434}"
  5415. Global Const $folderid_gametasks = "{054FAE61-4DD8-4787-80B6-090220C4B700}"
  5416. Global Const $folderid_history = "{D9DC8A3B-B784-432E-A781-5A1130A75963}"
  5417. Global Const $folderid_homegroup = "{52528A6B-B9E3-4ADD-B60D-588C2DBA842D}"
  5418. Global Const $folderid_implicitappshortcuts = "{BCB5256F-79F6-4CEE-B725-DC34E402FD46}"
  5419. Global Const $folderid_internetcache = "{352481E8-33BE-4251-BA85-6007CAEDCF9D}"
  5420. Global Const $folderid_internetfolder = "{4D9F7874-4E0C-4904-967B-40B0D20C3E4B}"
  5421. Global Const $folderid_libraries = "{1B3EA5DC-B587-4786-B4EF-BD1DC332AEAE}"
  5422. Global Const $folderid_links = "{BFB9D5E0-C6A9-404C-B2B2-AE6DB6AF4968}"
  5423. Global Const $folderid_localappdata = "{F1B32785-6FBA-4FCF-9D55-7B8E7F157091}"
  5424. Global Const $folderid_localappdatalow = "{A520A1A4-1780-4FF6-BD18-167343C5AF16}"
  5425. Global Const $folderid_localizedresourcesdir = "{2A00375E-224C-49DE-B8D1-440DF7EF3DDC}"
  5426. Global Const $folderid_music = "{4BD8D571-6D19-48D3-BE97-422220080E43}"
  5427. Global Const $folderid_musiclibrary = "{2112AB0A-C86A-4FFE-A368-0DE96E47012E}"
  5428. Global Const $folderid_nethood = "{C5ABBF53-E17F-4121-8900-86626FC2C973}"
  5429. Global Const $folderid_networkfolder = "{D20BEEC4-5CA8-4905-AE3B-BF251EA09B53}"
  5430. Global Const $folderid_originalimages = "{2C36C0AA-5812-4B87-BFD0-4CD0DFB19B39}"
  5431. Global Const $folderid_photoalbums = "{69D2CF90-FC33-4FB7-9A0C-EBB0F0FCB43C}"
  5432. Global Const $folderid_pictureslibrary = "{A990AE9F-A03B-4E80-94BC-9912D7504104}"
  5433. Global Const $folderid_pictures = "{33E28130-4E1E-4676-835A-98395C3BC3BB}"
  5434. Global Const $folderid_playlists = "{DE92C1C7-837F-4F69-A3BB-86E631204A23}"
  5435. Global Const $folderid_printersfolder = "{76FC4E2D-D6AD-4519-A663-37BD56068185}"
  5436. Global Const $folderid_printhood = "{9274BD8D-CFD1-41C3-B35E-B13F55A758F4}"
  5437. Global Const $folderid_profile = "{5E6C858F-0E22-4760-9AFE-EA3317B67173}"
  5438. Global Const $folderid_programdata = "{62AB5D82-FDC1-4DC3-A9DD-070D1D495D97}"
  5439. Global Const $folderid_programfiles = "{905E63B6-C1BF-494E-B29C-65B732D3D21A}"
  5440. Global Const $folderid_programfilesx64 = "{6D809377-6AF0-444B-8957-A3773F02200E}"
  5441. Global Const $folderid_programfilesx86 = "{7C5A40EF-A0FB-4BFC-874A-C0F2E0B9FA8E}"
  5442. Global Const $folderid_programfilescommon = "{F7F1ED05-9F6D-47A2-AAAE-29D317C6F066}"
  5443. Global Const $folderid_programfilescommonx64 = "{6365D5A7-0F0D-45E5-87F6-0DA56B6A4F7D}"
  5444. Global Const $folderid_programfilescommonx86 = "{DE974D24-D9C6-4D3E-BF91-F4455120B917}"
  5445. Global Const $folderid_programs = "{A77F5D77-2E2B-44C3-A6A2-ABA601054A51}"
  5446. Global Const $folderid_public = "{DFDF76A2-C82A-4D63-906A-5644AC457385}"
  5447. Global Const $folderid_publicdesktop = "{C4AA340D-F20F-4863-AFEF-F87EF2E6BA25}"
  5448. Global Const $folderid_publicdocuments = "{ED4824AF-DCE4-45A8-81E2-FC7965083634}"
  5449. Global Const $folderid_publicdownloads = "{3D644C9B-1FB8-4F30-9B45-F670235F79C0}"
  5450. Global Const $folderid_publicgametasks = "{DEBF2536-E1A8-4C59-B6A2-414586476AEA}"
  5451. Global Const $folderid_publiclibraries = "{48DAF80B-E6CF-4F4E-B800-0E69D84EE384}"
  5452. Global Const $folderid_publicmusic = "{3214FAB5-9757-4298-BB61-92A9DEAA44FF}"
  5453. Global Const $folderid_publicpictures = "{B6EBFB86-6907-413C-9AF7-4FC2ABF07CC5}"
  5454. Global Const $folderid_publicringtones = "{E555AB60-153B-4D17-9F04-A5FE99FC15EC}"
  5455. Global Const $folderid_publicvideos = "{2400183A-6185-49FB-A2D8-4A392A602BA3}"
  5456. Global Const $folderid_quicklaunch = "{52A4F021-7B75-48A9-9F6B-4B87A210BC8F}"
  5457. Global Const $folderid_recent = "{AE50C081-EBD2-438A-8655-8A092E34987A}"
  5458. Global Const $folderid_recordedtvlibrary = "{1A6FDBA2-F42D-4358-A798-B74D745926C5}"
  5459. Global Const $folderid_recyclebinfolder = "{B7534046-3ECB-4C18-BE4E-64CD4CB7D6AC}"
  5460. Global Const $folderid_resourcedir = "{8AD10C31-2ADB-4296-A8F7-E4701232C972}"
  5461. Global Const $folderid_ringtones = "{C870044B-F49E-4126-A9C3-B52A1FF411E8}"
  5462. Global Const $folderid_roamingappdata = "{3EB685DB-65F9-4CF6-A03A-E3EF65729F3D}"
  5463. Global Const $folderid_samplemusic = "{B250C668-F57D-4EE1-A63C-290EE7D1AA1F}"
  5464. Global Const $folderid_samplepictures = "{C4900540-2379-4C75-844B-64E6FAF8716B}"
  5465. Global Const $folderid_sampleplaylists = "{15CA69B3-30EE-49C1-ACE1-6B5EC372AFB5}"
  5466. Global Const $folderid_samplevideos = "{859EAD94-2E85-48AD-A71A-0969CB56A6CD}"
  5467. Global Const $folderid_savedgames = "{4C5C32FF-BB9D-43B0-B5B4-2D72E54EAAA4}"
  5468. Global Const $folderid_savedsearches = "{7D1D3A04-DEBB-4115-95CF-2F29DA2920DA}"
  5469. Global Const $folderid_search_csc = "{EE32E446-31CA-4ABA-814F-A5EBD2FD6D5E}"
  5470. Global Const $folderid_search_mapi = "{98EC0E18-2098-4D44-8644-66979315A281}"
  5471. Global Const $folderid_searchhome = "{190337D1-B8CA-4121-A639-6D472D16972A}"
  5472. Global Const $folderid_sendto = "{8983036C-27C0-404B-8F08-102D10DCFD74}"
  5473. Global Const $folderid_sidebardefaultparts = "{7B396E54-9EC5-4300-BE0A-2482EBAE1A26}"
  5474. Global Const $folderid_sidebarparts = "{A75D362E-50FC-4FB7-AC2C-A8BEAA314493}"
  5475. Global Const $folderid_startmenu = "{625B53C3-AB48-4EC1-BA1F-A1EF4146FC19}"
  5476. Global Const $folderid_startup = "{B97D20BB-F46A-4C97-BA10-5E3608430854}"
  5477. Global Const $folderid_syncmanagerfolder = "{43668BF8-C14E-49B2-97C9-747784D784B7}"
  5478. Global Const $folderid_syncresultsfolder = "{289A9A43-BE44-4057-A41B-587A76D7E7F9}"
  5479. Global Const $folderid_syncsetupfolder = "{0F214138-B1D3-4A90-BBA9-27CBC0C5389A}"
  5480. Global Const $folderid_system = "{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}"
  5481. Global Const $folderid_systemx86 = "{D65231B0-B2F1-4857-A4CE-A8E7C6EA7D27}"
  5482. Global Const $folderid_templates = "{A63293E8-664E-48DB-A079-DF759E0509F7}"
  5483. Global Const $folderid_userpinned = "{9E3995AB-1F9C-4F13-B827-48B24B6C7174}"
  5484. Global Const $folderid_userprofiles = "{0762D272-C50A-4BB0-A382-697DCD729B80}"
  5485. Global Const $folderid_userprogramfiles = "{5CD7AEE2-2219-4A67-B85D-6C9CE15660CB}"
  5486. Global Const $folderid_userprogramfilescommon = "{BCBD3057-CA5C-4622-B42D-BC56DB0AE516}"
  5487. Global Const $folderid_usersfiles = "{F3CE0F7C-4901-4ACC-8648-D5D44B04EF8F}"
  5488. Global Const $folderid_userslibraries = "{A302545D-DEFF-464B-ABE8-61C8648D939B}"
  5489. Global Const $folderid_videos = "{18989B1D-99B5-455B-841C-AB7C74E4DDFC}"
  5490. Global Const $folderid_videoslibrary = "{491E922F-5643-4AF4-A7EB-4E7A138D8174}"
  5491. Global Const $folderid_windows = "{F38BF404-1D43-42F2-9305-67DE0B28FC23}"
  5492. Global Const $kf_flag_alias_only = -2147483648
  5493. Global Const $kf_flag_create = 32768
  5494. Global Const $kf_flag_dont_verify = 16384
  5495. Global Const $kf_flag_dont_unexpand = 8192
  5496. Global Const $kf_flag_no_alias = 4096
  5497. Global Const $kf_flag_init = 2048
  5498. Global Const $kf_flag_default_path = 1024
  5499. Global Const $kf_flag_no_appcontainer_redirection = 65536
  5500. Global Const $kf_flag_not_parent_relative = 512
  5501. Global Const $kf_flag_simple_idlist = 256
  5502. Global Const $coinit_apartmentthreaded = 2
  5503. Global Const $coinit_disable_ole1dde = 4
  5504. Global Const $coinit_multithreaded = 0
  5505. Global Const $coinit_speed_over_memory = 8
  5506. #Region Global Variables and Constants
  5507.     Global $__enum, $__ext = 0
  5508.     Global $__hheap = 0, $__irgbmode = 1
  5509.     Global Const $tagosversioninfo = "struct;dword OSVersionInfoSize;dword MajorVersion;dword MinorVersion;dword BuildNumber;dword PlatformId;wchar CSDVersion[128];endstruct"
  5510.     Global Const $__winver = __winver()
  5511.     Global Const $__udfver = 776
  5512.     #Region Functions list
  5513.     #EndRegion Functions list
  5514.     #Region Public Functions
  5515.  
  5516.         Func _winapi_arraytostruct(Const ByRef $adata, $istart = 0, $iend = -1)
  5517.             If __checkerrorarraybounds($adata, $istart, $iend) Then Return SetError(@error + 10, @extended, 0)
  5518.             Local $struct = ""
  5519.             For $i = $istart To $iend
  5520.                 $struct &= "wchar[" & (StringLen($adata[$i]) + 1) & "];"
  5521.             Next
  5522.             Local $tdata = DllStructCreate($struct & "wchar[1]")
  5523.             Local $count = 1
  5524.             For $i = $istart To $iend
  5525.                 DllStructSetData($tdata, $count, $adata[$i])
  5526.                 $count += 1
  5527.             Next
  5528.             DllStructSetData($tdata, $count, ChrW(0))
  5529.             Return $tdata
  5530.         EndFunc
  5531.  
  5532.         Func _winapi_createmargins($ileftwidth, $irightwidth, $itopheight, $ibottomheight)
  5533.             Local $tmargins = DllStructCreate($tagmargins)
  5534.             DllStructSetData($tmargins, 1, $ileftwidth)
  5535.             DllStructSetData($tmargins, 2, $irightwidth)
  5536.             DllStructSetData($tmargins, 3, $itopheight)
  5537.             DllStructSetData($tmargins, 4, $ibottomheight)
  5538.             Return $tmargins
  5539.         EndFunc
  5540.  
  5541.         Func _winapi_createpoint($ix, $iy)
  5542.             Local $tpoint = DllStructCreate($tagpoint)
  5543.             DllStructSetData($tpoint, 1, $ix)
  5544.             DllStructSetData($tpoint, 2, $iy)
  5545.             Return $tpoint
  5546.         EndFunc
  5547.  
  5548.         Func _winapi_createrect($ileft, $itop, $iright, $ibottom)
  5549.             Local $trect = DllStructCreate($tagrect)
  5550.             DllStructSetData($trect, 1, $ileft)
  5551.             DllStructSetData($trect, 2, $itop)
  5552.             DllStructSetData($trect, 3, $iright)
  5553.             DllStructSetData($trect, 4, $ibottom)
  5554.             Return $trect
  5555.         EndFunc
  5556.  
  5557.         Func _winapi_createrectex($ix, $iy, $iwidth, $iheight)
  5558.             Local $trect = DllStructCreate($tagrect)
  5559.             DllStructSetData($trect, 1, $ix)
  5560.             DllStructSetData($trect, 2, $iy)
  5561.             DllStructSetData($trect, 3, $ix + $iwidth)
  5562.             DllStructSetData($trect, 4, $iy + $iheight)
  5563.             Return $trect
  5564.         EndFunc
  5565.  
  5566.         Func _winapi_createsize($iwidth, $iheight)
  5567.             Local $tsize = DllStructCreate($tagsize)
  5568.             DllStructSetData($tsize, 1, $iwidth)
  5569.             DllStructSetData($tsize, 2, $iheight)
  5570.             Return $tsize
  5571.         EndFunc
  5572.  
  5573.         Func _winapi_fatalexit($icode)
  5574.             DllCall("kernel32.dll", "none", "FatalExit", "int", $icode)
  5575.             If @error Then Return SetError(@error, @extended)
  5576.         EndFunc
  5577.  
  5578.         Func _winapi_getbitmapdimension($hbitmap)
  5579.             Local Const $tagbitmap = "struct;long bmType;long bmWidth;long bmHeight;long bmWidthBytes;ushort bmPlanes;ushort bmBitsPixel;ptr bmBits;endstruct"
  5580.             Local $tobj = DllStructCreate($tagbitmap)
  5581.             Local $ret = DllCall("gdi32.dll", "int", "GetObject", "handle", $hbitmap, "int", DllStructGetSize($tobj), "struct*", $tobj)
  5582.             If @error OR NOT $ret[0] Then Return SetError(@error + 10, @extended, 0)
  5583.             Return _winapi_createsize(DllStructGetData($tobj, "bmWidth"), DllStructGetData($tobj, "bmHeight"))
  5584.         EndFunc
  5585.  
  5586.         Func _winapi_getstring($pstring, $funicode = 1)
  5587.             Local $length = _winapi_strlen($pstring, $funicode)
  5588.             If @error OR NOT $length Then Return SetError(@error + 10, @extended, "")
  5589.             Local $tstring = DllStructCreate(__iif($funicode, "wchar", "char") & "[" & ($length + 1) & "]", $pstring)
  5590.             If @error Then Return SetError(@error, @extended, "")
  5591.             Return SetExtended($length, DllStructGetData($tstring, 1))
  5592.         EndFunc
  5593.  
  5594.         Func _winapi_isbadreadptr($paddress, $ilength)
  5595.             Local $ret = DllCall("kernel32.dll", "bool", "IsBadReadPtr", "ptr", $paddress, "uint_ptr", $ilength)
  5596.             If @error Then Return SetError(@error, @extended, False)
  5597.             Return $ret[0]
  5598.         EndFunc
  5599.  
  5600.         Func _winapi_isbadwriteptr($paddress, $ilength)
  5601.             Local $ret = DllCall("kernel32.dll", "bool", "IsBadWritePtr", "ptr", $paddress, "uint_ptr", $ilength)
  5602.             If @error Then Return SetError(@error, @extended, False)
  5603.             Return $ret[0]
  5604.         EndFunc
  5605.  
  5606.         Func _winapi_iswow64process($pid = 0)
  5607.             If NOT $pid Then $pid = @AutoItPID
  5608.             Local $hprocess = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", __iif($__winver < 1536, 1024, 4096), "bool", 0, "dword", $pid)
  5609.             If @error OR NOT $hprocess[0] Then Return SetError(@error + 20, @extended, False)
  5610.             Local $ret = DllCall("kernel32.dll", "bool", "IsWow64Process", "handle", $hprocess[0], "bool*", 0)
  5611.             If __checkerrorclosehandle($ret, $hprocess[0]) Then Return SetError(@error, @extended, False)
  5612.             Return $ret[2]
  5613.         EndFunc
  5614.  
  5615.         Func _winapi_movememory($pdestination, $psource, $ilength)
  5616.             If _winapi_isbadreadptr($psource, $ilength) Then Return SetError(10, @extended, 0)
  5617.             If _winapi_isbadwriteptr($pdestination, $ilength) Then Return SetError(11, @extended, 0)
  5618.             DllCall("ntdll.dll", "none", "RtlMoveMemory", "ptr", $pdestination, "ptr", $psource, "ulong_ptr", $ilength)
  5619.             If @error Then Return SetError(@error, @extended, 0)
  5620.             Return 1
  5621.         EndFunc
  5622.  
  5623.         Func _winapi_pathisdirectory($spath)
  5624.             Local $ret = DllCall("shlwapi.dll", "bool", "PathIsDirectoryW", "wstr", $spath)
  5625.             If @error Then Return SetError(@error, @extended, False)
  5626.             Return $ret[0]
  5627.         EndFunc
  5628.  
  5629.         Func _winapi_strlen($pstring, $funicode = 1)
  5630.             Local $w = ""
  5631.             If $funicode Then $w = "W"
  5632.             Local $ret = DllCall("kernel32.dll", "int", "lstrlen" & $w, "ptr", $pstring)
  5633.             If @error Then Return SetError(@error, @extended, 0)
  5634.             Return $ret[0]
  5635.         EndFunc
  5636.  
  5637.         Func _winapi_structtoarray(ByRef $tstruct, $iitems = 0)
  5638.             Local $size = 2 * Floor(DllStructGetSize($tstruct) / 2)
  5639.             Local $pstruct = DllStructGetPtr($tstruct)
  5640.             If NOT $size OR NOT $pstruct Then Return SetError(1, 0, 0)
  5641.             Local $tdata, $length, $offset = 0
  5642.             Local $result[101] = [0]
  5643.             While 1
  5644.                 $length = _winapi_strlen($pstruct + $offset)
  5645.                 If NOT $length Then
  5646.                     ExitLoop
  5647.                 EndIf
  5648.                 If 2 * (1 + $length) + $offset > $size Then Return SetError(3, 0, 0)
  5649.                 $tdata = DllStructCreate("wchar[" & (1 + $length) & "]", $pstruct + $offset)
  5650.                 If @error Then Return SetError(@error + 10, 0, 0)
  5651.                 __inc($result)
  5652.                 $result[$result[0]] = DllStructGetData($tdata, 1)
  5653.                 If $result[0] = $iitems Then
  5654.                     ExitLoop
  5655.                 EndIf
  5656.                 $offset += 2 * (1 + $length)
  5657.                 If $offset >= $size Then Return SetError(3, 0, 0)
  5658.             WEnd
  5659.             If NOT $result[0] Then Return SetError(2, 0, 0)
  5660.             __inc($result, -1)
  5661.             Return $result
  5662.         EndFunc
  5663.  
  5664.         Func _winapi_switchcolor($icolor)
  5665.             If $icolor = -1 Then Return $icolor
  5666.             Return BitOR(BitAND($icolor, 65280), BitShift(BitAND($icolor, 255), -16), BitShift(BitAND($icolor, 16711680), 16))
  5667.         EndFunc
  5668.  
  5669.         Func _winapi_zeromemory($pmemory, $ilength)
  5670.             If _winapi_isbadwriteptr($pmemory, $ilength) Then Return SetError(11, @extended, 0)
  5671.             DllCall("ntdll.dll", "none", "RtlZeroMemory", "ptr", $pmemory, "ulong_ptr", $ilength)
  5672.             If @error Then Return SetError(@error, @extended, 0)
  5673.             Return 1
  5674.         EndFunc
  5675.  
  5676.     #EndRegion Public Functions
  5677.     #Region Internal Functions
  5678.  
  5679.         Func __checkerrorarraybounds(Const ByRef $adata, ByRef $istart, ByRef $iend, $ndim = 1, $idim = 0)
  5680.             If NOT IsArray($adata) Then Return SetError(1, 0, 1)
  5681.             If UBound($adata, $idim) <> $ndim Then Return SetError(2, 0, 1)
  5682.             If $istart < 0 Then $istart = 0
  5683.             Local $iubound = UBound($adata) - 1
  5684.             If $iend < 1 OR $iend > $iubound Then $iend = $iubound
  5685.             If $istart > $iend Then Return SetError(4, 0, 1)
  5686.             Return 0
  5687.         EndFunc
  5688.  
  5689.         Func __checkerrorclosehandle($aret, $hfile, $blasterror = 0, $curerr = @error, $curext = @extended)
  5690.             If NOT $curerr AND NOT $aret[0] Then $curerr = 10
  5691.             Local $ilasterror = _winapi_getlasterror()
  5692.             DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hfile)
  5693.             If $curerr Then _winapi_setlasterror($ilasterror)
  5694.             If $blasterror Then $curext = $ilasterror
  5695.             Return SetError($curerr, $curext, $curerr)
  5696.         EndFunc
  5697.  
  5698.         Func __dll($spath, $fpin = 0)
  5699.             Local $ret = DllCall("kernel32.dll", "bool", "GetModuleHandleExW", "dword", __iif($fpin, 1, 2), "wstr", $spath, "ptr*", 0)
  5700.             If NOT $ret[3] Then
  5701.                 Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryW", "wstr", $spath)
  5702.                 If NOT $aresult[0] Then Return 0
  5703.             EndIf
  5704.             Return 1
  5705.         EndFunc
  5706.  
  5707.         Func __enumwindowsproc($hwnd, $fvisible)
  5708.             Local $aresult
  5709.             If ($fvisible) Then
  5710.                 $aresult = DllCall("user32.dll", "bool", "IsWindowVisible", "hwnd", $hwnd)
  5711.                 If NOT $aresult[0] Then
  5712.                     Return 1
  5713.                 EndIf
  5714.             EndIf
  5715.             __inc($__enum)
  5716.             $__enum[$__enum[0][0]][0] = $hwnd
  5717.             $aresult = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $hwnd, "wstr", "", "int", 4096)
  5718.             $__enum[$__enum[0][0]][1] = $aresult[2]
  5719.             Return 1
  5720.         EndFunc
  5721.  
  5722.         Func __fatalexit($icode, $stext = "")
  5723.             If $stext Then MsgBox(262160, "AutoIt", $stext)
  5724.             _winapi_fatalexit($icode)
  5725.         EndFunc
  5726.  
  5727.         Func __heapalloc($isize, $fabort = 0)
  5728.             Local $ret
  5729.             If NOT $__hheap Then
  5730.                 $ret = DllCall("kernel32.dll", "handle", "HeapCreate", "dword", 0, "ulong_ptr", 0, "ulong_ptr", 0)
  5731.                 If @error OR NOT $ret[0] Then __fatalexit(1, "Error allocating memory.")
  5732.                 $__hheap = $ret[0]
  5733.             EndIf
  5734.             $ret = DllCall("kernel32.dll", "ptr", "HeapAlloc", "handle", $__hheap, "dword", 8, "ulong_ptr", $isize)
  5735.             If @error OR NOT $ret[0] Then
  5736.                 If $fabort Then __fatalexit(1, "Error allocating memory.")
  5737.                 Return SetError(@error + 30, @extended, 0)
  5738.             EndIf
  5739.             Return $ret[0]
  5740.         EndFunc
  5741.  
  5742.         Func __heapfree(ByRef $pmemory, $fcheck = 0, $curerr = @error, $curext = @extended)
  5743.             If $fcheck AND (NOT __heapvalidate($pmemory)) Then Return SetError(@error, @extended, 0)
  5744.             Local $ret = DllCall("kernel32.dll", "int", "HeapFree", "ptr", $__hheap, "dword", 0, "ptr", $pmemory)
  5745.             If @error OR NOT $ret[0] Then Return SetError(@error + 40, @extended, 0)
  5746.             $pmemory = 0
  5747.             Return SetError($curerr, $curext, 1)
  5748.         EndFunc
  5749.  
  5750.         Func __heaprealloc($pmemory, $isize, $famount = 0, $fabort = 0)
  5751.             Local $ret
  5752.             If __heapvalidate($pmemory) Then
  5753.                 If $famount AND (__heapsize($pmemory) >= $isize) Then Return SetExtended(1, Ptr($pmemory))
  5754.                 $ret = DllCall("kernel32.dll", "ptr", "HeapReAlloc", "handle", $__hheap, "dword", 8, "ptr", $pmemory, "ulong_ptr", $isize)
  5755.                 If @error OR NOT $ret[0] Then
  5756.                     If $fabort Then __fatalexit(1, "Error allocating memory.")
  5757.                     Return SetError(@error + 20, @extended, Ptr($pmemory))
  5758.                 EndIf
  5759.                 $ret = $ret[0]
  5760.             Else
  5761.                 $ret = __heapalloc($isize, $fabort)
  5762.                 If @error Then Return SetError(@error, @extended, 0)
  5763.             EndIf
  5764.             Return $ret
  5765.         EndFunc
  5766.  
  5767.         Func __heapsize($pmemory, $fcheck = 0)
  5768.             If $fcheck AND (NOT __heapvalidate($pmemory)) Then Return SetError(@error, @extended, 0)
  5769.             Local $ret = DllCall("kernel32.dll", "ulong_ptr", "HeapSize", "handle", $__hheap, "dword", 0, "ptr", $pmemory)
  5770.             If @error OR ($ret[0] = Ptr(-1)) Then Return SetError(@error + 50, @extended, 0)
  5771.             Return $ret[0]
  5772.         EndFunc
  5773.  
  5774.         Func __heapvalidate($pmemory)
  5775.             If (NOT $__hheap) OR (NOT Ptr($pmemory)) Then Return SetError(9, 0, False)
  5776.             Local $ret = DllCall("kernel32.dll", "int", "HeapValidate", "handle", $__hheap, "dword", 0, "ptr", $pmemory)
  5777.             If @error Then Return SetError(@error, @extended, False)
  5778.             Return $ret[0]
  5779.         EndFunc
  5780.  
  5781.         Func __inc(ByRef $adata, $iincrement = 100)
  5782.             Select
  5783.                 Case UBound($adata, 2)
  5784.                     If $iincrement < 0 Then
  5785.                         ReDim $adata[$adata[0][0] + 1][UBound($adata, 2)]
  5786.                     Else
  5787.                         $adata[0][0] += 1
  5788.                         If $adata[0][0] > UBound($adata) - 1 Then
  5789.                             ReDim $adata[$adata[0][0] + $iincrement][UBound($adata, 2)]
  5790.                         EndIf
  5791.                     EndIf
  5792.                 Case UBound($adata, 1)
  5793.                     If $iincrement < 0 Then
  5794.                         ReDim $adata[$adata[0] + 1]
  5795.                     Else
  5796.                         $adata[0] += 1
  5797.                         If $adata[0] > UBound($adata) - 1 Then
  5798.                             ReDim $adata[$adata[0] + $iincrement]
  5799.                         EndIf
  5800.                     EndIf
  5801.                 Case Else
  5802.                     Return 0
  5803.             EndSelect
  5804.             Return 1
  5805.         EndFunc
  5806.  
  5807.         Func __iif($ftest, $vtrue, $vfalse)
  5808.             If $ftest Then
  5809.                 Return $vtrue
  5810.             Else
  5811.                 Return $vfalse
  5812.             EndIf
  5813.         EndFunc
  5814.  
  5815.         Func __init($bdata)
  5816.             Local $length = BinaryLen($bdata)
  5817.             Local $ret = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", 0, "ulong_ptr", $length, "dword", 4096, "dword", 64)
  5818.             If @error OR NOT $ret[0] Then __fatalexit(1, "Error allocating memory.")
  5819.             Local $tdata = DllStructCreate("byte[" & $length & "]", $ret[0])
  5820.             DllStructSetData($tdata, 1, $bdata)
  5821.             Return $ret[0]
  5822.         EndFunc
  5823.  
  5824.         Func __rgb($icolor)
  5825.             If $__irgbmode Then
  5826.                 $icolor = _winapi_switchcolor($icolor)
  5827.             EndIf
  5828.             Return $icolor
  5829.         EndFunc
  5830.  
  5831.         Func __winver()
  5832.             Local $tosvi = DllStructCreate($tagosversioninfo)
  5833.             DllStructSetData($tosvi, 1, DllStructGetSize($tosvi))
  5834.             Local $ret = DllCall("kernel32.dll", "bool", "GetVersionExW", "struct*", $tosvi)
  5835.             If @error OR NOT $ret[0] Then Return SetError(@error, @extended, 0)
  5836.             Return BitOR(BitShift(DllStructGetData($tosvi, 2), -8), DllStructGetData($tosvi, 3))
  5837.         EndFunc
  5838.  
  5839.     #EndRegion Internal Functions
  5840.     #Region Global Variables and Constants
  5841.         Global Const $__winapicom_tagguid = "struct;ulong Data1;ushort Data2;ushort Data3;byte Data4[8];endstruct"
  5842.     #EndRegion Global Variables and Constants
  5843.     #Region Functions list
  5844.     #EndRegion Functions list
  5845.     #Region Public Functions
  5846.  
  5847.         Func _winapi_clsidfromprogid($progid)
  5848.             Local $tguid = DllStructCreate($__winapicom_tagguid)
  5849.             Local $ret = DllCall("ole32.dll", "long", "CLSIDFromProgID", "wstr", $progid, "struct*", $tguid)
  5850.             If @error Then Return SetError(@error, @extended, "")
  5851.             If $ret[0] Then Return SetError(10, $ret[0], "")
  5852.             $ret = DllCall("ole32.dll", "int", "StringFromGUID2", "struct*", $tguid, "wstr", "", "int", 39)
  5853.             If @error OR NOT $ret[0] Then Return SetError(@error + 20, @extended, "")
  5854.             Return $ret[2]
  5855.         EndFunc
  5856.  
  5857.         Func _winapi_coinitialize($iflags = 0)
  5858.             Local $ret = DllCall("ole32.dll", "long", "CoInitializeEx", "ptr", 0, "dword", $iflags)
  5859.             If @error Then Return SetError(@error, @extended, 0)
  5860.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  5861.             Return 1
  5862.         EndFunc
  5863.  
  5864.         Func _winapi_cotaskmemalloc($isize)
  5865.             Local $ret = DllCall("ole32.dll", "ptr", "CoTaskMemAlloc", "uint_ptr", $isize)
  5866.             If @error Then Return SetError(@error, @extended, 0)
  5867.             Return $ret[0]
  5868.         EndFunc
  5869.  
  5870.         Func _winapi_cotaskmemfree($pmemory)
  5871.             DllCall("ole32.dll", "none", "CoTaskMemFree", "ptr", $pmemory)
  5872.             If @error Then Return SetError(@error, @extended, 0)
  5873.             Return 1
  5874.         EndFunc
  5875.  
  5876.         Func _winapi_cotaskmemrealloc($pmemory, $isize)
  5877.             Local $ret = DllCall("ole32.dll", "ptr", "CoTaskMemRealloc", "ptr", $pmemory, "ulong_ptr", $isize)
  5878.             If @error Then Return SetError(@error, @extended, 0)
  5879.             Return $ret[0]
  5880.         EndFunc
  5881.  
  5882.         Func _winapi_couninitialize()
  5883.             DllCall("ole32.dll", "none", "CoUninitialize")
  5884.             If @error Then Return SetError(@error, @extended, 0)
  5885.             Return 1
  5886.         EndFunc
  5887.  
  5888.         Func _winapi_createguid()
  5889.             Local $tguid = DllStructCreate($__winapicom_tagguid)
  5890.             Local $ret = DllCall("ole32.dll", "long", "CoCreateGuid", "struct*", $tguid)
  5891.             If @error Then Return SetError(@error, @extended, "")
  5892.             If $ret[0] Then Return SetError(10, $ret[0], "")
  5893.             $ret = DllCall("ole32.dll", "int", "StringFromGUID2", "struct*", $tguid, "wstr", "", "int", 65536)
  5894.             If @error OR NOT $ret[0] Then Return SetError(@error + 20, @extended, "")
  5895.             Return $ret[2]
  5896.         EndFunc
  5897.  
  5898.         Func _winapi_createstreamonhglobal($hglobal = 0, $fdeleteonrelease = 1)
  5899.             Local $ret = DllCall("ole32.dll", "long", "CreateStreamOnHGlobal", "handle", $hglobal, "bool", $fdeleteonrelease, "ptr*", 0)
  5900.             If @error Then Return SetError(@error, @extended, 0)
  5901.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  5902.             Return $ret[3]
  5903.         EndFunc
  5904.  
  5905.         Func _winapi_gethglobalfromstream($pstream)
  5906.             Local $ret = DllCall("ole32.dll", "uint", "GetHGlobalFromStream", "ptr", $pstream, "ptr*", 0)
  5907.             If @error Then Return SetError(@error, @extended, 0)
  5908.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  5909.             Return $ret[2]
  5910.         EndFunc
  5911.  
  5912.         Func _winapi_progidfromclsid($clsid)
  5913.             Local $tguid = DllStructCreate($__winapicom_tagguid)
  5914.             Local $ret = DllCall("ole32.dll", "uint", "CLSIDFromString", "wstr", $clsid, "struct*", $tguid)
  5915.             If @error OR $ret[0] Then Return SetError(@error + 20, @extended, "")
  5916.             $ret = DllCall("ole32.dll", "uint", "ProgIDFromCLSID", "ptr", DllStructGetPtr($tguid), "ptr*", 0)
  5917.             If @error Then Return SetError(@error, @extended, "")
  5918.             If $ret[0] Then Return SetError(10, $ret[0], "")
  5919.             Local $id = _winapi_getstring($ret[2])
  5920.             _winapi_cotaskmemfree($ret[2])
  5921.             Return $id
  5922.         EndFunc
  5923.  
  5924.         Func _winapi_releasestream($pstream)
  5925.             Local $ret = DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $pstream, "ulong_ptr", 8 * (1 + @AutoItX64), "uint", 4, "ushort", 23, "uint", 0, "ptr", 0, "ptr", 0, "str", "")
  5926.             If @error Then Return SetError(@error, @extended, 0)
  5927.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  5928.             Return 1
  5929.         EndFunc
  5930.  
  5931.     #EndRegion Public Functions
  5932.     Global Const $url_scheme_invalid = -1
  5933.     Global Const $url_scheme_unknown = 0
  5934.     Global Const $url_scheme_ftp = 1
  5935.     Global Const $url_scheme_http = 2
  5936.     Global Const $url_scheme_gopher = 3
  5937.     Global Const $url_scheme_mailto = 4
  5938.     Global Const $url_scheme_news = 5
  5939.     Global Const $url_scheme_nntp = 6
  5940.     Global Const $url_scheme_telnet = 7
  5941.     Global Const $url_scheme_wais = 8
  5942.     Global Const $url_scheme_file = 9
  5943.     Global Const $url_scheme_mk = 10
  5944.     Global Const $url_scheme_https = 11
  5945.     Global Const $url_scheme_shell = 12
  5946.     Global Const $url_scheme_snews = 13
  5947.     Global Const $url_scheme_local = 14
  5948.     Global Const $url_scheme_javascript = 15
  5949.     Global Const $url_scheme_vbscript = 16
  5950.     Global Const $url_scheme_about = 17
  5951.     Global Const $url_scheme_res = 18
  5952.     Global Const $url_scheme_msshellrooted = 19
  5953.     Global Const $url_scheme_msshellidlist = 20
  5954.     Global Const $url_scheme_mshelp = 21
  5955.     Global Const $url_scheme_msshelldevice = 22
  5956.     Global Const $url_scheme_wildcard = 23
  5957.     Global Const $url_scheme_search_ms = 24
  5958.     Global Const $url_scheme_search = 25
  5959.     Global Const $url_scheme_knownfolder = 26
  5960.     Global Const $gct_invalid = 0
  5961.     Global Const $gct_lfnchar = 1
  5962.     Global Const $gct_separator = 8
  5963.     Global Const $gct_shortchar = 2
  5964.     Global Const $gct_wild = 4
  5965.     Global Const $url_apply_default = 1
  5966.     Global Const $url_apply_guessscheme = 2
  5967.     Global Const $url_apply_guessfile = 4
  5968.     Global Const $url_apply_forceapply = 8
  5969.     Global Const $url_dont_simplify = 134217728
  5970.     Global Const $url_escape_as_utf8 = 262144
  5971.     Global Const $url_escape_percent = 4096
  5972.     Global Const $url_escape_spaces_only = 67108864
  5973.     Global Const $url_escape_unsafe = 536870912
  5974.     Global Const $url_no_meta = 134217728
  5975.     Global Const $url_pluggable_protocol = 1073741824
  5976.     Global Const $url_unescape = 268435456
  5977.     Global Const $url_part_hostname = 2
  5978.     Global Const $url_part_password = 4
  5979.     Global Const $url_part_port = 5
  5980.     Global Const $url_part_query = 6
  5981.     Global Const $url_part_scheme = 1
  5982.     Global Const $url_part_username = 3
  5983.     Global Const $urlis_appliable = 4
  5984.     Global Const $urlis_directory = 5
  5985.     Global Const $urlis_fileurl = 3
  5986.     Global Const $urlis_hasquery = 6
  5987.     Global Const $urlis_nohistory = 2
  5988.     Global Const $urlis_opaque = 1
  5989.     Global Const $urlis_url = 0
  5990.     #Region Functions list
  5991.     #EndRegion Functions list
  5992.     #Region Public Functions
  5993.  
  5994.         Func _winapi_commandlinetoargv($scmd)
  5995.             Local $result[1] = [0]
  5996.             $scmd = StringStripWS($scmd, 3)
  5997.             If NOT $scmd Then
  5998.                 Return $result
  5999.             EndIf
  6000.             Local $ret = DllCall("shell32.dll", "ptr", "CommandLineToArgvW", "wstr", $scmd, "int*", 0)
  6001.             If @error OR NOT $ret[0] OR (NOT $ret[2]) Then Return SetError(@error + 10, @extended, 0)
  6002.             Local $tptr = DllStructCreate("ptr[" & $ret[2] & "]", $ret[0])
  6003.             Dim $result[$ret[2] + 1] = [$ret[2]]
  6004.             For $i = 1 To $ret[2]
  6005.                 $result[$i] = _winapi_getstring(DllStructGetData($tptr, 1, $i))
  6006.             Next
  6007.             DllCall("kernel32.dll", "handle", "LocalFree", "handle", $ret[0])
  6008.             Return $result
  6009.         EndFunc
  6010.  
  6011.         Func _winapi_isnameinexpression($sstring, $spattern, $fcasesensitive = 0)
  6012.             If NOT $fcasesensitive Then $spattern = StringUpper($spattern)
  6013.             Local $tus1 = __us($spattern)
  6014.             Local $tus2 = __us($sstring)
  6015.             Local $ret = DllCall("ntdll.dll", "boolean", "RtlIsNameInExpression", "struct*", $tus1, "struct*", $tus2, "boolean", NOT $fcasesensitive, "ptr", 0)
  6016.             If @error Then Return SetError(@error, @extended, False)
  6017.             Return $ret[0]
  6018.         EndFunc
  6019.  
  6020.         Func _winapi_parseurl($surl)
  6021.             Local $tagparsedurl = "dword Size;ptr Protocol;uint cchProtocol;ptr Suffix;uint cchSuffix;uint Scheme"
  6022.             Local $tpurl = DllStructCreate($tagparsedurl)
  6023.             DllStructSetData($tpurl, 1, DllStructGetSize($tpurl))
  6024.             Local $turl = DllStructCreate("wchar[4096]")
  6025.             DllStructSetData($turl, 1, $surl)
  6026.             Local $ret = DllCall("shlwapi.dll", "long", "ParseURLW", "struct*", $turl, "struct*", $tpurl)
  6027.             If @error Then Return SetError(@error, @extended, "")
  6028.             If $ret[0] Then Return SetError(10, $ret[0], "")
  6029.             Local $result[3]
  6030.             $result[0] = DllStructGetData(DllStructCreate("wchar[" & DllStructGetData($tpurl, 3) & "]", DllStructGetData($tpurl, 2)), 1)
  6031.             $result[1] = DllStructGetData(DllStructCreate("wchar[" & DllStructGetData($tpurl, 5) & "]", DllStructGetData($tpurl, 4)), 1)
  6032.             $result[2] = DllStructGetData($tpurl, 6)
  6033.             Return $result
  6034.         EndFunc
  6035.  
  6036.         Func _winapi_parseusername($suser)
  6037.             If NOT __dll("credui.dll") Then Return SetError(103, 0, 0)
  6038.             Local $ret = DllCall("credui.dll", "dword", "CredUIParseUserNameW", "wstr", $suser, "wstr", "", "ulong", 4096, "wstr", "", "ulong", 4096)
  6039.             If @error Then Return SetError(@error, @extended, 0)
  6040.             Switch $ret[0]
  6041.                 Case 0
  6042.                 Case 1315
  6043.                     If StringStripWS($suser, 3) Then
  6044.                         $ret[2] = $suser
  6045.                         $ret[4] = ""
  6046.                     Else
  6047.                         ContinueCase
  6048.                     EndIf
  6049.                 Case Else
  6050.                     Return SetError(10, $ret[0], 0)
  6051.             EndSwitch
  6052.             Local $result[2]
  6053.             $result[0] = $ret[4]
  6054.             $result[1] = $ret[2]
  6055.             Return $result
  6056.         EndFunc
  6057.  
  6058.         Func _winapi_pathaddbackslash($spath)
  6059.             Local $tpath = DllStructCreate("wchar[260]")
  6060.             DllStructSetData($tpath, 1, $spath)
  6061.             Local $ret = DllCall("shlwapi.dll", "ptr", "PathAddBackslashW", "struct*", $tpath)
  6062.             If @error OR NOT $ret[0] Then Return SetError(@error, @extended, "")
  6063.             Return DllStructGetData($tpath, 1)
  6064.         EndFunc
  6065.  
  6066.         Func _winapi_pathaddextension($spath, $sext = "")
  6067.             Local $tpath = DllStructCreate("wchar[260]")
  6068.             DllStructSetData($tpath, 1, $spath)
  6069.             Local $typeofext = "wstr"
  6070.             If NOT StringStripWS($sext, 3) Then
  6071.                 $typeofext = "ptr"
  6072.                 $sext = 0
  6073.             EndIf
  6074.             Local $ret = DllCall("shlwapi.dll", "bool", "PathAddExtensionW", "struct*", $tpath, $typeofext, $sext)
  6075.             If @error Then Return SetError(@error, @extended, "")
  6076.             Return SetExtended($ret[0], DllStructGetData($tpath, 1))
  6077.         EndFunc
  6078.  
  6079.         Func _winapi_pathappend($spath, $smore)
  6080.             Local $tpath = DllStructCreate("wchar[260]")
  6081.             DllStructSetData($tpath, 1, $spath)
  6082.             Local $ret = DllCall("shlwapi.dll", "bool", "PathAppendW", "struct*", $tpath, "wstr", $smore)
  6083.             If @error OR NOT $ret[0] Then Return SetError(@error, @extended, "")
  6084.             Return DllStructGetData($tpath, 1)
  6085.         EndFunc
  6086.  
  6087.         Func _winapi_pathbuildroot($idrive)
  6088.             Local $ret = DllCall("shlwapi.dll", "ptr", "PathBuildRootW", "wstr", "", "int", $idrive)
  6089.             If @error Then Return SetError(@error, @extended, "")
  6090.             Return $ret[1]
  6091.         EndFunc
  6092.  
  6093.         Func _winapi_pathcanonicalize($spath)
  6094.             Local $ret = DllCall("shlwapi.dll", "bool", "PathCanonicalizeW", "wstr", "", "wstr", $spath)
  6095.             If @error OR NOT $ret[0] Then Return SetError(@error, @extended, $spath)
  6096.             Return $ret[1]
  6097.         EndFunc
  6098.  
  6099.         Func _winapi_pathcommonprefix($spath1, $spath2)
  6100.             Local $ret = DllCall("shlwapi.dll", "int", "PathCommonPrefixW", "wstr", $spath1, "wstr", $spath2, "wstr", "")
  6101.             If @error Then Return SetError(@error, @extended, "")
  6102.             Return SetExtended($ret[0], $ret[3])
  6103.         EndFunc
  6104.  
  6105.         Func _winapi_pathcompactpath($hwnd, $spath, $iwidth = 0)
  6106.             If $iwidth < 1 Then
  6107.                 Local $trect = DllStructCreate($tagrect)
  6108.                 DllCall("user32.dll", "bool", "GetClientRect", "hwnd", $hwnd, "struct*", $trect)
  6109.                 $iwidth += DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left")
  6110.             EndIf
  6111.             Local $ret = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hwnd)
  6112.             If @error OR NOT $ret[0] Then Return SetError(@error + 20, @extended, $spath)
  6113.             Local $hdc = $ret[0]
  6114.             Local Const $wm_getfont = 49
  6115.             $ret = DllCall("user32.dll", "ptr", "SendMessage", "hwnd", $hwnd, "uint", $wm_getfont, "wparam", 0, "lparam", 0)
  6116.             Local $hback = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hdc, "handle", $ret[0])
  6117.             Local $ierror = 0
  6118.             $ret = DllCall("shlwapi.dll", "bool", "PathCompactPathW", "handle", $hdc, "wstr", $spath, "int", $iwidth)
  6119.             If @error OR NOT $ret[0] Then $ierror = @error + 10
  6120.             DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hdc, "handle", $hback[0])
  6121.             DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hwnd, "handle", $hdc)
  6122.             If $ierror Then Return SetError($ierror, 0, $spath)
  6123.             Return $ret[2]
  6124.         EndFunc
  6125.  
  6126.         Func _winapi_pathcompactpathex($spath, $imax)
  6127.             Local $ret = DllCall("shlwapi.dll", "bool", "PathCompactPathExW", "wstr", "", "wstr", $spath, "uint", $imax + 1, "dword", 0)
  6128.             If @error OR NOT $ret[0] Then Return SetError(@error + 10, @extended, $spath)
  6129.             Return $ret[1]
  6130.         EndFunc
  6131.  
  6132.         Func _winapi_pathcreatefromurl($surl)
  6133.             Local $ret = DllCall("shlwapi.dll", "long", "PathCreateFromUrlW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", 0)
  6134.             If @error Then Return SetError(@error, @extended, "")
  6135.             If $ret[0] Then Return SetError(10, $ret[0], "")
  6136.             Return $ret[2]
  6137.         EndFunc
  6138.  
  6139.         Func _winapi_pathfindextension($spath)
  6140.             Local $ret = DllCall("shlwapi.dll", "wstr", "PathFindExtensionW", "wstr", $spath)
  6141.             If @error Then Return SetError(@error, @extended, "")
  6142.             Return $ret[0]
  6143.         EndFunc
  6144.  
  6145.         Func _winapi_pathfindfilename($spath)
  6146.             Local $ret = DllCall("shlwapi.dll", "wstr", "PathFindFileNameW", "wstr", $spath)
  6147.             If @error Then Return SetError(@error, @extended, $spath)
  6148.             Return $ret[0]
  6149.         EndFunc
  6150.  
  6151.         Func _winapi_pathfindnextcomponent($spath)
  6152.             Local $tpath = DllStructCreate("wchar[" & (StringLen($spath) + 1) & "]")
  6153.             DllStructSetData($tpath, 1, $spath)
  6154.             Local $ret = DllCall("shlwapi.dll", "ptr", "PathFindNextComponentW", "struct*", $tpath)
  6155.             If @error OR NOT $ret[0] Then Return SetError(@error + 10, @extended, "")
  6156.             Return _winapi_getstring($ret[0])
  6157.         EndFunc
  6158.  
  6159.         Func _winapi_pathgetargs($spath)
  6160.             Local $tpath = DllStructCreate("wchar[" & (StringLen($spath) + 1) & "]")
  6161.             DllStructSetData($tpath, 1, $spath)
  6162.             Local $ret = DllCall("shlwapi.dll", "ptr", "PathGetArgsW", "struct*", $tpath)
  6163.             If @error OR NOT $ret[0] Then Return SetError(@error, @extended, "")
  6164.             Return _winapi_getstring($ret[0])
  6165.         EndFunc
  6166.  
  6167.         Func _winapi_pathgetchartype($schar)
  6168.             Local $ret = DllCall("shlwapi.dll", "uint", "PathGetCharTypeW", "word", AscW($schar))
  6169.             If @error Then Return SetError(@error, @extended, -1)
  6170.             Return $ret[0]
  6171.         EndFunc
  6172.  
  6173.         Func _winapi_pathgetdrivenumber($spath)
  6174.             Local $ret = DllCall("shlwapi.dll", "int", "PathGetDriveNumberW", "wstr", $spath)
  6175.             If @error OR ($ret[0] = -1) Then Return SetError(@error, @extended, "")
  6176.             Return Chr($ret[0] + 65) & ":"
  6177.         EndFunc
  6178.  
  6179.         Func _winapi_pathiscontenttype($spath, $stype)
  6180.             Local $ret = DllCall("shlwapi.dll", "bool", "PathIsContentTypeW", "wstr", $spath, "wstr", $stype)
  6181.             If @error Then Return SetError(@error, @extended, False)
  6182.             Return $ret[0]
  6183.         EndFunc
  6184.  
  6185.         Func _winapi_pathisexe($spath)
  6186.             Local $ret = DllCall("shell32.dll", "bool", "PathIsExe", "wstr", $spath)
  6187.             If @error Then Return SetError(@error, @extended, False)
  6188.             Return $ret[0]
  6189.         EndFunc
  6190.  
  6191.         Func _winapi_pathisfilespec($spath)
  6192.             Local $ret = DllCall("shlwapi.dll", "bool", "PathIsFileSpecW", "wstr", $spath)
  6193.             If @error Then Return SetError(@error, @extended, False)
  6194.             Return $ret[0]
  6195.         EndFunc
  6196.  
  6197.         Func _winapi_pathislfnfilespec($spath)
  6198.             Local $ret = DllCall("shlwapi.dll", "bool", "PathIsLFNFileSpecW", "wstr", $spath)
  6199.             If @error Then Return SetError(@error, @extended, False)
  6200.             Return $ret[0]
  6201.         EndFunc
  6202.  
  6203.         Func _winapi_pathisrelative($spath)
  6204.             Local $ret = DllCall("shlwapi.dll", "bool", "PathIsRelativeW", "wstr", $spath)
  6205.             If @error Then Return SetError(@error, @extended, False)
  6206.             Return $ret[0]
  6207.         EndFunc
  6208.  
  6209.         Func _winapi_pathisroot($spath)
  6210.             Local $ret = DllCall("shlwapi.dll", "bool", "PathIsRootW", "wstr", $spath)
  6211.             If @error Then Return SetError(@error, @extended, False)
  6212.             Return $ret[0]
  6213.         EndFunc
  6214.  
  6215.         Func _winapi_pathissameroot($spath1, $spath2)
  6216.             Local $ret = DllCall("shlwapi.dll", "bool", "PathIsSameRootW", "wstr", $spath1, "wstr", $spath2)
  6217.             If @error Then Return SetError(@error, @extended, False)
  6218.             Return $ret[0]
  6219.         EndFunc
  6220.  
  6221.         Func _winapi_pathissystemfolder($spath)
  6222.             Local $ret = DllCall("shlwapi.dll", "bool", "PathIsSystemFolderW", "wstr", $spath, "dword", 0)
  6223.             If @error Then Return SetError(@error, @extended, False)
  6224.             Return $ret[0]
  6225.         EndFunc
  6226.  
  6227.         Func _winapi_pathisunc($spath)
  6228.             Local $ret = DllCall("shlwapi.dll", "bool", "PathIsUNCW", "wstr", $spath)
  6229.             If @error Then Return SetError(@error, @extended, False)
  6230.             Return $ret[0]
  6231.         EndFunc
  6232.  
  6233.         Func _winapi_pathisuncserver($spath)
  6234.             Local $ret = DllCall("shlwapi.dll", "bool", "PathIsUNCServerW", "wstr", $spath)
  6235.             If @error Then Return SetError(@error, @extended, False)
  6236.             Return $ret[0]
  6237.         EndFunc
  6238.  
  6239.         Func _winapi_pathisuncservershare($spath)
  6240.             Local $ret = DllCall("shlwapi.dll", "bool", "PathIsUNCServerShareW", "wstr", $spath)
  6241.             If @error Then Return SetError(@error, @extended, False)
  6242.             Return $ret[0]
  6243.         EndFunc
  6244.  
  6245.         Func _winapi_pathmakesystemfolder($spath)
  6246.             Local $ret = DllCall("shlwapi.dll", "bool", "PathMakeSystemFolderW", "wstr", $spath)
  6247.             If @error Then Return SetError(@error, @extended, False)
  6248.             Return $ret[0]
  6249.         EndFunc
  6250.  
  6251.         Func _winapi_pathmatchspec($spath, $sspec)
  6252.             Local $ret = DllCall("shlwapi.dll", "bool", "PathMatchSpecW", "wstr", $spath, "wstr", $sspec)
  6253.             If @error Then Return SetError(@error, @extended, False)
  6254.             Return $ret[0]
  6255.         EndFunc
  6256.  
  6257.         Func _winapi_pathparseiconlocation($spath)
  6258.             Local $ret = DllCall("shlwapi.dll", "int", "PathParseIconLocationW", "wstr", $spath)
  6259.             If @error Then Return SetError(@error, @extended, 0)
  6260.             Local $result[2]
  6261.             $result[0] = $ret[1]
  6262.             $result[1] = $ret[0]
  6263.             Return $result
  6264.         EndFunc
  6265.  
  6266.         Func _winapi_pathrelativepathto($spathfrom, $fdirfrom, $spathto, $fdirto)
  6267.             If $fdirfrom Then
  6268.                 $fdirfrom = 16
  6269.             EndIf
  6270.             If $fdirto Then
  6271.                 $fdirto = 16
  6272.             EndIf
  6273.             Local $ret = DllCall("shlwapi.dll", "bool", "PathRelativePathToW", "wstr", "", "wstr", $spathfrom, "dword", $fdirfrom, "wstr", $spathto, "dword", $fdirto)
  6274.             If @error OR NOT $ret[0] Then Return SetError(@error, @extended, "")
  6275.             Return $ret[1]
  6276.         EndFunc
  6277.  
  6278.         Func _winapi_pathremoveargs($spath)
  6279.             Local $ret = DllCall("shlwapi.dll", "none", "PathRemoveArgsW", "wstr", $spath)
  6280.             If @error Then Return SetError(@error, @extended, "")
  6281.             Return $ret[1]
  6282.         EndFunc
  6283.  
  6284.         Func _winapi_pathremovebackslash($spath)
  6285.             Local $ret = DllCall("shlwapi.dll", "ptr", "PathRemoveBackslashW", "wstr", $spath)
  6286.             If @error Then Return SetError(@error, @extended, "")
  6287.             Return $ret[1]
  6288.         EndFunc
  6289.  
  6290.         Func _winapi_pathremoveextension($spath)
  6291.             Local $ret = DllCall("shlwapi.dll", "none", "PathRemoveExtensionW", "wstr", $spath)
  6292.             If @error Then Return SetError(@error, @extended, "")
  6293.             Return $ret[1]
  6294.         EndFunc
  6295.  
  6296.         Func _winapi_pathremovefilespec($spath)
  6297.             Local $ret = DllCall("shlwapi.dll", "bool", "PathRemoveFileSpecW", "wstr", $spath)
  6298.             If @error Then Return SetError(@error, @extended, "")
  6299.             Return SetExtended($ret[0], $ret[1])
  6300.         EndFunc
  6301.  
  6302.         Func _winapi_pathrenameextension($spath, $sext)
  6303.             Local $tpath = DllStructCreate("wchar[260]")
  6304.             DllStructSetData($tpath, 1, $spath)
  6305.             Local $ret = DllCall("shlwapi.dll", "bool", "PathRenameExtensionW", "struct*", $tpath, "wstr", $sext)
  6306.             If @error OR NOT $ret[0] Then Return SetError(@error, @extended, "")
  6307.             Return DllStructGetData($tpath, 1)
  6308.         EndFunc
  6309.  
  6310.         Func _winapi_pathsearchandqualify($spath, $fexists = 0)
  6311.             Local $ret = DllCall("shlwapi.dll", "bool", "PathSearchAndQualifyW", "wstr", $spath, "wstr", "", "int", 4096)
  6312.             If @error OR NOT $ret[0] Then Return SetError(@error + 10, @extended, "")
  6313.             If $fexists AND NOT FileExists($ret[2]) Then Return SetError(20, 0, "")
  6314.             Return $ret[2]
  6315.         EndFunc
  6316.  
  6317.         Func _winapi_pathskiproot($spath)
  6318.             Local $tpath = DllStructCreate("wchar[" & (StringLen($spath) + 1) & "]")
  6319.             DllStructSetData($tpath, 1, $spath)
  6320.             Local $ret = DllCall("shlwapi.dll", "ptr", "PathSkipRootW", "struct*", $tpath)
  6321.             If @error Then Return SetError(@error, @extended, "")
  6322.             If NOT $ret[0] Then Return $spath
  6323.             Return _winapi_getstring($ret[0])
  6324.         EndFunc
  6325.  
  6326.         Func _winapi_pathstrippath($spath)
  6327.             Local $ret = DllCall("shlwapi.dll", "none", "PathStripPathW", "wstr", $spath)
  6328.             If @error Then Return SetError(@error, @extended, "")
  6329.             Return $ret[1]
  6330.         EndFunc
  6331.  
  6332.         Func _winapi_pathstriptoroot($spath)
  6333.             Local $ret = DllCall("shlwapi.dll", "bool", "PathStripToRootW", "wstr", $spath)
  6334.             If @error OR NOT $ret[0] Then Return SetError(@error, @extended, "")
  6335.             Return $ret[1]
  6336.         EndFunc
  6337.  
  6338.         Func _winapi_pathundecorate($spath)
  6339.             Local $ret = DllCall("shlwapi.dll", "none", "PathUndecorateW", "wstr", $spath)
  6340.             If @error Then Return SetError(@error, @extended, "")
  6341.             Return $ret[1]
  6342.         EndFunc
  6343.  
  6344.         Func _winapi_pathunexpandenvstrings($spath)
  6345.             Local $ret = DllCall("shlwapi.dll", "bool", "PathUnExpandEnvStringsW", "wstr", $spath, "wstr", "", "uint", 4096)
  6346.             If @error OR NOT $ret[0] Then Return SetError(@error, @extended, "")
  6347.             Return $ret[2]
  6348.         EndFunc
  6349.  
  6350.         Func _winapi_pathunmakesystemfolder($spath)
  6351.             Local $ret = DllCall("shlwapi.dll", "bool", "PathUnmakeSystemFolderW", "wstr", $spath)
  6352.             If @error Then Return SetError(@error, @extended, False)
  6353.             Return $ret[0]
  6354.         EndFunc
  6355.  
  6356.         Func _winapi_pathunquotespaces($spath)
  6357.             Local $ret = DllCall("shlwapi.dll", "none", "PathUnquoteSpacesW", "wstr", $spath)
  6358.             If @error Then Return SetError(@error, @extended, "")
  6359.             Return $ret[1]
  6360.         EndFunc
  6361.  
  6362.         Func _winapi_pathyetanothermakeuniquename($spath)
  6363.             Local $ret = DllCall("shell32.dll", "int", "PathYetAnotherMakeUniqueName", "wstr", "", "wstr", $spath, "ptr", 0, "ptr", 0)
  6364.             If @error OR NOT $ret[0] Then Return SetError(@error, @extended, "")
  6365.             Return $ret[1]
  6366.         EndFunc
  6367.  
  6368.         Func _winapi_shellgetimagelist($fsmall = 0)
  6369.             Local $plarge, $psmall, $tptr = DllStructCreate("ptr")
  6370.             If $fsmall Then
  6371.                 $plarge = 0
  6372.                 $psmall = DllStructGetPtr($tptr)
  6373.             Else
  6374.                 $plarge = DllStructGetPtr($tptr)
  6375.                 $psmall = 0
  6376.             EndIf
  6377.             Local $ret = DllCall("shell32.dll", "int", "Shell_GetImageLists", "ptr", $plarge, "ptr", $psmall)
  6378.             If @error OR NOT $ret[0] Then Return SetError(@error, @extended, 0)
  6379.             Return DllStructGetData($tptr, 1)
  6380.         EndFunc
  6381.  
  6382.         Func _winapi_urlapplyscheme($surl, $iflags = 1)
  6383.             Local $ret = DllCall("shlwapi.dll", "long", "UrlApplySchemeW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", $iflags)
  6384.             If @error Then Return SetError(@error, @extended, "")
  6385.             If $ret[0] Then Return SetError(10, $ret[0], "")
  6386.             Return $ret[2]
  6387.         EndFunc
  6388.  
  6389.         Func _winapi_urlcanonicalize($surl, $iflags)
  6390.             Local $ret = DllCall("shlwapi.dll", "long", "UrlCanonicalizeW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", $iflags)
  6391.             If @error Then Return SetError(@error, @extended, "")
  6392.             If $ret[0] Then Return SetError(10, $ret[0], "")
  6393.             Return $ret[2]
  6394.         EndFunc
  6395.  
  6396.         Func _winapi_urlcombine($surl, $spart, $iflags = 0)
  6397.             Local $ret = DllCall("shlwapi.dll", "long", "UrlCombineW", "wstr", $surl, "wstr", $spart, "wstr", "", "dword*", 4096, "dword", $iflags)
  6398.             If @error Then Return SetError(@error, @extended, "")
  6399.             If $ret[0] Then Return SetError(10, $ret[0], "")
  6400.             Return $ret[3]
  6401.         EndFunc
  6402.  
  6403.         Func _winapi_urlcompare($surl1, $surl2, $fignoreslash = 0)
  6404.             Local $ret = DllCall("shlwapi.dll", "int", "UrlCompareW", "wstr", $surl1, "wstr", $surl2, "bool", $fignoreslash)
  6405.             If @error Then Return SetError(@error, @extended, 0)
  6406.             Return $ret[0]
  6407.         EndFunc
  6408.  
  6409.         Func _winapi_urlcreatefrompath($spath)
  6410.             Local $ret = DllCall("shlwapi.dll", "long", "UrlCreateFromPathW", "wstr", $spath, "wstr", "", "dword*", 4096, "dword", 0)
  6411.             If @error Then Return SetError(@error, @extended, "")
  6412.             If $ret[0] < 0 OR $ret[0] > 1 Then
  6413.                 Return SetError(10, $ret[0], "")
  6414.             EndIf
  6415.             Return $ret[2]
  6416.         EndFunc
  6417.  
  6418.         Func _winapi_urlfixup($surl)
  6419.             Local $ret = DllCall("shlwapi.dll", "long", "UrlFixupW", "wstr", $surl, "wstr", "", "dword", 4096)
  6420.             If @error Then Return SetError(@error, @extended, "")
  6421.             If $ret[0] Then Return SetError(10, $ret[0], "")
  6422.             Return $ret[2]
  6423.         EndFunc
  6424.  
  6425.         Func _winapi_urlgetpart($surl, $ipart)
  6426.             Local $ret = DllCall("shlwapi.dll", "long", "UrlGetPartW", "wstr", $surl, "wstr", "", "dword*", 4096, "dword", $ipart, "dword", 0)
  6427.             If @error Then Return SetError(@error, @extended, "")
  6428.             If $ret[0] Then Return SetError(10, $ret[0], "")
  6429.             Return $ret[2]
  6430.         EndFunc
  6431.  
  6432.         Func _winapi_urlhash($surl, $ilength = 32)
  6433.             If $ilength <= 0 OR $ilength > 256 Then Return SetError(256, 0, 0)
  6434.             Local $tdata = DllStructCreate("byte[" & $ilength & "]")
  6435.             Local $ret = DllCall("shlwapi.dll", "long", "UrlHashW", "wstr", $surl, "struct*", $tdata, "dword", $ilength)
  6436.             If @error Then Return SetError(@error + 10, @extended, 0)
  6437.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  6438.             Return DllStructGetData($tdata, 1)
  6439.         EndFunc
  6440.  
  6441.         Func _winapi_urlis($surl, $itype = 0)
  6442.             Local $ret = DllCall("shlwapi.dll", "bool", "UrlIsW", "wstr", $surl, "uint", $itype)
  6443.             If @error Then Return SetError(@error, @extended, False)
  6444.             Return $ret[0]
  6445.         EndFunc
  6446.  
  6447.     #EndRegion Public Functions
  6448.     #Region Internal Functions
  6449.  
  6450.         Func __us($sstring, $ilength = 0)
  6451.             If $ilength Then
  6452.                 $sstring = StringLeft($sstring, $ilength)
  6453.             Else
  6454.                 $ilength = StringLen($sstring)
  6455.             EndIf
  6456.             Local $tus = DllStructCreate("ushort;ushort;ptr;wchar[" & ($ilength + 1) & "]")
  6457.             DllStructSetData($tus, 1, 2 * StringLen($sstring))
  6458.             DllStructSetData($tus, 2, 2 * $ilength)
  6459.             DllStructSetData($tus, 3, DllStructGetPtr($tus, 4))
  6460.             DllStructSetData($tus, 4, $sstring)
  6461.             Return $tus
  6462.         EndFunc
  6463.  
  6464.     #EndRegion Internal Functions
  6465.     #Region Global Variables and Constants
  6466.         Global Const $tagnotifyicondata = "struct;dword Size;hwnd hWnd;uint ID;uint Flags;uint CallbackMessage;ptr hIcon;wchar Tip[128];dword State;dword StateMask;wchar Info[256];uint Version;wchar InfoTitle[64];dword InfoFlags;endstruct"
  6467.         Global Const $tagnotifyicondata_v3 = $tagnotifyicondata & ";" & $tagguid
  6468.         Global Const $tagnotifyicondata_v4 = $tagnotifyicondata_v3 & ";ptr hBalloonIcon;"
  6469.         Global Const $tagshellexecuteinfo = "dword Size;ulong Mask;hwnd hWnd;ptr Verb;ptr File;ptr Parameters;ptr Directory;int Show;ulong_ptr hInstApp;ptr IDList;ptr Class;ulong_ptr hKeyClass;dword HotKey;ptr hMonitor;ptr hProcess"
  6470.         Global Const $tagshfileinfo = "ptr hIcon;int iIcon;dword Attributes;wchar DisplayName[260];wchar TypeName[80]"
  6471.         Global Const $tagshfileopstruct = "hwnd hWnd;uint Func;ptr From;ptr To;dword Flags;int fAnyOperationsAborted;ptr hNameMappings;ptr ProgressTitle"
  6472.         Global Const $tagshfoldercustomsettings = "dword Size;dword Mask;ptr GUID;ptr WebViewTemplate;dword SizeWVT;ptr WebViewTemplateVersion;ptr InfoTip;dword SizeIT;ptr CLSID;dword Flags;ptr IconFile;dword SizeIF;int IconIndex;ptr Logo;dword SizeL"
  6473.         Global Const $tagshstockiconinfo = "dword Size;ptr hIcon;int SysImageIndex;int iIcon;wchar Path[260]"
  6474.     #EndRegion Global Variables and Constants
  6475.     #Region Functions list
  6476.     #EndRegion Functions list
  6477.     #Region Public Functions
  6478.  
  6479.         Func _winapi_defsubclassproc($hwnd, $imsg, $wparam, $lparam)
  6480.             Local $ret = DllCall("comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hwnd, "uint", $imsg, "wparam", $wparam, "lparam", $lparam)
  6481.             If @error Then Return SetError(@error, @extended, 0)
  6482.             Return $ret[0]
  6483.         EndFunc
  6484.  
  6485.         Func _winapi_dllgetversion($spath)
  6486.             Local $tversion = DllStructCreate("dword[5]")
  6487.             DllStructSetData($tversion, 1, DllStructGetSize($tversion), 1)
  6488.             Local $ret = DllCall($spath, "uint", "DllGetVersion", "struct*", $tversion)
  6489.             If @error Then Return SetError(@error, @extended, 0)
  6490.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  6491.             Local $result[4]
  6492.             For $i = 0 To 3
  6493.                 $result[$i] = DllStructGetData($tversion, 1, $i + 2)
  6494.             Next
  6495.             Return $result
  6496.         EndFunc
  6497.  
  6498.         Func _winapi_getallusersprofiledirectory()
  6499.             Local $ret = DllCall("userenv.dll", "bool", "GetAllUsersProfileDirectoryW", "wstr", "", "dword*", 4096)
  6500.             If @error OR NOT $ret[0] Then Return SetError(@error, @extended, "")
  6501.             Return $ret[1]
  6502.         EndFunc
  6503.  
  6504.         Func _winapi_getdefaultuserprofiledirectory()
  6505.             Local $ret = DllCall("userenv.dll", "bool", "GetDefaultUserProfileDirectoryW", "wstr", "", "dword*", 4096)
  6506.             If @error Then Return SetError(@error, @extended, "")
  6507.             Return $ret[1]
  6508.         EndFunc
  6509.  
  6510.         Func _winapi_getwindowsubclass($hwnd, $psubclassproc, $id)
  6511.             Local $ret = DllCall("comctl32.dll", "bool", "GetWindowSubclass", "hwnd", $hwnd, "ptr", $psubclassproc, "uint_ptr", $id, "dword_ptr*", 0)
  6512.             If @error OR NOT $ret[0] Then Return SetError(@error + 10, @extended, 0)
  6513.             Return $ret[4]
  6514.         EndFunc
  6515.  
  6516.         Func _winapi_removewindowsubclass($hwnd, $psubclassproc, $id)
  6517.             Local $ret = DllCall("comctl32.dll", "bool", "RemoveWindowSubclass", "hwnd", $hwnd, "ptr", $psubclassproc, "uint_ptr", $id)
  6518.             If @error Then Return SetError(@error, @extended, False)
  6519.             Return $ret[0]
  6520.         EndFunc
  6521.  
  6522.         Func _winapi_setcurrentprocessexplicitappusermodelid($sappid)
  6523.             Local $ret = DllCall("shell32.dll", "long", "SetCurrentProcessExplicitAppUserModelID", "wstr", $sappid)
  6524.             If @error Then Return SetError(@error, @extended, 0)
  6525.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  6526.             Return 1
  6527.         EndFunc
  6528.  
  6529.         Func _winapi_setwindowsubclass($hwnd, $psubclassproc, $id, $pdata = 0)
  6530.             Local $ret = DllCall("comctl32.dll", "bool", "SetWindowSubclass", "hwnd", $hwnd, "ptr", $psubclassproc, "uint_ptr", $id, "dword_ptr", $pdata)
  6531.             If @error Then Return SetError(@error, @extended, 0)
  6532.             Return $ret[0]
  6533.         EndFunc
  6534.  
  6535.         Func _winapi_shelladdtorecentdocs($sfile)
  6536.             Local $typeoffile = "wstr"
  6537.             If StringStripWS($sfile, 3) Then
  6538.                 $sfile = _winapi_pathsearchandqualify($sfile, 1)
  6539.                 If NOT $sfile Then
  6540.                     Return SetError(1, 0, 0)
  6541.                 EndIf
  6542.             Else
  6543.                 $typeoffile = "ptr"
  6544.                 $sfile = 0
  6545.             EndIf
  6546.             DllCall("shell32.dll", "none", "SHAddToRecentDocs", "uint", 3, $typeoffile, $sfile)
  6547.             If @error Then Return SetError(@error, @extended, 0)
  6548.             Return 1
  6549.         EndFunc
  6550.  
  6551.         Func _winapi_shellchangenotify($ievent, $iflags, $iitem1 = 0, $iitem2 = 0)
  6552.             Local $typeofitem1 = "dword_ptr", $typeofitem2 = "dword_ptr"
  6553.             If IsString($iitem1) Then
  6554.                 $typeofitem1 = "wstr"
  6555.             EndIf
  6556.             If IsString($iitem2) Then
  6557.                 $typeofitem2 = "wstr"
  6558.             EndIf
  6559.             DllCall("shell32.dll", "none", "SHChangeNotify", "long", $ievent, "uint", $iflags, $typeofitem1, $iitem1, $typeofitem2, $iitem2)
  6560.             If @error Then Return SetError(@error, @extended, 0)
  6561.             Return 1
  6562.         EndFunc
  6563.  
  6564.         Func _winapi_shellchangenotifyderegister($id)
  6565.             Local $ret = DllCall("shell32.dll", "bool", "SHChangeNotifyDeregister", "ulong", $id)
  6566.             If @error Then Return SetError(@error, @extended, False)
  6567.             Return $ret[0]
  6568.         EndFunc
  6569.  
  6570.         Func _winapi_shellchangenotifyregister($hwnd, $imsg, $ievents, $isources, $apaths, $frecursive = 0)
  6571.             Local $path = $apaths, $struct = ""
  6572.             If IsArray($apaths) Then
  6573.                 If UBound($apaths, 2) Then Return SetError(1, 0, 0)
  6574.             Else
  6575.                 Dim $apaths[1] = [$path]
  6576.             EndIf
  6577.             For $i = 0 To UBound($apaths) - 1
  6578.                 If NOT _winapi_pathisdirectory($apaths[$i]) Then Return SetError(2, 0, 0)
  6579.             Next
  6580.             For $i = 0 To UBound($apaths) - 1
  6581.                 $struct &= "ptr;int;"
  6582.             Next
  6583.             Local $tentry = DllStructCreate($struct)
  6584.             For $i = 0 To UBound($apaths) - 1
  6585.                 $apaths[$i] = _winapi_shellilcreatefrompath(_winapi_pathsearchandqualify($apaths[$i]))
  6586.                 DllStructSetData($tentry, 2 * $i + 1, $apaths[$i])
  6587.                 DllStructSetData($tentry, 2 * $i + 2, $frecursive)
  6588.             Next
  6589.             Local $error = 0
  6590.             Local $ret = DllCall("shell32.dll", "ulong", "SHChangeNotifyRegister", "hwnd", $hwnd, "int", $isources, "long", $ievents, "uint", $imsg, "int", UBound($apaths), "struct*", $tentry)
  6591.             If @error OR NOT $ret[0] Then $error = @error + 10
  6592.             For $i = 0 To UBound($apaths) - 1
  6593.                 _winapi_cotaskmemfree($apaths[$i])
  6594.             Next
  6595.             Return SetError($error, 0, $ret[0])
  6596.         EndFunc
  6597.  
  6598.         Func _winapi_shellcreatedirectory($spath, $hparent = 0, $tsecurity = 0)
  6599.             Local $ret = DllCall("shell32.dll", "int", "SHCreateDirectoryExW", "hwnd", $hparent, "wstr", $spath, "struct*", $tsecurity)
  6600.             If @error Then Return SetError(@error, @extended, 0)
  6601.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  6602.             Return 1
  6603.         EndFunc
  6604.  
  6605.         Func _winapi_shellemptyrecyclebin($sroot = "", $iflags = 0, $hparent = 0)
  6606.             Local $ret = DllCall("shell32.dll", "long", "SHEmptyRecycleBinW", "hwnd", $hparent, "wstr", $sroot, "dword", $iflags)
  6607.             If @error Then Return SetError(@error, @extended, 0)
  6608.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  6609.             Return 1
  6610.         EndFunc
  6611.  
  6612.         Func _winapi_shellexecute($sfile, $sargs = "", $sdir = "", $sverb = "", $ishow = 1, $hparent = 0)
  6613.             Local $typeofargs = "wstr", $typeofdir = "wstr", $typeofverb = "wstr"
  6614.             If NOT StringStripWS($sargs, 3) Then
  6615.                 $typeofargs = "ptr"
  6616.                 $sargs = 0
  6617.             EndIf
  6618.             If NOT StringStripWS($sdir, 3) Then
  6619.                 $typeofdir = "ptr"
  6620.                 $sdir = 0
  6621.             EndIf
  6622.             If NOT StringStripWS($sverb, 3) Then
  6623.                 $typeofverb = "ptr"
  6624.                 $sverb = 0
  6625.             EndIf
  6626.             Local $ret = DllCall("shell32.dll", "ULONG_PTR", "ShellExecuteW", "hwnd", $hparent, $typeofverb, $sverb, "wstr", $sfile, $typeofargs, $sargs, $typeofdir, $sdir, "int", $ishow)
  6627.             If @error Then Return SetError(@error, @extended, False)
  6628.             If $ret[0] <= 32 Then Return SetError(10, $ret[0], 0)
  6629.             Return $ret[0]
  6630.         EndFunc
  6631.  
  6632.         Func _winapi_shellexecuteex(ByRef $tshexinfo)
  6633.             Local $ret = DllCall("shell32.dll", "bool", "ShellExecuteExW", "struct*", $tshexinfo)
  6634.             If @error Then Return SetError(@error, @extended, 0)
  6635.             Return $ret[0]
  6636.         EndFunc
  6637.  
  6638.         Func _winapi_shellextractassociatedicon($sfile, $fsmall = 0)
  6639.             Local $flags = 256
  6640.             If NOT _winapi_pathisdirectory($sfile) Then
  6641.                 $flags = BitOR($flags, 16)
  6642.             EndIf
  6643.             If $fsmall Then
  6644.                 $flags = BitOR($flags, 1)
  6645.             EndIf
  6646.             Local $tshfileinfo = DllStructCreate($tagshfileinfo)
  6647.             If NOT _winapi_shellgetfileinfo($sfile, $flags, 0, $tshfileinfo) Then Return SetError(@error + 10, @extended, 0)
  6648.             Return DllStructGetData($tshfileinfo, "hIcon")
  6649.         EndFunc
  6650.  
  6651.         Func _winapi_shellextracticon($sicon, $iindex, $iwidth, $iheight)
  6652.             Local $ret = DllCall("shell32.dll", "int", "SHExtractIconsW", "wstr", $sicon, "int", $iindex, "int", $iwidth, "int", $iheight, "ptr*", 0, "ptr*", 0, "int", 1, "int", 0)
  6653.             If @error OR NOT $ret[0] OR NOT $ret[5] Then Return SetError(@error, @extended, 0)
  6654.             Return $ret[5]
  6655.         EndFunc
  6656.  
  6657.         Func _winapi_shellfileoperation($sfrom, $sto, $ifunc, $iflags, $stitle = "", $hparent = 0)
  6658.             Local $data
  6659.             If NOT IsArray($sfrom) Then
  6660.                 $data = $sfrom
  6661.                 Dim $sfrom[1] = [$data]
  6662.             EndIf
  6663.             Local $tfrom = _winapi_arraytostruct($sfrom)
  6664.             If @error Then Return SetError(@error + 20, @extended, 0)
  6665.             If NOT IsArray($sto) Then
  6666.                 $data = $sto
  6667.                 Dim $sto[1] = [$data]
  6668.             EndIf
  6669.             Local $tto = _winapi_arraytostruct($sto)
  6670.             If @error Then Return SetError(@error + 30, @extended, 0)
  6671.             Local $tshfileopstruct = DllStructCreate($tagshfileopstruct)
  6672.             DllStructSetData($tshfileopstruct, "hWnd", $hparent)
  6673.             DllStructSetData($tshfileopstruct, "Func", $ifunc)
  6674.             DllStructSetData($tshfileopstruct, "From", DllStructGetPtr($tfrom))
  6675.             DllStructSetData($tshfileopstruct, "To", DllStructGetPtr($tto))
  6676.             DllStructSetData($tshfileopstruct, "Flags", $iflags)
  6677.             DllStructSetData($tshfileopstruct, "ProgressTitle", $stitle)
  6678.             Local $ret = DllCall("shell32.dll", "int", "SHFileOperationW", "struct*", $tshfileopstruct)
  6679.             If @error Then Return SetError(@error, @extended, 0)
  6680.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  6681.             Return $tshfileopstruct
  6682.         EndFunc
  6683.  
  6684.         Func _winapi_shellflushsfcache()
  6685.             DllCall("shell32.dll", "none", "SHFlushSFCache")
  6686.             If @error Then Return SetError(@error, @extended, 0)
  6687.             Return 1
  6688.         EndFunc
  6689.  
  6690.         Func _winapi_shellgetfileinfo($spath, $iflags, $iattributes, ByRef $tshfileinfo)
  6691.             Local $ret = DllCall("shell32.dll", "dword_ptr", "SHGetFileInfoW", "wstr", $spath, "dword", $iattributes, "struct*", $tshfileinfo, "uint", DllStructGetSize($tshfileinfo), "uint", $iflags)
  6692.             If @error Then Return SetError(@error, @extended, 0)
  6693.             Return $ret[0]
  6694.         EndFunc
  6695.  
  6696.         Func _winapi_shellgeticonoverlayindex($sicon, $iindex)
  6697.             Local $typeoficon = "wstr"
  6698.             If NOT StringStripWS($sicon, 3) Then
  6699.                 $typeoficon = "ptr"
  6700.                 $sicon = 0
  6701.             EndIf
  6702.             Local $ret = DllCall("shell32.dll", "int", "SHGetIconOverlayIndexW", $typeoficon, $sicon, "int", $iindex)
  6703.             If @error OR ($ret[0] = -1) Then Return SetError(@error, @extended, -1)
  6704.             Return $ret[0]
  6705.         EndFunc
  6706.  
  6707.         Func _winapi_shellgetknownfolderidlist($guid, $iflags = 0, $htoken = 0)
  6708.             Local $tguid = DllStructCreate($tagguid)
  6709.             Local $ret = DllCall("ole32.dll", "uint", "CLSIDFromString", "wstr", $guid, "ptr", DllStructGetPtr($tguid))
  6710.             If @error OR $ret[0] Then Return SetError(@error + 20, @extended, 0)
  6711.             $ret = DllCall("shell32.dll", "uint", "SHGetKnownFolderIDList", "ptr", DllStructGetPtr($tguid), "dword", $iflags, "ptr", $htoken, "ptr*", 0)
  6712.             If @error Then Return SetError(@error, @extended, 0)
  6713.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  6714.             Return $ret[4]
  6715.         EndFunc
  6716.  
  6717.         Func _winapi_shellgetknownfolderpath($guid, $iflags = 0, $htoken = 0)
  6718.             Local $tguid = DllStructCreate($tagguid)
  6719.             Local $ret = DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $guid, "struct*", $tguid)
  6720.             If @error OR $ret[0] Then Return SetError(@error + 20, @extended, "")
  6721.             $ret = DllCall("shell32.dll", "long", "SHGetKnownFolderPath", "struct*", $tguid, "dword", $iflags, "handle", $htoken, "ptr*", 0)
  6722.             If @error Then Return SetError(@error, @extended, "")
  6723.             If $ret[0] Then Return SetError(10, $ret[0], "")
  6724.             Local $path = _winapi_getstring($ret[4])
  6725.             _winapi_cotaskmemfree($ret[4])
  6726.             Return $path
  6727.         EndFunc
  6728.  
  6729.         Func _winapi_shellgetlocalizedname($spath)
  6730.             Local $ret = DllCall("shell32.dll", "long", "SHGetLocalizedName", "wstr", $spath, "wstr", "", "uint*", 0, "int*", 0)
  6731.             If @error Then Return SetError(@error, @extended, 0)
  6732.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  6733.             Local $result[2]
  6734.             Local $aresult = DllCall("kernel32.dll", "dword", "ExpandEnvironmentStringsW", "wstr", $ret[2], "wstr", "", "dword", 4096)
  6735.             $result[0] = $aresult[2]
  6736.             $result[1] = $ret[4]
  6737.             Return $result
  6738.         EndFunc
  6739.  
  6740.         Func _winapi_shellgetpathfromidlist($pidl)
  6741.             Local $ret = DllCall("shell32.dll", "bool", "SHGetPathFromIDListW", "ptr", $pidl, "wstr", "")
  6742.             If @error OR NOT $ret[0] Then Return SetError(@error, @extended, "")
  6743.             Return $ret[2]
  6744.         EndFunc
  6745.  
  6746.         Func _winapi_shellgetsetfoldercustomsettings($spath, $iflag, ByRef $tshfcs)
  6747.             Local $proc = "SHGetSetFolderCustomSettings"
  6748.             If $__winver < 1536 Then $proc &= "W"
  6749.             Local $ret = DllCall("shell32.dll", "long", $proc, "struct*", $tshfcs, "wstr", $spath, "dword", $iflag)
  6750.             If @error Then Return SetError(@error, @extended, 0)
  6751.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  6752.             Return 1
  6753.         EndFunc
  6754.  
  6755.         Func _winapi_shellgetsettings($iflags)
  6756.             Local $tshellstate = DllStructCreate("uint[8]")
  6757.             DllCall("shell32.dll", "none", "SHGetSetSettings", "struct*", $tshellstate, "dword", $iflags, "bool", 0)
  6758.             If @error Then Return SetError(@error, @extended, 0)
  6759.             Local $val1 = DllStructGetData($tshellstate, 1, 1)
  6760.             Local $val2 = DllStructGetData($tshellstate, 1, 8)
  6761.             Local $result = 0
  6762.             Local $opt[20][2] = [[1, 1], [2, 2], [4, 32768], [8, 32], [16, 8], [32, 128], [64, 512], [128, 1024], [256, 2048], [1024, 4096], [2048, 8192], [4096, 16384], [8192, 131072], [32768, 262144], [65536, 1048576], [1, 524288], [2, 2097152], [8, 8388608], [16, 16777216], [32, 33554432]]
  6763.             For $i = 0 To 14
  6764.                 If BitAND($val1, $opt[$i][0]) Then
  6765.                     $result += $opt[$i][1]
  6766.                 EndIf
  6767.             Next
  6768.             For $i = 15 To 19
  6769.                 If BitAND($val2, $opt[$i][0]) Then
  6770.                     $result += $opt[$i][1]
  6771.                 EndIf
  6772.             Next
  6773.             Return $result
  6774.         EndFunc
  6775.  
  6776.         Func _winapi_shellgetspecialfolderlocation($csidl)
  6777.             Local $ret = DllCall("shell32.dll", "long", "SHGetSpecialFolderLocation", "hwnd", 0, "int", $csidl, "ptr*", 0)
  6778.             If @error Then Return SetError(@error, @extended, 0)
  6779.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  6780.             Return $ret[3]
  6781.         EndFunc
  6782.  
  6783.         Func _winapi_shellgetspecialfolderpath($csidl, $fcreate = 0)
  6784.             Local $ret = DllCall("shell32.dll", "bool", "SHGetSpecialFolderPathW", "hwnd", 0, "wstr", "", "int", $csidl, "bool", $fcreate)
  6785.             If @error OR NOT $ret[0] Then Return SetError(@error + 10, @extended, "")
  6786.             Return $ret[2]
  6787.         EndFunc
  6788.  
  6789.         Func _winapi_shellgetstockiconinfo($siid, $iflags)
  6790.             Local $tshstockiconinfo = DllStructCreate($tagshstockiconinfo)
  6791.             DllStructSetData($tshstockiconinfo, "Size", DllStructGetSize($tshstockiconinfo))
  6792.             Local $ret = DllCall("shell32.dll", "long", "SHGetStockIconInfo", "int", $siid, "uint", $iflags, "struct*", $tshstockiconinfo)
  6793.             If @error Then Return SetError(@error, @extended, 0)
  6794.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  6795.             Return $tshstockiconinfo
  6796.         EndFunc
  6797.  
  6798.         Func _winapi_shellilcreatefrompath($spath)
  6799.             Local $ret = DllCall("shell32.dll", "long", "SHILCreateFromPath", "wstr", $spath, "ptr*", 0, "dword*", 0)
  6800.             If @error Then Return SetError(@error, @extended, 0)
  6801.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  6802.             Return $ret[2]
  6803.         EndFunc
  6804.  
  6805.         Func _winapi_shellnotifyicon($imessage, ByRef $tnotifyicondata)
  6806.             Local $ret = DllCall("shell32.dll", "bool", "Shell_NotifyIconW", "dword", $imessage, "struct*", $tnotifyicondata)
  6807.             If @error Then Return SetError(@error, @extended, False)
  6808.             Return $ret[0]
  6809.         EndFunc
  6810.  
  6811.         Func _winapi_shellnotifyicongetrect($hwnd, $id, $tguid = 0)
  6812.             Local $tnii = DllStructCreate("dword;hwnd;uint;" & $tagguid)
  6813.             DllStructSetData($tnii, 1, DllStructGetSize($tnii))
  6814.             DllStructSetData($tnii, 2, $hwnd)
  6815.             DllStructSetData($tnii, 3, $id)
  6816.             If IsDllStruct($tguid) Then
  6817.                 If NOT _winapi_movememory(DllStructGetPtr($tnii, 4), DllStructGetPtr($tguid), 16) Then Return SetError(@error + 10, @extended, 0)
  6818.             EndIf
  6819.             Local $trect = DllStructCreate($tagrect)
  6820.             Local $ret = DllCall("shell32.dll ", "long", "Shell_NotifyIconGetRect", "struct*", $tnii, "struct*", $trect)
  6821.             If @error Then Return SetError(@error, @extended, 0)
  6822.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  6823.             Return $trect
  6824.         EndFunc
  6825.  
  6826.         Func _winapi_shellobjectproperties($spath, $itype = 2, $sproperty = "", $hparent = 0)
  6827.             Local $typeofproperty = "wstr"
  6828.             If NOT StringStripWS($sproperty, 3) Then
  6829.                 $typeofproperty = "ptr"
  6830.                 $sproperty = 0
  6831.             EndIf
  6832.             Local $ret = DllCall("shell32.dll", "bool", "SHObjectProperties", "hwnd", $hparent, "dword", $itype, "wstr", $spath, $typeofproperty, $sproperty)
  6833.             If @error Then Return SetError(@error, @extended, False)
  6834.             Return $ret[0]
  6835.         EndFunc
  6836.  
  6837.         Func _winapi_shellopenfolderandselectitems($spath, $anames = 0, $istart = 0, $iend = -1, $iflags = 0)
  6838.             Local $pidl, $ret, $tptr = 0, $count = 0, $obj = 0, $error = 0
  6839.             $spath = _winapi_pathremovebackslash(_winapi_pathsearchandqualify($spath))
  6840.             If IsArray($anames) Then
  6841.                 If $spath AND NOT _winapi_pathisdirectory($spath) Then Return SetError(@error + 20, @extended, 0)
  6842.             EndIf
  6843.             $pidl = _winapi_shellilcreatefrompath($spath)
  6844.             If @error Then Return SetError(@error + 30, @extended, 0)
  6845.             If NOT __checkerrorarraybounds($anames, $istart, $iend) Then
  6846.                 $tptr = DllStructCreate("ptr[" & ($iend - $istart + 1) & "]")
  6847.                 For $i = $istart To $iend
  6848.                     $count += 1
  6849.                     If $anames[$i] Then
  6850.                         DllStructSetData($tptr, 1, _winapi_shellilcreatefrompath($spath & "\" & $anames[$i]), $count)
  6851.                     Else
  6852.                         DllStructSetData($tptr, 1, 0, $count)
  6853.                     EndIf
  6854.                 Next
  6855.             EndIf
  6856.             If _winapi_coinitialize() Then $obj = 1
  6857.             $ret = DllCall("shell32.dll", "long", "SHOpenFolderAndSelectItems", "ptr", $pidl, "uint", $count, "struct*", $tptr, "dword", $iflags)
  6858.             If @error Then
  6859.                 $error = @error + 10
  6860.             Else
  6861.                 If $ret[0] Then $error = 10
  6862.             EndIf
  6863.             If $obj Then _winapi_couninitialize()
  6864.             _winapi_cotaskmemfree($pidl)
  6865.             For $i = 1 To $count
  6866.                 $pidl = DllStructGetData($tptr, $i)
  6867.                 If $pidl Then
  6868.                     _winapi_cotaskmemfree($pidl)
  6869.                 EndIf
  6870.             Next
  6871.             If $error = 10 Then Return SetError(10, $ret[0], 0)
  6872.             If $error Then Return SetError($error, 0, 0)
  6873.             Return 1
  6874.         EndFunc
  6875.  
  6876.         Func _winapi_shellqueryrecyclebin($sroot = "")
  6877.             Local $tshqrbi = DllStructCreate("align 4;dword_ptr;int64;int64")
  6878.             DllStructSetData($tshqrbi, 1, DllStructGetSize($tshqrbi))
  6879.             Local $ret = DllCall("shell32.dll", "long", "SHQueryRecycleBinW", "wstr", $sroot, "struct*", $tshqrbi)
  6880.             If @error Then Return SetError(@error, @extended, 0)
  6881.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  6882.             Local $result[2]
  6883.             $result[0] = DllStructGetData($tshqrbi, 2)
  6884.             $result[1] = DllStructGetData($tshqrbi, 3)
  6885.             Return $result
  6886.         EndFunc
  6887.  
  6888.         Func _winapi_shellqueryusernotificationstate()
  6889.             Local $ret = DllCall("shell32.dll", "long", "SHQueryUserNotificationState", "uint*", 0)
  6890.             If @error Then Return SetError(@error, @extended, 0)
  6891.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  6892.             Return $ret[1]
  6893.         EndFunc
  6894.  
  6895.         Func _winapi_shellremovelocalizedname($spath)
  6896.             Local $ret = DllCall("shell32.dll", "long", "SHRemoveLocalizedName", "wstr", $spath)
  6897.             If @error Then Return SetError(@error, @extended, 0)
  6898.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  6899.             Return 1
  6900.         EndFunc
  6901.  
  6902.         Func _winapi_shellrestricted($irestriction)
  6903.             Local $ret = DllCall("shell32.dll", "dword", "SHRestricted", "uint", $irestriction)
  6904.             If @error Then Return SetError(@error, @extended, 0)
  6905.             Return $ret[0]
  6906.         EndFunc
  6907.  
  6908.         Func _winapi_shellsetknownfolderpath($guid, $spath, $iflags = 0, $htoken = 0)
  6909.             Local $tguid = DllStructCreate($tagguid)
  6910.             Local $ret = DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $guid, "struct*", $tguid)
  6911.             If @error OR $ret[0] Then Return SetError(@error + 20, @extended, 0)
  6912.             $ret = DllCall("shell32.dll", "long", "SHSetKnownFolderPath", "struct*", $tguid, "dword", $iflags, "handle", $htoken, "wstr", $spath)
  6913.             If @error Then Return SetError(@error, @extended, 0)
  6914.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  6915.             Return 1
  6916.         EndFunc
  6917.  
  6918.         Func _winapi_shellsetlocalizedname($spath, $smodule, $iresid)
  6919.             Local $ret = DllCall("shell32.dll", "long", "SHSetLocalizedName", "wstr", $spath, "wstr", $smodule, "int", $iresid)
  6920.             If @error Then Return SetError(@error, @extended, 0)
  6921.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  6922.             Return 1
  6923.         EndFunc
  6924.  
  6925.         Func _winapi_shellsetsettings($iflags, $fset)
  6926.             Local $val1 = 0, $val2 = 0
  6927.             Local $opt[20][2] = [[1, 1], [2, 2], [4, 32768], [8, 32], [16, 8], [32, 128], [64, 512], [128, 1024], [256, 2048], [1024, 4096], [2048, 8192], [4096, 16384], [8192, 131072], [32768, 262144], [65536, 1048576], [1, 524288], [2, 2097152], [8, 8388608], [16, 16777216], [32, 33554432]]
  6928.             If $fset Then
  6929.                 For $i = 0 To 14
  6930.                     If BitAND($iflags, $opt[$i][1]) Then
  6931.                         $val1 += $opt[$i][0]
  6932.                     EndIf
  6933.                 Next
  6934.                 For $i = 15 To 19
  6935.                     If BitAND($iflags, $opt[$i][1]) Then
  6936.                         $val2 += $opt[$i][0]
  6937.                     EndIf
  6938.                 Next
  6939.             EndIf
  6940.             Local $tshellstate = DllStructCreate("uint[8]")
  6941.             DllStructSetData($tshellstate, 1, $val1, 1)
  6942.             DllStructSetData($tshellstate, 1, $val2, 8)
  6943.             DllCall("shell32.dll", "none", "SHGetSetSettings", "struct*", $tshellstate, "dword", $iflags, "bool", 1)
  6944.             If @error Then Return SetError(@error, @extended, 0)
  6945.             Return 1
  6946.         EndFunc
  6947.  
  6948.         Func _winapi_shellupdateimage($sicon, $iindex, $iimage, $iflags = 0)
  6949.             DllCall("shell32.dll", "none", "SHUpdateImageW", "wstr", $sicon, "int", $iindex, "uint", $iflags, "int", $iimage)
  6950.             If @error Then Return SetError(@error, @extended, 0)
  6951.             Return 1
  6952.         EndFunc
  6953.  
  6954.     #EndRegion Public Functions
  6955.     #Region Global Variables and Constants
  6956.         Global $__pfrbuffer = 0, $__ifrbuffersize = 16385
  6957.         Global Const $tagfindreplace = "dword Size;hwnd hOwner;ptr hInstance;dword Flags;ptr FindWhat;ptr ReplaceWith;ushort FindWhatLen;ushort ReplaceWithLen;lparam lParam;ptr Hook;ptr TemplateName"
  6958.         Global Const $tagmsgboxparams = "uint Size;hwnd hOwner;ptr hInstance;int_ptr Text;int_ptr Caption;dword Style;int_ptr Icon;dword_ptr ContextHelpId;ptr MsgBoxCallback;dword LanguageId"
  6959.         Global Const $tagpagesetupdlg = "dword Size;hwnd hOwner;ptr hDevMode;ptr hDevNames;dword Flags;long PaperWidth;long PaperHeight;long MarginMinLeft;long MarginMinTop;long MarginMinRight;long MarginMinBottom;long MarginLeft;long MarginTop;long MarginRight;long MarginBottom;ptr hInstance;lparam lParam;ptr PageSetupHook;ptr PagePaintHook;ptr PageSetupTemplateName;ptr hPageSetupTemplate"
  6960.         Global Const $tagprintdlg = __iif(@AutoItX64, "", "align 2;") & "dword Size;hwnd hOwner;handle hDevMode;handle hDevNames;handle hDC;dword Flags;word FromPage;word ToPage;word MinPage;word MaxPage;word Copies;handle hInstance;lparam lParam;ptr PrintHook;ptr SetupHook;ptr PrintTemplateName;ptr SetupTemplateName;handle hPrintTemplate;handle hSetupTemplate"
  6961.         Global Const $tagprintdlgex = "dword Size;hwnd hOwner;handle hDevMode;handle hDevNames;handle hDC;dword Flags;dword Flags2;dword ExclusionFlags;dword NumPageRanges;dword MaxPageRanges;ptr PageRanges;dword MinPage;dword MaxPage;dword Copies;handle hInstance;ptr PrintTemplateName;lparam lParam;dword NumPropertyPages;ptr hPropertyPages;dword StartPage;dword ResultAction"
  6962.         Global Const $tagprintpagerange = "dword FromPage;dword ToPage"
  6963.     #EndRegion Global Variables and Constants
  6964.     #Region Functions list
  6965.     #EndRegion Functions list
  6966.     #Region Public Functions
  6967.  
  6968.         Func _winapi_browseforfolderdlg($sroot = "", $stext = "", $iflags = 0, $pbrowseproc = 0, $lparam = 0, $hparent = 0)
  6969.             Local Const $tagbrowseinfo = "hwnd hwndOwner;ptr pidlRoot;ptr pszDisplayName; ptr lpszTitle;uint ulFlags;ptr lpfn;lparam lParam;int iImage"
  6970.             Local $tbrowseinfo = DllStructCreate($tagbrowseinfo & ";wchar[" & (StringLen($stext) + 1) & "];wchar[260]")
  6971.             Local $pidl = 0, $result = ""
  6972.             If StringStripWS($sroot, 3) Then
  6973.                 Local $path = _winapi_pathsearchandqualify($sroot, 1)
  6974.                 If @error Then
  6975.                     $path = $sroot
  6976.                 EndIf
  6977.                 $pidl = _winapi_shellilcreatefrompath($path)
  6978.                 If @error Then
  6979.                 EndIf
  6980.             EndIf
  6981.             DllStructSetData($tbrowseinfo, 1, $hparent)
  6982.             DllStructSetData($tbrowseinfo, 2, $pidl)
  6983.             DllStructSetData($tbrowseinfo, 3, DllStructGetPtr($tbrowseinfo, 10))
  6984.             DllStructSetData($tbrowseinfo, 4, DllStructGetPtr($tbrowseinfo, 9))
  6985.             DllStructSetData($tbrowseinfo, 5, $iflags)
  6986.             DllStructSetData($tbrowseinfo, 6, $pbrowseproc)
  6987.             DllStructSetData($tbrowseinfo, 7, $lparam)
  6988.             DllStructSetData($tbrowseinfo, 8, 0)
  6989.             DllStructSetData($tbrowseinfo, 9, $stext)
  6990.             Local $ret = DllCall("shell32.dll", "ptr", "SHBrowseForFolderW", "struct*", $tbrowseinfo)
  6991.             If @error OR NOT $ret[0] Then Return SetError(@error, @extended, "")
  6992.             $result = _winapi_shellgetpathfromidlist($ret[0])
  6993.             _winapi_cotaskmemfree($ret[0])
  6994.             If $pidl Then
  6995.                 _winapi_cotaskmemfree($pidl)
  6996.             EndIf
  6997.             If NOT $result Then Return SetError(10, 0, "")
  6998.             Return $result
  6999.         EndFunc
  7000.  
  7001.         Func _winapi_commdlgextendederrorex()
  7002.             Local $ret = DllCall("comdlg32.dll", "dword", "CommDlgExtendedError")
  7003.             If @error Then Return SetError(@error, @extended, 0)
  7004.             Return $ret[0]
  7005.         EndFunc
  7006.  
  7007.         Func _winapi_confirmcredentials($starget, $fconfirm)
  7008.             If NOT __dll("credui.dll") Then Return SetError(103, 0, 0)
  7009.             Local $ret = DllCall("credui.dll", "dword", "CredUIConfirmCredentialsW", "wstr", $starget, "bool", $fconfirm)
  7010.             If @error Then Return SetError(@error, @extended, 0)
  7011.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  7012.             Return 1
  7013.         EndFunc
  7014.  
  7015.         Func _winapi_findtextdlg($howner, $sfindwhat = "", $iflags = 0, $pfindproc = 0, $lparam = 0)
  7016.             $__pfrbuffer = __heaprealloc($__pfrbuffer, 2 * $__ifrbuffersize)
  7017.             If @error Then Return SetError(@error + 20, @extended, 0)
  7018.             DllStructSetData(DllStructCreate("wchar[" & $__ifrbuffersize & "]", $__pfrbuffer), 1, StringLeft($sfindwhat, $__ifrbuffersize - 1))
  7019.             Local $tfr = DllStructCreate($tagfindreplace)
  7020.             DllStructSetData($tfr, "Size", DllStructGetSize($tfr))
  7021.             DllStructSetData($tfr, "hOwner", $howner)
  7022.             DllStructSetData($tfr, "hInstance", 0)
  7023.             DllStructSetData($tfr, "Flags", $iflags)
  7024.             DllStructSetData($tfr, "FindWhat", $__pfrbuffer)
  7025.             DllStructSetData($tfr, "ReplaceWith", 0)
  7026.             DllStructSetData($tfr, "FindWhatLen", $__ifrbuffersize * 2)
  7027.             DllStructSetData($tfr, "ReplaceWithLen", 0)
  7028.             DllStructSetData($tfr, "lParam", $lparam)
  7029.             DllStructSetData($tfr, "Hook", $pfindproc)
  7030.             DllStructSetData($tfr, "TemplateName", 0)
  7031.             Local $ret = DllCall("comdlg32.dll", "hwnd", "FindTextW", "struct*", $tfr)
  7032.             If @error OR NOT $ret[0] Then
  7033.                 Local $error = @error + 30
  7034.                 __heapfree($__pfrbuffer)
  7035.                 If IsArray($ret) Then
  7036.                     Return SetError(10, _winapi_commdlgextendederrorex(), 0)
  7037.                 Else
  7038.                     Return SetError($error, @extended, 0)
  7039.                 EndIf
  7040.             EndIf
  7041.             Return $ret[0]
  7042.         EndFunc
  7043.  
  7044.         Func _winapi_flushfrbuffer()
  7045.             If NOT __heapfree($__pfrbuffer, 1) Then Return SetError(@error, @extended, 0)
  7046.             Return 1
  7047.         EndFunc
  7048.  
  7049.         Func _winapi_formatdrivedlg($sdrive, $ioption = 0, $hparent = 0)
  7050.             If NOT IsString($sdrive) Then Return SetError(10, 0, 0)
  7051.             $sdrive = StringLeft(StringUpper(StringStripWS($sdrive, 1)), 1)
  7052.             If NOT $sdrive Then Return SetError(11, 0, 0)
  7053.             $sdrive = Asc($sdrive) - 65
  7054.             If ($sdrive < 0) OR ($sdrive > 25) Then Return SetError(12, 0, 0)
  7055.             Local $ret = DllCall("shell32.dll", "dword", "SHFormatDrive", "hwnd", $hparent, "uint", $sdrive, "uint", 65535, "uint", $ioption)
  7056.             If @error Then Return SetError(@error, @extended, 0)
  7057.             If $ret[0] < 0 Then Return SetError($ret[0], 0, 0)
  7058.             Return $ret[0]
  7059.         EndFunc
  7060.  
  7061.         Func _winapi_getconnecteddlg($idlg, $iflags = 0, $hparent = 0)
  7062.             If NOT __dll("connect.dll") Then Return SetError(103, 0, 0)
  7063.             Switch $idlg
  7064.                 Case 0
  7065.                     $idlg = "GetNetworkConnected"
  7066.                 Case 1
  7067.                     $idlg = "GetInternetConnected"
  7068.                 Case 2
  7069.                     $idlg = "GetVPNConnected"
  7070.                 Case Else
  7071.                     Return SetError(1, 0, 0)
  7072.             EndSwitch
  7073.             Local $str = ""
  7074.             If BitAND($iflags, 1) Then
  7075.                 $str &= "-SkipInternetDetection "
  7076.             EndIf
  7077.             If BitAND($iflags, 2) Then
  7078.                 $str &= "-SkipExistingConnections "
  7079.             EndIf
  7080.             If BitAND($iflags, 4) Then
  7081.                 $str &= "-HideFinishPage "
  7082.             EndIf
  7083.             Local $ret = DllCall("connect.dll", "long", $idlg, "hwnd", $hparent, "dword", 0, "dword", 0, "dword", 0, "handle", 0, "wstr", StringStripWS($str, 2))
  7084.             If @error Then Return SetError(@error, @extended, 0)
  7085.             If NOT ($ret[0] = 0 OR $ret[0] = 1) Then Return SetError(10, $ret[0], 0)
  7086.             Return Number(NOT $ret[0])
  7087.         EndFunc
  7088.  
  7089.         Func _winapi_getfrbuffer()
  7090.             Return $__ifrbuffersize - 1
  7091.         EndFunc
  7092.  
  7093.         Func _winapi_messageboxcheck($itype, $stitle, $stext, $sregval, $idefault = -1, $hparent = 0)
  7094.             Local $ret = DllCall("shlwapi.dll", "int", "SHMessageBoxCheckW", "hwnd", $hparent, "wstr", $stext, "wstr", $stitle, "uint", $itype, "int", $idefault, "wstr", $sregval)
  7095.             If @error Then Return SetError(@error, @extended, -1)
  7096.             Return $ret[0]
  7097.         EndFunc
  7098.  
  7099.         Func _winapi_messageboxindirect($tmsgboxparams)
  7100.             Local $ret = DllCall("user32.dll", "int", "MessageBoxIndirectW", "struct*", $tmsgboxparams)
  7101.             If @error Then Return SetError(@error, @extended, 0)
  7102.             Return $ret[0]
  7103.         EndFunc
  7104.  
  7105.         Func _winapi_openfiledlg($stitle = "", $sinitdir = "", $sfilters = "", $ideffilter = 0, $sdeffile = "", $sdefext = "", $iflags = 0, $iflagsex = 0, $pofnproc = 0, $pdata = 0, $hparent = 0)
  7106.             Local $result = __ofndlg(0, $stitle, $sinitdir, $sfilters, $ideffilter, $sdeffile, $sdefext, $iflags, $iflagsex, $pofnproc, $pdata, $hparent)
  7107.             If @error Then Return SetError(@error, @extended, "")
  7108.             Return $result
  7109.         EndFunc
  7110.  
  7111.         Func _winapi_pagesetupdlg(ByRef $tpagesetupdlg)
  7112.             Local $ret = DllCall("comdlg32.dll", "int", "PageSetupDlgW", "struct*", $tpagesetupdlg)
  7113.             If @error Then Return SetError(@error, @extended, 0)
  7114.             If NOT $ret[0] Then Return SetError(10, _winapi_commdlgextendederrorex(), 0)
  7115.             Return $ret[0]
  7116.         EndFunc
  7117.  
  7118.         Func _winapi_pickicondlg($sicon = "", $iindex = 0, $hparent = 0)
  7119.             Local $ret = DllCall("shell32.dll", "int", "PickIconDlg", "hwnd", $hparent, "wstr", $sicon, "int", 4096, "int*", $iindex)
  7120.             If @error OR NOT $ret[0] Then Return SetError(@error + 10, @extended, 0)
  7121.             Local $result[2]
  7122.             Local $aresult = DllCall("kernel32.dll", "dword", "ExpandEnvironmentStringsW", "wstr", $ret[2], "wstr", "", "dword", 4096)
  7123.             $result[0] = $aresult[2]
  7124.             $result[1] = $ret[4]
  7125.             Return $result
  7126.         EndFunc
  7127.  
  7128.         Func _winapi_printdlg(ByRef $tprintdlg)
  7129.             Local $ret = DllCall("comdlg32.dll", "long", "PrintDlgW", "struct*", $tprintdlg)
  7130.             If @error Then Return SetError(@error, @extended, 0)
  7131.             If NOT $ret[0] Then Return SetError(10, _winapi_commdlgextendederrorex(), 0)
  7132.             Return $ret[0]
  7133.         EndFunc
  7134.  
  7135.         Func _winapi_printdlgex(ByRef $tprintdlgex)
  7136.             Local $tpdex = DllStructCreate($tagprintdlgex, DllStructGetPtr($tprintdlgex))
  7137.             Local $ret = DllCall("comdlg32.dll", "long", "PrintDlgExW", "struct*", $tpdex)
  7138.             If @error Then Return SetError(@error, @extended, 0)
  7139.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  7140.             Return SetExtended(DllStructGetData($tpdex, "ResultAction"), 1)
  7141.         EndFunc
  7142.  
  7143.         Func _winapi_replacetextdlg($howner, $sfindwhat = "", $sreplacewith = "", $iflags = 0, $preplaceproc = 0, $lparam = 0)
  7144.             $__pfrbuffer = __heaprealloc($__pfrbuffer, 4 * $__ifrbuffersize)
  7145.             If @error Then Return SetError(@error + 100, @extended, 0)
  7146.             Local $tbuff = DllStructCreate("wchar[" & $__ifrbuffersize & "];wchar[" & $__ifrbuffersize & "]", $__pfrbuffer)
  7147.             DllStructSetData($tbuff, 1, StringLeft($sfindwhat, $__ifrbuffersize - 1))
  7148.             DllStructSetData($tbuff, 2, StringLeft($sreplacewith, $__ifrbuffersize - 1))
  7149.             Local $tfr = DllStructCreate($tagfindreplace)
  7150.             DllStructSetData($tfr, "Size", DllStructGetSize($tfr))
  7151.             DllStructSetData($tfr, "hOwner", $howner)
  7152.             DllStructSetData($tfr, "hInstance", 0)
  7153.             DllStructSetData($tfr, "Flags", $iflags)
  7154.             DllStructSetData($tfr, "FindWhat", DllStructGetPtr($tbuff, 1))
  7155.             DllStructSetData($tfr, "ReplaceWith", DllStructGetPtr($tbuff, 2))
  7156.             DllStructSetData($tfr, "FindWhatLen", $__ifrbuffersize * 2)
  7157.             DllStructSetData($tfr, "ReplaceWithLen", $__ifrbuffersize * 2)
  7158.             DllStructSetData($tfr, "lParam", $lparam)
  7159.             DllStructSetData($tfr, "Hook", $preplaceproc)
  7160.             DllStructSetData($tfr, "TemplateName", 0)
  7161.             Local $ret = DllCall("comdlg32.dll", "hwnd", "ReplaceTextW", "struct*", $tfr)
  7162.             If @error OR NOT $ret[0] Then
  7163.                 Local $error = @error
  7164.                 __heapfree($__pfrbuffer)
  7165.                 If IsArray($ret) Then
  7166.                     Return SetError(10, _winapi_commdlgextendederrorex(), 0)
  7167.                 Else
  7168.                     Return SetError($error, 0, 0)
  7169.                 EndIf
  7170.             EndIf
  7171.             Return $ret[0]
  7172.         EndFunc
  7173.  
  7174.         Func _winapi_restartdlg($stext = "", $iflags = 2, $hparent = 0)
  7175.             Local $ret = DllCall("shell32.dll", "int", "RestartDialog", "hwnd", $hparent, "wstr", $stext, "int", $iflags)
  7176.             If @error Then Return SetError(@error, @extended, 0)
  7177.             Return $ret[0]
  7178.         EndFunc
  7179.  
  7180.         Func _winapi_savefiledlg($stitle = "", $sinitdir = "", $sfilters = "", $ideffilter = 0, $sdeffile = "", $sdefext = "", $iflags = 0, $iflagsex = 0, $pofnproc = 0, $pdata = 0, $hparent = 0)
  7181.             Local $result = __ofndlg(1, $stitle, $sinitdir, $sfilters, $ideffilter, $sdeffile, $sdefext, $iflags, $iflagsex, $pofnproc, $pdata, $hparent)
  7182.             If @error Then Return SetError(@error, @extended, "")
  7183.             Return $result
  7184.         EndFunc
  7185.  
  7186.         Func _winapi_setfrbuffer($ichars)
  7187.             $ichars = Number($ichars)
  7188.             If $ichars < 80 Then
  7189.                 $ichars = 80
  7190.             EndIf
  7191.             $__ifrbuffersize = $ichars + 1
  7192.             Return 1
  7193.         EndFunc
  7194.  
  7195.         Func _winapi_shellaboutdlg($stitle, $sname, $stext, $hicon = 0, $hparent = 0)
  7196.             Local $ret = DllCall("shell32.dll", "int", "ShellAboutW", "hwnd", $hparent, "wstr", $stitle & "#" & $sname, "wstr", $stext, "handle", $hicon)
  7197.             If @error Then Return SetError(@error, @extended, False)
  7198.             Return $ret[0]
  7199.         EndFunc
  7200.  
  7201.         Func _winapi_shellopenwithdlg($sfile, $iflags = 0, $hparent = 0)
  7202.             Local $topenasinfo = DllStructCreate("ptr;ptr;dword;wchar[" & (StringLen($sfile) + 1) & "]")
  7203.             DllStructSetData($topenasinfo, 1, DllStructGetPtr($topenasinfo, 4))
  7204.             DllStructSetData($topenasinfo, 2, 0)
  7205.             DllStructSetData($topenasinfo, 3, $iflags)
  7206.             DllStructSetData($topenasinfo, 4, $sfile)
  7207.             Local $ret = DllCall("shell32.dll", "long", "SHOpenWithDialog", "hwnd", $hparent, "struct*", $topenasinfo)
  7208.             If @error Then Return SetError(@error, @extended, 0)
  7209.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  7210.             Return 1
  7211.         EndFunc
  7212.  
  7213.         Func _winapi_shellstartnetconnectiondlg($sremote = "", $iflags = 0, $hparent = 0)
  7214.             Local $typeofremote = "wstr"
  7215.             If NOT StringStripWS($sremote, 3) Then
  7216.                 $typeofremote = "ptr"
  7217.                 $sremote = 0
  7218.             EndIf
  7219.             DllCall("shell32.dll", "long", "SHStartNetConnectionDialogW", "hwnd", $hparent, $typeofremote, $sremote, "dword", $iflags)
  7220.             If @error Then Return SetError(@error, @extended, 0)
  7221.             Return 1
  7222.         EndFunc
  7223.  
  7224.         Func _winapi_shelluserauthenticationdlg($scaption, $smessage, $suser, $spassword, $starget, $iflags = 0, $ierror = 0, $fsave = 0, $hbitmap = 0, $hparent = 0)
  7225.             If NOT __dll("credui.dll") Then Return SetError(103, 0, 0)
  7226.             Local $tinfo = DllStructCreate("dword;hwnd;ptr;ptr;ptr;wchar[" & (StringLen($smessage) + 1) & "];wchar[" & (StringLen($scaption) + 1) & "]")
  7227.             DllStructSetData($tinfo, 1, DllStructGetPtr($tinfo, 6) - DllStructGetPtr($tinfo))
  7228.             DllStructSetData($tinfo, 2, $hparent)
  7229.             DllStructSetData($tinfo, 3, DllStructGetPtr($tinfo, 6))
  7230.             DllStructSetData($tinfo, 4, DllStructGetPtr($tinfo, 7))
  7231.             DllStructSetData($tinfo, 5, $hbitmap)
  7232.             DllStructSetData($tinfo, 6, $smessage)
  7233.             DllStructSetData($tinfo, 7, $scaption)
  7234.             Local $ret = DllCall("credui.dll", "dword", "CredUIPromptForCredentialsW", "struct*", $tinfo, "wstr", $starget, "ptr", 0, "dword", $ierror, "wstr", $suser, "ulong", 4096, "wstr", $spassword, "ulong", 4096, "bool*", $fsave, "dword", $iflags)
  7235.             If @error Then Return SetError(@error, @extended, 0)
  7236.             If $ret[0] Then Return SetError(10, $ret[0], 0)
  7237.             Local $result[3]
  7238.             $result[0] = $ret[5]
  7239.             $result[1] = $ret[7]
  7240.             $result[2] = $ret[9]
  7241.             Return $result
  7242.         EndFunc
  7243.  
  7244.         Func _winapi_shelluserauthenticationdlgex($scaption, $smessage, $suser, $spassword, $iflags = 0, $ierror = 0, $fsave = 0, $ipackage = 0, $hparent = 0)
  7245.             If NOT __dll("credui.dll") Then Return SetError(103, 0, 0)
  7246.             Local $tblob = 0, $ret
  7247.             If StringLen($suser) Then
  7248.                 $ret = DllCall("credui.dll", "bool", "CredPackAuthenticationBufferW", "dword", 1, "wstr", $suser, "wstr", $spassword, "ptr", 0, "dword*", 0)
  7249.                 If @error OR NOT $ret[5] Then Return SetError(@error + 10, @extended, 0)
  7250.                 $tblob = DllStructCreate("byte[" & $ret[5] & "]")
  7251.                 $ret = DllCall("credui.dll", "bool", "CredPackAuthenticationBufferW", "dword", 1, "wstr", $suser, "wstr", $spassword, "struct*", $tblob, "dword*", $ret[5])
  7252.                 If @error OR NOT $ret[0] Then Return SetError(@error + 20, @extended, 0)
  7253.             EndIf
  7254.             Local $tinfo = DllStructCreate("dword;hwnd;ptr;ptr;ptr;wchar[" & (StringLen($smessage) + 1) & "];wchar[" & (StringLen($scaption) + 1) & "]")
  7255.             DllStructSetData($tinfo, 1, DllStructGetPtr($tinfo, 6) - DllStructGetPtr($tinfo))
  7256.             DllStructSetData($tinfo, 2, $hparent)
  7257.             DllStructSetData($tinfo, 3, DllStructGetPtr($tinfo, 6))
  7258.             DllStructSetData($tinfo, 4, DllStructGetPtr($tinfo, 7))
  7259.             DllStructSetData($tinfo, 5, 0)
  7260.             DllStructSetData($tinfo, 6, $smessage)
  7261.             DllStructSetData($tinfo, 7, $scaption)
  7262.             $ret = DllCall("credui.dll", "dword", "CredUIPromptForWindowsCredentialsW", "struct*", $tinfo, "dword", $ierror, "ulong*", $ipackage, "struct*", $tblob, "ulong", DllStructGetSize($tblob), "ptr*", 0, "ulong*", 0, "bool*", $fsave, "dword", $iflags)
  7263.             If @error Then Return SetError(@error + 30, @extended, 0)
  7264.             If $ret[0] Then Return SetError(30, $ret[0], 0)
  7265.             Local $result[4]
  7266.             $result[2] = $ret[8]
  7267.             $result[3] = $ret[3]
  7268.             Local $pblob = $ret[6]
  7269.             Local $size = $ret[7]
  7270.             $ret = DllCall("credui.dll", "bool", "CredUnPackAuthenticationBufferW", "dword", 1, "ptr", $pblob, "dword", $size, "wstr", "", "dword*", 4096, "wstr", "", "dword*", 4096, "wstr", "", "dword*", 4096)
  7271.             If NOT @error AND $ret[0] Then
  7272.                 $result[0] = $ret[4]
  7273.                 $result[1] = $ret[8]
  7274.             Else
  7275.                 $result = @error + 40
  7276.             EndIf
  7277.             If NOT _winapi_zeromemory($pblob, $size) Then
  7278.             EndIf
  7279.             _winapi_cotaskmemfree($pblob)
  7280.             If $result Then Return SetError($result, 0, 0)
  7281.             Return $result
  7282.         EndFunc
  7283.  
  7284.     #EndRegion Public Functions
  7285.     #Region Internal Functions
  7286.  
  7287.         Func __ofndlg($idlg, $stitle, $sinitdir, $sfilters, $ideffilter, $sdeffile, $sdefext, $iflags, $iflagsex, $pofnproc, $pdata, $hparent)
  7288.             Local $tbuffer = DllStructCreate("wchar[32768]")
  7289.             Local $tfilters = 0, $tdefext = 0, $tinitdir = 0, $ttitle = 0
  7290.             Local $tofn = DllStructCreate($tagopenfilename)
  7291.             DllStructSetData($tofn, 1, DllStructGetSize($tofn))
  7292.             DllStructSetData($tofn, 2, $hparent)
  7293.             DllStructSetData($tofn, 3, 0)
  7294.             Local $adata = StringSplit($sfilters, "|")
  7295.             Local $afilters[$adata[0] * 2]
  7296.             Local $count = 0
  7297.             For $i = 1 To $adata[0]
  7298.                 $afilters[$count + 0] = StringStripWS($adata[$i], 3)
  7299.                 $afilters[$count + 1] = StringStripWS(StringRegExpReplace($adata[$i], ".*\((.*)\)", "\1"), 8)
  7300.                 If $afilters[$count + 1] Then
  7301.                     $count += 2
  7302.                 EndIf
  7303.             Next
  7304.             If $count Then
  7305.                 $tfilters = _winapi_arraytostruct($afilters, 0, $count - 1)
  7306.                 If @error Then
  7307.                 EndIf
  7308.             EndIf
  7309.             DllStructSetData($tofn, 4, DllStructGetPtr($tfilters))
  7310.             DllStructSetData($tofn, 5, 0)
  7311.             DllStructSetData($tofn, 6, 0)
  7312.             DllStructSetData($tofn, 7, $ideffilter)
  7313.             $sdeffile = StringStripWS($sdeffile, 3)
  7314.             If $sdeffile Then
  7315.                 DllStructSetData($tbuffer, 1, $sdeffile)
  7316.             EndIf
  7317.             DllStructSetData($tofn, 8, DllStructGetPtr($tbuffer))
  7318.             DllStructSetData($tofn, 9, 32768)
  7319.             DllStructSetData($tofn, 10, 0)
  7320.             DllStructSetData($tofn, 11, 0)
  7321.             $sinitdir = StringStripWS($sinitdir, 3)
  7322.             If $sinitdir Then
  7323.                 $tinitdir = DllStructCreate("wchar[" & (StringLen($sinitdir) + 1) & "]")
  7324.             EndIf
  7325.             DllStructSetData($tinitdir, 1, $sinitdir)
  7326.             DllStructSetData($tofn, 12, DllStructGetPtr($tinitdir))
  7327.             $stitle = StringStripWS($stitle, 3)
  7328.             If $stitle Then
  7329.                 $ttitle = DllStructCreate("wchar[" & (StringLen($stitle) + 1) & "]")
  7330.             EndIf
  7331.             DllStructSetData($ttitle, 1, $stitle)
  7332.             DllStructSetData($tofn, 13, DllStructGetPtr($ttitle))
  7333.             DllStructSetData($tofn, 14, $iflags)
  7334.             DllStructSetData($tofn, 15, 0)
  7335.             DllStructSetData($tofn, 16, 0)
  7336.             $sdefext = StringStripWS($sdefext, 3)
  7337.             If $sdefext Then
  7338.                 $tdefext = DllStructCreate("wchar[" & (StringLen($tdefext) + 1) & "]")
  7339.             EndIf
  7340.             DllStructSetData($tdefext, 1, StringReplace($sdefext, ".", ""))
  7341.             DllStructSetData($tofn, 17, DllStructGetPtr($tdefext))
  7342.             DllStructSetData($tofn, 18, $pdata)
  7343.             DllStructSetData($tofn, 19, $pofnproc)
  7344.             DllStructSetData($tofn, 20, 0)
  7345.             DllStructSetData($tofn, 21, 0)
  7346.             DllStructSetData($tofn, 22, 0)
  7347.             DllStructSetData($tofn, 23, $iflagsex)
  7348.             Local $ret
  7349.             Switch $idlg
  7350.                 Case 0
  7351.                     $ret = DllCall("comdlg32.dll", "int", "GetOpenFileNameW", "struct*", $tofn)
  7352.                 Case 1
  7353.                     $ret = DllCall("comdlg32.dll", "int", "GetSaveFileNameW", "struct*", $tofn)
  7354.                 Case Else
  7355.             EndSwitch
  7356.             If @error Then Return SetError(@error, @extended, "")
  7357.             If NOT $ret[0] Then Return SetError(10, _winapi_commdlgextendederrorex(), "")
  7358.             If BitAND($iflags, 512) Then
  7359.                 If BitAND($iflags, 524288) Then
  7360.                     $adata = _winapi_structtoarray($tbuffer)
  7361.                     If @error Then
  7362.                         Return SetError(11, 0, "")
  7363.                     EndIf
  7364.                 Else
  7365.                     $adata = StringSplit(DllStructGetData($tbuffer, 1), " ")
  7366.                 EndIf
  7367.                 Switch $adata[0]
  7368.                     Case 0
  7369.                         Return SetError(12, 0, "")
  7370.                     Case 1
  7371.                     Case Else
  7372.                         Local $path = $adata[1]
  7373.                         For $i = 2 To $adata[0]
  7374.                             $adata[$i - 1] = _winapi_pathappend($path, $adata[$i])
  7375.                         Next
  7376.                         ReDim $adata[$adata[0]]
  7377.                         $adata[0] -= 1
  7378.                 EndSwitch
  7379.             Else
  7380.                 $adata = DllStructGetData($tbuffer, 1)
  7381.             EndIf
  7382.             $__ext = $tofn
  7383.             Return $adata
  7384.         EndFunc
  7385.  
  7386.     #EndRegion Internal Functions
  7387.     Global $i
  7388.     Global $check_on_off = 0
  7389.     Global $v = 0, $anti = 0, $ad = 0, $m = 0, $update, $s = 0
  7390.     Global $rest, $again, $tip
  7391.     Local $programname = "Zerux Beta 1.2"
  7392.     Local $tmp_v = "", $tmp_anti = "", $tmp_ad = "", $tmp_m = "", $tmp_s = ""
  7393.     Global $zeruxgui
  7394.     Opt("TrayOnEventMode", 1)
  7395.     Opt("TrayMenuMode", 1)
  7396.     If _singleton(@ScriptName, 1) = 0 Then
  7397.         Exit
  7398.     EndIf
  7399.     ProcessSetPriority(@ScriptName, 1)
  7400.     DllCall("psapi.dll", "int", "EmptyWorkingSet", "long", -1)
  7401.     $runguard1000 = TrayCreateItem($programname)
  7402.     TrayItemSetOnEvent(-1, "start")
  7403.     $license = TrayCreateItem("라이센스")
  7404.     TrayItemSetOnEvent(-1, "license")
  7405.     TrayCreateItem("")
  7406.     $check = TrayCreateItem("실시간 감시 On/Off")
  7407.     TrayItemSetOnEvent(-1, "check")
  7408.     TrayCreateItem("")
  7409.     $setting_are = TrayCreateItem("환경설정")
  7410.     TrayItemSetOnEvent(-1, "setting_are")
  7411.     TrayCreateItem("")
  7412.     $exit = TrayCreateItem("종료")
  7413.     TrayItemSetOnEvent(-1, "_exit")
  7414.     TraySetState()
  7415.     TraySetToolTip($programname)
  7416.  
  7417.     Func start()
  7418.         Local $socket, $data
  7419.         If ProcessExists("zeruxgui.exe") Then
  7420.             UDPStartup()
  7421.             $socket = UDPOpen(@IPAddress1, 1000)
  7422.             $data = "exit"
  7423.             UDPSend($socket, $data)
  7424.             UDPCloseSocket($socket)
  7425.             UDPShutdown()
  7426.             $zeruxgui = 0
  7427.         Else
  7428.             Run(@ScriptDir & "\zeruxgui.exe")
  7429.             $zeruxgui = 1
  7430.         EndIf
  7431.     EndFunc
  7432.  
  7433.     Func license()
  7434.         _winapi_shellaboutdlg("Elkiesoft License", "Zerux AI Security", "개인 사용자 한에서만 무료로 사용 재배포가 가능하며 수정및 판매는 불가능합니다. 기업 ,단체, 공기관은 로열티나 사용료를 지불하여 계약에 따라 사용할수 있습니다.", _winapi_shellextracticon(@AutoItExe, 0, 32, 32))
  7435.     EndFunc
  7436.  
  7437.     Func check()
  7438.         If $check_on_off == 1 Then
  7439.             $check_on_off = 0
  7440.             TrayTip($programname, "실시간 감시 시작되었습니다!", 1, 5)
  7441.         ElseIf $check_on_off == 0 Then
  7442.             $check_on_off = 1
  7443.             TrayTip($programname, "실시간 감시 중지되었습니다!", 1, 5)
  7444.         EndIf
  7445.     EndFunc
  7446.  
  7447.     Func setting_are()
  7448.         Run(@ScriptDir & "\환경설정")
  7449.     EndFunc
  7450.  
  7451.     Func _exit()
  7452.         Local $socket, $data
  7453.         UDPStartup()
  7454.         $socket = UDPOpen(@IPAddress1, 1000)
  7455.         $data = "exit"
  7456.         UDPSend($socket, $data)
  7457.         UDPCloseSocket($socket)
  7458.         UDPShutdown()
  7459.         ClipPut(StringToBinary(@MDAY & @MON, 1))
  7460.         Do
  7461.             Sleep(500)
  7462.         Until ClipGet() == StringToBinary(@MON & @MDAY, 1)
  7463.         ClipPut("")
  7464.         Exit
  7465.     EndFunc
  7466.  
  7467.     If NOT FileExists(@ScriptDir & "\setting.ini") Then
  7468.         IniWrite(@ScriptDir & "\setting.ini", "SET_ONE", "virus", 1)
  7469.         IniWrite(@ScriptDir & "\setting.ini", "SET_ONE", "anticode", 1)
  7470.         IniWrite(@ScriptDir & "\setting.ini", "SET_ONE", "adware", 1)
  7471.         IniWrite(@ScriptDir & "\setting.ini", "SET_ONE", "melware", 1)
  7472.         IniWrite(@ScriptDir & "\setting.ini", "SET_ONE", "spyware", 1)
  7473.         IniWrite(@ScriptDir & "\setting.ini", "SET_ONE", "again", 1)
  7474.         IniWrite(@ScriptDir & "\setting.ini", "SET_TWO", "tip", 1)
  7475.         IniWrite(@ScriptDir & "\setting.ini", "SET_TWO", "start", 1)
  7476.         IniWrite(@ScriptDir & "\setting.ini", "SET_TWO", "update", 1)
  7477.         IniWrite(@ScriptDir & "\setting.ini", "SET_ONE", "speed", 20)
  7478.         IniWrite(@ScriptDir & "\setting.ini", "SET_ONE", "ping", 1)
  7479.     EndIf
  7480.     Global $gver = IniRead(@ScriptDir & "\G-Engine.ini", "Ver", "Version", "")
  7481.     Global $tmp
  7482.     $update = IniRead(@ScriptDir & "\setting.ini", "SET_TWO", "update", "")
  7483.     If $update == 1 Then
  7484.         If Ping("210.216.176.19") Then
  7485.             TrayTip($programname, $gver & " : 서버 불안정으로 업데이트 연기합니다.", 1, 5)
  7486.         Else
  7487.             $tmp = BinaryToString(InetRead("http://zerux.co.kr/zerux/gver.txt"), 1)
  7488.             If $gver == $tmp Then
  7489.                 TrayTip($programname, $gver & " : 최신 백신엔진 사용중", 1, 5)
  7490.             Else
  7491.                 FileDelete(@ScriptDir & "\G-Engine.ini")
  7492.                 FileWrite(@ScriptDir & "\G-Engine.ini", BinaryToString(InetRead("http://zerux.co.kr/zerux/gengine.txt"), 1))
  7493.                 $gver = IniRead(@ScriptDir & "\G-Engine.ini", "Ver", "Version", "")
  7494.                 TrayTip($programname, $gver & " : 백신엔진 업데이트완료!", 1, 5)
  7495.             EndIf
  7496.         EndIf
  7497.     EndIf
  7498.     TraySetToolTip($programname & ": " & $gver)
  7499.     $rest = IniRead(@ScriptDir & "\setting.ini", "SET_ONE", "speed", "")
  7500.     $again = IniRead(@ScriptDir & "\setting.ini", "SET_ONE", "again", "")
  7501.     $tip = IniRead(@ScriptDir & "\setting.ini", "SET_TWO", "tip", "")
  7502.     $zeruxgui = IniRead(@ScriptDir & "\setting.ini", "SET_TWO", "gui", "")
  7503.     _main()
  7504.  
  7505.     Func _main()
  7506.         While (1)
  7507.             If $check_on_off == 1 Then
  7508.                 ContinueLoop
  7509.             EndIf
  7510.             DllCall("psapi.dll", "int", "EmptyWorkingSet", "long", -1)
  7511.             If NOT ProcessExists("zerux.exe") Then
  7512.                 If NOT ProcessExists("zerux.exe") Then
  7513.                     Run(@ScriptDir & "\zerux.exe")
  7514.                 EndIf
  7515.             EndIf
  7516.             If NOT ProcessExists("zeruxgui.exe") Then
  7517.                 If $zeruxgui == 1 Then
  7518.                     Run(@ScriptDir & "\zeruxgui.exe")
  7519.                 EndIf
  7520.             EndIf
  7521.             If IniRead(@ScriptDir & "\setting.ini", "SET_ONE", "virus", "") == 1 Then
  7522.                 $virus = IniReadSection(@ScriptDir & "\G-Engine.ini", "Virus")
  7523.                 For $i = 1 To $virus[0][0]
  7524.                     If ProcessExists($virus[$i][1]) Then
  7525.                         If $again == 1 Then
  7526.                             If StringCompare($tmp_v, $virus[$i][1]) == 0 Then
  7527.                                 $v += 1
  7528.                                 If $v <= 2 Then
  7529.                                     ProcessClose($virus[$i][1])
  7530.                                     If $tip == 1 Then
  7531.                                         TrayTip($programname, $virus[$i][1] & "는 바이러스 임으로 종료합니다.", 1, 5)
  7532.                                     EndIf
  7533.                                 ElseIf $v == 3 Then
  7534.                                     If $tip == 1 Then
  7535.                                         ToolTip($virus[$i][1] & "를 종료하는데 실패함!", 0, 0, $programname)
  7536.                                         Sleep(3000)
  7537.                                         ToolTip("")
  7538.                                     EndIf
  7539.                                 EndIf
  7540.                             Else
  7541.                                 ProcessClose($virus[$i][1])
  7542.                                 If $tip == 1 Then
  7543.                                     TrayTip($programname, $virus[$i][1] & "는 바이러스 임으로 종료합니다.", 1, 5)
  7544.                                 EndIf
  7545.                             EndIf
  7546.                             $tmp_v = $virus[$i][1]
  7547.                         Else
  7548.                             ProcessClose($virus[$i][1])
  7549.                             If $tip == 1 Then
  7550.                                 TrayTip($programname, $virus[$i][1] & "는 바이러스 임으로 종료합니다.", 1, 5)
  7551.                             EndIf
  7552.                         EndIf
  7553.                     EndIf
  7554.                     Sleep($rest)
  7555.                 Next
  7556.             EndIf
  7557.             If IniRead(@ScriptDir & "\setting.ini", "SET_ONE", "anticode", "") == 1 Then
  7558.                 $anticode = IniReadSection(@ScriptDir & "\G-Engine.ini", "AntiCode")
  7559.                 For $i = 1 To $anticode[0][0]
  7560.                     If ProcessExists($anticode[$i][1]) Then
  7561.                         If $again == 1 Then
  7562.                             If StringCompare($tmp_anti, $anticode[$i][1]) == 0 Then
  7563.                                 $anti += 1
  7564.                                 If $anti <= 2 Then
  7565.                                     ProcessClose($anticode[$i][1])
  7566.                                     If $tip == 1 Then
  7567.                                         TrayTip($programname, $anticode[$i][1] & "는 악성코드 임으로 종료합니다.", 1, 5)
  7568.                                     EndIf
  7569.                                 ElseIf $anti == 3 Then
  7570.                                     If $tip == 1 Then
  7571.                                         ToolTip($anticode[$i][1] & "를 종료하는데 실패함!", 0, 0, $programname)
  7572.                                         Sleep(3000)
  7573.                                         ToolTip("")
  7574.                                     EndIf
  7575.                                 EndIf
  7576.                             Else
  7577.                                 ProcessClose($anticode[$i][1])
  7578.                                 If $tip == 1 Then
  7579.                                     TrayTip($programname, $anticode[$i][1] & "는 악성코드 임으로 종료합니다.", 1, 5)
  7580.                                 EndIf
  7581.                             EndIf
  7582.                             $tmp_anti = $anticode[$i][1]
  7583.                         Else
  7584.                             ProcessClose($anticode[$i][1])
  7585.                             If $tip == 1 Then
  7586.                                 TrayTip($programname, $anticode[$i][1] & "는 악성코드 임으로 종료합니다.", 1, 5)
  7587.                             EndIf
  7588.                         EndIf
  7589.                     EndIf
  7590.                     Sleep($rest)
  7591.                 Next
  7592.             EndIf
  7593.             If IniRead(@ScriptDir & "\setting.ini", "SET_ONE", "adware", "") == 1 Then
  7594.                 $adware = IniReadSection(@ScriptDir & "\G-Engine.ini", "Adware")
  7595.                 For $i = 1 To $adware[0][0]
  7596.                     If ProcessExists($adware[$i][1]) Then
  7597.                         If $again == 1 Then
  7598.                             If StringCompare($tmp_ad, $adware[$i][1]) == 0 Then
  7599.                                 $ad += 1
  7600.                                 If NOT $ad <= 2 Then
  7601.                                     ProcessClose($adware[$i][1])
  7602.                                     If $tip == 1 Then
  7603.                                         TrayTip($programname, $adware[$i][1] & "는 애드웨어 임으로 종료합니다.", 1, 5)
  7604.                                     EndIf
  7605.                                 ElseIf $ad == 3 Then
  7606.                                     If $tip == 1 Then
  7607.                                         ToolTip($adware[$i][1] & "를 종료하는데 실패함!", 0, 0, $programname)
  7608.                                         Sleep(3000)
  7609.                                         ToolTip("")
  7610.                                     EndIf
  7611.                                 EndIf
  7612.                             Else
  7613.                                 ProcessClose($adware[$i][1])
  7614.                                 If $tip == 1 Then
  7615.                                     TrayTip($programname, $adware[$i][1] & "는 애드웨어 임으로 종료합니다.", 1, 5)
  7616.                                 EndIf
  7617.                             EndIf
  7618.                             $tmp_ad = $adware[$i][1]
  7619.                         Else
  7620.                             ProcessClose($adware[$i][1])
  7621.                             If $tip == 1 Then
  7622.                                 TrayTip($programname, $adware[$i][1] & "는 애드웨어 임으로 종료합니다.", 1, 5)
  7623.                             EndIf
  7624.                         EndIf
  7625.                     EndIf
  7626.                     Sleep($rest)
  7627.                 Next
  7628.             EndIf
  7629.             If IniRead(@ScriptDir & "\setting.ini", "SET_ONE", "spyware", "") == 1 Then
  7630.                 $spyware = IniReadSection(@ScriptDir & "\G-Engine.ini", "Spyware")
  7631.                 For $i = 1 To $spyware[0][0]
  7632.                     If ProcessExists($spyware[$i][1]) Then
  7633.                         If $again == 1 Then
  7634.                             If StringCompare($tmp_s, $spyware[$i][1]) == 0 Then
  7635.                                 $s += 1
  7636.                                 If $s <= 2 Then
  7637.                                     ProcessClose($spyware[$i][1])
  7638.                                     If $tip == 1 Then
  7639.                                         TrayTip($programname, $spyware[$i][1] & "는 스파이웨어 임으로 종료합니다.", 1, 5)
  7640.                                     EndIf
  7641.                                 ElseIf $s == 3 Then
  7642.                                     If $tip == 1 Then
  7643.                                         ToolTip($spyware[$i][1] & "를 종료하는데 실패함!", 0, 0, $programname)
  7644.                                         Sleep(3000)
  7645.                                         ToolTip("")
  7646.                                     EndIf
  7647.                                 EndIf
  7648.                             Else
  7649.                                 ProcessClose($spyware[$i][1])
  7650.                                 If $tip == 1 Then
  7651.                                     TrayTip($programname, $spyware[$i][1] & "는 스파이웨어 임으로 종료합니다.", 1, 5)
  7652.                                 EndIf
  7653.                             EndIf
  7654.                             $tmp_s = $spyware[$i][1]
  7655.                         Else
  7656.                             ProcessClose($spyware[$i][1])
  7657.                             If $tip == 1 Then
  7658.                                 TrayTip($programname, $spyware[$i][1] & "는 스파이웨어 임으로 종료합니다.", 1, 5)
  7659.                             EndIf
  7660.                         EndIf
  7661.                     EndIf
  7662.                     Sleep($rest)
  7663.                 Next
  7664.             EndIf
  7665.             If IniRead(@ScriptDir & "\setting.ini", "SET_ONE", "melware", "") == 1 Then
  7666.                 $melware = IniReadSection(@ScriptDir & "\G-Engine.ini", "Melware")
  7667.                 For $i = 1 To $melware[0][0]
  7668.                     If ProcessExists($melware[$i][1]) Then
  7669.                         If $again == 1 Then
  7670.                             If StringCompare($tmp_m, $melware[$i][1]) == 0 Then
  7671.                                 $m += 1
  7672.                                 If $m <= 2 Then
  7673.                                     ProcessClose($melware[$i][1])
  7674.                                     If $tip == 1 Then
  7675.                                         TrayTip($programname, $melware[$i][1] & "는 맬웨어 임으로 종료합니다.", 1, 5)
  7676.                                     EndIf
  7677.                                 ElseIf $m == 3 Then
  7678.                                     If $tip == 1 Then
  7679.                                         ToolTip($melware[$i][1] & "를 종료하는데 실패함!", 0, 0, $programname)
  7680.                                         Sleep(3000)
  7681.                                         ToolTip("")
  7682.                                     EndIf
  7683.                                 EndIf
  7684.                             Else
  7685.                                 ProcessClose($melware[$i][1])
  7686.                                 If $tip == 1 Then
  7687.                                     TrayTip($programname, $melware[$i][1] & "는 맬웨어 임으로 종료합니다.", 1, 5)
  7688.                                 EndIf
  7689.                             EndIf
  7690.                             $tmp_m = $melware[$i][1]
  7691.                         Else
  7692.                             ProcessClose($melware[$i][1])
  7693.                             If $tip == 1 Then
  7694.                                 TrayTip($programname, $melware[$i][1] & "는 맬웨어 임으로 종료합니다.", 1, 5)
  7695.                             EndIf
  7696.                         EndIf
  7697.                     EndIf
  7698.                     Sleep($rest)
  7699.                 Next
  7700.             EndIf
  7701.             Sleep(1000)
  7702.         WEnd
  7703.     EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement