View difference between Paste ID: 5sY0aymR and JjvXceLu
SHOW: | | - or go back to the newest paste.
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
		$smodulenametype = "ptr"
1287
	EndIf
1288
	Local $aresult = DllCall("kernel32.dll", "handle", "GetModuleHandleW", $smodulenametype, $smodulename)
1289
	If @error Then Return SetError(@error, @extended, 0)
1290
	Return $aresult[0]
1291
EndFunc
1292
1293
Func _winapi_getmousepos($ftoclient = False, $hwnd = 0)
1294
	Local $imode = Opt("MouseCoordMode", 1)
1295
	Local $apos = MouseGetPos()
1296
	Opt("MouseCoordMode", $imode)
1297
	Local $tpoint = DllStructCreate($tagpoint)
1298
	DllStructSetData($tpoint, "X", $apos[0])
1299
	DllStructSetData($tpoint, "Y", $apos[1])
1300
	If $ftoclient Then
1301
		_winapi_screentoclient($hwnd, $tpoint)
1302
		If @error Then Return SetError(@error, @extended, 0)
1303
	EndIf
1304
	Return $tpoint
1305
EndFunc
1306
1307
Func _winapi_getmouseposx($ftoclient = False, $hwnd = 0)
1308
	Local $tpoint = _winapi_getmousepos($ftoclient, $hwnd)
1309
	If @error Then Return SetError(@error, @extended, 0)
1310
	Return DllStructGetData($tpoint, "X")
1311
EndFunc
1312
1313
Func _winapi_getmouseposy($ftoclient = False, $hwnd = 0)
1314
	Local $tpoint = _winapi_getmousepos($ftoclient, $hwnd)
1315
	If @error Then Return SetError(@error, @extended, 0)
1316
	Return DllStructGetData($tpoint, "Y")
1317
EndFunc
1318
1319
Func _winapi_getobject($hobject, $isize, $pobject)
1320
	Local $aresult = DllCall("gdi32.dll", "int", "GetObject", "handle", $hobject, "int", $isize, "ptr", $pobject)
1321
	If @error Then Return SetError(@error, @extended, 0)
1322
	Return $aresult[0]
1323
EndFunc
1324
1325
Func _winapi_getopenfilename($stitle = "", $sfilter = "All files (*.*)", $sinitaldir = ".", $sdefaultfile = "", $sdefaultext = "", $ifilterindex = 1, $iflags = 0, $iflagsex = 0, $hwndowner = 0)
1326
	Local $ipathlen = 4096
1327
	Local $inulls = 0
1328
	Local $tofn = DllStructCreate($tagopenfilename)
1329
	Local $afiles[1] = [0]
1330
	Local $iflag = $iflags
1331
	Local $asflines = StringSplit($sfilter, "|")
1332
	Local $asfilter[$asflines[0] * 2 + 1]
1333
	Local $istart, $ifinal, $stfilter
1334
	$asfilter[0] = $asflines[0] * 2
1335
	For $i = 1 To $asflines[0]
1336
		$istart = StringInStr($asflines[$i], "(", 0, 1)
1337
		$ifinal = StringInStr($asflines[$i], ")", 0, -1)
1338
		$asfilter[$i * 2 - 1] = StringStripWS(StringLeft($asflines[$i], $istart - 1), 3)
1339
		$asfilter[$i * 2] = StringStripWS(StringTrimRight(StringTrimLeft($asflines[$i], $istart), StringLen($asflines[$i]) - $ifinal + 1), 3)
1340
		$stfilter &= "wchar[" & StringLen($asfilter[$i * 2 - 1]) + 1 & "];wchar[" & StringLen($asfilter[$i * 2]) + 1 & "];"
1341
	Next
1342
	Local $ttitle = DllStructCreate("wchar Title[" & StringLen($stitle) + 1 & "]")
1343
	Local $tinitialdir = DllStructCreate("wchar InitDir[" & StringLen($sinitaldir) + 1 & "]")
1344
	Local $tfilter = DllStructCreate($stfilter & "wchar")
1345
	Local $tpath = DllStructCreate("wchar Path[" & $ipathlen & "]")
1346
	Local $textn = DllStructCreate("wchar Extension[" & StringLen($sdefaultext) + 1 & "]")
1347
	For $i = 1 To $asfilter[0]
1348
		DllStructSetData($tfilter, $i, $asfilter[$i])
1349
	Next
1350
	DllStructSetData($ttitle, "Title", $stitle)
1351
	DllStructSetData($tinitialdir, "InitDir", $sinitaldir)
1352
	DllStructSetData($tpath, "Path", $sdefaultfile)
1353
	DllStructSetData($textn, "Extension", $sdefaultext)
1354
	DllStructSetData($tofn, "StructSize", DllStructGetSize($tofn))
1355
	DllStructSetData($tofn, "hwndOwner", $hwndowner)
1356
	DllStructSetData($tofn, "lpstrFilter", DllStructGetPtr($tfilter))
1357
	DllStructSetData($tofn, "nFilterIndex", $ifilterindex)
1358
	DllStructSetData($tofn, "lpstrFile", DllStructGetPtr($tpath))
1359
	DllStructSetData($tofn, "nMaxFile", $ipathlen)
1360
	DllStructSetData($tofn, "lpstrInitialDir", DllStructGetPtr($tinitialdir))
1361
	DllStructSetData($tofn, "lpstrTitle", DllStructGetPtr($ttitle))
1362
	DllStructSetData($tofn, "Flags", $iflag)
1363
	DllStructSetData($tofn, "lpstrDefExt", DllStructGetPtr($textn))
1364
	DllStructSetData($tofn, "FlagsEx", $iflagsex)
1365
	DllCall("comdlg32.dll", "bool", "GetOpenFileNameW", "ptr", DllStructGetPtr($tofn))
1366
	If @error Then Return SetError(@error, @extended, $afiles)
1367
	If BitAND($iflags, $ofn_allowmultiselect) = $ofn_allowmultiselect AND BitAND($iflags, $ofn_explorer) = $ofn_explorer Then
1368
		For $x = 1 To $ipathlen
1369
			If DllStructGetData($tpath, "Path", $x) = Chr(0) Then
1370
				DllStructSetData($tpath, "Path", "|", $x)
1371
				$inulls += 1
1372
			Else
1373
				$inulls = 0
1374
			EndIf
1375
			If $inulls = 2 Then ExitLoop 
1376
		Next
1377
		DllStructSetData($tpath, "Path", Chr(0), $x - 1)
1378
		$afiles = StringSplit(DllStructGetData($tpath, "Path"), "|")
1379
		If $afiles[0] = 1 Then Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
1380
		Return StringSplit(DllStructGetData($tpath, "Path"), "|")
1381
	ElseIf BitAND($iflags, $ofn_allowmultiselect) = $ofn_allowmultiselect Then
1382
		$afiles = StringSplit(DllStructGetData($tpath, "Path"), " ")
1383
		If $afiles[0] = 1 Then Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
1384
		Return StringSplit(StringReplace(DllStructGetData($tpath, "Path"), " ", "|"), "|")
1385
	Else
1386
		Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
1387
	EndIf
1388
EndFunc
1389
1390
Func _winapi_getoverlappedresult($hfile, $poverlapped, ByRef $ibytes, $fwait = False)
1391
	Local $aresult = DllCall("kernel32.dll", "bool", "GetOverlappedResult", "handle", $hfile, "ptr", $poverlapped, "dword*", 0, "bool", $fwait)
1392
	If @error Then Return SetError(@error, @extended, False)
1393
	$ibytes = $aresult[3]
1394
	Return $aresult[0]
1395
EndFunc
1396
1397
Func _winapi_getparent($hwnd)
1398
	Local $aresult = DllCall("user32.dll", "hwnd", "GetParent", "hwnd", $hwnd)
1399
	If @error Then Return SetError(@error, @extended, 0)
1400
	Return $aresult[0]
1401
EndFunc
1402
1403
Func _winapi_getprocessaffinitymask($hprocess)
1404
	Local $aresult = DllCall("kernel32.dll", "bool", "GetProcessAffinityMask", "handle", $hprocess, "dword_ptr*", 0, "dword_ptr*", 0)
1405
	If @error Then Return SetError(@error, @extended, 0)
1406
	Local $amask[3]
1407
	$amask[0] = True
1408
	$amask[1] = $aresult[2]
1409
	$amask[2] = $aresult[3]
1410
	Return $amask
1411
EndFunc
1412
1413
Func _winapi_getsavefilename($stitle = "", $sfilter = "All files (*.*)", $sinitaldir = ".", $sdefaultfile = "", $sdefaultext = "", $ifilterindex = 1, $iflags = 0, $iflagsex = 0, $hwndowner = 0)
1414
	Local $ipathlen = 4096
1415
	Local $tofn = DllStructCreate($tagopenfilename)
1416
	Local $afiles[1] = [0]
1417
	Local $iflag = $iflags
1418
	Local $asflines = StringSplit($sfilter, "|")
1419
	Local $asfilter[$asflines[0] * 2 + 1]
1420
	Local $istart, $ifinal, $stfilter
1421
	$asfilter[0] = $asflines[0] * 2
1422
	For $i = 1 To $asflines[0]
1423
		$istart = StringInStr($asflines[$i], "(", 0, 1)
1424
		$ifinal = StringInStr($asflines[$i], ")", 0, -1)
1425
		$asfilter[$i * 2 - 1] = StringStripWS(StringLeft($asflines[$i], $istart - 1), 3)
1426
		$asfilter[$i * 2] = StringStripWS(StringTrimRight(StringTrimLeft($asflines[$i], $istart), StringLen($asflines[$i]) - $ifinal + 1), 3)
1427
		$stfilter &= "wchar[" & StringLen($asfilter[$i * 2 - 1]) + 1 & "];wchar[" & StringLen($asfilter[$i * 2]) + 1 & "];"
1428
	Next
1429
	Local $ttitle = DllStructCreate("wchar Title[" & StringLen($stitle) + 1 & "]")
1430
	Local $tinitialdir = DllStructCreate("wchar InitDir[" & StringLen($sinitaldir) + 1 & "]")
1431
	Local $tfilter = DllStructCreate($stfilter & "wchar")
1432
	Local $tpath = DllStructCreate("wchar Path[" & $ipathlen & "]")
1433
	Local $textn = DllStructCreate("wchar Extension[" & StringLen($sdefaultext) + 1 & "]")
1434
	For $i = 1 To $asfilter[0]
1435
		DllStructSetData($tfilter, $i, $asfilter[$i])
1436
	Next
1437
	DllStructSetData($ttitle, "Title", $stitle)
1438
	DllStructSetData($tinitialdir, "InitDir", $sinitaldir)
1439
	DllStructSetData($tpath, "Path", $sdefaultfile)
1440
	DllStructSetData($textn, "Extension", $sdefaultext)
1441
	DllStructSetData($tofn, "StructSize", DllStructGetSize($tofn))
1442
	DllStructSetData($tofn, "hwndOwner", $hwndowner)
1443
	DllStructSetData($tofn, "lpstrFilter", DllStructGetPtr($tfilter))
1444
	DllStructSetData($tofn, "nFilterIndex", $ifilterindex)
1445
	DllStructSetData($tofn, "lpstrFile", DllStructGetPtr($tpath))
1446
	DllStructSetData($tofn, "nMaxFile", $ipathlen)
1447
	DllStructSetData($tofn, "lpstrInitialDir", DllStructGetPtr($tinitialdir))
1448
	DllStructSetData($tofn, "lpstrTitle", DllStructGetPtr($ttitle))
1449
	DllStructSetData($tofn, "Flags", $iflag)
1450
	DllStructSetData($tofn, "lpstrDefExt", DllStructGetPtr($textn))
1451
	DllStructSetData($tofn, "FlagsEx", $iflagsex)
1452
	DllCall("comdlg32.dll", "bool", "GetSaveFileNameW", "ptr", DllStructGetPtr($tofn))
1453
	If @error Then Return SetError(@error, @extended, $afiles)
1454
	Return __winapi_parsefiledialogpath(DllStructGetData($tpath, "Path"))
1455
EndFunc
1456
1457
Func _winapi_getstockobject($iobject)
1458
	Local $aresult = DllCall("gdi32.dll", "handle", "GetStockObject", "int", $iobject)
1459
	If @error Then Return SetError(@error, @extended, 0)
1460
	Return $aresult[0]
1461
EndFunc
1462
1463
Func _winapi_getstdhandle($istdhandle)
1464
	If $istdhandle < 0 OR $istdhandle > 2 Then Return SetError(2, 0, -1)
1465
	Local Const $ahandle[3] = [-10, -11, -12]
1466
	Local $aresult = DllCall("kernel32.dll", "handle", "GetStdHandle", "dword", $ahandle[$istdhandle])
1467
	If @error Then Return SetError(@error, @extended, -1)
1468
	Return $aresult[0]
1469
EndFunc
1470
1471
Func _winapi_getsyscolor($iindex)
1472
	Local $aresult = DllCall("user32.dll", "dword", "GetSysColor", "int", $iindex)
1473
	If @error Then Return SetError(@error, @extended, 0)
1474
	Return $aresult[0]
1475
EndFunc
1476
1477
Func _winapi_getsyscolorbrush($iindex)
1478
	Local $aresult = DllCall("user32.dll", "handle", "GetSysColorBrush", "int", $iindex)
1479
	If @error Then Return SetError(@error, @extended, 0)
1480
	Return $aresult[0]
1481
EndFunc
1482
1483
Func _winapi_getsystemmetrics($iindex)
1484
	Local $aresult = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $iindex)
1485
	If @error Then Return SetError(@error, @extended, 0)
1486
	Return $aresult[0]
1487
EndFunc
1488
1489
Func _winapi_gettextextentpoint32($hdc, $stext)
1490
	Local $tsize = DllStructCreate($tagsize)
1491
	Local $isize = StringLen($stext)
1492
	DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hdc, "wstr", $stext, "int", $isize, "ptr", DllStructGetPtr($tsize))
1493
	If @error Then Return SetError(@error, @extended, 0)
1494
	Return $tsize
1495
EndFunc
1496
1497
Func _winapi_getwindow($hwnd, $icmd)
1498
	Local $aresult = DllCall("user32.dll", "hwnd", "GetWindow", "hwnd", $hwnd, "uint", $icmd)
1499
	If @error Then Return SetError(@error, @extended, 0)
1500
	Return $aresult[0]
1501
EndFunc
1502
1503
Func _winapi_getwindowdc($hwnd)
1504
	Local $aresult = DllCall("user32.dll", "handle", "GetWindowDC", "hwnd", $hwnd)
1505
	If @error Then Return SetError(@error, @extended, 0)
1506
	Return $aresult[0]
1507
EndFunc
1508
1509
Func _winapi_getwindowheight($hwnd)
1510
	Local $trect = _winapi_getwindowrect($hwnd)
1511
	If @error Then Return SetError(@error, @extended, 0)
1512
	Return DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top")
1513
EndFunc
1514
1515
Func _winapi_getwindowlong($hwnd, $iindex)
1516
	Local $sfuncname = "GetWindowLongW"
1517
	If @AutoItX64 Then $sfuncname = "GetWindowLongPtrW"
1518
	Local $aresult = DllCall("user32.dll", "long_ptr", $sfuncname, "hwnd", $hwnd, "int", $iindex)
1519
	If @error Then Return SetError(@error, @extended, 0)
1520
	Return $aresult[0]
1521
EndFunc
1522
1523
Func _winapi_getwindowplacement($hwnd)
1524
	Local $twindowplacement = DllStructCreate($tagwindowplacement)
1525
	DllStructSetData($twindowplacement, "length", DllStructGetSize($twindowplacement))
1526
	Local $pwindowplacement = DllStructGetPtr($twindowplacement)
1527
	DllCall("user32.dll", "bool", "GetWindowPlacement", "hwnd", $hwnd, "ptr", $pwindowplacement)
1528
	If @error Then Return SetError(@error, @extended, 0)
1529
	Return $twindowplacement
1530
EndFunc
1531
1532
Func _winapi_getwindowrect($hwnd)
1533
	Local $trect = DllStructCreate($tagrect)
1534
	DllCall("user32.dll", "bool", "GetWindowRect", "hwnd", $hwnd, "ptr", DllStructGetPtr($trect))
1535
	If @error Then Return SetError(@error, @extended, 0)
1536
	Return $trect
1537
EndFunc
1538
1539
Func _winapi_getwindowrgn($hwnd, $hrgn)
1540
	Local $aresult = DllCall("user32.dll", "int", "GetWindowRgn", "hwnd", $hwnd, "handle", $hrgn)
1541
	If @error Then Return SetError(@error, @extended, 0)
1542
	Return $aresult[0]
1543
EndFunc
1544
1545
Func _winapi_getwindowtext($hwnd)
1546
	Local $aresult = DllCall("user32.dll", "int", "GetWindowTextW", "hwnd", $hwnd, "wstr", "", "int", 4096)
1547
	If @error Then Return SetError(@error, @extended, "")
1548
	Return SetExtended($aresult[0], $aresult[2])
1549
EndFunc
1550
1551
Func _winapi_getwindowthreadprocessid($hwnd, ByRef $ipid)
1552
	Local $aresult = DllCall("user32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $hwnd, "dword*", 0)
1553
	If @error Then Return SetError(@error, @extended, 0)
1554
	$ipid = $aresult[2]
1555
	Return $aresult[0]
1556
EndFunc
1557
1558
Func _winapi_getwindowwidth($hwnd)
1559
	Local $trect = _winapi_getwindowrect($hwnd)
1560
	If @error Then Return SetError(@error, @extended, 0)
1561
	Return DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left")
1562
EndFunc
1563
1564
Func _winapi_getxyfrompoint(ByRef $tpoint, ByRef $ix, ByRef $iy)
1565
	$ix = DllStructGetData($tpoint, "X")
1566
	$iy = DllStructGetData($tpoint, "Y")
1567
EndFunc
1568
1569
Func _winapi_globalmemorystatus()
1570
	Local $tmem = DllStructCreate($tagmemorystatusex)
1571
	Local $pmem = DllStructGetPtr($tmem)
1572
	Local $imem = DllStructGetSize($tmem)
1573
	DllStructSetData($tmem, 1, $imem)
1574
	DllCall("kernel32.dll", "none", "GlobalMemoryStatusEx", "ptr", $pmem)
1575
	If @error Then Return SetError(@error, @extended, 0)
1576
	Local $amem[7]
1577
	$amem[0] = DllStructGetData($tmem, 2)
1578
	$amem[1] = DllStructGetData($tmem, 3)
1579
	$amem[2] = DllStructGetData($tmem, 4)
1580
	$amem[3] = DllStructGetData($tmem, 5)
1581
	$amem[4] = DllStructGetData($tmem, 6)
1582
	$amem[5] = DllStructGetData($tmem, 7)
1583
	$amem[6] = DllStructGetData($tmem, 8)
1584
	Return $amem
1585
EndFunc
1586
1587
Func _winapi_guidfromstring($sguid)
1588
	Local $tguid = DllStructCreate($tagguid)
1589
	_winapi_guidfromstringex($sguid, DllStructGetPtr($tguid))
1590
	If @error Then Return SetError(@error, @extended, 0)
1591
	Return $tguid
1592
EndFunc
1593
1594
Func _winapi_guidfromstringex($sguid, $pguid)
1595
	Local $aresult = DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $sguid, "ptr", $pguid)
1596
	If @error Then Return SetError(@error, @extended, False)
1597
	Return $aresult[0]
1598
EndFunc
1599
1600
Func _winapi_hiword($ilong)
1601
	Return BitShift($ilong, 16)
1602
EndFunc
1603
1604
Func _winapi_inprocess($hwnd, ByRef $hlastwnd)
1605
	If $hwnd = $hlastwnd Then Return True
1606
	For $ii = $__gainprocess_winapi[0][0] To 1 Step -1
1607
		If $hwnd = $__gainprocess_winapi[$ii][0] Then
1608
			If $__gainprocess_winapi[$ii][1] Then
1609
				$hlastwnd = $hwnd
1610
				Return True
1611
			Else
1612
				Return False
1613
			EndIf
1614
		EndIf
1615
	Next
1616
	Local $iprocessid
1617
	_winapi_getwindowthreadprocessid($hwnd, $iprocessid)
1618
	Local $icount = $__gainprocess_winapi[0][0] + 1
1619
	If $icount >= 64 Then $icount = 1
1620
	$__gainprocess_winapi[0][0] = $icount
1621
	$__gainprocess_winapi[$icount][0] = $hwnd
1622
	$__gainprocess_winapi[$icount][1] = ($iprocessid = @AutoItPID)
1623
	Return $__gainprocess_winapi[$icount][1]
1624
EndFunc
1625
1626
Func _winapi_inttofloat($iint)
1627
	Local $tint = DllStructCreate("int")
1628
	Local $tfloat = DllStructCreate("float", DllStructGetPtr($tint))
1629
	DllStructSetData($tint, 1, $iint)
1630
	Return DllStructGetData($tfloat, 1)
1631
EndFunc
1632
1633
Func _winapi_isclassname($hwnd, $sclassname)
1634
	Local $sseparator = Opt("GUIDataSeparatorChar")
1635
	Local $aclassname = StringSplit($sclassname, $sseparator)
1636
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
1637
	Local $sclasscheck = _winapi_getclassname($hwnd)
1638
	For $x = 1 To UBound($aclassname) - 1
1639
		If StringUpper(StringMid($sclasscheck, 1, StringLen($aclassname[$x]))) = StringUpper($aclassname[$x]) Then Return True
1640
	Next
1641
	Return False
1642
EndFunc
1643
1644
Func _winapi_iswindow($hwnd)
1645
	Local $aresult = DllCall("user32.dll", "bool", "IsWindow", "hwnd", $hwnd)
1646
	If @error Then Return SetError(@error, @extended, 0)
1647
	Return $aresult[0]
1648
EndFunc
1649
1650
Func _winapi_iswindowvisible($hwnd)
1651
	Local $aresult = DllCall("user32.dll", "bool", "IsWindowVisible", "hwnd", $hwnd)
1652
	If @error Then Return SetError(@error, @extended, 0)
1653
	Return $aresult[0]
1654
EndFunc
1655
1656
Func _winapi_invalidaterect($hwnd, $trect = 0, $ferase = True)
1657
	Local $prect = 0
1658
	If IsDllStruct($trect) Then $prect = DllStructGetPtr($trect)
1659
	Local $aresult = DllCall("user32.dll", "bool", "InvalidateRect", "hwnd", $hwnd, "ptr", $prect, "bool", $ferase)
1660
	If @error Then Return SetError(@error, @extended, False)
1661
	Return $aresult[0]
1662
EndFunc
1663
1664
Func _winapi_lineto($hdc, $ix, $iy)
1665
	Local $aresult = DllCall("gdi32.dll", "bool", "LineTo", "handle", $hdc, "int", $ix, "int", $iy)
1666
	If @error Then Return SetError(@error, @extended, False)
1667
	Return $aresult[0]
1668
EndFunc
1669
1670
Func _winapi_loadbitmap($hinstance, $sbitmap)
1671
	Local $sbitmaptype = "int"
1672
	If IsString($sbitmap) Then $sbitmaptype = "wstr"
1673
	Local $aresult = DllCall("user32.dll", "handle", "LoadBitmapW", "handle", $hinstance, $sbitmaptype, $sbitmap)
1674
	If @error Then Return SetError(@error, @extended, 0)
1675
	Return $aresult[0]
1676
EndFunc
1677
1678
Func _winapi_loadimage($hinstance, $simage, $itype, $ixdesired, $iydesired, $iload)
1679
	Local $aresult, $simagetype = "int"
1680
	If IsString($simage) Then $simagetype = "wstr"
1681
	$aresult = DllCall("user32.dll", "handle", "LoadImageW", "handle", $hinstance, $simagetype, $simage, "uint", $itype, "int", $ixdesired, "int", $iydesired, "uint", $iload)
1682
	If @error Then Return SetError(@error, @extended, 0)
1683
	Return $aresult[0]
1684
EndFunc
1685
1686
Func _winapi_loadlibrary($sfilename)
1687
	Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryW", "wstr", $sfilename)
1688
	If @error Then Return SetError(@error, @extended, 0)
1689
	Return $aresult[0]
1690
EndFunc
1691
1692
Func _winapi_loadlibraryex($sfilename, $iflags = 0)
1693
	Local $aresult = DllCall("kernel32.dll", "handle", "LoadLibraryExW", "wstr", $sfilename, "ptr", 0, "dword", $iflags)
1694
	If @error Then Return SetError(@error, @extended, 0)
1695
	Return $aresult[0]
1696
EndFunc
1697
1698
Func _winapi_loadshell32icon($iiconid)
1699
	Local $ticons = DllStructCreate("ptr Data")
1700
	Local $picons = DllStructGetPtr($ticons)
1701
	Local $iicons = _winapi_extracticonex("shell32.dll", $iiconid, 0, $picons, 1)
1702
	If @error Then Return SetError(@error, @extended, 0)
1703
	If $iicons <= 0 Then Return SetError(1, 0, 0)
1704
	Return DllStructGetData($ticons, "Data")
1705
EndFunc
1706
1707
Func _winapi_loadstring($hinstance, $istringid)
1708
	Local $aresult = DllCall("user32.dll", "int", "LoadStringW", "handle", $hinstance, "uint", $istringid, "wstr", "", "int", 4096)
1709
	If @error Then Return SetError(@error, @extended, "")
1710
	Return SetExtended($aresult[0], $aresult[3])
1711
EndFunc
1712
1713
Func _winapi_localfree($hmem)
1714
	Local $aresult = DllCall("kernel32.dll", "handle", "LocalFree", "handle", $hmem)
1715
	If @error Then Return SetError(@error, @extended, False)
1716
	Return $aresult[0]
1717
EndFunc
1718
1719
Func _winapi_loword($ilong)
1720
	Return BitAND($ilong, 65535)
1721
EndFunc
1722
1723
Func _winapi_makelangid($lgidprimary, $lgidsub)
1724
	Return BitOR(BitShift($lgidsub, -10), $lgidprimary)
1725
EndFunc
1726
1727
Func _winapi_makelcid($lgid, $srtid)
1728
	Return BitOR(BitShift($srtid, -16), $lgid)
1729
EndFunc
1730
1731
Func _winapi_makelong($ilo, $ihi)
1732
	Return BitOR(BitShift($ihi, -16), BitAND($ilo, 65535))
1733
EndFunc
1734
1735
Func _winapi_makeqword($lodword, $hidword)
1736
	Local $tint64 = DllStructCreate("uint64")
1737
	Local $tdwords = DllStructCreate("dword;dword", DllStructGetPtr($tint64))
1738
	DllStructSetData($tdwords, 1, $lodword)
1739
	DllStructSetData($tdwords, 2, $hidword)
1740
	Return DllStructGetData($tint64, 1)
1741
EndFunc
1742
1743
Func _winapi_messagebeep($itype = 1)
1744
	Local $isound
1745
	Switch $itype
1746
		Case 1
1747
			$isound = 0
1748
		Case 2
1749
			$isound = 16
1750
		Case 3
1751
			$isound = 32
1752
		Case 4
1753
			$isound = 48
1754
		Case 5
1755
			$isound = 64
1756
		Case Else
1757
			$isound = -1
1758
	EndSwitch
1759
	Local $aresult = DllCall("user32.dll", "bool", "MessageBeep", "uint", $isound)
1760
	If @error Then Return SetError(@error, @extended, False)
1761
	Return $aresult[0]
1762
EndFunc
1763
1764
Func _winapi_msgbox($iflags, $stitle, $stext)
1765
	BlockInput(0)
1766
	MsgBox($iflags, $stitle, $stext & "      ")
1767
EndFunc
1768
1769
Func _winapi_mouse_event($iflags, $ix = 0, $iy = 0, $idata = 0, $iextrainfo = 0)
1770
	DllCall("user32.dll", "none", "mouse_event", "dword", $iflags, "dword", $ix, "dword", $iy, "dword", $idata, "ulong_ptr", $iextrainfo)
1771
	If @error Then Return SetError(@error, @extended)
1772
EndFunc
1773
1774
Func _winapi_moveto($hdc, $ix, $iy)
1775
	Local $aresult = DllCall("gdi32.dll", "bool", "MoveToEx", "handle", $hdc, "int", $ix, "int", $iy, "ptr", 0)
1776
	If @error Then Return SetError(@error, @extended, False)
1777
	Return $aresult[0]
1778
EndFunc
1779
1780
Func _winapi_movewindow($hwnd, $ix, $iy, $iwidth, $iheight, $frepaint = True)
1781
	Local $aresult = DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hwnd, "int", $ix, "int", $iy, "int", $iwidth, "int", $iheight, "bool", $frepaint)
1782
	If @error Then Return SetError(@error, @extended, False)
1783
	Return $aresult[0]
1784
EndFunc
1785
1786
Func _winapi_muldiv($inumber, $inumerator, $idenominator)
1787
	Local $aresult = DllCall("kernel32.dll", "int", "MulDiv", "int", $inumber, "int", $inumerator, "int", $idenominator)
1788
	If @error Then Return SetError(@error, @extended, -1)
1789
	Return $aresult[0]
1790
EndFunc
1791
1792
Func _winapi_multibytetowidechar($stext, $icodepage = 0, $iflags = 0, $bretstring = False)
1793
	Local $stexttype = "ptr", $ptext = $stext
1794
	If IsDllStruct($stext) Then
1795
		$ptext = DllStructGetPtr($stext)
1796
	Else
1797
		If NOT IsPtr($stext) Then $stexttype = "STR"
1798
	EndIf
1799
	Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, $stexttype, $ptext, "int", -1, "ptr", 0, "int", 0)
1800
	If @error Then Return SetError(@error, @extended, 0)
1801
	Local $iout = $aresult[0]
1802
	Local $tout = DllStructCreate("wchar[" & $iout & "]")
1803
	Local $pout = DllStructGetPtr($tout)
1804
	$aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, $stexttype, $ptext, "int", -1, "ptr", $pout, "int", $iout)
1805
	If @error Then Return SetError(@error, @extended, 0)
1806
	If $bretstring Then Return DllStructGetData($tout, 1)
1807
	Return $tout
1808
EndFunc
1809
1810
Func _winapi_multibytetowidecharex($stext, $ptext, $icodepage = 0, $iflags = 0)
1811
	Local $aresult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $icodepage, "dword", $iflags, "STR", $stext, "int", -1, "ptr", $ptext, "int", (StringLen($stext) + 1) * 2)
1812
	If @error Then Return SetError(@error, @extended, False)
1813
	Return $aresult[0]
1814
EndFunc
1815
1816
Func _winapi_openprocess($iaccess, $finherit, $iprocessid, $fdebugpriv = False)
1817
	Local $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $finherit, "dword", $iprocessid)
1818
	If @error Then Return SetError(@error, @extended, 0)
1819
	If $aresult[0] Then Return $aresult[0]
1820
	If NOT $fdebugpriv Then Return 0
1821
	Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
1822
	If @error Then Return SetError(@error, @extended, 0)
1823
	_security__setprivilege($htoken, "SeDebugPrivilege", True)
1824
	Local $ierror = @error
1825
	Local $ilasterror = @extended
1826
	Local $iret = 0
1827
	If NOT @error Then
1828
		$aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $finherit, "dword", $iprocessid)
1829
		$ierror = @error
1830
		$ilasterror = @extended
1831
		If $aresult[0] Then $iret = $aresult[0]
1832
		_security__setprivilege($htoken, "SeDebugPrivilege", False)
1833
		If @error Then
1834
			$ierror = @error
1835
			$ilasterror = @extended
1836
		EndIf
1837
	EndIf
1838
	_winapi_closehandle($htoken)
1839
	Return SetError($ierror, $ilasterror, $iret)
1840
EndFunc
1841
1842
Func __winapi_parsefiledialogpath($spath)
1843
	Local $afiles[3]
1844
	$afiles[0] = 2
1845
	Local $stemp = StringMid($spath, 1, StringInStr($spath, "\", 0, -1) - 1)
1846
	$afiles[1] = $stemp
1847
	$afiles[2] = StringMid($spath, StringInStr($spath, "\", 0, -1) + 1)
1848
	Return $afiles
1849
EndFunc
1850
1851
Func _winapi_pathfindonpath(Const $szfile, $aextrapaths = "", Const $szpathdelimiter = @LF)
1852
	Local $iextracount = 0
1853
	If IsString($aextrapaths) Then
1854
		If StringLen($aextrapaths) Then
1855
			$aextrapaths = StringSplit($aextrapaths, $szpathdelimiter, 1 + 2)
1856
			$iextracount = UBound($aextrapaths, 1)
1857
		EndIf
1858
	ElseIf IsArray($aextrapaths) Then
1859
		$iextracount = UBound($aextrapaths)
1860
	EndIf
1861
	Local $tpaths, $tpathptrs
1862
	If $iextracount Then
1863
		Local $szstruct = ""
1864
		For $path In $aextrapaths
1865
			$szstruct &= "wchar[" & StringLen($path) + 1 & "];"
1866
		Next
1867
		$tpaths = DllStructCreate($szstruct)
1868
		$tpathptrs = DllStructCreate("ptr[" & $iextracount + 1 & "]")
1869
		For $i = 1 To $iextracount
1870
			DllStructSetData($tpaths, $i, $aextrapaths[$i - 1])
1871
			DllStructSetData($tpathptrs, 1, DllStructGetPtr($tpaths, $i), $i)
1872
		Next
1873
		DllStructSetData($tpathptrs, 1, Ptr(0), $iextracount + 1)
1874
	EndIf
1875
	Local $aresult = DllCall("shlwapi.dll", "bool", "PathFindOnPathW", "wstr", $szfile, "ptr", DllStructGetPtr($tpathptrs))
1876
	If @error Then Return SetError(@error, @extended, False)
1877
	If $aresult[0] = 0 Then Return SetError(1, 0, $szfile)
1878
	Return $aresult[1]
1879
EndFunc
1880
1881
Func _winapi_pointfromrect(ByRef $trect, $fcenter = True)
1882
	Local $ix1 = DllStructGetData($trect, "Left")
1883
	Local $iy1 = DllStructGetData($trect, "Top")
1884
	Local $ix2 = DllStructGetData($trect, "Right")
1885
	Local $iy2 = DllStructGetData($trect, "Bottom")
1886
	If $fcenter Then
1887
		$ix1 = $ix1 + (($ix2 - $ix1) / 2)
1888
		$iy1 = $iy1 + (($iy2 - $iy1) / 2)
1889
	EndIf
1890
	Local $tpoint = DllStructCreate($tagpoint)
1891
	DllStructSetData($tpoint, "X", $ix1)
1892
	DllStructSetData($tpoint, "Y", $iy1)
1893
	Return $tpoint
1894
EndFunc
1895
1896
Func _winapi_postmessage($hwnd, $imsg, $iwparam, $ilparam)
1897
	Local $aresult = DllCall("user32.dll", "bool", "PostMessage", "hwnd", $hwnd, "uint", $imsg, "wparam", $iwparam, "lparam", $ilparam)
1898
	If @error Then Return SetError(@error, @extended, False)
1899
	Return $aresult[0]
1900
EndFunc
1901
1902
Func _winapi_primarylangid($lgid)
1903
	Return BitAND($lgid, 1023)
1904
EndFunc
1905
1906
Func _winapi_ptinrect(ByRef $trect, ByRef $tpoint)
1907
	Local $ix = DllStructGetData($tpoint, "X")
1908
	Local $iy = DllStructGetData($tpoint, "Y")
1909
	Local $aresult = DllCall("user32.dll", "bool", "PtInRect", "ptr", DllStructGetPtr($trect), "long", $ix, "long", $iy)
1910
	If @error Then Return SetError(@error, @extended, False)
1911
	Return $aresult[0]
1912
EndFunc
1913
1914
Func _winapi_readfile($hfile, $pbuffer, $itoread, ByRef $iread, $poverlapped = 0)
1915
	Local $aresult = DllCall("kernel32.dll", "bool", "ReadFile", "handle", $hfile, "ptr", $pbuffer, "dword", $itoread, "dword*", 0, "ptr", $poverlapped)
1916
	If @error Then Return SetError(@error, @extended, False)
1917
	$iread = $aresult[4]
1918
	Return $aresult[0]
1919
EndFunc
1920
1921
Func _winapi_readprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isize, ByRef $iread)
1922
	Local $aresult = DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $hprocess, "ptr", $pbaseaddress, "ptr", $pbuffer, "ulong_ptr", $isize, "ulong_ptr*", 0)
1923
	If @error Then Return SetError(@error, @extended, False)
1924
	$iread = $aresult[5]
1925
	Return $aresult[0]
1926
EndFunc
1927
1928
Func _winapi_rectisempty(ByRef $trect)
1929
	Return (DllStructGetData($trect, "Left") = 0) AND (DllStructGetData($trect, "Top") = 0) AND (DllStructGetData($trect, "Right") = 0) AND (DllStructGetData($trect, "Bottom") = 0)
1930
EndFunc
1931
1932
Func _winapi_redrawwindow($hwnd, $trect = 0, $hregion = 0, $iflags = 5)
1933
	Local $prect = 0
1934
	If $trect <> 0 Then $prect = DllStructGetPtr($trect)
1935
	Local $aresult = DllCall("user32.dll", "bool", "RedrawWindow", "hwnd", $hwnd, "ptr", $prect, "handle", $hregion, "uint", $iflags)
1936
	If @error Then Return SetError(@error, @extended, False)
1937
	Return $aresult[0]
1938
EndFunc
1939
1940
Func _winapi_registerwindowmessage($smessage)
1941
	Local $aresult = DllCall("user32.dll", "uint", "RegisterWindowMessageW", "wstr", $smessage)
1942
	If @error Then Return SetError(@error, @extended, 0)
1943
	Return $aresult[0]
1944
EndFunc
1945
1946
Func _winapi_releasecapture()
1947
	Local $aresult = DllCall("user32.dll", "bool", "ReleaseCapture")
1948
	If @error Then Return SetError(@error, @extended, False)
1949
	Return $aresult[0]
1950
EndFunc
1951
1952
Func _winapi_releasedc($hwnd, $hdc)
1953
	Local $aresult = DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hwnd, "handle", $hdc)
1954
	If @error Then Return SetError(@error, @extended, False)
1955
	Return $aresult[0]
1956
EndFunc
1957
1958
Func _winapi_screentoclient($hwnd, ByRef $tpoint)
1959
	Local $aresult = DllCall("user32.dll", "bool", "ScreenToClient", "hwnd", $hwnd, "ptr", DllStructGetPtr($tpoint))
1960
	If @error Then Return SetError(@error, @extended, False)
1961
	Return $aresult[0]
1962
EndFunc
1963
1964
Func _winapi_selectobject($hdc, $hgdiobj)
1965
	Local $aresult = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hdc, "handle", $hgdiobj)
1966
	If @error Then Return SetError(@error, @extended, False)
1967
	Return $aresult[0]
1968
EndFunc
1969
1970
Func _winapi_setbkcolor($hdc, $icolor)
1971
	Local $aresult = DllCall("gdi32.dll", "INT", "SetBkColor", "handle", $hdc, "dword", $icolor)
1972
	If @error Then Return SetError(@error, @extended, -1)
1973
	Return $aresult[0]
1974
EndFunc
1975
1976
Func _winapi_setbkmode($hdc, $ibkmode)
1977
	Local $aresult = DllCall("gdi32.dll", "int", "SetBkMode", "handle", $hdc, "int", $ibkmode)
1978
	If @error Then Return SetError(@error, @extended, 0)
1979
	Return $aresult[0]
1980
EndFunc
1981
1982
Func _winapi_setcapture($hwnd)
1983
	Local $aresult = DllCall("user32.dll", "hwnd", "SetCapture", "hwnd", $hwnd)
1984
	If @error Then Return SetError(@error, @extended, 0)
1985
	Return $aresult[0]
1986
EndFunc
1987
1988
Func _winapi_setcursor($hcursor)
1989
	Local $aresult = DllCall("user32.dll", "handle", "SetCursor", "handle", $hcursor)
1990
	If @error Then Return SetError(@error, @extended, 0)
1991
	Return $aresult[0]
1992
EndFunc
1993
1994
Func _winapi_setdefaultprinter($sprinter)
1995
	Local $aresult = DllCall("winspool.drv", "bool", "SetDefaultPrinterW", "wstr", $sprinter)
1996
	If @error Then Return SetError(@error, @extended, False)
1997
	Return $aresult[0]
1998
EndFunc
1999
2000
Func _winapi_setdibits($hdc, $hbmp, $istartscan, $iscanlines, $pbits, $pbmi, $icoloruse = 0)
2001
	Local $aresult = DllCall("gdi32.dll", "int", "SetDIBits", "handle", $hdc, "handle", $hbmp, "uint", $istartscan, "uint", $iscanlines, "ptr", $pbits, "ptr", $pbmi, "uint", $icoloruse)
2002
	If @error Then Return SetError(@error, @extended, False)
2003
	Return $aresult[0]
2004
EndFunc
2005
2006
Func _winapi_setendoffile($hfile)
2007
	Local $aresult = DllCall("kernel32.dll", "bool", "SetEndOfFile", "handle", $hfile)
2008
	If @error Then Return SetError(@error, @extended, False)
2009
	Return $aresult[0]
2010
EndFunc
2011
2012
Func _winapi_setevent($hevent)
2013
	Local $aresult = DllCall("kernel32.dll", "bool", "SetEvent", "handle", $hevent)
2014
	If @error Then Return SetError(@error, @extended, False)
2015
	Return $aresult[0]
2016
EndFunc
2017
2018
Func _winapi_setfilepointer($hfile, $ipos, $imethod = 0)
2019
	Local $aresult = DllCall("kernel32.dll", "INT", "SetFilePointer", "handle", $hfile, "long", $ipos, "ptr", 0, "long", $imethod)
2020
	If @error Then Return SetError(@error, @extended, -1)
2021
	Return $aresult[0]
2022
EndFunc
2023
2024
Func _winapi_setfocus($hwnd)
2025
	Local $aresult = DllCall("user32.dll", "hwnd", "SetFocus", "hwnd", $hwnd)
2026
	If @error Then Return SetError(@error, @extended, 0)
2027
	Return $aresult[0]
2028
EndFunc
2029
2030
Func _winapi_setfont($hwnd, $hfont, $fredraw = True)
2031
	_sendmessage($hwnd, $__winapiconstant_wm_setfont, $hfont, $fredraw, 0, "hwnd")
2032
EndFunc
2033
2034
Func _winapi_sethandleinformation($hobject, $imask, $iflags)
2035
	Local $aresult = DllCall("kernel32.dll", "bool", "SetHandleInformation", "handle", $hobject, "dword", $imask, "dword", $iflags)
2036
	If @error Then Return SetError(@error, @extended, False)
2037
	Return $aresult[0]
2038
EndFunc
2039
2040
Func _winapi_setlayeredwindowattributes($hwnd, $i_transcolor, $transparency = 255, $dwflags = 3, $iscolorref = False)
2041
	If $dwflags = Default OR $dwflags = "" OR $dwflags < 0 Then $dwflags = 3
2042
	If NOT $iscolorref Then
2043
		$i_transcolor = Hex(String($i_transcolor), 6)
2044
		$i_transcolor = Execute("0x00" & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
2045
	EndIf
2046
	Local $aresult = DllCall("user32.dll", "bool", "SetLayeredWindowAttributes", "hwnd", $hwnd, "dword", $i_transcolor, "byte", $transparency, "dword", $dwflags)
2047
	If @error Then Return SetError(@error, @extended, False)
2048
	Return $aresult[0]
2049
EndFunc
2050
2051
Func _winapi_setparent($hwndchild, $hwndparent)
2052
	Local $aresult = DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $hwndchild, "hwnd", $hwndparent)
2053
	If @error Then Return SetError(@error, @extended, 0)
2054
	Return $aresult[0]
2055
EndFunc
2056
2057
Func _winapi_setprocessaffinitymask($hprocess, $imask)
2058
	Local $aresult = DllCall("kernel32.dll", "bool", "SetProcessAffinityMask", "handle", $hprocess, "ulong_ptr", $imask)
2059
	If @error Then Return SetError(@error, @extended, False)
2060
	Return $aresult[0]
2061
EndFunc
2062
2063
Func _winapi_setsyscolors($velements, $vcolors)
2064
	Local $isearray = IsArray($velements), $iscarray = IsArray($vcolors)
2065
	Local $ielementnum
2066
	If NOT $iscarray AND NOT $isearray Then
2067
		$ielementnum = 1
2068
	ElseIf $iscarray OR $isearray Then
2069
		If NOT $iscarray OR NOT $isearray Then Return SetError(-1, -1, False)
2070
		If UBound($velements) <> UBound($vcolors) Then Return SetError(-1, -1, False)
2071
		$ielementnum = UBound($velements)
2072
	EndIf
2073
	Local $telements = DllStructCreate("int Element[" & $ielementnum & "]")
2074
	Local $tcolors = DllStructCreate("dword NewColor[" & $ielementnum & "]")
2075
	Local $pelements = DllStructGetPtr($telements)
2076
	Local $pcolors = DllStructGetPtr($tcolors)
2077
	If NOT $isearray Then
2078
		DllStructSetData($telements, "Element", $velements, 1)
2079
	Else
2080
		For $x = 0 To $ielementnum - 1
2081
			DllStructSetData($telements, "Element", $velements[$x], $x + 1)
2082
		Next
2083
	EndIf
2084
	If NOT $iscarray Then
2085
		DllStructSetData($tcolors, "NewColor", $vcolors, 1)
2086
	Else
2087
		For $x = 0 To $ielementnum - 1
2088
			DllStructSetData($tcolors, "NewColor", $vcolors[$x], $x + 1)
2089
		Next
2090
	EndIf
2091
	Local $aresult = DllCall("user32.dll", "bool", "SetSysColors", "int", $ielementnum, "ptr", $pelements, "ptr", $pcolors)
2092
	If @error Then Return SetError(@error, @extended, False)
2093
	Return $aresult[0]
2094
EndFunc
2095
2096
Func _winapi_settextcolor($hdc, $icolor)
2097
	Local $aresult = DllCall("gdi32.dll", "INT", "SetTextColor", "handle", $hdc, "dword", $icolor)
2098
	If @error Then Return SetError(@error, @extended, -1)
2099
	Return $aresult[0]
2100
EndFunc
2101
2102
Func _winapi_setwindowlong($hwnd, $iindex, $ivalue)
2103
	_winapi_setlasterror(0)
2104
	Local $sfuncname = "SetWindowLongW"
2105
	If @AutoItX64 Then $sfuncname = "SetWindowLongPtrW"
2106
	Local $aresult = DllCall("user32.dll", "long_ptr", $sfuncname, "hwnd", $hwnd, "int", $iindex, "long_ptr", $ivalue)
2107
	If @error Then Return SetError(@error, @extended, 0)
2108
	Return $aresult[0]
2109
EndFunc
2110
2111
Func _winapi_setwindowplacement($hwnd, $pwindowplacement)
2112
	Local $aresult = DllCall("user32.dll", "bool", "SetWindowPlacement", "hwnd", $hwnd, "ptr", $pwindowplacement)
2113
	If @error Then Return SetError(@error, @extended, False)
2114
	Return $aresult[0]
2115
EndFunc
2116
2117
Func _winapi_setwindowpos($hwnd, $hafter, $ix, $iy, $icx, $icy, $iflags)
2118
	Local $aresult = DllCall("user32.dll", "bool", "SetWindowPos", "hwnd", $hwnd, "hwnd", $hafter, "int", $ix, "int", $iy, "int", $icx, "int", $icy, "uint", $iflags)
2119
	If @error Then Return SetError(@error, @extended, False)
2120
	Return $aresult[0]
2121
EndFunc
2122
2123
Func _winapi_setwindowrgn($hwnd, $hrgn, $bredraw = True)
2124
	Local $aresult = DllCall("user32.dll", "int", "SetWindowRgn", "hwnd", $hwnd, "handle", $hrgn, "bool", $bredraw)
2125
	If @error Then Return SetError(@error, @extended, False)
2126
	Return $aresult[0]
2127
EndFunc
2128
2129
Func _winapi_setwindowshookex($idhook, $lpfn, $hmod, $dwthreadid = 0)
2130
	Local $aresult = DllCall("user32.dll", "handle", "SetWindowsHookEx", "int", $idhook, "ptr", $lpfn, "handle", $hmod, "dword", $dwthreadid)
2131
	If @error Then Return SetError(@error, @extended, 0)
2132
	Return $aresult[0]
2133
EndFunc
2134
2135
Func _winapi_setwindowtext($hwnd, $stext)
2136
	Local $aresult = DllCall("user32.dll", "bool", "SetWindowTextW", "hwnd", $hwnd, "wstr", $stext)
2137
	If @error Then Return SetError(@error, @extended, False)
2138
	Return $aresult[0]
2139
EndFunc
2140
2141
Func _winapi_showcursor($fshow)
2142
	Local $aresult = DllCall("user32.dll", "int", "ShowCursor", "bool", $fshow)
2143
	If @error Then Return SetError(@error, @extended, 0)
2144
	Return $aresult[0]
2145
EndFunc
2146
2147
Func _winapi_showerror($stext, $fexit = True)
2148
	_winapi_msgbox(266256, "Error", $stext)
2149
	If $fexit Then Exit 
2150
EndFunc
2151
2152
Func _winapi_showmsg($stext)
2153
	_winapi_msgbox(64 + 4096, "Information", $stext)
2154
EndFunc
2155
2156
Func _winapi_showwindow($hwnd, $icmdshow = 5)
2157
	Local $aresult = DllCall("user32.dll", "bool", "ShowWindow", "hwnd", $hwnd, "int", $icmdshow)
2158
	If @error Then Return SetError(@error, @extended, False)
2159
	Return $aresult[0]
2160
EndFunc
2161
2162
Func _winapi_stringfromguid($pguid)
2163
	Local $aresult = DllCall("ole32.dll", "int", "StringFromGUID2", "ptr", $pguid, "wstr", "", "int", 40)
2164
	If @error Then Return SetError(@error, @extended, "")
2165
	Return SetExtended($aresult[0], $aresult[2])
2166
EndFunc
2167
2168
Func _winapi_sublangid($lgid)
2169
	Return BitShift($lgid, 10)
2170
EndFunc
2171
2172
Func _winapi_systemparametersinfo($iaction, $iparam = 0, $vparam = 0, $iwinini = 0)
2173
	Local $aresult = DllCall("user32.dll", "bool", "SystemParametersInfoW", "uint", $iaction, "uint", $iparam, "ptr", $vparam, "uint", $iwinini)
2174
	If @error Then Return SetError(@error, @extended, False)
2175
	Return $aresult[0]
2176
EndFunc
2177
2178
Func _winapi_twipsperpixelx()
2179
	Local $lngdc, $twipsperpixelx
2180
	$lngdc = _winapi_getdc(0)
2181
	$twipsperpixelx = 1440 / _winapi_getdevicecaps($lngdc, $__winapiconstant_logpixelsx)
2182
	_winapi_releasedc(0, $lngdc)
2183
	Return $twipsperpixelx
2184
EndFunc
2185
2186
Func _winapi_twipsperpixely()
2187
	Local $lngdc, $twipsperpixely
2188
	$lngdc = _winapi_getdc(0)
2189
	$twipsperpixely = 1440 / _winapi_getdevicecaps($lngdc, $__winapiconstant_logpixelsy)
2190
	_winapi_releasedc(0, $lngdc)
2191
	Return $twipsperpixely
2192
EndFunc
2193
2194
Func _winapi_unhookwindowshookex($hhk)
2195
	Local $aresult = DllCall("user32.dll", "bool", "UnhookWindowsHookEx", "handle", $hhk)
2196
	If @error Then Return SetError(@error, @extended, False)
2197
	Return $aresult[0]
2198
EndFunc
2199
2200
Func _winapi_updatelayeredwindow($hwnd, $hdcdest, $pptdest, $psize, $hdcsrce, $pptsrce, $irgb, $pblend, $iflags)
2201
	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)
2202
	If @error Then Return SetError(@error, @extended, False)
2203
	Return $aresult[0]
2204
EndFunc
2205
2206
Func _winapi_updatewindow($hwnd)
2207
	Local $aresult = DllCall("user32.dll", "bool", "UpdateWindow", "hwnd", $hwnd)
2208
	If @error Then Return SetError(@error, @extended, False)
2209
	Return $aresult[0]
2210
EndFunc
2211
2212
Func _winapi_waitforinputidle($hprocess, $itimeout = -1)
2213
	Local $aresult = DllCall("user32.dll", "dword", "WaitForInputIdle", "handle", $hprocess, "dword", $itimeout)
2214
	If @error Then Return SetError(@error, @extended, False)
2215
	Return $aresult[0]
2216
EndFunc
2217
2218
Func _winapi_waitformultipleobjects($icount, $phandles, $fwaitall = False, $itimeout = -1)
2219
	Local $aresult = DllCall("kernel32.dll", "INT", "WaitForMultipleObjects", "dword", $icount, "ptr", $phandles, "bool", $fwaitall, "dword", $itimeout)
2220
	If @error Then Return SetError(@error, @extended, -1)
2221
	Return $aresult[0]
2222
EndFunc
2223
2224
Func _winapi_waitforsingleobject($hhandle, $itimeout = -1)
2225
	Local $aresult = DllCall("kernel32.dll", "INT", "WaitForSingleObject", "handle", $hhandle, "dword", $itimeout)
2226
	If @error Then Return SetError(@error, @extended, -1)
2227
	Return $aresult[0]
2228
EndFunc
2229
2230
Func _winapi_widechartomultibyte($punicode, $icodepage = 0, $bretstring = True)
2231
	Local $sunicodetype = "ptr"
2232
	If IsDllStruct($punicode) Then
2233
		$punicode = DllStructGetPtr($punicode)
2234
	Else
2235
		If NOT IsPtr($punicode) Then $sunicodetype = "wstr"
2236
	EndIf
2237
	Local $aresult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $icodepage, "dword", 0, $sunicodetype, $punicode, "int", -1, "ptr", 0, "int", 0, "ptr", 0, "ptr", 0)
2238
	If @error Then Return SetError(@error, @extended, "")
2239
	Local $tmultibyte = DllStructCreate("char[" & $aresult[0] & "]")
2240
	Local $pmultibyte = DllStructGetPtr($tmultibyte)
2241
	$aresult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $icodepage, "dword", 0, $sunicodetype, $punicode, "int", -1, "ptr", $pmultibyte, "int", $aresult[0], "ptr", 0, "ptr", 0)
2242
	If @error Then Return SetError(@error, @extended, "")
2243
	If $bretstring Then Return DllStructGetData($tmultibyte, 1)
2244
	Return $tmultibyte
2245
EndFunc
2246
2247
Func _winapi_windowfrompoint(ByRef $tpoint)
2248
	Local $tpointcast = DllStructCreate("int64", DllStructGetPtr($tpoint))
2249
	Local $aresult = DllCall("user32.dll", "hwnd", "WindowFromPoint", "int64", DllStructGetData($tpointcast, 1))
2250
	If @error Then Return SetError(@error, @extended, 0)
2251
	Return $aresult[0]
2252
EndFunc
2253
2254
Func _winapi_writeconsole($hconsole, $stext)
2255
	Local $aresult = DllCall("kernel32.dll", "bool", "WriteConsoleW", "handle", $hconsole, "wstr", $stext, "dword", StringLen($stext), "dword*", 0, "ptr", 0)
2256
	If @error Then Return SetError(@error, @extended, False)
2257
	Return $aresult[0]
2258
EndFunc
2259
2260
Func _winapi_writefile($hfile, $pbuffer, $itowrite, ByRef $iwritten, $poverlapped = 0)
2261
	Local $aresult = DllCall("kernel32.dll", "bool", "WriteFile", "handle", $hfile, "ptr", $pbuffer, "dword", $itowrite, "dword*", 0, "ptr", $poverlapped)
2262
	If @error Then Return SetError(@error, @extended, False)
2263
	$iwritten = $aresult[4]
2264
	Return $aresult[0]
2265
EndFunc
2266
2267
Func _winapi_writeprocessmemory($hprocess, $pbaseaddress, $pbuffer, $isize, ByRef $iwritten, $sbuffer = "ptr")
2268
	Local $aresult = DllCall("kernel32.dll", "bool", "WriteProcessMemory", "handle", $hprocess, "ptr", $pbaseaddress, $sbuffer, $pbuffer, "ulong_ptr", $isize, "ulong_ptr*", 0)
2269
	If @error Then Return SetError(@error, @extended, False)
2270
	$iwritten = $aresult[5]
2271
	Return $aresult[0]
2272
EndFunc
2273
2274
Global Const $fw_dontcare = 0
2275
Global Const $fw_thin = 100
2276
Global Const $fw_extralight = 200
2277
Global Const $fw_ultralight = 200
2278
Global Const $fw_light = 300
2279
Global Const $fw_normal = 400
2280
Global Const $fw_regular = 400
2281
Global Const $fw_medium = 500
2282
Global Const $fw_semibold = 600
2283
Global Const $fw_demibold = 600
2284
Global Const $fw_bold = 700
2285
Global Const $fw_extrabold = 800
2286
Global Const $fw_ultrabold = 800
2287
Global Const $fw_heavy = 900
2288
Global Const $fw_black = 900
2289
Global Const $cf_effects = 256
2290
Global Const $cf_printerfonts = 2
2291
Global Const $cf_screenfonts = 1
2292
Global Const $cf_noscriptsel = 8388608
2293
Global Const $cf_inittologfontstruct = 64
2294
Global Const $logpixelsx = 88
2295
Global Const $logpixelsy = 90
2296
Global Const $ansi_charset = 0
2297
Global Const $baltic_charset = 186
2298
Global Const $chinesebig5_charset = 136
2299
Global Const $default_charset = 1
2300
Global Const $easteurope_charset = 238
2301
Global Const $gb2312_charset = 134
2302
Global Const $greek_charset = 161
2303
Global Const $hangeul_charset = 129
2304
Global Const $mac_charset = 77
2305
Global Const $oem_charset = 255
2306
Global Const $russian_charset = 204
2307
Global Const $shiftjis_charset = 128
2308
Global Const $symbol_charset = 2
2309
Global Const $turkish_charset = 162
2310
Global Const $vietnamese_charset = 163
2311
Global Const $out_character_precis = 2
2312
Global Const $out_default_precis = 0
2313
Global Const $out_device_precis = 5
2314
Global Const $out_outline_precis = 8
2315
Global Const $out_ps_only_precis = 10
2316
Global Const $out_raster_precis = 6
2317
Global Const $out_string_precis = 1
2318
Global Const $out_stroke_precis = 3
2319
Global Const $out_tt_only_precis = 7
2320
Global Const $out_tt_precis = 4
2321
Global Const $clip_character_precis = 1
2322
Global Const $clip_default_precis = 0
2323
Global Const $clip_embedded = 128
2324
Global Const $clip_lh_angles = 16
2325
Global Const $clip_mask = 15
2326
Global Const $clip_stroke_precis = 2
2327
Global Const $clip_tt_always = 32
2328
Global Const $antialiased_quality = 4
2329
Global Const $default_quality = 0
2330
Global Const $draft_quality = 1
2331
Global Const $nonantialiased_quality = 3
2332
Global Const $proof_quality = 2
2333
Global Const $default_pitch = 0
2334
Global Const $fixed_pitch = 1
2335
Global Const $variable_pitch = 2
2336
Global Const $ff_decorative = 80
2337
Global Const $ff_dontcare = 0
2338
Global Const $ff_modern = 48
2339
Global Const $ff_roman = 16
2340
Global Const $ff_script = 64
2341
Global Const $ff_swiss = 32
2342
Global Const $__miscconstant_cc_anycolor = 256
2343
Global Const $__miscconstant_cc_fullopen = 2
2344
Global Const $__miscconstant_cc_rgbinit = 1
2345
Global Const $tagchoosecolor = "dword Size;hwnd hWndOwnder;handle hInstance;dword rgbResult;ptr CustColors;dword Flags;lparam lCustData;" & "ptr lpfnHook;ptr lpTemplateName"
2346
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"
2347
2348
Func _choosecolor($ireturntype = 0, $icolorref = 0, $ireftype = 0, $hwndownder = 0)
2349
	Local $custcolors = "dword[16]"
2350
	Local $tchoose = DllStructCreate($tagchoosecolor)
2351
	Local $tcc = DllStructCreate($custcolors)
2352
	If $ireftype = 1 Then
2353
		$icolorref = Int($icolorref)
2354
	ElseIf $ireftype = 2 Then
2355
		$icolorref = Hex(String($icolorref), 6)
2356
		$icolorref = "0x" & StringMid($icolorref, 5, 2) & StringMid($icolorref, 3, 2) & StringMid($icolorref, 1, 2)
2357
	EndIf
2358
	DllStructSetData($tchoose, "Size", DllStructGetSize($tchoose))
2359
	DllStructSetData($tchoose, "hWndOwnder", $hwndownder)
2360
	DllStructSetData($tchoose, "rgbResult", $icolorref)
2361
	DllStructSetData($tchoose, "CustColors", DllStructGetPtr($tcc))
2362
	DllStructSetData($tchoose, "Flags", BitOR($__miscconstant_cc_anycolor, $__miscconstant_cc_fullopen, $__miscconstant_cc_rgbinit))
2363
	Local $aresult = DllCall("comdlg32.dll", "bool", "ChooseColor", "ptr", DllStructGetPtr($tchoose))
2364
	If @error Then Return SetError(@error, @extended, -1)
2365
	If $aresult[0] = 0 Then Return SetError(-3, -3, -1)
2366
	Local $color_picked = DllStructGetData($tchoose, "rgbResult")
2367
	If $ireturntype = 1 Then
2368
		Return "0x" & Hex(String($color_picked), 6)
2369
	ElseIf $ireturntype = 2 Then
2370
		$color_picked = Hex(String($color_picked), 6)
2371
		Return "0x" & StringMid($color_picked, 5, 2) & StringMid($color_picked, 3, 2) & StringMid($color_picked, 1, 2)
2372
	ElseIf $ireturntype = 0 Then
2373
		Return $color_picked
2374
	Else
2375
		Return SetError(-4, -4, -1)
2376
	EndIf
2377
EndFunc
2378
2379
Func _choosefont($sfontname = "Courier New", $ipointsize = 10, $icolorref = 0, $ifontweight = 0, $iitalic = False, $iunderline = False, $istrikethru = False, $hwndowner = 0)
2380
	Local $italic = 0, $underline = 0, $strikeout = 0
2381
	Local $lngdc = __misc_getdc(0)
2382
	Local $lfheight = Round(($ipointsize * __misc_getdevicecaps($lngdc, $logpixelsx)) / 72, 0)
2383
	__misc_releasedc(0, $lngdc)
2384
	Local $tchoosefont = DllStructCreate($tagchoosefont)
2385
	Local $tlogfont = DllStructCreate($taglogfont)
2386
	DllStructSetData($tchoosefont, "Size", DllStructGetSize($tchoosefont))
2387
	DllStructSetData($tchoosefont, "hWndOwner", $hwndowner)
2388
	DllStructSetData($tchoosefont, "LogFont", DllStructGetPtr($tlogfont))
2389
	DllStructSetData($tchoosefont, "PointSize", $ipointsize)
2390
	DllStructSetData($tchoosefont, "Flags", BitOR($cf_screenfonts, $cf_printerfonts, $cf_effects, $cf_inittologfontstruct, $cf_noscriptsel))
2391
	DllStructSetData($tchoosefont, "rgbColors", $icolorref)
2392
	DllStructSetData($tchoosefont, "FontType", 0)
2393
	DllStructSetData($tlogfont, "Height", $lfheight)
2394
	DllStructSetData($tlogfont, "Weight", $ifontweight)
2395
	DllStructSetData($tlogfont, "Italic", $iitalic)
2396
	DllStructSetData($tlogfont, "Underline", $iunderline)
2397
	DllStructSetData($tlogfont, "Strikeout", $istrikethru)
2398
	DllStructSetData($tlogfont, "FaceName", $sfontname)
2399
	Local $aresult = DllCall("comdlg32.dll", "bool", "ChooseFontW", "ptr", DllStructGetPtr($tchoosefont))
2400
	If @error Then Return SetError(@error, @extended, -1)
2401
	If $aresult[0] = 0 Then Return SetError(-3, -3, -1)
2402
	Local $fontname = DllStructGetData($tlogfont, "FaceName")
2403
	If StringLen($fontname) = 0 AND StringLen($sfontname) > 0 Then $fontname = $sfontname
2404
	If DllStructGetData($tlogfont, "Italic") Then $italic = 2
2405
	If DllStructGetData($tlogfont, "Underline") Then $underline = 4
2406
	If DllStructGetData($tlogfont, "Strikeout") Then $strikeout = 8
2407
	Local $attributes = BitOR($italic, $underline, $strikeout)
2408
	Local $size = DllStructGetData($tchoosefont, "PointSize") / 10
2409
	Local $colorref = DllStructGetData($tchoosefont, "rgbColors")
2410
	Local $weight = DllStructGetData($tlogfont, "Weight")
2411
	Local $color_picked = Hex(String($colorref), 6)
2412
	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), ",")
2413
EndFunc
2414
2415
Func _clipputfile($sfile, $sseparator = "|")
2416
	Local Const $gmem_moveable = 2, $cf_hdrop = 15
2417
	$sfile &= $sseparator & $sseparator
2418
	Local $nglobmemsize = (StringLen($sfile) + 20)
2419
	Local $aresult = DllCall("user32.dll", "bool", "OpenClipboard", "hwnd", 0)
2420
	If @error OR $aresult[0] = 0 Then Return SetError(1, _winapi_getlasterror(), False)
2421
	Local $ierror = 0, $ilasterror = 0
2422
	$aresult = DllCall("user32.dll", "bool", "EmptyClipboard")
2423
	If @error OR NOT $aresult[0] Then
2424
		$ierror = 2
2425
		$ilasterror = _winapi_getlasterror()
2426
	Else
2427
		$aresult = DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", $gmem_moveable, "ulong_ptr", $nglobmemsize)
2428
		If @error OR NOT $aresult[0] Then
2429
			$ierror = 3
2430
			$ilasterror = _winapi_getlasterror()
2431
		Else
2432
			Local $hglobal = $aresult[0]
2433
			$aresult = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", $hglobal)
2434
			If @error OR NOT $aresult[0] Then
2435
				$ierror = 4
2436
				$ilasterror = _winapi_getlasterror()
2437
			Else
2438
				Local $hlock = $aresult[0]
2439
				Local $dropfiles = DllStructCreate("dword;ptr;int;int;int;char[" & StringLen($sfile) + 1 & "]", $hlock)
2440
				If @error Then Return SetError(5, 6, False)
2441
				Local $tempstruct = DllStructCreate("dword;ptr;int;int;int")
2442
				DllStructSetData($dropfiles, 1, DllStructGetSize($tempstruct))
2443
				DllStructSetData($dropfiles, 2, 0)
2444
				DllStructSetData($dropfiles, 3, 0)
2445
				DllStructSetData($dropfiles, 4, 0)
2446
				DllStructSetData($dropfiles, 5, 0)
2447
				DllStructSetData($dropfiles, 6, $sfile)
2448
				For $i = 1 To StringLen($sfile)
2449
					If DllStructGetData($dropfiles, 6, $i) = $sseparator Then DllStructSetData($dropfiles, 6, Chr(0), $i)
2450
				Next
2451
				$aresult = DllCall("user32.dll", "handle", "SetClipboardData", "uint", $cf_hdrop, "handle", $hglobal)
2452
				If @error OR NOT $aresult[0] Then
2453
					$ierror = 6
2454
					$ilasterror = _winapi_getlasterror()
2455
				EndIf
2456
				$aresult = DllCall("kernel32.dll", "bool", "GlobalUnlock", "handle", $hglobal)
2457
				If (@error OR NOT $aresult[0]) AND NOT $ierror AND _winapi_getlasterror() Then
2458
					$ierror = 8
2459
					$ilasterror = _winapi_getlasterror()
2460
				EndIf
2461
			EndIf
2462
			$aresult = DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", $hglobal)
2463
			If (@error OR NOT $aresult[0]) AND NOT $ierror Then
2464
				$ierror = 9
2465
				$ilasterror = _winapi_getlasterror()
2466
			EndIf
2467
		EndIf
2468
	EndIf
2469
	$aresult = DllCall("user32.dll", "bool", "CloseClipboard")
2470
	If (@error OR NOT $aresult[0]) AND NOT $ierror Then Return SetError(7, _winapi_getlasterror(), False)
2471
	If $ierror Then Return SetError($ierror, $ilasterror, False)
2472
	Return True
2473
EndFunc
2474
2475
Func _iif($ftest, $vtrueval, $vfalseval)
2476
	If $ftest Then
2477
		Return $vtrueval
2478
	Else
2479
		Return $vfalseval
2480
	EndIf
2481
EndFunc
2482
2483
Func _mousetrap($ileft = 0, $itop = 0, $iright = 0, $ibottom = 0)
2484
	Local $aresult
2485
	If @NumParams == 0 Then
2486
		$aresult = DllCall("user32.dll", "bool", "ClipCursor", "ptr", 0)
2487
		If @error OR NOT $aresult[0] Then Return SetError(1, _winapi_getlasterror(), False)
2488
	Else
2489
		If @NumParams == 2 Then
2490
			$iright = $ileft + 1
2491
			$ibottom = $itop + 1
2492
		EndIf
2493
		Local $trect = DllStructCreate($tagrect)
2494
		DllStructSetData($trect, "Left", $ileft)
2495
		DllStructSetData($trect, "Top", $itop)
2496
		DllStructSetData($trect, "Right", $iright)
2497
		DllStructSetData($trect, "Bottom", $ibottom)
2498
		$aresult = DllCall("user32.dll", "bool", "ClipCursor", "ptr", DllStructGetPtr($trect))
2499
		If @error OR NOT $aresult[0] Then Return SetError(2, _winapi_getlasterror(), False)
2500
	EndIf
2501
	Return True
2502
EndFunc
2503
2504
Func _singleton($soccurencename, $iflag = 0)
2505
	Local Const $error_already_exists = 183
2506
	Local Const $security_descriptor_revision = 1
2507
	Local $psecurityattributes = 0
2508
	If BitAND($iflag, 2) Then
2509
		Local $tsecuritydescriptor = DllStructCreate("dword[5]")
2510
		Local $psecuritydescriptor = DllStructGetPtr($tsecuritydescriptor)
2511
		Local $aret = DllCall("advapi32.dll", "bool", "InitializeSecurityDescriptor", "ptr", $psecuritydescriptor, "dword", $security_descriptor_revision)
2512
		If @error Then Return SetError(@error, @extended, 0)
2513
		If $aret[0] Then
2514
			$aret = DllCall("advapi32.dll", "bool", "SetSecurityDescriptorDacl", "ptr", $psecuritydescriptor, "bool", 1, "ptr", 0, "bool", 0)
2515
			If @error Then Return SetError(@error, @extended, 0)
2516
			If $aret[0] Then
2517
				Local $structsecurityattributes = DllStructCreate($tagsecurity_attributes)
2518
				DllStructSetData($structsecurityattributes, 1, DllStructGetSize($structsecurityattributes))
2519
				DllStructSetData($structsecurityattributes, 2, $psecuritydescriptor)
2520
				DllStructSetData($structsecurityattributes, 3, 0)
2521
				$psecurityattributes = DllStructGetPtr($structsecurityattributes)
2522
			EndIf
2523
		EndIf
2524
	EndIf
2525
	Local $handle = DllCall("kernel32.dll", "handle", "CreateMutexW", "ptr", $psecurityattributes, "bool", 1, "wstr", $soccurencename)
2526
	If @error Then Return SetError(@error, @extended, 0)
2527
	Local $lasterror = DllCall("kernel32.dll", "dword", "GetLastError")
2528
	If @error Then Return SetError(@error, @extended, 0)
2529
	If $lasterror[0] = $error_already_exists Then
2530
		If BitAND($iflag, 1) Then
2531
			Return SetError($lasterror[0], $lasterror[0], 0)
2532
		Else
2533
			Exit  - 1
2534
		EndIf
2535
	EndIf
2536
	Return $handle[0]
2537
EndFunc
2538
2539
Func _ispressed($shexkey, $vdll = "user32.dll")
2540
	Local $a_r = DllCall($vdll, "short", "GetAsyncKeyState", "int", "0x" & $shexkey)
2541
	If @error Then Return SetError(@error, @extended, False)
2542
	Return BitAND($a_r[0], 32768) <> 0
2543
EndFunc
2544
2545
Func _versioncompare($sversion1, $sversion2)
2546
	If $sversion1 = $sversion2 Then Return 0
2547
	Local $sep = "."
2548
	If StringInStr($sversion1, $sep) = 0 Then $sep = ","
2549
	Local $aversion1 = StringSplit($sversion1, $sep)
2550
	Local $aversion2 = StringSplit($sversion2, $sep)
2551
	If UBound($aversion1) <> UBound($aversion2) OR UBound($aversion1) = 0 Then
2552
		SetExtended(1)
2553
		If $sversion1 > $sversion2 Then
2554
			Return 1
2555
		ElseIf $sversion1 < $sversion2 Then
2556
			Return  - 1
2557
		EndIf
2558
	Else
2559
		For $i = 1 To UBound($aversion1) - 1
2560
			If StringIsDigit($aversion1[$i]) AND StringIsDigit($aversion2[$i]) Then
2561
				If Number($aversion1[$i]) > Number($aversion2[$i]) Then
2562
					Return 1
2563
				ElseIf Number($aversion1[$i]) < Number($aversion2[$i]) Then
2564
					Return  - 1
2565
				EndIf
2566
			Else
2567
				SetExtended(1)
2568
				If $aversion1[$i] > $aversion2[$i] Then
2569
					Return 1
2570
				ElseIf $aversion1[$i] < $aversion2[$i] Then
2571
					Return  - 1
2572
				EndIf
2573
			EndIf
2574
		Next
2575
	EndIf
2576
	Return SetError(2, 0, 0)
2577
EndFunc
2578
2579
Func __misc_getdc($hwnd)
2580
	Local $aresult = DllCall("User32.dll", "handle", "GetDC", "hwnd", $hwnd)
2581
	If @error OR NOT $aresult[0] Then Return SetError(1, _winapi_getlasterror(), 0)
2582
	Return $aresult[0]
2583
EndFunc
2584
2585
Func __misc_getdevicecaps($hdc, $iindex)
2586
	Local $aresult = DllCall("GDI32.dll", "int", "GetDeviceCaps", "handle", $hdc, "int", $iindex)
2587
	If @error Then Return SetError(@error, @extended, 0)
2588
	Return $aresult[0]
2589
EndFunc
2590
2591
Func __misc_releasedc($hwnd, $hdc)
2592
	Local $aresult = DllCall("User32.dll", "int", "ReleaseDC", "hwnd", $hwnd, "handle", $hdc)
2593
	If @error Then Return SetError(@error, @extended, False)
2594
	Return $aresult[0] <> 0
2595
EndFunc
2596
2597
Global Const $bs_groupbox = 7
2598
Global Const $bs_bottom = 2048
2599
Global Const $bs_center = 768
2600
Global Const $bs_defpushbutton = 1
2601
Global Const $bs_left = 256
2602
Global Const $bs_multiline = 8192
2603
Global Const $bs_pushbox = 10
2604
Global Const $bs_pushlike = 4096
2605
Global Const $bs_right = 512
2606
Global Const $bs_rightbutton = 32
2607
Global Const $bs_top = 1024
2608
Global Const $bs_vcenter = 3072
2609
Global Const $bs_flat = 32768
2610
Global Const $bs_icon = 64
2611
Global Const $bs_bitmap = 128
2612
Global Const $bs_notify = 16384
2613
Global Const $bs_splitbutton = 12
2614
Global Const $bs_defsplitbutton = 13
2615
Global Const $bs_commandlink = 14
2616
Global Const $bs_defcommandlink = 15
2617
Global Const $bcsif_glyph = 1
2618
Global Const $bcsif_image = 2
2619
Global Const $bcsif_style = 4
2620
Global Const $bcsif_size = 8
2621
Global Const $bcss_nosplit = 1
2622
Global Const $bcss_stretch = 2
2623
Global Const $bcss_alignleft = 4
2624
Global Const $bcss_image = 8
2625
Global Const $button_imagelist_align_left = 0
2626
Global Const $button_imagelist_align_right = 1
2627
Global Const $button_imagelist_align_top = 2
2628
Global Const $button_imagelist_align_bottom = 3
2629
Global Const $button_imagelist_align_center = 4
2630
Global Const $bs_3state = 5
2631
Global Const $bs_auto3state = 6
2632
Global Const $bs_autocheckbox = 3
2633
Global Const $bs_checkbox = 2
2634
Global Const $bs_radiobutton = 4
2635
Global Const $bs_autoradiobutton = 9
2636
Global Const $bs_ownerdraw = 11
2637
Global Const $gui_ss_default_button = 0
2638
Global Const $gui_ss_default_checkbox = 0
2639
Global Const $gui_ss_default_group = 0
2640
Global Const $gui_ss_default_radio = 0
2641
Global Const $bcm_first = 5632
2642
Global Const $bcm_getidealsize = ($bcm_first + 1)
2643
Global Const $bcm_getimagelist = ($bcm_first + 3)
2644
Global Const $bcm_getnote = ($bcm_first + 10)
2645
Global Const $bcm_getnotelength = ($bcm_first + 11)
2646
Global Const $bcm_getsplitinfo = ($bcm_first + 8)
2647
Global Const $bcm_gettextmargin = ($bcm_first + 5)
2648
Global Const $bcm_setdropdownstate = ($bcm_first + 6)
2649
Global Const $bcm_setimagelist = ($bcm_first + 2)
2650
Global Const $bcm_setnote = ($bcm_first + 9)
2651
Global Const $bcm_setshield = ($bcm_first + 12)
2652
Global Const $bcm_setsplitinfo = ($bcm_first + 7)
2653
Global Const $bcm_settextmargin = ($bcm_first + 4)
2654
Global Const $bm_click = 245
2655
Global Const $bm_getcheck = 240
2656
Global Const $bm_getimage = 246
2657
Global Const $bm_getstate = 242
2658
Global Const $bm_setcheck = 241
2659
Global Const $bm_setdontclick = 248
2660
Global Const $bm_setimage = 247
2661
Global Const $bm_setstate = 243
2662
Global Const $bm_setstyle = 244
2663
Global Const $bcn_first = -1250
2664
Global Const $bcn_dropdown = ($bcn_first + 2)
2665
Global Const $bcn_hotitemchange = ($bcn_first + 1)
2666
Global Const $bn_clicked = 0
2667
Global Const $bn_paint = 1
2668
Global Const $bn_hilite = 2
2669
Global Const $bn_unhilite = 3
2670
Global Const $bn_disable = 4
2671
Global Const $bn_doubleclicked = 5
2672
Global Const $bn_setfocus = 6
2673
Global Const $bn_killfocus = 7
2674
Global Const $bn_pushed = $bn_hilite
2675
Global Const $bn_unpushed = $bn_unhilite
2676
Global Const $bn_dblclk = $bn_doubleclicked
2677
Global Const $bst_checked = 1
2678
Global Const $bst_indeterminate = 2
2679
Global Const $bst_unchecked = 0
2680
Global Const $bst_focus = 8
2681
Global Const $bst_pushed = 4
2682
Global Const $bst_dontclick = 128
2683
Global Const $gui_event_close = -3
2684
Global Const $gui_event_minimize = -4
2685
Global Const $gui_event_restore = -5
2686
Global Const $gui_event_maximize = -6
2687
Global Const $gui_event_primarydown = -7
2688
Global Const $gui_event_primaryup = -8
2689
Global Const $gui_event_secondarydown = -9
2690
Global Const $gui_event_secondaryup = -10
2691
Global Const $gui_event_mousemove = -11
2692
Global Const $gui_event_resized = -12
2693
Global Const $gui_event_dropped = -13
2694
Global Const $gui_rundefmsg = "GUI_RUNDEFMSG"
2695
Global Const $gui_avistop = 0
2696
Global Const $gui_avistart = 1
2697
Global Const $gui_aviclose = 2
2698
Global Const $gui_checked = 1
2699
Global Const $gui_indeterminate = 2
2700
Global Const $gui_unchecked = 4
2701
Global Const $gui_dropaccepted = 8
2702
Global Const $gui_nodropaccepted = 4096
2703
Global Const $gui_acceptfiles = $gui_dropaccepted
2704
Global Const $gui_show = 16
2705
Global Const $gui_hide = 32
2706
Global Const $gui_enable = 64
2707
Global Const $gui_disable = 128
2708
Global Const $gui_focus = 256
2709
Global Const $gui_nofocus = 8192
2710
Global Const $gui_defbutton = 512
2711
Global Const $gui_expand = 1024
2712
Global Const $gui_ontop = 2048
2713
Global Const $gui_fontitalic = 2
2714
Global Const $gui_fontunder = 4
2715
Global Const $gui_fontstrike = 8
2716
Global Const $gui_dockauto = 1
2717
Global Const $gui_dockleft = 2
2718
Global Const $gui_dockright = 4
2719
Global Const $gui_dockhcenter = 8
2720
Global Const $gui_docktop = 32
2721
Global Const $gui_dockbottom = 64
2722
Global Const $gui_dockvcenter = 128
2723
Global Const $gui_dockwidth = 256
2724
Global Const $gui_dockheight = 512
2725
Global Const $gui_docksize = 768
2726
Global Const $gui_dockmenubar = 544
2727
Global Const $gui_dockstatebar = 576
2728
Global Const $gui_dockall = 802
2729
Global Const $gui_dockborders = 102
2730
Global Const $gui_gr_close = 1
2731
Global Const $gui_gr_line = 2
2732
Global Const $gui_gr_bezier = 4
2733
Global Const $gui_gr_move = 6
2734
Global Const $gui_gr_color = 8
2735
Global Const $gui_gr_rect = 10
2736
Global Const $gui_gr_ellipse = 12
2737
Global Const $gui_gr_pie = 14
2738
Global Const $gui_gr_dot = 16
2739
Global Const $gui_gr_pixel = 18
2740
Global Const $gui_gr_hint = 20
2741
Global Const $gui_gr_refresh = 22
2742
Global Const $gui_gr_pensize = 24
2743
Global Const $gui_gr_nobkcolor = -2
2744
Global Const $gui_bkcolor_default = -1
2745
Global Const $gui_bkcolor_transparent = -2
2746
Global Const $gui_bkcolor_lv_alternate = -33554432
2747
Global Const $gui_ws_ex_parentdrag = 1048576
2748
Global Const $process_terminate = 1
2749
Global Const $process_create_thread = 2
2750
Global Const $process_set_sessionid = 4
2751
Global Const $process_vm_operation = 8
2752
Global Const $process_vm_read = 16
2753
Global Const $process_vm_write = 32
2754
Global Const $process_dup_handle = 64
2755
Global Const $process_create_process = 128
2756
Global Const $process_set_quota = 256
2757
Global Const $process_set_information = 512
2758
Global Const $process_query_information = 1024
2759
Global Const $process_suspend_resume = 2048
2760
Global Const $process_all_access = 2035711
2761
Global Const $ddl_archive = 32
2762
Global Const $ddl_directory = 16
2763
Global Const $ddl_drives = 16384
2764
Global Const $ddl_exclusive = 32768
2765
Global Const $ddl_hidden = 2
2766
Global Const $ddl_readonly = 1
2767
Global Const $ddl_readwrite = 0
2768
Global Const $ddl_system = 4
2769
Global Const $color_aqua = 65535
2770
Global Const $color_black = 0
2771
Global Const $color_blue = 255
2772
Global Const $color_cream = 16776176
2773
Global Const $color_fuchsia = 16711935
2774
Global Const $color_gray = 8421504
2775
Global Const $color_green = 32768
2776
Global Const $color_lime = 65280
2777
Global Const $color_maroon = 9116770
2778
Global Const $color_medblue = 708
2779
Global Const $color_medgray = 10526884
2780
Global Const $color_moneygreen = 12639424
2781
Global Const $color_navy = 128
2782
Global Const $color_olive = 8421376
2783
Global Const $color_purple = 8388736
2784
Global Const $color_red = 16711680
2785
Global Const $color_silver = 12632256
2786
Global Const $color_skyblue = 10930928
2787
Global Const $color_teal = 32896
2788
Global Const $color_white = 16777215
2789
Global Const $color_yellow = 16776960
2790
Global Const $clr_none = -1
2791
Global Const $clr_default = -16777216
2792
Global Const $clr_aqua = 16776960
2793
Global Const $clr_black = 0
2794
Global Const $clr_blue = 16711680
2795
Global Const $clr_cream = 15793151
2796
Global Const $clr_fuchsia = 16711935
2797
Global Const $clr_gray = 8421504
2798
Global Const $clr_green = 32768
2799
Global Const $clr_lime = 65280
2800
Global Const $clr_maroon = 6429835
2801
Global Const $clr_medblue = 12845568
2802
Global Const $clr_medgray = 10789024
2803
Global Const $clr_moneygreen = 12639424
2804
Global Const $clr_navy = 8388608
2805
Global Const $clr_olive = 32896
2806
Global Const $clr_purple = 8388736
2807
Global Const $clr_red = 255
2808
Global Const $clr_silver = 12632256
2809
Global Const $clr_skyblue = 15780518
2810
Global Const $clr_teal = 8421376
2811
Global Const $clr_white = 16777215
2812
Global Const $clr_yellow = 65535
2813
Global Const $cc_anycolor = 256
2814
Global Const $cc_fullopen = 2
2815
Global Const $cc_rgbinit = 1
2816
Global Const $opt_coordsrelative = 0
2817
Global Const $opt_coordsabsolute = 1
2818
Global Const $opt_coordsclient = 2
2819
Global Const $opt_errorsilent = 0
2820
Global Const $opt_errorfatal = 1
2821
Global Const $opt_capsnostore = 0
2822
Global Const $opt_capsstore = 1
2823
Global Const $opt_matchstart = 1
2824
Global Const $opt_matchany = 2
2825
Global Const $opt_matchexact = 3
2826
Global Const $opt_matchadvanced = 4
2827
Global Const $ccs_top = 1
2828
Global Const $ccs_nomovey = 2
2829
Global Const $ccs_bottom = 3
2830
Global Const $ccs_noresize = 4
2831
Global Const $ccs_noparentalign = 8
2832
Global Const $ccs_nohilite = 16
2833
Global Const $ccs_adjustable = 32
2834
Global Const $ccs_nodivider = 64
2835
Global Const $ccs_vert = 128
2836
Global Const $ccs_left = 129
2837
Global Const $ccs_nomovex = 130
2838
Global Const $ccs_right = 131
2839
Global Const $di_mask = 1
2840
Global Const $di_image = 2
2841
Global Const $di_normal = 3
2842
Global Const $di_compat = 4
2843
Global Const $di_defaultsize = 8
2844
Global Const $di_nomirror = 16
2845
Global Const $display_device_attached_to_desktop = 1
2846
Global Const $display_device_multi_driver = 2
2847
Global Const $display_device_primary_device = 4
2848
Global Const $display_device_mirroring_driver = 8
2849
Global Const $display_device_vga_compatible = 16
2850
Global Const $display_device_removable = 32
2851
Global Const $display_device_disconnect = 33554432
2852
Global Const $display_device_remote = 67108864
2853
Global Const $display_device_modespruned = 134217728
2854
Global Const $flashw_caption = 1
2855
Global Const $flashw_tray = 2
2856
Global Const $flashw_timer = 4
2857
Global Const $flashw_timernofg = 12
2858
Global Const $format_message_allocate_buffer = 256
2859
Global Const $format_message_ignore_inserts = 512
2860
Global Const $format_message_from_string = 1024
2861
Global Const $format_message_from_hmodule = 2048
2862
Global Const $format_message_from_system = 4096
2863
Global Const $format_message_argument_array = 8192
2864
Global Const $gw_hwndfirst = 0
2865
Global Const $gw_hwndlast = 1
2866
Global Const $gw_hwndnext = 2
2867
Global Const $gw_hwndprev = 3
2868
Global Const $gw_owner = 4
2869
Global Const $gw_child = 5
2870
Global Const $gwl_wndproc = -4
2871
Global Const $gwl_hinstance = -6
2872
Global Const $gwl_hwndparent = -8
2873
Global Const $gwl_id = -12
2874
Global Const $gwl_style = -16
2875
Global Const $gwl_exstyle = -20
2876
Global Const $gwl_userdata = -21
2877
Global Const $std_cut = 0
2878
Global Const $std_copy = 1
2879
Global Const $std_paste = 2
2880
Global Const $std_undo = 3
2881
Global Const $std_redow = 4
2882
Global Const $std_delete = 5
2883
Global Const $std_filenew = 6
2884
Global Const $std_fileopen = 7
2885
Global Const $std_filesave = 8
2886
Global Const $std_printpre = 9
2887
Global Const $std_properties = 10
2888
Global Const $std_help = 11
2889
Global Const $std_find = 12
2890
Global Const $std_replace = 13
2891
Global Const $std_print = 14
2892
Global Const $lr_defaultcolor = 0
2893
Global Const $lr_monochrome = 1
2894
Global Const $lr_color = 2
2895
Global Const $lr_copyreturnorg = 4
2896
Global Const $lr_copydeleteorg = 8
2897
Global Const $lr_loadfromfile = 16
2898
Global Const $lr_loadtransparent = 32
2899
Global Const $lr_defaultsize = 64
2900
Global Const $lr_vgacolor = 128
2901
Global Const $lr_loadmap3dcolors = 4096
2902
Global Const $lr_createdibsection = 8192
2903
Global Const $lr_copyfromresource = 16384
2904
Global Const $lr_shared = 32768
2905
Global Const $image_bitmap = 0
2906
Global Const $image_icon = 1
2907
Global Const $image_cursor = 2
2908
Global Const $kb_sendspecial = 0
2909
Global Const $kb_sendraw = 1
2910
Global Const $kb_capsoff = 0
2911
Global Const $kb_capson = 1
2912
Global Const $dont_resolve_dll_references = 1
2913
Global Const $load_library_as_datafile = 2
2914
Global Const $load_with_altered_search_path = 8
2915
Global Const $objid_window = 0
2916
Global Const $objid_titlebar = -2
2917
Global Const $objid_sizegrip = -7
2918
Global Const $objid_caret = -8
2919
Global Const $objid_cursor = -9
2920
Global Const $objid_alert = -10
2921
Global Const $objid_sound = -11
2922
Global Const $vk_down = 40
2923
Global Const $vk_end = 35
2924
Global Const $vk_home = 36
2925
Global Const $vk_left = 37
2926
Global Const $vk_next = 34
2927
Global Const $vk_prior = 33
2928
Global Const $vk_right = 39
2929
Global Const $vk_up = 38
2930
Global Const $mb_ok = 0
2931
Global Const $mb_okcancel = 1
2932
Global Const $mb_abortretryignore = 2
2933
Global Const $mb_yesnocancel = 3
2934
Global Const $mb_yesno = 4
2935
Global Const $mb_retrycancel = 5
2936
Global Const $mb_iconhand = 16
2937
Global Const $mb_iconquestion = 32
2938
Global Const $mb_iconexclamation = 48
2939
Global Const $mb_iconasterisk = 64
2940
Global Const $mb_defbutton1 = 0
2941
Global Const $mb_defbutton2 = 256
2942
Global Const $mb_defbutton3 = 512
2943
Global Const $mb_applmodal = 0
2944
Global Const $mb_systemmodal = 4096
2945
Global Const $mb_taskmodal = 8192
2946
Global Const $mb_topmost = 262144
2947
Global Const $mb_rightjustified = 524288
2948
Global Const $idtimeout = -1
2949
Global Const $idok = 1
2950
Global Const $idcancel = 2
2951
Global Const $idabort = 3
2952
Global Const $idretry = 4
2953
Global Const $idignore = 5
2954
Global Const $idyes = 6
2955
Global Const $idno = 7
2956
Global Const $idtryagain = 10
2957
Global Const $idcontinue = 11
2958
Global Const $dlg_notitle = 1
2959
Global Const $dlg_notontop = 2
2960
Global Const $dlg_textleft = 4
2961
Global Const $dlg_textright = 8
2962
Global Const $dlg_moveable = 16
2963
Global Const $dlg_textvcenter = 32
2964
Global Const $tip_iconnone = 0
2965
Global Const $tip_iconasterisk = 1
2966
Global Const $tip_iconexclamation = 2
2967
Global Const $tip_iconhand = 3
2968
Global Const $tip_nosound = 16
2969
Global Const $idc_unknown = 0
2970
Global Const $idc_appstarting = 1
2971
Global Const $idc_arrow = 2
2972
Global Const $idc_cross = 3
2973
Global Const $idc_hand = 32649
2974
Global Const $idc_help = 4
2975
Global Const $idc_ibeam = 5
2976
Global Const $idc_icon = 6
2977
Global Const $idc_no = 7
2978
Global Const $idc_size = 8
2979
Global Const $idc_sizeall = 9
2980
Global Const $idc_sizenesw = 10
2981
Global Const $idc_sizens = 11
2982
Global Const $idc_sizenwse = 12
2983
Global Const $idc_sizewe = 13
2984
Global Const $idc_uparrow = 14
2985
Global Const $idc_wait = 15
2986
Global Const $idi_application = 32512
2987
Global Const $idi_asterisk = 32516
2988
Global Const $idi_exclamation = 32515
2989
Global Const $idi_hand = 32513
2990
Global Const $idi_question = 32514
2991
Global Const $idi_winlogo = 32517
2992
Global Const $sd_logoff = 0
2993
Global Const $sd_shutdown = 1
2994
Global Const $sd_reboot = 2
2995
Global Const $sd_force = 4
2996
Global Const $sd_powerdown = 8
2997
Global Const $str_nocasesense = 0
2998
Global Const $str_casesense = 1
2999
Global Const $str_stripleading = 1
3000
Global Const $str_striptrailing = 2
3001
Global Const $str_stripspaces = 4
3002
Global Const $str_stripall = 8
3003
Global Const $tray_item_exit = 3
3004
Global Const $tray_item_pause = 4
3005
Global Const $tray_item_first = 7
3006
Global Const $tray_checked = 1
3007
Global Const $tray_unchecked = 4
3008
Global Const $tray_enable = 64
3009
Global Const $tray_disable = 128
3010
Global Const $tray_focus = 256
3011
Global Const $tray_default = 512
3012
Global Const $tray_event_showicon = -3
3013
Global Const $tray_event_hideicon = -4
3014
Global Const $tray_event_flashicon = -5
3015
Global Const $tray_event_noflashicon = -6
3016
Global Const $tray_event_primarydown = -7
3017
Global Const $tray_event_primaryup = -8
3018
Global Const $tray_event_secondarydown = -9
3019
Global Const $tray_event_secondaryup = -10
3020
Global Const $tray_event_mouseover = -11
3021
Global Const $tray_event_mouseout = -12
3022
Global Const $tray_event_primarydouble = -13
3023
Global Const $tray_event_secondarydouble = -14
3024
Global Const $stdin_child = 1
3025
Global Const $stdout_child = 2
3026
Global Const $stderr_child = 4
3027
Global Const $stderr_merged = 8
3028
Global Const $stdio_inherit_parent = 16
3029
Global Const $run_create_new_console = 65536
3030
Global Const $mouseeventf_absolute = 32768
3031
Global Const $mouseeventf_move = 1
3032
Global Const $mouseeventf_leftdown = 2
3033
Global Const $mouseeventf_leftup = 4
3034
Global Const $mouseeventf_rightdown = 8
3035
Global Const $mouseeventf_rightup = 16
3036
Global Const $mouseeventf_middledown = 32
3037
Global Const $mouseeventf_middleup = 64
3038
Global Const $mouseeventf_wheel = 2048
3039
Global Const $mouseeventf_xdown = 128
3040
Global Const $mouseeventf_xup = 256
3041
Global Const $reg_none = 0
3042
Global Const $reg_sz = 1
3043
Global Const $reg_expand_sz = 2
3044
Global Const $reg_binary = 3
3045
Global Const $reg_dword = 4
3046
Global Const $reg_dword_big_endian = 5
3047
Global Const $reg_link = 6
3048
Global Const $reg_multi_sz = 7
3049
Global Const $reg_resource_list = 8
3050
Global Const $reg_full_resource_descriptor = 9
3051
Global Const $reg_resource_requirements_list = 10
3052
Global Const $hwnd_bottom = 1
3053
Global Const $hwnd_notopmost = -2
3054
Global Const $hwnd_top = 0
3055
Global Const $hwnd_topmost = -1
3056
Global Const $swp_nosize = 1
3057
Global Const $swp_nomove = 2
3058
Global Const $swp_nozorder = 4
3059
Global Const $swp_noredraw = 8
3060
Global Const $swp_noactivate = 16
3061
Global Const $swp_framechanged = 32
3062
Global Const $swp_drawframe = 32
3063
Global Const $swp_showwindow = 64
3064
Global Const $swp_hidewindow = 128
3065
Global Const $swp_nocopybits = 256
3066
Global Const $swp_noownerzorder = 512
3067
Global Const $swp_noreposition = 512
3068
Global Const $swp_nosendchanging = 1024
3069
Global Const $swp_defererase = 8192
3070
Global Const $swp_asyncwindowpos = 16384
3071
Global Const $lang_afrikaans = 54
3072
Global Const $lang_albanian = 28
3073
Global Const $lang_arabic = 1
3074
Global Const $lang_armenian = 43
3075
Global Const $lang_assamese = 77
3076
Global Const $lang_azeri = 44
3077
Global Const $lang_basque = 45
3078
Global Const $lang_belarusian = 35
3079
Global Const $lang_bengali = 69
3080
Global Const $lang_bulgarian = 2
3081
Global Const $lang_catalan = 3
3082
Global Const $lang_chinese = 4
3083
Global Const $lang_croatian = 26
3084
Global Const $lang_czech = 5
3085
Global Const $lang_danish = 6
3086
Global Const $lang_dutch = 19
3087
Global Const $lang_english = 9
3088
Global Const $lang_estonian = 37
3089
Global Const $lang_faeroese = 56
3090
Global Const $lang_farsi = 41
3091
Global Const $lang_finnish = 11
3092
Global Const $lang_french = 156
3093
Global Const $lang_georgian = 55
3094
Global Const $lang_german = 7
3095
Global Const $lang_greek = 8
3096
Global Const $lang_gujarati = 71
3097
Global Const $lang_hebrew = 13
3098
Global Const $lang_hindi = 57
3099
Global Const $lang_hungarian = 14
3100
Global Const $lang_icelandic = 15
3101
Global Const $lang_indonesian = 33
3102
Global Const $lang_italian = 16
3103
Global Const $lang_japanese = 17
3104
Global Const $lang_kannada = 75
3105
Global Const $lang_kashmiri = 96
3106
Global Const $lang_kazak = 63
3107
Global Const $lang_konkani = 87
3108
Global Const $lang_korean = 18
3109
Global Const $lang_latvian = 38
3110
Global Const $lang_lithuanian = 39
3111
Global Const $lang_macedonian = 47
3112
Global Const $lang_malay = 62
3113
Global Const $lang_malayalam = 76
3114
Global Const $lang_manipuri = 88
3115
Global Const $lang_marathi = 78
3116
Global Const $lang_nepali = 97
3117
Global Const $lang_neutral = 0
3118
Global Const $lang_norwegian = 20
3119
Global Const $lang_oriya = 72
3120
Global Const $lang_polish = 21
3121
Global Const $lang_portuguese = 22
3122
Global Const $lang_punjabi = 70
3123
Global Const $lang_romanian = 24
3124
Global Const $lang_russian = 25
3125
Global Const $lang_sanskrit = 79
3126
Global Const $lang_serbian = 26
3127
Global Const $lang_sindhi = 89
3128
Global Const $lang_slovak = 27
3129
Global Const $lang_slovenian = 36
3130
Global Const $lang_spanish = 10
3131
Global Const $lang_swahili = 65
3132
Global Const $lang_swedish = 29
3133
Global Const $lang_tamil = 73
3134
Global Const $lang_tatar = 68
3135
Global Const $lang_telugu = 74
3136
Global Const $lang_thai = 30
3137
Global Const $lang_turkish = 31
3138
Global Const $lang_ukrainian = 34
3139
Global Const $lang_urdu = 32
3140
Global Const $lang_uzbek = 67
3141
Global Const $lang_vietnamese = 42
3142
Global Const $sublang_arabic_algeria = 5
3143
Global Const $sublang_arabic_bahrain = 15
3144
Global Const $sublang_arabic_egypt = 3
3145
Global Const $sublang_arabic_iraq = 2
3146
Global Const $sublang_arabic_jordan = 11
3147
Global Const $sublang_arabic_kuwait = 13
3148
Global Const $sublang_arabic_lebanon = 12
3149
Global Const $sublang_arabic_libya = 4
3150
Global Const $sublang_arabic_morocco = 6
3151
Global Const $sublang_arabic_oman = 8
3152
Global Const $sublang_arabic_qatar = 16
3153
Global Const $sublang_arabic_saudi_arabia = 1
3154
Global Const $sublang_arabic_syria = 10
3155
Global Const $sublang_arabic_tunisia = 7
3156
Global Const $sublang_arabic_uae = 14
3157
Global Const $sublang_arabic_yemen = 9
3158
Global Const $sublang_azeri_cyrillic = 2
3159
Global Const $sublang_azeri_latin = 1
3160
Global Const $sublang_chinese_hongkong = 3
3161
Global Const $sublang_chinese_macau = 5
3162
Global Const $sublang_chinese_simplified = 2
3163
Global Const $sublang_chinese_singapore = 4
3164
Global Const $sublang_chinese_traditional = 1
3165
Global Const $sublang_default = 1
3166
Global Const $sublang_dutch = 1
3167
Global Const $sublang_dutch_belgian = 2
3168
Global Const $sublang_english_aus = 3
3169
Global Const $sublang_english_belize = 10
3170
Global Const $sublang_english_can = 4
3171
Global Const $sublang_english_caribbean = 9
3172
Global Const $sublang_english_eire = 6
3173
Global Const $sublang_english_jamaica = 8
3174
Global Const $sublang_english_nz = 5
3175
Global Const $sublang_english_philippines = 13
3176
Global Const $sublang_english_south_africa = 7
3177
Global Const $sublang_english_trinidad = 11
3178
Global Const $sublang_english_uk = 2
3179
Global Const $sublang_english_us = 1
3180
Global Const $sublang_english_zimbabwe = 12
3181
Global Const $sublang_french = 1
3182
Global Const $sublang_french_belgian = 2
3183
Global Const $sublang_french_canadian = 3
3184
Global Const $sublang_french_luxembourg = 5
3185
Global Const $sublang_french_monaco = 6
3186
Global Const $sublang_french_swiss = 4
3187
Global Const $sublang_german = 1
3188
Global Const $sublang_german_austrian = 3
3189
Global Const $sublang_german_liechtenstein = 5
3190
Global Const $sublang_german_luxembourg = 4
3191
Global Const $sublang_german_swiss = 2
3192
Global Const $sublang_italian = 1
3193
Global Const $sublang_italian_swiss = 2
3194
Global Const $sublang_kashmiri_india = 2
3195
Global Const $sublang_korean = 1
3196
Global Const $sublang_lithuanian = 1
3197
Global Const $sublang_malay_brunei_darussalam = 2
3198
Global Const $sublang_malay_malaysia = 1
3199
Global Const $sublang_nepali_india = 2
3200
Global Const $sublang_neutral = 0
3201
Global Const $sublang_norwegian_bokmal = 1
3202
Global Const $sublang_norwegian_nynorsk = 2
3203
Global Const $sublang_portuguese = 2
3204
Global Const $sublang_portuguese_brazilian = 1
3205
Global Const $sublang_serbian_cyrillic = 3
3206
Global Const $sublang_serbian_latin = 2
3207
Global Const $sublang_spanish = 1
3208
Global Const $sublang_spanish_argentina = 11
3209
Global Const $sublang_spanish_bolivia = 16
3210
Global Const $sublang_spanish_chile = 13
3211
Global Const $sublang_spanish_colombia = 9
3212
Global Const $sublang_spanish_costa_rica = 5
3213
Global Const $sublang_spanish_dominican_republic = 7
3214
Global Const $sublang_spanish_ecuador = 12
3215
Global Const $sublang_spanish_el_salvador = 17
3216
Global Const $sublang_spanish_guatemala = 4
3217
Global Const $sublang_spanish_honduras = 18
3218
Global Const $sublang_spanish_mexican = 2
3219
Global Const $sublang_spanish_modern = 3
3220
Global Const $sublang_spanish_nicaragua = 19
3221
Global Const $sublang_spanish_panama = 6
3222
Global Const $sublang_spanish_paraguay = 15
3223
Global Const $sublang_spanish_peru = 10
3224
Global Const $sublang_spanish_puerto_rico = 20
3225
Global Const $sublang_spanish_uruguay = 14
3226
Global Const $sublang_spanish_venezuela = 8
3227
Global Const $sublang_swedish = 1
3228
Global Const $sublang_swedish_finland = 2
3229
Global Const $sublang_sys_default = 2
3230
Global Const $sublang_urdu_india = 2
3231
Global Const $sublang_urdu_pakistan = 1
3232
Global Const $sublang_uzbek_cyrillic = 2
3233
Global Const $sort_default = 0
3234
Global Const $sort_japanese_xjis = 0
3235
Global Const $sort_japanese_unicode = 1
3236
Global Const $sort_chinese_big5 = 0
3237
Global Const $sort_chinese_prcp = 0
3238
Global Const $sort_chinese_unicode = 1
3239
Global Const $sort_chinese_prc = 2
3240
Global Const $sort_korean_ksc = 0
3241
Global Const $sort_korean_unicode = 1
3242
Global Const $sort_german_phone_book = 1
3243
Global Const $sort_hungarian_default = 0
3244
Global Const $sort_hungarian_technical = 1
3245
Global Const $sort_georgian_traditional = 0
3246
Global Const $sort_georgian_modern = 1
3247
Global Const $ws_tiled = 0
3248
Global Const $ws_overlapped = 0
3249
Global Const $ws_maximizebox = 65536
3250
Global Const $ws_minimizebox = 131072
3251
Global Const $ws_tabstop = 65536
3252
Global Const $ws_group = 131072
3253
Global Const $ws_sizebox = 262144
3254
Global Const $ws_thickframe = 262144
3255
Global Const $ws_sysmenu = 524288
3256
Global Const $ws_hscroll = 1048576
3257
Global Const $ws_vscroll = 2097152
3258
Global Const $ws_dlgframe = 4194304
3259
Global Const $ws_border = 8388608
3260
Global Const $ws_caption = 12582912
3261
Global Const $ws_overlappedwindow = 13565952
3262
Global Const $ws_tiledwindow = 13565952
3263
Global Const $ws_maximize = 16777216
3264
Global Const $ws_clipchildren = 33554432
3265
Global Const $ws_clipsiblings = 67108864
3266
Global Const $ws_disabled = 134217728
3267
Global Const $ws_visible = 268435456
3268
Global Const $ws_minimize = 536870912
3269
Global Const $ws_child = 1073741824
3270
Global Const $ws_popup = -2147483648
3271
Global Const $ws_popupwindow = -2138570752
3272
Global Const $ds_modalframe = 128
3273
Global Const $ds_setforeground = 512
3274
Global Const $ds_contexthelp = 8192
3275
Global Const $ws_ex_acceptfiles = 16
3276
Global Const $ws_ex_mdichild = 64
3277
Global Const $ws_ex_appwindow = 262144
3278
Global Const $ws_ex_composited = 33554432
3279
Global Const $ws_ex_clientedge = 512
3280
Global Const $ws_ex_contexthelp = 1024
3281
Global Const $ws_ex_dlgmodalframe = 1
3282
Global Const $ws_ex_leftscrollbar = 16384
3283
Global Const $ws_ex_overlappedwindow = 768
3284
Global Const $ws_ex_right = 4096
3285
Global Const $ws_ex_staticedge = 131072
3286
Global Const $ws_ex_toolwindow = 128
3287
Global Const $ws_ex_topmost = 8
3288
Global Const $ws_ex_transparent = 32
3289
Global Const $ws_ex_windowedge = 256
3290
Global Const $ws_ex_layered = 524288
3291
Global Const $ws_ex_controlparent = 65536
3292
Global Const $ws_ex_layoutrtl = 4194304
3293
Global Const $ws_ex_rtlreading = 8192
3294
Global Const $wm_gettextlength = 14
3295
Global Const $wm_gettext = 13
3296
Global Const $wm_size = 5
3297
Global Const $wm_sizing = 532
3298
Global Const $wm_user = 1024
3299
Global Const $wm_create = 1
3300
Global Const $wm_destroy = 2
3301
Global Const $wm_move = 3
3302
Global Const $wm_activate = 6
3303
Global Const $wm_setfocus = 7
3304
Global Const $wm_killfocus = 8
3305
Global Const $wm_enable = 10
3306
Global Const $wm_setredraw = 11
3307
Global Const $wm_settext = 12
3308
Global Const $wm_paint = 15
3309
Global Const $wm_close = 16
3310
Global Const $wm_quit = 18
3311
Global Const $wm_erasebkgnd = 20
3312
Global Const $wm_syscolorchange = 21
3313
Global Const $wm_showwindow = 24
3314
Global Const $wm_wininichange = 26
3315
Global Const $wm_devmodechange = 27
3316
Global Const $wm_activateapp = 28
3317
Global Const $wm_fontchange = 29
3318
Global Const $wm_timechange = 30
3319
Global Const $wm_cancelmode = 31
3320
Global Const $wm_setcursor = 32
3321
Global Const $wm_mouseactivate = 33
3322
Global Const $wm_childactivate = 34
3323
Global Const $wm_queuesync = 35
3324
Global Const $wm_getminmaxinfo = 36
3325
Global Const $wm_painticon = 38
3326
Global Const $wm_iconerasebkgnd = 39
3327
Global Const $wm_nextdlgctl = 40
3328
Global Const $wm_spoolerstatus = 42
3329
Global Const $wm_drawitem = 43
3330
Global Const $wm_measureitem = 44
3331
Global Const $wm_deleteitem = 45
3332
Global Const $wm_vkeytoitem = 46
3333
Global Const $wm_chartoitem = 47
3334
Global Const $wm_setfont = 48
3335
Global Const $wm_getfont = 49
3336
Global Const $wm_sethotkey = 50
3337
Global Const $wm_gethotkey = 51
3338
Global Const $wm_querydragicon = 55
3339
Global Const $wm_compareitem = 57
3340
Global Const $wm_getobject = 61
3341
Global Const $wm_compacting = 65
3342
Global Const $wm_commnotify = 68
3343
Global Const $wm_windowposchanging = 70
3344
Global Const $wm_windowposchanged = 71
3345
Global Const $wm_power = 72
3346
Global Const $wm_notify = 78
3347
Global Const $wm_copydata = 74
3348
Global Const $wm_canceljournal = 75
3349
Global Const $wm_inputlangchangerequest = 80
3350
Global Const $wm_inputlangchange = 81
3351
Global Const $wm_tcard = 82
3352
Global Const $wm_help = 83
3353
Global Const $wm_userchanged = 84
3354
Global Const $wm_notifyformat = 85
3355
Global Const $wm_cut = 768
3356
Global Const $wm_copy = 769
3357
Global Const $wm_paste = 770
3358
Global Const $wm_clear = 771
3359
Global Const $wm_undo = 772
3360
Global Const $wm_contextmenu = 123
3361
Global Const $wm_stylechanging = 124
3362
Global Const $wm_stylechanged = 125
3363
Global Const $wm_displaychange = 126
3364
Global Const $wm_geticon = 127
3365
Global Const $wm_seticon = 128
3366
Global Const $wm_nccreate = 129
3367
Global Const $wm_ncdestroy = 130
3368
Global Const $wm_nccalcsize = 131
3369
Global Const $wm_nchittest = 132
3370
Global Const $wm_ncpaint = 133
3371
Global Const $wm_ncactivate = 134
3372
Global Const $wm_getdlgcode = 135
3373
Global Const $wm_syncpaint = 136
3374
Global Const $wm_ncmousemove = 160
3375
Global Const $wm_nclbuttondown = 161
3376
Global Const $wm_nclbuttonup = 162
3377
Global Const $wm_nclbuttondblclk = 163
3378
Global Const $wm_ncrbuttondown = 164
3379
Global Const $wm_ncrbuttonup = 165
3380
Global Const $wm_ncrbuttondblclk = 166
3381
Global Const $wm_ncmbuttondown = 167
3382
Global Const $wm_ncmbuttonup = 168
3383
Global Const $wm_ncmbuttondblclk = 169
3384
Global Const $wm_keydown = 256
3385
Global Const $wm_keyup = 257
3386
Global Const $wm_char = 258
3387
Global Const $wm_deadchar = 259
3388
Global Const $wm_syskeydown = 260
3389
Global Const $wm_syskeyup = 261
3390
Global Const $wm_syschar = 262
3391
Global Const $wm_sysdeadchar = 263
3392
Global Const $wm_initdialog = 272
3393
Global Const $wm_command = 273
3394
Global Const $wm_syscommand = 274
3395
Global Const $wm_timer = 275
3396
Global Const $wm_hscroll = 276
3397
Global Const $wm_vscroll = 277
3398
Global Const $wm_initmenu = 278
3399
Global Const $wm_initmenupopup = 279
3400
Global Const $wm_menuselect = 287
3401
Global Const $wm_menuchar = 288
3402
Global Const $wm_enteridle = 289
3403
Global Const $wm_menurbuttonup = 290
3404
Global Const $wm_menudrag = 291
3405
Global Const $wm_menugetobject = 292
3406
Global Const $wm_uninitmenupopup = 293
3407
Global Const $wm_menucommand = 294
3408
Global Const $wm_changeuistate = 295
3409
Global Const $wm_updateuistate = 296
3410
Global Const $wm_queryuistate = 297
3411
Global Const $wm_ctlcolormsgbox = 306
3412
Global Const $wm_ctlcoloredit = 307
3413
Global Const $wm_ctlcolorlistbox = 308
3414
Global Const $wm_ctlcolorbtn = 309
3415
Global Const $wm_ctlcolordlg = 310
3416
Global Const $wm_ctlcolorscrollbar = 311
3417
Global Const $wm_ctlcolorstatic = 312
3418
Global Const $wm_ctlcolor = 25
3419
Global Const $mn_gethmenu = 481
3420
Global Const $nm_first = 0
3421
Global Const $nm_outofmemory = $nm_first - 1
3422
Global Const $nm_click = $nm_first - 2
3423
Global Const $nm_dblclk = $nm_first - 3
3424
Global Const $nm_return = $nm_first - 4
3425
Global Const $nm_rclick = $nm_first - 5
3426
Global Const $nm_rdblclk = $nm_first - 6
3427
Global Const $nm_setfocus = $nm_first - 7
3428
Global Const $nm_killfocus = $nm_first - 8
3429
Global Const $nm_customdraw = $nm_first - 12
3430
Global Const $nm_hover = $nm_first - 13
3431
Global Const $nm_nchittest = $nm_first - 14
3432
Global Const $nm_keydown = $nm_first - 15
3433
Global Const $nm_releasedcapture = $nm_first - 16
3434
Global Const $nm_setcursor = $nm_first - 17
3435
Global Const $nm_char = $nm_first - 18
3436
Global Const $nm_tooltipscreated = $nm_first - 19
3437
Global Const $nm_ldown = $nm_first - 20
3438
Global Const $nm_rdown = $nm_first - 21
3439
Global Const $nm_themechanged = $nm_first - 22
3440
Global Const $wm_mousemove = 512
3441
Global Const $wm_lbuttondown = 513
3442
Global Const $wm_lbuttonup = 514
3443
Global Const $wm_lbuttondblclk = 515
3444
Global Const $wm_rbuttondown = 516
3445
Global Const $wm_rbuttonup = 517
3446
Global Const $wm_rbuttondblck = 518
3447
Global Const $wm_mbuttondown = 519
3448
Global Const $wm_mbuttonup = 520
3449
Global Const $wm_mbuttondblck = 521
3450
Global Const $wm_mousewheel = 522
3451
Global Const $wm_xbuttondown = 523
3452
Global Const $wm_xbuttonup = 524
3453
Global Const $wm_xbuttondblclk = 525
3454
Global Const $wm_mousehwheel = 526
3455
Global Const $ps_solid = 0
3456
Global Const $ps_dash = 1
3457
Global Const $ps_dot = 2
3458
Global Const $ps_dashdot = 3
3459
Global Const $ps_dashdotdot = 4
3460
Global Const $ps_null = 5
3461
Global Const $ps_insideframe = 6
3462
Global Const $lwa_alpha = 2
3463
Global Const $lwa_colorkey = 1
3464
Global Const $rgn_and = 1
3465
Global Const $rgn_or = 2
3466
Global Const $rgn_xor = 3
3467
Global Const $rgn_diff = 4
3468
Global Const $rgn_copy = 5
3469
Global Const $errorregion = 0
3470
Global Const $nullregion = 1
3471
Global Const $simpleregion = 2
3472
Global Const $complexregion = 3
3473
Global Const $transparent = 1
3474
Global Const $opaque = 2
3475
Global Const $ccm_first = 8192
3476
Global Const $ccm_getunicodeformat = ($ccm_first + 6)
3477
Global Const $ccm_setunicodeformat = ($ccm_first + 5)
3478
Global Const $ccm_setbkcolor = $ccm_first + 1
3479
Global Const $ccm_setcolorscheme = $ccm_first + 2
3480
Global Const $ccm_getcolorscheme = $ccm_first + 3
3481
Global Const $ccm_getdroptarget = $ccm_first + 4
3482
Global Const $ccm_setwindowtheme = $ccm_first + 11
3483
Global Const $ga_parent = 1
3484
Global Const $ga_root = 2
3485
Global Const $ga_rootowner = 3
3486
Global Const $sm_cxscreen = 0
3487
Global Const $sm_cyscreen = 1
3488
Global Const $sm_cxvscroll = 2
3489
Global Const $sm_cyhscroll = 3
3490
Global Const $sm_cycaption = 4
3491
Global Const $sm_cxborder = 5
3492
Global Const $sm_cyborder = 6
3493
Global Const $sm_cxdlgframe = 7
3494
Global Const $sm_cydlgframe = 8
3495
Global Const $sm_cyvthumb = 9
3496
Global Const $sm_cxhthumb = 10
3497
Global Const $sm_cxicon = 11
3498
Global Const $sm_cyicon = 12
3499
Global Const $sm_cxcursor = 13
3500
Global Const $sm_cycursor = 14
3501
Global Const $sm_cymenu = 15
3502
Global Const $sm_cxfullscreen = 16
3503
Global Const $sm_cyfullscreen = 17
3504
Global Const $sm_cykanjiwindow = 18
3505
Global Const $sm_mousepresent = 19
3506
Global Const $sm_cyvscroll = 20
3507
Global Const $sm_cxhscroll = 21
3508
Global Const $sm_debug = 22
3509
Global Const $sm_swapbutton = 23
3510
Global Const $sm_reserved1 = 24
3511
Global Const $sm_reserved2 = 25
3512
Global Const $sm_reserved3 = 26
3513
Global Const $sm_reserved4 = 27
3514
Global Const $sm_cxmin = 28
3515
Global Const $sm_cymin = 29
3516
Global Const $sm_cxsize = 30
3517
Global Const $sm_cysize = 31
3518
Global Const $sm_cxframe = 32
3519
Global Const $sm_cyframe = 33
3520
Global Const $sm_cxmintrack = 34
3521
Global Const $sm_cymintrack = 35
3522
Global Const $sm_cxdoubleclk = 36
3523
Global Const $sm_cydoubleclk = 37
3524
Global Const $sm_cxiconspacing = 38
3525
Global Const $sm_cyiconspacing = 39
3526
Global Const $sm_menudropalignment = 40
3527
Global Const $sm_penwindows = 41
3528
Global Const $sm_dbcsenabled = 42
3529
Global Const $sm_cmousebuttons = 43
3530
Global Const $sm_secure = 44
3531
Global Const $sm_cxedge = 45
3532
Global Const $sm_cyedge = 46
3533
Global Const $sm_cxminspacing = 47
3534
Global Const $sm_cyminspacing = 48
3535
Global Const $sm_cxsmicon = 49
3536
Global Const $sm_cysmicon = 50
3537
Global Const $sm_cysmcaption = 51
3538
Global Const $sm_cxsmsize = 52
3539
Global Const $sm_cysmsize = 53
3540
Global Const $sm_cxmenusize = 54
3541
Global Const $sm_cymenusize = 55
3542
Global Const $sm_arrange = 56
3543
Global Const $sm_cxminimized = 57
3544
Global Const $sm_cyminimized = 58
3545
Global Const $sm_cxmaxtrack = 59
3546
Global Const $sm_cymaxtrack = 60
3547
Global Const $sm_cxmaximized = 61
3548
Global Const $sm_cymaximized = 62
3549
Global Const $sm_network = 63
3550
Global Const $sm_cleanboot = 67
3551
Global Const $sm_cxdrag = 68
3552
Global Const $sm_cydrag = 69
3553
Global Const $sm_showsounds = 70
3554
Global Const $sm_cxmenucheck = 71
3555
Global Const $sm_cymenucheck = 72
3556
Global Const $sm_slowmachine = 73
3557
Global Const $sm_mideastenabled = 74
3558
Global Const $sm_mousewheelpresent = 75
3559
Global Const $sm_xvirtualscreen = 76
3560
Global Const $sm_yvirtualscreen = 77
3561
Global Const $sm_cxvirtualscreen = 78
3562
Global Const $sm_cyvirtualscreen = 79
3563
Global Const $sm_cmonitors = 80
3564
Global Const $sm_samedisplayformat = 81
3565
Global Const $sm_immenabled = 82
3566
Global Const $sm_cxfocusborder = 83
3567
Global Const $sm_cyfocusborder = 84
3568
Global Const $sm_tabletpc = 86
3569
Global Const $sm_mediacenter = 87
3570
Global Const $sm_starter = 88
3571
Global Const $sm_serverr2 = 89
3572
Global Const $sm_cmetrics = 90
3573
Global Const $sm_remotesession = 4096
3574
Global Const $sm_shuttingdown = 8192
3575
Global Const $sm_remotecontrol = 8193
3576
Global Const $sm_caretblinkingenabled = 8194
3577
Global Const $blackness = 66
3578
Global Const $captureblt = 1073741824
3579
Global Const $dstinvert = 5570569
3580
Global Const $mergecopy = 12583114
3581
Global Const $mergepaint = 12255782
3582
Global Const $nomirrorbitmap = -2147483648
3583
Global Const $notsrccopy = 3342344
3584
Global Const $notsrcerase = 1114278
3585
Global Const $patcopy = 15728673
3586
Global Const $patinvert = 5898313
3587
Global Const $patpaint = 16452105
3588
Global Const $srcand = 8913094
3589
Global Const $srccopy = 13369376
3590
Global Const $srcerase = 4457256
3591
Global Const $srcinvert = 6684742
3592
Global Const $srcpaint = 15597702
3593
Global Const $whiteness = 16711778
3594
Global Const $dt_bottom = 8
3595
Global Const $dt_calcrect = 1024
3596
Global Const $dt_center = 1
3597
Global Const $dt_editcontrol = 8192
3598
Global Const $dt_end_ellipsis = 32768
3599
Global Const $dt_expandtabs = 64
3600
Global Const $dt_externalleading = 512
3601
Global Const $dt_hideprefix = 1048576
3602
Global Const $dt_internal = 4096
3603
Global Const $dt_left = 0
3604
Global Const $dt_modifystring = 65536
3605
Global Const $dt_noclip = 256
3606
Global Const $dt_nofullwidthcharbreak = 524288
3607
Global Const $dt_noprefix = 2048
3608
Global Const $dt_path_ellipsis = 16384
3609
Global Const $dt_prefixonly = 2097152
3610
Global Const $dt_right = 2
3611
Global Const $dt_rtlreading = 131072
3612
Global Const $dt_singleline = 32
3613
Global Const $dt_tabstop = 128
3614
Global Const $dt_top = 0
3615
Global Const $dt_vcenter = 4
3616
Global Const $dt_wordbreak = 16
3617
Global Const $dt_word_ellipsis = 262144
3618
Global Const $rdw_erase = 4
3619
Global Const $rdw_frame = 1024
3620
Global Const $rdw_internalpaint = 2
3621
Global Const $rdw_invalidate = 1
3622
Global Const $rdw_noerase = 32
3623
Global Const $rdw_noframe = 2048
3624
Global Const $rdw_nointernalpaint = 16
3625
Global Const $rdw_validate = 8
3626
Global Const $rdw_erasenow = 512
3627
Global Const $rdw_updatenow = 256
3628
Global Const $rdw_allchildren = 128
3629
Global Const $rdw_nochildren = 64
3630
Global Const $wm_renderformat = 773
3631
Global Const $wm_renderallformats = 774
3632
Global Const $wm_destroyclipboard = 775
3633
Global Const $wm_drawclipboard = 776
3634
Global Const $wm_paintclipboard = 777
3635
Global Const $wm_vscrollclipboard = 778
3636
Global Const $wm_sizeclipboard = 779
3637
Global Const $wm_askcbformatname = 780
3638
Global Const $wm_changecbchain = 781
3639
Global Const $wm_hscrollclipboard = 782
3640
Global Const $hterror = -2
3641
Global Const $httransparent = -1
3642
Global Const $htnowhere = 0
3643
Global Const $htclient = 1
3644
Global Const $htcaption = 2
3645
Global Const $htsysmenu = 3
3646
Global Const $htgrowbox = 4
3647
Global Const $htsize = $htgrowbox
3648
Global Const $htmenu = 5
3649
Global Const $hthscroll = 6
3650
Global Const $htvscroll = 7
3651
Global Const $htminbutton = 8
3652
Global Const $htmaxbutton = 9
3653
Global Const $htleft = 10
3654
Global Const $htright = 11
3655
Global Const $httop = 12
3656
Global Const $httopleft = 13
3657
Global Const $httopright = 14
3658
Global Const $htbottom = 15
3659
Global Const $htbottomleft = 16
3660
Global Const $htbottomright = 17
3661
Global Const $htborder = 18
3662
Global Const $htreduce = $htminbutton
3663
Global Const $htzoom = $htmaxbutton
3664
Global Const $htsizefirst = $htleft
3665
Global Const $htsizelast = $htbottomright
3666
Global Const $htobject = 19
3667
Global Const $htclose = 20
3668
Global Const $hthelp = 21
3669
Global Const $color_scrollbar = 0
3670
Global Const $color_background = 1
3671
Global Const $color_activecaption = 2
3672
Global Const $color_inactivecaption = 3
3673
Global Const $color_menu = 4
3674
Global Const $color_window = 5
3675
Global Const $color_windowframe = 6
3676
Global Const $color_menutext = 7
3677
Global Const $color_windowtext = 8
3678
Global Const $color_captiontext = 9
3679
Global Const $color_activeborder = 10
3680
Global Const $color_inactiveborder = 11
3681
Global Const $color_appworkspace = 12
3682
Global Const $color_highlight = 13
3683
Global Const $color_highlighttext = 14
3684
Global Const $color_btnface = 15
3685
Global Const $color_btnshadow = 16
3686
Global Const $color_graytext = 17
3687
Global Const $color_btntext = 18
3688
Global Const $color_inactivecaptiontext = 19
3689
Global Const $color_btnhighlight = 20
3690
Global Const $color_3ddkshadow = 21
3691
Global Const $color_3dlight = 22
3692
Global Const $color_infotext = 23
3693
Global Const $color_infobk = 24
3694
Global Const $color_hotlight = 26
3695
Global Const $color_gradientactivecaption = 27
3696
Global Const $color_gradientinactivecaption = 28
3697
Global Const $color_menuhilight = 29
3698
Global Const $color_menubar = 30
3699
Global Const $color_desktop = 1
3700
Global Const $color_3dface = 15
3701
Global Const $color_3dshadow = 16
3702
Global Const $color_3dhighlight = 20
3703
Global Const $color_3dhilight = 20
3704
Global Const $color_btnhilight = 20
3705
Global Const $hinst_commctrl = -1
3706
Global Const $idb_std_small_color = 0
3707
Global Const $idb_std_large_color = 1
3708
Global Const $idb_view_small_color = 4
3709
Global Const $idb_view_large_color = 5
3710
Global Const $idb_hist_small_color = 8
3711
Global Const $idb_hist_large_color = 9
3712
Global Const $startf_forceofffeedback = 128
3713
Global Const $startf_forceonfeedback = 64
3714
Global Const $startf_runfullscreen = 32
3715
Global Const $startf_usecountchars = 8
3716
Global Const $startf_usefillattribute = 16
3717
Global Const $startf_usehotkey = 512
3718
Global Const $startf_useposition = 4
3719
Global Const $startf_useshowwindow = 1
3720
Global Const $startf_usesize = 2
3721
Global Const $startf_usestdhandles = 256
3722
Global Const $cdds_prepaint = 1
3723
Global Const $cdds_postpaint = 2
3724
Global Const $cdds_preerase = 3
3725
Global Const $cdds_posterase = 4
3726
Global Const $cdds_item = 65536
3727
Global Const $cdds_itemprepaint = 65537
3728
Global Const $cdds_itempostpaint = 65538
3729
Global Const $cdds_itempreerase = 65539
3730
Global Const $cdds_itemposterase = 65540
3731
Global Const $cdds_subitem = 131072
3732
Global Const $cdis_selected = 1
3733
Global Const $cdis_grayed = 2
3734
Global Const $cdis_disabled = 4
3735
Global Const $cdis_checked = 8
3736
Global Const $cdis_focus = 16
3737
Global Const $cdis_default = 32
3738
Global Const $cdis_hot = 64
3739
Global Const $cdis_marked = 128
3740
Global Const $cdis_indeterminate = 256
3741
Global Const $cdis_showkeyboardcues = 512
3742
Global Const $cdis_nearhot = 1024
3743
Global Const $cdis_othersidehot = 2048
3744
Global Const $cdis_drophilited = 4096
3745
Global Const $cdrf_dodefault = 0
3746
Global Const $cdrf_newfont = 2
3747
Global Const $cdrf_skipdefault = 4
3748
Global Const $cdrf_notifypostpaint = 16
3749
Global Const $cdrf_notifyitemdraw = 32
3750
Global Const $cdrf_notifysubitemdraw = 32
3751
Global Const $cdrf_notifyposterase = 64
3752
Global Const $cdrf_doerase = 8
3753
Global Const $cdrf_skippostpaint = 256
3754
Global Const $gui_ss_default_gui = BitOR($ws_minimizebox, $ws_caption, $ws_popup, $ws_sysmenu)
3755
Global $pid
3756
#Region _Memory
3757
3758
Func _hextostring($strhex)
3759
	If StringLeft($strhex, 2) = "0x" Then Return BinaryToString($strhex)
3760
	Return BinaryToString("0x" & $strhex)
3761
EndFunc
3762
3763
Func _stringbetween($s_string, $s_start, $s_end, $v_case = -1)
3764
	Local $s_case = ""
3765
	If $v_case = Default OR $v_case = -1 Then $s_case = "(?i)"
3766
	Local $s_pattern_escape = "(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)"
3767
	$s_start = StringRegExpReplace($s_start, $s_pattern_escape, "\\$1")
3768
	$s_end = StringRegExpReplace($s_end, $s_pattern_escape, "\\$1")
3769
	If $s_start = "" Then $s_start = "\A"
3770
	If $s_end = "" Then $s_end = "\z"
3771
	Local $a_ret = StringRegExp($s_string, "(?s)" & $s_case & $s_start & "(.*?)" & $s_end, 3)
3772
	If @error Then Return SetError(1, 0, 0)
3773
	Return $a_ret
3774
EndFunc
3775
3776
Func _stringencrypt($i_encrypt, $s_encrypttext, $s_encryptpassword, $i_encryptlevel = 1)
3777
	If $i_encrypt <> 0 AND $i_encrypt <> 1 Then
3778
		SetError(1, 0, "")
3779
	ElseIf $s_encrypttext = "" OR $s_encryptpassword = "" Then
3780
		SetError(1, 0, "")
3781
	Else
3782
		If Number($i_encryptlevel) <= 0 OR Int($i_encryptlevel) <> $i_encryptlevel Then $i_encryptlevel = 1
3783
		Local $v_encryptmodified
3784
		Local $i_encryptcounth
3785
		Local $i_encryptcountg
3786
		Local $v_encryptswap
3787
		Local $av_encryptbox[256][2]
3788
		Local $i_encryptcounta
3789
		Local $i_encryptcountb
3790
		Local $i_encryptcountc
3791
		Local $i_encryptcountd
3792
		Local $i_encryptcounte
3793
		Local $v_encryptcipher
3794
		Local $v_encryptcipherby
3795
		If $i_encrypt = 1 Then
3796
			For $i_encryptcountf = 0 To $i_encryptlevel Step 1
3797
				$i_encryptcountg = ""
3798
				$i_encryptcounth = ""
3799
				$v_encryptmodified = ""
3800
				For $i_encryptcountg = 1 To StringLen($s_encrypttext)
3801
					If $i_encryptcounth = StringLen($s_encryptpassword) Then
3802
						$i_encryptcounth = 1
3803
					Else
3804
						$i_encryptcounth += 1
3805
					EndIf
3806
					$v_encryptmodified = $v_encryptmodified & Chr(BitXOR(Asc(StringMid($s_encrypttext, $i_encryptcountg, 1)), Asc(StringMid($s_encryptpassword, $i_encryptcounth, 1)), 255))
3807
				Next
3808
				$s_encrypttext = $v_encryptmodified
3809
				$i_encryptcounta = ""
3810
				$i_encryptcountb = 0
3811
				$i_encryptcountc = ""
3812
				$i_encryptcountd = ""
3813
				$i_encryptcounte = ""
3814
				$v_encryptcipherby = ""
3815
				$v_encryptcipher = ""
3816
				$v_encryptswap = ""
3817
				$av_encryptbox = ""
3818
				Local $av_encryptbox[256][2]
3819
				For $i_encryptcounta = 0 To 255
3820
					$av_encryptbox[$i_encryptcounta][1] = Asc(StringMid($s_encryptpassword, Mod($i_encryptcounta, StringLen($s_encryptpassword)) + 1, 1))
3821
					$av_encryptbox[$i_encryptcounta][0] = $i_encryptcounta
3822
				Next
3823
				For $i_encryptcounta = 0 To 255
3824
					$i_encryptcountb = Mod(($i_encryptcountb + $av_encryptbox[$i_encryptcounta][0] + $av_encryptbox[$i_encryptcounta][1]), 256)
3825
					$v_encryptswap = $av_encryptbox[$i_encryptcounta][0]
3826
					$av_encryptbox[$i_encryptcounta][0] = $av_encryptbox[$i_encryptcountb][0]
3827
					$av_encryptbox[$i_encryptcountb][0] = $v_encryptswap
3828
				Next
3829
				For $i_encryptcounta = 1 To StringLen($s_encrypttext)
3830
					$i_encryptcountc = Mod(($i_encryptcountc + 1), 256)
3831
					$i_encryptcountd = Mod(($i_encryptcountd + $av_encryptbox[$i_encryptcountc][0]), 256)
3832
					$i_encryptcounte = $av_encryptbox[Mod(($av_encryptbox[$i_encryptcountc][0] + $av_encryptbox[$i_encryptcountd][0]), 256)][0]
3833
					$v_encryptcipherby = BitXOR(Asc(StringMid($s_encrypttext, $i_encryptcounta, 1)), $i_encryptcounte)
3834
					$v_encryptcipher &= Hex($v_encryptcipherby, 2)
3835
				Next
3836
				$s_encrypttext = $v_encryptcipher
3837
			Next
3838
		Else
3839
			For $i_encryptcountf = 0 To $i_encryptlevel Step 1
3840
				$i_encryptcountb = 0
3841
				$i_encryptcountc = ""
3842
				$i_encryptcountd = ""
3843
				$i_encryptcounte = ""
3844
				$v_encryptcipherby = ""
3845
				$v_encryptcipher = ""
3846
				$v_encryptswap = ""
3847
				$av_encryptbox = ""
3848
				Local $av_encryptbox[256][2]
3849
				For $i_encryptcounta = 0 To 255
3850
					$av_encryptbox[$i_encryptcounta][1] = Asc(StringMid($s_encryptpassword, Mod($i_encryptcounta, StringLen($s_encryptpassword)) + 1, 1))
3851
					$av_encryptbox[$i_encryptcounta][0] = $i_encryptcounta
3852
				Next
3853
				For $i_encryptcounta = 0 To 255
3854
					$i_encryptcountb = Mod(($i_encryptcountb + $av_encryptbox[$i_encryptcounta][0] + $av_encryptbox[$i_encryptcounta][1]), 256)
3855
					$v_encryptswap = $av_encryptbox[$i_encryptcounta][0]
3856
					$av_encryptbox[$i_encryptcounta][0] = $av_encryptbox[$i_encryptcountb][0]
3857
					$av_encryptbox[$i_encryptcountb][0] = $v_encryptswap
3858
				Next
3859
				For $i_encryptcounta = 1 To StringLen($s_encrypttext) Step 2
3860
					$i_encryptcountc = Mod(($i_encryptcountc + 1), 256)
3861
					$i_encryptcountd = Mod(($i_encryptcountd + $av_encryptbox[$i_encryptcountc][0]), 256)
3862
					$i_encryptcounte = $av_encryptbox[Mod(($av_encryptbox[$i_encryptcountc][0] + $av_encryptbox[$i_encryptcountd][0]), 256)][0]
3863
					$v_encryptcipherby = BitXOR(Dec(StringMid($s_encrypttext, $i_encryptcounta, 2)), $i_encryptcounte)
3864
					$v_encryptcipher = $v_encryptcipher & Chr($v_encryptcipherby)
3865
				Next
3866
				$s_encrypttext = $v_encryptcipher
3867
				$i_encryptcountg = ""
3868
				$i_encryptcounth = ""
3869
				$v_encryptmodified = ""
3870
				For $i_encryptcountg = 1 To StringLen($s_encrypttext)
3871
					If $i_encryptcounth = StringLen($s_encryptpassword) Then
3872
						$i_encryptcounth = 1
3873
					Else
3874
						$i_encryptcounth += 1
3875
					EndIf
3876
					$v_encryptmodified &= Chr(BitXOR(Asc(StringMid($s_encrypttext, $i_encryptcountg, 1)), Asc(StringMid($s_encryptpassword, $i_encryptcounth, 1)), 255))
3877
				Next
3878
				$s_encrypttext = $v_encryptmodified
3879
			Next
3880
		EndIf
3881
		Return $s_encrypttext
3882
	EndIf
3883
EndFunc
3884
3885
Func _stringexplode($sstring, $sdelimiter, $ilimit = 0)
3886
	If $ilimit > 0 Then
3887
		$sstring = StringReplace($sstring, $sdelimiter, Chr(0), $ilimit)
3888
		$sdelimiter = Chr(0)
3889
	ElseIf $ilimit < 0 Then
3890
		Local $iindex = StringInStr($sstring, $sdelimiter, 0, $ilimit)
3891
		If $iindex Then
3892
			$sstring = StringLeft($sstring, $iindex - 1)
3893
		EndIf
3894
	EndIf
3895
	Return StringSplit($sstring, $sdelimiter, 3)
3896
EndFunc
3897
3898
Func _stringinsert($s_string, $s_insertstring, $i_position)
3899
	Local $i_length, $s_start, $s_end
3900
	If $s_string = "" OR (NOT IsString($s_string)) Then
3901
		Return SetError(1, 0, $s_string)
3902
	ElseIf $s_insertstring = "" OR (NOT IsString($s_string)) Then
3903
		Return SetError(2, 0, $s_string)
3904
	Else
3905
		$i_length = StringLen($s_string)
3906
		If (Abs($i_position) > $i_length) OR (NOT IsInt($i_position)) Then
3907
			Return SetError(3, 0, $s_string)
3908
		EndIf
3909
	EndIf
3910
	If $i_position = 0 Then
3911
		Return $s_insertstring & $s_string
3912
	ElseIf $i_position > 0 Then
3913
		$s_start = StringLeft($s_string, $i_position)
3914
		$s_end = StringRight($s_string, $i_length - $i_position)
3915
		Return $s_start & $s_insertstring & $s_end
3916
	ElseIf $i_position < 0 Then
3917
		$s_start = StringLeft($s_string, Abs($i_length + $i_position))
3918
		$s_end = StringRight($s_string, Abs($i_position))
3919
		Return $s_start & $s_insertstring & $s_end
3920
	EndIf
3921
EndFunc
3922
3923
Func _stringproper($s_string)
3924
	Local $ix = 0
3925
	Local $capnext = 1
3926
	Local $s_nstr = ""
3927
	Local $s_curchar
3928
	For $ix = 1 To StringLen($s_string)
3929
		$s_curchar = StringMid($s_string, $ix, 1)
3930
		Select 
3931
			Case $capnext = 1
3932
				If StringRegExp($s_curchar, "[a-zA-ZÀ-ÿaS~x]") Then
3933
					$s_curchar = StringUpper($s_curchar)
3934
					$capnext = 0
3935
				EndIf
3936
			Case NOT StringRegExp($s_curchar, "[a-zA-ZÀ-ÿaS~x]")
3937
				$capnext = 1
3938
			Case Else
3939
				$s_curchar = StringLower($s_curchar)
3940
		EndSelect
3941
		$s_nstr &= $s_curchar
3942
	Next
3943
	Return $s_nstr
3944
EndFunc
3945
3946
Func _stringrepeat($sstring, $irepeatcount)
3947
	Local $sresult
3948
	Select 
3949
		Case NOT StringIsInt($irepeatcount)
3950
			SetError(1)
3951
			Return ""
3952
		Case StringLen($sstring) < 1
3953
			SetError(1)
3954
			Return ""
3955
		Case $irepeatcount <= 0
3956
			SetError(1)
3957
			Return ""
3958
		Case Else
3959
			For $icount = 1 To $irepeatcount
3960
				$sresult &= $sstring
3961
			Next
3962
			Return $sresult
3963
	EndSelect
3964
EndFunc
3965
3966
Func _stringreverse($s_string)
3967
	Local $i_len = StringLen($s_string)
3968
	If $i_len < 1 Then Return SetError(1, 0, "")
3969
	Local $t_chars = DllStructCreate("char[" & $i_len + 1 & "]")
3970
	DllStructSetData($t_chars, 1, $s_string)
3971
	Local $a_rev = DllCall("msvcrt.dll", "ptr:cdecl", "_strrev", "ptr", DllStructGetPtr($t_chars))
3972
	If @error OR $a_rev[0] = 0 Then Return SetError(2, 0, "")
3973
	Return DllStructGetData($t_chars, 1)
3974
EndFunc
3975
3976
Func _stringtohex($strchar)
3977
	Return Hex(StringToBinary($strchar))
3978
EndFunc
3979
3980
Func _memoryopen($iv_pid, $iv_desiredaccess = 2035711, $iv_inherithandle = 1)
3981
	If NOT ProcessExists($iv_pid) Then
3982
		SetError(1)
3983
		Return 0
3984
	EndIf
3985
	Local $ah_handle[2] = [DllOpen("kernel32.dll")]
3986
	If @error Then
3987
		SetError(2)
3988
		Return 0
3989
	EndIf
3990
	Local $av_openprocess = DllCall($ah_handle[0], "int", "OpenProcess", "int", $iv_desiredaccess, "int", $iv_inherithandle, "int", $iv_pid)
3991
	If @error Then
3992
		DllClose($ah_handle[0])
3993
		SetError(3)
3994
		Return 0
3995
	EndIf
3996
	$ah_handle[1] = $av_openprocess[0]
3997
	Return $ah_handle
3998
EndFunc
3999
4000
Func _memoryread($iv_address, $ah_handle, $sv_type = "dword")
4001
	If NOT IsArray($ah_handle) Then
4002
		SetError(1)
4003
		Return 0
4004
	EndIf
4005
	Local $v_buffer = DllStructCreate($sv_type)
4006
	If @error Then
4007
		SetError(@error + 1)
4008
		Return 0
4009
	EndIf
4010
	DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
4011
	If NOT @error Then
4012
		Local $v_value = DllStructGetData($v_buffer, 1)
4013
		Return $v_value
4014
	Else
4015
		SetError(6)
4016
		Return 0
4017
	EndIf
4018
EndFunc
4019
4020
Func _memoryreadprotected($iv_address, $ah_handle, $sv_type = "dword")
4021
	If NOT IsArray($ah_handle) Then
4022
		SetError(1)
4023
		Return 0
4024
	EndIf
4025
	Local $v_buffer = DllStructCreate($sv_type)
4026
	If @error Then
4027
		SetError(@error + 1)
4028
		Return 0
4029
	EndIf
4030
	Local $x = DllCall($ah_handle[0], "int", "VirtualProtectEx", "int", $ah_handle[1], "ptr", $iv_address, "int", DllStructGetSize($v_buffer), "dword", 64, "dword*", 0)
4031
	DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
4032
	DllCall($ah_handle[0], "int", "VirtualProtectEx", "int", $ah_handle[1], "ptr", $iv_address, "int", DllStructGetSize($v_buffer), "dword", $x[5], "dword*", 0)
4033
	If NOT @error Then
4034
		Local $v_value = DllStructGetData($v_buffer, 1)
4035
		Return $v_value
4036
	Else
4037
		SetError(6)
4038
		Return 0
4039
	EndIf
4040
EndFunc
4041
4042
Func setconsoletitle($stitle)
4043
	Return DllCall("Kernel32.dll", "bool", "SetConsoleTitleW", "wstr", $stitle)
4044
EndFunc
4045
4046
Func _memorywrite($iv_address, $ah_handle, $v_data, $sv_type = "dword")
4047
	If NOT IsArray($ah_handle) Then
4048
		SetError(1)
4049
		Return 0
4050
	EndIf
4051
	Local $v_buffer = DllStructCreate($sv_type)
4052
	If @error Then
4053
		SetError(@error + 1)
4054
		Return 0
4055
	Else
4056
		DllStructSetData($v_buffer, 1, $v_data)
4057
		If @error Then
4058
			SetError(6)
4059
			Return 0
4060
		EndIf
4061
	EndIf
4062
	DllCall($ah_handle[0], "int", "WriteProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
4063
	If NOT @error Then
4064
		Return 1
4065
	Else
4066
		SetError(7)
4067
		Return 0
4068
	EndIf
4069
EndFunc
4070
4071
Func _memorywriteprotected($iv_address, $ah_handle, $v_data, $sv_type = "dword")
4072
	If NOT IsArray($ah_handle) Then
4073
		SetError(1)
4074
		Return 0
4075
	EndIf
4076
	Local $v_buffer = DllStructCreate($sv_type)
4077
	If @error Then
4078
		SetError(@error + 1)
4079
		Return 0
4080
	Else
4081
		DllStructSetData($v_buffer, 1, $v_data)
4082
		If @error Then
4083
			SetError(6)
4084
			Return 0
4085
		EndIf
4086
	EndIf
4087
	Local $x = DllCall($ah_handle[0], "int", "VirtualProtectEx", "int", $ah_handle[1], "ptr", $iv_address, "int", DllStructGetSize($v_buffer), "dword", 64, "dword*", 0)
4088
	DllCall($ah_handle[0], "int", "WriteProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
4089
	DllCall($ah_handle[0], "int", "VirtualProtectEx", "int", $ah_handle[1], "ptr", $iv_address, "int", DllStructGetSize($v_buffer), "dword", $x[5], "dword*", 0)
4090
	If NOT @error Then
4091
		Return 1
4092
	Else
4093
		SetError(7)
4094
		Return 0
4095
	EndIf
4096
EndFunc
4097
4098
Func _memoryclose($ah_handle)
4099
	If NOT IsArray($ah_handle) Then
4100
		SetError(1)
4101
		Return 0
4102
	EndIf
4103
	DllCall($ah_handle[0], "int", "CloseHandle", "int", $ah_handle[1])
4104
	If NOT @error Then
4105
		DllClose($ah_handle[0])
4106
		Return 1
4107
	Else
4108
		DllClose($ah_handle[0])
4109
		SetError(2)
4110
		Return 0
4111
	EndIf
4112
EndFunc
4113
4114
Func setprivilege($privilege, $benable)
4115
	Const $my_token_adjust_privileges = 32
4116
	Const $my_token_query = 8
4117
	Const $my_se_privilege_enabled = 2
4118
	Local $htoken, $sp_auxret, $sp_ret, $hcurrprocess, $ntokens, $ntokenindex, $priv
4119
	$ntokens = 1
4120
	$luid = DllStructCreate("dword;int")
4121
	If IsArray($privilege) Then $ntokens = UBound($privilege)
4122
	$token_privileges = DllStructCreate("dword;dword[" & (3 * $ntokens) & "]")
4123
	$newtoken_privileges = DllStructCreate("dword;dword[" & (3 * $ntokens) & "]")
4124
	$hcurrprocess = DllCall("kernel32.dll", "hwnd", "GetCurrentProcess")
4125
	$sp_auxret = DllCall("advapi32.dll", "int", "OpenProcessToken", "hwnd", $hcurrprocess[0], "int", BitOR($my_token_adjust_privileges, $my_token_query), "int*", 0)
4126
	If $sp_auxret[0] Then
4127
		$htoken = $sp_auxret[3]
4128
		DllStructSetData($token_privileges, 1, 1)
4129
		$ntokenindex = 1
4130
		While $ntokenindex <= $ntokens
4131
			If IsArray($privilege) Then
4132
				$priv = $privilege[$ntokenindex - 1]
4133
			Else
4134
				$priv = $privilege
4135
			EndIf
4136
			$ret = DllCall("advapi32.dll", "int", "LookupPrivilegeValue", "str", "", "str", $priv, "ptr", DllStructGetPtr($luid))
4137
			If $ret[0] Then
4138
				If $benable Then
4139
					DllStructSetData($token_privileges, 2, $my_se_privilege_enabled, (3 * $ntokenindex))
4140
				Else
4141
					DllStructSetData($token_privileges, 2, 0, (3 * $ntokenindex))
4142
				EndIf
4143
				DllStructSetData($token_privileges, 2, DllStructGetData($luid, 1), (3 * ($ntokenindex - 1)) + 1)
4144
				DllStructSetData($token_privileges, 2, DllStructGetData($luid, 2), (3 * ($ntokenindex - 1)) + 2)
4145
				DllStructSetData($luid, 1, 0)
4146
				DllStructSetData($luid, 2, 0)
4147
			EndIf
4148
			$ntokenindex += 1
4149
		WEnd
4150
		$ret = DllCall("advapi32.dll", "int", "AdjustTokenPrivileges", "hwnd", $htoken, "int", 0, "ptr", DllStructGetPtr($token_privileges), "int", DllStructGetSize($newtoken_privileges), "ptr", DllStructGetPtr($newtoken_privileges), "int*", 0)
4151
		$f = DllCall("kernel32.dll", "int", "GetLastError")
4152
	EndIf
4153
	$newtoken_privileges = 0
4154
	$token_privileges = 0
4155
	$luid = 0
4156
	If $sp_auxret[0] = 0 Then Return 0
4157
	$sp_auxret = DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $htoken)
4158
	If NOT $ret[0] AND NOT $sp_auxret[0] Then Return 0
4159
	Return $ret[0]
4160
EndFunc
4161
4162
Func _memorymodulegetbaseaddress($ipid, $smodule)
4163
	If NOT ProcessExists($ipid) Then Return SetError(1, 0, 0)
4164
	If NOT IsString($smodule) Then Return SetError(2, 0, 0)
4165
	Local $psapi = DllOpen("psapi.dll")
4166
	Local $hprocess
4167
	Local $permission = BitOR(2, 1024, 8, 16, 32)
4168
	If $ipid > 0 Then
4169
		Local $hprocess = DllCall("kernel32.dll", "ptr", "OpenProcess", "dword", $permission, "int", 0, "dword", $ipid)
4170
		If $hprocess[0] Then
4171
			$hprocess = $hprocess[0]
4172
		EndIf
4173
	EndIf
4174
	Local $modules = DllStructCreate("ptr[1024]")
4175
	Local $acall = DllCall($psapi, "int", "EnumProcessModules", "ptr", $hprocess, "ptr", DllStructGetPtr($modules), "dword", DllStructGetSize($modules), "dword*", 0)
4176
	If $acall[4] > 0 Then
4177
		Local $imodnum = $acall[4] / 4
4178
		Local $atemp
4179
		For $i = 1 To $imodnum
4180
			$atemp = DllCall($psapi, "dword", "GetModuleBaseNameW", "ptr", $hprocess, "ptr", Ptr(DllStructGetData($modules, 1, $i)), "wstr", "", "dword", 260)
4181
			If $atemp[3] = $smodule Then
4182
				DllClose($psapi)
4183
				Return Ptr(DllStructGetData($modules, 1, $i))
4184
			EndIf
4185
		Next
4186
	EndIf
4187
	DllClose($psapi)
4188
	Return SetError(-1, 0, 0)
4189
	_memoryclose($pid)
4190
EndFunc
4191
4192
Func _findpattern($iv_pid, $dwstart, $bpattern, $bprotected = False)
4193
	If $bprotected = False Then
4194
		Local $dwstart2 = $dwstart - 4096
4195
		Local $memopenhandle = _memoryopen($iv_pid, 2035711)
4196
		Do
4197
			$dwstart2 = $dwstart2 + 4096
4198
			Local $searchbuffer = _memoryread($dwstart2, $memopenhandle, "byte[4130]")
4199
			Local $ncount = StringInStr($searchbuffer, $bpattern)
4200
		Until $ncount = NOT 0
4201
		Local $ncountf = ($ncount / 2) - 1
4202
		Return "0x" & Hex($dwstart2 + $ncountf)
4203
		_memoryclose($iv_pid)
4204
	ElseIf $bprotected = True Then
4205
		Local $dwstart2 = $dwstart - 4096
4206
		Local $memopenhandle = _memoryopen($iv_pid, 2035711)
4207
		Do
4208
			$dwstart2 = $dwstart2 + 4096
4209
			Local $searchbuffer = _memoryreadprotected($dwstart2, $memopenhandle, "byte[4130]")
4210
			Local $ncount = StringInStr($searchbuffer, $bpattern)
4211
		Until $ncount = NOT 0
4212
		Local $ncountf = ($ncount / 2) - 1
4213
		Return "0x" & Hex($dwstart2 + $ncountf)
4214
		_memoryclose($iv_pid)
4215
	EndIf
4216
EndFunc
4217
4218
Func _findpatternhdr($iv_pid, $dwstart, $bpattern)
4219
	Local $dwstart2 = $dwstart - 147456
4220
	Local $memopenhandle = _memoryopen($iv_pid, 2035711)
4221
	Do
4222
		$dwstart2 = $dwstart2 + 147456
4223
		Local $searchbuffer = _memoryread($dwstart2, $memopenhandle, "byte[147456]")
4224
		Local $ncount = StringInStr($searchbuffer, $bpattern)
4225
	Until $ncount = NOT 0
4226
	Local $ncountf = ($ncount / 2) - 1
4227
	Return "0x" & Hex($dwstart2 + $ncountf - $dwstart)
4228
	_memoryclose($iv_pid)
4229
EndFunc
4230
4231
Func _pattern($iv_pid, $dwstart, $bpattern)
4232
	Local $dwstart2 = $dwstart
4233
	Local $memopenhandle = _memoryopen($iv_pid, 2035711)
4234
	Local $bpatterna = StringSplit($bpattern, "*", 1)
4235
	Do
4236
		$dwstart2 = $dwstart2 + 65536
4237
		Local $searchbuffer = _memoryread($dwstart2, $memopenhandle, "byte[65536]")
4238
		Local $ncount = StringInStr($searchbuffer, $bpattern)
4239
	Until $ncount = NOT 0
4240
	Local $ncountf = ($ncount / 2) - 1
4241
	Return "0x" & Hex($dwstart2 + $ncountf)
4242
	_memoryclose($iv_pid)
4243
EndFunc
4244
4245
Func __setprivilege($privilege, $benable)
4246
	Const $my_token_adjust_privileges = 32
4247
	Const $my_token_query = 8
4248
	Const $my_se_privilege_enabled = 2
4249
	Local $htoken, $sp_auxret, $sp_ret, $hcurrprocess, $ntokens, $ntokenindex, $priv
4250
	$ntokens = 1
4251
	$luid = DllStructCreate("dword;int")
4252
	If IsArray($privilege) Then $ntokens = UBound($privilege)
4253
	$token_privileges = DllStructCreate("dword;dword[" & (3 * $ntokens) & "]")
4254
	$newtoken_privileges = DllStructCreate("dword;dword[" & (3 * $ntokens) & "]")
4255
	$hcurrprocess = DllCall("kernel32.dll", "hwnd", "GetCurrentProcess")
4256
	$sp_auxret = DllCall("advapi32.dll", "int", "OpenProcessToken", "hwnd", $hcurrprocess[0], "int", BitOR($my_token_adjust_privileges, $my_token_query), "int*", 0)
4257
	If $sp_auxret[0] Then
4258
		$htoken = $sp_auxret[3]
4259
		DllStructSetData($token_privileges, 1, 1)
4260
		$ntokenindex = 1
4261
		While $ntokenindex <= $ntokens
4262
			If IsArray($privilege) Then
4263
				$priv = $privilege[$ntokenindex - 1]
4264
			Else
4265
				$priv = $privilege
4266
			EndIf
4267
			$ret = DllCall("advapi32.dll", "int", "LookupPrivilegeValue", "str", "", "str", $priv, "ptr", DllStructGetPtr($luid))
4268
			If $ret[0] Then
4269
				If $benable Then
4270
					DllStructSetData($token_privileges, 2, $my_se_privilege_enabled, (3 * $ntokenindex))
4271
				Else
4272
					DllStructSetData($token_privileges, 2, 0, (3 * $ntokenindex))
4273
				EndIf
4274
				DllStructSetData($token_privileges, 2, DllStructGetData($luid, 1), (3 * ($ntokenindex - 1)) + 1)
4275
				DllStructSetData($token_privileges, 2, DllStructGetData($luid, 2), (3 * ($ntokenindex - 1)) + 2)
4276
				DllStructSetData($luid, 1, 0)
4277
				DllStructSetData($luid, 2, 0)
4278
			EndIf
4279
			$ntokenindex += 1
4280
		WEnd
4281
		$ret = DllCall("advapi32.dll", "int", "AdjustTokenPrivileges", "hwnd", $htoken, "int", 0, "ptr", DllStructGetPtr($token_privileges), "int", DllStructGetSize($newtoken_privileges), "ptr", DllStructGetPtr($newtoken_privileges), "int*", 0)
4282
		$f = DllCall("kernel32.dll", "int", "GetLastError")
4283
	EndIf
4284
	$newtoken_privileges = 0
4285
	$token_privileges = 0
4286
	$luid = 0
4287
	If $sp_auxret[0] = 0 Then Return 0
4288
	$sp_auxret = DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $htoken)
4289
	If NOT $ret[0] AND NOT $sp_auxret[0] Then Return 0
4290
	Return $ret[0]
4291
EndFunc
4292
4293
Func swapendian($hex)
4294
	Return Hex(BitOR(BitOR(BitOR(BitShift($hex, 24), BitAND(BitShift($hex, -8), 16711680)), BitAND(BitShift($hex, 8), 65280)), BitShift($hex, -24)), 8)
4295
EndFunc
4296
4297
Func swapendian2($dw)
4298
	Return Hex(Int(StringToBinary(BinaryToString($dw), 1)))
4299
EndFunc
4300
4301
Func _getdriveinfo($sdrive)
4302
	$sdrive = StringRegExpReplace($sdrive, "(?i)(.*)([a-z]{1}:)(.*)", "$2")
4303
	Local $sdrivetype = DriveGetType($sdrive)
4304
	If $sdrivetype <> "Fixed" AND $sdrivetype <> "Removable" Then SetError(1, 0, 1)
4305
	If NOT FileExists($sdrive) Then Return SetError(1, 0, 1)
4306
	Local $wbemflagreturnimmediately = 16
4307
	Local $wbemflagforwardonly = 32
4308
	Local $colitems = ""
4309
	Local $apartition, $aphysicaldrive, $aout[14][2]
4310
	$objwmiservice = ObjGet("winmgmts:\\localhost\root\CIMV2")
4311
	If NOT IsObj($objwmiservice) Then Return SetError(2, 0, 2)
4312
	$colitems = $objwmiservice.execquery("SELECT * FROM Win32_LogicalDiskToPartition", "WQL", $wbemflagreturnimmediately + $wbemflagforwardonly)
4313
	If IsObj($colitems) Then
4314
		For $objitem In $colitems
4315
			If StringInStr($objitem.dependent, '"' & $sdrive & '"') Then
4316
				$apartition = StringRegExp($objitem.antecedent, 'DeviceID="(.*)"', 3)
4317
			EndIf
4318
		Next
4319
	EndIf
4320
	If NOT IsArray($apartition) Then Return SetError(3, 0, 3)
4321
	$colitems = $objwmiservice.execquery("SELECT * FROM Win32_DiskDriveToDiskPartition", "WQL", $wbemflagreturnimmediately + $wbemflagforwardonly)
4322
	If IsObj($colitems) Then
4323
		For $objitem In $colitems
4324
			If StringInStr($objitem.dependent, '"' & $apartition[0] & '"') Then
4325
				$aphysicaldrive = StringRegExp($objitem.antecedent, 'DeviceID="(.*)"', 3)
4326
			EndIf
4327
		Next
4328
	EndIf
4329
	If NOT IsArray($aphysicaldrive) Then Return SetError(4, 0, 4)
4330
	$aphysicaldrive[0] = StringReplace($aphysicaldrive[0], "\\", "\")
4331
	$colitems = $objwmiservice.execquery("SELECT * FROM Win32_DiskDrive", "WQL", $wbemflagreturnimmediately + $wbemflagforwardonly)
4332
	If IsObj($colitems) Then
4333
		For $objitem In $colitems
4334
			If StringInStr($objitem.deviceid, $aphysicaldrive[0]) Then
4335
				$aout[0][0] = "Volume-Label"
4336
				$aout[0][1] = DriveGetLabel($sdrive)
4337
				$aout[1][0] = "Serial-Nr. (Volume)"
4338
				$aout[1][1] = DriveGetSerial($sdrive)
4339
				$aout[2][0] = "Model"
4340
				$aout[2][1] = $objitem.model
4341
				$aout[3][0] = "Serial-Nr. (Drive)"
4342
				$aout[3][1] = StringMid($objitem.pnpdeviceid, StringInStr($objitem.pnpdeviceid, "\", 0, -1) + 1)
4343
				$aout[3][1] = StringReplace($aout[3][1], "&0", "")
4344
				$aout[4][0] = "Interface"
4345
				$aout[4][1] = $objitem.interfacetype
4346
				$aout[5][0] = "Size (Bytes)"
4347
				$aout[5][1] = $objitem.size
4348
				$aout[6][0] = "Media Type"
4349
				$aout[6][1] = StringRegExpReplace($objitem.mediatype, "[^[:print:]]", " ")
4350
				$aout[7][0] = "Total Cylinders"
4351
				$aout[7][1] = $objitem.totalcylinders
4352
				$aout[8][0] = "Total Heads"
4353
				$aout[8][1] = $objitem.totalheads
4354
				$aout[9][0] = "Total Tracks"
4355
				$aout[9][1] = $objitem.totaltracks
4356
				$aout[10][0] = "Total Sectors"
4357
				$aout[10][1] = $objitem.totalsectors
4358
				$aout[11][0] = "Tracks Per Cylinder"
4359
				$aout[11][1] = $objitem.trackspercylinder
4360
				$aout[12][0] = "Sectors Per Track"
4361
				$aout[12][1] = $objitem.sectorspertrack
4362
				$aout[13][0] = "Bytes Per Sector"
4363
				$aout[13][1] = $objitem.bytespersector
4364
			EndIf
4365
		Next
4366
	EndIf
4367
	$objwmiservice = ""
4368
	Return $aout
4369
EndFunc
4370
4371
Func createremotethread($hprocess, $lpthreadattributes, $dwstacksize, $lpstartaddress, $lpparameter, $dwcreationflags, $lpthreadid)
4372
	If NOT IsArray($hprocess) Then
4373
		SetError(1)
4374
		Return  - 1
4375
	EndIf
4376
	Return DllCall($hprocess[0], "HANDLE", "CreateRemoteThread", "HANDLE", $hprocess[1], "int", $lpthreadattributes, "int", $dwstacksize, "DWORD", $lpstartaddress, "ptr", $lpparameter, "DWORD", $dwcreationflags, "DWORD*", $lpthreadid)
4377
EndFunc
4378
4379
Func file_open($filename)
4380
	Return FileOpen($filename, 17)
4381
EndFunc
4382
4383
Func file_close($filehandle)
4384
	FileClose($filehandle)
4385
EndFunc
4386
4387
Func file_scanex($hfile, $pattern, $mask, $addr = 0)
4388
	$pattern = StringRegExpReplace($pattern, "[^0123456789ABCDEFabcdef.]", "")
4389
	If StringLen($pattern) = 0 Then
4390
		SetError(2)
4391
		Return  - 2
4392
	EndIf
4393
	If StringLen($pattern) / 2 <> StringLen($mask) Then
4394
		SetError(4)
4395
		Return  - 4
4396
	EndIf
4397
	Local $formatedpattern = ""
4398
	Local $bufferpattern
4399
	Local $buffermask
4400
	For $i = 0 To StringLen($mask) - 1
4401
		$bufferpattern = StringLeft($pattern, 2)
4402
		$pattern = StringRight($pattern, StringLen($pattern) - 2)
4403
		$buffermask = StringLeft($mask, 1)
4404
		$mask = StringRight($mask, StringLen($mask) - 1)
4405
		If $buffermask = "?" Then $bufferpattern = ".."
4406
		$formatedpattern = $formatedpattern & $bufferpattern
4407
	Next
4408
	$pattern = $formatedpattern
4409
	$bytes = StringTrimLeft(file_read($hfile, $addr, 16777215), 2)
4410
	StringRegExp($bytes, $pattern, 1, 0)
4411
	If NOT @error Then
4412
		$retn = StringFormat("0x%.8X", 0 + ((@extended - StringLen($pattern) - 2) / 2))
4413
		Return $retn
4414
	Else
4415
		Return  - 3
4416
	EndIf
4417
EndFunc
4418
4419
Func file_scan($hfile, $pattern, $addr = 0)
4420
	$bytes = StringTrimLeft(file_read($hfile, $addr, 16777215), 2)
4421
	StringRegExp($bytes, $pattern, 1, 0)
4422
	If NOT @error Then
4423
		$retn = StringFormat("0x%.8X", $addr + ((@extended - StringLen($pattern) - 2) / 2))
4424
		Return $retn
4425
	Else
4426
		Return  - 3
4427
	EndIf
4428
EndFunc
4429
4430
Func file_read($hfile, $address, $length)
4431
	FileSetPos($hfile, $address, 0)
4432
	$ret = FileRead($hfile, $length)
4433
	FileSetPos($hfile, 0, 0)
4434
	Return $ret
4435
EndFunc
4436
4437
Func file_write($hfile, $address, $bytes)
4438
	FileSetPos($hfile, $address, 0)
4439
	$ret = FileWrite($hfile, $bytes)
4440
	FileSetPos($hfile, 0, 0)
4441
	Return $ret
4442
EndFunc
4443
4444
Func _memoryscanex($ah_handle, $pattern, $mask, $after = False, $iv_addrstart = 4194304, $iv_addrend = 16777215, $step = 51200)
4445
	If NOT IsArray($ah_handle) Then
4446
		SetError(1)
4447
		Return  - 1
4448
	EndIf
4449
	$pattern = StringRegExpReplace($pattern, "[^0123456789ABCDEFabcdef.]", "")
4450
	If StringLen($pattern) = 0 Then
4451
		SetError(2)
4452
		Return  - 2
4453
	EndIf
4454
	If StringLen($pattern) / 2 <> StringLen($mask) Then
4455
		SetError(4)
4456
		Return  - 4
4457
	EndIf
4458
	Local $formatedpattern = ""
4459
	Local $bufferpattern
4460
	Local $buffermask
4461
	For $i = 0 To StringLen($mask) - 1
4462
		$bufferpattern = StringLeft($pattern, 2)
4463
		$pattern = StringRight($pattern, StringLen($pattern) - 2)
4464
		$buffermask = StringLeft($mask, 1)
4465
		$mask = StringRight($mask, StringLen($mask) - 1)
4466
		If $buffermask = "?" Then $bufferpattern = ".."
4467
		$formatedpattern = $formatedpattern & $bufferpattern
4468
	Next
4469
	$pattern = $formatedpattern
4470
	For $addr = $iv_addrstart To $iv_addrend Step $step-(StringLen($pattern) / 2 )
4471
		StringRegExp(_memoryread($addr, $ah_handle, "byte[" & $step & "]"), $pattern, 1, 2)
4472
		If NOT @error Then
4473
			If $after Then
4474
				Return StringFormat("0x%.8X", $addr + ((@extended - 2) / 2))
4475
			Else
4476
				Return StringFormat("0x%.8X", $addr + ((@extended - StringLen($pattern) - 2) / 2))
4477
			EndIf
4478
		EndIf
4479
	Next
4480
	Return  - 3
4481
EndFunc
4482
4483
Global Const $es_left = 0
4484
Global Const $es_center = 1
4485
Global Const $es_right = 2
4486
Global Const $es_multiline = 4
4487
Global Const $es_uppercase = 8
4488
Global Const $es_lowercase = 16
4489
Global Const $es_password = 32
4490
Global Const $es_autovscroll = 64
4491
Global Const $es_autohscroll = 128
4492
Global Const $es_nohidesel = 256
4493
Global Const $es_oemconvert = 1024
4494
Global Const $es_readonly = 2048
4495
Global Const $es_wantreturn = 4096
4496
Global Const $es_number = 8192
4497
Global Const $ec_err = -1
4498
Global Const $ecm_first = 5376
4499
Global Const $em_canundo = 198
4500
Global Const $em_charfrompos = 215
4501
Global Const $em_emptyundobuffer = 205
4502
Global Const $em_fmtlines = 200
4503
Global Const $em_getcuebanner = ($ecm_first + 2)
4504
Global Const $em_getfirstvisibleline = 206
4505
Global Const $em_gethandle = 189
4506
Global Const $em_getimestatus = 217
4507
Global Const $em_getlimittext = 213
4508
Global Const $em_getline = 196
4509
Global Const $em_getlinecount = 186
4510
Global Const $em_getmargins = 212
4511
Global Const $em_getmodify = 184
4512
Global Const $em_getpasswordchar = 210
4513
Global Const $em_getrect = 178
4514
Global Const $em_getsel = 176
4515
Global Const $em_getthumb = 190
4516
Global Const $em_getwordbreakproc = 209
4517
Global Const $em_hideballoontip = ($ecm_first + 4)
4518
Global Const $em_limittext = 197
4519
Global Const $em_linefromchar = 201
4520
Global Const $em_lineindex = 187
4521
Global Const $em_linelength = 193
4522
Global Const $em_linescroll = 182
4523
Global Const $em_posfromchar = 214
4524
Global Const $em_replacesel = 194
4525
Global Const $em_scroll = 181
4526
Global Const $em_scrollcaret = 183
4527
Global Const $em_setcuebanner = ($ecm_first + 1)
4528
Global Const $em_sethandle = 188
4529
Global Const $em_setimestatus = 216
4530
Global Const $em_setlimittext = $em_limittext
4531
Global Const $em_setmargins = 211
4532
Global Const $em_setmodify = 185
4533
Global Const $em_setpasswordchar = 204
4534
Global Const $em_setreadonly = 207
4535
Global Const $em_setrect = 179
4536
Global Const $em_setrectnp = 180
4537
Global Const $em_setsel = 177
4538
Global Const $em_settabstops = 203
4539
Global Const $em_setwordbreakproc = 208
4540
Global Const $em_showballoontip = ($ecm_first + 3)
4541
Global Const $em_undo = 199
4542
Global Const $ec_leftmargin = 1
4543
Global Const $ec_rightmargin = 2
4544
Global Const $ec_usefontinfo = 65535
4545
Global Const $emsis_compositionstring = 1
4546
Global Const $eimes_getcompstratonce = 1
4547
Global Const $eimes_cancelcompstrinfocus = 2
4548
Global Const $eimes_completecompstrkillfocus = 4
4549
Global Const $en_align_ltr_ec = 1792
4550
Global Const $en_align_rtl_ec = 1793
4551
Global Const $en_change = 768
4552
Global Const $en_errspace = 1280
4553
Global Const $en_hscroll = 1537
4554
Global Const $en_killfocus = 512
4555
Global Const $en_maxtext = 1281
4556
Global Const $en_setfocus = 256
4557
Global Const $en_update = 1024
4558
Global Const $en_vscroll = 1538
4559
Global Const $tti_none = 0
4560
Global Const $tti_info = 1
4561
Global Const $tti_warning = 2
4562
Global Const $tti_error = 3
4563
Global Const $tti_info_large = 4
4564
Global Const $tti_warning_large = 5
4565
Global Const $tti_error_large = 6
4566
Global Const $__editconstant_ws_vscroll = 2097152
4567
Global Const $__editconstant_ws_hscroll = 1048576
4568
Global Const $gui_ss_default_edit = BitOR($es_wantreturn, $__editconstant_ws_vscroll, $__editconstant_ws_hscroll, $es_autovscroll, $es_autohscroll)
4569
Global Const $gui_ss_default_input = BitOR($es_left, $es_autohscroll)
4570
Global Const $sbars_sizegrip = 256
4571
Global Const $sbt_tooltips = 2048
4572
Global Const $sbars_tooltips = 2048
4573
Global Const $sbt_sunken = 0
4574
Global Const $sbt_noborders = 256
4575
Global Const $sbt_popout = 512
4576
Global Const $sbt_rtlreading = 1024
4577
Global Const $sbt_notabparsing = 2048
4578
Global Const $sbt_ownerdraw = 4096
4579
Global Const $__statusbarconstant_wm_user = 1024
4580
Global Const $sb_getborders = ($__statusbarconstant_wm_user + 7)
4581
Global Const $sb_geticon = ($__statusbarconstant_wm_user + 20)
4582
Global Const $sb_getparts = ($__statusbarconstant_wm_user + 6)
4583
Global Const $sb_getrect = ($__statusbarconstant_wm_user + 10)
4584
Global Const $sb_gettexta = ($__statusbarconstant_wm_user + 2)
4585
Global Const $sb_gettextw = ($__statusbarconstant_wm_user + 13)
4586
Global Const $sb_gettext = $sb_gettexta
4587
Global Const $sb_gettextlengtha = ($__statusbarconstant_wm_user + 3)
4588
Global Const $sb_gettextlengthw = ($__statusbarconstant_wm_user + 12)
4589
Global Const $sb_gettextlength = $sb_gettextlengtha
4590
Global Const $sb_gettiptexta = ($__statusbarconstant_wm_user + 18)
4591
Global Const $sb_gettiptextw = ($__statusbarconstant_wm_user + 19)
4592
Global Const $sb_getunicodeformat = 8192 + 6
4593
Global Const $sb_issimple = ($__statusbarconstant_wm_user + 14)
4594
Global Const $sb_setbkcolor = 8192 + 1
4595
Global Const $sb_seticon = ($__statusbarconstant_wm_user + 15)
4596
Global Const $sb_setminheight = ($__statusbarconstant_wm_user + 8)
4597
Global Const $sb_setparts = ($__statusbarconstant_wm_user + 4)
4598
Global Const $sb_settexta = ($__statusbarconstant_wm_user + 1)
4599
Global Const $sb_settextw = ($__statusbarconstant_wm_user + 11)
4600
Global Const $sb_settext = $sb_settexta
4601
Global Const $sb_settiptexta = ($__statusbarconstant_wm_user + 16)
4602
Global Const $sb_settiptextw = ($__statusbarconstant_wm_user + 17)
4603
Global Const $sb_setunicodeformat = 8192 + 5
4604
Global Const $sb_simple = ($__statusbarconstant_wm_user + 9)
4605
Global Const $sb_simpleid = 255
4606
Global Const $sbn_first = -880
4607
Global Const $sbn_simplemodechange = $sbn_first - 0
4608
Global Const $gmem_fixed = 0
4609
Global Const $gmem_moveable = 2
4610
Global Const $gmem_nocompact = 16
4611
Global Const $gmem_nodiscard = 32
4612
Global Const $gmem_zeroinit = 64
4613
Global Const $gmem_modify = 128
4614
Global Const $gmem_discardable = 256
4615
Global Const $gmem_not_banked = 4096
4616
Global Const $gmem_share = 8192
4617
Global Const $gmem_ddeshare = 8192
4618
Global Const $gmem_notify = 16384
4619
Global Const $gmem_lower = 4096
4620
Global Const $gmem_valid_flags = 32626
4621
Global Const $gmem_invalid_handle = 32768
4622
Global Const $gptr = $gmem_fixed + $gmem_zeroinit
4623
Global Const $ghnd = $gmem_moveable + $gmem_zeroinit
4624
Global Const $mem_commit = 4096
4625
Global Const $mem_reserve = 8192
4626
Global Const $mem_top_down = 1048576
4627
Global Const $mem_shared = 134217728
4628
Global Const $page_noaccess = 1
4629
Global Const $page_readonly = 2
4630
Global Const $page_readwrite = 4
4631
Global Const $page_execute = 16
4632
Global Const $page_execute_read = 32
4633
Global Const $page_execute_readwrite = 64
4634
Global Const $page_guard = 256
4635
Global Const $page_nocache = 512
4636
Global Const $mem_decommit = 16384
4637
Global Const $mem_release = 32768
4638
Global Const $tagmemmap = "handle hProc;ulong_ptr Size;ptr Mem"
4639
4640
Func _memfree(ByRef $tmemmap)
4641
	Local $pmemory = DllStructGetData($tmemmap, "Mem")
4642
	Local $hprocess = DllStructGetData($tmemmap, "hProc")
4643
	Local $bresult = _memvirtualfreeex($hprocess, $pmemory, 0, $mem_release)
4644
	DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hprocess)
4645
	If @error Then Return SetError(@error, @extended, False)
4646
	Return $bresult
4647
EndFunc
4648
4649
Func _memglobalalloc($ibytes, $iflags = 0)
4650
	Local $aresult = DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", $iflags, "ulong_ptr", $ibytes)
4651
	If @error Then Return SetError(@error, @extended, 0)
4652
	Return $aresult[0]
4653
EndFunc
4654
4655
Func _memglobalfree($hmem)
4656
	Local $aresult = DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", $hmem)
4657
	If @error Then Return SetError(@error, @extended, False)
4658
	Return $aresult[0]
4659
EndFunc
4660
4661
Func _memgloballock($hmem)
4662
	Local $aresult = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", $hmem)
4663
	If @error Then Return SetError(@error, @extended, 0)
4664
	Return $aresult[0]
4665
EndFunc
4666
4667
Func _memglobalsize($hmem)
4668
	Local $aresult = DllCall("kernel32.dll", "ulong_ptr", "GlobalSize", "handle", $hmem)
4669
	If @error Then Return SetError(@error, @extended, 0)
4670
	Return $aresult[0]
4671
EndFunc
4672
4673
Func _memglobalunlock($hmem)
4674
	Local $aresult = DllCall("kernel32.dll", "bool", "GlobalUnlock", "handle", $hmem)
4675
	If @error Then Return SetError(@error, @extended, 0)
4676
	Return $aresult[0]
4677
EndFunc
4678
4679
Func _meminit($hwnd, $isize, ByRef $tmemmap)
4680
	Local $aresult = DllCall("User32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $hwnd, "dword*", 0)
4681
	If @error Then Return SetError(@error, @extended, 0)
4682
	Local $iprocessid = $aresult[2]
4683
	If $iprocessid = 0 Then Return SetError(1, 0, 0)
4684
	Local $iaccess = BitOR($process_vm_operation, $process_vm_read, $process_vm_write)
4685
	Local $hprocess = __mem_openprocess($iaccess, False, $iprocessid, True)
4686
	Local $ialloc = BitOR($mem_reserve, $mem_commit)
4687
	Local $pmemory = _memvirtualallocex($hprocess, 0, $isize, $ialloc, $page_readwrite)
4688
	If $pmemory = 0 Then Return SetError(2, 0, 0)
4689
	$tmemmap = DllStructCreate($tagmemmap)
4690
	DllStructSetData($tmemmap, "hProc", $hprocess)
4691
	DllStructSetData($tmemmap, "Size", $isize)
4692
	DllStructSetData($tmemmap, "Mem", $pmemory)
4693
	Return $pmemory
4694
EndFunc
4695
4696
Func _memmovememory($psource, $pdest, $ilength)
4697
	DllCall("kernel32.dll", "none", "RtlMoveMemory", "ptr", $pdest, "ptr", $psource, "ulong_ptr", $ilength)
4698
	If @error Then Return SetError(@error, @extended)
4699
EndFunc
4700
4701
Func _memread(ByRef $tmemmap, $psrce, $pdest, $isize)
4702
	Local $aresult = DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", DllStructGetData($tmemmap, "hProc"), "ptr", $psrce, "ptr", $pdest, "ulong_ptr", $isize, "ulong_ptr*", 0)
4703
	If @error Then Return SetError(@error, @extended, False)
4704
	Return $aresult[0]
4705
EndFunc
4706
4707
Func _memwrite(ByRef $tmemmap, $psrce, $pdest = 0, $isize = 0, $ssrce = "ptr")
4708
	If $pdest = 0 Then $pdest = DllStructGetData($tmemmap, "Mem")
4709
	If $isize = 0 Then $isize = DllStructGetData($tmemmap, "Size")
4710
	Local $aresult = DllCall("kernel32.dll", "bool", "WriteProcessMemory", "handle", DllStructGetData($tmemmap, "hProc"), "ptr", $pdest, $ssrce, $psrce, "ulong_ptr", $isize, "ulong_ptr*", 0)
4711
	If @error Then Return SetError(@error, @extended, False)
4712
	Return $aresult[0]
4713
EndFunc
4714
4715
Func _memvirtualalloc($paddress, $isize, $iallocation, $iprotect)
4716
	Local $aresult = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", $paddress, "ulong_ptr", $isize, "dword", $iallocation, "dword", $iprotect)
4717
	If @error Then Return SetError(@error, @extended, 0)
4718
	Return $aresult[0]
4719
EndFunc
4720
4721
Func _memvirtualallocex($hprocess, $paddress, $isize, $iallocation, $iprotect)
4722
	Local $aresult = DllCall("kernel32.dll", "ptr", "VirtualAllocEx", "handle", $hprocess, "ptr", $paddress, "ulong_ptr", $isize, "dword", $iallocation, "dword", $iprotect)
4723
	If @error Then Return SetError(@error, @extended, 0)
4724
	Return $aresult[0]
4725
EndFunc
4726
4727
Func _memvirtualfree($paddress, $isize, $ifreetype)
4728
	Local $aresult = DllCall("kernel32.dll", "bool", "VirtualFree", "ptr", $paddress, "ulong_ptr", $isize, "dword", $ifreetype)
4729
	If @error Then Return SetError(@error, @extended, False)
4730
	Return $aresult[0]
4731
EndFunc
4732
4733
Func _memvirtualfreeex($hprocess, $paddress, $isize, $ifreetype)
4734
	Local $aresult = DllCall("kernel32.dll", "bool", "VirtualFreeEx", "handle", $hprocess, "ptr", $paddress, "ulong_ptr", $isize, "dword", $ifreetype)
4735
	If @error Then Return SetError(@error, @extended, False)
4736
	Return $aresult[0]
4737
EndFunc
4738
4739
Func __mem_openprocess($iaccess, $finherit, $iprocessid, $fdebugpriv = False)
4740
	Local $aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $finherit, "dword", $iprocessid)
4741
	If @error Then Return SetError(@error, @extended, 0)
4742
	If $aresult[0] Then Return $aresult[0]
4743
	If NOT $fdebugpriv Then Return 0
4744
	Local $htoken = _security__openthreadtokenex(BitOR($token_adjust_privileges, $token_query))
4745
	If @error Then Return SetError(@error, @extended, 0)
4746
	_security__setprivilege($htoken, "SeDebugPrivilege", True)
4747
	Local $ierror = @error
4748
	Local $ilasterror = @extended
4749
	Local $iret = 0
4750
	If NOT @error Then
4751
		$aresult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iaccess, "bool", $finherit, "dword", $iprocessid)
4752
		$ierror = @error
4753
		$ilasterror = @extended
4754
		If $aresult[0] Then $iret = $aresult[0]
4755
		_security__setprivilege($htoken, "SeDebugPrivilege", False)
4756
		If @error Then
4757
			$ierror = @error
4758
			$ilasterror = @extended
4759
		EndIf
4760
	EndIf
4761
	DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $htoken)
4762
	Return SetError($ierror, $ilasterror, $iret)
4763
EndFunc
4764
4765
Global Const $_udf_globalids_offset = 2
4766
Global Const $_udf_globalid_max_win = 16
4767
Global Const $_udf_startid = 10000
4768
Global Const $_udf_globalid_max_ids = 55535
4769
Global Const $__udfguiconstant_ws_visible = 268435456
4770
Global Const $__udfguiconstant_ws_child = 1073741824
4771
Global $_udf_globalids_used[$_udf_globalid_max_win][$_udf_globalid_max_ids + $_udf_globalids_offset + 1]
4772
4773
Func __udf_getnextglobalid($hwnd)
4774
	Local $nctrlid, $iusedindex = -1, $fallused = True
4775
	If NOT WinExists($hwnd) Then Return SetError(-1, -1, 0)
4776
	For $iindex = 0 To $_udf_globalid_max_win - 1
4777
		If $_udf_globalids_used[$iindex][0] <> 0 Then
4778
			If NOT WinExists($_udf_globalids_used[$iindex][0]) Then
4779
				For $x = 0 To UBound($_udf_globalids_used, 2) - 1
4780
					$_udf_globalids_used[$iindex][$x] = 0
4781
				Next
4782
				$_udf_globalids_used[$iindex][1] = $_udf_startid
4783
				$fallused = False
4784
			EndIf
4785
		EndIf
4786
	Next
4787
	For $iindex = 0 To $_udf_globalid_max_win - 1
4788
		If $_udf_globalids_used[$iindex][0] = $hwnd Then
4789
			$iusedindex = $iindex
4790
			ExitLoop 
4791
		EndIf
4792
	Next
4793
	If $iusedindex = -1 Then
4794
		For $iindex = 0 To $_udf_globalid_max_win - 1
4795
			If $_udf_globalids_used[$iindex][0] = 0 Then
4796
				$_udf_globalids_used[$iindex][0] = $hwnd
4797
				$_udf_globalids_used[$iindex][1] = $_udf_startid
4798
				$fallused = False
4799
				$iusedindex = $iindex
4800
				ExitLoop 
4801
			EndIf
4802
		Next
4803
	EndIf
4804
	If $iusedindex = -1 AND $fallused Then Return SetError(16, 0, 0)
4805
	If $_udf_globalids_used[$iusedindex][1] = $_udf_startid + $_udf_globalid_max_ids Then
4806
		For $iidindex = $_udf_globalids_offset To UBound($_udf_globalids_used, 2) - 1
4807
			If $_udf_globalids_used[$iusedindex][$iidindex] = 0 Then
4808
				$nctrlid = ($iidindex - $_udf_globalids_offset) + 10000
4809
				$_udf_globalids_used[$iusedindex][$iidindex] = $nctrlid
4810
				Return $nctrlid
4811
			EndIf
4812
		Next
4813
		Return SetError(-1, $_udf_globalid_max_ids, 0)
4814
	EndIf
4815
	$nctrlid = $_udf_globalids_used[$iusedindex][1]
4816
	$_udf_globalids_used[$iusedindex][1] += 1
4817
	$_udf_globalids_used[$iusedindex][($nctrlid - 10000) + $_udf_globalids_offset] = $nctrlid
4818
	Return $nctrlid
4819
EndFunc
4820
4821
Func __udf_freeglobalid($hwnd, $iglobalid)
4822
	If $iglobalid - $_udf_startid < 0 OR $iglobalid - $_udf_startid > $_udf_globalid_max_ids Then Return SetError(-1, 0, False)
4823
	For $iindex = 0 To $_udf_globalid_max_win - 1
4824
		If $_udf_globalids_used[$iindex][0] = $hwnd Then
4825
			For $x = $_udf_globalids_offset To UBound($_udf_globalids_used, 2) - 1
4826
				If $_udf_globalids_used[$iindex][$x] = $iglobalid Then
4827
					$_udf_globalids_used[$iindex][$x] = 0
4828
					Return True
4829
				EndIf
4830
			Next
4831
			Return SetError(-3, 0, False)
4832
		EndIf
4833
	Next
4834
	Return SetError(-2, 0, False)
4835
EndFunc
4836
4837
Func __udf_debugprint($stext, $iline = @ScriptLineNumber, $err = @error, $ext = @extended)
4838
	ConsoleWrite("!===========================================================" & @CRLF & "+======================================================" & @CRLF & "-->Line(" & StringFormat("%04d", $iline) & "):" & @TAB & $stext & @CRLF & "+======================================================" & @CRLF)
4839
	Return SetError($err, $ext, 1)
4840
EndFunc
4841
4842
Func __udf_validateclassname($hwnd, $sclassnames)
4843
	__udf_debugprint("This is for debugging only, set the debug variable to false before submitting")
4844
	If _winapi_isclassname($hwnd, $sclassnames) Then Return True
4845
	Local $sseparator = Opt("GUIDataSeparatorChar")
4846
	$sclassnames = StringReplace($sclassnames, $sseparator, ",")
4847
	__udf_debugprint("Invalid Class Type(s):" & @LF & @TAB & "Expecting Type(s): " & $sclassnames & @LF & @TAB & "Received Type : " & _winapi_getclassname($hwnd))
4848
	Exit 
4849
EndFunc
4850
4851
Global $__ghsblastwnd
4852
Global $debug_sb = False
4853
Global Const $__statusbarconstant_classname = "msctls_statusbar32"
4854
Global Const $__statusbarconstant_wm_size = 5
4855
Global Const $__statusbarconstant_clr_default = -16777216
4856
Global Const $tagborders = "int BX;int BY;int RX"
4857
4858
Func _guictrlstatusbar_create($hwnd, $vpartedge = -1, $vparttext = "", $istyles = -1, $iexstyles = -1)
4859
	If NOT IsHWnd($hwnd) Then Return SetError(1, 0, 0)
4860
	Local $istyle = BitOR($__udfguiconstant_ws_child, $__udfguiconstant_ws_visible)
4861
	If $istyles = -1 Then $istyles = 0
4862
	If $iexstyles = -1 Then $iexstyles = 0
4863
	Local $apartwidth[1], $aparttext[1]
4864
	If @NumParams > 1 Then
4865
		If IsArray($vpartedge) Then
4866
			$apartwidth = $vpartedge
4867
		Else
4868
			$apartwidth[0] = $vpartedge
4869
		EndIf
4870
		If @NumParams = 2 Then
4871
			ReDim $aparttext[UBound($apartwidth)]
4872
		Else
4873
			If IsArray($vparttext) Then
4874
				$aparttext = $vparttext
4875
			Else
4876
				$aparttext[0] = $vparttext
4877
			EndIf
4878
			If UBound($apartwidth) <> UBound($aparttext) Then
4879
				Local $ilast
4880
				If UBound($apartwidth) > UBound($aparttext) Then
4881
					$ilast = UBound($aparttext)
4882
					ReDim $aparttext[UBound($apartwidth)]
4883
					For $x = $ilast To UBound($aparttext) - 1
4884
						$apartwidth[$x] = ""
4885
					Next
4886
				Else
4887
					$ilast = UBound($apartwidth)
4888
					ReDim $apartwidth[UBound($aparttext)]
4889
					For $x = $ilast To UBound($apartwidth) - 1
4890
						$apartwidth[$x] = $apartwidth[$x - 1] + 75
4891
					Next
4892
					$apartwidth[UBound($aparttext) - 1] = -1
4893
				EndIf
4894
			EndIf
4895
		EndIf
4896
		If NOT IsHWnd($hwnd) Then $hwnd = HWnd($hwnd)
4897
		If @NumParams > 3 Then $istyle = BitOR($istyle, $istyles)
4898
	EndIf
4899
	Local $nctrlid = __udf_getnextglobalid($hwnd)
4900
	If @error Then Return SetError(@error, @extended, 0)
4901
	Local $hwndsbar = _winapi_createwindowex($iexstyles, $__statusbarconstant_classname, "", $istyle, 0, 0, 0, 0, $hwnd, $nctrlid)
4902
	If @error Then Return SetError(@error, @extended, 0)
4903
	If @NumParams > 1 Then
4904
		_guictrlstatusbar_setparts($hwndsbar, UBound($apartwidth), $apartwidth)
4905
		For $x = 0 To UBound($aparttext) - 1
4906
			_guictrlstatusbar_settext($hwndsbar, $aparttext[$x], $x)
4907
		Next
4908
	EndIf
4909
	Return $hwndsbar
4910
EndFunc
4911
4912
Func _guictrlstatusbar_destroy(ByRef $hwnd)
4913
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
4914
	If NOT _winapi_isclassname($hwnd, $__statusbarconstant_classname) Then Return SetError(2, 2, False)
4915
	Local $destroyed = 0
4916
	If IsHWnd($hwnd) Then
4917
		If _winapi_inprocess($hwnd, $__ghsblastwnd) Then
4918
			Local $nctrlid = _winapi_getdlgctrlid($hwnd)
4919
			Local $hparent = _winapi_getparent($hwnd)
4920
			$destroyed = _winapi_destroywindow($hwnd)
4921
			Local $iret = __udf_freeglobalid($hparent, $nctrlid)
4922
			If NOT $iret Then
4923
			EndIf
4924
		Else
4925
			Return SetError(1, 1, False)
4926
		EndIf
4927
	EndIf
4928
	If $destroyed Then $hwnd = 0
4929
	Return $destroyed <> 0
4930
EndFunc
4931
4932
Func _guictrlstatusbar_embedcontrol($hwnd, $ipart, $hcontrol, $ifit = 4)
4933
	Local $arect = _guictrlstatusbar_getrect($hwnd, $ipart)
4934
	Local $ibarx = $arect[0]
4935
	Local $ibary = $arect[1]
4936
	Local $ibarw = $arect[2] - $ibarx
4937
	Local $ibarh = $arect[3] - $ibary
4938
	Local $iconx = $ibarx
4939
	Local $icony = $ibary
4940
	Local $iconw = _winapi_getwindowwidth($hcontrol)
4941
	Local $iconh = _winapi_getwindowheight($hcontrol)
4942
	If $iconw > $ibarw Then $iconw = $ibarw
4943
	If $iconh > $ibarh Then $iconh = $ibarh
4944
	Local $ipadx = ($ibarw - $iconw) / 2
4945
	Local $ipady = ($ibarh - $iconh) / 2
4946
	If $ipadx < 0 Then $ipadx = 0
4947
	If $ipady < 0 Then $ipady = 0
4948
	If BitAND($ifit, 1) = 1 Then $iconx = $ibarx + $ipadx
4949
	If BitAND($ifit, 2) = 2 Then $icony = $ibary + $ipady
4950
	If BitAND($ifit, 4) = 4 Then
4951
		$ipadx = _guictrlstatusbar_getbordersrect($hwnd)
4952
		$ipady = _guictrlstatusbar_getbordersvert($hwnd)
4953
		$iconx = $ibarx
4954
		If _guictrlstatusbar_issimple($hwnd) Then $iconx += $ipadx
4955
		$icony = $ibary + $ipady
4956
		$iconw = $ibarw - ($ipadx * 2)
4957
		$iconh = $ibarh - ($ipady * 2)
4958
	EndIf
4959
	_winapi_setparent($hcontrol, $hwnd)
4960
	_winapi_movewindow($hcontrol, $iconx, $icony, $iconw, $iconh)
4961
EndFunc
4962
4963
Func _guictrlstatusbar_getborders($hwnd)
4964
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
4965
	Local $tborders = DllStructCreate($tagborders)
4966
	Local $pborders = DllStructGetPtr($tborders)
4967
	Local $iret
4968
	If _winapi_inprocess($hwnd, $__ghsblastwnd) Then
4969
		$iret = _sendmessage($hwnd, $sb_getborders, 0, $pborders, 0, "wparam", "ptr")
4970
	Else
4971
		Local $isize = DllStructGetSize($tborders)
4972
		Local $tmemmap
4973
		Local $pmemory = _meminit($hwnd, $isize, $tmemmap)
4974
		$iret = _sendmessage($hwnd, $sb_getborders, 0, $pmemory, 0, "wparam", "ptr")
4975
		_memread($tmemmap, $pmemory, $pborders, $isize)
4976
		_memfree($tmemmap)
4977
	EndIf
4978
	Local $aborders[3]
4979
	If $iret = 0 Then Return SetError(-1, -1, $aborders)
4980
	$aborders[0] = DllStructGetData($tborders, "BX")
4981
	$aborders[1] = DllStructGetData($tborders, "BY")
4982
	$aborders[2] = DllStructGetData($tborders, "RX")
4983
	Return $aborders
4984
EndFunc
4985
4986
Func _guictrlstatusbar_getbordershorz($hwnd)
4987
	Local $aborders = _guictrlstatusbar_getborders($hwnd)
4988
	Return SetError(@error, @extended, $aborders[0])
4989
EndFunc
4990
4991
Func _guictrlstatusbar_getbordersrect($hwnd)
4992
	Local $aborders = _guictrlstatusbar_getborders($hwnd)
4993
	Return SetError(@error, @extended, $aborders[2])
4994
EndFunc
4995
4996
Func _guictrlstatusbar_getbordersvert($hwnd)
4997
	Local $aborders = _guictrlstatusbar_getborders($hwnd)
4998
	Return SetError(@error, @extended, $aborders[1])
4999
EndFunc
5000
5001
Func _guictrlstatusbar_getcount($hwnd)
5002
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
5003
	Return _sendmessage($hwnd, $sb_getparts)
5004
EndFunc
5005
5006
Func _guictrlstatusbar_getheight($hwnd)
5007
	Local $trect = _guictrlstatusbar_getrectex($hwnd, 0)
5008
	Return DllStructGetData($trect, "Bottom") - DllStructGetData($trect, "Top") - (_guictrlstatusbar_getbordersvert($hwnd) * 2)
5009
EndFunc
5010
5011
Func _guictrlstatusbar_geticon($hwnd, $iindex = 0)
5012
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
5013
	Return _sendmessage($hwnd, $sb_geticon, $iindex, 0, 0, "wparam", "lparam", "hwnd")
5014
EndFunc
5015
5016
Func _guictrlstatusbar_getparts($hwnd)
5017
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
5018
	Local $icount = _guictrlstatusbar_getcount($hwnd)
5019
	Local $tparts = DllStructCreate("int[" & $icount & "]")
5020
	Local $pparts = DllStructGetPtr($tparts)
5021
	Local $aparts[$icount + 1]
5022
	If _winapi_inprocess($hwnd, $__ghsblastwnd) Then
5023
		$aparts[0] = _sendmessage($hwnd, $sb_getparts, $icount, $pparts, 0, "wparam", "ptr")
5024
	Else
5025
		Local $iparts = DllStructGetSize($tparts)
5026
		Local $tmemmap
5027
		Local $pmemory = _meminit($hwnd, $iparts, $tmemmap)
5028
		$aparts[0] = _sendmessage($hwnd, $sb_getparts, $icount, $pmemory, 0, "wparam", "ptr")
5029
		_memread($tmemmap, $pmemory, $pparts, $iparts)
5030
		_memfree($tmemmap)
5031
	EndIf
5032
	For $ii = 1 To $icount
5033
		$aparts[$ii] = DllStructGetData($tparts, 1, $ii)
5034
	Next
5035
	Return $aparts
5036
EndFunc
5037
5038
Func _guictrlstatusbar_getrect($hwnd, $ipart)
5039
	Local $trect = _guictrlstatusbar_getrectex($hwnd, $ipart)
5040
	If @error Then Return SetError(@error, 0, 0)
5041
	Local $arect[4]
5042
	$arect[0] = DllStructGetData($trect, "Left")
5043
	$arect[1] = DllStructGetData($trect, "Top")
5044
	$arect[2] = DllStructGetData($trect, "Right")
5045
	$arect[3] = DllStructGetData($trect, "Bottom")
5046
	Return $arect
5047
EndFunc
5048
5049
Func _guictrlstatusbar_getrectex($hwnd, $ipart)
5050
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
5051
	Local $trect = DllStructCreate($tagrect)
5052
	Local $prect = DllStructGetPtr($trect)
5053
	Local $iret
5054
	If _winapi_inprocess($hwnd, $__ghsblastwnd) Then
5055
		$iret = _sendmessage($hwnd, $sb_getrect, $ipart, $prect, 0, "wparam", "ptr")
5056
	Else
5057
		Local $irect = DllStructGetSize($trect)
5058
		Local $tmemmap
5059
		Local $pmemory = _meminit($hwnd, $irect, $tmemmap)
5060
		$iret = _sendmessage($hwnd, $sb_getrect, $ipart, $pmemory, 0, "wparam", "ptr")
5061
		_memread($tmemmap, $pmemory, $prect, $irect)
5062
		_memfree($tmemmap)
5063
	EndIf
5064
	Return SetError($iret = 0, 0, $trect)
5065
EndFunc
5066
5067
Func _guictrlstatusbar_gettext($hwnd, $ipart)
5068
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
5069
	Local $funicode = _guictrlstatusbar_getunicodeformat($hwnd)
5070
	Local $ibuffer = _guictrlstatusbar_gettextlength($hwnd, $ipart)
5071
	If $ibuffer = 0 Then Return SetError(1, 0, "")
5072
	Local $tbuffer
5073
	If $funicode Then
5074
		$tbuffer = DllStructCreate("wchar Text[" & $ibuffer & "]")
5075
		$ibuffer *= 2
5076
	Else
5077
		$tbuffer = DllStructCreate("char Text[" & $ibuffer & "]")
5078
	EndIf
5079
	Local $pbuffer = DllStructGetPtr($tbuffer)
5080
	If _winapi_inprocess($hwnd, $__ghsblastwnd) Then
5081
		_sendmessage($hwnd, $sb_gettextw, $ipart, $pbuffer, 0, "wparam", "ptr")
5082
	Else
5083
		Local $tmemmap
5084
		Local $pmemory = _meminit($hwnd, $ibuffer, $tmemmap)
5085
		If $funicode Then
5086
			_sendmessage($hwnd, $sb_gettextw, $ipart, $pmemory, 0, "wparam", "ptr")
5087
		Else
5088
			_sendmessage($hwnd, $sb_gettext, $ipart, $pmemory, 0, "wparam", "ptr")
5089
		EndIf
5090
		_memread($tmemmap, $pmemory, $pbuffer, $ibuffer)
5091
		_memfree($tmemmap)
5092
	EndIf
5093
	Return DllStructGetData($tbuffer, "Text")
5094
EndFunc
5095
5096
Func _guictrlstatusbar_gettextflags($hwnd, $ipart)
5097
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
5098
	If _guictrlstatusbar_getunicodeformat($hwnd) Then
5099
		Return _sendmessage($hwnd, $sb_gettextlengthw, $ipart)
5100
	Else
5101
		Return _sendmessage($hwnd, $sb_gettextlength, $ipart)
5102
	EndIf
5103
EndFunc
5104
5105
Func _guictrlstatusbar_gettextlength($hwnd, $ipart)
5106
	Return _winapi_loword(_guictrlstatusbar_gettextflags($hwnd, $ipart))
5107
EndFunc
5108
5109
Func _guictrlstatusbar_gettextlengthex($hwnd, $ipart)
5110
	Return _winapi_hiword(_guictrlstatusbar_gettextflags($hwnd, $ipart))
5111
EndFunc
5112
5113
Func _guictrlstatusbar_gettiptext($hwnd, $ipart)
5114
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
5115
	Local $funicode = _guictrlstatusbar_getunicodeformat($hwnd)
5116
	Local $tbuffer
5117
	If $funicode Then
5118
		$tbuffer = DllStructCreate("wchar Text[4096]")
5119
	Else
5120
		$tbuffer = DllStructCreate("char Text[4096]")
5121
	EndIf
5122
	Local $pbuffer = DllStructGetPtr($tbuffer)
5123
	If _winapi_inprocess($hwnd, $__ghsblastwnd) Then
5124
		_sendmessage($hwnd, $sb_gettiptextw, _winapi_makelong($ipart, 4096), $pbuffer, 0, "wparam", "ptr")
5125
	Else
5126
		Local $tmemmap
5127
		Local $pmemory = _meminit($hwnd, 4096, $tmemmap)
5128
		If $funicode Then
5129
			_sendmessage($hwnd, $sb_gettiptextw, _winapi_makelong($ipart, 4096), $pmemory, 0, "wparam", "ptr")
5130
		Else
5131
			_sendmessage($hwnd, $sb_gettiptexta, _winapi_makelong($ipart, 4096), $pmemory, 0, "wparam", "ptr")
5132
		EndIf
5133
		_memread($tmemmap, $pmemory, $pbuffer, 4096)
5134
		_memfree($tmemmap)
5135
	EndIf
5136
	Return DllStructGetData($tbuffer, "Text")
5137
EndFunc
5138
5139
Func _guictrlstatusbar_getunicodeformat($hwnd)
5140
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
5141
	Return _sendmessage($hwnd, $sb_getunicodeformat) <> 0
5142
EndFunc
5143
5144
Func _guictrlstatusbar_getwidth($hwnd, $ipart)
5145
	Local $trect = _guictrlstatusbar_getrectex($hwnd, $ipart)
5146
	Return DllStructGetData($trect, "Right") - DllStructGetData($trect, "Left") - (_guictrlstatusbar_getbordershorz($hwnd) * 2)
5147
EndFunc
5148
5149
Func _guictrlstatusbar_issimple($hwnd)
5150
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
5151
	Return _sendmessage($hwnd, $sb_issimple) <> 0
5152
EndFunc
5153
5154
Func _guictrlstatusbar_resize($hwnd)
5155
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
5156
	_sendmessage($hwnd, $__statusbarconstant_wm_size)
5157
EndFunc
5158
5159
Func _guictrlstatusbar_setbkcolor($hwnd, $icolor)
5160
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
5161
	$icolor = _sendmessage($hwnd, $sb_setbkcolor, 0, $icolor)
5162
	If $icolor = $__statusbarconstant_clr_default Then Return "0x" & Hex($__statusbarconstant_clr_default)
5163
	Return $icolor
5164
EndFunc
5165
5166
Func _guictrlstatusbar_seticon($hwnd, $ipart, $hicon = -1, $siconfile = "")
5167
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
5168
	If $hicon = -1 Then Return _sendmessage($hwnd, $sb_seticon, $ipart, $hicon, 0, "wparam", "handle") <> 0
5169
	If StringLen($siconfile) <= 0 Then Return _sendmessage($hwnd, $sb_seticon, $ipart, $hicon) <> 0
5170
	Local $ticon = DllStructCreate("handle")
5171
	Local $vresult = DllCall("shell32.dll", "uint", "ExtractIconExW", "wstr", $siconfile, "int", $hicon, "ptr", 0, "ptr", DllStructGetPtr($ticon), "uint", 1)
5172
	If @error Then Return SetError(@error, @extended, False)
5173
	$vresult = $vresult[0]
5174
	If $vresult > 0 Then $vresult = _sendmessage($hwnd, $sb_seticon, $ipart, DllStructGetData($ticon, 1), 0, "wparam", "handle")
5175
	DllCall("user32.dll", "bool", "DestroyIcon", "handle", DllStructGetData($ticon, 1))
5176
	Return $vresult
5177
EndFunc
5178
5179
Func _guictrlstatusbar_setminheight($hwnd, $iminheight)
5180
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
5181
	_sendmessage($hwnd, $sb_setminheight, $iminheight)
5182
	_guictrlstatusbar_resize($hwnd)
5183
EndFunc
5184
5185
Func _guictrlstatusbar_setparts($hwnd, $iaparts = -1, $iapartwidth = 25)
5186
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
5187
	Local $tparts, $iparts = 1
5188
	If IsArray($iaparts) <> 0 Then
5189
		$iaparts[UBound($iaparts) - 1] = -1
5190
		$iparts = UBound($iaparts)
5191
		$tparts = DllStructCreate("int[" & $iparts & "]")
5192
		For $x = 0 To $iparts - 2
5193
			DllStructSetData($tparts, 1, $iaparts[$x], $x + 1)
5194
		Next
5195
		DllStructSetData($tparts, 1, -1, $iparts)
5196
	ElseIf IsArray($iapartwidth) <> 0 Then
5197
		$iparts = UBound($iapartwidth)
5198
		$tparts = DllStructCreate("int[" & $iparts & "]")
5199
		For $x = 0 To $iparts - 2
5200
			DllStructSetData($tparts, 1, $iapartwidth[$x], $x + 1)
5201
		Next
5202
		DllStructSetData($tparts, 1, -1, $iparts)
5203
	ElseIf $iaparts > 1 Then
5204
		$iparts = $iaparts
5205
		$tparts = DllStructCreate("int[" & $iparts & "]")
5206
		For $x = 1 To $iparts - 1
5207
			DllStructSetData($tparts, 1, $iapartwidth * $x, $x)
5208
		Next
5209
		DllStructSetData($tparts, 1, -1, $iparts)
5210
	Else
5211
		$tparts = DllStructCreate("int")
5212
		DllStructSetData($tparts, $iparts, -1)
5213
	EndIf
5214
	Local $pparts = DllStructGetPtr($tparts)
5215
	If _winapi_inprocess($hwnd, $__ghsblastwnd) Then
5216
		_sendmessage($hwnd, $sb_setparts, $iparts, $pparts, 0, "wparam", "ptr")
5217
	Else
5218
		Local $isize = DllStructGetSize($tparts)
5219
		Local $tmemmap
5220
		Local $pmemory = _meminit($hwnd, $isize, $tmemmap)
5221
		_memwrite($tmemmap, $pparts)
5222
		_sendmessage($hwnd, $sb_setparts, $iparts, $pmemory, 0, "wparam", "ptr")
5223
		_memfree($tmemmap)
5224
	EndIf
5225
	_guictrlstatusbar_resize($hwnd)
5226
	Return True
5227
EndFunc
5228
5229
Func _guictrlstatusbar_setsimple($hwnd, $fsimple = True)
5230
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
5231
	_sendmessage($hwnd, $sb_simple, $fsimple)
5232
EndFunc
5233
5234
Func _guictrlstatusbar_settext($hwnd, $stext = "", $ipart = 0, $iuflag = 0)
5235
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
5236
	Local $funicode = _guictrlstatusbar_getunicodeformat($hwnd)
5237
	Local $ibuffer = StringLen($stext) + 1
5238
	Local $ttext
5239
	If $funicode Then
5240
		$ttext = DllStructCreate("wchar Text[" & $ibuffer & "]")
5241
		$ibuffer *= 2
5242
	Else
5243
		$ttext = DllStructCreate("char Text[" & $ibuffer & "]")
5244
	EndIf
5245
	Local $pbuffer = DllStructGetPtr($ttext)
5246
	DllStructSetData($ttext, "Text", $stext)
5247
	If _guictrlstatusbar_issimple($hwnd) Then $ipart = $sb_simpleid
5248
	Local $iret
5249
	If _winapi_inprocess($hwnd, $__ghsblastwnd) Then
5250
		$iret = _sendmessage($hwnd, $sb_settextw, BitOR($ipart, $iuflag), $pbuffer, 0, "wparam", "ptr")
5251
	Else
5252
		Local $tmemmap
5253
		Local $pmemory = _meminit($hwnd, $ibuffer, $tmemmap)
5254
		_memwrite($tmemmap, $pbuffer)
5255
		If $funicode Then
5256
			$iret = _sendmessage($hwnd, $sb_settextw, BitOR($ipart, $iuflag), $pmemory, 0, "wparam", "ptr")
5257
		Else
5258
			$iret = _sendmessage($hwnd, $sb_settext, BitOR($ipart, $iuflag), $pmemory, 0, "wparam", "ptr")
5259
		EndIf
5260
		_memfree($tmemmap)
5261
	EndIf
5262
	Return $iret <> 0
5263
EndFunc
5264
5265
Func _guictrlstatusbar_settiptext($hwnd, $ipart, $stext)
5266
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
5267
	Local $funicode = _guictrlstatusbar_getunicodeformat($hwnd)
5268
	Local $ibuffer = StringLen($stext) + 1
5269
	Local $ttext
5270
	If $funicode Then
5271
		$ttext = DllStructCreate("wchar TipText[" & $ibuffer & "]")
5272
		$ibuffer *= 2
5273
	Else
5274
		$ttext = DllStructCreate("char TipText[" & $ibuffer & "]")
5275
	EndIf
5276
	Local $pbuffer = DllStructGetPtr($ttext)
5277
	DllStructSetData($ttext, "TipText", $stext)
5278
	If _winapi_inprocess($hwnd, $__ghsblastwnd) Then
5279
		_sendmessage($hwnd, $sb_settiptextw, $ipart, $pbuffer, 0, "wparam", "ptr")
5280
	Else
5281
		Local $tmemmap
5282
		Local $pmemory = _meminit($hwnd, $ibuffer, $tmemmap)
5283
		_memwrite($tmemmap, $pbuffer, $pmemory, $ibuffer)
5284
		If $funicode Then
5285
			_sendmessage($hwnd, $sb_settiptextw, $ipart, $pmemory, 0, "wparam", "ptr")
5286
		Else
5287
			_sendmessage($hwnd, $sb_settiptexta, $ipart, $pmemory, 0, "wparam", "ptr")
5288
		EndIf
5289
		_memfree($tmemmap)
5290
	EndIf
5291
EndFunc
5292
5293
Func _guictrlstatusbar_setunicodeformat($hwnd, $funicode = True)
5294
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
5295
	Return _sendmessage($hwnd, $sb_setunicodeformat, $funicode)
5296
EndFunc
5297
5298
Func _guictrlstatusbar_showhide($hwnd, $istate)
5299
	If $debug_sb Then __udf_validateclassname($hwnd, $__statusbarconstant_classname)
5300
	If $istate <> @SW_HIDE AND $istate <> @SW_SHOW Then Return SetError(1, 1, False)
5301
	Return _winapi_showwindow($hwnd, $istate)
5302
EndFunc
5303
5304
Global $_gheditlastwnd
5305
Global $debug_ed = False
5306
Global Const $__editconstant_classname = "Edit"
5307
Global Const $__editconstant_gui_checked = 1
5308
Global Const $__editconstant_gui_hide = 32
5309
Global Const $__editconstant_gui_event_close = -3
5310
Global Const $__editconstant_gui_enable = 64
5311
Global Const $__editconstant_gui_disable = 128
5312
Global Const $__editconstant_ss_center = 1
5313
Global Const $__editconstant_wm_setredraw = 11
5314
Global Const $__editconstant_ws_caption = 12582912
5315
Global Const $__editconstant_ws_popup = -2147483648
5316
Global Const $__editconstant_ws_tabstop = 65536
5317
Global Const $__editconstant_ws_sysmenu = 524288
5318
Global Const $__editconstant_ws_minimizebox = 131072
5319
Global Const $__editconstant_default_gui_font = 17
5320
Global Const $__editconstant_wm_setfont = 48
5321
Global Const $__editconstant_wm_gettextlength = 14
5322
Global Const $__editconstant_wm_gettext = 13
5323
Global Const $__editconstant_wm_settext = 12
5324
Global Const $__editconstant_sb_lineup = 0
5325
Global Const $__editconstant_sb_linedown = 1
5326
Global Const $__editconstant_sb_pagedown = 3
5327
Global Const $__editconstant_sb_pageup = 2
5328
Global Const $__editconstant_sb_scrollcaret = 4
5329
Global Const $tageditballoontip = "dword Size;ptr Title;ptr Text;int Icon"
5330
5331
Func _guictrledit_appendtext($hwnd, $stext)
5332
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5333
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5334
	Local $ilength = _guictrledit_gettextlen($hwnd)
5335
	_guictrledit_setsel($hwnd, $ilength, $ilength)
5336
	_sendmessage($hwnd, $em_replacesel, True, $stext, 0, "wparam", "wstr")
5337
EndFunc
5338
5339
Func _guictrledit_beginupdate($hwnd)
5340
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5341
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5342
	Return _sendmessage($hwnd, $__editconstant_wm_setredraw) = 0
5343
EndFunc
5344
5345
Func _guictrledit_canundo($hwnd)
5346
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5347
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5348
	Return _sendmessage($hwnd, $em_canundo) <> 0
5349
EndFunc
5350
5351
Func _guictrledit_charfrompos($hwnd, $ix, $iy)
5352
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5353
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5354
	Local $areturn[2]
5355
	Local $iret = _sendmessage($hwnd, $em_charfrompos, 0, _winapi_makelong($ix, $iy))
5356
	$areturn[0] = _winapi_loword($iret)
5357
	$areturn[1] = _winapi_hiword($iret)
5358
	Return $areturn
5359
EndFunc
5360
5361
Func _guictrledit_create($hwnd, $stext, $ix, $iy, $iwidth = 150, $iheight = 150, $istyle = 3150020, $iexstyle = 512)
5362
	If NOT IsHWnd($hwnd) Then Return SetError(1, 0, 0)
5363
	If NOT IsString($stext) Then Return SetError(2, 0, 0)
5364
	If $iwidth = -1 Then $iwidth = 150
5365
	If $iheight = -1 Then $iheight = 150
5366
	If $istyle = -1 Then $istyle = 3150020
5367
	If $iexstyle = -1 Then $iexstyle = 512
5368
	If BitAND($istyle, $es_readonly) = $es_readonly Then
5369
		$istyle = BitOR($__udfguiconstant_ws_child, $__udfguiconstant_ws_visible, $istyle)
5370
	Else
5371
		$istyle = BitOR($__udfguiconstant_ws_child, $__udfguiconstant_ws_visible, $__editconstant_ws_tabstop, $istyle)
5372
	EndIf
5373
	Local $nctrlid = __udf_getnextglobalid($hwnd)
5374
	If @error Then Return SetError(@error, @extended, 0)
5375
	Local $hedit = _winapi_createwindowex($iexstyle, $__editconstant_classname, "", $istyle, $ix, $iy, $iwidth, $iheight, $hwnd, $nctrlid)
5376
	_sendmessage($hedit, $__editconstant_wm_setfont, _winapi_getstockobject($__editconstant_default_gui_font), True)
5377
	_guictrledit_settext($hedit, $stext)
5378
	_guictrledit_setlimittext($hedit, 0)
5379
	Return $hedit
5380
EndFunc
5381
5382
Func _guictrledit_destroy(ByRef $hwnd)
5383
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5384
	If NOT _winapi_isclassname($hwnd, $__editconstant_classname) Then Return SetError(2, 2, False)
5385
	Local $destroyed = 0
5386
	If IsHWnd($hwnd) Then
5387
		If _winapi_inprocess($hwnd, $_gheditlastwnd) Then
5388
			Local $nctrlid = _winapi_getdlgctrlid($hwnd)
5389
			Local $hparent = _winapi_getparent($hwnd)
5390
			$destroyed = _winapi_destroywindow($hwnd)
5391
			Local $iret = __udf_freeglobalid($hparent, $nctrlid)
5392
			If NOT $iret Then
5393
			EndIf
5394
		Else
5395
			Return SetError(1, 1, False)
5396
		EndIf
5397
	Else
5398
		$destroyed = GUICtrlDelete($hwnd)
5399
	EndIf
5400
	If $destroyed Then $hwnd = 0
5401
	Return $destroyed <> 0
5402
EndFunc
5403
5404
Func _guictrledit_emptyundobuffer($hwnd)
5405
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5406
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5407
	_sendmessage($hwnd, $em_emptyundobuffer)
5408
EndFunc
5409
5410
Func _guictrledit_endupdate($hwnd)
5411
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5412
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5413
	Return _sendmessage($hwnd, $__editconstant_wm_setredraw, 1) = 0
5414
EndFunc
5415
5416
Func _guictrledit_fmtlines($hwnd, $fsoftbreak = False)
5417
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5418
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5419
	Return _sendmessage($hwnd, $em_fmtlines, $fsoftbreak)
5420
EndFunc
5421
5422
Func _guictrledit_find($hwnd, $freplace = False)
5423
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5424
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5425
	Local $ipos = 0, $icase, $ioccurance = 0, $ireplacements = 0
5426
	Local $apartsrightedge[3] = [125, 225, -1]
5427
	Local $oldmode = Opt("GUIOnEventMode", 0)
5428
	Local $asel = _guictrledit_getsel($hwnd)
5429
	Local $stext = _guictrledit_gettext($hwnd)
5430
	Local $guisearch = GUICreate("Find", 349, 177, -1, -1, BitOR($__udfguiconstant_ws_child, $__editconstant_ws_minimizebox, $__editconstant_ws_caption, $__editconstant_ws_popup, $__editconstant_ws_sysmenu))
5431
	Local $statusbar1 = _guictrlstatusbar_create($guisearch, $apartsrightedge)
5432
	_guictrlstatusbar_settext($statusbar1, "Find: ")
5433
	GUISetIcon(@SystemDir & "\shell32.dll", 22, $guisearch)
5434
	GUICtrlCreateLabel("Find what:", 9, 10, 53, 16, $__editconstant_ss_center)
5435
	Local $inputsearch = GUICtrlCreateInput("", 80, 8, 257, 21)
5436
	Local $lblreplace = GUICtrlCreateLabel("Replace with:", 9, 42, 69, 17, $__editconstant_ss_center)
5437
	Local $inputreplace = GUICtrlCreateInput("", 80, 40, 257, 21)
5438
	Local $chkwholeonly = GUICtrlCreateCheckbox("Match whole word only", 9, 72, 145, 17)
5439
	Local $chkmatchcase = GUICtrlCreateCheckbox("Match case", 9, 96, 145, 17)
5440
	Local $btnfindnext = GUICtrlCreateButton("Find Next", 168, 72, 161, 21, 0)
5441
	Local $btnreplace = GUICtrlCreateButton("Replace", 168, 96, 161, 21, 0)
5442
	Local $btnclose = GUICtrlCreateButton("Close", 104, 130, 161, 21, 0)
5443
	If (IsArray($asel) AND $asel <> $ec_err) Then
5444
		GUICtrlSetData($inputsearch, StringMid($stext, $asel[0] + 1, $asel[1] - $asel[0]))
5445
		If $asel[0] <> $asel[1] Then
5446
			$ipos = $asel[0]
5447
			If BitAND(GUICtrlRead($chkmatchcase), $__editconstant_gui_checked) = $__editconstant_gui_checked Then $icase = 1
5448
			$ioccurance = 1
5449
			Local $itpose
5450
			While 1
5451
				$itpose = StringInStr($stext, GUICtrlRead($inputsearch), $icase, $ioccurance)
5452
				If NOT $itpose Then
5453
					$ioccurance = 0
5454
					ExitLoop 
5455
				ElseIf $itpose = $ipos + 1 Then
5456
					ExitLoop 
5457
				EndIf
5458
				$ioccurance += 1
5459
			WEnd
5460
		EndIf
5461
		_guictrlstatusbar_settext($statusbar1, "Find: " & GUICtrlRead($inputsearch))
5462
	EndIf
5463
	If $freplace = False Then
5464
		GUICtrlSetState($lblreplace, $__editconstant_gui_hide)
5465
		GUICtrlSetState($inputreplace, $__editconstant_gui_hide)
5466
		GUICtrlSetState($btnreplace, $__editconstant_gui_hide)
5467
	Else
5468
		_guictrlstatusbar_settext($statusbar1, "Replacements: " & $ireplacements, 1)
5469
		_guictrlstatusbar_settext($statusbar1, "With: ", 2)
5470
	EndIf
5471
	GUISetState(@SW_SHOW)
5472
	Local $msgfind
5473
	While 1
5474
		$msgfind = GUIGetMsg()
5475
		Select 
5476
			Case $msgfind = $__editconstant_gui_event_close OR $msgfind = $btnclose
5477
				ExitLoop 
5478
			Case $msgfind = $btnfindnext
5479
				GUICtrlSetState($btnfindnext, $__editconstant_gui_disable)
5480
				GUICtrlSetCursor($btnfindnext, 15)
5481
				Sleep(100)
5482
				_guictrlstatusbar_settext($statusbar1, "Find: " & GUICtrlRead($inputsearch))
5483
				If $freplace = True Then
5484
					_guictrlstatusbar_settext($statusbar1, "Find: " & GUICtrlRead($inputsearch))
5485
					_guictrlstatusbar_settext($statusbar1, "With: " & GUICtrlRead($inputreplace), 2)
5486
				EndIf
5487
				__guictrledit_findtext($hwnd, $inputsearch, $chkmatchcase, $chkwholeonly, $ipos, $ioccurance, $ireplacements)
5488
				Sleep(100)
5489
				GUICtrlSetState($btnfindnext, $__editconstant_gui_enable)
5490
				GUICtrlSetCursor($btnfindnext, 2)
5491
			Case $msgfind = $btnreplace
5492
				GUICtrlSetState($btnreplace, $__editconstant_gui_disable)
5493
				GUICtrlSetCursor($btnreplace, 15)
5494
				Sleep(100)
5495
				_guictrlstatusbar_settext($statusbar1, "Find: " & GUICtrlRead($inputsearch))
5496
				_guictrlstatusbar_settext($statusbar1, "With: " & GUICtrlRead($inputreplace), 2)
5497
				If $ipos Then
5498
					_guictrledit_replacesel($hwnd, GUICtrlRead($inputreplace))
5499
					$ireplacements += 1
5500
					$ioccurance -= 1
5501
					_guictrlstatusbar_settext($statusbar1, "Replacements: " & $ireplacements, 1)
5502
				EndIf
5503
				__guictrledit_findtext($hwnd, $inputsearch, $chkmatchcase, $chkwholeonly, $ipos, $ioccurance, $ireplacements)
5504
				Sleep(100)
5505
				GUICtrlSetState($btnreplace, $__editconstant_gui_enable)
5506
				GUICtrlSetCursor($btnreplace, 2)
5507
		EndSelect
5508
	WEnd
5509
	GUIDelete($guisearch)
5510
	Opt("GUIOnEventMode", $oldmode)
5511
EndFunc
5512
5513
Func __guictrledit_findtext($hwnd, $inputsearch, $chkmatchcase, $chkwholeonly, ByRef $ipos, ByRef $ioccurance, ByRef $ireplacements)
5514
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5515
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5516
	Local $icase = 0, $iwhole = 0
5517
	Local $fexact = False
5518
	Local $sfind = GUICtrlRead($inputsearch)
5519
	Local $stext = _guictrledit_gettext($hwnd)
5520
	If BitAND(GUICtrlRead($chkmatchcase), $__editconstant_gui_checked) = $__editconstant_gui_checked Then $icase = 1
5521
	If BitAND(GUICtrlRead($chkwholeonly), $__editconstant_gui_checked) = $__editconstant_gui_checked Then $iwhole = 1
5522
	If $sfind <> "" Then
5523
		$ioccurance += 1
5524
		$ipos = StringInStr($stext, $sfind, $icase, $ioccurance)
5525
		If $iwhole AND $ipos Then
5526
			Local $c_compare2 = StringMid($stext, $ipos + StringLen($sfind), 1)
5527
			If $ipos = 1 Then
5528
				If ($ipos + StringLen($sfind)) - 1 = StringLen($stext) OR ($c_compare2 = " " OR $c_compare2 = @LF OR $c_compare2 = @CR OR $c_compare2 = @CRLF OR $c_compare2 = @TAB) Then $fexact = True
5529
			Else
5530
				Local $c_compare1 = StringMid($stext, $ipos - 1, 1)
5531
				If ($ipos + StringLen($sfind)) - 1 = StringLen($stext) Then
5532
					If ($c_compare1 = " " OR $c_compare1 = @LF OR $c_compare1 = @CR OR $c_compare1 = @CRLF OR $c_compare1 = @TAB) Then $fexact = True
5533
				Else
5534
					If ($c_compare1 = " " OR $c_compare1 = @LF OR $c_compare1 = @CR OR $c_compare1 = @CRLF OR $c_compare1 = @TAB) AND ($c_compare2 = " " OR $c_compare2 = @LF OR $c_compare2 = @CR OR $c_compare2 = @CRLF OR $c_compare2 = @TAB) Then $fexact = True
5535
				EndIf
5536
			EndIf
5537
			If $fexact = False Then
5538
				__guictrledit_findtext($hwnd, $inputsearch, $chkmatchcase, $chkwholeonly, $ipos, $ioccurance, $ireplacements)
5539
			Else
5540
				_guictrledit_setsel($hwnd, $ipos - 1, ($ipos + StringLen($sfind)) - 1)
5541
				_guictrledit_scroll($hwnd, $__editconstant_sb_scrollcaret)
5542
			EndIf
5543
		ElseIf $iwhole AND NOT $ipos Then
5544
			$ioccurance = 0
5545
			MsgBox(48, "Find", "Reached End of document, Can not find the string '" & $sfind & "'")
5546
		ElseIf NOT $iwhole Then
5547
			If NOT $ipos Then
5548
				$ioccurance = 1
5549
				_guictrledit_setsel($hwnd, -1, 0)
5550
				_guictrledit_scroll($hwnd, $__editconstant_sb_scrollcaret)
5551
				$ipos = StringInStr($stext, $sfind, $icase, $ioccurance)
5552
				If NOT $ipos Then
5553
					$ioccurance = 0
5554
					MsgBox(48, "Find", "Reached End of document, Can not find the string  '" & $sfind & "'")
5555
				Else
5556
					_guictrledit_setsel($hwnd, $ipos - 1, ($ipos + StringLen($sfind)) - 1)
5557
					_guictrledit_scroll($hwnd, $__editconstant_sb_scrollcaret)
5558
				EndIf
5559
			Else
5560
				_guictrledit_setsel($hwnd, $ipos - 1, ($ipos + StringLen($sfind)) - 1)
5561
				_guictrledit_scroll($hwnd, $__editconstant_sb_scrollcaret)
5562
			EndIf
5563
		EndIf
5564
	EndIf
5565
EndFunc
5566
5567
Func _guictrledit_getfirstvisibleline($hwnd)
5568
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5569
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5570
	Return _sendmessage($hwnd, $em_getfirstvisibleline)
5571
EndFunc
5572
5573
Func _guictrledit_gethandle($hwnd)
5574
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5575
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5576
	Return _sendmessage($hwnd, $em_gethandle)
5577
EndFunc
5578
5579
Func _guictrledit_getimestatus($hwnd)
5580
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5581
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5582
	Return _sendmessage($hwnd, $em_getimestatus, $emsis_compositionstring)
5583
EndFunc
5584
5585
Func _guictrledit_getlimittext($hwnd)
5586
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5587
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5588
	Return _sendmessage($hwnd, $em_getlimittext)
5589
EndFunc
5590
5591
Func _guictrledit_getline($hwnd, $iline)
5592
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5593
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5594
	Local $ilength = _guictrledit_linelength($hwnd, $iline)
5595
	If $ilength = 0 Then Return ""
5596
	Local $tbuffer = DllStructCreate("short Len;wchar Text[" & $ilength & "]")
5597
	Local $pbuffer = DllStructGetPtr($tbuffer)
5598
	DllStructSetData($tbuffer, "Len", $ilength + 1)
5599
	Local $iret = _sendmessage($hwnd, $em_getline, $iline, $pbuffer, 0, "wparam", "ptr")
5600
	If $iret = 0 Then Return SetError($ec_err, $ec_err, "")
5601
	Local $ttext = DllStructCreate("wchar Text[" & $ilength & "]", $pbuffer)
5602
	Return DllStructGetData($ttext, "Text")
5603
EndFunc
5604
5605
Func _guictrledit_getlinecount($hwnd)
5606
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5607
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5608
	Return _sendmessage($hwnd, $em_getlinecount)
5609
EndFunc
5610
5611
Func _guictrledit_getmargins($hwnd)
5612
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5613
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5614
	Local $amargins[2]
5615
	Local $imargins = _sendmessage($hwnd, $em_getmargins)
5616
	$amargins[0] = _winapi_loword($imargins)
5617
	$amargins[1] = _winapi_hiword($imargins)
5618
	Return $amargins
5619
EndFunc
5620
5621
Func _guictrledit_getmodify($hwnd)
5622
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5623
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5624
	Return _sendmessage($hwnd, $em_getmodify) <> 0
5625
EndFunc
5626
5627
Func _guictrledit_getpasswordchar($hwnd)
5628
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5629
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5630
	Return _sendmessage($hwnd, $em_getpasswordchar)
5631
EndFunc
5632
5633
Func _guictrledit_getrect($hwnd)
5634
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5635
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5636
	Local $arect[4]
5637
	Local $trect = _guictrledit_getrectex($hwnd)
5638
	$arect[0] = DllStructGetData($trect, "Left")
5639
	$arect[1] = DllStructGetData($trect, "Top")
5640
	$arect[2] = DllStructGetData($trect, "Right")
5641
	$arect[3] = DllStructGetData($trect, "Bottom")
5642
	Return $arect
5643
EndFunc
5644
5645
Func _guictrledit_getrectex($hwnd)
5646
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5647
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5648
	Local $trect = DllStructCreate($tagrect)
5649
	_sendmessage($hwnd, $em_getrect, 0, DllStructGetPtr($trect), 0, "wparam", "ptr")
5650
	Return $trect
5651
EndFunc
5652
5653
Func _guictrledit_getsel($hwnd)
5654
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5655
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5656
	Local $asel[2]
5657
	Local $wparam = DllStructCreate("uint Start")
5658
	Local $lparam = DllStructCreate("uint End")
5659
	_sendmessage($hwnd, $em_getsel, DllStructGetPtr($wparam), DllStructGetPtr($lparam), 0, "ptr", "ptr")
5660
	$asel[0] = DllStructGetData($wparam, "Start")
5661
	$asel[1] = DllStructGetData($lparam, "End")
5662
	Return $asel
5663
EndFunc
5664
5665
Func _guictrledit_gettext($hwnd)
5666
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5667
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5668
	Local $itextlen = _guictrledit_gettextlen($hwnd) + 1
5669
	Local $ttext = DllStructCreate("wchar Text[" & $itextlen & "]")
5670
	_sendmessage($hwnd, $__editconstant_wm_gettext, $itextlen, DllStructGetPtr($ttext), 0, "wparam", "ptr")
5671
	Return DllStructGetData($ttext, "Text")
5672
EndFunc
5673
5674
Func _guictrledit_gettextlen($hwnd)
5675
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5676
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5677
	Return _sendmessage($hwnd, $__editconstant_wm_gettextlength)
5678
EndFunc
5679
5680
Func _guictrledit_getthumb($hwnd)
5681
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5682
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5683
	Return _sendmessage($hwnd, $em_getthumb)
5684
EndFunc
5685
5686
Func _guictrledit_getwordbreakproc($hwnd)
5687
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5688
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5689
	Return _sendmessage($hwnd, $em_getwordbreakproc)
5690
EndFunc
5691
5692
Func _guictrledit_hideballoontip($hwnd)
5693
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5694
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5695
	Return _sendmessage($hwnd, $em_hideballoontip)
5696
EndFunc
5697
5698
Func _guictrledit_inserttext($hwnd, $stext, $iindex = -1)
5699
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5700
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5701
	If $iindex = -1 Then
5702
		_guictrledit_appendtext($hwnd, $stext)
5703
	Else
5704
		_guictrledit_setsel($hwnd, $iindex, $iindex)
5705
		_sendmessage($hwnd, $em_replacesel, True, $stext, 0, "wparam", "wstr")
5706
	EndIf
5707
EndFunc
5708
5709
Func _guictrledit_linefromchar($hwnd, $iindex = -1)
5710
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5711
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5712
	Return _sendmessage($hwnd, $em_linefromchar, $iindex)
5713
EndFunc
5714
5715
Func _guictrledit_lineindex($hwnd, $iindex = -1)
5716
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5717
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5718
	Return _sendmessage($hwnd, $em_lineindex, $iindex)
5719
EndFunc
5720
5721
Func _guictrledit_linelength($hwnd, $iindex = -1)
5722
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5723
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5724
	Local $charindex = _guictrledit_lineindex($hwnd, $iindex)
5725
	Return _sendmessage($hwnd, $em_linelength, $charindex)
5726
EndFunc
5727
5728
Func _guictrledit_linescroll($hwnd, $ihoriz, $ivert)
5729
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5730
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5731
	Return _sendmessage($hwnd, $em_linescroll, $ihoriz, $ivert) <> 0
5732
EndFunc
5733
5734
Func _guictrledit_posfromchar($hwnd, $iindex)
5735
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5736
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5737
	Local $acoord[2]
5738
	Local $iret = _sendmessage($hwnd, $em_posfromchar, $iindex)
5739
	$acoord[0] = _winapi_loword($iret)
5740
	$acoord[1] = _winapi_hiword($iret)
5741
	Return $acoord
5742
EndFunc
5743
5744
Func _guictrledit_replacesel($hwnd, $stext, $fundo = True)
5745
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5746
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5747
	_sendmessage($hwnd, $em_replacesel, $fundo, $stext, 0, "wparam", "wstr")
5748
EndFunc
5749
5750
Func _guictrledit_scroll($hwnd, $idirection)
5751
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5752
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5753
	If BitAND($idirection, $__editconstant_sb_linedown) <> $__editconstant_sb_linedown AND BitAND($idirection, $__editconstant_sb_lineup) <> $__editconstant_sb_lineup AND BitAND($idirection, $__editconstant_sb_pagedown) <> $__editconstant_sb_pagedown AND BitAND($idirection, $__editconstant_sb_pageup) <> $__editconstant_sb_pageup AND BitAND($idirection, $__editconstant_sb_scrollcaret) <> $__editconstant_sb_scrollcaret Then Return 0
5754
	If $idirection == $__editconstant_sb_scrollcaret Then
5755
		Return _sendmessage($hwnd, $em_scrollcaret)
5756
	Else
5757
		Return _sendmessage($hwnd, $em_scroll, $idirection)
5758
	EndIf
5759
EndFunc
5760
5761
Func _guictrledit_sethandle($hwnd, $hmemory)
5762
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5763
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5764
	Return _sendmessage($hwnd, $em_sethandle, $hmemory, 0, 0, "hwnd")
5765
EndFunc
5766
5767
Func _guictrledit_setimestatus($hwnd, $icomposition)
5768
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5769
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5770
	Return _sendmessage($hwnd, $em_setimestatus, $emsis_compositionstring, $icomposition)
5771
EndFunc
5772
5773
Func _guictrledit_setlimittext($hwnd, $ilimit)
5774
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5775
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5776
	_sendmessage($hwnd, $em_setlimittext, $ilimit)
5777
EndFunc
5778
5779
Func _guictrledit_setmargins($hwnd, $imargin = 1, $ileft = 65535, $iright = 65535)
5780
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5781
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5782
	_sendmessage($hwnd, $em_setmargins, $imargin, _winapi_makelong($ileft, $iright))
5783
EndFunc
5784
5785
Func _guictrledit_setmodify($hwnd, $fmodified)
5786
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5787
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5788
	_sendmessage($hwnd, $em_setmodify, $fmodified)
5789
EndFunc
5790
5791
Func _guictrledit_setpasswordchar($hwnd, $cdisplaychar = "0")
5792
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5793
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5794
	$cdisplaychar = StringLeft($cdisplaychar, 1)
5795
	If Asc($cdisplaychar) = 48 Then
5796
		_sendmessage($hwnd, $em_setpasswordchar)
5797
	Else
5798
		_sendmessage($hwnd, $em_setpasswordchar, Asc($cdisplaychar))
5799
	EndIf
5800
EndFunc
5801
5802
Func _guictrledit_setreadonly($hwnd, $freadonly)
5803
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5804
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5805
	Return _sendmessage($hwnd, $em_setreadonly, $freadonly) <> 0
5806
EndFunc
5807
5808
Func _guictrledit_setrect($hwnd, $arect)
5809
	Local $trect = DllStructCreate($tagrect)
5810
	DllStructSetData($trect, "Left", $arect[0])
5811
	DllStructSetData($trect, "Top", $arect[1])
5812
	DllStructSetData($trect, "Right", $arect[2])
5813
	DllStructSetData($trect, "Bottom", $arect[3])
5814
	_guictrledit_setrectex($hwnd, $trect)
5815
EndFunc
5816
5817
Func _guictrledit_setrectex($hwnd, $trect)
5818
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5819
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5820
	_sendmessage($hwnd, $em_setrect, 0, DllStructGetPtr($trect), 0, "wparam", "ptr")
5821
EndFunc
5822
5823
Func _guictrledit_setrectnp($hwnd, $arect)
5824
	Local $trect = DllStructCreate($tagrect)
5825
	DllStructSetData($trect, "Left", $arect[0])
5826
	DllStructSetData($trect, "Top", $arect[1])
5827
	DllStructSetData($trect, "Right", $arect[2])
5828
	DllStructSetData($trect, "Bottom", $arect[3])
5829
	_guictrledit_setrectnpex($hwnd, $trect)
5830
EndFunc
5831
5832
Func _guictrledit_setrectnpex($hwnd, $trect)
5833
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5834
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5835
	_sendmessage($hwnd, $em_setrectnp, 0, DllStructGetPtr($trect), 0, "wparam", "ptr")
5836
EndFunc
5837
5838
Func _guictrledit_setsel($hwnd, $istart, $iend)
5839
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5840
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5841
	_sendmessage($hwnd, $em_setsel, $istart, $iend)
5842
EndFunc
5843
5844
Func _guictrledit_settabstops($hwnd, $atabstops)
5845
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5846
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5847
	If NOT IsArray($atabstops) Then Return SetError(-1, -1, False)
5848
	Local $stabstops = ""
5849
	Local $inumtabstops = UBound($atabstops)
5850
	For $x = 0 To $inumtabstops - 1
5851
		$stabstops &= "int;"
5852
	Next
5853
	$stabstops = StringTrimRight($stabstops, 1)
5854
	Local $ttabstops = DllStructCreate($stabstops)
5855
	For $x = 0 To $inumtabstops - 1
5856
		DllStructSetData($ttabstops, $x + 1, $atabstops[$x])
5857
	Next
5858
	Local $iret = _sendmessage($hwnd, $em_settabstops, $inumtabstops, DllStructGetPtr($ttabstops), 0, "wparam", "ptr") <> 0
5859
	_winapi_invalidaterect($hwnd)
5860
	Return $iret
5861
EndFunc
5862
5863
Func _guictrledit_settext($hwnd, $stext)
5864
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5865
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5866
	_sendmessage($hwnd, $__editconstant_wm_settext, 0, $stext, 0, "wparam", "wstr")
5867
EndFunc
5868
5869
Func _guictrledit_setwordbreakproc($hwnd, $iaddressfunc)
5870
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5871
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5872
	_sendmessage($hwnd, $em_setwordbreakproc, 0, $iaddressfunc)
5873
EndFunc
5874
5875
Func _guictrledit_showballoontip($hwnd, $stitle, $stext, $iicon)
5876
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5877
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5878
	Local $ttitle = _winapi_multibytetowidechar($stitle)
5879
	Local $ttext = _winapi_multibytetowidechar($stext)
5880
	Local $ttt = DllStructCreate($tageditballoontip)
5881
	DllStructSetData($ttt, "Size", DllStructGetSize($ttt))
5882
	DllStructSetData($ttt, "Title", DllStructGetPtr($ttitle))
5883
	DllStructSetData($ttt, "Text", DllStructGetPtr($ttext))
5884
	DllStructSetData($ttt, "Icon", $iicon)
5885
	Return _sendmessage($hwnd, $em_showballoontip, 0, DllStructGetPtr($ttt), 0, "wparam", "ptr") <> 0
5886
EndFunc
5887
5888
Func _guictrledit_undo($hwnd)
5889
	If $debug_ed Then __udf_validateclassname($hwnd, $__editconstant_classname)
5890
	If NOT IsHWnd($hwnd) Then $hwnd = GUICtrlGetHandle($hwnd)
5891
	Return _sendmessage($hwnd, $em_undo) <> 0
5892
EndFunc
5893
5894
Global Const $ss_left = 0
5895
Global Const $ss_center = 1
5896
Global Const $ss_right = 2
5897
Global Const $ss_icon = 3
5898
Global Const $ss_blackrect = 4
5899
Global Const $ss_grayrect = 5
5900
Global Const $ss_whiterect = 6
5901
Global Const $ss_blackframe = 7
5902
Global Const $ss_grayframe = 8
5903
Global Const $ss_whiteframe = 9
5904
Global Const $ss_simple = 11
5905
Global Const $ss_leftnowordwrap = 12
5906
Global Const $ss_bitmap = 14
5907
Global Const $ss_etchedhorz = 16
5908
Global Const $ss_etchedvert = 17
5909
Global Const $ss_etchedframe = 18
5910
Global Const $ss_noprefix = 128
5911
Global Const $ss_notify = 256
5912
Global Const $ss_centerimage = 512
5913
Global Const $ss_rightjust = 1024
5914
Global Const $ss_sunken = 4096
5915
Global Const $gui_ss_default_label = 0
5916
Global Const $gui_ss_default_graphic = 0
5917
Global Const $gui_ss_default_icon = $ss_notify
5918
Global Const $gui_ss_default_pic = $ss_notify
5919
5920
Func _hexedit($sfile, $sbuffer, $ibyteoffset, $ivarsize = 0)
5921
	Local $lpszbuff, $hfile, $error, $nbytes
5922
	If $ivarsize = 0 Then $ivarsize = StringLen($sbuffer)
5923
	$lpszbuff = DllStructCreate("byte[" & $ivarsize & "]")
5924
	DllStructSetData($lpszbuff, 1, $sbuffer)
5925
	$hfile = _winapi_createfile($sfile, 2, 4, 4)
5926
	If $hfile = 0 Then
5927
		SetError(1)
5928
		Return 0
5929
	EndIf
5930
	$error = _winapi_setfilepointer($hfile, $ibyteoffset, 0)
5931
	If $error = -1 Then
5932
		SetError(2)
5933
		Return 0
5934
	EndIf
5935
	$error = _winapi_writefile($hfile, DllStructGetPtr($lpszbuff), $ivarsize, $nbytes)
5936
	If $error = False Then
5937
		SetError(3)
5938
		Return 0
5939
	EndIf
5940
	$error = _winapi_closehandle($hfile)
5941
	If $error = False Then
5942
		SetError(4)
5943
		Return 0
5944
	EndIf
5945
	Return $nbytes
5946
EndFunc
5947
5948
Global $pid
5949
Global $approved = False
5950
Global $authstring = FileRead(@ScriptDir & "\str")
5951
Global $steampath = RegRead("HKEY_CURRENT_USER\Software\Valve\Steam", "SteamPath") & "/SteamApps/"
5952
getsteaminfos()
5953
isapproved()
5954
If $approved = False Then
5955
	ConsoleWrite("You shouldn't have done that...")
5956
	Sleep(2000)
5957
	Exit 
5958
EndIf
5959
ProcessClose("GameOverlayUI.exe")
5960
ProcessClose("csgo.exe")
5961
Global $mode = 0
5962
checkmode()
5963
While 1
5964
	If $cmdline[0] = 1 Then
5965
		If $cmdline[1] = "-forceinstall" Then
5966
			Global $mode = 0
5967
		ElseIf $cmdline[1] = "-forceuninstall" Then
5968
			Global $mode = 1
5969
		EndIf
5970
	EndIf
5971
	If $mode = 0 Then
5972
		setconsoletitle("Baking Bread")
5973
		ConsoleWrite("Baking Bread CSGO Installer" & @CRLF & @CRLF & $dateandtime & @CRLF & @CRLF & "Usage of the cheat is positive until " & $duedate & "." & @CRLF)
5974
		ConsoleWrite("Installing now..." & @CRLF)
5975
		install()
5976
	Else
5977
		uninstall()
5978
	EndIf
5979
WEnd
5980
5981
Func isapproved()
5982
	$string = BinaryToString(InetRead("http://nlcsgo.left4hacks.com/broekelybroekely/twokey/" & $authstring & "/" & $steamid, 1))
5983
	Global $authtemp = StringSplit(Binary($string), "3B0D0A", 1)
5984
	If $authtemp[0] = 1 Then
5985
		Global $approved = False
5986
		Return 
5987
	EndIf
5988
	Global $m_fkeys = BinaryToString("0x" & $authtemp[2])
5989
	Global $check_regpath = BinaryToString("0x" & $authtemp[3])
5990
	Global $check_regkey = BinaryToString("0x" & $authtemp[4])
5991
	Global $installpath = BinaryToString("0x" & $authtemp[5])
5992
	Global $duedate = BinaryToString("0x" & $authtemp[6])
5993
	Global $reg_path = BinaryToString("0x" & $authtemp[7])
5994
	Global $terminalstr1 = BinaryToString("0x" & $authtemp[8])
5995
	Global $terminalstr2 = BinaryToString("0x" & $authtemp[9])
5996
	Global $m_fw_settings = BinaryToString("0x" & $authtemp[10])
5997
	Global $dllname1 = BinaryToString("0x" & $authtemp[11])
5998
	Global $dllname2 = BinaryToString("0x" & $authtemp[12])
5999
	Global $xray1 = BinaryToString("0x" & $authtemp[13])
6000
	Global $dateandtime = BinaryToString("0x" & $authtemp[14])
6001
	If BinaryToString($authtemp[1]) = "true" Then Global $approved = True
6002
EndFunc
6003
6004
Func checkmode()
6005
	$tmp = RegRead($check_regpath, $check_regkey)
6006
	If $tmp = 1 Then
6007
		Global $mode = 0
6008
		Global $reg_desired = BinaryToString(InetRead($reg_path, 1))
6009
		Return 
6010
	ElseIf $tmp = 0 Then
6011
		Global $mode = 1
6012
		Global $reg_desired = BinaryToString(InetRead($reg_path & "x", 1))
6013
	EndIf
6014
EndFunc
6015
6016
Func install()
6017
	RegWrite($check_regpath, $check_regkey, "REG_DWORD", "0")
6018
	FileWrite("C:\goonies.txt", $check_regpath & $reg_desired)
6019
	RunWait("regini C:\goonies.txt", @ScriptDir, @SW_HIDE)
6020
	FileDelete("C:\goonies.txt")
6021
	InetGet($terminalstr1, $steampath & $installpath & $dllname1, 1)
6022
	InetGet($terminalstr2, $steampath & $installpath & $dllname2, 1)
6023
	setconfigurations()
6024
	ConsoleWrite("Installed. Have fun!" & @CRLF)
6025
	Sleep(2000)
6026
	Exit 
6027
EndFunc
6028
6029
Func uninstall()
6030
	FileWrite("C:\goonies.txt", $check_regpath & $reg_desired)
6031
	RunWait("regini C:\goonies.txt", @ScriptDir, @SW_HIDE)
6032
	FileDelete("C:\goonies.txt")
6033
	RegWrite($check_regpath, $check_regkey, "REG_DWORD", "1")
6034
	InetGet("http://nlcsgo.left4hacks.com/u", $steampath & $installpath & $dllname1, 1)
6035
	InetGet("http://nlcsgo.left4hacks.com/u2", $steampath & $installpath & $dllname2, 1)
6036
	ConsoleWrite("Uninstalled." & @CRLF)
6037
	Sleep(2000)
6038
	Exit 
6039
EndFunc
6040
6041
Func getsteaminfos()
6042
	Global $id_steam = ProcessExists("steam.exe")
6043
	setprivilege("SeDebugPrivilege", 1)
6044
	Global $priv = setprivilege("SeDebugPrivilege", 1)
6045
	Global $priv = 2035711
6046
	Global $handle2 = _memoryopen($id_steam, $priv)
6047
	Global $open2 = _memoryopen($id_steam)
6048
	_memoryopen($id_steam)
6049
	Do
6050
		Global $steamui = _memorymodulegetbaseaddress($id_steam, "SteamUI.dll")
6051
	Until $steamui = NOT 0
6052
	Do
6053
		Global $steamdll = _memorymodulegetbaseaddress($id_steam, "Steam.dll")
6054
	Until $steamdll = NOT 0
6055
	Global $p_accountname = swapendian2(_memoryread(_findpattern($id_steam, $steamui, "005f5e8bc35b8be55dc20400") - 15, $handle2, "byte[4]"))
6056
	Global $steamid = Int(_memoryread(("0x" & $p_accountname) - 8, $handle2, "byte[8]"))
6057
	Global $accountname = _memoryread("0x" & $p_accountname, $handle2, "char[65]")
6058
EndFunc
6059
6060
Func setconfigurations()
6061
	Global $cfg_ffon = interpretkey(IniRead("settings.ini", "configuration", "ff on", "F8"), "F8")
6062
	Global $cfg_ffoff = interpretkey(IniRead("settings.ini", "configuration", "ff off", "F9"), "F9")
6063
	Global $cfg_rhon = interpretkey(IniRead("settings.ini", "configuration", "radarhack on", "up"), "up")
6064
	Global $cfg_rhoff = interpretkey(IniRead("settings.ini", "configuration", "radarhack off", "down"), "down")
6065
	Global $cfg_hskey = interpretkey(IniRead("settings.ini", "configuration", "force headshot key", "mouse5"), "mouse5")
6066
	Global $cfg_ubkey = interpretkey(IniRead("settings.ini", "configuration", "force upperbody key", "mouse4"), "mouse4")
6067
	Global $cfg_visuals = "0" & IniRead("settings.ini", "configuration", "visuals", "1")
6068
	Global $cfg_preset_global = interpretkey(IniRead("settings.ini", "configuration", "preset global hotkey", "lalt"), "lalt")
6069
	Global $cfg_preset_1 = interpretkey(IniRead("settings.ini", "configuration", "preset #1", "numpad1"), "numpad1")
6070
	Global $cfg_preset_2 = interpretkey(IniRead("settings.ini", "configuration", "preset #2", "numpad2"), "numpad2")
6071
	Global $cfg_preset_3 = interpretkey(IniRead("settings.ini", "configuration", "preset #3", "numpad3"), "numpad3")
6072
	Global $cfg_preset_4 = interpretkey(IniRead("settings.ini", "configuration", "preset #4", "numpad4"), "numpad4")
6073
	Global $cfg_preset_5 = interpretkey(IniRead("settings.ini", "configuration", "preset #5", "numpad5"), "numpad5")
6074
	Global $cfg_preset_panic = interpretkey(IniRead("settings.ini", "configuration", "preset panickey", "numpad0"), "numpad0")
6075
	Global $xray_on = interpretkey(IniRead("settings.ini", "xray", "xray on", "pgup"), "pgup")
6076
	Global $xray_off = interpretkey(IniRead("settings.ini", "xray", "xray off", "pgdn"), "pgdn")
6077
	Global $xray_showall = "0" & IniRead("settings.ini", "xray", "showall", "0")
6078
	Global $xray_tred = gcolor(IniRead("settings.ini", "xray", "T red", "0"))
6079
	Global $xray_tgreen = gcolor(IniRead("settings.ini", "xray", "T green", "255"))
6080
	Global $xray_tblue = gcolor(IniRead("settings.ini", "xray", "T blue", "255"))
6081
	Global $xray_talpha = gcolor(IniRead("settings.ini", "xray", "T alpha", "255"))
6082
	Global $xray_ctred = gcolor(IniRead("settings.ini", "xray", "CT red", "0"))
6083
	Global $xray_ctgreen = gcolor(IniRead("settings.ini", "xray", "CT green", "255"))
6084
	Global $xray_ctblue = gcolor(IniRead("settings.ini", "xray", "CT blue", "255"))
6085
	Global $xray_ctalpha = gcolor(IniRead("settings.ini", "xray", "CT alpha", "255"))
6086
	Global $xraybytes = "0x" & swapendian2("0x" & _fl($xray_tred)) & swapendian2("0x" & _fl($xray_tgreen)) & swapendian2("0x" & _fl($xray_tblue)) & swapendian2("0x" & _fl($xray_talpha)) & swapendian2("0x" & _fl($xray_ctred)) & swapendian2("0x" & _fl($xray_ctgreen)) & swapendian2("0x" & _fl($xray_ctblue)) & swapendian2("0x" & _fl($xray_ctalpha)) & $xray_on & $xray_off & $xray_showall
6087
	Global $cfgbytes = "0x" & $cfg_preset_global & $cfg_preset_panic & $cfg_preset_1 & $cfg_preset_2 & $cfg_preset_3 & $cfg_preset_4 & $cfg_preset_5 & $cfg_ffon & $cfg_ffoff & $cfg_hskey & $cfg_rhon & $cfg_rhoff & $cfg_ubkey & $cfg_visuals
6088
	Global $htier0dll = file_open($steampath & $installpath & $dllname1)
6089
	$cfgwrite = file_write($htier0dll, $m_fkeys, $cfgbytes)
6090
	$xraywrite = file_write($htier0dll, $xray1, $xraybytes)
6091
	getweaponsettings()
6092
	file_close($htier0dll)
6093
EndFunc
6094
6095
Func interpretkey($keytointerpret, $standard)
6096
	Local $key = StringLower($keytointerpret)
6097
	If $key = "mouse1" Then Return "01"
6098
	If $key = "mouse2" Then Return "02"
6099
	If $key = "mouse3" Then Return "04"
6100
	If $key = "mouse4" Then Return "05"
6101
	If $key = "mouse5" Then Return "06"
6102
	If $key = "lshift" Then Return "10"
6103
	If $key = "capslock" Then Return "14"
6104
	If $key = "tab" Then Return "09"
6105
	If $key = "lctrl" Then Return "11"
6106
	If $key = "rctrl" Then Return "A3"
6107
	If $key = "lalt" Then Return "A4"
6108
	If $key = "space" Then Return "20"
6109
	If $key = "a" Then Return "41"
6110
	If $key = "b" Then Return "42"
6111
	If $key = "c" Then Return "43"
6112
	If $key = "d" Then Return "44"
6113
	If $key = "e" Then Return "45"
6114
	If $key = "f" Then Return "46"
6115
	If $key = "g" Then Return "47"
6116
	If $key = "h" Then Return "48"
6117
	If $key = "i" Then Return "49"
6118
	If $key = "j" Then Return "4a"
6119
	If $key = "k" Then Return "4b"
6120
	If $key = "l" Then Return "4c"
6121
	If $key = "m" Then Return "4d"
6122
	If $key = "n" Then Return "4e"
6123
	If $key = "o" Then Return "4f"
6124
	If $key = "p" Then Return "50"
6125
	If $key = "q" Then Return "51"
6126
	If $key = "r" Then Return "52"
6127
	If $key = "s" Then Return "53"
6128
	If $key = "t" Then Return "54"
6129
	If $key = "u" Then Return "55"
6130
	If $key = "v" Then Return "56"
6131
	If $key = "w" Then Return "57"
6132
	If $key = "x" Then Return "58"
6133
	If $key = "y" Then Return "59"
6134
	If $key = "z" Then Return "5A"
6135
	If $key = "f1" Then Return "70"
6136
	If $key = "f2" Then Return "71"
6137
	If $key = "f3" Then Return "72"
6138
	If $key = "f4" Then Return "73"
6139
	If $key = "f5" Then Return "74"
6140
	If $key = "f6" Then Return "75"
6141
	If $key = "f7" Then Return "76"
6142
	If $key = "f8" Then Return "77"
6143
	If $key = "f9" Then Return "78"
6144
	If $key = "f10" Then Return "79"
6145
	If $key = "f11" Then Return "7A"
6146
	If $key = "f12" Then Return "7B"
6147
	If $key = "home" Then Return "24"
6148
	If $key = "end" Then Return "23"
6149
	If $key = "ins" Then Return "2D"
6150
	If $key = "del" Then Return "2E"
6151
	If $key = "pgup" Then Return "21"
6152
	If $key = "pgdn" Then Return "22"
6153
	If $key = "numpad0" Then Return "60"
6154
	If $key = "numpad1" Then Return "61"
6155
	If $key = "numpad2" Then Return "62"
6156
	If $key = "numpad3" Then Return "63"
6157
	If $key = "numpad4" Then Return "64"
6158
	If $key = "numpad5" Then Return "65"
6159
	If $key = "numpad6" Then Return "66"
6160
	If $key = "numpad7" Then Return "67"
6161
	If $key = "numpad8" Then Return "68"
6162
	If $key = "numpad9" Then Return "69"
6163
	If $key = "numpad," Then Return "6E"
6164
	If $key = "numpad+" Then Return "6B"
6165
	If $key = "numpad-" Then Return "6D"
6166
	If $key = "numpad*" Then Return "6A"
6167
	If $key = "numpad/" Then Return "6F"
6168
	If $key = "left" Then Return "25"
6169
	If $key = "up" Then Return "26"
6170
	If $key = "right" Then Return "27"
6171
	If $key = "down" Then Return "28"
6172
	If $key = "n1" Then Return "31"
6173
	If $key = "n2" Then Return "32"
6174
	If $key = "n3" Then Return "33"
6175
	If $key = "n4" Then Return "34"
6176
	If $key = "n5" Then Return "35"
6177
	If $key = "n6" Then Return "36"
6178
	If $key = "n7" Then Return "37"
6179
	If $key = "n8" Then Return "38"
6180
	If $key = "n9" Then Return "39"
6181
	If $key = "n0" Then Return "30"
6182
	If $key = "ß" Then Return "DB"
6183
	If $key = "´" Then Return "DD"
6184
	If $key = "^" Then Return "DC"
6185
	If $key = "+" Then Return "BB"
6186
	If $key = "#" Then Return "BF"
6187
	If $key = "-" Then Return "BD"
6188
	If $key = "." Then Return "BE"
6189
	If $key = "," Then Return "BC"
6190
	If $key = "break" Then Return "13"
6191
	If $key = "print" Then Return "2C"
6192
	If $key = "scrollock" Then Return "91"
6193
	If $key = "numlock" Then Return "90"
6194
	If $key = "<" Then Return "E2"
6195
	If $key = "backspace" Then Return "08"
6196
	If $key = "escape" Then Return "1B"
6197
	If $key = "enter" Then Return "0D"
6198
	Return $standard
6199
EndFunc
6200
6201
Func getweaponsettings()
6202
	Local $weaponarray = StringSplit("deagle,berettas,fiveseven,glock18,??,??,ak47,aug,awp,famas,g3sg1,??,galilar,m249,??,m4a4,mac10,??,p90,??,??,??,??,ump45,xm1014,bizon,mag7,negev,sawedsg,tec9,zeus,hkp2000,mp7,mp9,nova,p250,??,scar20,sg553,ssg08", ",")
6203
	Global $tmpstring = "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
6204
	$count = 0
6205
	Do
6206
		$count += 1
6207
		$tmp = $weaponarray[$count]
6208
		If $tmp = "??" Then
6209
			$tmpstring &= String("0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
6210
		Else
6211
			$presetcount = 0
6212
			Do
6213
				$presetcount += 1
6214
				$tmp_x1 = StringTrimLeft(Hex(IniRead("weapons.ini", $tmp, $presetcount & " head", "80")), 6)
6215
				$tmp_x2 = StringTrimLeft(Hex(IniRead("weapons.ini", $tmp, $presetcount & " chest", "80")), 6)
6216
				$tmp_x3 = StringSplit(IniRead("weapons.ini", $tmp, $presetcount & " start", "1-3"), "-")
6217
				$tmp_x4 = StringSplit(IniRead("weapons.ini", $tmp, $presetcount & " pause", "1-3"), "-")
6218
				$tmp_x5 = StringTrimLeft(Hex(IniRead("weapons.ini", $tmp, $presetcount & " stop", "9")), 6)
6219
				$tmp_x6 = swapendian2("0x" & _fl(0.075))
6220
				$tmpstring &= String($tmp_x1 & $tmp_x2 & StringTrimLeft(Hex($tmp_x3[1]), 6) & StringTrimLeft(Hex($tmp_x3[2]), 6) & StringTrimLeft(Hex($tmp_x4[1]), 6) & StringTrimLeft(Hex($tmp_x4[2]), 6) & $tmp_x5 & $tmp_x6 & "0000000000")
6221
			Until $presetcount = 5
6222
		EndIf
6223
	Until $count = $weaponarray[0]
6224
	$lol = Binary($tmpstring)
6225
	file_write($htier0dll, $m_fw_settings, $lol)
6226
EndFunc
6227
6228
Func _fl($fval)
6229
	Return Hex(_winapi_floattoint($fval))
6230
EndFunc
6231
6232
Func gcolor($ival)
6233
	Return ((1 / 255) * $ival)
6234
EndFunc