Advertisement
Guest User

Source code for me

a guest
Nov 26th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 63.19 KB | None | 0 0
  1. #Region
  2. #AutoIt3Wrapper_Icon=Untitled-3.ico
  3. #AutoIt3Wrapper_OutFile=..\bin\bakingbreadcsgo.exe
  4. #AutoIt3Wrapper_Change2CUI=y
  5. #AutoIt3Wrapper_res_requestedExecutionLevel=asInvoker
  6. #EndRegion
  7. Global Const $tagpoint = "long X;long Y"
  8. Global Const $tagrect = "long Left;long Top;long Right;long Bottom"
  9. Global Const $tagsize = "long X;long Y"
  10. Global Const $tagmargins = "int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight"
  11. Global Const $tagfiletime = "dword Lo;dword Hi"
  12. Global Const $tagsystemtime = "word Year;word Month;word Dow;word Day;word Hour;word Minute;word Second;word MSeconds"
  13. Global Const $tagtime_zone_information = "long Bias;wchar StdName[32];word StdDate[8];long StdBias;wchar DayName[32];word DayDate[8];long DayBias"
  14. Global Const $tagnmhdr = "hwnd hWndFrom;uint_ptr IDFrom;INT Code"
  15. Global Const $tagcomboboxexitem = "uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;int SelectedImage;int OverlayImage;" & "int Indent;lparam Param"
  16. Global Const $tagnmcbedragbegin = $tagnmhdr & ";int ItemID;ptr szText"
  17. Global Const $tagnmcbeendedit = $tagnmhdr & ";bool fChanged;int NewSelection;ptr szText;int Why"
  18. Global Const $tagnmcomboboxex = $tagnmhdr & ";uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;" & "int SelectedImage;int OverlayImage;int Indent;lparam Param"
  19. 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"
  20. Global Const $tagnmdatetimechange = $tagnmhdr & ";dword Flag;" & $tagsystemtime
  21. Global Const $tagnmdatetimeformat = $tagnmhdr & ";ptr Format;" & $tagsystemtime & ";ptr pDisplay;wchar Display[64]"
  22. Global Const $tagnmdatetimeformatquery = $tagnmhdr & ";ptr Format;long SizeX;long SizeY"
  23. Global Const $tagnmdatetimekeydown = $tagnmhdr & ";int VirtKey;ptr Format;" & $tagsystemtime
  24. Global Const $tagnmdatetimestring = $tagnmhdr & ";ptr UserString;" & $tagsystemtime & ";dword Flags"
  25. 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"
  26. Global Const $taggdipbitmapdata = "uint Width;uint Height;int Stride;int Format;ptr Scan0;uint_ptr Reserved"
  27. Global Const $taggdipencoderparam = "byte GUID[16];dword Count;dword Type;ptr Values"
  28. Global Const $taggdipencoderparams = "dword Count;byte Params[0]"
  29. Global Const $taggdiprectf = "float X;float Y;float Width;float Height"
  30. Global Const $taggdipstartupinput = "uint Version;ptr Callback;bool NoThread;bool NoCodecs"
  31. Global Const $taggdipstartupoutput = "ptr HookProc;ptr UnhookProc"
  32. 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"
  33. Global Const $taggdippencoderparams = "dword Count;byte Params[0]"
  34. 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"
  35. Global Const $tagnmhddispinfo = $tagnmhdr & ";int Item;uint Mask;ptr Text;int TextMax;int Image;lparam lParam"
  36. Global Const $tagnmhdfilterbtnclick = $tagnmhdr & ";int Item;" & $tagrect
  37. Global Const $tagnmheader = $tagnmhdr & ";int Item;int Button;ptr pItem"
  38. Global Const $taggetipaddress = "byte Field4;byte Field3;byte Field2;byte Field1"
  39. Global Const $tagnmipaddress = $tagnmhdr & ";int Field;int Value"
  40. Global Const $taglvfindinfo = "uint Flags;ptr Text;lparam Param;" & $tagpoint & ";uint Direction"
  41. Global Const $taglvhittestinfo = $tagpoint & ";uint Flags;int Item;int SubItem"
  42. Global Const $taglvitem = "uint Mask;int Item;int SubItem;uint State;uint StateMask;ptr Text;int TextMax;int Image;lparam Param;" & "int Indent;int GroupID;uint Columns;ptr pColumns"
  43. Global Const $tagnmlistview = $tagnmhdr & ";int Item;int SubItem;uint NewState;uint OldState;uint Changed;" & "long ActionX;long ActionY;lparam Param"
  44. Global Const $tagnmlvcustomdraw = $tagnmhdr & ";dword dwDrawStage;handle hdc;long Left;long Top;long Right;long Bottom;" & "dword_ptr dwItemSpec;uint uItemState;lparam lItemlParam" & ";dword clrText;dword clrTextBk;int iSubItem;dword dwItemType;dword clrFace;int iIconEffect;" & "int iIconPhase;int iPartId;int iStateId;long TextLeft;long TextTop;long TextRight;long TextBottom;uint uAlign"
  45. Global Const $tagnmlvdispinfo = $tagnmhdr & ";" & $taglvitem
  46. Global Const $tagnmlvfinditem = $tagnmhdr & ";" & $taglvfindinfo
  47. Global Const $tagnmlvgetinfotip = $tagnmhdr & ";dword Flags;ptr Text;int TextMax;int Item;int SubItem;lparam lParam"
  48. Global Const $tagnmitemactivate = $tagnmhdr & ";int Index;int SubItem;uint NewState;uint OldState;uint Changed;" & $tagpoint & ";lparam lParam;uint KeyFlags"
  49. Global Const $tagnmlvkeydown = $tagnmhdr & ";align 1;word VKey;uint Flags"
  50. Global Const $tagnmlvscroll = $tagnmhdr & ";int DX;int DY"
  51. Global Const $tagmchittestinfo = "uint Size;" & $tagpoint & ";uint Hit;" & $tagsystemtime
  52. 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"
  53. 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"
  54. 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"
  55. Global Const $tagnmdaystate = $tagnmhdr & ";" & $tagsystemtime & ";int DayState;ptr pDayState"
  56. Global Const $tagnmselchange = $tagnmhdr & ";word BegYear;word BegMonth;word BegDOW;word BegDay;" & "word BegHour;word BegMinute;word BegSecond;word BegMSeconds;word EndYear;word EndMonth;word EndDOW;" & "word EndDay;word EndHour;word EndMinute;word EndSecond;word EndMSeconds"
  57. Global Const $tagnmobjectnotify = $tagnmhdr & ";int Item;ptr piid;ptr pObject;long Result"
  58. Global Const $tagnmtckeydown = $tagnmhdr & ";word VKey;uint Flags"
  59. Global Const $tagtvitem = "uint Mask;handle hItem;uint State;uint StateMask;ptr Text;int TextMax;int Image;int SelectedImage;" & "int Children;lparam Param"
  60. Global Const $tagtvitemex = $tagtvitem & ";int Integral"
  61. Global Const $tagnmtreeview = $tagnmhdr & ";uint Action;uint OldMask;handle OldhItem;uint OldState;uint OldStateMask;" & "ptr OldText;int OldTextMax;int OldImage;int OldSelectedImage;int OldChildren;lparam OldParam;uint NewMask;handle NewhItem;" & "uint NewState;uint NewStateMask;ptr NewText;int NewTextMax;int NewImage;int NewSelectedImage;int NewChildren;" & "lparam NewParam;long PointX;long PointY"
  62. Global Const $tagnmtvcustomdraw = $tagnmhdr & ";dword DrawStage;handle HDC;long Left;long Top;long Right;long Bottom;" & "dword_ptr ItemSpec;uint ItemState;lparam ItemParam;dword ClrText;dword ClrTextBk;int Level"
  63. Global Const $tagnmtvdispinfo = $tagnmhdr & ";" & $tagtvitem
  64. Global Const $tagnmtvgetinfotip = $tagnmhdr & ";ptr Text;int TextMax;handle hItem;lparam lParam"
  65. Global Const $tagtvhittestinfo = $tagpoint & ";uint Flags;handle Item"
  66. Global Const $tagnmtvkeydown = $tagnmhdr & ";word VKey;uint Flags"
  67. Global Const $tagnmmouse = $tagnmhdr & ";dword_ptr ItemSpec;dword_ptr ItemData;" & $tagpoint & ";lparam HitInfo"
  68. Global Const $tagtoken_privileges = "dword Count;int64 LUID;dword Attributes"
  69. Global Const $tagimageinfo = "handle hBitmap;handle hMask;int Unused1;int Unused2;" & $tagrect
  70. Global Const $tagmenuinfo = "dword Size;INT Mask;dword Style;uint YMax;handle hBack;dword ContextHelpID;ulong_ptr MenuData"
  71. 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"
  72. 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"
  73. Global Const $tagnmrebarautobreak = $tagnmhdr & ";uint uBand;uint wID;lparam lParam;uint uMsg;uint fStyleCurrent;bool fAutoBreak"
  74. Global Const $tagnmrbautosize = $tagnmhdr & ";bool fChanged;long TargetLeft;long TargetTop;long TargetRight;long TargetBottom;" & "long ActualLeft;long ActualTop;long ActualRight;long ActualBottom"
  75. Global Const $tagnmrebar = $tagnmhdr & ";dword dwMask;uint uBand;uint fStyle;uint wID;laram lParam"
  76. Global Const $tagnmrebarchevron = $tagnmhdr & ";uint uBand;uint wID;lparam lParam;" & $tagrect & ";lparam lParamNM"
  77. Global Const $tagnmrebarchildsize = $tagnmhdr & ";uint uBand;uint wID;long CLeft;long CTop;long CRight;long CBottom;" & "long BLeft;long BTop;long BRight;long BBottom"
  78. Global Const $tagcolorscheme = "dword Size;dword BtnHighlight;dword BtnShadow"
  79. Global Const $tagnmtoolbar = $tagnmhdr & ";int iItem;" & "int iBitmap;int idCommand;byte fsState;byte fsStyle;align;dword_ptr dwData;int_ptr iString" & ";int cchText;ptr pszText;" & $tagrect
  80. Global Const $tagnmtbhotitem = $tagnmhdr & ";int idOld;int idNew;dword dwFlags"
  81. Global Const $tagtbbutton = "int Bitmap;int Command;byte State;byte Style;align;dword_ptr Param;int_ptr String"
  82. Global Const $tagtbbuttoninfo = "uint Size;dword Mask;int Command;int Image;byte State;byte Style;word CX;dword_ptr Param;ptr Text;int TextMax"
  83. Global Const $tagnetresource = "dword Scope;dword Type;dword DisplayType;dword Usage;ptr LocalName;ptr RemoteName;ptr Comment;ptr Provider"
  84. Global Const $tagoverlapped = "ulong_ptr Internal;ulong_ptr InternalHigh;dword Offset;dword OffsetHigh;handle hEvent"
  85. 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"
  86. Global Const $tagbitmapinfo = "dword Size;long Width;long Height;word Planes;word BitCount;dword Compression;dword SizeImage;" & "long XPelsPerMeter;long YPelsPerMeter;dword ClrUsed;dword ClrImportant;dword RGBQuad"
  87. Global Const $tagblendfunction = "byte Op;byte Flags;byte Alpha;byte Format"
  88. Global Const $tagguid = "dword Data1;word Data2;word Data3;byte Data4[8]"
  89. Global Const $tagwindowplacement = "uint length; uint flags;uint showCmd;long ptMinPosition[2];long ptMaxPosition[2];long rcNormalPosition[4]"
  90. Global Const $tagwindowpos = "hwnd hWnd;hwnd InsertAfter;int X;int Y;int CX;int CY;uint Flags"
  91. Global Const $tagscrollinfo = "uint cbSize;uint fMask;int nMin;int nMax;uint nPage;int nPos;int nTrackPos"
  92. Global Const $tagscrollbarinfo = "dword cbSize;" & $tagrect & ";int dxyLineButton;int xyThumbTop;" & "int xyThumbBottom;int reserved;dword rgstate[6]"
  93. Global Const $taglogfont = "long Height;long Width;long Escapement;long Orientation;long Weight;byte Italic;byte Underline;" & "byte Strikeout;byte CharSet;byte OutPrecision;byte ClipPrecision;byte Quality;byte PitchAndFamily;wchar FaceName[32]"
  94. Global Const $tagkbdllhookstruct = "dword vkCode;dword scanCode;dword flags;dword time;ulong_ptr dwExtraInfo"
  95. Global Const $tagprocess_information = "handle hProcess;handle hThread;dword ProcessID;dword ThreadID"
  96. 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"
  97. Global Const $tagsecurity_attributes = "dword Length;ptr Descriptor;bool InheritHandle"
  98. 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]"
  99. Global Const $fc_nooverwrite = 0
  100. Global Const $fc_overwrite = 1
  101. Global Const $ft_modified = 0
  102. Global Const $ft_created = 1
  103. Global Const $ft_accessed = 2
  104. Global Const $fo_read = 0
  105. Global Const $fo_append = 1
  106. Global Const $fo_overwrite = 2
  107. Global Const $fo_binary = 16
  108. Global Const $fo_unicode = 32
  109. Global Const $fo_utf16_le = 32
  110. Global Const $fo_utf16_be = 64
  111. Global Const $fo_utf8 = 128
  112. Global Const $fo_utf8_nobom = 256
  113. Global Const $eof = -1
  114. Global Const $fd_filemustexist = 1
  115. Global Const $fd_pathmustexist = 2
  116. Global Const $fd_multiselect = 4
  117. Global Const $fd_promptcreatenew = 8
  118. Global Const $fd_promptoverwrite = 16
  119. Global Const $create_new = 1
  120. Global Const $create_always = 2
  121. Global Const $open_existing = 3
  122. Global Const $open_always = 4
  123. Global Const $truncate_existing = 5
  124. Global Const $invalid_set_file_pointer = -1
  125. Global Const $file_begin = 0
  126. Global Const $file_current = 1
  127. Global Const $file_end = 2
  128. Global Const $file_attribute_readonly = 1
  129. Global Const $file_attribute_hidden = 2
  130. Global Const $file_attribute_system = 4
  131. Global Const $file_attribute_directory = 16
  132. Global Const $file_attribute_archive = 32
  133. Global Const $file_attribute_device = 64
  134. Global Const $file_attribute_normal = 128
  135. Global Const $file_attribute_temporary = 256
  136. Global Const $file_attribute_sparse_file = 512
  137. Global Const $file_attribute_reparse_point = 1024
  138. Global Const $file_attribute_compressed = 2048
  139. Global Const $file_attribute_offline = 4096
  140. Global Const $file_attribute_not_content_indexed = 8192
  141. Global Const $file_attribute_encrypted = 16384
  142. Global Const $file_share_read = 1
  143. Global Const $file_share_write = 2
  144. Global Const $file_share_delete = 4
  145. Global Const $generic_all = 268435456
  146. Global Const $generic_execute = 536870912
  147. Global Const $generic_write = 1073741824
  148. Global Const $generic_read = -2147483648
  149. Global Const $error_no_token = 1008
  150. Global Const $se_assignprimarytoken_name = "SeAssignPrimaryTokenPrivilege"
  151. Global Const $se_audit_name = "SeAuditPrivilege"
  152. Global Const $se_backup_name = "SeBackupPrivilege"
  153. Global Const $se_change_notify_name = "SeChangeNotifyPrivilege"
  154. Global Const $se_create_global_name = "SeCreateGlobalPrivilege"
  155. Global Const $se_create_pagefile_name = "SeCreatePagefilePrivilege"
  156. Global Const $se_create_permanent_name = "SeCreatePermanentPrivilege"
  157. Global Const $se_create_token_name = "SeCreateTokenPrivilege"
  158. Global Const $se_debug_name = "SeDebugPrivilege"
  159. Global Const $se_enable_delegation_name = "SeEnableDelegationPrivilege"
  160. Global Const $se_impersonate_name = "SeImpersonatePrivilege"
  161. Global Const $se_inc_base_priority_name = "SeIncreaseBasePriorityPrivilege"
  162. Global Const $se_increase_quota_name = "SeIncreaseQuotaPrivilege"
  163. Global Const $se_load_driver_name = "SeLoadDriverPrivilege"
  164. Global Const $se_lock_memory_name = "SeLockMemoryPrivilege"
  165. Global Const $se_machine_account_name = "SeMachineAccountPrivilege"
  166. Global Const $se_manage_volume_name = "SeManageVolumePrivilege"
  167. Global Const $se_prof_single_process_name = "SeProfileSingleProcessPrivilege"
  168. Global Const $se_remote_shutdown_name = "SeRemoteShutdownPrivilege"
  169. Global Const $se_restore_name = "SeRestorePrivilege"
  170. Global Const $se_security_name = "SeSecurityPrivilege"
  171. Global Const $se_shutdown_name = "SeShutdownPrivilege"
  172. Global Const $se_sync_agent_name = "SeSyncAgentPrivilege"
  173. Global Const $se_system_environment_name = "SeSystemEnvironmentPrivilege"
  174. Global Const $se_system_profile_name = "SeSystemProfilePrivilege"
  175. Global Const $se_systemtime_name = "SeSystemtimePrivilege"
  176. Global Const $se_take_ownership_name = "SeTakeOwnershipPrivilege"
  177. Global Const $se_tcb_name = "SeTcbPrivilege"
  178. Global Const $se_unsolicited_input_name = "SeUnsolicitedInputPrivilege"
  179. Global Const $se_undock_name = "SeUndockPrivilege"
  180. Global Const $se_privilege_enabled_by_default = 1
  181. Global Const $se_privilege_enabled = 2
  182. Global Const $se_privilege_removed = 4
  183. Global Const $se_privilege_used_for_access = -2147483648
  184. Global Const $tokenuser = 1
  185. Global Const $tokengroups = 2
  186. Global Const $tokenprivileges = 3
  187. Global Const $tokenowner = 4
  188. Global Const $tokenprimarygroup = 5
  189. Global Const $tokendefaultdacl = 6
  190. Global Const $tokensource = 7
  191. Global Const $tokentype = 8
  192. Global Const $tokenimpersonationlevel = 9
  193. Global Const $tokenstatistics = 10
  194. Global Const $tokenrestrictedsids = 11
  195. Global Const $tokensessionid = 12
  196. Global Const $tokengroupsandprivileges = 13
  197. Global Const $tokensessionreference = 14
  198. Global Const $tokensandboxinert = 15
  199. Global Const $tokenauditpolicy = 16
  200. Global Const $tokenorigin = 17
  201. Global Const $tokenelevationtype = 18
  202. Global Const $tokenlinkedtoken = 19
  203. Global Const $tokenelevation = 20
  204. Global Const $tokenhasrestrictions = 21
  205. Global Const $tokenaccessinformation = 22
  206. Global Const $tokenvirtualizationallowed = 23
  207. Global Const $tokenvirtualizationenabled = 24
  208. Global Const $tokenintegritylevel = 25
  209. Global Const $tokenuiaccess = 26
  210. Global Const $tokenmandatorypolicy = 27
  211. Global Const $tokenlogonsid = 28
  212. Global Const $token_assign_primary = 1
  213. Global Const $token_duplicate = 2
  214. Global Const $token_impersonate = 4
  215. Global Const $token_query = 8
  216. Global Const $token_query_source = 16
  217. Global Const $token_adjust_privileges = 32
  218. Global Const $token_adjust_groups = 64
  219. Global Const $token_adjust_default = 128
  220. Global Const $token_adjust_sessionid = 256
  221.  
  222. Func _winapi_getlasterror($curerr = @error, $curext = @extended)
  223. Local $aresult = DllCall("kernel32.dll", "dword", "GetLastError")
  224. Return SetError($curerr, $curext, $aresult[0])
  225. EndFunc
  226.  
  227. Func _winapi_setlasterror($ierrcode, $curerr = @error, $curext = @extended)
  228. DllCall("kernel32.dll", "none", "SetLastError", "dword", $ierrcode)
  229. Return SetError($curerr, $curext)
  230. EndFunc
  231.  
  232. Func _security__adjusttokenprivileges($htoken, $fdisableall, $pnewstate, $ibufferlen, $pprevstate = 0, $prequired = 0)
  233. Local $aresult = DllCall("advapi32.dll", "bool", "AdjustTokenPrivileges", "handle", $htoken, "bool", $fdisableall, "ptr", $pnewstate, "dword", $ibufferlen, "ptr", $pprevstate, "ptr", $prequired)
  234. If @error Then Return SetError(@error, @extended, False)
  235. Return $aresult[0]
  236. EndFunc
  237.  
  238. Func _security__getaccountsid($saccount, $ssystem = "")
  239. Local $aacct = _security__lookupaccountname($saccount, $ssystem)
  240. If @error Then Return SetError(@error, 0, 0)
  241. Return _security__stringsidtosid($aacct[0])
  242. EndFunc
  243.  
  244. Func _security__getlengthsid($psid)
  245. If NOT _security__isvalidsid($psid) Then Return SetError(-1, 0, 0)
  246. Local $aresult = DllCall("advapi32.dll", "dword", "GetLengthSid", "ptr", $psid)
  247. If @error Then Return SetError(@error, @extended, 0)
  248. Return $aresult[0]
  249. EndFunc
  250.  
  251. Func _security__gettokeninformation($htoken, $iclass)
  252. Local $aresult = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $htoken, "int", $iclass, "ptr", 0, "dword", 0, "dword*", 0)
  253. If @error Then Return SetError(@error, @extended, 0)
  254. If NOT $aresult[0] Then Return 0
  255. Local $tbuffer = DllStructCreate("byte[" & $aresult[5] & "]")
  256. Local $pbuffer = DllStructGetPtr($tbuffer)
  257. $aresult = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $htoken, "int", $iclass, "ptr", $pbuffer, "dword", $aresult[5], "dword*", 0)
  258. If @error Then Return SetError(@error, @extended, 0)
  259. If NOT $aresult[0] Then Return 0
  260. Return $tbuffer
  261. EndFunc
  262.  
  263. Func _security__impersonateself($ilevel = 2)
  264. Local $aresult = DllCall("advapi32.dll", "bool", "ImpersonateSelf", "int", $ilevel)
  265. If @error Then Return SetError(@error, @extended, False)
  266. Return $aresult[0]
  267. EndFunc
  268.  
  269. Func _security__isvalidsid($psid)
  270. Local $aresult = DllCall("advapi32.dll", "bool", "IsValidSid", "ptr", $psid)
  271. If @error Then Return SetError(@error, @extended, False)
  272. Return $aresult[0]
  273. EndFunc
  274.  
  275. Func _security__lookupaccountname($saccount, $ssystem = "")
  276. Local $tdata = DllStructCreate("byte SID[256]")
  277. Local $psid = DllStructGetPtr($tdata, "SID")
  278. Local $aresult = DllCall("advapi32.dll", "bool", "LookupAccountNameW", "wstr", $ssystem, "wstr", $saccount, "ptr", $psid, "dword*", 256, "wstr", "", "dword*", 256, "int*", 0)
  279. If @error Then Return SetError(@error, @extended, 0)
  280. If NOT $aresult[0] Then Return 0
  281. Local $aacct[3]
  282. $aacct[0] = _security__sidtostringsid($psid)
  283. $aacct[1] = $aresult[5]
  284. $aacct[2] = $aresult[7]
  285. Return $aacct
  286. EndFunc
  287.  
  288. Func _security__lookupaccountsid($vsid)
  289. Local $psid, $aacct[3]
  290. If IsString($vsid) Then
  291. Local $tsid = _security__stringsidtosid($vsid)
  292. $psid = DllStructGetPtr($tsid)
  293. Else
  294. $psid = $vsid
  295. EndIf
  296. If NOT _security__isvalidsid($psid) Then Return SetError(-1, 0, 0)
  297. Local $aresult = DllCall("advapi32.dll", "bool", "LookupAccountSidW", "ptr", 0, "ptr", $psid, "wstr", "", "dword*", 256, "wstr", "", "dword*", 256, "int*", 0)
  298. If @error Then Return SetError(@error, @extended, 0)
  299. If NOT $aresult[0] Then Return 0
  300. Local $aacct[3]
  301. $aacct[0] = $aresult[3]
  302. $aacct[1] = $aresult[5]
  303. $aacct[2] = $aresult[7]
  304. Return $aacct
  305. EndFunc
  306.  
  307. Func _security__lookupprivilegevalue($ssystem, $sname)
  308. Local $aresult = DllCall("advapi32.dll", "int", "LookupPrivilegeValueW", "wstr", $ssystem, "wstr", $sname, "int64*", 0)
  309. If @error Then Return SetError(@error, @extended, 0)
  310. Return SetError(0, $aresult[0], $aresult[3])
  311. EndFunc
  312.  
  313. Func _security__openprocesstoken($hprocess, $iaccess)
  314. Local $aresult = DllCall("advapi32.dll", "int", "OpenProcessToken", "handle", $hprocess, "dword", $iaccess, "ptr", 0)
  315. If @error Then Return SetError(@error, @extended, 0)
  316. Return SetError(0, $aresult[0], $aresult[3])
  317. EndFunc
  318.  
  319. Func _security__openthreadtoken($iaccess, $hthread = 0, $fopenasself = False)
  320. If $hthread = 0 Then $hthread = DllCall("kernel32.dll", "handle", "GetCurrentThread")
  321. If @error Then Return SetError(@error, @extended, 0)
  322. Local $aresult = DllCall("advapi32.dll", "bool", "OpenThreadToken", "handle", $hthread[0], "dword", $iaccess, "int", $fopenasself, "ptr*", 0)
  323. If @error Then Return SetError(@error, @extended, 0)
  324. Return SetError(0, $aresult[0], $aresult[4])
  325. EndFunc
  326.  
  327. Func _security__openthreadtokenex($iaccess, $hthread = 0, $fopenasself = False)
  328. Local $htoken = _security__openthreadtoken($iaccess, $hthread, $fopenasself)
  329. If $htoken = 0 Then
  330. If _winapi_getlasterror() <> $error_no_token Then Return SetError(-3, _winapi_getlasterror(), 0)
  331. If NOT _security__impersonateself() Then Return SetError(-1, _winapi_getlasterror(), 0)
  332. $htoken = _security__openthreadtoken($iaccess, $hthread, $fopenasself)
  333. If $htoken = 0 Then Return SetError(-2, _winapi_getlasterror(), 0)
  334. EndIf
  335. Return $htoken
  336. EndFunc
  337.  
  338. Func _security__setprivilege($htoken, $sprivilege, $fenable)
  339. Local $iluid = _security__lookupprivilegevalue("", $sprivilege)
  340. If $iluid = 0 Then Return SetError(-1, 0, False)
  341. Local $tcurrstate = DllStructCreate($tagtoken_privileges)
  342. Local $pcurrstate = DllStructGetPtr($tcurrstate)
  343. Local $icurrstate = DllStructGetSize($tcurrstate)
  344. Local $tprevstate = DllStructCreate($tagtoken_privileges)
  345. Local $pprevstate = DllStructGetPtr($tprevstate)
  346. Local $iprevstate = DllStructGetSize($tprevstate)
  347. Local $trequired = DllStructCreate("int Data")
  348. Local $prequired = DllStructGetPtr($trequired)
  349. DllStructSetData($tcurrstate, "Count", 1)
  350. DllStructSetData($tcurrstate, "LUID", $iluid)
  351. If NOT _security__adjusttokenprivileges($htoken, False, $pcurrstate, $icurrstate, $pprevstate, $prequired) Then Return SetError(-2, @error, False)
  352. DllStructSetData($tprevstate, "Count", 1)
  353. DllStructSetData($tprevstate, "LUID", $iluid)
  354. Local $iattributes = DllStructGetData($tprevstate, "Attributes")
  355. If $fenable Then
  356. $iattributes = BitOR($iattributes, $se_privilege_enabled)
  357. Else
  358. $iattributes = BitAND($iattributes, BitNOT($se_privilege_enabled))
  359. EndIf
  360. DllStructSetData($tprevstate, "Attributes", $iattributes)
  361. If NOT _security__adjusttokenprivileges($htoken, False, $pprevstate, $iprevstate, $pcurrstate, $prequired) Then Return SetError(-3, @error, False)
  362. Return True
  363. EndFunc
  364.  
  365. Func _security__sidtostringsid($psid)
  366. If NOT _security__isvalidsid($psid) Then Return SetError(-1, 0, "")
  367. Local $aresult = DllCall("advapi32.dll", "int", "ConvertSidToStringSidW", "ptr", $psid, "ptr*", 0)
  368. If @error Then Return SetError(@error, @extended, "")
  369. If NOT $aresult[0] Then Return ""
  370. Local $tbuffer = DllStructCreate("wchar Text[256]", $aresult[2])
  371. Local $ssid = DllStructGetData($tbuffer, "Text")
  372. DllCall("Kernel32.dll", "ptr", "LocalFree", "ptr", $aresult[2])
  373. Return $ssid
  374. EndFunc
  375.  
  376. Func _security__sidtypestr($itype)
  377. Switch $itype
  378. Case 1
  379. Return "User"
  380. Case 2
  381. Return "Group"
  382. Case 3
  383. Return "Domain"
  384. Case 4
  385. Return "Alias"
  386. Case 5
  387. Return "Well Known Group"
  388. Case 6
  389. Return "Deleted Account"
  390. Case 7
  391. Return "Invalid"
  392. Case 8
  393. Return "Invalid"
  394. Case 9
  395. Return "Computer"
  396. Case Else
  397. Return "Unknown SID Type"
  398. EndSwitch
  399. EndFunc
  400.  
  401. Func _security__stringsidtosid($ssid)
  402. Local $aresult = DllCall("advapi32.dll", "bool", "ConvertStringSidToSidW", "wstr", $ssid, "ptr*", 0)
  403. If @error Then Return SetError(@error, @extended, 0)
  404. If NOT $aresult[0] Then Return 0
  405. Local $isize = _security__getlengthsid($aresult[2])
  406. Local $tbuffer = DllStructCreate("byte Data[" & $isize & "]", $aresult[2])
  407. Local $tsid = DllStructCreate("byte Data[" & $isize & "]")
  408. DllStructSetData($tsid, "Data", DllStructGetData($tbuffer, "Data"))
  409. DllCall("kernel32.dll", "ptr", "LocalFree", "ptr", $aresult[2])
  410. Return $tsid
  411. EndFunc
  412.  
  413. Func _sendmessage($hwnd, $imsg, $wparam = 0, $lparam = 0, $ireturn = 0, $wparamtype = "wparam", $lparamtype = "lparam", $sreturntype = "lresult")
  414. Local $aresult = DllCall("user32.dll", $sreturntype, "SendMessageW", "hwnd", $hwnd, "uint", $imsg, $wparamtype, $wparam, $lparamtype, $lparam)
  415. If @error Then Return SetError(@error, @extended, "")
  416. If $ireturn >= 0 AND $ireturn <= 4 Then Return $aresult[$ireturn]
  417. Return $aresult
  418. EndFunc
  419.  
  420. Func _sendmessagea($hwnd, $imsg, $wparam = 0, $lparam = 0, $ireturn = 0, $wparamtype = "wparam", $lparamtype = "lparam", $sreturntype = "lresult")
  421. Local $aresult = DllCall("user32.dll", $sreturntype, "SendMessageA", "hwnd", $hwnd, "uint", $imsg, $wparamtype, $wparam, $lparamtype, $lparam)
  422. If @error Then Return SetError(@error, @extended, "")
  423. If $ireturn >= 0 AND $ireturn <= 4 Then Return $aresult[$ireturn]
  424. Return $aresult
  425. EndFunc
  426.  
  427. Global $__gainprocess_winapi[64][2] = [[0, 0]]
  428. Global $__gawinlist_winapi[64][2] = [[0, 0]]
  429. Global Const $__winapiconstant_wm_setfont = 48
  430. Global Const $__winapiconstant_fw_normal = 400
  431. Global Const $__winapiconstant_default_charset = 1
  432. Global Const $__winapiconstant_out_default_precis = 0
  433. Global Const $__winapiconstant_clip_default_precis = 0
  434. Global Const $__winapiconstant_default_quality = 0
  435. Global Const $__winapiconstant_format_message_allocate_buffer = 256
  436. Global Const $__winapiconstant_format_message_from_system = 4096
  437. Global Const $__winapiconstant_logpixelsx = 88
  438. Global Const $__winapiconstant_logpixelsy = 90
  439. Global Const $hgdi_error = Ptr(-1)
  440. Global Const $invalid_handle_value = Ptr(-1)
  441. Global Const $clr_invalid = -1
  442. Global Const $__winapiconstant_flashw_caption = 1
  443. Global Const $__winapiconstant_flashw_tray = 2
  444. Global Const $__winapiconstant_flashw_timer = 4
  445. Global Const $__winapiconstant_flashw_timernofg = 12
  446. Global Const $__winapiconstant_gw_hwndnext = 2
  447. Global Const $__winapiconstant_gw_child = 5
  448. Global Const $__winapiconstant_di_mask = 1
  449. Global Const $__winapiconstant_di_image = 2
  450. Global Const $__winapiconstant_di_normal = 3
  451. Global Const $__winapiconstant_di_compat = 4
  452. Global Const $__winapiconstant_di_defaultsize = 8
  453. Global Const $__winapiconstant_di_nomirror = 16
  454. Global Const $__winapiconstant_display_device_attached_to_desktop = 1
  455. Global Const $__winapiconstant_display_device_primary_device = 4
  456. Global Const $__winapiconstant_display_device_mirroring_driver = 8
  457. Global Const $__winapiconstant_display_device_vga_compatible = 16
  458. Global Const $__winapiconstant_display_device_removable = 32
  459. Global Const $__winapiconstant_display_device_modespruned = 134217728
  460. Global Const $null_brush = 5
  461. Global Const $null_pen = 8
  462. Global Const $black_brush = 4
  463. Global Const $dkgray_brush = 3
  464. Global Const $dc_brush = 18
  465. Global Const $gray_brush = 2
  466. Global Const $hollow_brush = $null_brush
  467. Global Const $ltgray_brush = 1
  468. Global Const $white_brush = 0
  469. Global Const $black_pen = 7
  470. Global Const $dc_pen = 19
  471. Global Const $white_pen = 6
  472. Global Const $ansi_fixed_font = 11
  473. Global Const $ansi_var_font = 12
  474. Global Const $device_default_font = 14
  475. Global Const $default_gui_font = 17
  476. Global Const $oem_fixed_font = 10
  477. Global Const $system_font = 13
  478. Global Const $system_fixed_font = 16
  479. Global Const $default_palette = 15
  480. Global Const $mb_precomposed = 1
  481. Global Const $mb_composite = 2
  482. Global Const $mb_useglyphchars = 4
  483. Global Const $ulw_alpha = 2
  484. Global Const $ulw_colorkey = 1
  485. Global Const $ulw_opaque = 4
  486. Global Const $wh_callwndproc = 4
  487. Global Const $wh_callwndprocret = 12
  488. Global Const $wh_cbt = 5
  489. Global Const $wh_debug = 9
  490. Global Const $wh_foregroundidle = 11
  491. Global Const $wh_getmessage = 3
  492. Global Const $wh_journalplayback = 1
  493. Global Const $wh_journalrecord = 0
  494. Global Const $wh_keyboard = 2
  495. Global Const $wh_keyboard_ll = 13
  496. Global Const $wh_mouse = 7
  497. Global Const $wh_mouse_ll = 14
  498. Global Const $wh_msgfilter = -1
  499. Global Const $wh_shell = 10
  500. Global Const $wh_sysmsgfilter = 6
  501. Global Const $wpf_asyncwindowplacement = 4
  502. Global Const $wpf_restoretomaximized = 2
  503. Global Const $wpf_setminposition = 1
  504. Global Const $kf_extended = 256
  505. Global Const $kf_altdown = 8192
  506. Global Const $kf_up = 32768
  507. Global Const $llkhf_extended = BitShift($kf_extended, 8)
  508. Global Const $llkhf_injected = 16
  509. Global Const $llkhf_altdown = BitShift($kf_altdown, 8)
  510. Global Const $llkhf_up = BitShift($kf_up, 8)
  511. Global Const $ofn_allowmultiselect = 512
  512. Global Const $ofn_createprompt = 8192
  513. Global Const $ofn_dontaddtorecent = 33554432
  514. Global Const $ofn_enablehook = 32
  515. Global Const $ofn_enableincludenotify = 4194304
  516. Global Const $ofn_enablesizing = 8388608
  517. Global Const $ofn_enabletemplate = 64
  518. Global Const $ofn_enabletemplatehandle = 128
  519. Global Const $ofn_explorer = 524288
  520. Global Const $ofn_extensiondifferent = 1024
  521. Global Const $ofn_filemustexist = 4096
  522. Global Const $ofn_forceshowhidden = 268435456
  523. Global Const $ofn_hidereadonly = 4
  524. Global Const $ofn_longnames = 2097152
  525. Global Const $ofn_nochangedir = 8
  526. Global Const $ofn_nodereferencelinks = 1048576
  527. Global Const $ofn_nolongnames = 262144
  528. Global Const $ofn_nonetworkbutton = 131072
  529. Global Const $ofn_noreadonlyreturn = 32768
  530. Global Const $ofn_notestfilecreate = 65536
  531. Global Const $ofn_novalidate = 256
  532. Global Const $ofn_overwriteprompt = 2
  533. Global Const $ofn_pathmustexist = 2048
  534. Global Const $ofn_readonly = 1
  535. Global Const $ofn_shareaware = 16384
  536. Global Const $ofn_showhelp = 16
  537. Global Const $ofn_ex_noplacesbar = 1
  538. Global Const $tagcursorinfo = "dword Size;dword Flags;handle hCursor;" & $tagpoint
  539. Global Const $tagdisplay_device = "dword Size;wchar Name[32];wchar String[128];dword Flags;wchar ID[128];wchar Key[128]"
  540. Global Const $tagflashwinfo = "uint Size;hwnd hWnd;dword Flags;uint Count;dword TimeOut"
  541. Global Const $tagiconinfo = "bool Icon;dword XHotSpot;dword YHotSpot;handle hMask;handle hColor"
  542. Global Const $tagmemorystatusex = "dword Length;dword MemoryLoad;" & "uint64 TotalPhys;uint64 AvailPhys;uint64 TotalPageFile;uint64 AvailPageFile;" & "uint64 TotalVirtual;uint64 AvailVirtual;uint64 AvailExtendedVirtual"
  543.  
  544. Func _winapi_attachconsole($iprocessid = -1)
  545. Local $aresult = DllCall("kernel32.dll", "bool", "AttachConsole", "dword", $iprocessid)
  546. If @error Then Return SetError(@error, @extended, False)
  547. Return $aresult[0]
  548. EndFunc
  549.  
  550. Func _winapi_attachthreadinput($iattach, $iattachto, $fattach)
  551. Local $aresult = DllCall("user32.dll", "bool", "AttachThreadInput", "dword", $iattach, "dword", $iattachto, "bool", $fattach)
  552. If @error Then Return SetError(@error, @extended, False)
  553. Return $aresult[0]
  554. EndFunc
  555.  
  556. Func _winapi_beep($ifreq = 500, $iduration = 1000)
  557. Local $aresult = DllCall("kernel32.dll", "bool", "Beep", "dword", $ifreq, "dword", $iduration)
  558. If @error Then Return SetError(@error, @extended, False)
  559. Return $aresult[0]
  560. EndFunc
  561.  
  562. Func _winapi_bitblt($hdestdc, $ixdest, $iydest, $iwidth, $iheight, $hsrcdc, $ixsrc, $iysrc, $irop)
  563. 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)
  564. If @error Then Return SetError(@error, @extended, False)
  565. Return $aresult[0]
  566. EndFunc
  567.  
  568. Func _winapi_callnexthookex($hhk, $icode, $wparam, $lparam)
  569. Local $aresult = DllCall("user32.dll", "lresult", "CallNextHookEx", "handle", $hhk, "int", $icode, "wparam", $wparam, "lparam", $lparam)
  570. If @error Then Return SetError(@error, @extended, -1)
  571. Return $aresult[0]
  572. EndFunc
  573.  
  574. Func _winapi_callwindowproc($lpprevwndfunc, $hwnd, $msg, $wparam, $lparam)
  575. Local $aresult = DllCall("user32.dll", "lresult", "CallWindowProc", "ptr", $lpprevwndfunc, "hwnd", $hwnd, "uint", $msg, "wparam", $wparam, "lparam", $lparam)
  576. If @error Then Return SetError(@error, @extended, -1)
  577. Return $aresult[0]
  578. EndFunc
  579.  
  580. Func _winapi_clienttoscreen($hwnd, ByRef $tpoint)
  581. Local $ppoint = DllStructGetPtr($tpoint)
  582. DllCall("user32.dll", "bool", "ClientToScreen", "hwnd", $hwnd, "ptr", $ppoint)
  583. Return SetError(@error, @extended, $tpoint)
  584. EndFunc
  585.  
  586. Func _winapi_closehandle($hobject)
  587. Local $aresult = DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hobject)
  588. If @error Then Return SetError(@error, @extended, False)
  589. Return $aresult[0]
  590. EndFunc
  591.  
  592. Func _winapi_combinergn($hrgndest, $hrgnsrc1, $hrgnsrc2, $icombinemode)
  593. Local $aresult = DllCall("gdi32.dll", "int", "CombineRgn", "handle", $hrgndest, "handle", $hrgnsrc1, "handle", $hrgnsrc2, "int", $icombinemode)
  594. If @error Then Return SetError(@error, @extended, 0)
  595. Return $aresult[0]
  596. EndFunc
  597.  
  598. Func _winapi_commdlgextendederror()
  599. Local Const $cderr_dialogfailure = 65535
  600. Local Const $cderr_findresfailure = 6
  601. Local Const $cderr_initialization = 2
  602. Local Const $cderr_loadresfailure = 7
  603. Local Const $cderr_loadstrfailure = 5
  604. Local Const $cderr_lockresfailure = 8
  605. Local Const $cderr_memallocfailure = 9
  606. Local Const $cderr_memlockfailure = 10
  607. Local Const $cderr_nohinstance = 4
  608. Local Const $cderr_nohook = 11
  609. Local Const $cderr_notemplate = 3
  610. Local Const $cderr_registermsgfail = 12
  611. Local Const $cderr_structsize = 1
  612. Local Const $fnerr_buffertoosmall = 12291
  613. Local Const $fnerr_invalidfilename = 12290
  614. Local Const $fnerr_subclassfailure = 12289
  615. Local $aresult = DllCall("comdlg32.dll", "dword", "CommDlgExtendedError")
  616. If @error Then Return SetError(@error, @extended, 0)
  617. Switch $aresult[0]
  618. Case $cderr_dialogfailure
  619. 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.")
  620. Case $cderr_findresfailure
  621. Return SetError($aresult[0], 0, "The common dialog box function failed to find a specified resource.")
  622. Case $cderr_initialization
  623. Return SetError($aresult[0], 0, "The common dialog box function failed during initialization." & @LF & "This error often occurs when sufficient memory is not available.")
  624. Case $cderr_loadresfailure
  625. Return SetError($aresult[0], 0, "The common dialog box function failed to load a specified resource.")
  626. Case $cderr_loadstrfailure
  627. Return SetError($aresult[0], 0, "The common dialog box function failed to load a specified string.")
  628. Case $cderr_lockresfailure
  629. Return SetError($aresult[0], 0, "The common dialog box function failed to lock a specified resource.")
  630. Case $cderr_memallocfailure
  631. Return SetError($aresult[0], 0, "The common dialog box function was unable to allocate memory for internal structures.")
  632. Case $cderr_memlockfailure
  633. Return SetError($aresult[0], 0, "The common dialog box function was unable to lock the memory associated with a handle.")
  634. Case $cderr_nohinstance
  635. 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.")
  636. Case $cderr_nohook
  637. 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.")
  638. Case $cderr_notemplate
  639. 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.")
  640. Case $cderr_registermsgfail
  641. Return SetError($aresult[0], 0, "The RegisterWindowMessage function returned an error code when it was called by the common dialog box function.")
  642. Case $cderr_structsize
  643. Return SetError($aresult[0], 0, "The lStructSize member of the initialization structure for the corresponding common dialog box is invalid")
  644. Case $fnerr_buffertoosmall
  645. 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.")
  646. Case $fnerr_invalidfilename
  647. Return SetError($aresult[0], 0, "A file name is invalid.")
  648. Case $fnerr_subclassfailure
  649. Return SetError($aresult[0], 0, "An attempt to subclass a list box failed because sufficient memory was not available.")
  650. EndSwitch
  651. Return Hex($aresult[0])
  652. EndFunc
  653.  
  654. Func _winapi_copyicon($hicon)
  655. Local $aresult = DllCall("user32.dll", "handle", "CopyIcon", "handle", $hicon)
  656. If @error Then Return SetError(@error, @extended, 0)
  657. Return $aresult[0]
  658. EndFunc
  659.  
  660. Func _winapi_createbitmap($iwidth, $iheight, $iplanes = 1, $ibitsperpel = 1, $pbits = 0)
  661. Local $aresult = DllCall("gdi32.dll", "handle", "CreateBitmap", "int", $iwidth, "int", $iheight, "uint", $iplanes, "uint", $ibitsperpel, "ptr", $pbits)
  662. If @error Then Return SetError(@error, @extended, 0)
  663. Return $aresult[0]
  664. EndFunc
  665.  
  666. Func _winapi_createcompatiblebitmap($hdc, $iwidth, $iheight)
  667. Local $aresult = DllCall("gdi32.dll", "handle", "CreateCompatibleBitmap", "handle", $hdc, "int", $iwidth, "int", $iheight)
  668. If @error Then Return SetError(@error, @extended, 0)
  669. Return $aresult[0]
  670. EndFunc
  671.  
  672. Func _winapi_createcompatibledc($hdc)
  673. Local $aresult = DllCall("gdi32.dll", "handle", "CreateCompatibleDC", "handle", $hdc)
  674. If @error Then Return SetError(@error, @extended, 0)
  675. Return $aresult[0]
  676. EndFunc
  677.  
  678. Func _winapi_createevent($pattributes = 0, $fmanualreset = True, $finitialstate = True, $sname = "")
  679. Local $snametype = "wstr"
  680. If $sname = "" Then
  681. $sname = 0
  682. $snametype = "ptr"
  683. EndIf
  684. Local $aresult = DllCall("kernel32.dll", "handle", "CreateEventW", "ptr", $pattributes, "bool", $fmanualreset, "bool", $finitialstate, $snametype, $sname)
  685. If @error Then Return SetError(@error, @extended, 0)
  686. Return $aresult[0]
  687. EndFunc
  688.  
  689. Func _winapi_createfile($sfilename, $icreation, $iaccess = 4, $ishare = 0, $iattributes = 0, $psecurity = 0)
  690. Local $ida = 0, $ism = 0, $icd = 0, $ifa = 0
  691. If BitAND($iaccess, 1) <> 0 Then $ida = BitOR($ida, $generic_execute)
  692. If BitAND($iaccess, 2) <> 0 Then $ida = BitOR($ida, $generic_read)
  693. If BitAND($iaccess, 4) <> 0 Then $ida = BitOR($ida, $generic_write)
  694. If BitAND($ishare, 1) <> 0 Then $ism = BitOR($ism, $file_share_delete)
  695. If BitAND($ishare, 2) <> 0 Then $ism = BitOR($ism, $file_share_read)
  696. If BitAND($ishare, 4) <> 0 Then $ism = BitOR($ism, $file_share_write)
  697. Switch $icreation
  698. Case 0
  699. $icd = $create_new
  700. Case 1
  701. $icd = $create_always
  702. Case 2
  703. $icd = $open_existing
  704. Case 3
  705. $icd = $open_always
  706. Case 4
  707. $icd = $truncate_existing
  708. EndSwitch
  709. If BitAND($iattributes, 1) <> 0 Then $ifa = BitOR($ifa, $file_attribute_archive)
  710. If BitAND($iattributes, 2) <> 0 Then $ifa = BitOR($ifa, $file_attribute_hidden)
  711. If BitAND($iattributes, 4) <> 0 Then $ifa = BitOR($ifa, $file_attribute_readonly)
  712. If BitAND($iattributes, 8) <> 0 Then $ifa = BitOR($ifa, $file_attribute_system)
  713. Local $aresult = DllCall("kernel32.dll", "handle", "CreateFileW", "wstr", $sfilename, "dword", $ida, "dword", $ism, "ptr", $psecurity, "dword", $icd, "dword", $ifa, "ptr", 0)
  714. If @error OR $aresult[0] = Ptr(-1) Then Return SetError(@error, @extended, 0)
  715. Return $aresult[0]
  716. EndFunc
  717.  
  718. 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")
  719. 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)
  720. If @error Then Return SetError(@error, @extended, 0)
  721. Return $aresult[0]
  722. EndFunc
  723.  
  724. Func _winapi_createfontindirect($tlogfont)
  725. Local $aresult = DllCall("gdi32.dll", "handle", "CreateFontIndirectW", "ptr", DllStructGetPtr($tlogfont))
  726. If @error Then Return SetError(@error, @extended, 0)
  727. Return $aresult[0]
  728. EndFunc
  729.  
  730. Func _winapi_createpen($ipenstyle, $iwidth, $ncolor)
  731. Local $aresult = DllCall("gdi32.dll", "handle", "CreatePen", "int", $ipenstyle, "int", $iwidth, "dword", $ncolor)
  732. If @error Then Return SetError(@error, @extended, 0)
  733. Return $aresult[0]
  734. EndFunc
  735.  
  736. Func _winapi_createprocess($sappname, $scommand, $psecurity, $pthread, $finherit, $iflags, $penviron, $sdir, $pstartupinfo, $pprocess)
  737. Local $pcommand = 0
  738. Local $sappnametype = "wstr", $sdirtype = "wstr"
  739. If $sappname = "" Then
  740. $sappnametype = "ptr"
  741. $sappname = 0
  742. EndIf
  743. If $scommand <> "" Then
  744. Local $tcommand = DllStructCreate("wchar Text[" & 260 + 1 & "]")
  745. $pcommand = DllStructGetPtr($tcommand)
  746. DllStructSetData($tcommand, "Text", $scommand)
  747. EndIf
  748. If $sdir = "" Then
  749. $sdirtype = "ptr"
  750. $sdir = 0
  751. EndIf
  752. Local $aresult = DllCall("kernel32.dll", "bool", "CreateProcessW", $sappnametype, $sappname, "ptr", $pcommand, "ptr", $psecurity, "ptr", $pthread, "bool", $finherit, "dword", $iflags, "ptr", $penviron, $sdirtype, $sdir, "ptr", $pstartupinfo, "ptr", $pprocess)
  753. If @error Then Return SetError(@error, @extended, False)
  754. Return $aresult[0]
  755. EndFunc
  756.  
  757. Func _winapi_createrectrgn($ileftrect, $itoprect, $irightrect, $ibottomrect)
  758. Local $aresult = DllCall("gdi32.dll", "handle", "CreateRectRgn", "int", $ileftrect, "int", $itoprect, "int", $irightrect, "int", $ibottomrect)
  759. If @error Then Return SetError(@error, @extended, 0)
  760. Return $aresult[0]
  761. EndFunc
  762.  
  763. Func _winapi_createroundrectrgn($ileftrect, $itoprect, $irightrect, $ibottomrect, $iwidthellipse, $iheightellipse)
  764. Local $aresult = DllCall("gdi32.dll", "handle", "CreateRoundRectRgn", "int", $ileftrect, "int", $itoprect, "int", $irightrect, "int", $ibottomrect, "int", $iwidthellipse, "int", $iheightellipse)
  765. If @error Then Return SetError(@error, @extended, 0)
  766. Return $aresult[0]
  767. EndFunc
  768.  
  769. Func _winapi_createsolidbitmap($hwnd, $icolor, $iwidth, $iheight, $brgb = 1)
  770. Local $hdc = _winapi_getdc($hwnd)
  771. Local $hdestdc = _winapi_createcompatibledc($hdc)
  772. Local $hbitmap = _winapi_createcompatiblebitmap($hdc, $iwidth, $iheight)
  773. Local $hold = _winapi_selectobject($hdestdc, $hbitmap)
  774. Local $trect = DllStructCreate($tagrect)
  775. DllStructSetData($trect, 1, 0)
  776. DllStructSetData($trect, 2, 0)
  777. DllStructSetData($trect, 3, $iwidth)
  778. DllStructSetData($trect, 4, $iheight)
  779. If $brgb Then
  780. $icolor = BitOR(BitAND($icolor, 65280), BitShift(BitAND($icolor, 255), -16), BitShift(BitAND($icolor, 16711680), 16))
  781. EndIf
  782. Local $hbrush = _winapi_createsolidbrush($icolor)
  783. _winapi_fillrect($hdestdc, DllStructGetPtr($trect), $hbrush)
  784. If @error Then
  785. _winapi_deleteobject($hbitmap)
  786. $hbitmap = 0
  787. EndIf
  788. _winapi_deleteobject($hbrush)
  789. _winapi_releasedc($hwnd, $hdc)
  790. _winapi_selectobject($hdestdc, $hold)
  791. _winapi_deletedc($hdestdc)
  792. If NOT $hbitmap Then Return SetError(1, 0, 0)
  793. Return $hbitmap
  794. EndFunc
  795.  
  796. Func _winapi_createsolidbrush($ncolor)
  797. Local $aresult = DllCall("gdi32.dll", "handle", "CreateSolidBrush", "dword", $ncolor)
  798. If @error Then Return SetError(@error, @extended, 0)
  799. Return $aresult[0]
  800. EndFunc
  801.  
  802. Func _winapi_createwindowex($iexstyle, $sclass, $sname, $istyle, $ix, $iy, $iwidth, $iheight, $hparent, $hmenu = 0, $hinstance = 0, $pparam = 0)
  803. If $hinstance = 0 Then $hinstance = _winapi_getmodulehandle("")
  804. 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)
  805. If @error Then Return SetError(@error, @extended, 0)
  806. Return $aresult[0]
  807. EndFunc
  808.  
  809. Func _winapi_defwindowproc($hwnd, $imsg, $iwparam, $ilparam)
  810. Local $aresult = DllCall("user32.dll", "lresult", "DefWindowProc", "hwnd", $hwnd, "uint", $imsg, "wparam", $iwparam, "lparam", $ilparam)
  811. If @error Then Return SetError(@error, @extended, 0)
  812. Return $aresult[0]
  813. EndFunc
  814.  
  815. Func _winapi_deletedc($hdc)
  816. Local $aresult = DllCall("gdi32.dll", "bool", "DeleteDC", "handle", $hdc)
  817. If @error Then Return SetError(@error, @extended, False)
  818. Return $aresult[0]
  819. EndFunc
  820.  
  821. Func _winapi_deleteobject($hobject)
  822. Local $aresult = DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hobject)
  823. If @error Then Return SetError(@error, @extended, False)
  824. Return $aresult[0]
  825. EndFunc
  826.  
  827. Func _winapi_destroyicon($hicon)
  828. Local $aresult = DllCall("user32.dll", "bool", "DestroyIcon", "handle", $hicon)
  829. If @error Then Return SetError(@error, @extended, False)
  830. Return $aresult[0]
  831. EndFunc
  832.  
  833. Func _winapi_destroywindow($hwnd)
  834. Local $aresult = DllCall("user32.dll", "bool", "DestroyWindow", "hwnd", $hwnd)
  835. If @error Then Return SetError(@error, @extended, False)
  836. Return $aresult[0]
  837. EndFunc
  838.  
  839. Func _winapi_drawedge($hdc, $ptrrect, $nedgetype, $grfflags)
  840. Local $aresult = DllCall("user32.dll", "bool", "DrawEdge", "handle", $hdc, "ptr", $ptrrect, "uint", $nedgetype, "uint", $grfflags)
  841. If @error Then Return SetError(@error, @extended, False)
  842. Return $aresult[0]
  843. EndFunc
  844.  
  845. Func _winapi_drawframecontrol($hdc, $ptrrect, $ntype, $nstate)
  846. Local $aresult = DllCall("user32.dll", "bool", "DrawFrameControl", "handle", $hdc, "ptr", $ptrrect, "uint", $ntype, "uint", $nstate)
  847. If @error Then Return SetError(@error, @extended, False)
  848. Return $aresult[0]
  849. EndFunc
  850.  
  851. Func _winapi_drawicon($hdc, $ix, $iy, $hicon)
  852. Local $aresult = DllCall("user32.dll", "bool", "DrawIcon", "handle", $hdc, "int", $ix, "int", $iy, "handle", $hicon)
  853. If @error Then Return SetError(@error, @extended, False)
  854. Return $aresult[0]
  855. EndFunc
  856.  
  857. Func _winapi_drawiconex($hdc, $ix, $iy, $hicon, $iwidth = 0, $iheight = 0, $istep = 0, $hbrush = 0, $iflags = 3)
  858. Local $ioptions
  859. Switch $iflags
  860. Case 1
  861. $ioptions = $__winapiconstant_di_mask
  862. Case 2
  863. $ioptions = $__winapiconstant_di_image
  864. Case 3
  865. $ioptions = $__winapiconstant_di_normal
  866. Case 4
  867. $ioptions = $__winapiconstant_di_compat
  868. Case 5
  869. $ioptions = $__winapiconstant_di_defaultsize
  870. Case Else
  871. $ioptions = $__winapiconstant_di_nomirror
  872. EndSwitch
  873. 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)
  874. If @error Then Return SetError(@error, @extended, False)
  875. Return $aresult[0]
  876. EndFunc
  877.  
  878. Func _winapi_drawline($hdc, $ix1, $iy1, $ix2, $iy2)
  879. _winapi_moveto($hdc, $ix1, $iy1)
  880. If @error Then Return SetError(@error, @extended, False)
  881. _winapi_lineto($hdc, $ix2, $iy2)
  882. If @error Then Return SetError(@error, @extended, False)
  883. Return True
  884. EndFunc
  885.  
  886. Func _winapi_drawtext($hdc, $stext, ByRef $trect, $iflags)
  887. Local $aresult = DllCall("user32.dll", "int", "DrawTextW", "handle", $hdc, "wstr", $stext, "int", -1, "ptr", DllStructGetPtr($trect), "uint", $iflags)
  888. If @error Then Return SetError(@error, @extended, 0)
  889. Return $aresult[0]
  890. EndFunc
  891.  
  892. Func _winapi_enablewindow($hwnd, $fenable = True)
  893. Local $aresult = DllCall("user32.dll", "bool", "EnableWindow", "hwnd", $hwnd, "bool", $fenable)
  894. If @error Then Return SetError(@error, @extended, False)
  895. Return $aresult[0]
  896. EndFunc
  897.  
  898. Func _winapi_enumdisplaydevices($sdevice, $idevnum)
  899. Local $pname = 0, $iflags = 0, $adevice[5]
  900. If $sdevice <> "" Then
  901. Local $tname = DllStructCreate("wchar Text[" & StringLen($sdevice) + 1 & "]")
  902. $pname = DllStructGetPtr($tname)
  903. DllStructSetData($tname, "Text", $sdevice)
  904. EndIf
  905. Local $tdevice = DllStructCreate($tagdisplay_device)
  906. Local $pdevice = DllStructGetPtr($tdevice)
  907. Local $idevice = DllStructGetSize($tdevice)
  908. DllStructSetData($tdevice, "Size", $idevice)
  909. DllCall("user32.dll", "bool", "EnumDisplayDevicesW", "ptr", $pname, "dword", $idevnum, "ptr", $pdevice, "dword", 1)
  910. If @error Then Return SetError(@error, @extended, 0)
  911. Local $in = DllStructGetData($tdevice, "Flags")
  912. If BitAND($in, $__winapiconstant_display_device_attached_to_desktop) <> 0 Then $iflags = BitOR($iflags, 1)
  913. If BitAND($in, $__winapiconstant_display_device_primary_device) <> 0 Then $iflags = BitOR($iflags, 2)
  914. If BitAND($in, $__winapiconstant_display_device_mirroring_driver) <> 0 Then $iflags = BitOR($iflags, 4)
  915. If BitAND($in, $__winapiconstant_display_device_vga_compatible) <> 0 Then $iflags = BitOR($iflags, 8)
  916. If BitAND($in, $__winapiconstant_display_device_removable) <> 0 Then $iflags = BitOR($iflags, 16)
  917. If BitAND($in, $__winapiconstant_display_device_modespruned) <> 0 Then $iflags = BitOR($iflags, 32)
  918. $adevice[0] = True
  919. $adevice[1] = DllStructGetData($tdevice, "Name")
  920. $adevice[2] = DllStructGetData($tdevice, "String")
  921. $adevice[3] = $iflags
  922. $adevice[4] = DllStructGetData($tdevice, "ID")
  923. Return $adevice
  924. EndFunc
  925.  
  926. Func _winapi_enumwindows($fvisible = True, $hwnd = Default)
  927. __winapi_enumwindowsinit()
  928. If $hwnd = Default Then $hwnd = _winapi_getdesktopwindow()
  929. __winapi_enumwindowschild($hwnd, $fvisible)
  930. Return $__gawinlist_winapi
  931. EndFunc
  932.  
  933. Func __winapi_enumwindowsadd($hwnd, $sclass = "")
  934. If $sclass = "" Then $sclass = _winapi_getclassname($hwnd)
  935. $__gawinlist_winapi[0][0] += 1
  936. Local $icount = $__gawinlist_winapi[0][0]
  937. If $icount >= $__gawinlist_winapi[0][1] Then
  938. ReDim $__gawinlist_winapi[$icount + 64][2]
  939. $__gawinlist_winapi[0][1] += 64
  940. EndIf
  941. $__gawinlist_winapi[$icount][0] = $hwnd
  942. $__gawinlist_winapi[$icount][1] = $sclass
  943. EndFunc
  944.  
  945. Func __winapi_enumwindowschild($hwnd, $fvisible = True)
  946. $hwnd = _winapi_getwindow($hwnd, $__winapiconstant_gw_child)
  947. While $hwnd <> 0
  948. If (NOT $fvisible) OR _winapi_iswindowvisible($hwnd) Then
  949. __winapi_enumwindowschild($hwnd, $fvisible)
  950. __winapi_enumwindowsadd($hwnd)
  951. EndIf
  952. $hwnd = _winapi_getwindow($hwnd, $__winapiconstant_gw_hwndnext)
  953. WEnd
  954. EndFunc
  955.  
  956. Func __winapi_enumwindowsinit()
  957. ReDim $__gawinlist_winapi[64][2]
  958. $__gawinlist_winapi[0][0] = 0
  959. $__gawinlist_winapi[0][1] = 64
  960. EndFunc
  961.  
  962. Func _winapi_enumwindowspopup()
  963. __winapi_enumwindowsinit()
  964. Local $hwnd = _winapi_getwindow(_winapi_getdesktopwindow(), $__winapiconstant_gw_child)
  965. Local $sclass
  966. While $hwnd <> 0
  967. If _winapi_iswindowvisible($hwnd) Then
  968. $sclass = _winapi_getclassname($hwnd)
  969. If $sclass = "#32768" Then
  970. __winapi_enumwindowsadd($hwnd)
  971. ElseIf $sclass = "ToolbarWindow32" Then
  972. __winapi_enumwindowsadd($hwnd)
  973. ElseIf $sclass = "ToolTips_Class32" Then
  974. __winapi_enumwindowsadd($hwnd)
  975. ElseIf $sclass = "BaseBar" Then
  976. __winapi_enumwindowschild($hwnd)
  977. EndIf
  978. EndIf
  979. $hwnd = _winapi_getwindow($hwnd, $__winapiconstant_gw_hwndnext)
  980. WEnd
  981. Return $__gawinlist_winapi
  982. EndFunc
  983.  
  984. Func _winapi_enumwindowstop()
  985. __winapi_enumwindowsinit()
  986. Local $hwnd = _winapi_getwindow(_winapi_getdesktopwindow(), $__winapiconstant_gw_child)
  987. While $hwnd <> 0
  988. If _winapi_iswindowvisible($hwnd) Then __winapi_enumwindowsadd($hwnd)
  989. $hwnd = _winapi_getwindow($hwnd, $__winapiconstant_gw_hwndnext)
  990. WEnd
  991. Return $__gawinlist_winapi
  992. EndFunc
  993.  
  994. Func _winapi_expandenvironmentstrings($sstring)
  995. Local $aresult = DllCall("kernel32.dll", "dword", "ExpandEnvironmentStringsW", "wstr", $sstring, "wstr", "", "dword", 4096)
  996. If @error Then Return SetError(@error, @extended, "")
  997. Return $aresult[2]
  998. EndFunc
  999.  
  1000. Func _winapi_extracticonex($sfile, $iindex, $plarge, $psmall, $iicons)
  1001. Local $aresult = DllCall("shell32.dll", "uint", "ExtractIconExW", "wstr", $sfile, "int", $iindex, "handle", $plarge, "handle", $psmall, "uint", $iicons)
  1002. If @error Then Return SetError(@error, @extended, 0)
  1003. Return $aresult[0]
  1004. EndFunc
  1005.  
  1006. Func _winapi_fatalappexit($smessage)
  1007. DllCall("kernel32.dll", "none", "FatalAppExitW", "uint", 0, "wstr", $smessage)
  1008. If @error Then Return SetError(@error, @extended)
  1009. EndFunc
  1010.  
  1011. Func _winapi_fillrect($hdc, $ptrrect, $hbrush)
  1012. Local $aresult
  1013. If IsPtr($hbrush) Then
  1014. $aresult = DllCall("user32.dll", "int", "FillRect", "handle", $hdc, "ptr", $ptrrect, "handle", $hbrush)
  1015. Else
  1016. $aresult = DllCall("user32.dll", "int", "FillRect", "handle", $hdc, "ptr", $ptrrect, "dword", $hbrush)
  1017. EndIf
  1018. If @error Then Return SetError(@error, @extended, False)
  1019. Return $aresult[0]
  1020. EndFunc
  1021.  
  1022. Func _winapi_findexecutable($sfilename, $sdirectory = "")
  1023. Local $aresult = DllCall("shell32.dll", "INT", "FindExecutableW", "wstr", $sfilename, "wstr", $sdirectory, "wstr", "")
  1024. If @error Then Return SetError(@error, @extended, 0)
  1025. Return SetExtended($aresult[0], $aresult[3])
  1026. EndFunc
  1027.  
  1028. Func _winapi_findwindow($sclassname, $swindowname)
  1029. Local $aresult = DllCall("user32.dll", "hwnd", "FindWindowW", "wstr", $sclassname, "wstr", $swindowname)
  1030. If @error Then Return SetError(@error, @extended, 0)
  1031. Return $aresult[0]
  1032. EndFunc
  1033.  
  1034. Func _winapi_flashwindow($hwnd, $finvert = True)
  1035. Local $aresult = DllCall("user32.dll", "bool", "FlashWindow", "hwnd", $hwnd, "bool", $finvert)
  1036. If @error Then Return SetError(@error, @extended, False)
  1037. Return $aresult[0]
  1038. EndFunc
  1039.  
  1040. Func _winapi_flashwindowex($hwnd, $iflags = 3, $icount = 3, $itimeout = 0)
  1041. Local $tflash = DllStructCreate($tagflashwinfo)
  1042. Local $pflash = DllStructGetPtr($tflash)
  1043. Local $iflash = DllStructGetSize($tflash)
  1044. Local $imode = 0
  1045. If BitAND($iflags, 1) <> 0 Then $imode = BitOR($imode, $__winapiconstant_flashw_caption)
  1046. If BitAND($iflags, 2) <> 0 Then $imode = BitOR($imode, $__winapiconstant_flashw_tray)
  1047. If BitAND($iflags, 4) <> 0 Then $imode = BitOR($imode, $__winapiconstant_flashw_timer)
  1048. If BitAND($iflags, 8) <> 0 Then $imode = BitOR($imode, $__winapiconstant_flashw_timernofg)
  1049. DllStructSetData($tflash, "Size", $iflash)
  1050. DllStructSetData($tflash, "hWnd", $hwnd)
  1051. DllStructSetData($tflash, "Flags", $imode)
  1052. DllStructSetData($tflash, "Count", $icount)
  1053. DllStructSetData($tflash, "Timeout", $itimeout)
  1054. Local $aresult = DllCall("user32.dll", "bool", "FlashWindowEx", "ptr", $pflash)
  1055. If @error Then Return SetError(@error, @extended, False)
  1056. Return $aresult[0]
  1057. EndFunc
  1058.  
  1059. Func _winapi_floattoint($nfloat)
  1060. Local $tfloat = DllStructCreate("float")
  1061. Local $tint = DllStructCreate("int", DllStructGetPtr($tfloat))
  1062. DllStructSetData($tfloat, 1, $nfloat)
  1063. Return DllStructGetData($tint, 1)
  1064. EndFunc
  1065.  
  1066. Func _winapi_flushfilebuffers($hfile)
  1067. Local $aresult = DllCall("kernel32.dll", "bool", "FlushFileBuffers", "handle", $hfile)
  1068. If @error Then Return SetError(@error, @extended, False)
  1069. Return $aresult[0]
  1070. EndFunc
  1071.  
  1072. Func _winapi_formatmessage($iflags, $psource, $imessageid, $ilanguageid, ByRef $pbuffer, $isize, $varguments)
  1073. Local $sbuffertype = "ptr"
  1074. If IsString($pbuffer) Then $sbuffertype = "wstr"
  1075. Local $aresult = DllCall("Kernel32.dll", "dword", "FormatMessageW", "dword", $iflags, "ptr", $psource, "dword", $imessageid, "dword", $ilanguageid, $sbuffertype, $pbuffer, "dword", $isize, "ptr", $varguments)
  1076. If @error Then Return SetError(@error, @extended, 0)
  1077. If $sbuffertype = "wstr" Then $pbuffer = $aresult[5]
  1078. Return $aresult[0]
  1079. EndFunc
  1080.  
  1081. Func _winapi_framerect($hdc, $ptrrect, $hbrush)
  1082. Local $aresult = DllCall("user32.dll", "int", "FrameRect", "handle", $hdc, "ptr", $ptrrect, "handle", $hbrush)
  1083. If @error Then Return SetError(@error, @extended, False)
  1084. Return $aresult[0]
  1085. EndFunc
  1086.  
  1087. Func _winapi_freelibrary($hmodule)
  1088. Local $aresult = DllCall("kernel32.dll", "bool", "FreeLibrary", "handle", $hmodule)
  1089. If @error Then Return SetError(@error, @extended, False)
  1090. Return $aresult[0]
  1091. EndFunc
  1092.  
  1093. Func _winapi_getancestor($hwnd, $iflags = 1)
  1094. Local $aresult = DllCall("user32.dll", "hwnd", "GetAncestor", "hwnd", $hwnd, "uint", $iflags)
  1095. If @error Then Return SetError(@error, @extended, 0)
  1096. Return $aresult[0]
  1097. EndFunc
  1098.  
  1099. Func _winapi_getasynckeystate($ikey)
  1100. Local $aresult = DllCall("user32.dll", "short", "GetAsyncKeyState", "int", $ikey)
  1101. If @error Then Return SetError(@error, @extended, 0)
  1102. Return $aresult[0]
  1103. EndFunc
  1104.  
  1105. Func _winapi_getbkmode($hdc)
  1106. Local $aresult = DllCall("gdi32.dll", "int", "GetBkMode", "handle", $hdc)
  1107. If @error Then Return SetError(@error, @extended, 0)
  1108. Return $aresult[0]
  1109. EndFunc
  1110.  
  1111. Func _winapi_getclassname($hwnd)
  1112. If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
  1113. Local $aresult = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $hwnd, "wstr", "", "int", 4096)
  1114. If @error Then Return SetError(@error, @extended, False)
  1115. Return SetExtended($aresult[0], $aresult[2])
  1116. EndFunc
  1117.  
  1118. Func _winapi_getclientheight($hwnd)
  1119. Local $trect = _winapi_getclientrect($hwnd)
  1120. If @error Then Return SetError(@error, @extended, 0)
  1121. Return DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top")
  1122. EndFunc
  1123.  
  1124. Func _winapi_getclientwidth($hwnd)
  1125. Local $trect = _winapi_getclientrect($hwnd)
  1126. If @error Then Return SetError(@error, @extended, 0)
  1127. Return DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left")
  1128. EndFunc
  1129.  
  1130. Func _winapi_getclientrect($hwnd)
  1131. Local $trect = DllStructCreate($tagrect)
  1132. DllCall("user32.dll", "bool", "GetClientRect", "hwnd", $hwnd, "ptr", DllStructGetPtr($trect))
  1133. If @error Then Return SetError(@error, @extended, 0)
  1134. Return $trect
  1135. EndFunc
  1136.  
  1137. Func _winapi_getcurrentprocess()
  1138. Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentProcess")
  1139. If @error Then Return SetError(@error, @extended, 0)
  1140. Return $aresult[0]
  1141. EndFunc
  1142.  
  1143. Func _winapi_getcurrentprocessid()
  1144. Local $aresult = DllCall("kernel32.dll", "dword", "GetCurrentProcessId")
  1145. If @error Then Return SetError(@error, @extended, 0)
  1146. Return $aresult[0]
  1147. EndFunc
  1148.  
  1149. Func _winapi_getcurrentthread()
  1150. Local $aresult = DllCall("kernel32.dll", "handle", "GetCurrentThread")
  1151. If @error Then Return SetError(@error, @extended, 0)
  1152. Return $aresult[0]
  1153. EndFunc
  1154.  
  1155. Func _winapi_getcurrentthreadid()
  1156. Local $aresult = DllCall("kernel32.dll", "dword", "GetCurrentThreadId")
  1157. If @error Then Return SetError(@error, @extended, 0)
  1158. Return $aresult[0]
  1159. EndFunc
  1160.  
  1161. Func _winapi_getcursorinfo()
  1162. Local $tcursor = DllStructCreate($tagcursorinfo)
  1163. Local $icursor = DllStructGetSize($tcursor)
  1164. DllStructSetData($tcursor, "Size", $icursor)
  1165. DllCall("user32.dll", "bool", "GetCursorInfo", "ptr", DllStructGetPtr($tcursor))
  1166. If @error Then Return SetError(@error, @extended, 0)
  1167. Local $acursor[5]
  1168. $acursor[0] = True
  1169. $acursor[1] = DllStructGetData($tcursor, "Flags") <> 0
  1170. $acursor[2] = DllStructGetData($tcursor, "hCursor")
  1171. $acursor[3] = DllStructGetData($tcursor, "X")
  1172. $acursor[4] = DllStructGetData($tcursor, "Y")
  1173. Return $acursor
  1174. EndFunc
  1175.  
  1176. Func _winapi_getdc($hwnd)
  1177. Local $aresult = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hwnd)
  1178. If @error Then Return SetError(@error, @extended, 0)
  1179. Return $aresult[0]
  1180. EndFunc
  1181.  
  1182. Func _winapi_getdesktopwindow()
  1183. Local $aresult = DllCall("user32.dll", "hwnd", "GetDesktopWindow")
  1184. If @error Then Return SetError(@error, @extended, 0)
  1185. Return $aresult[0]
  1186. EndFunc
  1187.  
  1188. Func _winapi_getdevicecaps($hdc, $iindex)
  1189. Local $aresult = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hdc, "int", $iindex)
  1190. If @error Then Return SetError(@error, @extended, 0)
  1191. Return $aresult[0]
  1192. EndFunc
  1193.  
  1194. Func _winapi_getdibits($hdc, $hbmp, $istartscan, $iscanlines, $pbits, $pbi, $iusage)
  1195. Local $aresult = DllCall("gdi32.dll", "int", "GetDIBits", "handle", $hdc, "handle", $hbmp, "uint", $istartscan, "uint", $iscanlines, "ptr", $pbits, "ptr", $pbi, "uint", $iusage)
  1196. If @error Then Return SetError(@error, @extended, False)
  1197. Return $aresult[0]
  1198. EndFunc
  1199.  
  1200. Func _winapi_getdlgctrlid($hwnd)
  1201. Local $aresult = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hwnd)
  1202. If @error Then Return SetError(@error, @extended, 0)
  1203. Return $aresult[0]
  1204. EndFunc
  1205.  
  1206. Func _winapi_getdlgitem($hwnd, $iitemid)
  1207. Local $aresult = DllCall("user32.dll", "hwnd", "GetDlgItem", "hwnd", $hwnd, "int", $iitemid)
  1208. If @error Then Return SetError(@error, @extended, 0)
  1209. Return $aresult[0]
  1210. EndFunc
  1211.  
  1212. Func _winapi_getfocus()
  1213. Local $aresult = DllCall("user32.dll", "hwnd", "GetFocus")
  1214. If @error Then Return SetError(@error, @extended, 0)
  1215. Return $aresult[0]
  1216. EndFunc
  1217.  
  1218. Func _winapi_getforegroundwindow()
  1219. Local $aresult = DllCall("user32.dll", "hwnd", "GetForegroundWindow")
  1220. If @error Then Return SetError(@error, @extended, 0)
  1221. Return $aresult[0]
  1222. EndFunc
  1223.  
  1224. Func _winapi_getguiresources($iflag = 0, $hprocess = -1)
  1225. If $hprocess = -1 Then $hprocess = _winapi_getcurrentprocess()
  1226. Local $aresult = DllCall("user32.dll", "dword", "GetGuiResources", "handle", $hprocess, "dword", $iflag)
  1227. If @error Then Return SetError(@error, @extended, 0)
  1228. Return $aresult[0]
  1229. EndFunc
  1230.  
  1231. Func _winapi_geticoninfo($hicon)
  1232. Local $tinfo = DllStructCreate($tagiconinfo)
  1233. DllCall("user32.dll", "bool", "GetIconInfo", "handle", $hicon, "ptr", DllStructGetPtr($tinfo))
  1234. If @error Then Return SetError(@error, @extended, 0)
  1235. Local $aicon[6]
  1236. $aicon[0] = True
  1237. $aicon[1] = DllStructGetData($tinfo, "Icon") <> 0
  1238. $aicon[2] = DllStructGetData($tinfo, "XHotSpot")
  1239. $aicon[3] = DllStructGetData($tinfo, "YHotSpot")
  1240. $aicon[4] = DllStructGetData($tinfo, "hMask")
  1241. $aicon[5] = DllStructGetData($tinfo, "hColor")
  1242. Return $aicon
  1243. EndFunc
  1244.  
  1245. Func _winapi_getfilesizeex($hfile)
  1246. Local $aresult = DllCall("kernel32.dll", "bool", "GetFileSizeEx", "handle", $hfile, "int64*", 0)
  1247. If @error Then Return SetError(@error, @extended, 0)
  1248. Return $aresult[2]
  1249. EndFunc
  1250.  
  1251. Func _winapi_getlasterrormessage()
  1252. Local $tbufferptr = DllStructCreate("ptr")
  1253. Local $pbufferptr = DllStructGetPtr($tbufferptr)
  1254. Local $ncount = _winapi_formatmessage(BitOR($__winapiconstant_format_message_allocate_buffer, $__winapiconstant_format_message_from_system), 0, _winapi_getlasterror(), 0, $pbufferptr, 0, 0)
  1255. If @error Then Return SetError(@error, 0, "")
  1256. Local $stext = ""
  1257. Local $pbuffer = DllStructGetData($tbufferptr, 1)
  1258. If $pbuffer Then
  1259. If $ncount > 0 Then
  1260. Local $tbuffer = DllStructCreate("wchar[" & ($ncount + 1) & "]", $pbuffer)
  1261. $stext = DllStructGetData($tbuffer, 1)
  1262. EndIf
  1263. _winapi_localfree($pbuffer)
  1264. EndIf
  1265. Return $stext
  1266. EndFunc
  1267.  
  1268. Func _winapi_getlayeredwindowattributes($hwnd, ByRef $i_transcolor, ByRef $transparency, $ascolorref = False)
  1269. $i_transcolor = -1
  1270. $transparency = -1
  1271. Local $aresult = DllCall("user32.dll", "bool", "GetLayeredWindowAttributes", "hwnd", $hwnd, "dword*", $i_transcolor, "byte*", $transparency, "dword*", 0)
  1272. If @error Then Return SetError(@error, @extended, 0)
  1273. If NOT $ascolorref Then
  1274. $aresult[2] = Hex(String($aresult[2]), 6)
  1275. $aresult[2] = "0x" & StringMid($aresult[2], 5, 2) & StringMid($aresult[2], 3, 2) & StringMid($aresult[2], 1, 2)
  1276. EndIf
  1277. $i_transcolor = $aresult[2]
  1278. $transparency = $aresult[3]
  1279. Return $aresult[4]
  1280. EndFunc
  1281.  
  1282. Func _winapi_getmodulehandle($smodulename)
  1283. Local $smodulenametype = "wstr"
  1284. If $smodulename = "" Then
  1285. $smodulename = 0
  1286. $s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement