Global Const $OPT_COORDSRELATIVE = 0 Global Const $OPT_COORDSABSOLUTE = 1 Global Const $OPT_COORDSCLIENT = 2 Global Const $OPT_ERRORSILENT = 0 Global Const $OPT_ERRORFATAL = 1 Global Const $OPT_CAPSNOSTORE = 0 Global Const $OPT_CAPSSTORE = 1 Global Const $OPT_MATCHSTART = 1 Global Const $OPT_MATCHANY = 2 Global Const $OPT_MATCHEXACT = 3 Global Const $OPT_MATCHADVANCED = 4 Global Const $CCS_TOP = 0x01 Global Const $CCS_NOMOVEY = 0x02 Global Const $CCS_BOTTOM = 0x03 Global Const $CCS_NORESIZE = 0x04 Global Const $CCS_NOPARENTALIGN = 0x08 Global Const $CCS_NOHILITE = 0x10 Global Const $CCS_ADJUSTABLE = 0x20 Global Const $CCS_NODIVIDER = 0x40 Global Const $CCS_VERT = 0x0080 Global Const $CCS_LEFT = 0x0081 Global Const $CCS_NOMOVEX = 0x0082 Global Const $CCS_RIGHT = 0x0083 Global Const $DT_DRIVETYPE = 1 Global Const $DT_SSDSTATUS = 2 Global Const $DT_BUSTYPE = 3 Global Const $PROXY_IE = 0 Global Const $PROXY_NONE = 1 Global Const $PROXY_SPECIFIED = 2 Global Const $OBJID_WINDOW = 0x00000000 Global Const $OBJID_TITLEBAR = 0xFFFFFFFE Global Const $OBJID_SIZEGRIP = 0xFFFFFFF9 Global Const $OBJID_CARET = 0xFFFFFFF8 Global Const $OBJID_CURSOR = 0xFFFFFFF7 Global Const $OBJID_ALERT = 0xFFFFFFF6 Global Const $OBJID_SOUND = 0xFFFFFFF5 Global Const $DLG_CENTERONTOP = 0 Global Const $DLG_NOTITLE = 1 Global Const $DLG_NOTONTOP = 2 Global Const $DLG_TEXTLEFT = 4 Global Const $DLG_TEXTRIGHT = 8 Global Const $DLG_MOVEABLE = 16 Global Const $DLG_TEXTVCENTER = 32 Global Const $IDC_UNKNOWN = 0 Global Const $IDC_APPSTARTING = 1 Global Const $IDC_ARROW = 2 Global Const $IDC_CROSS = 3 Global Const $IDC_HAND = 32649 Global Const $IDC_HELP = 4 Global Const $IDC_IBEAM = 5 Global Const $IDC_ICON = 6 Global Const $IDC_NO = 7 Global Const $IDC_SIZE = 8 Global Const $IDC_SIZEALL = 9 Global Const $IDC_SIZENESW = 10 Global Const $IDC_SIZENS = 11 Global Const $IDC_SIZENWSE = 12 Global Const $IDC_SIZEWE = 13 Global Const $IDC_UPARROW = 14 Global Const $IDC_WAIT = 15 Global Const $IDI_APPLICATION = 32512 Global Const $IDI_ASTERISK = 32516 Global Const $IDI_EXCLAMATION = 32515 Global Const $IDI_HAND = 32513 Global Const $IDI_QUESTION = 32514 Global Const $IDI_WINLOGO = 32517 Global Const $IDI_SHIELD = 32518 Global Const $IDI_ERROR = $IDI_HAND Global Const $IDI_INFORMATION = $IDI_ASTERISK Global Const $IDI_WARNING = $IDI_EXCLAMATION Global Const $SD_LOGOFF = 0 Global Const $SD_SHUTDOWN = 1 Global Const $SD_REBOOT = 2 Global Const $SD_FORCE = 4 Global Const $SD_POWERDOWN = 8 Global Const $SD_FORCEHUNG = 16 Global Const $SD_STANDBY = 32 Global Const $SD_HIBERNATE = 64 Global Const $STDIN_CHILD = 1 Global Const $STDOUT_CHILD = 2 Global Const $STDERR_CHILD = 4 Global Const $STDERR_MERGED = 8 Global Const $STDIO_INHERIT_PARENT = 0x10 Global Const $RUN_CREATE_NEW_CONSOLE = 0x00010000 Global Const $UBOUND_DIMENSIONS = 0 Global Const $UBOUND_ROWS = 1 Global Const $UBOUND_COLUMNS = 2 Global Const $MOUSEEVENTF_ABSOLUTE = 0x8000 Global Const $MOUSEEVENTF_MOVE = 0x0001 Global Const $MOUSEEVENTF_LEFTDOWN = 0x0002 Global Const $MOUSEEVENTF_LEFTUP = 0x0004 Global Const $MOUSEEVENTF_RIGHTDOWN = 0x0008 Global Const $MOUSEEVENTF_RIGHTUP = 0x0010 Global Const $MOUSEEVENTF_MIDDLEDOWN = 0x0020 Global Const $MOUSEEVENTF_MIDDLEUP = 0x0040 Global Const $MOUSEEVENTF_WHEEL = 0x0800 Global Const $MOUSEEVENTF_XDOWN = 0x0080 Global Const $MOUSEEVENTF_XUP = 0x0100 Global Const $REG_NONE = 0 Global Const $REG_SZ = 1 Global Const $REG_EXPAND_SZ = 2 Global Const $REG_BINARY = 3 Global Const $REG_DWORD = 4 Global Const $REG_DWORD_LITTLE_ENDIAN = 4 Global Const $REG_DWORD_BIG_ENDIAN = 5 Global Const $REG_LINK = 6 Global Const $REG_MULTI_SZ = 7 Global Const $REG_RESOURCE_LIST = 8 Global Const $REG_FULL_RESOURCE_DESCRIPTOR = 9 Global Const $REG_RESOURCE_REQUIREMENTS_LIST = 10 Global Const $REG_QWORD = 11 Global Const $REG_QWORD_LITTLE_ENDIAN = 11 Global Const $HWND_BOTTOM = 1 Global Const $HWND_NOTOPMOST = -2 Global Const $HWND_TOP = 0 Global Const $HWND_TOPMOST = -1 Global Const $SWP_NOSIZE = 0x0001 Global Const $SWP_NOMOVE = 0x0002 Global Const $SWP_NOZORDER = 0x0004 Global Const $SWP_NOREDRAW = 0x0008 Global Const $SWP_NOACTIVATE = 0x0010 Global Const $SWP_FRAMECHANGED = 0x0020 Global Const $SWP_DRAWFRAME = 0x0020 Global Const $SWP_SHOWWINDOW = 0x0040 Global Const $SWP_HIDEWINDOW = 0x0080 Global Const $SWP_NOCOPYBITS = 0x0100 Global Const $SWP_NOOWNERZORDER = 0x0200 Global Const $SWP_NOREPOSITION = 0x0200 Global Const $SWP_NOSENDCHANGING = 0x0400 Global Const $SWP_DEFERERASE = 0x2000 Global Const $SWP_ASYNCWINDOWPOS = 0x4000 Global Const $KEYWORD_DEFAULT = 1 Global Const $KEYWORD_NULL = 2 Global Const $DECLARED_LOCAL = -1 Global Const $DECLARED_UNKNOWN = 0 Global Const $DECLARED_GLOBAL = 1 Global Const $ASSIGN_CREATE = 0 Global Const $ASSIGN_FORCELOCAL = 1 Global Const $ASSIGN_FORCEGLOBAL = 2 Global Const $ASSIGN_EXISTFAIL = 4 Global Const $BI_ENABLE = 0 Global Const $BI_DISABLE = 1 Global Const $BREAK_ENABLE = 1 Global Const $BREAK_DISABLE = 0 Global Const $CDTRAY_OPEN = "open" Global Const $CDTRAY_CLOSED = "closed" Global Const $SEND_DEFAULT = 0 Global Const $SEND_RAW = 1 Global Const $DIR_DEFAULT = 0 Global Const $DIR_EXTENDED= 1 Global Const $DIR_NORECURSE = 2 Global Const $DIR_REMOVE= 1 Global Const $DT_ALL = "ALL" Global Const $DT_CDROM = "CDROM" Global Const $DT_REMOVABLE = "REMOVABLE" Global Const $DT_FIXED = "FIXED" Global Const $DT_NETWORK = "NETWORK" Global Const $DT_RAMDISK = "RAMDISK" Global Const $DT_UNKNOWN = "UNKNOWN" Global Const $DT_UNDEFINED = 1 Global Const $DT_FAT = "FAT" Global Const $DT_FAT32 = "FAT32" Global Const $DT_EXFAT = "exFAT" Global Const $DT_NTFS = "NTFS" Global Const $DT_NWFS = "NWFS" Global Const $DT_CDFS = "CDFS" Global Const $DT_UDF = "UDF" Global Const $DMA_DEFAULT = 0 Global Const $DMA_PERSISTENT = 1 Global Const $DMA_AUTHENTICATION = 8 Global Const $DS_UNKNOWN = "UNKNOWN" Global Const $DS_READY = "READY" Global Const $DS_NOTREADY = "NOTREADY" Global Const $DS_INVALID = "INVALID" Global Const $MOUSE_CLICK_LEFT = "left" Global Const $MOUSE_CLICK_RIGHT = "right" Global Const $MOUSE_CLICK_MIDDLE = "middle" Global Const $MOUSE_CLICK_MAIN = "main" Global Const $MOUSE_CLICK_MENU = "menu" Global Const $MOUSE_CLICK_PRIMARY = "primary" Global Const $MOUSE_CLICK_SECONDARY = "secondary" Global Const $MOUSE_WHEEL_UP = "up" Global Const $MOUSE_WHEEL_DOWN = "down" Global Const $NUMBER_AUTO = 0 Global Const $NUMBER_32BIT = 1 Global Const $NUMBER_64BIT = 2 Global Const $NUMBER_DOUBLE = 3 Global Const $OBJ_NAME = 1 Global Const $OBJ_STRING = 2 Global Const $OBJ_PROGID = 3 Global Const $OBJ_FILE = 4 Global Const $OBJ_MODULE = 5 Global Const $OBJ_CLSID = 6 Global Const $OBJ_IID = 7 Global Const $EXITCLOSE_NORMAL = 0 Global Const $EXITCLOSE_BYEXIT = 1 Global Const $EXITCLOSE_BYCLICK = 2 Global Const $EXITCLOSE_BYLOGOFF = 3 Global Const $EXITCLOSE_BYSHUTDOWN = 4 Global Const $PROCESS_STATS_MEMORY = 0 Global Const $PROCESS_STATS_IO = 1 Global Const $PROCESS_LOW = 0 Global Const $PROCESS_BELOWNORMAL = 1 Global Const $PROCESS_NORMAL = 2 Global Const $PROCESS_ABOVENORMAL = 3 Global Const $PROCESS_HIGH = 4 Global Const $PROCESS_REALTIME = 5 Global Const $RUN_LOGON_NOPROFILE = 0 Global Const $RUN_LOGON_PROFILE = 1 Global Const $RUN_LOGON_NETWORK = 2 Global Const $RUN_LOGON_INHERIT = 4 Global Const $SOUND_NOWAIT = 0 Global Const $SOUND_WAIT = 1 Global Const $SHEX_OPEN = "open" Global Const $SHEX_EDIT = "edit" Global Const $SHEX_PRINT = "print" Global Const $SHEX_PROPERTIES = "properties" Global Const $TCP_DATA_DEFAULT = 0 Global Const $TCP_DATA_BINARY = 1 Global Const $UDP_OPEN_DEFAULT = 0 Global Const $UDP_OPEN_BROADCAST = 1 Global Const $UDP_DATA_DEFAULT = 0 Global Const $UDP_DATA_BINARY = 1 Global Const $UDP_DATA_ARRAY = 2 Global Const $TIP_NOICON = 0 Global Const $TIP_INFOICON = 1 Global Const $TIP_WARNINGICON = 2 Global Const $TIP_ERRORICON = 3 Global Const $TIP_BALLOON = 1 Global Const $TIP_CENTER = 2 Global Const $TIP_FORCEVISIBLE = 4 Global Const $WINDOWS_NOONTOP = 0 Global Const $WINDOWS_ONTOP = 1 Global Const $WIN_STATE_EXISTS = 1 Global Const $WIN_STATE_VISIBLE = 2 Global Const $WIN_STATE_ENABLED = 4 Global Const $WIN_STATE_ACTIVE = 8 Global Const $WIN_STATE_MINIMIZED = 16 Global Const $WIN_STATE_MAXIMIZED = 32 Global Const $MB_OK = 0 Global Const $MB_OKCANCEL = 1 Global Const $MB_ABORTRETRYIGNORE = 2 Global Const $MB_YESNOCANCEL = 3 Global Const $MB_YESNO = 4 Global Const $MB_RETRYCANCEL = 5 Global Const $MB_CANCELTRYCONTINUE = 6 Global Const $MB_HELP = 0x4000 Global Const $MB_ICONSTOP = 16 Global Const $MB_ICONERROR = 16 Global Const $MB_ICONHAND = 16 Global Const $MB_ICONQUESTION = 32 Global Const $MB_ICONEXCLAMATION = 48 Global Const $MB_ICONWARNING = 48 Global Const $MB_ICONINFORMATION = 64 Global Const $MB_ICONASTERISK = 64 Global Const $MB_USERICON = 0x00000080 Global Const $MB_DEFBUTTON1 = 0 Global Const $MB_DEFBUTTON2 = 256 Global Const $MB_DEFBUTTON3 = 512 Global Const $MB_DEFBUTTON4 = 768 Global Const $MB_APPLMODAL = 0 Global Const $MB_SYSTEMMODAL = 4096 Global Const $MB_TASKMODAL = 8192 Global Const $MB_DEFAULT_DESKTOP_ONLY = 0x00020000 Global Const $MB_RIGHT = 0x00080000 Global Const $MB_RTLREADING = 0x00100000 Global Const $MB_SETFOREGROUND = 0x00010000 Global Const $MB_TOPMOST = 0x00040000 Global Const $MB_SERVICE_NOTIFICATION = 0x00200000 Global Const $MB_RIGHTJUSTIFIED = $MB_RIGHT Global Const $IDTIMEOUT = -1 Global Const $IDOK = 1 Global Const $IDCANCEL = 2 Global Const $IDABORT = 3 Global Const $IDRETRY = 4 Global Const $IDIGNORE = 5 Global Const $IDYES = 6 Global Const $IDNO = 7 Global Const $IDCLOSE = 8 Global Const $IDHELP = 9 Global Const $IDTRYAGAIN = 10 Global Const $IDCONTINUE = 11 Global Const $STR_NOCASESENSE = 0 Global Const $STR_CASESENSE = 1 Global Const $STR_NOCASESENSEBASIC = 2 Global Const $STR_STRIPLEADING = 1 Global Const $STR_STRIPTRAILING = 2 Global Const $STR_STRIPSPACES = 4 Global Const $STR_STRIPALL = 8 Global Const $STR_CHRSPLIT = 0 Global Const $STR_ENTIRESPLIT = 1 Global Const $STR_NOCOUNT = 2 Global Const $STR_REGEXPMATCH = 0 Global Const $STR_REGEXPARRAYMATCH = 1 Global Const $STR_REGEXPARRAYFULLMATCH = 2 Global Const $STR_REGEXPARRAYGLOBALMATCH = 3 Global Const $STR_REGEXPARRAYGLOBALFULLMATCH = 4 Global Const $STR_ENDISSTART = 0 Global Const $STR_ENDNOTSTART = 1 Global Const $SB_ANSI = 1 Global Const $SB_UTF16LE = 2 Global Const $SB_UTF16BE = 3 Global Const $SB_UTF8 = 4 Global Const $SE_UTF16 = 0 Global Const $SE_ANSI = 1 Global Const $SE_UTF8 = 2 Global Const $STR_UTF16 = 0 Global Const $STR_UCS2 = 1 #Region Global Variables and Constants Global Const $_ARRAYCONSTANT_SORTINFOSIZE = 11 Global $__g_aArrayDisplay_SortInfo[$_ARRAYCONSTANT_SORTINFOSIZE] Global Const $ARRAYDISPLAY_COLALIGNLEFT = 0 Global Const $ARRAYDISPLAY_TRANSPOSE = 1 Global Const $ARRAYDISPLAY_COLALIGNRIGHT = 2 Global Const $ARRAYDISPLAY_COLALIGNCENTER = 4 Global Const $ARRAYDISPLAY_VERBOSE = 8 Global Const $ARRAYDISPLAY_NOROW = 64 Global Const $_ARRAYCONSTANT_tagHDITEM = "uint Mask;int XY;ptr Text;handle hBMP;int TextMax;int Fmt;lparam Param;int Image;int Order;uint Type;ptr pFilter;uint State" Global Const $_ARRAYCONSTANT_tagLVITEM = "struct;uint Mask;int Item;int SubItem;uint State;uint StateMask;ptr Text;int TextMax;int Image;lparam Param;" & "int Indent;int GroupID;uint Columns;ptr pColumns;ptr piColFmt;int iGroup;endstruct" #EndRegion Global Variables and Constants #Region Functions list #EndRegion Functions list Func __ArrayDisplay_Share(Const ByRef $aArray, $sTitle = Default, $sArrayRange = Default, $iFlags = Default, $vUser_Separator = Default, $sHeader = Default, $iMax_ColWidth = Default, $hUser_Function = Default, $bDebug = True) Local $vTmp, $sMsgBoxTitle = (($bDebug) ? ("DebugArray") : ("ArrayDisplay")) If $sTitle = Default Then $sTitle = $sMsgBoxTitle If $sArrayRange = Default Then $sArrayRange = "" If $iFlags = Default Then $iFlags = 0 If $vUser_Separator = Default Then $vUser_Separator = "" If $sHeader = Default Then $sHeader = "" If $iMax_ColWidth = Default Then $iMax_ColWidth = 350 If $hUser_Function = Default Then $hUser_Function = 0 Local $iTranspose = BitAND($iFlags, $ARRAYDISPLAY_TRANSPOSE) Local $iColAlign = BitAND($iFlags, 6) Local $iVerbose = BitAND($iFlags, $ARRAYDISPLAY_VERBOSE) Local $iNoRow = BitAND($iFlags, $ARRAYDISPLAY_NOROW) Local $iButtonBorder = (($bDebug) ? (40) : (20)) Local $sMsg = "", $iRet = 1 If IsArray($aArray) Then Local $iDimension = UBound($aArray, $UBOUND_DIMENSIONS), $iRowCount = UBound($aArray, $UBOUND_ROWS), $iColCount = UBound($aArray, $UBOUND_COLUMNS) If $iDimension > 2 Then $sMsg = "Larger than 2D array passed to function" $iRet = 2 EndIf If $iDimension = 1 Then $iTranspose = 0 EndIf Else $sMsg = "No array variable passed to function" EndIf If $sMsg Then If $iVerbose And MsgBox($MB_SYSTEMMODAL + $MB_ICONERROR + $MB_YESNO, $sMsgBoxTitle & " Error: " & $sTitle, $sMsg & @CRLF & @CRLF & "Exit the script?") = $IDYES Then Exit Else Return SetError($iRet, 0, 0) EndIf EndIf Local $iCW_ColWidth = Number($vUser_Separator) Local $sCurr_Separator = Opt("GUIDataSeparatorChar") If $vUser_Separator = "" Then $vUser_Separator = $sCurr_Separator Local $iItem_Start = 0, $iItem_End = $iRowCount - 1, $iSubItem_Start = 0, $iSubItem_End = (($iDimension = 2) ? ($iColCount - 1) : (0)) Local $bRange_Flag = False, $avRangeSplit If $sArrayRange Then Local $aArray_Range = StringRegExp($sArrayRange & "||", "(?U)(.*)\|", 3) If $aArray_Range[0] Then $avRangeSplit = StringSplit($aArray_Range[0], ":") If @error Then $iItem_End = Number($avRangeSplit[1]) Else $iItem_Start = Number($avRangeSplit[1]) If $avRangeSplit[2] <> "" Then $iItem_End = Number($avRangeSplit[2]) EndIf EndIf EndIf If $iItem_Start < 0 Then $iItem_Start = 0 If $iItem_End > $iRowCount - 1 Then $iItem_End = $iRowCount - 1 If $iItem_Start > $iItem_End Then $vTmp = $iItem_Start $iItem_Start = $iItem_End $iItem_End = $vTmp EndIf If $iItem_Start <> 0 Or $iItem_End <> $iRowCount - 1 Then $bRange_Flag = True If $iDimension = 2 And $aArray_Range[1] Then $avRangeSplit = StringSplit($aArray_Range[1], ":") If @error Then $iSubItem_End = Number($avRangeSplit[1]) Else $iSubItem_Start = Number($avRangeSplit[1]) If $avRangeSplit[2] <> "" Then $iSubItem_End = Number($avRangeSplit[2]) EndIf EndIf If $iSubItem_Start > $iSubItem_End Then $vTmp = $iSubItem_Start $iSubItem_Start = $iSubItem_End $iSubItem_End = $vTmp EndIf If $iSubItem_Start < 0 Then $iSubItem_Start = 0 If $iSubItem_End > $iColCount - 1 Then $iSubItem_End = $iColCount - 1 If $iSubItem_Start <> 0 Or $iSubItem_End <> $iColCount - 1 Then $bRange_Flag = True EndIf EndIf Local $sDisplayData = "[" & $iRowCount & "]" If $iDimension = 2 Then $sDisplayData &= " [" & $iColCount & "]" EndIf Local $sTipData = "" If $bRange_Flag Then If $sTipData Then $sTipData &= " - " $sTipData &= "Range set" EndIf If $iTranspose Then If $sTipData Then $sTipData &= " - " $sTipData &= "Transposed" EndIf Local $asHeader = StringSplit($sHeader, $sCurr_Separator, $STR_NOCOUNT) If UBound($asHeader) = 0 Then Local $asHeader[1] = [""] $sHeader = "Row" Local $iIndex = $iSubItem_Start If $iTranspose Then $sHeader = "Col" For $j = $iItem_Start To $iItem_End $sHeader &= $sCurr_Separator & "Row " & $j Next Else If $asHeader[0] Then For $iIndex = $iSubItem_Start To $iSubItem_End If $iIndex >= UBound($asHeader) Then ExitLoop $sHeader &= $sCurr_Separator & $asHeader[$iIndex] Next EndIf For $j = $iIndex To $iSubItem_End $sHeader &= $sCurr_Separator & "Col " & $j Next EndIf If $iNoRow Then $sHeader = StringTrimLeft($sHeader, 4) If $iVerbose And ($iItem_End - $iItem_Start + 1) * ($iSubItem_End - $iSubItem_Start + 1) > 10000 Then SplashTextOn($sMsgBoxTitle, "Preparing display" & @CRLF & @CRLF & "Please be patient", 300, 100) EndIf Local Const $_ARRAYCONSTANT_GUI_DOCKBOTTOM = 64 Local Const $_ARRAYCONSTANT_GUI_DOCKBORDERS = 102 Local Const $_ARRAYCONSTANT_GUI_DOCKHEIGHT = 512 Local Const $_ARRAYCONSTANT_GUI_DOCKLEFT = 2 Local Const $_ARRAYCONSTANT_GUI_DOCKRIGHT = 4 Local Const $_ARRAYCONSTANT_GUI_DOCKHCENTER = 8 Local Const $_ARRAYCONSTANT_GUI_EVENT_CLOSE = -3 Local Const $_ARRAYCONSTANT_GUI_FOCUS = 256 Local Const $_ARRAYCONSTANT_SS_CENTER = 0x1 Local Const $_ARRAYCONSTANT_SS_CENTERIMAGE = 0x0200 Local Const $_ARRAYCONSTANT_LVM_GETITEMCOUNT = (0x1000 + 4) Local Const $_ARRAYCONSTANT_LVM_GETITEMRECT = (0x1000 + 14) Local Const $_ARRAYCONSTANT_LVM_GETCOLUMNWIDTH = (0x1000 + 29) Local Const $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH = (0x1000 + 30) Local Const $_ARRAYCONSTANT_LVM_GETITEMSTATE = (0x1000 + 44) Local Const $_ARRAYCONSTANT_LVM_GETSELECTEDCOUNT = (0x1000 + 50) Local Const $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE = (0x1000 + 54) Local Const $_ARRAYCONSTANT_LVS_EX_GRIDLINES = 0x1 Local Const $_ARRAYCONSTANT_LVIS_SELECTED = 0x0002 Local Const $_ARRAYCONSTANT_LVS_SHOWSELALWAYS = 0x8 Local Const $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT = 0x20 Local Const $_ARRAYCONSTANT_WS_EX_CLIENTEDGE = 0x0200 Local Const $_ARRAYCONSTANT_WS_MAXIMIZEBOX = 0x00010000 Local Const $_ARRAYCONSTANT_WS_MINIMIZEBOX = 0x00020000 Local Const $_ARRAYCONSTANT_WS_SIZEBOX = 0x00040000 Local Const $_ARRAYCONSTANT_WM_SETREDRAW = 11 Local Const $_ARRAYCONSTANT_LVSCW_AUTOSIZE = -1 Local Const $_ARRAYCONSTANT_LVSCW_AUTOSIZE_USEHEADER = -2 Local $iCoordMode = Opt("GUICoordMode", 1) Local $iOrgWidth = 210, $iHeight = 200, $iMinSize = 250 Local $hGUI = GUICreate($sTitle, $iOrgWidth, $iHeight, Default, Default, BitOR($_ARRAYCONSTANT_WS_SIZEBOX, $_ARRAYCONSTANT_WS_MINIMIZEBOX, $_ARRAYCONSTANT_WS_MAXIMIZEBOX)) Local $aiGUISize = WinGetClientSize($hGUI) Local $iButtonWidth_1 = $aiGUISize[0] / 2 Local $iButtonWidth_2 = $aiGUISize[0] / 3 Local $idListView = GUICtrlCreateListView($sHeader, 0, 0, $aiGUISize[0], $aiGUISize[1] - $iButtonBorder, $_ARRAYCONSTANT_LVS_SHOWSELALWAYS) GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_LVS_EX_GRIDLINES, $_ARRAYCONSTANT_LVS_EX_GRIDLINES) GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT, $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT) GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_WS_EX_CLIENTEDGE, $_ARRAYCONSTANT_WS_EX_CLIENTEDGE) Local $idCopy_ID = 9999, $idCopy_Data = 99999, $idData_Label = 99999, $idUser_Func = 99999, $idExit_Script = 99999 If $bDebug Then $idCopy_ID = GUICtrlCreateButton("Copy Data && Hdr/Row", 0, $aiGUISize[1] - $iButtonBorder, $iButtonWidth_1, 20) $idCopy_Data = GUICtrlCreateButton("Copy Data Only", $iButtonWidth_1, $aiGUISize[1] - $iButtonBorder, $iButtonWidth_1, 20) Local $iButtonWidth_Var = $iButtonWidth_1 Local $iOffset = $iButtonWidth_1 If IsFunc($hUser_Function) Then $idUser_Func = GUICtrlCreateButton("Run User Func", $iButtonWidth_2, $aiGUISize[1] - 20, $iButtonWidth_2, 20) $iButtonWidth_Var = $iButtonWidth_2 $iOffset = $iButtonWidth_2 * 2 EndIf $idExit_Script = GUICtrlCreateButton("Exit Script", $iOffset, $aiGUISize[1] - 20, $iButtonWidth_Var, 20) $idData_Label = GUICtrlCreateLabel($sDisplayData, 0, $aiGUISize[1] - 20, $iButtonWidth_Var, 18, BitOR($_ARRAYCONSTANT_SS_CENTER, $_ARRAYCONSTANT_SS_CENTERIMAGE)) Else $idData_Label = GUICtrlCreateLabel($sDisplayData, 0, $aiGUISize[1] - 20, $aiGUISize[0], 18, BitOR($_ARRAYCONSTANT_SS_CENTER, $_ARRAYCONSTANT_SS_CENTERIMAGE)) EndIf Select Case $iTranspose Or $bRange_Flag GUICtrlSetColor($idData_Label, 0xFF0000) GUICtrlSetTip($idData_Label, $sTipData) EndSelect GUICtrlSetResizing($idListView, $_ARRAYCONSTANT_GUI_DOCKBORDERS) GUICtrlSetResizing($idCopy_ID, $_ARRAYCONSTANT_GUI_DOCKLEFT + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT) GUICtrlSetResizing($idCopy_Data, $_ARRAYCONSTANT_GUI_DOCKRIGHT + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT) GUICtrlSetResizing($idData_Label, $_ARRAYCONSTANT_GUI_DOCKLEFT + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT) GUICtrlSetResizing($idUser_Func, $_ARRAYCONSTANT_GUI_DOCKHCENTER + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT) GUICtrlSetResizing($idExit_Script, $_ARRAYCONSTANT_GUI_DOCKRIGHT + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT) GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_WM_SETREDRAW, 0, 0) Local $iRowIndex, $iColFill If $iTranspose Then For $i = $iSubItem_Start To $iSubItem_End $iRowIndex = __ArrayDisplay_AddItem($idListView, "NULL") If $iNoRow Then $iColFill = 0 Else __ArrayDisplay_AddSubItem($idListView, $iRowIndex, "Col " & $i, 0) $iColFill = 1 EndIf For $j = $iItem_Start To $iItem_End If $iDimension = 2 Then $vTmp = $aArray[$j][$i] Else $vTmp = $aArray[$j] EndIf Switch VarGetType($vTmp) Case "Array" __ArrayDisplay_AddSubItem($idListView, $iRowIndex, "{Array}", $iColFill) Case Else __ArrayDisplay_AddSubItem($idListView, $iRowIndex, $vTmp, $iColFill) EndSwitch $iColFill += 1 Next Next Else For $i = $iItem_Start To $iItem_End $iRowIndex = __ArrayDisplay_AddItem($idListView, "NULL") If $iNoRow Then $iColFill = 0 Else __ArrayDisplay_AddSubItem($idListView, $iRowIndex, "Row " & $i, 0) $iColFill = 1 EndIf For $j = $iSubItem_Start To $iSubItem_End If $iDimension = 2 Then $vTmp = $aArray[$i][$j] Else $vTmp = $aArray[$i] EndIf Switch VarGetType($vTmp) Case "Array" __ArrayDisplay_AddSubItem($idListView, $iRowIndex, "{Array}", $iColFill) Case Else __ArrayDisplay_AddSubItem($idListView, $iRowIndex, $vTmp, $iColFill) EndSwitch $iColFill += 1 Next Next EndIf If $iColAlign Then For $i = 0 To $iColFill - 1 __ArrayDisplay_JustifyColumn($idListView, $i, $iColAlign / 2) Next EndIf GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_WM_SETREDRAW, 1, 0) Local $iBorder = (($iRowIndex > 19) ? (65) : (45)) Local $iWidth = $iBorder, $iColWidth = 0, $aiColWidth[$iColFill], $iMin_ColWidth = 55 For $i = 0 To UBound($aiColWidth) - 1 GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $_ARRAYCONSTANT_LVSCW_AUTOSIZE) $iColWidth = GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_GETCOLUMNWIDTH, $i, 0) If $sHeader <> "" Then GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $_ARRAYCONSTANT_LVSCW_AUTOSIZE_USEHEADER) Local $iColWidthHeader = GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_GETCOLUMNWIDTH, $i, 0) If $iColWidth < $iMin_ColWidth And $iColWidthHeader < $iMin_ColWidth Then GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $iMin_ColWidth) $iColWidth = $iMin_ColWidth ElseIf $iColWidthHeader < $iColWidth Then GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $iColWidth) Else $iColWidth = $iColWidthHeader EndIf Else If $iColWidth < $iMin_ColWidth Then GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $iMin_ColWidth) $iColWidth = $iMin_ColWidth EndIf EndIf $iWidth += $iColWidth $aiColWidth[$i] = $iColWidth Next If $iWidth > @DesktopWidth - 100 Then $iWidth = $iBorder For $i = 0 To UBound($aiColWidth) - 1 If $aiColWidth[$i] > $iMax_ColWidth Then GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_SETCOLUMNWIDTH, $i, $iMax_ColWidth) $iWidth += $iMax_ColWidth Else $iWidth += $aiColWidth[$i] EndIf Next EndIf If $iWidth > @DesktopWidth - 100 Then $iWidth = @DesktopWidth - 100 ElseIf $iWidth < $iMinSize Then $iWidth = $iMinSize EndIf Local $tRECT = DllStructCreate("struct; long Left;long Top;long Right;long Bottom; endstruct") DllCall("user32.dll", "struct*", "SendMessageW", "hwnd", GUICtrlGetHandle($idListView), "uint", $_ARRAYCONSTANT_LVM_GETITEMRECT, "wparam", 0, "struct*", $tRECT) Local $aiWin_Pos = WinGetPos($hGUI) Local $aiLV_Pos = ControlGetPos($hGUI, "", $idListView) $iHeight = (($iRowIndex + 4) * (DllStructGetData($tRECT, "Bottom") - DllStructGetData($tRECT, "Top"))) + $aiWin_Pos[3] - $aiLV_Pos[3] If $iHeight > @DesktopHeight - 100 Then $iHeight = @DesktopHeight - 100 ElseIf $iHeight < $iMinSize Then $iHeight = $iMinSize EndIf If $iVerbose Then SplashOff() GUISetState(@SW_HIDE, $hGUI) WinMove($hGUI, "", (@DesktopWidth - $iWidth) / 2, (@DesktopHeight - $iHeight) / 2, $iWidth, $iHeight) GUISetState(@SW_SHOW, $hGUI) Local $iOnEventMode = Opt("GUIOnEventMode", 0), $iMsg __ArrayDisplay_RegisterSortCallBack($idListView, 2, True, "__ArrayDisplay_SortCallBack") While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $_ARRAYCONSTANT_GUI_EVENT_CLOSE ExitLoop Case $idCopy_ID, $idCopy_Data Local $iSel_Count = GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_GETSELECTEDCOUNT, 0, 0) If $iVerbose And (Not $iSel_Count) And ($iItem_End - $iItem_Start) * ($iSubItem_End - $iSubItem_Start) > 10000 Then SplashTextOn($sMsgBoxTitle, "Copying data" & @CRLF & @CRLF & "Please be patient", 300, 100) EndIf Local $sClip = "", $sItem, $aSplit For $i = 0 To GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_GETITEMCOUNT, 0, 0) - 1 If $iSel_Count And Not (GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_GETITEMSTATE, $i, $_ARRAYCONSTANT_LVIS_SELECTED) <> 0) Then ContinueLoop EndIf $sItem = __ArrayDisplay_GetItemTextString($idListView, $i) If $iMsg = $idCopy_ID And $iNoRow Then $sItem = "Row " & ($i + (($iTranspose) ? ($iSubItem_Start) : ($iItem_Start))) & $sCurr_Separator & $sItem EndIf If $iMsg = $idCopy_Data And Not $iNoRow Then $sItem = StringRegExpReplace($sItem, "^Row\s\d+\|(.*)$", "$1") EndIf If $iCW_ColWidth Then $aSplit = StringSplit($sItem, $sCurr_Separator) $sItem = "" For $j = 1 To $aSplit[0] $sItem &= StringFormat("%-" & $iCW_ColWidth + 1 & "s", StringLeft($aSplit[$j], $iCW_ColWidth)) Next Else $sItem = StringReplace($sItem, $sCurr_Separator, $vUser_Separator) EndIf $sClip &= $sItem & @CRLF Next $sItem = $sHeader If $iMsg = $idCopy_ID Then $sItem = $sHeader If $iNoRow Then $sItem = "Row|" & $sItem EndIf If $iCW_ColWidth Then $aSplit = StringSplit($sItem, $sCurr_Separator) $sItem = "" For $j = 1 To $aSplit[0] $sItem &= StringFormat("%-" & $iCW_ColWidth + 1 & "s", StringLeft($aSplit[$j], $iCW_ColWidth)) Next Else $sItem = StringReplace($sItem, $sCurr_Separator, $vUser_Separator) EndIf $sClip = $sItem & @CRLF & $sClip EndIf ClipPut($sClip) SplashOff() GUICtrlSetState($idListView, $_ARRAYCONSTANT_GUI_FOCUS) Case $idListView __ArrayDisplay_SortItems($idListView, GUICtrlGetState($idListView)) Case $idUser_Func Local $aiSelItems[1] = [0] For $i = 0 To GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_GETITEMCOUNT, 0, 0) - 1 If (GUICtrlSendMsg($idListView, $_ARRAYCONSTANT_LVM_GETITEMSTATE, $i, $_ARRAYCONSTANT_LVIS_SELECTED) <> 0) Then $aiSelItems[0] += 1 ReDim $aiSelItems[$aiSelItems[0] + 1] $aiSelItems[$aiSelItems[0]] = $i + $iItem_Start EndIf Next $hUser_Function($aArray, $aiSelItems) GUICtrlSetState($idListView, $_ARRAYCONSTANT_GUI_FOCUS) Case $idExit_Script GUIDelete($hGUI) Exit EndSwitch WEnd GUIDelete($hGUI) Opt("GUICoordMode", $iCoordMode) Opt("GUIOnEventMode", $iOnEventMode) Return 1 EndFunc Func __ArrayDisplay_RegisterSortCallBack($hWnd, $vCompareType = 2, $bArrows = True, $sSort_Callback = "__ArrayDisplay_SortCallBack") #Au3Stripper_Ignore_Funcs=$sSort_Callback If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $hHeader = HWnd(GUICtrlSendMsg($hWnd, 0x101F, 0, 0)) $__g_aArrayDisplay_SortInfo[1] = $hWnd $__g_aArrayDisplay_SortInfo[2] = DllCallbackRegister($sSort_Callback, "int", "int;int;hwnd") $__g_aArrayDisplay_SortInfo[3] = -1 $__g_aArrayDisplay_SortInfo[4] = -1 $__g_aArrayDisplay_SortInfo[5] = 1 $__g_aArrayDisplay_SortInfo[6] = -1 $__g_aArrayDisplay_SortInfo[7] = 0 $__g_aArrayDisplay_SortInfo[8] = $vCompareType $__g_aArrayDisplay_SortInfo[9] = $bArrows $__g_aArrayDisplay_SortInfo[10] = $hHeader Return $__g_aArrayDisplay_SortInfo[2] <> 0 EndFunc #Au3Stripper_Ignore_Funcs=__ArrayDisplay_SortCallBack Func __ArrayDisplay_SortCallBack($nItem1, $nItem2, $hWnd) If $__g_aArrayDisplay_SortInfo[3] = $__g_aArrayDisplay_SortInfo[4] Then If Not $__g_aArrayDisplay_SortInfo[7] Then $__g_aArrayDisplay_SortInfo[5] *= -1 $__g_aArrayDisplay_SortInfo[7] = 1 EndIf Else $__g_aArrayDisplay_SortInfo[7] = 1 EndIf $__g_aArrayDisplay_SortInfo[6] = $__g_aArrayDisplay_SortInfo[3] Local $sVal1 = __ArrayDisplay_GetItemText($hWnd, $nItem1, $__g_aArrayDisplay_SortInfo[3]) Local $sVal2 = __ArrayDisplay_GetItemText($hWnd, $nItem2, $__g_aArrayDisplay_SortInfo[3]) If $__g_aArrayDisplay_SortInfo[8] = 1 Then If (StringIsFloat($sVal1) Or StringIsInt($sVal1)) Then $sVal1 = Number($sVal1) If (StringIsFloat($sVal2) Or StringIsInt($sVal2)) Then $sVal2 = Number($sVal2) EndIf Local $nResult If $__g_aArrayDisplay_SortInfo[8] < 2 Then $nResult = 0 If $sVal1 < $sVal2 Then $nResult = -1 ElseIf $sVal1 > $sVal2 Then $nResult = 1 EndIf Else $nResult = DllCall('shlwapi.dll', 'int', 'StrCmpLogicalW', 'wstr', $sVal1, 'wstr', $sVal2)[0] EndIf $nResult = $nResult * $__g_aArrayDisplay_SortInfo[5] Return $nResult EndFunc Func __ArrayDisplay_SortItems($hWnd, $iCol) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $pFunction = DllCallbackGetPtr($__g_aArrayDisplay_SortInfo[2]) $__g_aArrayDisplay_SortInfo[3] = $iCol $__g_aArrayDisplay_SortInfo[7] = 0 $__g_aArrayDisplay_SortInfo[4] = $__g_aArrayDisplay_SortInfo[6] Local $aResult = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", 0x1051, "hwnd", $hWnd, "ptr", $pFunction) If $aResult[0] <> 0 Then If $__g_aArrayDisplay_SortInfo[9] Then Local $hHeader = $__g_aArrayDisplay_SortInfo[10], $iFormat For $x = 0 To __ArrayDisplay_GetItemCount($hHeader) - 1 $iFormat = __ArrayDisplay_GetItemFormat($hHeader, $x) If BitAND($iFormat, 0x00000200) Then __ArrayDisplay_SetItemFormat($hHeader, $x, BitXOR($iFormat, 0x00000200)) ElseIf BitAND($iFormat, 0x00000400) Then __ArrayDisplay_SetItemFormat($hHeader, $x, BitXOR($iFormat, 0x00000400)) EndIf Next $iFormat = __ArrayDisplay_GetItemFormat($hHeader, $iCol) If $__g_aArrayDisplay_SortInfo[5] = 1 Then __ArrayDisplay_SetItemFormat($hHeader, $iCol, BitOR($iFormat, 0x00000400)) Else __ArrayDisplay_SetItemFormat($hHeader, $iCol, BitOR($iFormat, 0x00000200)) EndIf EndIf Return True EndIf Return False EndFunc Func __ArrayDisplay_AddItem($hWnd, $sText) Local $tItem = DllStructCreate($_ARRAYCONSTANT_tagLVITEM) DllStructSetData($tItem, "Param", 0) Local $iBuffer = StringLen($sText) + 1 Local $tBuffer = DllStructCreate("wchar Text[" & $iBuffer & "]") $iBuffer *= 2 DllStructSetData($tBuffer, "Text", $sText) DllStructSetData($tItem, "Text", DllStructGetPtr($tBuffer)) DllStructSetData($tItem, "TextMax", $iBuffer) Local $iMask = 0x00000005 DllStructSetData($tItem, "Mask", $iMask) DllStructSetData($tItem, "Item", 999999999) DllStructSetData($tItem, "Image", -1) Local $pItem = DllStructGetPtr($tItem) Local $iRet = GUICtrlSendMsg($hWnd, 0x104D, 0, $pItem) Return $iRet EndFunc Func __ArrayDisplay_AddSubItem($hWnd, $iIndex, $sText, $iSubItem) Local $iBuffer = StringLen($sText) + 1 Local $tBuffer = DllStructCreate("wchar Text[" & $iBuffer & "]") $iBuffer *= 2 Local $pBuffer = DllStructGetPtr($tBuffer) Local $tItem = DllStructCreate($_ARRAYCONSTANT_tagLVITEM) Local $iMask = 0x00000001 DllStructSetData($tBuffer, "Text", $sText) DllStructSetData($tItem, "Mask", $iMask) DllStructSetData($tItem, "Item", $iIndex) DllStructSetData($tItem, "SubItem", $iSubItem) DllStructSetData($tItem, "Image", -1) Local $pItem = DllStructGetPtr($tItem) DllStructSetData($tItem, "Text", $pBuffer) Local $iRet = GUICtrlSendMsg($hWnd, 0x104C, 0, $pItem) Return $iRet <> 0 EndFunc Func __ArrayDisplay_GetColumnCount($hWnd) Local $hHeader = HWnd(GUICtrlSendMsg($hWnd, 0x101F, 0, 0)) Return __ArrayDisplay_GetItemCount($hHeader) EndFunc Func __ArrayDisplay_GetHeader($hWnd) Return HWnd(GUICtrlSendMsg($hWnd, 0x101F, 0, 0)) EndFunc Func __ArrayDisplay_GetItem($hWnd, $iIndex, ByRef $tItem) Local $aResult = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", 0x120B, "wparam", $iIndex, "struct*", $tItem) Return $aResult[0] <> 0 EndFunc Func __ArrayDisplay_GetItemCount($hWnd) Local $aResult = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", 0x1200, "wparam", 0, "lparam", 0) Return $aResult[0] EndFunc Func __ArrayDisplay_GetItemFormat($hWnd, $iIndex) Local $tItem = DllStructCreate($_ARRAYCONSTANT_tagHDITEM) DllStructSetData($tItem, "Mask", 0x00000004) __ArrayDisplay_GetItem($hWnd, $iIndex, $tItem) Return DllStructGetData($tItem, "Fmt") EndFunc Func __ArrayDisplay_GetItemText($hWnd, $iIndex, $iSubItem = 0) Local $tBuffer = DllStructCreate("wchar Text[4096]") Local $pBuffer = DllStructGetPtr($tBuffer) Local $tItem = DllStructCreate($_ARRAYCONSTANT_tagLVITEM) DllStructSetData($tItem, "SubItem", $iSubItem) DllStructSetData($tItem, "TextMax", 4096) DllStructSetData($tItem, "Text", $pBuffer) If IsHWnd($hWnd) Then DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", 0x1073, "wparam", $iIndex, "struct*", $tItem) Else Local $pItem = DllStructGetPtr($tItem) GUICtrlSendMsg($hWnd, 0x1073, $iIndex, $pItem) EndIf Return DllStructGetData($tBuffer, "Text") EndFunc Func __ArrayDisplay_GetItemTextString($hWnd, $iItem) Local $sRow = "", $sSeparatorChar = Opt('GUIDataSeparatorChar') Local $iSelected = $iItem For $x = 0 To __ArrayDisplay_GetColumnCount($hWnd) - 1 $sRow &= __ArrayDisplay_GetItemText($hWnd, $iSelected, $x) & $sSeparatorChar Next Return StringTrimRight($sRow, 1) EndFunc Func __ArrayDisplay_JustifyColumn($idListView, $iIndex, $iAlign = -1) Local $tColumn = DllStructCreate("uint Mask;int Fmt;int CX;ptr Text;int TextMax;int SubItem;int Image;int Order;int cxMin;int cxDefault;int cxIdeal") If $iAlign < 0 Or $iAlign > 2 Then $iAlign = 0 DllStructSetData($tColumn, "Mask", 0x01) DllStructSetData($tColumn, "Fmt", $iAlign) Local $pColumn = DllStructGetPtr($tColumn) Local $iRet = GUICtrlSendMsg($idListView, 0x1060 , $iIndex, $pColumn) Return $iRet <> 0 EndFunc Func __ArrayDisplay_SetItemFormat($hWnd, $iIndex, $iFormat) Local $tItem = DllStructCreate($_ARRAYCONSTANT_tagHDITEM) DllStructSetData($tItem, "Mask", 0x00000004) DllStructSetData($tItem, "Fmt", $iFormat) Local $aResult = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", 0x120C, "wparam", $iIndex, "struct*", $tItem) Return $aResult[0] <> 0 EndFunc Global Enum $ARRAYFILL_FORCE_DEFAULT, $ARRAYFILL_FORCE_SINGLEITEM, $ARRAYFILL_FORCE_INT, $ARRAYFILL_FORCE_NUMBER, $ARRAYFILL_FORCE_PTR, $ARRAYFILL_FORCE_HWND, $ARRAYFILL_FORCE_STRING, $ARRAYFILL_FORCE_BOOLEAN Global Enum $ARRAYUNIQUE_NOCOUNT, $ARRAYUNIQUE_COUNT Global Enum $ARRAYUNIQUE_AUTO, $ARRAYUNIQUE_FORCE32, $ARRAYUNIQUE_FORCE64, $ARRAYUNIQUE_MATCH, $ARRAYUNIQUE_DISTINCT Func _ArrayAdd(ByRef $aArray, $vValue, $iStart = 0, $sDelim_Item = "|", $sDelim_Row = @CRLF, $iForce = $ARRAYFILL_FORCE_DEFAULT) If $iStart = Default Then $iStart = 0 If $sDelim_Item = Default Then $sDelim_Item = "|" If $sDelim_Row = Default Then $sDelim_Row = @CRLF If $iForce = Default Then $iForce = $ARRAYFILL_FORCE_DEFAULT If Not IsArray($aArray) Then Return SetError(1, 0, -1) Local $iDim_1 = UBound($aArray, $UBOUND_ROWS) Local $hDataType = 0 Switch $iForce Case $ARRAYFILL_FORCE_INT $hDataType = Int Case $ARRAYFILL_FORCE_NUMBER $hDataType = Number Case $ARRAYFILL_FORCE_PTR $hDataType = Ptr Case $ARRAYFILL_FORCE_HWND $hDataType = Hwnd Case $ARRAYFILL_FORCE_STRING $hDataType = String Case $ARRAYFILL_FORCE_BOOLEAN $hDataType = "Boolean" EndSwitch Switch UBound($aArray, $UBOUND_DIMENSIONS) Case 1 If $iForce = $ARRAYFILL_FORCE_SINGLEITEM Then ReDim $aArray[$iDim_1 + 1] $aArray[$iDim_1] = $vValue Return $iDim_1 EndIf If IsArray($vValue) Then If UBound($vValue, $UBOUND_DIMENSIONS) <> 1 Then Return SetError(5, 0, -1) $hDataType = 0 Else Local $aTmp = StringSplit($vValue, $sDelim_Item, $STR_NOCOUNT + $STR_ENTIRESPLIT) If UBound($aTmp, $UBOUND_ROWS) = 1 Then $aTmp[0] = $vValue EndIf $vValue = $aTmp EndIf Local $iAdd = UBound($vValue, $UBOUND_ROWS) ReDim $aArray[$iDim_1 + $iAdd] For $i = 0 To $iAdd - 1 If String($hDataType) = "Boolean" Then Switch $vValue[$i] Case "True", "1" $aArray[$iDim_1 + $i] = True Case "False", "0", "" $aArray[$iDim_1 + $i] = False EndSwitch ElseIf IsFunc($hDataType) Then $aArray[$iDim_1 + $i] = $hDataType($vValue[$i]) Else $aArray[$iDim_1 + $i] = $vValue[$i] EndIf Next Return $iDim_1 + $iAdd - 1 Case 2 Local $iDim_2 = UBound($aArray, $UBOUND_COLUMNS) If $iStart < 0 Or $iStart > $iDim_2 - 1 Then Return SetError(4, 0, -1) Local $iValDim_1, $iValDim_2 = 0, $iColCount If IsArray($vValue) Then If UBound($vValue, $UBOUND_DIMENSIONS) <> 2 Then Return SetError(5, 0, -1) $iValDim_1 = UBound($vValue, $UBOUND_ROWS) $iValDim_2 = UBound($vValue, $UBOUND_COLUMNS) $hDataType = 0 Else Local $aSplit_1 = StringSplit($vValue, $sDelim_Row, $STR_NOCOUNT + $STR_ENTIRESPLIT) $iValDim_1 = UBound($aSplit_1, $UBOUND_ROWS) Local $aTmp[$iValDim_1][0], $aSplit_2 For $i = 0 To $iValDim_1 - 1 $aSplit_2 = StringSplit($aSplit_1[$i], $sDelim_Item, $STR_NOCOUNT + $STR_ENTIRESPLIT) $iColCount = UBound($aSplit_2) If $iColCount > $iValDim_2 Then $iValDim_2 = $iColCount ReDim $aTmp[$iValDim_1][$iValDim_2] EndIf For $j = 0 To $iColCount - 1 $aTmp[$i][$j] = $aSplit_2[$j] Next Next $vValue = $aTmp EndIf If UBound($vValue, $UBOUND_COLUMNS) + $iStart > UBound($aArray, $UBOUND_COLUMNS) Then Return SetError(3, 0, -1) ReDim $aArray[$iDim_1 + $iValDim_1][$iDim_2] For $iWriteTo_Index = 0 To $iValDim_1 - 1 For $j = 0 To $iDim_2 - 1 If $j < $iStart Then $aArray[$iWriteTo_Index + $iDim_1][$j] = "" ElseIf $j - $iStart > $iValDim_2 - 1 Then $aArray[$iWriteTo_Index + $iDim_1][$j] = "" Else If String($hDataType) = "Boolean" Then Switch $vValue[$iWriteTo_Index][$j - $iStart] Case "True", "1" $aArray[$iWriteTo_Index + $iDim_1][$j] = True Case "False", "0", "" $aArray[$iWriteTo_Index + $iDim_1][$j] = False EndSwitch ElseIf IsFunc($hDataType) Then $aArray[$iWriteTo_Index + $iDim_1][$j] = $hDataType($vValue[$iWriteTo_Index][$j - $iStart]) Else $aArray[$iWriteTo_Index + $iDim_1][$j] = $vValue[$iWriteTo_Index][$j - $iStart] EndIf EndIf Next Next Case Else Return SetError(2, 0, -1) EndSwitch Return UBound($aArray, $UBOUND_ROWS) - 1 EndFunc Func _ArrayBinarySearch(Const ByRef $aArray, $vValue, $iStart = 0, $iEnd = 0, $iColumn = 0) If $iStart = Default Then $iStart = 0 If $iEnd = Default Then $iEnd = 0 If $iColumn = Default Then $iColumn = 0 If Not IsArray($aArray) Then Return SetError(1, 0, -1) Local $iDim_1 = UBound($aArray, $UBOUND_ROWS) If $iDim_1 = 0 Then Return SetError(6, 0, -1) If $iEnd < 1 Or $iEnd > $iDim_1 - 1 Then $iEnd = $iDim_1 - 1 If $iStart < 0 Then $iStart = 0 If $iStart > $iEnd Then Return SetError(4, 0, -1) Local $iMid = Int(($iEnd + $iStart) / 2) Switch UBound($aArray, $UBOUND_DIMENSIONS) Case 1 If $aArray[$iStart] > $vValue Or $aArray[$iEnd] < $vValue Then Return SetError(2, 0, -1) While $iStart <= $iMid And $vValue <> $aArray[$iMid] If $vValue < $aArray[$iMid] Then $iEnd = $iMid - 1 Else $iStart = $iMid + 1 EndIf $iMid = Int(($iEnd + $iStart) / 2) WEnd If $iStart > $iEnd Then Return SetError(3, 0, -1) Case 2 Local $iDim_2 = UBound($aArray, $UBOUND_COLUMNS) - 1 If $iColumn < 0 Or $iColumn > $iDim_2 Then Return SetError(7, 0, -1) If $aArray[$iStart][$iColumn] > $vValue Or $aArray[$iEnd][$iColumn] < $vValue Then Return SetError(2, 0, -1) While $iStart <= $iMid And $vValue <> $aArray[$iMid][$iColumn] If $vValue < $aArray[$iMid][$iColumn] Then $iEnd = $iMid - 1 Else $iStart = $iMid + 1 EndIf $iMid = Int(($iEnd + $iStart) / 2) WEnd If $iStart > $iEnd Then Return SetError(3, 0, -1) Case Else Return SetError(5, 0, -1) EndSwitch Return $iMid EndFunc Func _ArrayColDelete(ByRef $aArray, $iColumn, $bConvert = False) If $bConvert = Default Then $bConvert = False If Not IsArray($aArray) Then Return SetError(1, 0, -1) Local $iDim_1 = UBound($aArray, $UBOUND_ROWS) If UBound($aArray, $UBOUND_DIMENSIONS) <> 2 Then Return SetError(2, 0, -1) Local $iDim_2 = UBound($aArray, $UBOUND_COLUMNS) Switch $iDim_2 Case 2 If $iColumn < 0 Or $iColumn > 1 Then Return SetError(3, 0, -1) If $bConvert Then Local $aTempArray[$iDim_1] For $i = 0 To $iDim_1 - 1 $aTempArray[$i] = $aArray[$i][(Not $iColumn)] Next $aArray = $aTempArray Else ContinueCase EndIf Case Else If $iColumn < 0 Or $iColumn > $iDim_2 - 1 Then Return SetError(3, 0, -1) For $i = 0 To $iDim_1 - 1 For $j = $iColumn To $iDim_2 - 2 $aArray[$i][$j] = $aArray[$i][$j + 1] Next Next ReDim $aArray[$iDim_1][$iDim_2 - 1] EndSwitch Return UBound($aArray, $UBOUND_COLUMNS) EndFunc Func _ArrayColInsert(ByRef $aArray, $iColumn) If Not IsArray($aArray) Then Return SetError(1, 0, -1) Local $iDim_1 = UBound($aArray, $UBOUND_ROWS) Switch UBound($aArray, $UBOUND_DIMENSIONS) Case 1 Local $aTempArray[$iDim_1][2] Switch $iColumn Case 0, 1 For $i = 0 To $iDim_1 - 1 $aTempArray[$i][(Not $iColumn)] = $aArray[$i] Next Case Else Return SetError(3, 0, -1) EndSwitch $aArray = $aTempArray Case 2 Local $iDim_2 = UBound($aArray, $UBOUND_COLUMNS) If $iColumn < 0 Or $iColumn > $iDim_2 Then Return SetError(3, 0, -1) ReDim $aArray[$iDim_1][$iDim_2 + 1] For $i = 0 To $iDim_1 - 1 For $j = $iDim_2 To $iColumn + 1 Step -1 $aArray[$i][$j] = $aArray[$i][$j - 1] Next $aArray[$i][$iColumn] = "" Next Case Else Return SetError(2, 0, -1) EndSwitch Return UBound($aArray, $UBOUND_COLUMNS) EndFunc Func _ArrayCombinations(Const ByRef $aArray, $iSet, $sDelimiter = "") If $sDelimiter = Default Then $sDelimiter = "" If Not IsArray($aArray) Then Return SetError(1, 0, 0) If UBound($aArray, $UBOUND_DIMENSIONS) <> 1 Then Return SetError(2, 0, 0) Local $iN = UBound($aArray) Local $iR = $iSet Local $aIdx[$iR] For $i = 0 To $iR - 1 $aIdx[$i] = $i Next Local $iTotal = __Array_Combinations($iN, $iR) Local $iLeft = $iTotal Local $aResult[$iTotal + 1] $aResult[0] = $iTotal Local $iCount = 1 While $iLeft > 0 __Array_GetNext($iN, $iR, $iLeft, $iTotal, $aIdx) For $i = 0 To $iSet - 1 $aResult[$iCount] &= $aArray[$aIdx[$i]] & $sDelimiter Next If $sDelimiter <> "" Then $aResult[$iCount] = StringTrimRight($aResult[$iCount], 1) $iCount += 1 WEnd Return $aResult EndFunc Func _ArrayConcatenate(ByRef $aArrayTarget, Const ByRef $aArraySource, $iStart = 0) If $iStart = Default Then $iStart = 0 If Not IsArray($aArrayTarget) Then Return SetError(1, 0, -1) If Not IsArray($aArraySource) Then Return SetError(2, 0, -1) Local $iDim_Total_Tgt = UBound($aArrayTarget, $UBOUND_DIMENSIONS) Local $iDim_Total_Src = UBound($aArraySource, $UBOUND_DIMENSIONS) Local $iDim_1_Tgt = UBound($aArrayTarget, $UBOUND_ROWS) Local $iDim_1_Src = UBound($aArraySource, $UBOUND_ROWS) If $iStart < 0 Or $iStart > $iDim_1_Src - 1 Then Return SetError(6, 0, -1) Switch $iDim_Total_Tgt Case 1 If $iDim_Total_Src <> 1 Then Return SetError(4, 0, -1) ReDim $aArrayTarget[$iDim_1_Tgt + $iDim_1_Src - $iStart] For $i = $iStart To $iDim_1_Src - 1 $aArrayTarget[$iDim_1_Tgt + $i - $iStart] = $aArraySource[$i] Next Case 2 If $iDim_Total_Src <> 2 Then Return SetError(4, 0, -1) Local $iDim_2_Tgt = UBound($aArrayTarget, $UBOUND_COLUMNS) If UBound($aArraySource, $UBOUND_COLUMNS) <> $iDim_2_Tgt Then Return SetError(5, 0, -1) ReDim $aArrayTarget[$iDim_1_Tgt + $iDim_1_Src - $iStart][$iDim_2_Tgt] For $i = $iStart To $iDim_1_Src - 1 For $j = 0 To $iDim_2_Tgt - 1 $aArrayTarget[$iDim_1_Tgt + $i - $iStart][$j] = $aArraySource[$i][$j] Next Next Case Else Return SetError(3, 0, -1) EndSwitch Return UBound($aArrayTarget, $UBOUND_ROWS) EndFunc Func _ArrayDelete(ByRef $aArray, $vRange) If Not IsArray($aArray) Then Return SetError(1, 0, -1) Local $iDim_1 = UBound($aArray, $UBOUND_ROWS) - 1 If IsArray($vRange) Then If UBound($vRange, $UBOUND_DIMENSIONS) <> 1 Or UBound($vRange, $UBOUND_ROWS) < 2 Then Return SetError(4, 0, -1) Else Local $iNumber, $aSplit_1, $aSplit_2 $vRange = StringStripWS($vRange, 8) $aSplit_1 = StringSplit($vRange, ";") $vRange = "" For $i = 1 To $aSplit_1[0] If Not StringRegExp($aSplit_1[$i], "^\d+(-\d+)?$") Then Return SetError(3, 0, -1) $aSplit_2 = StringSplit($aSplit_1[$i], "-") Switch $aSplit_2[0] Case 1 $vRange &= $aSplit_2[1] & ";" Case 2 If Number($aSplit_2[2]) >= Number($aSplit_2[1]) Then $iNumber = $aSplit_2[1] - 1 Do $iNumber += 1 $vRange &= $iNumber & ";" Until $iNumber = $aSplit_2[2] EndIf EndSwitch Next $vRange = StringSplit(StringTrimRight($vRange, 1), ";") EndIf If $vRange[1] < 0 Or $vRange[$vRange[0]] > $iDim_1 Then Return SetError(5, 0, -1) Local $iCopyTo_Index = 0 Switch UBound($aArray, $UBOUND_DIMENSIONS) Case 1 For $i = 1 To $vRange[0] $aArray[$vRange[$i]] = ChrW(0xFAB1) Next For $iReadFrom_Index = 0 To $iDim_1 If $aArray[$iReadFrom_Index] == ChrW(0xFAB1) Then ContinueLoop Else If $iReadFrom_Index <> $iCopyTo_Index Then $aArray[$iCopyTo_Index] = $aArray[$iReadFrom_Index] EndIf $iCopyTo_Index += 1 EndIf Next ReDim $aArray[$iDim_1 - $vRange[0] + 1] Case 2 Local $iDim_2 = UBound($aArray, $UBOUND_COLUMNS) - 1 For $i = 1 To $vRange[0] $aArray[$vRange[$i]][0] = ChrW(0xFAB1) Next For $iReadFrom_Index = 0 To $iDim_1 If $aArray[$iReadFrom_Index][0] == ChrW(0xFAB1) Then ContinueLoop Else If $iReadFrom_Index <> $iCopyTo_Index Then For $j = 0 To $iDim_2 $aArray[$iCopyTo_Index][$j] = $aArray[$iReadFrom_Index][$j] Next EndIf $iCopyTo_Index += 1 EndIf Next ReDim $aArray[$iDim_1 - $vRange[0] + 1][$iDim_2 + 1] Case Else Return SetError(2, 0, False) EndSwitch Return UBound($aArray, $UBOUND_ROWS) EndFunc Func _ArrayDisplay(Const ByRef $aArray, $sTitle = Default, $sArrayRange = Default, $iFlags = Default, $vUser_Separator = Default, $sHeader = Default, $iMax_ColWidth = Default) #forceref $vUser_Separator Local $iRet = __ArrayDisplay_Share($aArray, $sTitle, $sArrayRange, $iFlags, Default, $sHeader, $iMax_ColWidth, 0, False) Return SetError(@error, @extended, $iRet) EndFunc Func _ArrayExtract(Const ByRef $aArray, $iStart_Row = -1, $iEnd_Row = -1, $iStart_Col = -1, $iEnd_Col = -1) If $iStart_Row = Default Then $iStart_Row = -1 If $iEnd_Row = Default Then $iEnd_Row = -1 If $iStart_Col = Default Then $iStart_Col = -1 If $iEnd_Col = Default Then $iEnd_Col = -1 If Not IsArray($aArray) Then Return SetError(1, 0, -1) Local $iDim_1 = UBound($aArray, $UBOUND_ROWS) - 1 If $iEnd_Row = -1 Then $iEnd_Row = $iDim_1 If $iStart_Row = -1 Then $iStart_Row = 0 If $iStart_Row < -1 Or $iEnd_Row < -1 Then Return SetError(3, 0, -1) If $iStart_Row > $iDim_1 Or $iEnd_Row > $iDim_1 Then Return SetError(3, 0, -1) If $iStart_Row > $iEnd_Row Then Return SetError(4, 0, -1) Switch UBound($aArray, $UBOUND_DIMENSIONS) Case 1 Local $aRetArray[$iEnd_Row - $iStart_Row + 1] For $i = 0 To $iEnd_Row - $iStart_Row $aRetArray[$i] = $aArray[$i + $iStart_Row] Next Return $aRetArray Case 2 Local $iDim_2 = UBound($aArray, $UBOUND_COLUMNS) - 1 If $iEnd_Col = -1 Then $iEnd_Col = $iDim_2 If $iStart_Col = -1 Then $iStart_Col = 0 If $iStart_Col < -1 Or $iEnd_Col < -1 Then Return SetError(5, 0, -1) If $iStart_Col > $iDim_2 Or $iEnd_Col > $iDim_2 Then Return SetError(5, 0, -1) If $iStart_Col > $iEnd_Col Then Return SetError(6, 0, -1) If $iStart_Col = $iEnd_Col Then Local $aRetArray[$iEnd_Row - $iStart_Row + 1] Else Local $aRetArray[$iEnd_Row - $iStart_Row + 1][$iEnd_Col - $iStart_Col + 1] EndIf For $i = 0 To $iEnd_Row - $iStart_Row For $j = 0 To $iEnd_Col - $iStart_Col If $iStart_Col = $iEnd_Col Then $aRetArray[$i] = $aArray[$i + $iStart_Row][$j + $iStart_Col] Else $aRetArray[$i][$j] = $aArray[$i + $iStart_Row][$j + $iStart_Col] EndIf Next Next Return $aRetArray Case Else Return SetError(2, 0, -1) EndSwitch Return 1 EndFunc Func _ArrayFindAll(Const ByRef $aArray, $vValue, $iStart = 0, $iEnd = 0, $iCase = 0, $iCompare = 0, $iSubItem = 0, $bRow = False) If $iStart = Default Then $iStart = 0 If $iEnd = Default Then $iEnd = 0 If $iCase = Default Then $iCase = 0 If $iCompare = Default Then $iCompare = 0 If $iSubItem = Default Then $iSubItem = 0 If $bRow = Default Then $bRow = False $iStart = _ArraySearch($aArray, $vValue, $iStart, $iEnd, $iCase, $iCompare, 1, $iSubItem, $bRow) If @error Then Return SetError(@error, 0, -1) Local $iIndex = 0, $avResult[UBound($aArray, ($bRow ? $UBOUND_COLUMNS : $UBOUND_ROWS))] Do $avResult[$iIndex] = $iStart $iIndex += 1 $iStart = _ArraySearch($aArray, $vValue, $iStart + 1, $iEnd, $iCase, $iCompare, 1, $iSubItem, $bRow) Until @error ReDim $avResult[$iIndex] Return $avResult EndFunc Func _ArrayInsert(ByRef $aArray, $vRange, $vValue = "", $iStart = 0, $sDelim_Item = "|", $sDelim_Row = @CRLF, $iForce = $ARRAYFILL_FORCE_DEFAULT) If $vValue = Default Then $vValue = "" If $iStart = Default Then $iStart = 0 If $sDelim_Item = Default Then $sDelim_Item = "|" If $sDelim_Row = Default Then $sDelim_Row = @CRLF If $iForce = Default Then $iForce = $ARRAYFILL_FORCE_DEFAULT If Not IsArray($aArray) Then Return SetError(1, 0, -1) Local $iDim_1 = UBound($aArray, $UBOUND_ROWS) - 1 Local $hDataType = 0 Switch $iForce Case $ARRAYFILL_FORCE_INT $hDataType = Int Case $ARRAYFILL_FORCE_NUMBER $hDataType = Number Case $ARRAYFILL_FORCE_PTR $hDataType = Ptr Case $ARRAYFILL_FORCE_HWND $hDataType = Hwnd Case $ARRAYFILL_FORCE_STRING $hDataType = String EndSwitch Local $aSplit_1, $aSplit_2 If IsArray($vRange) Then If UBound($vRange, $UBOUND_DIMENSIONS) <> 1 Or UBound($vRange, $UBOUND_ROWS) < 2 Then Return SetError(4, 0, -1) Else Local $iNumber $vRange = StringStripWS($vRange, 8) $aSplit_1 = StringSplit($vRange, ";") $vRange = "" For $i = 1 To $aSplit_1[0] If Not StringRegExp($aSplit_1[$i], "^\d+(-\d+)?$") Then Return SetError(3, 0, -1) $aSplit_2 = StringSplit($aSplit_1[$i], "-") Switch $aSplit_2[0] Case 1 $vRange &= $aSplit_2[1] & ";" Case 2 If Number($aSplit_2[2]) >= Number($aSplit_2[1]) Then $iNumber = $aSplit_2[1] - 1 Do $iNumber += 1 $vRange &= $iNumber & ";" Until $iNumber = $aSplit_2[2] EndIf EndSwitch Next $vRange = StringSplit(StringTrimRight($vRange, 1), ";") EndIf If $vRange[1] < 0 Or $vRange[$vRange[0]] > $iDim_1 Then Return SetError(5, 0, -1) For $i = 2 To $vRange[0] If $vRange[$i] < $vRange[$i - 1] Then Return SetError(3, 0, -1) Next Local $iCopyTo_Index = $iDim_1 + $vRange[0] Local $iInsertPoint_Index = $vRange[0] Local $iInsert_Index = $vRange[$iInsertPoint_Index] Switch UBound($aArray, $UBOUND_DIMENSIONS) Case 1 If $iForce = $ARRAYFILL_FORCE_SINGLEITEM Then ReDim $aArray[$iDim_1 + $vRange[0] + 1] For $iReadFromIndex = $iDim_1 To 0 Step -1 $aArray[$iCopyTo_Index] = $aArray[$iReadFromIndex] $iCopyTo_Index -= 1 $iInsert_Index = $vRange[$iInsertPoint_Index] While $iReadFromIndex = $iInsert_Index $aArray[$iCopyTo_Index] = $vValue $iCopyTo_Index -= 1 $iInsertPoint_Index -= 1 If $iInsertPoint_Index < 1 Then ExitLoop 2 $iInsert_Index = $vRange[$iInsertPoint_Index] WEnd Next Return $iDim_1 + $vRange[0] + 1 EndIf ReDim $aArray[$iDim_1 + $vRange[0] + 1] If IsArray($vValue) Then If UBound($vValue, $UBOUND_DIMENSIONS) <> 1 Then Return SetError(5, 0, -1) $hDataType = 0 Else Local $aTmp = StringSplit($vValue, $sDelim_Item, $STR_NOCOUNT + $STR_ENTIRESPLIT) If UBound($aTmp, $UBOUND_ROWS) = 1 Then $aTmp[0] = $vValue $hDataType = 0 EndIf $vValue = $aTmp EndIf For $iReadFromIndex = $iDim_1 To 0 Step -1 $aArray[$iCopyTo_Index] = $aArray[$iReadFromIndex] $iCopyTo_Index -= 1 $iInsert_Index = $vRange[$iInsertPoint_Index] While $iReadFromIndex = $iInsert_Index If $iInsertPoint_Index <= UBound($vValue, $UBOUND_ROWS) Then If IsFunc($hDataType) Then $aArray[$iCopyTo_Index] = $hDataType($vValue[$iInsertPoint_Index - 1]) Else $aArray[$iCopyTo_Index] = $vValue[$iInsertPoint_Index - 1] EndIf Else $aArray[$iCopyTo_Index] = "" EndIf $iCopyTo_Index -= 1 $iInsertPoint_Index -= 1 If $iInsertPoint_Index = 0 Then ExitLoop 2 $iInsert_Index = $vRange[$iInsertPoint_Index] WEnd Next Case 2 Local $iDim_2 = UBound($aArray, $UBOUND_COLUMNS) If $iStart < 0 Or $iStart > $iDim_2 - 1 Then Return SetError(6, 0, -1) Local $iValDim_1, $iValDim_2 If IsArray($vValue) Then If UBound($vValue, $UBOUND_DIMENSIONS) <> 2 Then Return SetError(7, 0, -1) $iValDim_1 = UBound($vValue, $UBOUND_ROWS) $iValDim_2 = UBound($vValue, $UBOUND_COLUMNS) $hDataType = 0 Else $aSplit_1 = StringSplit($vValue, $sDelim_Row, $STR_NOCOUNT + $STR_ENTIRESPLIT) $iValDim_1 = UBound($aSplit_1, $UBOUND_ROWS) StringReplace($aSplit_1[0], $sDelim_Item, "") $iValDim_2 = @extended + 1 Local $aTmp[$iValDim_1][$iValDim_2] For $i = 0 To $iValDim_1 - 1 $aSplit_2 = StringSplit($aSplit_1[$i], $sDelim_Item, $STR_NOCOUNT + $STR_ENTIRESPLIT) For $j = 0 To $iValDim_2 - 1 $aTmp[$i][$j] = $aSplit_2[$j] Next Next $vValue = $aTmp EndIf If UBound($vValue, $UBOUND_COLUMNS) + $iStart > UBound($aArray, $UBOUND_COLUMNS) Then Return SetError(8, 0, -1) ReDim $aArray[$iDim_1 + $vRange[0] + 1][$iDim_2] For $iReadFromIndex = $iDim_1 To 0 Step -1 For $j = 0 To $iDim_2 - 1 $aArray[$iCopyTo_Index][$j] = $aArray[$iReadFromIndex][$j] Next $iCopyTo_Index -= 1 $iInsert_Index = $vRange[$iInsertPoint_Index] While $iReadFromIndex = $iInsert_Index For $j = 0 To $iDim_2 - 1 If $j < $iStart Then $aArray[$iCopyTo_Index][$j] = "" ElseIf $j - $iStart > $iValDim_2 - 1 Then $aArray[$iCopyTo_Index][$j] = "" Else If $iInsertPoint_Index - 1 < $iValDim_1 Then If IsFunc($hDataType) Then $aArray[$iCopyTo_Index][$j] = $hDataType($vValue[$iInsertPoint_Index - 1][$j - $iStart]) Else $aArray[$iCopyTo_Index][$j] = $vValue[$iInsertPoint_Index - 1][$j - $iStart] EndIf Else $aArray[$iCopyTo_Index][$j] = "" EndIf EndIf Next $iCopyTo_Index -= 1 $iInsertPoint_Index -= 1 If $iInsertPoint_Index = 0 Then ExitLoop 2 $iInsert_Index = $vRange[$iInsertPoint_Index] WEnd Next Case Else Return SetError(2, 0, -1) EndSwitch Return UBound($aArray, $UBOUND_ROWS) EndFunc Func _ArrayMax(Const ByRef $aArray, $iCompNumeric = 0, $iStart = -1, $iEnd = -1, $iSubItem = 0) Local $iResult = _ArrayMaxIndex($aArray, $iCompNumeric, $iStart, $iEnd, $iSubItem) If @error Then Return SetError(@error, 0, "") If UBound($aArray, $UBOUND_DIMENSIONS) = 1 Then Return $aArray[$iResult] Else Return $aArray[$iResult][$iSubItem] EndIf EndFunc Func _ArrayMaxIndex(Const ByRef $aArray, $iCompNumeric = 0, $iStart = -1, $iEnd = -1, $iSubItem = 0) If $iCompNumeric = Default Then $iCompNumeric = 0 If $iStart = Default Then $iStart = -1 If $iEnd = Default Then $iEnd = -1 If $iSubItem = Default Then $iSubItem = 0 Local $iRet = __Array_MinMaxIndex($aArray, $iCompNumeric, $iStart, $iEnd, $iSubItem, __Array_GreaterThan) Return SetError(@error, 0, $iRet) EndFunc Func _ArrayMin(Const ByRef $aArray, $iCompNumeric = 0, $iStart = -1, $iEnd = -1, $iSubItem = 0) Local $iResult = _ArrayMinIndex($aArray, $iCompNumeric, $iStart, $iEnd, $iSubItem) If @error Then Return SetError(@error, 0, "") If UBound($aArray, $UBOUND_DIMENSIONS) = 1 Then Return $aArray[$iResult] Else Return $aArray[$iResult][$iSubItem] EndIf EndFunc Func _ArrayMinIndex(Const ByRef $aArray, $iCompNumeric = 0, $iStart = -1, $iEnd = -1, $iSubItem = 0) If $iCompNumeric = Default Then $iCompNumeric = 0 If $iStart = Default Then $iStart = -1 If $iEnd = Default Then $iEnd = -1 If $iSubItem = Default Then $iSubItem = 0 Local $iRet = __Array_MinMaxIndex($aArray, $iCompNumeric, $iStart, $iEnd, $iSubItem, __Array_LessThan) Return SetError(@error, 0, $iRet) EndFunc Func _ArrayPermute(ByRef $aArray, $sDelimiter = "") If $sDelimiter = Default Then $sDelimiter = "" If Not IsArray($aArray) Then Return SetError(1, 0, 0) If UBound($aArray, $UBOUND_DIMENSIONS) <> 1 Then Return SetError(2, 0, 0) Local $iSize = UBound($aArray), $iFactorial = 1, $aIdx[$iSize], $aResult[1], $iCount = 1 If UBound($aArray) Then For $i = 0 To $iSize - 1 $aIdx[$i] = $i Next For $i = $iSize To 1 Step -1 $iFactorial *= $i Next ReDim $aResult[$iFactorial + 1] $aResult[0] = $iFactorial __Array_ExeterInternal($aArray, 0, $iSize, $sDelimiter, $aIdx, $aResult, $iCount) Else $aResult[0] = 0 EndIf Return $aResult EndFunc Func _ArrayPop(ByRef $aArray) If (Not IsArray($aArray)) Then Return SetError(1, 0, "") If UBound($aArray, $UBOUND_DIMENSIONS) <> 1 Then Return SetError(2, 0, "") Local $iUBound = UBound($aArray) - 1 If $iUBound = -1 Then Return SetError(3, 0, "") Local $sLastVal = $aArray[$iUBound] If $iUBound > -1 Then ReDim $aArray[$iUBound] EndIf Return $sLastVal EndFunc Func _ArrayPush(ByRef $aArray, $vValue, $iDirection = 0) If $iDirection = Default Then $iDirection = 0 If (Not IsArray($aArray)) Then Return SetError(1, 0, 0) If UBound($aArray, $UBOUND_DIMENSIONS) <> 1 Then Return SetError(3, 0, 0) Local $iUBound = UBound($aArray) - 1 If IsArray($vValue) Then Local $iUBoundS = UBound($vValue) If ($iUBoundS - 1) > $iUBound Then Return SetError(2, 0, 0) If $iDirection Then For $i = $iUBound To $iUBoundS Step -1 $aArray[$i] = $aArray[$i - $iUBoundS] Next For $i = 0 To $iUBoundS - 1 $aArray[$i] = $vValue[$i] Next Else For $i = 0 To $iUBound - $iUBoundS $aArray[$i] = $aArray[$i + $iUBoundS] Next For $i = 0 To $iUBoundS - 1 $aArray[$i + $iUBound - $iUBoundS + 1] = $vValue[$i] Next EndIf Else If $iUBound > -1 Then If $iDirection Then For $i = $iUBound To 1 Step -1 $aArray[$i] = $aArray[$i - 1] Next $aArray[0] = $vValue Else For $i = 0 To $iUBound - 1 $aArray[$i] = $aArray[$i + 1] Next $aArray[$iUBound] = $vValue EndIf EndIf EndIf Return 1 EndFunc Func _ArrayReverse(ByRef $aArray, $iStart = 0, $iEnd = 0) If $iStart = Default Then $iStart = 0 If $iEnd = Default Then $iEnd = 0 If Not IsArray($aArray) Then Return SetError(1, 0, 0) If UBound($aArray, $UBOUND_DIMENSIONS) <> 1 Then Return SetError(3, 0, 0) If Not UBound($aArray) Then Return SetError(4, 0, 0) Local $vTmp, $iUBound = UBound($aArray) - 1 If $iEnd < 1 Or $iEnd > $iUBound Then $iEnd = $iUBound If $iStart < 0 Then $iStart = 0 If $iStart > $iEnd Then Return SetError(2, 0, 0) For $i = $iStart To Int(($iStart + $iEnd - 1) / 2) $vTmp = $aArray[$i] $aArray[$i] = $aArray[$iEnd] $aArray[$iEnd] = $vTmp $iEnd -= 1 Next Return 1 EndFunc Func _ArraySearch(Const ByRef $aArray, $vValue, $iStart = 0, $iEnd = 0, $iCase = 0, $iCompare = 0, $iForward = 1, $iSubItem = -1, $bRow = False) If $iStart = Default Then $iStart = 0 If $iEnd = Default Then $iEnd = 0 If $iCase = Default Then $iCase = 0 If $iCompare = Default Then $iCompare = 0 If $iForward = Default Then $iForward = 1 If $iSubItem = Default Then $iSubItem = -1 If $bRow = Default Then $bRow = False If Not IsArray($aArray) Then Return SetError(1, 0, -1) Local $iDim_1 = UBound($aArray) - 1 If $iDim_1 = -1 Then Return SetError(3, 0, -1) Local $iDim_2 = UBound($aArray, $UBOUND_COLUMNS) - 1 Local $bCompType = False If $iCompare = 2 Then $iCompare = 0 $bCompType = True EndIf If $bRow Then If UBound($aArray, $UBOUND_DIMENSIONS) = 1 Then Return SetError(5, 0, -1) If $iEnd < 1 Or $iEnd > $iDim_2 Then $iEnd = $iDim_2 If $iStart < 0 Then $iStart = 0 If $iStart > $iEnd Then Return SetError(4, 0, -1) Else If $iEnd < 1 Or $iEnd > $iDim_1 Then $iEnd = $iDim_1 If $iStart < 0 Then $iStart = 0 If $iStart > $iEnd Then Return SetError(4, 0, -1) EndIf Local $iStep = 1 If Not $iForward Then Local $iTmp = $iStart $iStart = $iEnd $iEnd = $iTmp $iStep = -1 EndIf Switch UBound($aArray, $UBOUND_DIMENSIONS) Case 1 If Not $iCompare Then If Not $iCase Then For $i = $iStart To $iEnd Step $iStep If $bCompType And VarGetType($aArray[$i]) <> VarGetType($vValue) Then ContinueLoop If $aArray[$i] = $vValue Then Return $i Next Else For $i = $iStart To $iEnd Step $iStep If $bCompType And VarGetType($aArray[$i]) <> VarGetType($vValue) Then ContinueLoop If $aArray[$i] == $vValue Then Return $i Next EndIf Else For $i = $iStart To $iEnd Step $iStep If $iCompare = 3 Then If StringRegExp($aArray[$i], $vValue) Then Return $i Else If StringInStr($aArray[$i], $vValue, $iCase) > 0 Then Return $i EndIf Next EndIf Case 2 Local $iDim_Sub If $bRow Then $iDim_Sub = $iDim_1 If $iSubItem > $iDim_Sub Then $iSubItem = $iDim_Sub If $iSubItem < 0 Then $iSubItem = 0 Else $iDim_Sub = $iSubItem EndIf Else $iDim_Sub = $iDim_2 If $iSubItem > $iDim_Sub Then $iSubItem = $iDim_Sub If $iSubItem < 0 Then $iSubItem = 0 Else $iDim_Sub = $iSubItem EndIf EndIf For $j = $iSubItem To $iDim_Sub If Not $iCompare Then If Not $iCase Then For $i = $iStart To $iEnd Step $iStep If $bRow Then If $bCompType And VarGetType($aArray[$j][$i]) <> VarGetType($vValue) Then ContinueLoop If $aArray[$j][$i] = $vValue Then Return $i Else If $bCompType And VarGetType($aArray[$i][$j]) <> VarGetType($vValue) Then ContinueLoop If $aArray[$i][$j] = $vValue Then Return $i EndIf Next Else For $i = $iStart To $iEnd Step $iStep If $bRow Then If $bCompType And VarGetType($aArray[$j][$i]) <> VarGetType($vValue) Then ContinueLoop If $aArray[$j][$i] == $vValue Then Return $i Else If $bCompType And VarGetType($aArray[$i][$j]) <> VarGetType($vValue) Then ContinueLoop If $aArray[$i][$j] == $vValue Then Return $i EndIf Next EndIf Else For $i = $iStart To $iEnd Step $iStep If $iCompare = 3 Then If $bRow Then If StringRegExp($aArray[$j][$i], $vValue) Then Return $i Else If StringRegExp($aArray[$i][$j], $vValue) Then Return $i EndIf Else If $bRow Then If StringInStr($aArray[$j][$i], $vValue, $iCase) > 0 Then Return $i Else If StringInStr($aArray[$i][$j], $vValue, $iCase) > 0 Then Return $i EndIf EndIf Next EndIf Next Case Else Return SetError(2, 0, -1) EndSwitch Return SetError(6, 0, -1) EndFunc Func _ArrayShuffle(ByRef $aArray, $iStart_Row = 0, $iEnd_Row = 0, $iCol = -1) If $iStart_Row = Default Then $iStart_Row = 0 If $iEnd_Row = Default Then $iEnd_Row = 0 If $iCol = Default Then $iCol = -1 If Not IsArray($aArray) Then Return SetError(1, 0, -1) Local $iDim_1 = UBound($aArray, $UBOUND_ROWS) If $iEnd_Row = 0 Then $iEnd_Row = $iDim_1 - 1 If $iStart_Row < 0 Or $iStart_Row > $iDim_1 - 1 Then Return SetError(3, 0, -1) If $iEnd_Row < 1 Or $iEnd_Row > $iDim_1 - 1 Then Return SetError(3, 0, -1) If $iStart_Row > $iEnd_Row Then Return SetError(4, 0, -1) Local $vTmp, $iRand Switch UBound($aArray, $UBOUND_DIMENSIONS) Case 1 For $i = $iEnd_Row To $iStart_Row + 1 Step -1 $iRand = Random($iStart_Row, $i, 1) $vTmp = $aArray[$i] $aArray[$i] = $aArray[$iRand] $aArray[$iRand] = $vTmp Next Return 1 Case 2 Local $iDim_2 = UBound($aArray, $UBOUND_COLUMNS) If $iCol < -1 Or $iCol > $iDim_2 - 1 Then Return SetError(5, 0, -1) Local $iCol_Start, $iCol_End If $iCol = -1 Then $iCol_Start = 0 $iCol_End = $iDim_2 - 1 Else $iCol_Start = $iCol $iCol_End = $iCol EndIf For $i = $iEnd_Row To $iStart_Row + 1 Step -1 $iRand = Random($iStart_Row, $i, 1) For $j = $iCol_Start To $iCol_End $vTmp = $aArray[$i][$j] $aArray[$i][$j] = $aArray[$iRand][$j] $aArray[$iRand][$j] = $vTmp Next Next Return 1 Case Else Return SetError(2, 0, -1) EndSwitch EndFunc Func _ArraySort(ByRef $aArray, $iDescending = 0, $iStart = 0, $iEnd = 0, $iSubItem = 0, $iPivot = 0) If $iDescending = Default Then $iDescending = 0 If $iStart = Default Then $iStart = 0 If $iEnd = Default Then $iEnd = 0 If $iSubItem = Default Then $iSubItem = 0 If $iPivot = Default Then $iPivot = 0 If Not IsArray($aArray) Then Return SetError(1, 0, 0) Local $iUBound = UBound($aArray) - 1 If $iUBound = -1 Then Return SetError(5, 0, 0) If $iEnd = Default Then $iEnd = 0 If $iEnd < 1 Or $iEnd > $iUBound Or $iEnd = Default Then $iEnd = $iUBound If $iStart < 0 Or $iStart = Default Then $iStart = 0 If $iStart > $iEnd Then Return SetError(2, 0, 0) Switch UBound($aArray, $UBOUND_DIMENSIONS) Case 1 If $iPivot Then __ArrayDualPivotSort($aArray, $iStart, $iEnd) Else __ArrayQuickSort1D($aArray, $iStart, $iEnd) EndIf If $iDescending Then _ArrayReverse($aArray, $iStart, $iEnd) Case 2 If $iPivot Then Return SetError(6, 0, 0) Local $iSubMax = UBound($aArray, $UBOUND_COLUMNS) - 1 If $iSubItem > $iSubMax Then Return SetError(3, 0, 0) If $iDescending Then $iDescending = -1 Else $iDescending = 1 EndIf __ArrayQuickSort2D($aArray, $iDescending, $iStart, $iEnd, $iSubItem, $iSubMax) Case Else Return SetError(4, 0, 0) EndSwitch Return 1 EndFunc Func __ArrayQuickSort1D(ByRef $aArray, Const ByRef $iStart, Const ByRef $iEnd) If $iEnd <= $iStart Then Return Local $vTmp If ($iEnd - $iStart) < 15 Then Local $vCur For $i = $iStart + 1 To $iEnd $vTmp = $aArray[$i] If IsNumber($vTmp) Then For $j = $i - 1 To $iStart Step -1 $vCur = $aArray[$j] If ($vTmp >= $vCur And IsNumber($vCur)) Or (Not IsNumber($vCur) And StringCompare($vTmp, $vCur) >= 0) Then ExitLoop $aArray[$j + 1] = $vCur Next Else For $j = $i - 1 To $iStart Step -1 If (StringCompare($vTmp, $aArray[$j]) >= 0) Then ExitLoop $aArray[$j + 1] = $aArray[$j] Next EndIf $aArray[$j + 1] = $vTmp Next Return EndIf Local $L = $iStart, $R = $iEnd, $vPivot = $aArray[Int(($iStart + $iEnd) / 2)], $bNum = IsNumber($vPivot) Do If $bNum Then While ($aArray[$L] < $vPivot And IsNumber($aArray[$L])) Or (Not IsNumber($aArray[$L]) And StringCompare($aArray[$L], $vPivot) < 0) $L += 1 WEnd While ($aArray[$R] > $vPivot And IsNumber($aArray[$R])) Or (Not IsNumber($aArray[$R]) And StringCompare($aArray[$R], $vPivot) > 0) $R -= 1 WEnd Else While (StringCompare($aArray[$L], $vPivot) < 0) $L += 1 WEnd While (StringCompare($aArray[$R], $vPivot) > 0) $R -= 1 WEnd EndIf If $L <= $R Then $vTmp = $aArray[$L] $aArray[$L] = $aArray[$R] $aArray[$R] = $vTmp $L += 1 $R -= 1 EndIf Until $L > $R __ArrayQuickSort1D($aArray, $iStart, $R) __ArrayQuickSort1D($aArray, $L, $iEnd) EndFunc Func __ArrayQuickSort2D(ByRef $aArray, Const ByRef $iStep, Const ByRef $iStart, Const ByRef $iEnd, Const ByRef $iSubItem, Const ByRef $iSubMax) If $iEnd <= $iStart Then Return Local $vTmp, $L = $iStart, $R = $iEnd, $vPivot = $aArray[Int(($iStart + $iEnd) / 2)][$iSubItem], $bNum = IsNumber($vPivot) Do If $bNum Then While ($iStep * ($aArray[$L][$iSubItem] - $vPivot) < 0 And IsNumber($aArray[$L][$iSubItem])) Or (Not IsNumber($aArray[$L][$iSubItem]) And $iStep * StringCompare($aArray[$L][$iSubItem], $vPivot) < 0) $L += 1 WEnd While ($iStep * ($aArray[$R][$iSubItem] - $vPivot) > 0 And IsNumber($aArray[$R][$iSubItem])) Or (Not IsNumber($aArray[$R][$iSubItem]) And $iStep * StringCompare($aArray[$R][$iSubItem], $vPivot) > 0) $R -= 1 WEnd Else While ($iStep * StringCompare($aArray[$L][$iSubItem], $vPivot) < 0) $L += 1 WEnd While ($iStep * StringCompare($aArray[$R][$iSubItem], $vPivot) > 0) $R -= 1 WEnd EndIf If $L <= $R Then For $i = 0 To $iSubMax $vTmp = $aArray[$L][$i] $aArray[$L][$i] = $aArray[$R][$i] $aArray[$R][$i] = $vTmp Next $L += 1 $R -= 1 EndIf Until $L > $R __ArrayQuickSort2D($aArray, $iStep, $iStart, $R, $iSubItem, $iSubMax) __ArrayQuickSort2D($aArray, $iStep, $L, $iEnd, $iSubItem, $iSubMax) EndFunc Func __ArrayDualPivotSort(ByRef $aArray, $iPivot_Left, $iPivot_Right, $bLeftMost = True) If $iPivot_Left > $iPivot_Right Then Return Local $iLength = $iPivot_Right - $iPivot_Left + 1 Local $i, $j, $k, $iAi, $iAk, $iA1, $iA2, $iLast If $iLength < 45 Then If $bLeftMost Then $i = $iPivot_Left While $i < $iPivot_Right $j = $i $iAi = $aArray[$i + 1] While $iAi < $aArray[$j] $aArray[$j + 1] = $aArray[$j] $j -= 1 If $j + 1 = $iPivot_Left Then ExitLoop WEnd $aArray[$j + 1] = $iAi $i += 1 WEnd Else While 1 If $iPivot_Left >= $iPivot_Right Then Return 1 $iPivot_Left += 1 If $aArray[$iPivot_Left] < $aArray[$iPivot_Left - 1] Then ExitLoop WEnd While 1 $k = $iPivot_Left $iPivot_Left += 1 If $iPivot_Left > $iPivot_Right Then ExitLoop $iA1 = $aArray[$k] $iA2 = $aArray[$iPivot_Left] If $iA1 < $iA2 Then $iA2 = $iA1 $iA1 = $aArray[$iPivot_Left] EndIf $k -= 1 While $iA1 < $aArray[$k] $aArray[$k + 2] = $aArray[$k] $k -= 1 WEnd $aArray[$k + 2] = $iA1 While $iA2 < $aArray[$k] $aArray[$k + 1] = $aArray[$k] $k -= 1 WEnd $aArray[$k + 1] = $iA2 $iPivot_Left += 1 WEnd $iLast = $aArray[$iPivot_Right] $iPivot_Right -= 1 While $iLast < $aArray[$iPivot_Right] $aArray[$iPivot_Right + 1] = $aArray[$iPivot_Right] $iPivot_Right -= 1 WEnd $aArray[$iPivot_Right + 1] = $iLast EndIf Return 1 EndIf Local $iSeventh = BitShift($iLength, 3) + BitShift($iLength, 6) + 1 Local $iE1, $iE2, $iE3, $iE4, $iE5, $t $iE3 = Ceiling(($iPivot_Left + $iPivot_Right) / 2) $iE2 = $iE3 - $iSeventh $iE1 = $iE2 - $iSeventh $iE4 = $iE3 + $iSeventh $iE5 = $iE4 + $iSeventh If $aArray[$iE2] < $aArray[$iE1] Then $t = $aArray[$iE2] $aArray[$iE2] = $aArray[$iE1] $aArray[$iE1] = $t EndIf If $aArray[$iE3] < $aArray[$iE2] Then $t = $aArray[$iE3] $aArray[$iE3] = $aArray[$iE2] $aArray[$iE2] = $t If $t < $aArray[$iE1] Then $aArray[$iE2] = $aArray[$iE1] $aArray[$iE1] = $t EndIf EndIf If $aArray[$iE4] < $aArray[$iE3] Then $t = $aArray[$iE4] $aArray[$iE4] = $aArray[$iE3] $aArray[$iE3] = $t If $t < $aArray[$iE2] Then $aArray[$iE3] = $aArray[$iE2] $aArray[$iE2] = $t If $t < $aArray[$iE1] Then $aArray[$iE2] = $aArray[$iE1] $aArray[$iE1] = $t EndIf EndIf EndIf If $aArray[$iE5] < $aArray[$iE4] Then $t = $aArray[$iE5] $aArray[$iE5] = $aArray[$iE4] $aArray[$iE4] = $t If $t < $aArray[$iE3] Then $aArray[$iE4] = $aArray[$iE3] $aArray[$iE3] = $t If $t < $aArray[$iE2] Then $aArray[$iE3] = $aArray[$iE2] $aArray[$iE2] = $t If $t < $aArray[$iE1] Then $aArray[$iE2] = $aArray[$iE1] $aArray[$iE1] = $t EndIf EndIf EndIf EndIf Local $iLess = $iPivot_Left Local $iGreater = $iPivot_Right If (($aArray[$iE1] <> $aArray[$iE2]) And ($aArray[$iE2] <> $aArray[$iE3]) And ($aArray[$iE3] <> $aArray[$iE4]) And ($aArray[$iE4] <> $aArray[$iE5])) Then Local $iPivot_1 = $aArray[$iE2] Local $iPivot_2 = $aArray[$iE4] $aArray[$iE2] = $aArray[$iPivot_Left] $aArray[$iE4] = $aArray[$iPivot_Right] Do $iLess += 1 Until $aArray[$iLess] >= $iPivot_1 Do $iGreater -= 1 Until $aArray[$iGreater] <= $iPivot_2 $k = $iLess While $k <= $iGreater $iAk = $aArray[$k] If $iAk < $iPivot_1 Then $aArray[$k] = $aArray[$iLess] $aArray[$iLess] = $iAk $iLess += 1 ElseIf $iAk > $iPivot_2 Then While $aArray[$iGreater] > $iPivot_2 $iGreater -= 1 If $iGreater + 1 = $k Then ExitLoop 2 WEnd If $aArray[$iGreater] < $iPivot_1 Then $aArray[$k] = $aArray[$iLess] $aArray[$iLess] = $aArray[$iGreater] $iLess += 1 Else $aArray[$k] = $aArray[$iGreater] EndIf $aArray[$iGreater] = $iAk $iGreater -= 1 EndIf $k += 1 WEnd $aArray[$iPivot_Left] = $aArray[$iLess - 1] $aArray[$iLess - 1] = $iPivot_1 $aArray[$iPivot_Right] = $aArray[$iGreater + 1] $aArray[$iGreater + 1] = $iPivot_2 __ArrayDualPivotSort($aArray, $iPivot_Left, $iLess - 2, True) __ArrayDualPivotSort($aArray, $iGreater + 2, $iPivot_Right, False) If ($iLess < $iE1) And ($iE5 < $iGreater) Then While $aArray[$iLess] = $iPivot_1 $iLess += 1 WEnd While $aArray[$iGreater] = $iPivot_2 $iGreater -= 1 WEnd $k = $iLess While $k <= $iGreater $iAk = $aArray[$k] If $iAk = $iPivot_1 Then $aArray[$k] = $aArray[$iLess] $aArray[$iLess] = $iAk $iLess += 1 ElseIf $iAk = $iPivot_2 Then While $aArray[$iGreater] = $iPivot_2 $iGreater -= 1 If $iGreater + 1 = $k Then ExitLoop 2 WEnd If $aArray[$iGreater] = $iPivot_1 Then $aArray[$k] = $aArray[$iLess] $aArray[$iLess] = $iPivot_1 $iLess += 1 Else $aArray[$k] = $aArray[$iGreater] EndIf $aArray[$iGreater] = $iAk $iGreater -= 1 EndIf $k += 1 WEnd EndIf __ArrayDualPivotSort($aArray, $iLess, $iGreater, False) Else Local $iPivot = $aArray[$iE3] $k = $iLess While $k <= $iGreater If $aArray[$k] = $iPivot Then $k += 1 ContinueLoop EndIf $iAk = $aArray[$k] If $iAk < $iPivot Then $aArray[$k] = $aArray[$iLess] $aArray[$iLess] = $iAk $iLess += 1 Else While $aArray[$iGreater] > $iPivot $iGreater -= 1 WEnd If $aArray[$iGreater] < $iPivot Then $aArray[$k] = $aArray[$iLess] $aArray[$iLess] = $aArray[$iGreater] $iLess += 1 Else $aArray[$k] = $iPivot EndIf $aArray[$iGreater] = $iAk $iGreater -= 1 EndIf $k += 1 WEnd __ArrayDualPivotSort($aArray, $iPivot_Left, $iLess - 1, True) __ArrayDualPivotSort($aArray, $iGreater + 1, $iPivot_Right, False) EndIf EndFunc Func _ArraySwap(ByRef $aArray, $iIndex_1, $iIndex_2, $bCol = False, $iStart = -1, $iEnd = -1) If $bCol = Default Then $bCol = False If $iStart = Default Then $iStart = -1 If $iEnd = Default Then $iEnd = -1 If Not IsArray($aArray) Then Return SetError(1, 0, -1) Local $iDim_1 = UBound($aArray, $UBOUND_ROWS) - 1 Local $iDim_2 = UBound($aArray, $UBOUND_COLUMNS) - 1 If $iDim_2 = -1 Then $bCol = False $iStart = -1 $iEnd = -1 EndIf If $iStart > $iEnd Then Return SetError(5, 0, -1) If $bCol Then If $iIndex_1 < 0 Or $iIndex_2 > $iDim_2 Then Return SetError(3, 0, -1) If $iStart = -1 Then $iStart = 0 If $iEnd = -1 Then $iEnd = $iDim_1 Else If $iIndex_1 < 0 Or $iIndex_2 > $iDim_1 Then Return SetError(3, 0, -1) If $iStart = -1 Then $iStart = 0 If $iEnd = -1 Then $iEnd = $iDim_2 EndIf Local $vTmp Switch UBound($aArray, $UBOUND_DIMENSIONS) Case 1 $vTmp = $aArray[$iIndex_1] $aArray[$iIndex_1] = $aArray[$iIndex_2] $aArray[$iIndex_2] = $vTmp Case 2 If $iStart < -1 Or $iEnd < -1 Then Return SetError(4, 0, -1) If $bCol Then If $iStart > $iDim_1 Or $iEnd > $iDim_1 Then Return SetError(4, 0, -1) For $j = $iStart To $iEnd $vTmp = $aArray[$j][$iIndex_1] $aArray[$j][$iIndex_1] = $aArray[$j][$iIndex_2] $aArray[$j][$iIndex_2] = $vTmp Next Else If $iStart > $iDim_2 Or $iEnd > $iDim_2 Then Return SetError(4, 0, -1) For $j = $iStart To $iEnd $vTmp = $aArray[$iIndex_1][$j] $aArray[$iIndex_1][$j] = $aArray[$iIndex_2][$j] $aArray[$iIndex_2][$j] = $vTmp Next EndIf Case Else Return SetError(2, 0, -1) EndSwitch Return 1 EndFunc Func _ArrayToClip(Const ByRef $aArray, $sDelim_Col = "|", $iStart_Row = -1, $iEnd_Row = -1, $sDelim_Row = @CRLF, $iStart_Col = -1, $iEnd_Col = -1) Local $sResult = _ArrayToString($aArray, $sDelim_Col, $iStart_Row, $iEnd_Row, $sDelim_Row, $iStart_Col, $iEnd_Col) If @error Then Return SetError(@error, 0, 0) If ClipPut($sResult) Then Return 1 Return SetError(-1, 0, 0) EndFunc Func _ArrayToString(Const ByRef $aArray, $sDelim_Col = "|", $iStart_Row = -1, $iEnd_Row = -1, $sDelim_Row = @CRLF, $iStart_Col = -1, $iEnd_Col = -1) If $sDelim_Col = Default Then $sDelim_Col = "|" If $sDelim_Row = Default Then $sDelim_Row = @CRLF If $iStart_Row = Default Then $iStart_Row = -1 If $iEnd_Row = Default Then $iEnd_Row = -1 If $iStart_Col = Default Then $iStart_Col = -1 If $iEnd_Col = Default Then $iEnd_Col = -1 If Not IsArray($aArray) Then Return SetError(1, 0, -1) Local $iDim_1 = UBound($aArray, $UBOUND_ROWS) - 1 If $iStart_Row = -1 Then $iStart_Row = 0 If $iEnd_Row = -1 Then $iEnd_Row = $iDim_1 If $iStart_Row < -1 Or $iEnd_Row < -1 Then Return SetError(3, 0, -1) If $iStart_Row > $iDim_1 Or $iEnd_Row > $iDim_1 Then Return SetError(3, 0, "") If $iStart_Row > $iEnd_Row Then Return SetError(4, 0, -1) Local $sRet = "" Switch UBound($aArray, $UBOUND_DIMENSIONS) Case 1 For $i = $iStart_Row To $iEnd_Row $sRet &= $aArray[$i] & $sDelim_Col Next Return StringTrimRight($sRet, StringLen($sDelim_Col)) Case 2 Local $iDim_2 = UBound($aArray, $UBOUND_COLUMNS) - 1 If $iStart_Col = -1 Then $iStart_Col = 0 If $iEnd_Col = -1 Then $iEnd_Col = $iDim_2 If $iStart_Col < -1 Or $iEnd_Col < -1 Then Return SetError(5, 0, -1) If $iStart_Col > $iDim_2 Or $iEnd_Col > $iDim_2 Then Return SetError(5, 0, -1) If $iStart_Col > $iEnd_Col Then Return SetError(6, 0, -1) For $i = $iStart_Row To $iEnd_Row For $j = $iStart_Col To $iEnd_Col $sRet &= $aArray[$i][$j] & $sDelim_Col Next $sRet = StringTrimRight($sRet, StringLen($sDelim_Col)) & $sDelim_Row Next Return StringTrimRight($sRet, StringLen($sDelim_Row)) Case Else Return SetError(2, 0, -1) EndSwitch Return 1 EndFunc Func _ArrayTranspose(ByRef $aArray) Switch UBound($aArray, 0) Case 0 Return SetError(2, 0, 0) Case 1 Local $aTemp[1][UBound($aArray)] For $i = 0 To UBound($aArray) - 1 $aTemp[0][$i] = $aArray[$i] Next $aArray = $aTemp Case 2 Local $iDim_1 = UBound($aArray, 1), $iDim_2 = UBound($aArray, 2) If $iDim_1 <> $iDim_2 Then Local $aTemp[$iDim_2][$iDim_1] For $i = 0 To $iDim_1 - 1 For $j = 0 To $iDim_2 - 1 $aTemp[$j][$i] = $aArray[$i][$j] Next Next $aArray = $aTemp Else Local $vElement For $i = 0 To $iDim_1 - 1 For $j = $i + 1 To $iDim_2 - 1 $vElement = $aArray[$i][$j] $aArray[$i][$j] = $aArray[$j][$i] $aArray[$j][$i] = $vElement Next Next EndIf Case Else Return SetError(1, 0, 0) EndSwitch Return 1 EndFunc Func _ArrayTrim(ByRef $aArray, $iTrimNum, $iDirection = 0, $iStart = 0, $iEnd = 0, $iSubItem = 0) If $iDirection = Default Then $iDirection = 0 If $iStart = Default Then $iStart = 0 If $iEnd = Default Then $iEnd = 0 If $iSubItem = Default Then $iSubItem = 0 If Not IsArray($aArray) Then Return SetError(1, 0, 0) Local $iDim_1 = UBound($aArray, $UBOUND_ROWS) - 1 If $iEnd = 0 Then $iEnd = $iDim_1 If $iStart > $iEnd Then Return SetError(3, 0, -1) If $iStart < 0 Or $iEnd < 0 Then Return SetError(3, 0, -1) If $iStart > $iDim_1 Or $iEnd > $iDim_1 Then Return SetError(3, 0, -1) If $iStart > $iEnd Then Return SetError(4, 0, -1) Switch UBound($aArray, $UBOUND_DIMENSIONS) Case 1 If $iDirection Then For $i = $iStart To $iEnd $aArray[$i] = StringTrimRight($aArray[$i], $iTrimNum) Next Else For $i = $iStart To $iEnd $aArray[$i] = StringTrimLeft($aArray[$i], $iTrimNum) Next EndIf Case 2 Local $iDim_2 = UBound($aArray, $UBOUND_COLUMNS) - 1 If $iSubItem < 0 Or $iSubItem > $iDim_2 Then Return SetError(5, 0, -1) If $iDirection Then For $i = $iStart To $iEnd $aArray[$i][$iSubItem] = StringTrimRight($aArray[$i][$iSubItem], $iTrimNum) Next Else For $i = $iStart To $iEnd $aArray[$i][$iSubItem] = StringTrimLeft($aArray[$i][$iSubItem], $iTrimNum) Next EndIf Case Else Return SetError(2, 0, 0) EndSwitch Return 1 EndFunc Func _ArrayUnique(Const ByRef $aArray, $iColumn = 0, $iBase = 0, $iCase = 0, $iCount = $ARRAYUNIQUE_COUNT, $iIntType = $ARRAYUNIQUE_AUTO) If $iColumn = Default Then $iColumn = 0 If $iBase = Default Then $iBase = 0 If $iCase = Default Then $iCase = 0 If $iCount = Default Then $iCount = $ARRAYUNIQUE_COUNT If UBound($aArray, $UBOUND_ROWS) = 0 Then Return SetError(1, 0, 0) Local $iDims = UBound($aArray, $UBOUND_DIMENSIONS), $iNumColumns = UBound($aArray, $UBOUND_COLUMNS) If $iDims > 2 Then Return SetError(2, 0, 0) If $iBase < 0 Or $iBase > 1 Or (Not IsInt($iBase)) Then Return SetError(3, 0, 0) If $iCase < 0 Or $iCase > 1 Or (Not IsInt($iCase)) Then Return SetError(3, 0, 0) If $iCount < 0 Or $iCount > 1 Or (Not IsInt($iCount)) Then Return SetError(4, 0, 0) If $iIntType < 0 Or $iIntType > 4 Or (Not IsInt($iIntType)) Then Return SetError(5, 0, 0) If $iColumn < 0 Or ($iNumColumns = 0 And $iColumn > 0) Or ($iNumColumns > 0 And $iColumn >= $iNumColumns) Then Return SetError(6, 0, 0) If $iIntType = $ARRAYUNIQUE_AUTO Then Local $bInt, $sVarType If $iDims = 1 Then $bInt = IsInt($aArray[$iBase]) $sVarType = VarGetType($aArray[$iBase]) Else $bInt = IsInt($aArray[$iBase][$iColumn]) $sVarType = VarGetType($aArray[$iBase][$iColumn]) EndIf If $bInt And $sVarType = "Int64" Then $iIntType = $ARRAYUNIQUE_FORCE64 Else $iIntType = $ARRAYUNIQUE_FORCE32 EndIf EndIf ObjEvent("AutoIt.Error", __ArrayUnique_AutoErrFunc) Local $oDictionary = ObjCreate("Scripting.Dictionary") $oDictionary.CompareMode = Number(Not $iCase) Local $vElem, $sType, $vKey, $bCOMError = False For $i = $iBase To UBound($aArray) - 1 If $iDims = 1 Then $vElem = $aArray[$i] Else $vElem = $aArray[$i][$iColumn] EndIf Switch $iIntType Case $ARRAYUNIQUE_FORCE32 $oDictionary.Item($vElem) If @error Then $bCOMError = True ExitLoop EndIf Case $ARRAYUNIQUE_FORCE64 $sType = VarGetType($vElem) If $sType = "Int32" Then $bCOMError = True ExitLoop EndIf $vKey = "#" & $sType & "#" & String($vElem) If Not $oDictionary.Item($vKey) Then $oDictionary($vKey) = $vElem EndIf Case $ARRAYUNIQUE_MATCH $sType = VarGetType($vElem) If StringLeft($sType, 3) = "Int" Then $vKey = "#Int#" & String($vElem) Else $vKey = "#" & $sType & "#" & String($vElem) EndIf If Not $oDictionary.Item($vKey) Then $oDictionary($vKey) = $vElem EndIf Case $ARRAYUNIQUE_DISTINCT $vKey = "#" & VarGetType($vElem) & "#" & String($vElem) If Not $oDictionary.Item($vKey) Then $oDictionary($vKey) = $vElem EndIf EndSwitch Next Local $aValues, $j = 0 If $bCOMError Then Return SetError(7, 0, 0) ElseIf $iIntType <> $ARRAYUNIQUE_FORCE32 Then Local $aValues[$oDictionary.Count] For $vKey In $oDictionary.Keys() $aValues[$j] = $oDictionary($vKey) If StringLeft($vKey, 5) = "#Ptr#" Then $aValues[$j] = Ptr($aValues[$j]) EndIf $j += 1 Next Else $aValues = $oDictionary.Keys() EndIf If $iCount Then _ArrayInsert($aValues, 0, $oDictionary.Count) EndIf Return $aValues EndFunc Func _Array1DToHistogram($aArray, $iSizing = 100) If UBound($aArray, 0) > 1 Then Return SetError(1, 0, "") $iSizing = $iSizing * 8 Local $t, $n, $iMin = 0, $iMax = 0, $iOffset = 0 For $i = 0 To UBound($aArray) - 1 $t = $aArray[$i] $t = IsNumber($t) ? Round($t) : 0 If $t < $iMin Then $iMin = $t If $t > $iMax Then $iMax = $t Next Local $iRange = Int(Round(($iMax - $iMin) / 8)) * 8 Local $iSpaceRatio = 4 For $i = 0 To UBound($aArray) - 1 $t = $aArray[$i] If $t Then $n = Abs(Round(($iSizing * $t) / $iRange) / 8) $aArray[$i] = "" If $t > 0 Then If $iMin Then $iOffset = Int(Abs(Round(($iSizing * $iMin) / $iRange) / 8) / 8 * $iSpaceRatio) $aArray[$i] = __Array_StringRepeat(ChrW(0x20), $iOffset) EndIf Else If $iMin <> $t Then $iOffset = Int(Abs(Round(($iSizing * ($t - $iMin)) / $iRange) / 8) / 8 * $iSpaceRatio) $aArray[$i] = __Array_StringRepeat(ChrW(0x20), $iOffset) EndIf EndIf $aArray[$i] &= __Array_StringRepeat(ChrW(0x2588), Int($n / 8)) $n = Mod($n, 8) If $n > 0 Then $aArray[$i] &= ChrW(0x2588 + 8 - $n) $aArray[$i] &= ' ' & $t Else $aArray[$i] = "" EndIf Next Return $aArray EndFunc Func __Array_StringRepeat($sString, $iRepeatCount) $iRepeatCount = Int($iRepeatCount) If StringLen($sString) < 1 Or $iRepeatCount <= 0 Then Return SetError(1, 0, "") Local $sResult = "" While $iRepeatCount > 1 If BitAND($iRepeatCount, 1) Then $sResult &= $sString $sString &= $sString $iRepeatCount = BitShift($iRepeatCount, 1) WEnd Return $sString & $sResult EndFunc Func __Array_ExeterInternal(ByRef $aArray, $iStart, $iSize, $sDelimiter, ByRef $aIdx, ByRef $aResult, ByRef $iCount) If $iStart == $iSize - 1 Then For $i = 0 To $iSize - 1 $aResult[$iCount] &= $aArray[$aIdx[$i]] & $sDelimiter Next If $sDelimiter <> "" Then $aResult[$iCount] = StringTrimRight($aResult[$iCount], StringLen($sDelimiter)) $iCount += 1 Else Local $iTemp For $i = $iStart To $iSize - 1 $iTemp = $aIdx[$i] $aIdx[$i] = $aIdx[$iStart] $aIdx[$iStart] = $iTemp __Array_ExeterInternal($aArray, $iStart + 1, $iSize, $sDelimiter, $aIdx, $aResult, $iCount) $aIdx[$iStart] = $aIdx[$i] $aIdx[$i] = $iTemp Next EndIf EndFunc Func __Array_Combinations($iN, $iR) Local $i_Total = 1 For $i = $iR To 1 Step -1 $i_Total *= ($iN / $i) $iN -= 1 Next Return Round($i_Total) EndFunc Func __Array_GetNext($iN, $iR, ByRef $iLeft, $iTotal, ByRef $aIdx) If $iLeft == $iTotal Then $iLeft -= 1 Return EndIf Local $i = $iR - 1 While $aIdx[$i] == $iN - $iR + $i $i -= 1 WEnd $aIdx[$i] += 1 For $j = $i + 1 To $iR - 1 $aIdx[$j] = $aIdx[$i] + $j - $i Next $iLeft -= 1 EndFunc Func __Array_MinMaxIndex(Const ByRef $aArray, $iCompNumeric, $iStart, $iEnd, $iSubItem, $fuComparison) If $iCompNumeric = Default Then $iCompNumeric = 0 If $iCompNumeric <> 1 Then $iCompNumeric = 0 If $iStart = Default Then $iStart = 0 If $iEnd = Default Then $iEnd = 0 If $iSubItem = Default Then $iSubItem = 0 If Not IsArray($aArray) Then Return SetError(1, 0, -1) Local $iDim_1 = UBound($aArray, $UBOUND_ROWS) - 1 If $iDim_1 < 0 Then Return SetError(1, 0, -1) If $iEnd = -1 Then $iEnd = $iDim_1 If $iStart = -1 Then $iStart = 0 If $iStart < -1 Or $iEnd < -1 Then Return SetError(3, 0, -1) If $iStart > $iDim_1 Or $iEnd > $iDim_1 Then Return SetError(3, 0, -1) If $iStart > $iEnd Then Return SetError(4, 0, -1) If $iDim_1 < 0 Then Return SetError(5, 0, -1) Local $iMaxMinIndex = $iStart Switch UBound($aArray, $UBOUND_DIMENSIONS) Case 1 If $iCompNumeric Then For $i = $iStart To $iEnd If $fuComparison(Number($aArray[$i]), Number($aArray[$iMaxMinIndex])) Then $iMaxMinIndex = $i Next Else For $i = $iStart To $iEnd If $fuComparison($aArray[$i], $aArray[$iMaxMinIndex]) Then $iMaxMinIndex = $i Next EndIf Case 2 If $iSubItem < 0 Or $iSubItem > UBound($aArray, $UBOUND_COLUMNS) - 1 Then Return SetError(6, 0, -1) If $iCompNumeric Then For $i = $iStart To $iEnd If $fuComparison(Number($aArray[$i][$iSubItem]), Number($aArray[$iMaxMinIndex][$iSubItem])) Then $iMaxMinIndex = $i Next Else For $i = $iStart To $iEnd If $fuComparison($aArray[$i][$iSubItem], $aArray[$iMaxMinIndex][$iSubItem]) Then $iMaxMinIndex = $i Next EndIf Case Else Return SetError(2, 0, -1) EndSwitch Return $iMaxMinIndex EndFunc Func __Array_GreaterThan($vValue1, $vValue2) Return $vValue1 > $vValue2 EndFunc Func __Array_LessThan($vValue1, $vValue2) Return $vValue1 < $vValue2 EndFunc Func __ArrayUnique_AutoErrFunc() EndFunc Global Const $FC_NOOVERWRITE = 0 Global Const $FC_OVERWRITE = 1 Global Const $FC_CREATEPATH = 8 Global Const $FT_MODIFIED = 0 Global Const $FT_CREATED = 1 Global Const $FT_ACCESSED = 2 Global Const $FT_ARRAY = 0 Global Const $FT_STRING = 1 Global Const $FSF_CREATEBUTTON = 1 Global Const $FSF_NEWDIALOG = 2 Global Const $FSF_EDITCONTROL = 4 Global Const $FT_NONRECURSIVE = 0 Global Const $FT_RECURSIVE = 1 Global Const $FO_READ = 0 Global Const $FO_APPEND = 1 Global Const $FO_OVERWRITE = 2 Global Const $FO_CREATEPATH = 8 Global Const $FO_BINARY = 16 Global Const $FO_UNICODE = 32 Global Const $FO_UTF16_LE = 32 Global Const $FO_UTF16_BE = 64 Global Const $FO_UTF8 = 128 Global Const $FO_UTF8_NOBOM = 256 Global Const $FO_ANSI = 512 Global Const $FO_UTF16_LE_NOBOM = 1024 Global Const $FO_UTF16_BE_NOBOM = 2048 Global Const $FO_UTF8_FULL = 16384 Global Const $FO_FULLFILE_DETECT = 16384 Global Const $EOF = -1 Global Const $FD_FILEMUSTEXIST = 1 Global Const $FD_PATHMUSTEXIST = 2 Global Const $FD_MULTISELECT = 4 Global Const $FD_PROMPTCREATENEW = 8 Global Const $FD_PROMPTOVERWRITE = 16 Global Const $CREATE_NEW = 1 Global Const $CREATE_ALWAYS = 2 Global Const $OPEN_EXISTING = 3 Global Const $OPEN_ALWAYS = 4 Global Const $TRUNCATE_EXISTING = 5 Global Const $INVALID_SET_FILE_POINTER = -1 Global Const $FILE_BEGIN = 0 Global Const $FILE_CURRENT = 1 Global Const $FILE_END = 2 Global Const $FILE_ATTRIBUTE_READONLY = 0x00000001 Global Const $FILE_ATTRIBUTE_HIDDEN = 0x00000002 Global Const $FILE_ATTRIBUTE_SYSTEM = 0x00000004 Global Const $FILE_ATTRIBUTE_DIRECTORY = 0x00000010 Global Const $FILE_ATTRIBUTE_ARCHIVE = 0x00000020 Global Const $FILE_ATTRIBUTE_DEVICE = 0x00000040 Global Const $FILE_ATTRIBUTE_NORMAL = 0x00000080 Global Const $FILE_ATTRIBUTE_TEMPORARY = 0x00000100 Global Const $FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200 Global Const $FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400 Global Const $FILE_ATTRIBUTE_COMPRESSED = 0x00000800 Global Const $FILE_ATTRIBUTE_OFFLINE = 0x00001000 Global Const $FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000 Global Const $FILE_ATTRIBUTE_ENCRYPTED = 0x00004000 Global Const $FILE_SHARE_READ = 0x00000001 Global Const $FILE_SHARE_WRITE = 0x00000002 Global Const $FILE_SHARE_DELETE = 0x00000004 Global Const $FILE_SHARE_READWRITE = BitOR($FILE_SHARE_READ, $FILE_SHARE_WRITE) Global Const $FILE_SHARE_ANY = BitOR($FILE_SHARE_READ, $FILE_SHARE_WRITE, $FILE_SHARE_DELETE) Global Const $GENERIC_ALL = 0x10000000 Global Const $GENERIC_EXECUTE = 0x20000000 Global Const $GENERIC_WRITE = 0x40000000 Global Const $GENERIC_READ = 0x80000000 Global Const $GENERIC_READWRITE = BitOR($GENERIC_READ, $GENERIC_WRITE) Global Const $FILE_ENCODING_UTF16LE = 32 Global Const $FE_ENTIRE_UTF8 = 1 Global Const $FE_PARTIALFIRST_UTF8 = 2 Global Const $FN_FULLPATH = 0 Global Const $FN_RELATIVEPATH = 1 Global Const $FV_COMMENTS = "Comments" Global Const $FV_COMPANYNAME = "CompanyName" Global Const $FV_FILEDESCRIPTION = "FileDescription" Global Const $FV_FILEVERSION = "FileVersion" Global Const $FV_INTERNALNAME = "InternalName" Global Const $FV_LEGALCOPYRIGHT = "LegalCopyright" Global Const $FV_LEGALTRADEMARKS = "LegalTrademarks" Global Const $FV_ORIGINALFILENAME = "OriginalFilename" Global Const $FV_PRODUCTNAME = "ProductName" Global Const $FV_PRODUCTVERSION = "ProductVersion" Global Const $FV_PRIVATEBUILD = "PrivateBuild" Global Const $FV_SPECIALBUILD = "SpecialBuild" Global Const $FRTA_NOCOUNT = 0 Global Const $FRTA_COUNT = 1 Global Const $FRTA_INTARRAYS = 2 Global Const $FRTA_ENTIRESPLIT = 4 Global Const $FLTA_FILESFOLDERS = 0 Global Const $FLTA_FILES = 1 Global Const $FLTA_FOLDERS = 2 Global Const $FLTAR_FILESFOLDERS = 0 Global Const $FLTAR_FILES = 1 Global Const $FLTAR_FOLDERS = 2 Global Const $FLTAR_NOHIDDEN = 4 Global Const $FLTAR_NOSYSTEM = 8 Global Const $FLTAR_NOLINK = 16 Global Const $FLTAR_NORECUR = 0 Global Const $FLTAR_RECUR = 1 Global Const $FLTAR_NOSORT = 0 Global Const $FLTAR_SORT = 1 Global Const $FLTAR_FASTSORT = 2 Global Const $FLTAR_NOPATH = 0 Global Const $FLTAR_RELPATH = 1 Global Const $FLTAR_FULLPATH = 2 Global Const $PATH_ORIGINAL = 0 Global Const $PATH_DRIVE = 1 Global Const $PATH_DIRECTORY = 2 Global Const $PATH_FILENAME = 3 Global Const $PATH_EXTENSION = 4 Func _FileCountLines($sFilePath) FileReadToArray($sFilePath) If @error Then Return SetError(@error, @extended, 0) Return @extended EndFunc Func _FileCreate($sFilePath) Local $hFileOpen = FileOpen($sFilePath, BitOR($FO_OVERWRITE, $FO_CREATEPATH)) If $hFileOpen = -1 Then Return SetError(1, 0, 0) Local $iFileWrite = FileWrite($hFileOpen, "") FileClose($hFileOpen) If Not $iFileWrite Then Return SetError(2, 0, 0) Return 1 EndFunc Func _FileListToArray($sFilePath, $sFilter = "*", $iFlag = $FLTA_FILESFOLDERS, $bReturnPath = False) Local $sDelimiter = "|", $sFileList = "", $sFileName = "", $sFullPath = "" $sFilePath = StringRegExpReplace($sFilePath, "[\\/]+$", "") & "\" If $iFlag = Default Then $iFlag = $FLTA_FILESFOLDERS If $bReturnPath Then $sFullPath = $sFilePath If $sFilter = Default Then $sFilter = "*" If Not FileExists($sFilePath) Then Return SetError(1, 0, 0) If StringRegExp($sFilter, "[\\/:><\|]|(?s)^\s*$") Then Return SetError(2, 0, 0) If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 0, 0) Local $hSearch = FileFindFirstFile($sFilePath & $sFilter) If @error Then Return SetError(4, 0, 0) While 1 $sFileName = FileFindNextFile($hSearch) If @error Then ExitLoop If ($iFlag + @extended = 2) Then ContinueLoop $sFileList &= $sDelimiter & $sFullPath & $sFileName WEnd FileClose($hSearch) If $sFileList = "" Then Return SetError(4, 0, 0) Return StringSplit(StringTrimLeft($sFileList, 1), $sDelimiter) EndFunc Func _FileListToArrayRec($sFilePath, $sMask = "*", $iReturn = $FLTAR_FILESFOLDERS, $iRecur = $FLTAR_NORECUR, $iSort = $FLTAR_NOSORT, $iReturnPath = $FLTAR_RELPATH) If Not FileExists($sFilePath) Then Return SetError(1, 1, "") If $sMask = Default Then $sMask = "*" If $iReturn = Default Then $iReturn = $FLTAR_FILESFOLDERS If $iRecur = Default Then $iRecur = $FLTAR_NORECUR If $iSort = Default Then $iSort = $FLTAR_NOSORT If $iReturnPath = Default Then $iReturnPath = $FLTAR_RELPATH If $iRecur > 1 Or Not IsInt($iRecur) Then Return SetError(1, 6, "") Local $bLongPath = False If StringLeft($sFilePath, 4) == "\\?\" Then $bLongPath = True EndIf Local $sFolderSlash = "" If StringRight($sFilePath, 1) = "\" Then $sFolderSlash = "\" Else $sFilePath = $sFilePath & "\" EndIf Local $asFolderSearchList[100] = [1] $asFolderSearchList[1] = $sFilePath Local $iHide_HS = 0, $sHide_HS = "" If BitAND($iReturn, $FLTAR_NOHIDDEN) Then $iHide_HS += 2 $sHide_HS &= "H" $iReturn -= $FLTAR_NOHIDDEN EndIf If BitAND($iReturn, $FLTAR_NOSYSTEM) Then $iHide_HS += 4 $sHide_HS &= "S" $iReturn -= $FLTAR_NOSYSTEM EndIf Local $iHide_Link = 0 If BitAND($iReturn, $FLTAR_NOLINK) Then $iHide_Link = 0x400 $iReturn -= $FLTAR_NOLINK EndIf Local $iMaxLevel = 0 If $iRecur < 0 Then StringReplace($sFilePath, "\", "", 0, $STR_NOCASESENSEBASIC) $iMaxLevel = @extended - $iRecur EndIf Local $sExclude_List = "", $sExclude_List_Folder = "", $sInclude_List = "*" Local $aMaskSplit = StringSplit($sMask, "|") Switch $aMaskSplit[0] Case 3 $sExclude_List_Folder = $aMaskSplit[3] ContinueCase Case 2 $sExclude_List = $aMaskSplit[2] ContinueCase Case 1 $sInclude_List = $aMaskSplit[1] EndSwitch Local $sInclude_File_Mask = ".+" If $sInclude_List <> "*" Then If Not __FLTAR_ListToMask($sInclude_File_Mask, $sInclude_List) Then Return SetError(1, 2, "") EndIf Local $sInclude_Folder_Mask = ".+" Switch $iReturn Case 0 Switch $iRecur Case 0 $sInclude_Folder_Mask = $sInclude_File_Mask EndSwitch Case 2 $sInclude_Folder_Mask = $sInclude_File_Mask EndSwitch Local $sExclude_File_Mask = ":" If $sExclude_List <> "" Then If Not __FLTAR_ListToMask($sExclude_File_Mask, $sExclude_List) Then Return SetError(1, 3, "") EndIf Local $sExclude_Folder_Mask = ":" If $iRecur Then If $sExclude_List_Folder Then If Not __FLTAR_ListToMask($sExclude_Folder_Mask, $sExclude_List_Folder) Then Return SetError(1, 4, "") EndIf If $iReturn = 2 Then $sExclude_Folder_Mask = $sExclude_File_Mask EndIf Else $sExclude_Folder_Mask = $sExclude_File_Mask EndIf If Not ($iReturn = 0 Or $iReturn = 1 Or $iReturn = 2) Then Return SetError(1, 5, "") If Not ($iSort = 0 Or $iSort = 1 Or $iSort = 2) Then Return SetError(1, 7, "") If Not ($iReturnPath = 0 Or $iReturnPath = 1 Or $iReturnPath = 2) Then Return SetError(1, 8, "") If $iHide_Link Then Local $tFile_Data = DllStructCreate("struct;align 4;dword FileAttributes;uint64 CreationTime;uint64 LastAccessTime;uint64 LastWriteTime;" & "dword FileSizeHigh;dword FileSizeLow;dword Reserved0;dword Reserved1;wchar FileName[260];wchar AlternateFileName[14];endstruct") Local $hDLL = DllOpen('kernel32.dll'), $aDLL_Ret EndIf Local $asReturnList[100] = [0] Local $asFileMatchList = $asReturnList, $asRootFileMatchList = $asReturnList, $asFolderMatchList = $asReturnList Local $bFolder = False, $hSearch = 0, $sCurrentPath = "", $sName = "", $sRetPath = "" Local $iAttribs = 0, $sAttribs = '' Local $asFolderFileSectionList[100][2] = [[0, 0]] While $asFolderSearchList[0] > 0 $sCurrentPath = $asFolderSearchList[$asFolderSearchList[0]] $asFolderSearchList[0] -= 1 Switch $iReturnPath Case 1 $sRetPath = StringReplace($sCurrentPath, $sFilePath, "") Case 2 If $bLongPath Then $sRetPath = StringTrimLeft($sCurrentPath, 4) Else $sRetPath = $sCurrentPath EndIf EndSwitch If $iHide_Link Then $aDLL_Ret = DllCall($hDLL, 'handle', 'FindFirstFileW', 'wstr', $sCurrentPath & "*", 'struct*', $tFile_Data) If @error Or Not $aDLL_Ret[0] Then ContinueLoop EndIf $hSearch = $aDLL_Ret[0] Else $hSearch = FileFindFirstFile($sCurrentPath & "*") If $hSearch = -1 Then ContinueLoop EndIf EndIf If $iReturn = 0 And $iSort And $iReturnPath Then __FLTAR_AddToList($asFolderFileSectionList, $sRetPath, $asFileMatchList[0] + 1) EndIf $sAttribs = '' While 1 If $iHide_Link Then $aDLL_Ret = DllCall($hDLL, 'int', 'FindNextFileW', 'handle', $hSearch, 'struct*', $tFile_Data) If @error Or Not $aDLL_Ret[0] Then ExitLoop EndIf $sName = DllStructGetData($tFile_Data, "FileName") If $sName = ".." Then ContinueLoop EndIf $iAttribs = DllStructGetData($tFile_Data, "FileAttributes") If $iHide_HS And BitAND($iAttribs, $iHide_HS) Then ContinueLoop EndIf If BitAND($iAttribs, $iHide_Link) Then ContinueLoop EndIf $bFolder = False If BitAND($iAttribs, 16) Then $bFolder = True EndIf Else $bFolder = False $sName = FileFindNextFile($hSearch, 1) If @error Then ExitLoop EndIf $sAttribs = @extended If StringInStr($sAttribs, "D") Then $bFolder = True EndIf If StringRegExp($sAttribs, "[" & $sHide_HS & "]") Then ContinueLoop EndIf EndIf If $bFolder Then Select Case $iRecur < 0 StringReplace($sCurrentPath, "\", "", 0, $STR_NOCASESENSEBASIC) If @extended < $iMaxLevel Then ContinueCase EndIf Case $iRecur = 1 If Not StringRegExp($sName, $sExclude_Folder_Mask) Then __FLTAR_AddToList($asFolderSearchList, $sCurrentPath & $sName & "\") EndIf EndSelect EndIf If $iSort Then If $bFolder Then If StringRegExp($sName, $sInclude_Folder_Mask) And Not StringRegExp($sName, $sExclude_Folder_Mask) Then __FLTAR_AddToList($asFolderMatchList, $sRetPath & $sName & $sFolderSlash) EndIf Else If StringRegExp($sName, $sInclude_File_Mask) And Not StringRegExp($sName, $sExclude_File_Mask) Then If $sCurrentPath = $sFilePath Then __FLTAR_AddToList($asRootFileMatchList, $sRetPath & $sName) Else __FLTAR_AddToList($asFileMatchList, $sRetPath & $sName) EndIf EndIf EndIf Else If $bFolder Then If $iReturn <> 1 And StringRegExp($sName, $sInclude_Folder_Mask) And Not StringRegExp($sName, $sExclude_Folder_Mask) Then __FLTAR_AddToList($asReturnList, $sRetPath & $sName & $sFolderSlash) EndIf Else If $iReturn <> 2 And StringRegExp($sName, $sInclude_File_Mask) And Not StringRegExp($sName, $sExclude_File_Mask) Then __FLTAR_AddToList($asReturnList, $sRetPath & $sName) EndIf EndIf EndIf WEnd If $iHide_Link Then DllCall($hDLL, 'int', 'FindClose', 'ptr', $hSearch) Else FileClose($hSearch) EndIf WEnd If $iHide_Link Then DllClose($hDLL) EndIf If $iSort Then Switch $iReturn Case 2 If $asFolderMatchList[0] = 0 Then Return SetError(1, 9, "") ReDim $asFolderMatchList[$asFolderMatchList[0] + 1] $asReturnList = $asFolderMatchList __ArrayDualPivotSort($asReturnList, 1, $asReturnList[0]) Case 1 If $asRootFileMatchList[0] = 0 And $asFileMatchList[0] = 0 Then Return SetError(1, 9, "") If $iReturnPath = 0 Then __FLTAR_AddFileLists($asReturnList, $asRootFileMatchList, $asFileMatchList) __ArrayDualPivotSort($asReturnList, 1, $asReturnList[0]) Else __FLTAR_AddFileLists($asReturnList, $asRootFileMatchList, $asFileMatchList, 1) EndIf Case 0 If $asRootFileMatchList[0] = 0 And $asFolderMatchList[0] = 0 Then Return SetError(1, 9, "") If $iReturnPath = 0 Then __FLTAR_AddFileLists($asReturnList, $asRootFileMatchList, $asFileMatchList) $asReturnList[0] += $asFolderMatchList[0] ReDim $asFolderMatchList[$asFolderMatchList[0] + 1] _ArrayConcatenate($asReturnList, $asFolderMatchList, 1) __ArrayDualPivotSort($asReturnList, 1, $asReturnList[0]) Else Local $asReturnList[$asFileMatchList[0] + $asRootFileMatchList[0] + $asFolderMatchList[0] + 1] $asReturnList[0] = $asFileMatchList[0] + $asRootFileMatchList[0] + $asFolderMatchList[0] __ArrayDualPivotSort($asRootFileMatchList, 1, $asRootFileMatchList[0]) For $i = 1 To $asRootFileMatchList[0] $asReturnList[$i] = $asRootFileMatchList[$i] Next Local $iNextInsertionIndex = $asRootFileMatchList[0] + 1 __ArrayDualPivotSort($asFolderMatchList, 1, $asFolderMatchList[0]) Local $sFolderToFind = "" For $i = 1 To $asFolderMatchList[0] $asReturnList[$iNextInsertionIndex] = $asFolderMatchList[$i] $iNextInsertionIndex += 1 If $sFolderSlash Then $sFolderToFind = $asFolderMatchList[$i] Else $sFolderToFind = $asFolderMatchList[$i] & "\" EndIf Local $iFileSectionEndIndex = 0, $iFileSectionStartIndex = 0 For $j = 1 To $asFolderFileSectionList[0][0] If $sFolderToFind = $asFolderFileSectionList[$j][0] Then $iFileSectionStartIndex = $asFolderFileSectionList[$j][1] If $j = $asFolderFileSectionList[0][0] Then $iFileSectionEndIndex = $asFileMatchList[0] Else $iFileSectionEndIndex = $asFolderFileSectionList[$j + 1][1] - 1 EndIf If $iSort = 1 Then __ArrayDualPivotSort($asFileMatchList, $iFileSectionStartIndex, $iFileSectionEndIndex) EndIf For $k = $iFileSectionStartIndex To $iFileSectionEndIndex $asReturnList[$iNextInsertionIndex] = $asFileMatchList[$k] $iNextInsertionIndex += 1 Next ExitLoop EndIf Next Next EndIf EndSwitch Else If $asReturnList[0] = 0 Then Return SetError(1, 9, "") ReDim $asReturnList[$asReturnList[0] + 1] EndIf Return $asReturnList EndFunc Func __FLTAR_AddFileLists(ByRef $asTarget, $asSource_1, $asSource_2, $iSort = 0) ReDim $asSource_1[$asSource_1[0] + 1] If $iSort = 1 Then __ArrayDualPivotSort($asSource_1, 1, $asSource_1[0]) $asTarget = $asSource_1 $asTarget[0] += $asSource_2[0] ReDim $asSource_2[$asSource_2[0] + 1] If $iSort = 1 Then __ArrayDualPivotSort($asSource_2, 1, $asSource_2[0]) _ArrayConcatenate($asTarget, $asSource_2, 1) EndFunc Func __FLTAR_AddToList(ByRef $aList, $vValue_0, $vValue_1 = -1) If $vValue_1 = -1 Then $aList[0] += 1 If UBound($aList) <= $aList[0] Then ReDim $aList[UBound($aList) * 2] $aList[$aList[0]] = $vValue_0 Else $aList[0][0] += 1 If UBound($aList) <= $aList[0][0] Then ReDim $aList[UBound($aList) * 2][2] $aList[$aList[0][0]][0] = $vValue_0 $aList[$aList[0][0]][1] = $vValue_1 EndIf EndFunc Func __FLTAR_ListToMask(ByRef $sMask, $sList) If StringRegExp($sList, "\\|/|:|\<|\>|\|") Then Return 0 $sList = StringReplace(StringStripWS(StringRegExpReplace($sList, "\s*;\s*", ";"), BitOR($STR_STRIPLEADING, $STR_STRIPTRAILING)), ";", "|") $sList = StringReplace(StringReplace(StringRegExpReplace($sList, "[][$^.{}()+\-]", "\\$0"), "?", "."), "*", ".*?") $sMask = "(?i)^(" & $sList & ")\z" Return 1 EndFunc Func _FilePrint($sFilePath, $iShow = @SW_HIDE) Return ShellExecute($sFilePath, "", @WorkingDir, "print", $iShow = Default ? @SW_HIDE : $iShow) EndFunc Func _FileReadToArray($sFilePath, ByRef $vReturn, $iFlags = $FRTA_COUNT, $sDelimiter = "") $vReturn = 0 If $iFlags = Default Then $iFlags = $FRTA_COUNT If $sDelimiter = Default Then $sDelimiter = "" Local $bExpand = True If BitAND($iFlags, $FRTA_INTARRAYS) Then $bExpand = False $iFlags -= $FRTA_INTARRAYS EndIf Local $iEntire = $STR_CHRSPLIT If BitAND($iFlags, $FRTA_ENTIRESPLIT) Then $iEntire = $STR_ENTIRESPLIT $iFlags -= $FRTA_ENTIRESPLIT EndIf Local $iNoCount = 0 If $iFlags <> $FRTA_COUNT Then $iFlags = $FRTA_NOCOUNT $iNoCount = $STR_NOCOUNT EndIf If $sDelimiter Then Local $aLines = FileReadToArray($sFilePath) If @error Then Return SetError(@error, 0, 0) Local $iDim_1 = UBound($aLines) + $iFlags If $bExpand Then Local $iDim_2 = UBound(StringSplit($aLines[0], $sDelimiter, $iEntire + $STR_NOCOUNT)) Local $aTemp_Array[$iDim_1][$iDim_2] Local $iFields, $aSplit For $i = 0 To $iDim_1 - $iFlags - 1 $aSplit = StringSplit($aLines[$i], $sDelimiter, $iEntire + $STR_NOCOUNT) $iFields = UBound($aSplit) If $iFields <> $iDim_2 Then Return SetError(3, 0, 0) EndIf For $j = 0 To $iFields - 1 $aTemp_Array[$i + $iFlags][$j] = $aSplit[$j] Next Next If $iDim_2 < 2 Then Return SetError(4, 0, 0) If $iFlags Then $aTemp_Array[0][0] = $iDim_1 - $iFlags $aTemp_Array[0][1] = $iDim_2 EndIf Else Local $aTemp_Array[$iDim_1] For $i = 0 To $iDim_1 - $iFlags - 1 $aTemp_Array[$i + $iFlags] = StringSplit($aLines[$i], $sDelimiter, $iEntire + $iNoCount) Next If $iFlags Then $aTemp_Array[0] = $iDim_1 - $iFlags EndIf EndIf $vReturn = $aTemp_Array Else If $iFlags Then Local $hFileOpen = FileOpen($sFilePath, $FO_READ) If $hFileOpen = -1 Then Return SetError(1, 0, 0) Local $sFileRead = FileRead($hFileOpen) FileClose($hFileOpen) If StringLen($sFileRead) Then $vReturn = StringRegExp(@LF & $sFileRead, "(?|(\N+)\z|(\N*)(?:\R))", $STR_REGEXPARRAYGLOBALMATCH) $vReturn[0] = UBound($vReturn) - 1 Else Return SetError(2, 0, 0) EndIf Else $vReturn = FileReadToArray($sFilePath) If @error Then $vReturn = 0 Return SetError(@error, 0, 0) EndIf EndIf EndIf Return 1 EndFunc Func _FileWriteFromArray($sFilePath, Const ByRef $aArray, $iBase = Default, $iUBound = Default, $sDelimiter = "|") Local $iReturn = 0 If Not IsArray($aArray) Then Return SetError(2, 0, $iReturn) Local $iDims = UBound($aArray, $UBOUND_DIMENSIONS) If $iDims > 2 Then Return SetError(4, 0, 0) Local $iLast = UBound($aArray) - 1 If $iUBound = Default Or $iUBound > $iLast Then $iUBound = $iLast If $iBase < 0 Or $iBase = Default Then $iBase = 0 If $iBase > $iUBound Then Return SetError(5, 0, $iReturn) If $sDelimiter = Default Then $sDelimiter = "|" Local $hFileOpen = $sFilePath If IsString($sFilePath) Then $hFileOpen = FileOpen($sFilePath, $FO_OVERWRITE) If $hFileOpen = -1 Then Return SetError(1, 0, $iReturn) EndIf Local $iError = 0 $iReturn = 1 Switch $iDims Case 1 For $i = $iBase To $iUBound If Not FileWrite($hFileOpen, $aArray[$i] & @CRLF) Then $iError = 3 $iReturn = 0 ExitLoop EndIf Next Case 2 Local $sTemp = "" For $i = $iBase To $iUBound $sTemp = $aArray[$i][0] For $j = 1 To UBound($aArray, $UBOUND_COLUMNS) - 1 $sTemp &= $sDelimiter & $aArray[$i][$j] Next If Not FileWrite($hFileOpen, $sTemp & @CRLF) Then $iError = 3 $iReturn = 0 ExitLoop EndIf Next EndSwitch If IsString($sFilePath) Then FileClose($hFileOpen) Return SetError($iError, 0, $iReturn) EndFunc Func _FileWriteLog($sLogPath, $sLogMsg, $iFlag = -1) Local $iOpenMode = $FO_APPEND Local $sMsg = @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " : " & $sLogMsg If $iFlag = Default Then $iFlag = -1 If $iFlag <> -1 Then $iOpenMode = $FO_OVERWRITE $sMsg &= @CRLF & FileRead($sLogPath) EndIf Local $hFileOpen = $sLogPath If IsString($sLogPath) Then $hFileOpen = FileOpen($sLogPath, $iOpenMode) If $hFileOpen = -1 Then Return SetError(1, 0, 0) Local $iReturn = FileWriteLine($hFileOpen, $sMsg) If IsString($sLogPath) Then $iReturn = FileClose($hFileOpen) If $iReturn <= 0 Then Return SetError(2, $iReturn, 0) Return $iReturn EndFunc Func _FileWriteToLine($sFilePath, $iLine, $sText, $bOverWrite = False, $bFill = False) If $bOverWrite = Default Then $bOverWrite = False If $bFill = Default Then $bFill = False If Not FileExists($sFilePath) Then Return SetError(2, 0, 0) If $iLine <= 0 Then Return SetError(4, 0, 0) If Not (IsBool($bOverWrite) Or $bOverWrite = 0 Or $bOverWrite = 1) Then Return SetError(5, 0, 0) If Not IsString($sText) Then $sText = String($sText) If $sText = "" Then Return SetError(6, 0, 0) EndIf If Not IsBool($bFill) Then Return SetError(7, 0, 0) Local $aArray = FileReadToArray($sFilePath) If @error Then Local $aArray[0] Local $iUBound = UBound($aArray) - 1 If $bFill Then If $iUBound < $iLine Then ReDim $aArray[$iLine] $iUBound = $iLine - 1 EndIf Else If ($iUBound + 1) < $iLine Then Return SetError(1, 0, 0) EndIf $aArray[$iLine - 1] = ($bOverWrite ? $sText : $sText & @CRLF & $aArray[$iLine - 1]) Local $sData = "" For $i = 0 To $iUBound $sData &= $aArray[$i] & @CRLF Next $sData = StringTrimRight($sData, StringLen(@CRLF)) Local $hFileOpen = FileOpen($sFilePath, FileGetEncoding($sFilePath) + $FO_OVERWRITE) If $hFileOpen = -1 Then Return SetError(3, 0, 0) FileWrite($hFileOpen, $sData) FileClose($hFileOpen) Return 1 EndFunc Func _PathFull($sRelativePath, $sBasePath = @WorkingDir) If Not $sRelativePath Or $sRelativePath = "." Then Return $sBasePath Local $sFullPath = StringReplace($sRelativePath, "/", "\") Local Const $sFullPathConst = $sFullPath Local $sPath Local $bRootOnly = StringLeft($sFullPath, 1) = "\" And StringMid($sFullPath, 2, 1) <> "\" If $sBasePath = Default Then $sBasePath = @WorkingDir For $i = 1 To 2 $sPath = StringLeft($sFullPath, 2) If $sPath = "\\" Then $sFullPath = StringTrimLeft($sFullPath, 2) Local $nServerLen = StringInStr($sFullPath, "\") - 1 $sPath = "\\" & StringLeft($sFullPath, $nServerLen) $sFullPath = StringTrimLeft($sFullPath, $nServerLen) ExitLoop ElseIf StringRight($sPath, 1) = ":" Then $sFullPath = StringTrimLeft($sFullPath, 2) ExitLoop Else $sFullPath = $sBasePath & "\" & $sFullPath EndIf Next If StringLeft($sFullPath, 1) <> "\" Then If StringLeft($sFullPathConst, 2) = StringLeft($sBasePath, 2) Then $sFullPath = $sBasePath & "\" & $sFullPath Else $sFullPath = "\" & $sFullPath EndIf EndIf Local $aTemp = StringSplit($sFullPath, "\") Local $aPathParts[$aTemp[0]], $j = 0 For $i = 2 To $aTemp[0] If $aTemp[$i] = ".." Then If $j Then $j -= 1 ElseIf Not ($aTemp[$i] = "" And $i <> $aTemp[0]) And $aTemp[$i] <> "." Then $aPathParts[$j] = $aTemp[$i] $j += 1 EndIf Next $sFullPath = $sPath If Not $bRootOnly Then For $i = 0 To $j - 1 $sFullPath &= "\" & $aPathParts[$i] Next Else $sFullPath &= $sFullPathConst If StringInStr($sFullPath, "..") Then $sFullPath = _PathFull($sFullPath) EndIf Do $sFullPath = StringReplace($sFullPath, ".\", "\") Until @extended = 0 Return $sFullPath EndFunc Func _PathGetRelative($sFrom, $sTo) If StringRight($sFrom, 1) <> "\" Then $sFrom &= "\" If StringRight($sTo, 1) <> "\" Then $sTo &= "\" If $sFrom = $sTo Then Return SetError(1, 0, StringTrimRight($sTo, 1)) Local $asFrom = StringSplit($sFrom, "\") Local $asTo = StringSplit($sTo, "\") If $asFrom[1] <> $asTo[1] Then Return SetError(2, 0, StringTrimRight($sTo, 1)) Local $i = 2 Local $iDiff = 1 While 1 If $asFrom[$i] <> $asTo[$i] Then $iDiff = $i ExitLoop EndIf $i += 1 WEnd $i = 1 Local $sRelPath = "" For $j = 1 To $asTo[0] If $i >= $iDiff Then $sRelPath &= "\" & $asTo[$i] EndIf $i += 1 Next $sRelPath = StringTrimLeft($sRelPath, 1) $i = 1 For $j = 1 To $asFrom[0] If $i > $iDiff Then $sRelPath = "..\" & $sRelPath EndIf $i += 1 Next If StringRight($sRelPath, 1) == "\" Then $sRelPath = StringTrimRight($sRelPath, 1) Return $sRelPath EndFunc Func _PathMake($sDrive, $sDir, $sFileName, $sExtension) If StringLen($sDrive) Then If Not (StringLeft($sDrive, 2) = "\\") Then $sDrive = StringLeft($sDrive, 1) & ":" EndIf If StringLen($sDir) Then If Not (StringRight($sDir, 1) = "\") And Not (StringRight($sDir, 1) = "/") Then $sDir = $sDir & "\" Else $sDir = "\" EndIf If StringLen($sDir) Then If Not (StringLeft($sDir, 1) = "\") And Not (StringLeft($sDir, 1) = "/") Then $sDir = "\" & $sDir EndIf If StringLen($sExtension) Then If Not (StringLeft($sExtension, 1) = ".") Then $sExtension = "." & $sExtension EndIf Return $sDrive & $sDir & $sFileName & $sExtension EndFunc Func _PathSplit($sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sFileName, ByRef $sExtension) Local $aArray = StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", $STR_REGEXPARRAYMATCH) If @error Then ReDim $aArray[5] $aArray[$PATH_ORIGINAL] = $sFilePath EndIf $sDrive = $aArray[$PATH_DRIVE] If StringLeft($aArray[$PATH_DIRECTORY], 1) == "/" Then $sDir = StringRegExpReplace($aArray[$PATH_DIRECTORY], "\h*[\/\\]+\h*", "\/") Else $sDir = StringRegExpReplace($aArray[$PATH_DIRECTORY], "\h*[\/\\]+\h*", "\\") EndIf $aArray[$PATH_DIRECTORY] = $sDir $sFileName = $aArray[$PATH_FILENAME] $sExtension = $aArray[$PATH_EXTENSION] Return $aArray EndFunc Func _ReplaceStringInFile($sFilePath, $sSearchString, $sReplaceString, $iCaseSensitive = 0, $iOccurance = 1) If StringInStr(FileGetAttrib($sFilePath), "R") Then Return SetError(1, 0, -1) Local $hFileOpen = FileOpen($sFilePath, $FO_READ) If $hFileOpen = -1 Then Return SetError(2, 0, -1) Local $sFileRead = FileRead($hFileOpen) FileClose($hFileOpen) If $iCaseSensitive = Default Then $iCaseSensitive = 0 If $iOccurance = Default Then $iOccurance = 1 $sFileRead = StringReplace($sFileRead, $sSearchString, $sReplaceString, 1 - $iOccurance, $iCaseSensitive) Local $iReturn = @extended If $iReturn Then Local $iFileEncoding = FileGetEncoding($sFilePath) $hFileOpen = FileOpen($sFilePath, $iFileEncoding + $FO_OVERWRITE) If $hFileOpen = -1 Then Return SetError(3, 0, -1) FileWrite($hFileOpen, $sFileRead) FileClose($hFileOpen) EndIf Return $iReturn EndFunc Func _TempFile($sDirectoryName = @TempDir, $sFilePrefix = "~", $sFileExtension = ".tmp", $iRandomLength = 7) If $iRandomLength = Default Or $iRandomLength <= 0 Then $iRandomLength = 7 If $sDirectoryName = Default Or (Not FileExists($sDirectoryName)) Then $sDirectoryName = @TempDir If $sFileExtension = Default Then $sFileExtension = ".tmp" If $sFilePrefix = Default Then $sFilePrefix = "~" If Not FileExists($sDirectoryName) Then $sDirectoryName = @ScriptDir $sDirectoryName = StringRegExpReplace($sDirectoryName, "[\\/]+$", "") $sFileExtension = StringRegExpReplace($sFileExtension, "^\.+", "") $sFilePrefix = StringRegExpReplace($sFilePrefix, '[\\/:*?"<>|]', "") Local $sTempName = "" Do $sTempName = "" While StringLen($sTempName) < $iRandomLength $sTempName &= Chr(Random(97, 122, 1)) WEnd $sTempName = $sDirectoryName & "\" & $sFilePrefix & $sTempName & "." & $sFileExtension Until Not FileExists($sTempName) Return $sTempName EndFunc Global Const $DTS_SHORTDATEFORMAT = 0 Global Const $DTS_UPDOWN = 1 Global Const $DTS_SHOWNONE = 2 Global Const $DTS_LONGDATEFORMAT = 4 Global Const $DTS_TIMEFORMAT = 9 Global Const $DTS_RIGHTALIGN = 32 Global Const $DTS_SHORTDATECENTURYFORMAT = 0x0000000C Global Const $DTS_APPCANPARSE = 0x00000010 Global Const $DMW_LONGNAME = 0 Global Const $DMW_SHORTNAME = 1 Global Const $DMW_LOCALE_LONGNAME = 2 Global Const $DMW_LOCALE_SHORTNAME = 3 Global Const $GDT_ERROR = -1 Global Const $GDT_VALID = 0 Global Const $GDT_NONE = 1 Global Const $GDTR_MIN = 0x0001 Global Const $GDTR_MAX = 0x0002 Global Const $MCHT_NOWHERE = 0x00000000 Global Const $MCHT_TITLE = 0x00010000 Global Const $MCHT_CALENDAR = 0x00020000 Global Const $MCHT_TODAYLINK = 0x00030000 Global Const $MCHT_NEXT = 0x01000000 Global Const $MCHT_PREV = 0x02000000 Global Const $MCHT_TITLEBK = 0x00010000 Global Const $MCHT_TITLEMONTH = 0x00010001 Global Const $MCHT_TITLEYEAR = 0x00010002 Global Const $MCHT_TITLEBTNNEXT = 0x01010003 Global Const $MCHT_TITLEBTNPREV = 0x02010003 Global Const $MCHT_CALENDARBK = 0x00020000 Global Const $MCHT_CALENDARDATE = 0x00020001 Global Const $MCHT_CALENDARDAY = 0x00020002 Global Const $MCHT_CALENDARWEEKNUM = 0x00020003 Global Const $MCHT_CALENDARDATENEXT = 0x01020000 Global Const $MCHT_CALENDARDATEPREV = 0x02020000 Global Const $MCS_DAYSTATE = 0x0001 Global Const $MCS_MULTISELECT = 0x0002 Global Const $MCS_WEEKNUMBERS = 0x0004 Global Const $MCS_NOTODAYCIRCLE = 0x0008 Global Const $MCS_NOTODAY = 0x0010 Global Const $MCS_NOTRAILINGDATES = 0x0040 Global Const $MCS_SHORTDAYSOFWEEK = 0x0080 Global Const $MCS_NOSELCHANGEONNAV = 0x0100 Global Const $MCM_FIRST = 0x1000 Global Const $MCM_GETCALENDARBORDER = ($MCM_FIRST + 31) Global Const $MCM_GETCALENDARCOUNT = ($MCM_FIRST + 23) Global Const $MCM_GETCALENDARGRIDINFO = ($MCM_FIRST + 24) Global Const $MCM_GETCALID = ($MCM_FIRST + 27) Global Const $MCM_GETCOLOR = ($MCM_FIRST + 11) Global Const $MCM_GETCURRENTVIEW = ($MCM_FIRST + 22) Global Const $MCM_GETCURSEL = ($MCM_FIRST + 1) Global Const $MCM_GETFIRSTDAYOFWEEK = ($MCM_FIRST + 16) Global Const $MCM_GETMAXSELCOUNT = ($MCM_FIRST + 3) Global Const $MCM_GETMAXTODAYWIDTH = ($MCM_FIRST + 21) Global Const $MCM_GETMINREQRECT = ($MCM_FIRST + 9) Global Const $MCM_GETMONTHDELTA = ($MCM_FIRST + 19) Global Const $MCM_GETMONTHRANGE = ($MCM_FIRST + 7) Global Const $MCM_GETRANGE = ($MCM_FIRST + 17) Global Const $MCM_GETSELRANGE = ($MCM_FIRST + 5) Global Const $MCM_GETTODAY = ($MCM_FIRST + 13) Global Const $MCM_GETUNICODEFORMAT = 0x2000 + 6 Global Const $MCM_HITTEST = ($MCM_FIRST + 14) Global Const $MCM_SETCALENDARBORDER = ($MCM_FIRST + 30) Global Const $MCM_SETCALID = ($MCM_FIRST + 28) Global Const $MCM_SETCOLOR = ($MCM_FIRST + 10) Global Const $MCM_SETCURRENTVIEW = ($MCM_FIRST + 32) Global Const $MCM_SETCURSEL = ($MCM_FIRST + 2) Global Const $MCM_SETDAYSTATE = ($MCM_FIRST + 8) Global Const $MCM_SETFIRSTDAYOFWEEK = ($MCM_FIRST + 15) Global Const $MCM_SETMAXSELCOUNT = ($MCM_FIRST + 4) Global Const $MCM_SETMONTHDELTA = ($MCM_FIRST + 20) Global Const $MCM_SETRANGE = ($MCM_FIRST + 18) Global Const $MCM_SETSELRANGE = ($MCM_FIRST + 6) Global Const $MCM_SETTODAY = ($MCM_FIRST + 12) Global Const $MCM_SETUNICODEFORMAT = 0x2000 + 5 Global Const $MCM_SIZERECTTOMIN = ($MCM_FIRST + 29) Global Const $MCN_FIRST = -746 Global Const $MCN_SELCHANGE = ($MCN_FIRST - 3) Global Const $MCN_GETDAYSTATE = ($MCN_FIRST - 1) Global Const $MCN_SELECT = ($MCN_FIRST) Global Const $MCN_VIEWCHANGE = ($MCN_FIRST - 4) Global Const $MCSC_BACKGROUND = 0 Global Const $MCSC_MONTHBK = 4 Global Const $MCSC_TEXT = 1 Global Const $MCSC_TITLEBK = 2 Global Const $MCSC_TITLETEXT = 3 Global Const $MCSC_TRAILINGTEXT = 5 Global Const $DTM_FIRST = 0x1000 Global Const $DTM_GETSYSTEMTIME = $DTM_FIRST + 1 Global Const $DTM_SETSYSTEMTIME = $DTM_FIRST + 2 Global Const $DTM_GETRANGE = $DTM_FIRST + 3 Global Const $DTM_SETRANGE = $DTM_FIRST + 4 Global Const $DTM_SETFORMAT = $DTM_FIRST + 5 Global Const $DTM_SETMCCOLOR = $DTM_FIRST + 6 Global Const $DTM_GETMCCOLOR = $DTM_FIRST + 7 Global Const $DTM_GETMONTHCAL = $DTM_FIRST + 8 Global Const $DTM_SETMCFONT = $DTM_FIRST + 9 Global Const $DTM_GETMCFONT = $DTM_FIRST + 10 Global Const $DTM_SETFORMATW = $DTM_FIRST + 50 Global Const $DTN_FIRST = -740 Global Const $DTN_FIRST2 = -753 Global Const $DTN_DATETIMECHANGE = $DTN_FIRST2 - 6 Global Const $DTN_USERSTRING = $DTN_FIRST2 - 5 Global Const $DTN_WMKEYDOWN = $DTN_FIRST2 - 4 Global Const $DTN_FORMAT = $DTN_FIRST2 - 3 Global Const $DTN_FORMATQUERY = $DTN_FIRST2 - 2 Global Const $DTN_DROPDOWN = $DTN_FIRST2 - 1 Global Const $DTN_CLOSEUP = $DTN_FIRST2 - 0 Global Const $DTN_USERSTRINGW = $DTN_FIRST - 5 Global Const $DTN_WMKEYDOWNW = $DTN_FIRST - 4 Global Const $DTN_FORMATW = $DTN_FIRST - 3 Global Const $DTN_FORMATQUERYW = $DTN_FIRST - 2 Global Const $GUI_SS_DEFAULT_DATE = $DTS_LONGDATEFORMAT Global Const $GUI_SS_DEFAULT_MONTHCAL = 0 Global Const $GMEM_FIXED = 0x0000 Global Const $GMEM_MOVEABLE = 0x0002 Global Const $GMEM_NOCOMPACT = 0x0010 Global Const $GMEM_NODISCARD = 0x0020 Global Const $GMEM_ZEROINIT = 0x0040 Global Const $GMEM_MODIFY = 0x0080 Global Const $GMEM_DISCARDABLE = 0x0100 Global Const $GMEM_NOT_BANKED = 0x1000 Global Const $GMEM_SHARE = 0x2000 Global Const $GMEM_DDESHARE = 0x2000 Global Const $GMEM_NOTIFY = 0x4000 Global Const $GMEM_LOWER = 0x1000 Global Const $GMEM_VALID_FLAGS = 0x7F72 Global Const $GMEM_INVALID_HANDLE = 0x8000 Global Const $GPTR = BitOR($GMEM_FIXED, $GMEM_ZEROINIT) Global Const $GHND = BitOR($GMEM_MOVEABLE, $GMEM_ZEROINIT) Global Const $MEM_COMMIT = 0x00001000 Global Const $MEM_RESERVE = 0x00002000 Global Const $MEM_TOP_DOWN = 0x00100000 Global Const $MEM_SHARED = 0x08000000 Global Const $PAGE_NOACCESS = 0x00000001 Global Const $PAGE_READONLY = 0x00000002 Global Const $PAGE_READWRITE = 0x00000004 Global Const $PAGE_EXECUTE = 0x00000010 Global Const $PAGE_EXECUTE_READ = 0x00000020 Global Const $PAGE_EXECUTE_READWRITE = 0x00000040 Global Const $PAGE_EXECUTE_WRITECOPY = 0x00000080 Global Const $PAGE_GUARD = 0x00000100 Global Const $PAGE_NOCACHE = 0x00000200 Global Const $PAGE_WRITECOMBINE = 0x00000400 Global Const $PAGE_WRITECOPY = 0x00000008 Global Const $MEM_DECOMMIT = 0x00004000 Global Const $MEM_RELEASE = 0x00008000 Global Enum $MEM_LOAD, $MEM_TOTALPHYSRAM, $MEM_AVAILPHYSRAM, $MEM_TOTALPAGEFILE, $MEM_AVAILPAGEFILE, $MEM_TOTALVIRTUAL, $MEM_AVAILVIRTUAL Global Const $PROCESS_TERMINATE = 0x00000001 Global Const $PROCESS_CREATE_THREAD = 0x00000002 Global Const $PROCESS_SET_SESSIONID = 0x00000004 Global Const $PROCESS_VM_OPERATION = 0x00000008 Global Const $PROCESS_VM_READ = 0x00000010 Global Const $PROCESS_VM_WRITE = 0x00000020 Global Const $PROCESS_DUP_HANDLE = 0x00000040 Global Const $PROCESS_CREATE_PROCESS = 0x00000080 Global Const $PROCESS_SET_QUOTA = 0x00000100 Global Const $PROCESS_SET_INFORMATION = 0x00000200 Global Const $PROCESS_QUERY_INFORMATION = 0x00000400 Global Const $PROCESS_QUERY_LIMITED_INFORMATION = 0x1000 Global Const $PROCESS_SUSPEND_RESUME = 0x00000800 Global Const $PROCESS_ALL_ACCESS = 0x001F0FFF Global Const $SE_ASSIGNPRIMARYTOKEN_NAME = "SeAssignPrimaryTokenPrivilege" Global Const $SE_AUDIT_NAME = "SeAuditPrivilege" Global Const $SE_BACKUP_NAME = "SeBackupPrivilege" Global Const $SE_CHANGE_NOTIFY_NAME = "SeChangeNotifyPrivilege" Global Const $SE_CREATE_GLOBAL_NAME = "SeCreateGlobalPrivilege" Global Const $SE_CREATE_PAGEFILE_NAME = "SeCreatePagefilePrivilege" Global Const $SE_CREATE_PERMANENT_NAME = "SeCreatePermanentPrivilege" Global Const $SE_CREATE_SYMBOLIC_LINK_NAME = 'SeCreateSymbolicLinkPrivilege' Global Const $SE_CREATE_TOKEN_NAME = "SeCreateTokenPrivilege" Global Const $SE_DEBUG_NAME = "SeDebugPrivilege" Global Const $SE_ENABLE_DELEGATION_NAME = "SeEnableDelegationPrivilege" Global Const $SE_IMPERSONATE_NAME = "SeImpersonatePrivilege" Global Const $SE_INC_BASE_PRIORITY_NAME = "SeIncreaseBasePriorityPrivilege" Global Const $SE_INC_WORKING_SET_NAME = 'SeIncreaseWorkingSetPrivilege' Global Const $SE_INCREASE_QUOTA_NAME = "SeIncreaseQuotaPrivilege" Global Const $SE_LOAD_DRIVER_NAME = "SeLoadDriverPrivilege" Global Const $SE_LOCK_MEMORY_NAME = "SeLockMemoryPrivilege" Global Const $SE_MACHINE_ACCOUNT_NAME = "SeMachineAccountPrivilege" Global Const $SE_MANAGE_VOLUME_NAME = "SeManageVolumePrivilege" Global Const $SE_PROF_SINGLE_PROCESS_NAME = "SeProfileSingleProcessPrivilege" Global Const $SE_RELABEL_NAME = 'SeRelabelPrivilege' Global Const $SE_REMOTE_SHUTDOWN_NAME = "SeRemoteShutdownPrivilege" Global Const $SE_RESTORE_NAME = "SeRestorePrivilege" Global Const $SE_SECURITY_NAME = "SeSecurityPrivilege" Global Const $SE_SHUTDOWN_NAME = "SeShutdownPrivilege" Global Const $SE_SYNC_AGENT_NAME = "SeSyncAgentPrivilege" Global Const $SE_SYSTEM_ENVIRONMENT_NAME = "SeSystemEnvironmentPrivilege" Global Const $SE_SYSTEM_PROFILE_NAME = "SeSystemProfilePrivilege" Global Const $SE_SYSTEMTIME_NAME = "SeSystemtimePrivilege" Global Const $SE_TAKE_OWNERSHIP_NAME = "SeTakeOwnershipPrivilege" Global Const $SE_TCB_NAME = "SeTcbPrivilege" Global Const $SE_TIME_ZONE_NAME = 'SeTimeZonePrivilege' Global Const $SE_TRUSTED_CREDMAN_ACCESS_NAME = 'SeTrustedCredManAccessPrivilege' Global Const $SE_UNSOLICITED_INPUT_NAME = "SeUnsolicitedInputPrivilege" Global Const $SE_UNDOCK_NAME = "SeUndockPrivilege" Global Const $SE_PRIVILEGE_ENABLED_BY_DEFAULT = 0x00000001 Global Const $SE_PRIVILEGE_ENABLED = 0x00000002 Global Const $SE_PRIVILEGE_REMOVED = 0x00000004 Global Const $SE_PRIVILEGE_USED_FOR_ACCESS = 0x80000000 Global Const $SE_GROUP_MANDATORY = 0x00000001 Global Const $SE_GROUP_ENABLED_BY_DEFAULT = 0x00000002 Global Const $SE_GROUP_ENABLED = 0x00000004 Global Const $SE_GROUP_OWNER = 0x00000008 Global Const $SE_GROUP_USE_FOR_DENY_ONLY = 0x00000010 Global Const $SE_GROUP_INTEGRITY = 0x00000020 Global Const $SE_GROUP_INTEGRITY_ENABLED = 0x00000040 Global Const $SE_GROUP_RESOURCE = 0x20000000 Global Const $SE_GROUP_LOGON_ID = 0xC0000000 Global Enum $TOKENPRIMARY = 1, $TOKENIMPERSONATION Global Enum $SECURITYANONYMOUS = 0, $SECURITYIDENTIFICATION, $SECURITYIMPERSONATION, $SECURITYDELEGATION Global Enum $TOKENUSER = 1, $TOKENGROUPS, $TOKENPRIVILEGES, $TOKENOWNER, $TOKENPRIMARYGROUP, $TOKENDEFAULTDACL, $TOKENSOURCE, $TOKENTYPE, $TOKENIMPERSONATIONLEVEL, $TOKENSTATISTICS, $TOKENRESTRICTEDSIDS, $TOKENSESSIONID, $TOKENGROUPSANDPRIVILEGES, $TOKENSESSIONREFERENCE, $TOKENSANDBOXINERT, $TOKENAUDITPOLICY, $TOKENORIGIN, $TOKENELEVATIONTYPE, $TOKENLINKEDTOKEN, $TOKENELEVATION, $TOKENHASRESTRICTIONS, $TOKENACCESSINFORMATION, $TOKENVIRTUALIZATIONALLOWED, $TOKENVIRTUALIZATIONENABLED, $TOKENINTEGRITYLEVEL, $TOKENUIACCESS, $TOKENMANDATORYPOLICY, $TOKENLOGONSID Global Const $TOKEN_ASSIGN_PRIMARY = 0x00000001 Global Const $TOKEN_DUPLICATE = 0x00000002 Global Const $TOKEN_IMPERSONATE = 0x00000004 Global Const $TOKEN_QUERY = 0x00000008 Global Const $TOKEN_QUERY_SOURCE = 0x00000010 Global Const $TOKEN_ADJUST_PRIVILEGES = 0x00000020 Global Const $TOKEN_ADJUST_GROUPS = 0x00000040 Global Const $TOKEN_ADJUST_DEFAULT = 0x00000080 Global Const $TOKEN_ADJUST_SESSIONID = 0x00000100 Global Const $TOKEN_ALL_ACCESS = 0x000F01FF Global Const $TOKEN_READ = 0x00020008 Global Const $TOKEN_WRITE = 0x000200E0 Global Const $TOKEN_EXECUTE = 0x00020000 Global Const $TOKEN_HAS_TRAVERSE_PRIVILEGE = 0x00000001 Global Const $TOKEN_HAS_BACKUP_PRIVILEGE = 0x00000002 Global Const $TOKEN_HAS_RESTORE_PRIVILEGE = 0x00000004 Global Const $TOKEN_HAS_ADMIN_GROUP = 0x00000008 Global Const $TOKEN_IS_RESTRICTED = 0x00000010 Global Const $TOKEN_SESSION_NOT_REFERENCED = 0x00000020 Global Const $TOKEN_SANDBOX_INERT = 0x00000040 Global Const $TOKEN_HAS_IMPERSONATE_PRIVILEGE = 0x00000080 Global Const $RIGHTS_DELETE = 0x00010000 Global Const $READ_CONTROL = 0x00020000 Global Const $WRITE_DAC = 0x00040000 Global Const $WRITE_OWNER = 0x00080000 Global Const $SYNCHRONIZE = 0x00100000 Global Const $ACCESS_SYSTEM_SECURITY = 0x01000000 Global Const $STANDARD_RIGHTS_REQUIRED = 0x000f0000 Global Const $STANDARD_RIGHTS_READ = $READ_CONTROL Global Const $STANDARD_RIGHTS_WRITE = $READ_CONTROL Global Const $STANDARD_RIGHTS_EXECUTE = $READ_CONTROL Global Const $STANDARD_RIGHTS_ALL = 0x001F0000 Global Const $SPECIFIC_RIGHTS_ALL = 0x0000FFFF Global Enum $NOT_USED_ACCESS = 0, $GRANT_ACCESS, $SET_ACCESS, $DENY_ACCESS, $REVOKE_ACCESS, $SET_AUDIT_SUCCESS, $SET_AUDIT_FAILURE Global Enum $TRUSTEE_IS_UNKNOWN = 0, $TRUSTEE_IS_USER, $TRUSTEE_IS_GROUP, $TRUSTEE_IS_DOMAIN, $TRUSTEE_IS_ALIAS, $TRUSTEE_IS_WELL_KNOWN_GROUP, $TRUSTEE_IS_DELETED, $TRUSTEE_IS_INVALID, $TRUSTEE_IS_COMPUTER Global Const $LOGON_WITH_PROFILE = 0x00000001 Global Const $LOGON_NETCREDENTIALS_ONLY = 0x00000002 Global Enum $SIDTYPEUSER = 1, $SIDTYPEGROUP, $SIDTYPEDOMAIN, $SIDTYPEALIAS, $SIDTYPEWELLKNOWNGROUP, $SIDTYPEDELETEDACCOUNT, $SIDTYPEINVALID, $SIDTYPEUNKNOWN, $SIDTYPECOMPUTER, $SIDTYPELABEL Global Const $SID_ADMINISTRATORS = "S-1-5-32-544" Global Const $SID_USERS = "S-1-5-32-545" Global Const $SID_GUESTS = "S-1-5-32-546" Global Const $SID_ACCOUNT_OPERATORS = "S-1-5-32-548" Global Const $SID_SERVER_OPERATORS = "S-1-5-32-549" Global Const $SID_PRINT_OPERATORS = "S-1-5-32-550" Global Const $SID_BACKUP_OPERATORS = "S-1-5-32-551" Global Const $SID_REPLICATOR = "S-1-5-32-552" Global Const $SID_OWNER = "S-1-3-0" Global Const $SID_EVERYONE = "S-1-1-0" Global Const $SID_NETWORK = "S-1-5-2" Global Const $SID_INTERACTIVE = "S-1-5-4" Global Const $SID_SYSTEM = "S-1-5-18" Global Const $SID_AUTHENTICATED_USERS = "S-1-5-11" Global Const $SID_SCHANNEL_AUTHENTICATION = "S-1-5-64-14" Global Const $SID_DIGEST_AUTHENTICATION = "S-1-5-64-21" Global Const $SID_NT_SERVICE = "S-1-5-80" Global Const $SID_UNTRUSTED_MANDATORY_LEVEL = "S-1-16-0" Global Const $SID_LOW_MANDATORY_LEVEL = "S-1-16-4096" Global Const $SID_MEDIUM_MANDATORY_LEVEL = "S-1-16-8192" Global Const $SID_MEDIUM_PLUS_MANDATORY_LEVEL = "S-1-16-8448" Global Const $SID_HIGH_MANDATORY_LEVEL = "S-1-16-12288" Global Const $SID_SYSTEM_MANDATORY_LEVEL = "S-1-16-16384" Global Const $SID_PROTECTED_PROCESS_MANDATORY_LEVEL = "S-1-16-20480" Global Const $SID_SECURE_PROCESS_MANDATORY_LEVEL = "S-1-16-28672" Global Const $SID_ALL_SERVICES = "S-1-5-80-0" #Region Global Variables and Constants Global Const $FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100 Global Const $FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200 Global Const $FORMAT_MESSAGE_FROM_STRING = 0x00000400 Global Const $FORMAT_MESSAGE_FROM_HMODULE = 0x00000800 Global Const $FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000 Global Const $FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000 #EndRegion Global Variables and Constants Func _WinAPI_Beep($iFreq = 500, $iDuration = 1000) Local $aResult = DllCall("kernel32.dll", "bool", "Beep", "dword", $iFreq, "dword", $iDuration) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_FormatMessage($iFlags, $pSource, $iMessageID, $iLanguageID, ByRef $pBuffer, $iSize, $vArguments) Local $sBufferType = "struct*" If IsString($pBuffer) Then $sBufferType = "wstr" Local $aResult = DllCall("kernel32.dll", "dword", "FormatMessageW", "dword", $iFlags, "struct*", $pSource, "dword", $iMessageID, "dword", $iLanguageID, $sBufferType, $pBuffer, "dword", $iSize, "ptr", $vArguments) If @error Or Not $aResult[0] Then Return SetError(@error + 10, @extended, 0) If $sBufferType = "wstr" Then $pBuffer = $aResult[5] Return $aResult[0] EndFunc Func _WinAPI_GetErrorMessage($iCode, $iLanguage = 0, Const $_iCurrentError = @error, Const $_iCurrentExtended = @extended) Local $aRet = DllCall('kernel32.dll', 'dword', 'FormatMessageW', 'dword', 0x1000, 'ptr', 0, 'dword', $iCode, 'dword', $iLanguage, 'wstr', '', 'dword', 4096, 'ptr', 0) If @error Or Not $aRet[0] Then Return SetError(@error, @extended, '') Return SetError($_iCurrentError, $_iCurrentExtended, StringRegExpReplace($aRet[5], '[' & @LF & ',' & @CR & ']*\Z', '')) EndFunc Func _WinAPI_GetLastError(Const $_iCurrentError = @error, Const $_iCurrentExtended = @extended) Local $aResult = DllCall("kernel32.dll", "dword", "GetLastError") Return SetError($_iCurrentError, $_iCurrentExtended, $aResult[0]) EndFunc Func _WinAPI_GetLastErrorMessage(Const $_iCurrentError = @error, Const $_iCurrentExtended = @extended) Local $iLastError = _WinAPI_GetLastError() Local $tBufferPtr = DllStructCreate("ptr") Local $nCount = _WinAPI_FormatMessage(BitOR($FORMAT_MESSAGE_ALLOCATE_BUFFER, $FORMAT_MESSAGE_FROM_SYSTEM), 0, $iLastError, 0, $tBufferPtr, 0, 0) If @error Then Return SetError(-@error, @extended, "") Local $sText = "" Local $pBuffer = DllStructGetData($tBufferPtr, 1) If $pBuffer Then If $nCount > 0 Then Local $tBuffer = DllStructCreate("wchar[" & ($nCount + 1) & "]", $pBuffer) $sText = DllStructGetData($tBuffer, 1) If StringRight($sText, 2) = @CRLF Then $sText = StringTrimRight($sText, 2) EndIf DllCall("kernel32.dll", "handle", "LocalFree", "handle", $pBuffer) EndIf Return SetError($_iCurrentError, $_iCurrentExtended, $sText) EndFunc Func _WinAPI_MessageBeep($iType = 1) Local $iSound Switch $iType Case 1 $iSound = 0 Case 2 $iSound = 16 Case 3 $iSound = 32 Case 4 $iSound = 48 Case 5 $iSound = 64 Case Else $iSound = -1 EndSwitch Local $aResult = DllCall("user32.dll", "bool", "MessageBeep", "uint", $iSound) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_MsgBox($iFlags, $sTitle, $sText) BlockInput(0) MsgBox($iFlags, $sTitle, $sText & " ") EndFunc Func _WinAPI_SetLastError($iErrorCode, Const $_iCurrentError = @error, Const $_iCurrentExtended = @extended) DllCall("kernel32.dll", "none", "SetLastError", "dword", $iErrorCode) Return SetError($_iCurrentError, $_iCurrentExtended, Null) EndFunc Func _WinAPI_ShowError($sText, $bExit = True) BlockInput(0) MsgBox($MB_SYSTEMMODAL, "Error", $sText & " ") If $bExit Then Exit EndFunc Func _WinAPI_ShowLastError($sText = '', $bAbort = False, $iLanguage = 0, Const $_iCurrentError = @error, Const $_iCurrentExtended = @extended) Local $sError Local $iLastError = _WinAPI_GetLastError() While 1 $sError = _WinAPI_GetErrorMessage($iLastError, $iLanguage) If @error And $iLanguage Then $iLanguage = 0 Else ExitLoop EndIf WEnd If StringStripWS($sText, $STR_STRIPLEADING + $STR_STRIPTRAILING) Then $sText &= @CRLF & @CRLF Else $sText = '' EndIf _WinAPI_MsgBox(BitOR(0x00040000, BitShift(0x00000010, -2 * (Not $iLastError))), $iLastError, $sText & $sError) If $iLastError Then _WinAPI_SetLastError($iLastError) If $bAbort Then Exit $iLastError EndIf EndIf Return SetError($_iCurrentError, $_iCurrentExtended, 1) EndFunc Func _WinAPI_ShowMsg($sText) _WinAPI_MsgBox($MB_SYSTEMMODAL, "Information", $sText) EndFunc Func __COMErrorFormating(ByRef $oCOMError, $sPrefix = @TAB) Local Const $STR_STRIPTRAILING = 2 Local $sError = "COM Error encountered in " & @ScriptName & " (" & $oCOMError.Scriptline & ") :" & @CRLF & $sPrefix & "Number " & @TAB & "= 0x" & Hex($oCOMError.Number, 8) & " (" & $oCOMError.Number & ")" & @CRLF & $sPrefix & "WinDescription" & @TAB & "= " & StringStripWS($oCOMError.WinDescription, $STR_STRIPTRAILING) & @CRLF & $sPrefix & "Description " & @TAB & "= " & StringStripWS($oCOMError.Description, $STR_STRIPTRAILING) & @CRLF & $sPrefix & "Source " & @TAB & "= " & $oCOMError.Source & @CRLF & $sPrefix & "HelpFile " & @TAB & "= " & $oCOMError.HelpFile & @CRLF & $sPrefix & "HelpContext " & @TAB & "= " & $oCOMError.HelpContext & @CRLF & $sPrefix & "LastDllError " & @TAB & "= " & $oCOMError.LastDllError & @CRLF & $sPrefix & "Retcode " & @TAB & "= 0x" & Hex($oCOMError.retcode) Return $sError EndFunc Func _Security__AdjustTokenPrivileges($hToken, $bDisableAll, $tNewState, $iBufferLen, $tPrevState = 0, $pRequired = 0) Local $aCall = DllCall("advapi32.dll", "bool", "AdjustTokenPrivileges", "handle", $hToken, "bool", $bDisableAll, "struct*", $tNewState, "dword", $iBufferLen, "struct*", $tPrevState, "struct*", $pRequired) If @error Then Return SetError(@error, @extended, False) Return Not ($aCall[0] = 0) EndFunc Func _Security__CreateProcessWithToken($hToken, $iLogonFlags, $sCommandLine, $iCreationFlags, $sCurDir, $tSTARTUPINFO, $tPROCESS_INFORMATION) Local $aCall = DllCall("advapi32.dll", "bool", "CreateProcessWithTokenW", "handle", $hToken, "dword", $iLogonFlags, "ptr", 0, "wstr", $sCommandLine, "dword", $iCreationFlags, "struct*", 0, "wstr", $sCurDir, "struct*", $tSTARTUPINFO, "struct*", $tPROCESS_INFORMATION) If @error Or Not $aCall[0] Then Return SetError(@error, @extended, False) Return True EndFunc Func _Security__DuplicateTokenEx($hExistingToken, $iDesiredAccess, $iImpersonationLevel, $iTokenType) Local $aCall = DllCall("advapi32.dll", "bool", "DuplicateTokenEx", "handle", $hExistingToken, "dword", $iDesiredAccess, "struct*", 0, "int", $iImpersonationLevel, "int", $iTokenType, "handle*", 0) If @error Or Not $aCall[0] Then Return SetError(@error, @extended, 0) Return $aCall[6] EndFunc Func _Security__GetAccountSid($sAccount, $sSystem = "") Local $aAcct = _Security__LookupAccountName($sAccount, $sSystem) If @error Then Return SetError(@error, @extended, 0) If IsArray($aAcct) Then Return _Security__StringSidToSid($aAcct[0]) Return '' EndFunc Func _Security__GetLengthSid($pSID) If Not _Security__IsValidSid($pSID) Then Return SetError(@error + 10, @extended, 0) Local $aCall = DllCall("advapi32.dll", "dword", "GetLengthSid", "struct*", $pSID) If @error Then Return SetError(@error, @extended, 0) Return $aCall[0] EndFunc Func _Security__GetTokenInformation($hToken, $iClass) Local $aCall = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $hToken, "int", $iClass, "struct*", 0, "dword", 0, "dword*", 0) If @error Or Not $aCall[5] Then Return SetError(@error + 10, @extended, 0) Local $iLen = $aCall[5] Local $tBuffer = DllStructCreate("byte[" & $iLen & "]") $aCall = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $hToken, "int", $iClass, "struct*", $tBuffer, "dword", DllStructGetSize($tBuffer), "dword*", 0) If @error Or Not $aCall[0] Then Return SetError(@error, @extended, 0) Return $tBuffer EndFunc Func _Security__ImpersonateSelf($iLevel = $SECURITYIMPERSONATION) Local $aCall = DllCall("advapi32.dll", "bool", "ImpersonateSelf", "int", $iLevel) If @error Then Return SetError(@error, @extended, False) Return Not ($aCall[0] = 0) EndFunc Func _Security__IsValidSid($pSID) Local $aCall = DllCall("advapi32.dll", "bool", "IsValidSid", "struct*", $pSID) If @error Then Return SetError(@error, @extended, False) Return Not ($aCall[0] = 0) EndFunc Func _Security__LookupAccountName($sAccount, $sSystem = "") Local $tData = DllStructCreate("byte SID[256]") Local $aCall = DllCall("advapi32.dll", "bool", "LookupAccountNameW", "wstr", $sSystem, "wstr", $sAccount, "struct*", $tData, "dword*", DllStructGetSize($tData), "wstr", "", "dword*", DllStructGetSize($tData), "int*", 0) If @error Or Not $aCall[0] Then Return SetError(@error, @extended, 0) Local $aAcct[3] $aAcct[0] = _Security__SidToStringSid(DllStructGetPtr($tData, "SID")) $aAcct[1] = $aCall[5] $aAcct[2] = $aCall[7] Return $aAcct EndFunc Func _Security__LookupAccountSid($vSID, $sSystem = "") Local $pSID, $aAcct[3] If IsString($vSID) Then $pSID = _Security__StringSidToSid($vSID) Else $pSID = $vSID EndIf If Not _Security__IsValidSid($pSID) Then Return SetError(@error + 10, @extended, 0) Local $sTypeSystem = "ptr" If $sSystem Then $sTypeSystem = "wstr" Local $aCall = DllCall("advapi32.dll", "bool", "LookupAccountSidW", $sTypeSystem, $sSystem, "struct*", $pSID, "wstr", "", "dword*", 65536, "wstr", "", "dword*", 65536, "int*", 0) If @error Or Not $aCall[0] Then Return SetError(@error, @extended, 0) Local $aAcct[3] $aAcct[0] = $aCall[3] $aAcct[1] = $aCall[5] $aAcct[2] = $aCall[7] Return $aAcct EndFunc Func _Security__LookupPrivilegeValue($sSystem, $sName) Local $aCall = DllCall("advapi32.dll", "bool", "LookupPrivilegeValueW", "wstr", $sSystem, "wstr", $sName, "int64*", 0) If @error Or Not $aCall[0] Then Return SetError(@error, @extended, 0) Return $aCall[3] EndFunc Func _Security__OpenProcessToken($hProcess, $iAccess) Local $aCall = DllCall("advapi32.dll", "bool", "OpenProcessToken", "handle", $hProcess, "dword", $iAccess, "handle*", 0) If @error Or Not $aCall[0] Then Return SetError(@error, @extended, 0) Return $aCall[3] EndFunc Func _Security__OpenThreadToken($iAccess, $hThread = 0, $bOpenAsSelf = False) If $hThread = 0 Then Local $aResult = DllCall("kernel32.dll", "handle", "GetCurrentThread") If @error Then Return SetError(@error + 10, @extended, 0) $hThread = $aResult[0] EndIf Local $aCall = DllCall("advapi32.dll", "bool", "OpenThreadToken", "handle", $hThread, "dword", $iAccess, "bool", $bOpenAsSelf, "handle*", 0) If @error Or Not $aCall[0] Then Return SetError(@error, @extended, 0) Return $aCall[4] EndFunc Func _Security__OpenThreadTokenEx($iAccess, $hThread = 0, $bOpenAsSelf = False) Local $hToken = _Security__OpenThreadToken($iAccess, $hThread, $bOpenAsSelf) If $hToken = 0 Then Local Const $ERROR_NO_TOKEN = 1008 If _WinAPI_GetLastError() <> $ERROR_NO_TOKEN Then Return SetError(20, _WinAPI_GetLastError(), 0) If Not _Security__ImpersonateSelf() Then Return SetError(@error + 10, _WinAPI_GetLastError(), 0) $hToken = _Security__OpenThreadToken($iAccess, $hThread, $bOpenAsSelf) If $hToken = 0 Then Return SetError(@error, _WinAPI_GetLastError(), 0) EndIf Return $hToken EndFunc Func _Security__SetPrivilege($hToken, $sPrivilege, $bEnable) Local $iLUID = _Security__LookupPrivilegeValue("", $sPrivilege) If $iLUID = 0 Then Return SetError(@error + 10, @extended, False) Local Const $tagTOKEN_PRIVILEGES = "dword Count;align 4;int64 LUID;dword Attributes" Local $tCurrState = DllStructCreate($tagTOKEN_PRIVILEGES) Local $iCurrState = DllStructGetSize($tCurrState) Local $tPrevState = DllStructCreate($tagTOKEN_PRIVILEGES) Local $iPrevState = DllStructGetSize($tPrevState) Local $tRequired = DllStructCreate("int Data") DllStructSetData($tCurrState, "Count", 1) DllStructSetData($tCurrState, "LUID", $iLUID) If Not _Security__AdjustTokenPrivileges($hToken, False, $tCurrState, $iCurrState, $tPrevState, $tRequired) Then Return SetError(2, @error, False) DllStructSetData($tPrevState, "Count", 1) DllStructSetData($tPrevState, "LUID", $iLUID) Local $iAttributes = DllStructGetData($tPrevState, "Attributes") If $bEnable Then $iAttributes = BitOR($iAttributes, $SE_PRIVILEGE_ENABLED) Else $iAttributes = BitAND($iAttributes, BitNOT($SE_PRIVILEGE_ENABLED)) EndIf DllStructSetData($tPrevState, "Attributes", $iAttributes) If Not _Security__AdjustTokenPrivileges($hToken, False, $tPrevState, $iPrevState, $tCurrState, $tRequired) Then Return SetError(3, @error, False) Return True EndFunc Func _Security__SetTokenInformation($hToken, $iTokenInformation, $vTokenInformation, $iTokenInformationLength) Local $aCall = DllCall("advapi32.dll", "bool", "SetTokenInformation", "handle", $hToken, "int", $iTokenInformation, "struct*", $vTokenInformation, "dword", $iTokenInformationLength) If @error Or Not $aCall[0] Then Return SetError(@error, @extended, False) Return True EndFunc Func _Security__SidToStringSid($pSID) If Not _Security__IsValidSid($pSID) Then Return SetError(@error + 10, 0, "") Local $aCall = DllCall("advapi32.dll", "bool", "ConvertSidToStringSidW", "struct*", $pSID, "ptr*", 0) If @error Or Not $aCall[0] Then Return SetError(@error, @extended, "") Local $pStringSid = $aCall[2] Local $aLen = DllCall("kernel32.dll", "int", "lstrlenW", "struct*", $pStringSid) Local $sSID = DllStructGetData(DllStructCreate("wchar Text[" & $aLen[0] + 1 & "]", $pStringSid), "Text") DllCall("kernel32.dll", "handle", "LocalFree", "handle", $pStringSid) Return $sSID EndFunc Func _Security__SidTypeStr($iType) Switch $iType Case $SIDTYPEUSER Return "User" Case $SIDTYPEGROUP Return "Group" Case $SIDTYPEDOMAIN Return "Domain" Case $SIDTYPEALIAS Return "Alias" Case $SIDTYPEWELLKNOWNGROUP Return "Well Known Group" Case $SIDTYPEDELETEDACCOUNT Return "Deleted Account" Case $SIDTYPEINVALID Return "Invalid" Case $SIDTYPEUNKNOWN Return "Unknown Type" Case $SIDTYPECOMPUTER Return "Computer" Case $SIDTYPELABEL Return "A mandatory integrity label SID" Case Else Return "Unknown SID Type" EndSwitch EndFunc Func _Security__StringSidToSid($sSID) Local $aCall = DllCall("advapi32.dll", "bool", "ConvertStringSidToSidW", "wstr", $sSID, "ptr*", 0) If @error Or Not $aCall[0] Then Return SetError(@error, @extended, 0) Local $pSID = $aCall[2] Local $tBuffer = DllStructCreate("byte Data[" & _Security__GetLengthSid($pSID) & "]", $pSID) Local $tSID = DllStructCreate("byte Data[" & DllStructGetSize($tBuffer) & "]") DllStructSetData($tSID, "Data", DllStructGetData($tBuffer, "Data")) DllCall("kernel32.dll", "handle", "LocalFree", "handle", $pSID) Return $tSID EndFunc Global Const $tagPOINT = "struct;long X;long Y;endstruct" Global Const $tagRECT = "struct;long Left;long Top;long Right;long Bottom;endstruct" Global Const $tagSIZE = "struct;long X;long Y;endstruct" Global Const $tagMARGINS = "int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight" Global Const $tagFILETIME = "struct;dword Lo;dword Hi;endstruct" Global Const $tagSYSTEMTIME = "struct;word Year;word Month;word Dow;word Day;word Hour;word Minute;word Second;word MSeconds;endstruct" Global Const $tagTIME_ZONE_INFORMATION = "struct;long Bias;wchar StdName[32];word StdDate[8];long StdBias;wchar DayName[32];word DayDate[8];long DayBias;endstruct" Global Const $tagNMHDR = "struct;hwnd hWndFrom;uint_ptr IDFrom;INT Code;endstruct" Global Const $tagCOMBOBOXEXITEM = "uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;int SelectedImage;int OverlayImage;" & "int Indent;lparam Param" Global Const $tagNMCBEDRAGBEGIN = $tagNMHDR & ";int ItemID;wchar szText[260]" Global Const $tagNMCBEENDEDIT = $tagNMHDR & ";bool fChanged;int NewSelection;wchar szText[260];int Why" Global Const $tagNMCOMBOBOXEX = $tagNMHDR & ";uint Mask;int_ptr Item;ptr Text;int TextMax;int Image;" & "int SelectedImage;int OverlayImage;int Indent;lparam Param" Global Const $tagDTPRANGE = "word MinYear;word MinMonth;word MinDOW;word MinDay;word MinHour;word MinMinute;" & "word MinSecond;word MinMSecond;word MaxYear;word MaxMonth;word MaxDOW;word MaxDay;word MaxHour;" & "word MaxMinute;word MaxSecond;word MaxMSecond;bool MinValid;bool MaxValid" Global Const $tagNMDATETIMECHANGE = $tagNMHDR & ";dword Flag;" & $tagSYSTEMTIME Global Const $tagNMDATETIMEFORMAT = $tagNMHDR & ";ptr Format;" & $tagSYSTEMTIME & ";ptr pDisplay;wchar Display[64]" Global Const $tagNMDATETIMEFORMATQUERY = $tagNMHDR & ";ptr Format;struct;long SizeX;long SizeY;endstruct" Global Const $tagNMDATETIMEKEYDOWN = $tagNMHDR & ";int VirtKey;ptr Format;" & $tagSYSTEMTIME Global Const $tagNMDATETIMESTRING = $tagNMHDR & ";ptr UserString;" & $tagSYSTEMTIME & ";dword Flags" Global Const $tagEVENTLOGRECORD = "dword Length;dword Reserved;dword RecordNumber;dword TimeGenerated;dword TimeWritten;dword EventID;" & "word EventType;word NumStrings;word EventCategory;word ReservedFlags;dword ClosingRecordNumber;dword StringOffset;" & "dword UserSidLength;dword UserSidOffset;dword DataLength;dword DataOffset" Global Const $tagGDIP_EFFECTPARAMS_Blur = "float Radius; bool ExpandEdge" Global Const $tagGDIP_EFFECTPARAMS_BrightnessContrast = "int BrightnessLevel; int ContrastLevel" Global Const $tagGDIP_EFFECTPARAMS_ColorBalance = "int CyanRed; int MagentaGreen; int YellowBlue" Global Const $tagGDIP_EFFECTPARAMS_ColorCurve = "int Adjustment; int Channel; int AdjustValue" Global Const $tagGDIP_EFFECTPARAMS_ColorLUT = "byte LutB[256]; byte LutG[256]; byte LutR[256]; byte LutA[256]" Global Const $tagGDIP_EFFECTPARAMS_HueSaturationLightness = "int HueLevel; int SaturationLevel; int LightnessLevel" Global Const $tagGDIP_EFFECTPARAMS_Levels = "int Highlight; int Midtone; int Shadow" Global Const $tagGDIP_EFFECTPARAMS_RedEyeCorrection = "uint NumberOfAreas; ptr Areas" Global Const $tagGDIP_EFFECTPARAMS_Sharpen = "float Radius; float Amount" Global Const $tagGDIP_EFFECTPARAMS_Tint = "int Hue; int Amount" Global Const $tagGDIPBITMAPDATA = "uint Width;uint Height;int Stride;int Format;ptr Scan0;uint_ptr Reserved" Global Const $tagGDIPCOLORMATRIX = "float m[25]" Global Const $tagGDIPENCODERPARAM = "struct;byte GUID[16];ulong NumberOfValues;ulong Type;ptr Values;endstruct" Global Const $tagGDIPENCODERPARAMS = "uint Count;" & $tagGDIPENCODERPARAM Global Const $tagGDIPRECTF = "struct;float X;float Y;float Width;float Height;endstruct" Global Const $tagGDIPSTARTUPINPUT = "uint Version;ptr Callback;bool NoThread;bool NoCodecs" Global Const $tagGDIPSTARTUPOUTPUT = "ptr HookProc;ptr UnhookProc" Global Const $tagGDIPIMAGECODECINFO = "byte CLSID[16];byte FormatID[16];ptr CodecName;ptr DllName;ptr FormatDesc;ptr FileExt;" & "ptr MimeType;dword Flags;dword Version;dword SigCount;dword SigSize;ptr SigPattern;ptr SigMask" Global Const $tagGDIPPENCODERPARAMS = "uint Count;byte Params[1]" Global Const $tagHDITEM = "uint Mask;int XY;ptr Text;handle hBMP;int TextMax;int Fmt;lparam Param;int Image;int Order;uint Type;ptr pFilter;uint State" Global Const $tagNMHDDISPINFO = $tagNMHDR & ";int Item;uint Mask;ptr Text;int TextMax;int Image;lparam lParam" Global Const $tagNMHDFILTERBTNCLICK = $tagNMHDR & ";int Item;" & $tagRECT Global Const $tagNMHEADER = $tagNMHDR & ";int Item;int Button;ptr pItem" Global Const $tagGETIPAddress = "byte Field4;byte Field3;byte Field2;byte Field1" Global Const $tagNMIPADDRESS = $tagNMHDR & ";int Field;int Value" Global Const $tagLVFINDINFO = "struct;uint Flags;ptr Text;lparam Param;" & $tagPOINT & ";uint Direction;endstruct" Global Const $tagLVHITTESTINFO = $tagPOINT & ";uint Flags;int Item;int SubItem;int iGroup" Global Const $tagLVITEM = "struct;uint Mask;int Item;int SubItem;uint State;uint StateMask;ptr Text;int TextMax;int Image;lparam Param;" & "int Indent;int GroupID;uint Columns;ptr pColumns;ptr piColFmt;int iGroup;endstruct" Global Const $tagNMLISTVIEW = $tagNMHDR & ";int Item;int SubItem;uint NewState;uint OldState;uint Changed;" & "struct;long ActionX;long ActionY;endstruct;lparam Param" Global Const $tagNMLVCUSTOMDRAW = "struct;" & $tagNMHDR & ";dword dwDrawStage;handle hdc;" & $tagRECT & ";dword_ptr dwItemSpec;uint uItemState;lparam lItemlParam;endstruct" & ";dword clrText;dword clrTextBk;int iSubItem;dword dwItemType;dword clrFace;int iIconEffect;" & "int iIconPhase;int iPartID;int iStateID;struct;long TextLeft;long TextTop;long TextRight;long TextBottom;endstruct;uint uAlign" Global Const $tagNMLVDISPINFO = $tagNMHDR & ";" & $tagLVITEM Global Const $tagNMLVFINDITEM = $tagNMHDR & ";int Start;" & $tagLVFINDINFO Global Const $tagNMLVGETINFOTIP = $tagNMHDR & ";dword Flags;ptr Text;int TextMax;int Item;int SubItem;lparam lParam" Global Const $tagNMITEMACTIVATE = $tagNMHDR & ";int Index;int SubItem;uint NewState;uint OldState;uint Changed;" & $tagPOINT & ";lparam lParam;uint KeyFlags" Global Const $tagNMLVKEYDOWN = "align 1;" & $tagNMHDR & ";word VKey;uint Flags" Global Const $tagNMLVSCROLL = $tagNMHDR & ";int DX;int DY" Global Const $tagMCHITTESTINFO = "uint Size;" & $tagPOINT & ";uint Hit;" & $tagSYSTEMTIME & ";" & $tagRECT & ";int iOffset;int iRow;int iCol" Global Const $tagMCMONTHRANGE = "word MinYear;word MinMonth;word MinDOW;word MinDay;word MinHour;word MinMinute;word MinSecond;" & "word MinMSeconds;word MaxYear;word MaxMonth;word MaxDOW;word MaxDay;word MaxHour;word MaxMinute;word MaxSecond;" & "word MaxMSeconds;short Span" Global Const $tagMCRANGE = "word MinYear;word MinMonth;word MinDOW;word MinDay;word MinHour;word MinMinute;word MinSecond;" & "word MinMSeconds;word MaxYear;word MaxMonth;word MaxDOW;word MaxDay;word MaxHour;word MaxMinute;word MaxSecond;" & "word MaxMSeconds;short MinSet;short MaxSet" Global Const $tagMCSELRANGE = "word MinYear;word MinMonth;word MinDOW;word MinDay;word MinHour;word MinMinute;word MinSecond;" & "word MinMSeconds;word MaxYear;word MaxMonth;word MaxDOW;word MaxDay;word MaxHour;word MaxMinute;word MaxSecond;" & "word MaxMSeconds" Global Const $tagNMDAYSTATE = $tagNMHDR & ";" & $tagSYSTEMTIME & ";int DayState;ptr pDayState" Global Const $tagNMSELCHANGE = $tagNMHDR & ";struct;word BegYear;word BegMonth;word BegDOW;word BegDay;word BegHour;word BegMinute;word BegSecond;word BegMSeconds;endstruct;" & "struct;word EndYear;word EndMonth;word EndDOW;word EndDay;word EndHour;word EndMinute;word EndSecond;word EndMSeconds;endstruct" Global Const $tagNMOBJECTNOTIFY = $tagNMHDR & ";int Item;ptr piid;ptr pObject;long Result;dword dwFlags" Global Const $tagNMTCKEYDOWN = "align 1;" & $tagNMHDR & ";word VKey;uint Flags" Global Const $tagTVITEM = "struct;uint Mask;handle hItem;uint State;uint StateMask;ptr Text;int TextMax;int Image;int SelectedImage;" & "int Children;lparam Param;endstruct" Global Const $tagTVITEMEX = "struct;" & $tagTVITEM & ";int Integral;uint uStateEx;hwnd hwnd;int iExpandedImage;int iReserved;endstruct" Global Const $tagNMTREEVIEW = $tagNMHDR & ";uint Action;" & "struct;uint OldMask;handle OldhItem;uint OldState;uint OldStateMask;" & "ptr OldText;int OldTextMax;int OldImage;int OldSelectedImage;int OldChildren;lparam OldParam;endstruct;" & "struct;uint NewMask;handle NewhItem;uint NewState;uint NewStateMask;" & "ptr NewText;int NewTextMax;int NewImage;int NewSelectedImage;int NewChildren;lparam NewParam;endstruct;" & "struct;long PointX;long PointY;endstruct" Global Const $tagNMTVCUSTOMDRAW = "struct;" & $tagNMHDR & ";dword DrawStage;handle HDC;" & $tagRECT & ";dword_ptr ItemSpec;uint ItemState;lparam ItemParam;endstruct" & ";dword ClrText;dword ClrTextBk;int Level" Global Const $tagNMTVDISPINFO = $tagNMHDR & ";" & $tagTVITEM Global Const $tagNMTVGETINFOTIP = $tagNMHDR & ";ptr Text;int TextMax;handle hItem;lparam lParam" Global Const $tagNMTVITEMCHANGE = $tagNMHDR & ";uint Changed;handle hItem;uint StateNew;uint StateOld;lparam lParam;" Global Const $tagTVHITTESTINFO = $tagPOINT & ";uint Flags;handle Item" Global Const $tagNMTVKEYDOWN = "align 1;" & $tagNMHDR & ";word VKey;uint Flags" Global Const $tagNMMOUSE = $tagNMHDR & ";dword_ptr ItemSpec;dword_ptr ItemData;" & $tagPOINT & ";lparam HitInfo" Global Const $tagTOKEN_PRIVILEGES = "dword Count;align 4;int64 LUID;dword Attributes" Global Const $tagIMAGEINFO = "handle hBitmap;handle hMask;int Unused1;int Unused2;" & $tagRECT Global Const $tagMENUINFO = "dword Size;INT Mask;dword Style;uint YMax;handle hBack;dword ContextHelpID;ulong_ptr MenuData" Global Const $tagMENUITEMINFO = "uint Size;uint Mask;uint Type;uint State;uint ID;handle SubMenu;handle BmpChecked;handle BmpUnchecked;" & "ulong_ptr ItemData;ptr TypeData;uint CCH;handle BmpItem" Global Const $tagREBARBANDINFO = "uint cbSize;uint fMask;uint fStyle;dword clrFore;dword clrBack;ptr lpText;uint cch;" & "int iImage;hwnd hwndChild;uint cxMinChild;uint cyMinChild;uint cx;handle hbmBack;uint wID;uint cyChild;uint cyMaxChild;" & "uint cyIntegral;uint cxIdeal;lparam lParam;uint cxHeader" & ((@OSVersion = "WIN_XP") ? "" : ";" & $tagRECT & ";uint uChevronState") Global Const $tagNMREBARAUTOBREAK = $tagNMHDR & ";uint uBand;uint wID;lparam lParam;uint uMsg;uint fStyleCurrent;bool fAutoBreak" Global Const $tagNMRBAUTOSIZE = $tagNMHDR & ";bool fChanged;" & "struct;long TargetLeft;long TargetTop;long TargetRight;long TargetBottom;endstruct;" & "struct;long ActualLeft;long ActualTop;long ActualRight;long ActualBottom;endstruct" Global Const $tagNMREBAR = $tagNMHDR & ";dword dwMask;uint uBand;uint fStyle;uint wID;lparam lParam" Global Const $tagNMREBARCHEVRON = $tagNMHDR & ";uint uBand;uint wID;lparam lParam;" & $tagRECT & ";lparam lParamNM" Global Const $tagNMREBARCHILDSIZE = $tagNMHDR & ";uint uBand;uint wID;" & "struct;long CLeft;long CTop;long CRight;long CBottom;endstruct;" & "struct;long BLeft;long BTop;long BRight;long BBottom;endstruct" Global Const $tagCOLORSCHEME = "dword Size;dword BtnHighlight;dword BtnShadow" Global Const $tagNMTOOLBAR = $tagNMHDR & ";int iItem;" & "struct;int iBitmap;int idCommand;byte fsState;byte fsStyle;dword_ptr dwData;int_ptr iString;endstruct" & ";int cchText;ptr pszText;" & $tagRECT Global Const $tagNMTBHOTITEM = $tagNMHDR & ";int idOld;int idNew;dword dwFlags" Global Const $tagTBBUTTON = "int Bitmap;int Command;byte State;byte Style;dword_ptr Param;int_ptr String" Global Const $tagTBBUTTONINFO = "uint Size;dword Mask;int Command;int Image;byte State;byte Style;word CX;dword_ptr Param;ptr Text;int TextMax" Global Const $tagNETRESOURCE = "dword Scope;dword Type;dword DisplayType;dword Usage;ptr LocalName;ptr RemoteName;ptr Comment;ptr Provider" Global Const $tagOVERLAPPED = "ulong_ptr Internal;ulong_ptr InternalHigh;struct;dword Offset;dword OffsetHigh;endstruct;handle hEvent" Global Const $tagOPENFILENAME = "dword StructSize;hwnd hwndOwner;handle hInstance;ptr lpstrFilter;ptr lpstrCustomFilter;" & "dword nMaxCustFilter;dword nFilterIndex;ptr lpstrFile;dword nMaxFile;ptr lpstrFileTitle;dword nMaxFileTitle;" & "ptr lpstrInitialDir;ptr lpstrTitle;dword Flags;word nFileOffset;word nFileExtension;ptr lpstrDefExt;lparam lCustData;" & "ptr lpfnHook;ptr lpTemplateName;ptr pvReserved;dword dwReserved;dword FlagsEx" Global Const $tagBITMAPINFOHEADER = "struct;dword biSize;long biWidth;long biHeight;word biPlanes;word biBitCount;" & "dword biCompression;dword biSizeImage;long biXPelsPerMeter;long biYPelsPerMeter;dword biClrUsed;dword biClrImportant;endstruct" Global Const $tagBITMAPINFO = $tagBITMAPINFOHEADER & ";dword biRGBQuad[1]" Global Const $tagBLENDFUNCTION = "byte Op;byte Flags;byte Alpha;byte Format" Global Const $tagGUID = "struct;ulong Data1;ushort Data2;ushort Data3;byte Data4[8];endstruct" Global Const $tagWINDOWPLACEMENT = "uint length;uint flags;uint showCmd;long ptMinPosition[2];long ptMaxPosition[2];long rcNormalPosition[4]" Global Const $tagWINDOWPOS = "hwnd hWnd;hwnd InsertAfter;int X;int Y;int CX;int CY;uint Flags" Global Const $tagSCROLLINFO = "uint cbSize;uint fMask;int nMin;int nMax;uint nPage;int nPos;int nTrackPos" Global Const $tagSCROLLBARINFO = "dword cbSize;" & $tagRECT & ";int dxyLineButton;int xyThumbTop;" & "int xyThumbBottom;int reserved;dword rgstate[6]" Global Const $tagLOGFONT = "struct;long Height;long Width;long Escapement;long Orientation;long Weight;byte Italic;byte Underline;" & "byte Strikeout;byte CharSet;byte OutPrecision;byte ClipPrecision;byte Quality;byte PitchAndFamily;wchar FaceName[32];endstruct" Global Const $tagKBDLLHOOKSTRUCT = "dword vkCode;dword scanCode;dword flags;dword time;ulong_ptr dwExtraInfo" Global Const $tagPROCESS_INFORMATION = "handle hProcess;handle hThread;dword ProcessID;dword ThreadID" Global Const $tagSTARTUPINFO = "dword Size;ptr Reserved1;ptr Desktop;ptr Title;dword X;dword Y;dword XSize;dword YSize;dword XCountChars;" & "dword YCountChars;dword FillAttribute;dword Flags;word ShowWindow;word Reserved2;ptr Reserved3;handle StdInput;" & "handle StdOutput;handle StdError" Global Const $tagSECURITY_ATTRIBUTES = "dword Length;ptr Descriptor;bool InheritHandle" Global Const $tagWIN32_FIND_DATA = "dword dwFileAttributes;dword ftCreationTime[2];dword ftLastAccessTime[2];dword ftLastWriteTime[2];dword nFileSizeHigh;dword nFileSizeLow;dword dwReserved0;dword dwReserved1;wchar cFileName[260];wchar cAlternateFileName[14]" Global Const $tagTEXTMETRIC = "long tmHeight;long tmAscent;long tmDescent;long tmInternalLeading;long tmExternalLeading;" & "long tmAveCharWidth;long tmMaxCharWidth;long tmWeight;long tmOverhang;long tmDigitizedAspectX;long tmDigitizedAspectY;" & "wchar tmFirstChar;wchar tmLastChar;wchar tmDefaultChar;wchar tmBreakChar;byte tmItalic;byte tmUnderlined;byte tmStruckOut;" & "byte tmPitchAndFamily;byte tmCharSet" Global Const $tagMEMMAP = "handle hProc;ulong_ptr Size;ptr Mem" Func _MemFree(ByRef $tMemMap) Local $pMemory = DllStructGetData($tMemMap, "Mem") Local $hProcess = DllStructGetData($tMemMap, "hProc") Local $bResult = _MemVirtualFreeEx($hProcess, $pMemory, 0, $MEM_RELEASE) DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hProcess) If @error Then Return SetError(@error, @extended, False) Return $bResult EndFunc Func _MemGlobalAlloc($iBytes, $iFlags = 0) Local $aResult = DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", $iFlags, "ulong_ptr", $iBytes) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _MemGlobalFree($hMemory) Local $aResult = DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", $hMemory) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _MemGlobalLock($hMemory) Local $aResult = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", $hMemory) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _MemGlobalSize($hMemory) Local $aResult = DllCall("kernel32.dll", "ulong_ptr", "GlobalSize", "handle", $hMemory) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _MemGlobalUnlock($hMemory) Local $aResult = DllCall("kernel32.dll", "bool", "GlobalUnlock", "handle", $hMemory) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _MemInit($hWnd, $iSize, ByRef $tMemMap) Local $aResult = DllCall("user32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $hWnd, "dword*", 0) If @error Then Return SetError(@error + 10, @extended, 0) Local $iProcessID = $aResult[2] If $iProcessID = 0 Then Return SetError(1, 0, 0) Local $iAccess = BitOR($PROCESS_VM_OPERATION, $PROCESS_VM_READ, $PROCESS_VM_WRITE) Local $hProcess = __Mem_OpenProcess($iAccess, False, $iProcessID, True) Local $iAlloc = BitOR($MEM_RESERVE, $MEM_COMMIT) Local $pMemory = _MemVirtualAllocEx($hProcess, 0, $iSize, $iAlloc, $PAGE_READWRITE) If $pMemory = 0 Then Return SetError(2, 0, 0) $tMemMap = DllStructCreate($tagMEMMAP) DllStructSetData($tMemMap, "hProc", $hProcess) DllStructSetData($tMemMap, "Size", $iSize) DllStructSetData($tMemMap, "Mem", $pMemory) Return $pMemory EndFunc Func _MemMoveMemory($pSource, $pDest, $iLength) DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pDest, "struct*", $pSource, "ulong_ptr", $iLength) If @error Then Return SetError(@error, @extended) EndFunc Func _MemRead(ByRef $tMemMap, $pSrce, $pDest, $iSize) Local $aResult = DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", DllStructGetData($tMemMap, "hProc"), "ptr", $pSrce, "struct*", $pDest, "ulong_ptr", $iSize, "ulong_ptr*", 0) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _MemWrite(ByRef $tMemMap, $pSrce, $pDest = 0, $iSize = 0, $sSrce = "struct*") If $pDest = 0 Then $pDest = DllStructGetData($tMemMap, "Mem") If $iSize = 0 Then $iSize = DllStructGetData($tMemMap, "Size") Local $aResult = DllCall("kernel32.dll", "bool", "WriteProcessMemory", "handle", DllStructGetData($tMemMap, "hProc"), "ptr", $pDest, $sSrce, $pSrce, "ulong_ptr", $iSize, "ulong_ptr*", 0) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _MemVirtualAlloc($pAddress, $iSize, $iAllocation, $iProtect) Local $aResult = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", $pAddress, "ulong_ptr", $iSize, "dword", $iAllocation, "dword", $iProtect) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _MemVirtualAllocEx($hProcess, $pAddress, $iSize, $iAllocation, $iProtect) Local $aResult = DllCall("kernel32.dll", "ptr", "VirtualAllocEx", "handle", $hProcess, "ptr", $pAddress, "ulong_ptr", $iSize, "dword", $iAllocation, "dword", $iProtect) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _MemVirtualFree($pAddress, $iSize, $iFreeType) Local $aResult = DllCall("kernel32.dll", "bool", "VirtualFree", "ptr", $pAddress, "ulong_ptr", $iSize, "dword", $iFreeType) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _MemVirtualFreeEx($hProcess, $pAddress, $iSize, $iFreeType) Local $aResult = DllCall("kernel32.dll", "bool", "VirtualFreeEx", "handle", $hProcess, "ptr", $pAddress, "ulong_ptr", $iSize, "dword", $iFreeType) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func __Mem_OpenProcess($iAccess, $bInherit, $iPID, $bDebugPriv = False) Local $aResult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iAccess, "bool", $bInherit, "dword", $iPID) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return $aResult[0] If Not $bDebugPriv Then Return SetError(100, 0, 0) Local $hToken = _Security__OpenThreadTokenEx(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY)) If @error Then Return SetError(@error + 10, @extended, 0) _Security__SetPrivilege($hToken, "SeDebugPrivilege", True) Local $iError = @error Local $iExtended = @extended Local $iRet = 0 If Not @error Then $aResult = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $iAccess, "bool", $bInherit, "dword", $iPID) $iError = @error $iExtended = @extended If $aResult[0] Then $iRet = $aResult[0] _Security__SetPrivilege($hToken, "SeDebugPrivilege", False) If @error Then $iError = @error + 20 $iExtended = @extended EndIf Else $iError = @error + 30 EndIf DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hToken) Return SetError($iError, $iExtended, $iRet) EndFunc #Region Global Variables and Constants Global $__g_vEnum, $__g_vExt = 0 Global $__g_iRGBMode = 1 Global Const $tagOSVERSIONINFO = 'struct;dword OSVersionInfoSize;dword MajorVersion;dword MinorVersion;dword BuildNumber;dword PlatformId;wchar CSDVersion[128];endstruct' Global Const $IMAGE_BITMAP = 0 Global Const $IMAGE_ICON = 1 Global Const $IMAGE_CURSOR = 2 Global Const $IMAGE_ENHMETAFILE = 3 Global Const $LR_DEFAULTCOLOR = 0x0000 Global Const $LR_MONOCHROME = 0x0001 Global Const $LR_COLOR = 0x0002 Global Const $LR_COPYRETURNORG = 0x0004 Global Const $LR_COPYDELETEORG = 0x0008 Global Const $LR_LOADFROMFILE = 0x0010 Global Const $LR_LOADTRANSPARENT = 0x0020 Global Const $LR_DEFAULTSIZE = 0x0040 Global Const $LR_VGACOLOR = 0x0080 Global Const $LR_LOADMAP3DCOLORS = 0x1000 Global Const $LR_CREATEDIBSECTION = 0x2000 Global Const $LR_COPYFROMRESOURCE = 0x4000 Global Const $LR_SHARED = 0x8000 Global Const $__tagCURSORINFO = "dword Size;dword Flags;handle hCursor;" & "struct;long X;long Y;endstruct" Global Const $__WINVER = __WINVER() #EndRegion Global Variables and Constants #Region Functions list #EndRegion Functions list #Region Public Functions Func _WinAPI_CreateFile($sFileName, $iCreation, $iAccess = 4, $iShare = 0, $iAttributes = 0, $tSecurity = 0) Local $iDA = 0, $iSM = 0, $iCD = 0, $iFA = 0 If BitAND($iAccess, 1) <> 0 Then $iDA = BitOR($iDA, $GENERIC_EXECUTE) If BitAND($iAccess, 2) <> 0 Then $iDA = BitOR($iDA, $GENERIC_READ) If BitAND($iAccess, 4) <> 0 Then $iDA = BitOR($iDA, $GENERIC_WRITE) If BitAND($iShare, 1) <> 0 Then $iSM = BitOR($iSM, $FILE_SHARE_DELETE) If BitAND($iShare, 2) <> 0 Then $iSM = BitOR($iSM, $FILE_SHARE_READ) If BitAND($iShare, 4) <> 0 Then $iSM = BitOR($iSM, $FILE_SHARE_WRITE) Switch $iCreation Case 0 $iCD = $CREATE_NEW Case 1 $iCD = $CREATE_ALWAYS Case 2 $iCD = $OPEN_EXISTING Case 3 $iCD = $OPEN_ALWAYS Case 4 $iCD = $TRUNCATE_EXISTING EndSwitch If BitAND($iAttributes, 1) <> 0 Then $iFA = BitOR($iFA, $FILE_ATTRIBUTE_ARCHIVE) If BitAND($iAttributes, 2) <> 0 Then $iFA = BitOR($iFA, $FILE_ATTRIBUTE_HIDDEN) If BitAND($iAttributes, 4) <> 0 Then $iFA = BitOR($iFA, $FILE_ATTRIBUTE_READONLY) If BitAND($iAttributes, 8) <> 0 Then $iFA = BitOR($iFA, $FILE_ATTRIBUTE_SYSTEM) Local $aResult = DllCall("kernel32.dll", "handle", "CreateFileW", "wstr", $sFileName, "dword", $iDA, "dword", $iSM, "struct*", $tSecurity, "dword", $iCD, "dword", $iFA, "ptr", 0) If @error Or ($aResult[0] = Ptr(-1)) Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_FreeLibrary($hModule) Local $aResult = DllCall("kernel32.dll", "bool", "FreeLibrary", "handle", $hModule) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_GetCursorInfo() Local $tCursor = DllStructCreate($__tagCURSORINFO) Local $iCursor = DllStructGetSize($tCursor) DllStructSetData($tCursor, "Size", $iCursor) Local $aRet = DllCall("user32.dll", "bool", "GetCursorInfo", "struct*", $tCursor) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Local $aCursor[5] $aCursor[0] = True $aCursor[1] = DllStructGetData($tCursor, "Flags") <> 0 $aCursor[2] = DllStructGetData($tCursor, "hCursor") $aCursor[3] = DllStructGetData($tCursor, "X") $aCursor[4] = DllStructGetData($tCursor, "Y") Return $aCursor EndFunc Func _WinAPI_GetDlgCtrlID($hWnd) Local $aResult = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hWnd) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_GetModuleHandle($sModuleName) Local $sModuleNameType = "wstr" If $sModuleName = "" Then $sModuleName = 0 $sModuleNameType = "ptr" EndIf Local $aResult = DllCall("kernel32.dll", "handle", "GetModuleHandleW", $sModuleNameType, $sModuleName) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_GetString($pString, $bUnicode = True) Local $iLength = _WinAPI_StrLen($pString, $bUnicode) If @error Or Not $iLength Then Return SetError(@error + 10, @extended, '') Local $tString = DllStructCreate(($bUnicode ? 'wchar' : 'char') & '[' & ($iLength + 1) & ']', $pString) If @error Then Return SetError(@error, @extended, '') Return SetExtended($iLength, DllStructGetData($tString, 1)) EndFunc Func _WinAPI_IsWow64Process($iPID = 0) If Not $iPID Then $iPID = @AutoItPID Local $hProcess = DllCall('kernel32.dll', 'handle', 'OpenProcess', 'dword', ($__WINVER < 0x0600 ? 0x00000400 : 0x00001000), 'bool', 0, 'dword', $iPID) If @error Or Not $hProcess[0] Then Return SetError(@error + 20, @extended, False) Local $aRet = DllCall('kernel32.dll', 'bool', 'IsWow64Process', 'handle', $hProcess[0], 'bool*', 0) If __CheckErrorCloseHandle($aRet, $hProcess[0]) Then Return SetError(@error, @extended, False) Return $aRet[2] EndFunc Func _WinAPI_LoadImage($hInstance, $sImage, $iType, $iXDesired, $iYDesired, $iLoad) Local $aResult, $sImageType = "int" If IsString($sImage) Then $sImageType = "wstr" $aResult = DllCall("user32.dll", "handle", "LoadImageW", "handle", $hInstance, $sImageType, $sImage, "uint", $iType, "int", $iXDesired, "int", $iYDesired, "uint", $iLoad) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_LoadLibrary($sFileName) Local $aResult = DllCall("kernel32.dll", "handle", "LoadLibraryW", "wstr", $sFileName) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_PathIsDirectory($sFilePath) Local $aRet = DllCall('shlwapi.dll', 'bool', 'PathIsDirectoryW', 'wstr', $sFilePath) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_ReadFile($hFile, $pBuffer, $iToRead, ByRef $iRead, $tOverlapped = 0) Local $aResult = DllCall("kernel32.dll", "bool", "ReadFile", "handle", $hFile, "struct*", $pBuffer, "dword", $iToRead, "dword*", 0, "struct*", $tOverlapped) If @error Then Return SetError(@error, @extended, False) $iRead = $aResult[4] Return $aResult[0] EndFunc Func _WinAPI_StrLen($pString, $bUnicode = True) Local $W = '' If $bUnicode Then $W = 'W' Local $aRet = DllCall('kernel32.dll', 'int', 'lstrlen' & $W, 'struct*', $pString) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_SwitchColor($iColor) If $iColor = -1 Then Return $iColor Return BitOR(BitAND($iColor, 0x00FF00), BitShift(BitAND($iColor, 0x0000FF), -16), BitShift(BitAND($iColor, 0xFF0000), 16)) EndFunc Func _WinAPI_WriteFile($hFile, $pBuffer, $iToWrite, ByRef $iWritten, $tOverlapped = 0) Local $aResult = DllCall("kernel32.dll", "bool", "WriteFile", "handle", $hFile, "struct*", $pBuffer, "dword", $iToWrite, "dword*", 0, "struct*", $tOverlapped) If @error Then Return SetError(@error, @extended, False) $iWritten = $aResult[4] Return $aResult[0] EndFunc #EndRegion Public Functions #Region Internal Functions Func __CheckErrorArrayBounds(Const ByRef $aData, ByRef $iStart, ByRef $iEnd, $nDim = 1, $iDim = $UBOUND_DIMENSIONS) If Not IsArray($aData) Then Return SetError(1, 0, 1) If UBound($aData, $iDim) <> $nDim Then Return SetError(2, 0, 1) If $iStart < 0 Then $iStart = 0 Local $iUBound = UBound($aData) - 1 If $iEnd < 1 Or $iEnd > $iUBound Then $iEnd = $iUBound If $iStart > $iEnd Then Return SetError(4, 0, 1) Return 0 EndFunc Func __CheckErrorCloseHandle($aRet, $hFile, $bLastError = False, $iCurErr = @error, $iCurExt = @extended) If Not $iCurErr And Not $aRet[0] Then $iCurErr = 10 Local $aLastError = DllCall("kernel32.dll", "dword", "GetLastError") DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hFile) If $iCurErr Then DllCall("kernel32.dll", "none", "SetLastError", "dword", $aLastError[0]) If $bLastError Then $iCurExt = $aLastError[0] Return SetError($iCurErr, $iCurExt, $iCurErr) EndFunc Func __DLL($sPath, $bPin = False) Local $aRet = DllCall('kernel32.dll', 'bool', 'GetModuleHandleExW', 'dword', ($bPin ? 0x0001 : 0x0002), "wstr", $sPath, 'ptr*', 0) If Not $aRet[3] Then Local $aResult = DllCall("kernel32.dll", "handle", "LoadLibraryW", "wstr", $sPath) If Not $aResult[0] Then Return 0 EndIf Return 1 EndFunc Func __EnumWindowsProc($hWnd, $bVisible) Local $aResult If $bVisible Then $aResult = DllCall("user32.dll", "bool", "IsWindowVisible", "hwnd", $hWnd) If Not $aResult[0] Then Return 1 EndIf EndIf __Inc($__g_vEnum) $__g_vEnum[$__g_vEnum[0][0]][0] = $hWnd $aResult = DllCall("user32.dll", "int", "GetClassNameW", "hwnd", $hWnd, "wstr", "", "int", 4096) $__g_vEnum[$__g_vEnum[0][0]][1] = $aResult[2] Return 1 EndFunc Func __FatalExit($iCode, $sText = '') If $sText Then MsgBox($MB_SYSTEMMODAL, 'AutoIt', $sText) DllCall('kernel32.dll', 'none', 'FatalExit', 'int', $iCode) EndFunc Func __Inc(ByRef $aData, $iIncrement = 100) Select Case UBound($aData, $UBOUND_COLUMNS) If $iIncrement < 0 Then ReDim $aData[$aData[0][0] + 1][UBound($aData, $UBOUND_COLUMNS)] Else $aData[0][0] += 1 If $aData[0][0] > UBound($aData) - 1 Then ReDim $aData[$aData[0][0] + $iIncrement][UBound($aData, $UBOUND_COLUMNS)] EndIf EndIf Case UBound($aData, $UBOUND_ROWS) If $iIncrement < 0 Then ReDim $aData[$aData[0] + 1] Else $aData[0] += 1 If $aData[0] > UBound($aData) - 1 Then ReDim $aData[$aData[0] + $iIncrement] EndIf EndIf Case Else Return 0 EndSelect Return 1 EndFunc Func __RGB($iColor) If $__g_iRGBMode Then $iColor = _WinAPI_SwitchColor($iColor) EndIf Return $iColor EndFunc Func __WINVER() Local $tOSVI = DllStructCreate($tagOSVERSIONINFO) DllStructSetData($tOSVI, 1, DllStructGetSize($tOSVI)) Local $aRet = DllCall('kernel32.dll', 'bool', 'GetVersionExW', 'struct*', $tOSVI) If @error Or Not $aRet[0] Then Return SetError(@error, @extended, 0) Return BitOR(BitShift(DllStructGetData($tOSVI, 2), -8), DllStructGetData($tOSVI, 3)) EndFunc #EndRegion Internal Functions #Region Global Variables and Constants Global Const $DUPLICATE_CLOSE_SOURCE = 0x00000001 Global Const $DUPLICATE_SAME_ACCESS = 0x00000002 Global Const $OBJ_BITMAP = 7 Global Const $OBJ_BRUSH = 2 Global Const $OBJ_COLORSPACE = 14 Global Const $OBJ_DC = 3 Global Const $OBJ_ENHMETADC = 12 Global Const $OBJ_ENHMETAFILE = 13 Global Const $OBJ_EXTPEN = 11 Global Const $OBJ_FONT = 6 Global Const $OBJ_MEMDC = 10 Global Const $OBJ_METADC = 4 Global Const $OBJ_METAFILE = 9 Global Const $OBJ_PAL = 5 Global Const $OBJ_PEN = 1 Global Const $OBJ_REGION = 8 Global Const $NULL_BRUSH = 5 Global Const $NULL_PEN = 8 Global Const $BLACK_BRUSH = 4 Global Const $DKGRAY_BRUSH = 3 Global Const $DC_BRUSH = 18 Global Const $GRAY_BRUSH = 2 Global Const $HOLLOW_BRUSH = $NULL_BRUSH Global Const $LTGRAY_BRUSH = 1 Global Const $WHITE_BRUSH = 0 Global Const $BLACK_PEN = 7 Global Const $DC_PEN = 19 Global Const $WHITE_PEN = 6 Global Const $ANSI_FIXED_FONT = 11 Global Const $ANSI_VAR_FONT = 12 Global Const $DEVICE_DEFAULT_FONT = 14 Global Const $DEFAULT_GUI_FONT = 17 Global Const $OEM_FIXED_FONT = 10 Global Const $SYSTEM_FONT = 13 Global Const $SYSTEM_FIXED_FONT = 16 Global Const $DEFAULT_PALETTE = 15 #EndRegion Global Variables and Constants #Region Functions list #EndRegion Functions list #Region Public Functions Func _WinAPI_CloseHandle($hObject) Local $aResult = DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hObject) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_DeleteObject($hObject) Local $aResult = DllCall("gdi32.dll", "bool", "DeleteObject", "handle", $hObject) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_DuplicateHandle($hSourceProcessHandle, $hSourceHandle, $hTargetProcessHandle, $iDesiredAccess, $iInheritHandle, $iOptions) Local $aResult = DllCall("kernel32.dll", "bool", "DuplicateHandle", "handle", $hSourceProcessHandle, "handle", $hSourceHandle, "handle", $hTargetProcessHandle, "handle*", 0, "dword", $iDesiredAccess, "bool", $iInheritHandle, "dword", $iOptions) If @error Or Not $aResult[0] Then Return SetError(@error, @extended, 0) Return $aResult[4] EndFunc Func _WinAPI_GetCurrentObject($hDC, $iType) Local $aRet = DllCall('gdi32.dll', 'handle', 'GetCurrentObject', 'handle', $hDC, 'uint', $iType) If @error Or Not $aRet[0] Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetCurrentProcess() Local $aResult = DllCall("kernel32.dll", "handle", "GetCurrentProcess") If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_GetObject($hObject, $iSize, $pObject) Local $aResult = DllCall("gdi32.dll", "int", "GetObjectW", "handle", $hObject, "int", $iSize, "struct*", $pObject) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_GetObjectInfoByHandle($hObject) Local $tagPUBLIC_OBJECT_BASIC_INFORMATION = 'ulong Attributes;ulong GrantedAcess;ulong HandleCount;ulong PointerCount;ulong Reserved[10]' Local $tPOBI = DllStructCreate($tagPUBLIC_OBJECT_BASIC_INFORMATION) Local $aRet = DllCall('ntdll.dll', 'long', 'ZwQueryObject', 'handle', $hObject, 'uint', 0, 'struct*', $tPOBI, 'ulong', DllStructGetSize($tPOBI), 'ptr', 0) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Local $aResult[4] For $i = 0 To 3 $aResult[$i] = DllStructGetData($tPOBI, $i + 1) Next Return $aResult EndFunc Func _WinAPI_GetObjectNameByHandle($hObject) Local $tagUNICODE_STRING = 'struct;ushort Length;ushort MaximumLength;ptr Buffer;endstruct' Local $tagPUBLIC_OBJECT_TYPE_INFORMATION = 'struct;' & $tagUNICODE_STRING & ';ulong Reserved[22];endstruct' Local $tPOTI = DllStructCreate($tagPUBLIC_OBJECT_TYPE_INFORMATION & ';byte[32]') Local $aRet = DllCall('ntdll.dll', 'long', 'ZwQueryObject', 'handle', $hObject, 'uint', 2, 'struct*', $tPOTI, 'ulong', DllStructGetSize($tPOTI), 'ulong*', 0) If @error Then Return SetError(@error, @extended, '') If $aRet[0] Then Return SetError(10, $aRet[0], '') Local $pData = DllStructGetData($tPOTI, 3) If Not $pData Then Return SetError(11, 0, '') Return _WinAPI_GetString($pData) EndFunc Func _WinAPI_GetObjectType($hObject) Local $aRet = DllCall('gdi32.dll', 'dword', 'GetObjectType', 'handle', $hObject) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetStdHandle($iStdHandle) If $iStdHandle < 0 Or $iStdHandle > 2 Then Return SetError(2, 0, -1) Local Const $aHandle[3] = [-10, -11, -12] Local $aResult = DllCall("kernel32.dll", "handle", "GetStdHandle", "dword", $aHandle[$iStdHandle]) If @error Then Return SetError(@error, @extended, -1) Return $aResult[0] EndFunc Func _WinAPI_GetStockObject($iObject) Local $aResult = DllCall("gdi32.dll", "handle", "GetStockObject", "int", $iObject) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_SelectObject($hDC, $hGDIObj) Local $aResult = DllCall("gdi32.dll", "handle", "SelectObject", "handle", $hDC, "handle", $hGDIObj) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_SetHandleInformation($hObject, $iMask, $iFlags) Local $aResult = DllCall("kernel32.dll", "bool", "SetHandleInformation", "handle", $hObject, "dword", $iMask, "dword", $iFlags) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc #EndRegion Public Functions Global Const $LINGUISTIC_IGNORECASE = 0x00000010 Global Const $LINGUISTIC_IGNOREDIACRITIC = 0x00000020 Global Const $NORM_IGNORECASE = 0x00000001 Global Const $NORM_IGNOREKANATYPE = 0x00010000 Global Const $NORM_IGNORENONSPACE = 0x00000002 Global Const $NORM_IGNORESYMBOLS = 0x00000004 Global Const $NORM_IGNOREWIDTH = 0x00020000 Global Const $NORM_LINGUISTIC_CASING = 0x08000000 Global Const $SORT_DIGITSASNUMBERS = 0x00000008 Global Const $SORT_STRINGSORT = 0x00001000 Global Const $CSTR_LESS_THAN = 1 Global Const $CSTR_EQUAL = 2 Global Const $CSTR_GREATER_THAN = 3 Global Const $MUI_LANGUAGE_ID = 0x0004 Global Const $MUI_LANGUAGE_NAME = 0x0008 Global Const $DATE_AUTOLAYOUT = 0x40 Global Const $DATE_LONGDATE = 0x02 Global Const $DATE_LTRREADING = 0x10 Global Const $DATE_SHORTDATE = 0x01 Global Const $DATE_RTLREADING = 0x20 Global Const $DATE_USE_ALT_CALENDAR = 0x04 Global Const $DATE_YEARMONTH = 0x08 Global Const $GEO_NATION = 1 Global Const $GEO_LATITUDE = 2 Global Const $GEO_LONGITUDE = 3 Global Const $GEO_ISO2 = 4 Global Const $GEO_ISO3 = 5 Global Const $GEO_RFC1766 = 6 Global Const $GEO_LCID = 7 Global Const $GEO_FRIENDLYNAME = 8 Global Const $GEO_OFFICIALNAME = 9 Global Const $GEO_TIMEZONES = 10 Global Const $GEO_OFFICIALLANGUAGES = 11 Global Const $GEO_ISO_UN_NUMBER = 12 Global Const $GEO_PARENT = 13 Global Const $LOCALE_ILANGUAGE = 0x0001 Global Const $LOCALE_SLANGUAGE = 0x0002 Global Const $LOCALE_SENGLANGUAGE = 0x1001 Global Const $LOCALE_SABBREVLANGNAME = 0x0003 Global Const $LOCALE_SNATIVELANGNAME = 0x0004 Global Const $LOCALE_ICOUNTRY = 0x0005 Global Const $LOCALE_SCOUNTRY = 0x0006 Global Const $LOCALE_SENGCOUNTRY = 0x1002 Global Const $LOCALE_SABBREVCTRYNAME = 0x0007 Global Const $LOCALE_SNATIVECTRYNAME = 0x0008 Global Const $LOCALE_IDEFAULTLANGUAGE = 0x0009 Global Const $LOCALE_IDEFAULTCOUNTRY = 0x000A Global Const $LOCALE_IDEFAULTCODEPAGE = 0x000B Global Const $LOCALE_IDEFAULTANSICODEPAGE = 0x1004 Global Const $LOCALE_IDEFAULTMACCODEPAGE = 0x1011 Global Const $LOCALE_SLIST = 0x000C Global Const $LOCALE_IMEASURE = 0x000D Global Const $LOCALE_SDECIMAL = 0x000E Global Const $LOCALE_STHOUSAND = 0x000F Global Const $LOCALE_SGROUPING = 0x0010 Global Const $LOCALE_IDIGITS = 0x0011 Global Const $LOCALE_ILZERO = 0x0012 Global Const $LOCALE_INEGNUMBER = 0x1010 Global Const $LOCALE_SNATIVEDIGITS = 0x0013 Global Const $LOCALE_SCURRENCY = 0x0014 Global Const $LOCALE_SINTLSYMBOL = 0x0015 Global Const $LOCALE_SMONDECIMALSEP = 0x0016 Global Const $LOCALE_SMONTHOUSANDSEP = 0x0017 Global Const $LOCALE_SMONGROUPING = 0x0018 Global Const $LOCALE_ICURRDIGITS = 0x0019 Global Const $LOCALE_IINTLCURRDIGITS = 0x001A Global Const $LOCALE_ICURRENCY = 0x001B Global Const $LOCALE_INEGCURR = 0x001C Global Const $LOCALE_SDATE = 0x001D Global Const $LOCALE_STIME = 0x001E Global Const $LOCALE_SSHORTDATE = 0x001F Global Const $LOCALE_SLONGDATE = 0x0020 Global Const $LOCALE_STIMEFORMAT = 0x1003 Global Const $LOCALE_IDATE = 0x0021 Global Const $LOCALE_ILDATE = 0x0022 Global Const $LOCALE_ITIME = 0x0023 Global Const $LOCALE_ITIMEMARKPOSN = 0x1005 Global Const $LOCALE_ICENTURY = 0x0024 Global Const $LOCALE_ITLZERO = 0x0025 Global Const $LOCALE_IDAYLZERO = 0x0026 Global Const $LOCALE_IMONLZERO = 0x0027 Global Const $LOCALE_S1159 = 0x0028 Global Const $LOCALE_S2359 = 0x0029 Global Const $LOCALE_ICALENDARTYPE = 0x1009 Global Const $LOCALE_IOPTIONALCALENDAR = 0x100B Global Const $LOCALE_IFIRSTDAYOFWEEK = 0x100C Global Const $LOCALE_IFIRSTWEEKOFYEAR = 0x100D Global Const $LOCALE_SDAYNAME1 = 0x002A Global Const $LOCALE_SDAYNAME2 = 0x002B Global Const $LOCALE_SDAYNAME3 = 0x002C Global Const $LOCALE_SDAYNAME4 = 0x002D Global Const $LOCALE_SDAYNAME5 = 0x002E Global Const $LOCALE_SDAYNAME6 = 0x002F Global Const $LOCALE_SDAYNAME7 = 0x0030 Global Const $LOCALE_SABBREVDAYNAME1 = 0x0031 Global Const $LOCALE_SABBREVDAYNAME2 = 0x0032 Global Const $LOCALE_SABBREVDAYNAME3 = 0x0033 Global Const $LOCALE_SABBREVDAYNAME4 = 0x0034 Global Const $LOCALE_SABBREVDAYNAME5 = 0x0035 Global Const $LOCALE_SABBREVDAYNAME6 = 0x0036 Global Const $LOCALE_SABBREVDAYNAME7 = 0x0037 Global Const $LOCALE_SMONTHNAME1 = 0x0038 Global Const $LOCALE_SMONTHNAME2 = 0x0039 Global Const $LOCALE_SMONTHNAME3 = 0x003A Global Const $LOCALE_SMONTHNAME4 = 0x003B Global Const $LOCALE_SMONTHNAME5 = 0x003C Global Const $LOCALE_SMONTHNAME6 = 0x003D Global Const $LOCALE_SMONTHNAME7 = 0x003E Global Const $LOCALE_SMONTHNAME8 = 0x003F Global Const $LOCALE_SMONTHNAME9 = 0x0040 Global Const $LOCALE_SMONTHNAME10 = 0x0041 Global Const $LOCALE_SMONTHNAME11 = 0x0042 Global Const $LOCALE_SMONTHNAME12 = 0x0043 Global Const $LOCALE_SMONTHNAME13 = 0x100E Global Const $LOCALE_SABBREVMONTHNAME1 = 0x0044 Global Const $LOCALE_SABBREVMONTHNAME2 = 0x0045 Global Const $LOCALE_SABBREVMONTHNAME3 = 0x0046 Global Const $LOCALE_SABBREVMONTHNAME4 = 0x0047 Global Const $LOCALE_SABBREVMONTHNAME5 = 0x0048 Global Const $LOCALE_SABBREVMONTHNAME6 = 0x0049 Global Const $LOCALE_SABBREVMONTHNAME7 = 0x004A Global Const $LOCALE_SABBREVMONTHNAME8 = 0x004B Global Const $LOCALE_SABBREVMONTHNAME9 = 0x004C Global Const $LOCALE_SABBREVMONTHNAME10 = 0x004D Global Const $LOCALE_SABBREVMONTHNAME11 = 0x004E Global Const $LOCALE_SABBREVMONTHNAME12 = 0x004F Global Const $LOCALE_SABBREVMONTHNAME13 = 0x100F Global Const $LOCALE_SPOSITIVESIGN = 0x0050 Global Const $LOCALE_SNEGATIVESIGN = 0x0051 Global Const $LOCALE_IPOSSIGNPOSN = 0x0052 Global Const $LOCALE_INEGSIGNPOSN = 0x0053 Global Const $LOCALE_IPOSSYMPRECEDES = 0x0054 Global Const $LOCALE_IPOSSEPBYSPACE = 0x0055 Global Const $LOCALE_INEGSYMPRECEDES = 0x0056 Global Const $LOCALE_INEGSEPBYSPACE = 0x0057 Global Const $LOCALE_FONTSIGNATURE = 0x0058 Global Const $LOCALE_SISO639LANGNAME = 0x0059 Global Const $LOCALE_SISO3166CTRYNAME = 0x005A Global Const $LOCALE_IDEFAULTEBCDICCODEPAGE = 0x1012 Global Const $LOCALE_IPAPERSIZE = 0x100A Global Const $LOCALE_SENGCURRNAME = 0x1007 Global Const $LOCALE_SNATIVECURRNAME = 0x1008 Global Const $LOCALE_SYEARMONTH = 0x1006 Global Const $LOCALE_SSORTNAME = 0x1013 Global Const $LOCALE_IDIGITSUBSTITUTION = 0x1014 Global Const $LOCALE_CUSTOM_DEFAULT = 0x0C00 Global Const $LOCALE_CUSTOM_UI_DEFAULT = 0x1400 Global Const $LOCALE_CUSTOM_UNSPECIFIED = 0x1000 Global Const $LOCALE_INVARIANT = 0x007F Global Const $LOCALE_SYSTEM_DEFAULT = 0x0800 Global Const $LOCALE_USER_DEFAULT = 0x0400 Global Const $TIME_FORCE24HOURFORMAT = 0x08 Global Const $TIME_NOMINUTESORSECONDS = 0x01 Global Const $TIME_NOSECONDS = 0x02 Global Const $TIME_NOTIMEMARKER = 0x04 Global Const $LCID_INSTALLED = 1 Global Const $LCID_SUPPORTED = 2 #Region Global Variables and Constants Global Const $tagNUMBERFMT = 'uint NumDigits;uint LeadingZero;uint Grouping;ptr DecimalSep;ptr ThousandSep;uint NegativeOrder' #EndRegion Global Variables and Constants #Region Functions list #EndRegion Functions list #Region Public Functions Func _WinAPI_CompareString($iLCID, $sString1, $sString2, $iFlags = 0) Local $aRet = DllCall('kernel32.dll', 'int', 'CompareStringW', 'dword', $iLCID, 'dword', $iFlags, 'wstr', $sString1, 'int', -1, 'wstr', $sString2, 'int', -1) If @error Or Not $aRet[0] Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_CreateNumberFormatInfo($iNumDigits, $iLeadingZero, $iGrouping, $sDecimalSep, $sThousandSep, $iNegativeOrder) Local $tFMT = DllStructCreate($tagNUMBERFMT & ';wchar[' & (StringLen($sDecimalSep) + 1) & '];wchar[' & (StringLen($sThousandSep) + 1) & ']') DllStructSetData($tFMT, 1, $iNumDigits) DllStructSetData($tFMT, 2, $iLeadingZero) DllStructSetData($tFMT, 3, $iGrouping) DllStructSetData($tFMT, 4, DllStructGetPtr($tFMT, 7)) DllStructSetData($tFMT, 5, DllStructGetPtr($tFMT, 8)) DllStructSetData($tFMT, 6, $iNegativeOrder) DllStructSetData($tFMT, 7, $sDecimalSep) DllStructSetData($tFMT, 8, $sThousandSep) Return $tFMT EndFunc Func _WinAPI_EnumSystemGeoID() Local $hEnumProc = DllCallbackRegister('__EnumGeoIDProc', 'bool', 'long') Dim $__g_vEnum[101] = [0] Local $aRet = DllCall('kernel32.dll', 'bool', 'EnumSystemGeoID', 'dword', 16, 'long', 0, 'ptr', DllCallbackGetPtr($hEnumProc)) If @error Or Not $aRet[0] Or Not $__g_vEnum[0] Then $__g_vEnum = @error + 10 EndIf DllCallbackFree($hEnumProc) If $__g_vEnum Then Return SetError($__g_vEnum, 0, 0) __Inc($__g_vEnum, -1) Return $__g_vEnum EndFunc Func _WinAPI_EnumSystemLocales($iFlag) Local $hEnumProc = DllCallbackRegister('__EnumLocalesProc', 'bool', 'ptr') Dim $__g_vEnum[101] = [0] Local $aRet = DllCall('kernel32.dll', 'bool', 'EnumSystemLocalesW', 'ptr', DllCallbackGetPtr($hEnumProc), 'dword', $iFlag) If @error Or Not $aRet[0] Or Not $__g_vEnum[0] Then $__g_vEnum = @error + 10 EndIf DllCallbackFree($hEnumProc) If $__g_vEnum Then Return SetError($__g_vEnum, 0, 0) __Inc($__g_vEnum, -1) Return $__g_vEnum EndFunc Func _WinAPI_EnumUILanguages($iFlag = 0) Local $hEnumProc = DllCallbackRegister('__EnumUILanguagesProc', 'bool', 'ptr;long_ptr') Local $iID = 1 If $__WINVER >= 0x0600 Then If BitAND($iFlag, 0x0008) Then $iID = 0 EndIf Else $iFlag = 0 EndIf Dim $__g_vEnum[101] = [0] Local $aRet = DllCall('kernel32.dll', 'bool', 'EnumUILanguagesW', 'ptr', DllCallbackGetPtr($hEnumProc), 'dword', $iFlag, 'long_ptr', $iID) If @error Or Not $aRet[0] Or Not $__g_vEnum[0] Then $__g_vEnum = @error + 10 EndIf DllCallbackFree($hEnumProc) If $__g_vEnum Then Return SetError($__g_vEnum, 0, 0) __Inc($__g_vEnum, -1) Return $__g_vEnum EndFunc Func _WinAPI_GetDateFormat($iLCID = 0, $tSYSTEMTIME = 0, $iFlags = 0, $sFormat = '') If Not $iLCID Then $iLCID = 0x0400 Local $sTypeOfFormat = 'wstr' If Not StringStripWS($sFormat, $STR_STRIPLEADING + $STR_STRIPTRAILING) Then $sTypeOfFormat = 'ptr' $sFormat = 0 EndIf Local $aRet = DllCall('kernel32.dll', 'int', 'GetDateFormatW', 'dword', $iLCID, 'dword', $iFlags, 'struct*', $tSYSTEMTIME, $sTypeOfFormat, $sFormat, 'wstr', '', 'int', 2048) If @error Or Not $aRet[0] Then Return SetError(@error, @extended, '') Return $aRet[5] EndFunc Func _WinAPI_GetDurationFormat($iLCID, $iDuration, $sFormat = '') If Not $iLCID Then $iLCID = 0x0400 Local $pST, $iVal If IsDllStruct($iDuration) Then $pST = DllStructGetPtr($iDuration) $iVal = 0 Else $pST = 0 $iVal = $iDuration EndIf Local $sTypeOfFormat = 'wstr' If Not StringStripWS($sFormat, $STR_STRIPLEADING + $STR_STRIPTRAILING) Then $sTypeOfFormat = 'ptr' $sFormat = 0 EndIf Local $aRet = DllCall('kernel32.dll', 'int', 'GetDurationFormat', 'dword', $iLCID, 'dword', 0, 'ptr', $pST, 'uint64', $iVal, $sTypeOfFormat, $sFormat, 'wstr', '', 'int', 2048) If @error Or Not $aRet[0] Then Return SetError(@error, @extended, '') Return $aRet[6] EndFunc Func _WinAPI_GetGeoInfo($iGEOID, $iType, $iLanguage = 0) Local $aRet = DllCall('kernel32.dll', 'int', 'GetGeoInfoW', 'long', $iGEOID, 'dword', $iType, 'wstr', '', 'int', 4096, 'word', $iLanguage) If @error Or Not $aRet[0] Then Return SetError(@error, @extended, 0) Return $aRet[3] EndFunc Func _WinAPI_GetLocaleInfo($iLCID, $iType) Local $aRet = DllCall('kernel32.dll', 'int', 'GetLocaleInfoW', 'dword', $iLCID, 'dword', $iType, 'wstr', '', 'int', 2048) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, '') Return $aRet[3] EndFunc Func _WinAPI_GetNumberFormat($iLCID, $sNumber, $tNUMBERFMT = 0) If Not $iLCID Then $iLCID = 0x0400 Local $aRet = DllCall('kernel32.dll', 'int', 'GetNumberFormatW', 'dword', $iLCID, 'dword', 0, 'wstr', $sNumber, 'struct*', $tNUMBERFMT, 'wstr', '', 'int', 2048) If @error Or Not $aRet[0] Then Return SetError(@error, @extended, '') Return $aRet[5] EndFunc Func _WinAPI_GetSystemDefaultLangID() Local $aRet = DllCall('kernel32.dll', 'word', 'GetSystemDefaultLangID') If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetSystemDefaultLCID() Local $aRet = DllCall('kernel32.dll', 'dword', 'GetSystemDefaultLCID') If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetSystemDefaultUILanguage() Local $aRet = DllCall('kernel32.dll', 'word', 'GetSystemDefaultUILanguage') If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetThreadLocale() Local $aRet = DllCall('kernel32.dll', 'dword', 'GetThreadLocale') If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetThreadUILanguage() Local $aRet = DllCall('kernel32.dll', 'word', 'GetThreadUILanguage') If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetTimeFormat($iLCID = 0, $tSYSTEMTIME = 0, $iFlags = 0, $sFormat = '') If Not $iLCID Then $iLCID = 0x0400 Local $sTypeOfFormat = 'wstr' If Not StringStripWS($sFormat, $STR_STRIPLEADING + $STR_STRIPTRAILING) Then $sTypeOfFormat = 'ptr' $sFormat = 0 EndIf Local $aRet = DllCall('kernel32.dll', 'int', 'GetTimeFormatW', 'dword', $iLCID, 'dword', $iFlags, 'struct*', $tSYSTEMTIME, $sTypeOfFormat, $sFormat, 'wstr', '', 'int', 2048) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, '') Return $aRet[5] EndFunc Func _WinAPI_GetUserDefaultLangID() Local $aRet = DllCall('kernel32.dll', 'word', 'GetUserDefaultLangID') If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetUserDefaultLCID() Local $aRet = DllCall('kernel32.dll', 'dword', 'GetUserDefaultLCID') If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetUserDefaultUILanguage() Local $aRet = DllCall('kernel32.dll', 'word', 'GetUserDefaultUILanguage') If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetUserGeoID() Local $aRet = DllCall('kernel32.dll', 'long', 'GetUserGeoID', 'uint', 16) If @error Then Return SetError(@error, @extended, -1) Return $aRet[0] EndFunc Func _WinAPI_IsValidLocale($iLCID, $iFlag = 0) Local $aRet = DllCall('kernel32.dll', 'bool', 'IsValidLocale', 'dword', $iLCID, 'dword', $iFlag) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_SetLocaleInfo($iLCID, $iType, $sData) Local $aRet = DllCall('kernel32.dll', 'bool', 'SetLocaleInfoW', 'dword', $iLCID, 'dword', $iType, 'wstr', $sData) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_SetThreadLocale($iLCID) Local $aRet = DllCall('kernel32.dll', 'bool', 'SetThreadLocale', 'dword', $iLCID) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_SetThreadUILanguage($iLanguage) Local $aRet = DllCall('kernel32.dll', 'word', 'SetThreadUILanguage', 'word', $iLanguage) If @error Then Return SetError(@error, @extended, False) Return ($aRet[0] = $aRet[1]) EndFunc Func _WinAPI_SetUserGeoID($iGEOID) Local $aRet = DllCall('kernel32.dll', 'bool', 'SetUserGeoID', 'long', $iGEOID) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc #EndRegion Public Functions #Region Internal Functions Func __EnumGeoIDProc($iID) __Inc($__g_vEnum) $__g_vEnum[$__g_vEnum[0]] = $iID Return 1 EndFunc Func __EnumLocalesProc($pLocale) __Inc($__g_vEnum) $__g_vEnum[$__g_vEnum[0]] = Dec(DllStructGetData(DllStructCreate('wchar[' & (_WinAPI_StrLen($pLocale) + 1) & ']', $pLocale), 1)) Return 1 EndFunc Func __EnumUILanguagesProc($pLanguage, $iID) __Inc($__g_vEnum) $__g_vEnum[$__g_vEnum[0]] = DllStructGetData(DllStructCreate('wchar[' & (_WinAPI_StrLen($pLanguage) + 1) & ']', $pLanguage), 1) If $iID Then $__g_vEnum[$__g_vEnum[0]] = Dec($__g_vEnum[$__g_vEnum[0]]) EndIf Return 1 EndFunc #EndRegion Internal Functions Func _DateAdd($sType, $iNumber, $sDate) Local $asTimePart[4] Local $asDatePart[4] Local $iJulianDate $sType = StringLeft($sType, 1) If StringInStr("D,M,Y,w,h,n,s", $sType) = 0 Or $sType = "" Then Return SetError(1, 0, 0) EndIf If Not StringIsInt($iNumber) Then Return SetError(2, 0, 0) EndIf If Not _DateIsValid($sDate) Then Return SetError(3, 0, 0) EndIf _DateTimeSplit($sDate, $asDatePart, $asTimePart) If $sType = "d" Or $sType = "w" Then If $sType = "w" Then $iNumber = $iNumber * 7 $iJulianDate = _DateToDayValue($asDatePart[1], $asDatePart[2], $asDatePart[3]) + $iNumber _DayValueToDate($iJulianDate, $asDatePart[1], $asDatePart[2], $asDatePart[3]) EndIf If $sType = "m" Then $asDatePart[2] = $asDatePart[2] + $iNumber While $asDatePart[2] > 12 $asDatePart[2] = $asDatePart[2] - 12 $asDatePart[1] = $asDatePart[1] + 1 WEnd While $asDatePart[2] < 1 $asDatePart[2] = $asDatePart[2] + 12 $asDatePart[1] = $asDatePart[1] - 1 WEnd EndIf If $sType = "y" Then $asDatePart[1] = $asDatePart[1] + $iNumber EndIf If $sType = "h" Or $sType = "n" Or $sType = "s" Then Local $iTimeVal = _TimeToTicks($asTimePart[1], $asTimePart[2], $asTimePart[3]) / 1000 If $sType = "h" Then $iTimeVal = $iTimeVal + $iNumber * 3600 If $sType = "n" Then $iTimeVal = $iTimeVal + $iNumber * 60 If $sType = "s" Then $iTimeVal = $iTimeVal + $iNumber Local $iDay2Add = Int($iTimeVal / (24 * 60 * 60)) $iTimeVal = $iTimeVal - $iDay2Add * 24 * 60 * 60 If $iTimeVal < 0 Then $iDay2Add = $iDay2Add - 1 $iTimeVal = $iTimeVal + 24 * 60 * 60 EndIf $iJulianDate = _DateToDayValue($asDatePart[1], $asDatePart[2], $asDatePart[3]) + $iDay2Add _DayValueToDate($iJulianDate, $asDatePart[1], $asDatePart[2], $asDatePart[3]) _TicksToTime($iTimeVal * 1000, $asTimePart[1], $asTimePart[2], $asTimePart[3]) EndIf Local $iNumDays = _DaysInMonth($asDatePart[1]) If $iNumDays[$asDatePart[2]] < $asDatePart[3] Then $asDatePart[3] = $iNumDays[$asDatePart[2]] $sDate = $asDatePart[1] & '/' & StringRight("0" & $asDatePart[2], 2) & '/' & StringRight("0" & $asDatePart[3], 2) If $asTimePart[0] > 0 Then If $asTimePart[0] > 2 Then $sDate = $sDate & " " & StringRight("0" & $asTimePart[1], 2) & ':' & StringRight("0" & $asTimePart[2], 2) & ':' & StringRight("0" & $asTimePart[3], 2) Else $sDate = $sDate & " " & StringRight("0" & $asTimePart[1], 2) & ':' & StringRight("0" & $asTimePart[2], 2) EndIf EndIf Return $sDate EndFunc Func _DateDayOfWeek($iDayNum, $iFormat = Default) Local Const $MONDAY_IS_NO1 = 128 If $iFormat = Default Then $iFormat = 0 $iDayNum = Int($iDayNum) If $iDayNum < 1 Or $iDayNum > 7 Then Return SetError(1, 0, "") Local $tSYSTEMTIME = DllStructCreate($tagSYSTEMTIME) DllStructSetData($tSYSTEMTIME, "Year", BitAND($iFormat, $MONDAY_IS_NO1) ? 2007 : 2006) DllStructSetData($tSYSTEMTIME, "Month", 1) DllStructSetData($tSYSTEMTIME, "Day", $iDayNum) Return _WinAPI_GetDateFormat(BitAND($iFormat, $DMW_LOCALE_LONGNAME) ? $LOCALE_USER_DEFAULT : $LOCALE_INVARIANT, $tSYSTEMTIME, 0, BitAND($iFormat, $DMW_SHORTNAME) ? "ddd" : "dddd") EndFunc Func _DateDaysInMonth($iYear, $iMonthNum) $iMonthNum = Int($iMonthNum) $iYear = Int($iYear) Return __DateIsMonth($iMonthNum) And __DateIsYear($iYear) ? _DaysInMonth($iYear)[$iMonthNum] : SetError(1, 0, 0) EndFunc Func _DateDiff($sType, $sStartDate, $sEndDate) $sType = StringLeft($sType, 1) If StringInStr("d,m,y,w,h,n,s", $sType) = 0 Or $sType = "" Then Return SetError(1, 0, 0) EndIf If Not _DateIsValid($sStartDate) Then Return SetError(2, 0, 0) EndIf If Not _DateIsValid($sEndDate) Then Return SetError(3, 0, 0) EndIf Local $asStartDatePart[4], $asStartTimePart[4], $asEndDatePart[4], $asEndTimePart[4] _DateTimeSplit($sStartDate, $asStartDatePart, $asStartTimePart) _DateTimeSplit($sEndDate, $asEndDatePart, $asEndTimePart) Local $aDaysDiff = _DateToDayValue($asEndDatePart[1], $asEndDatePart[2], $asEndDatePart[3]) - _DateToDayValue($asStartDatePart[1], $asStartDatePart[2], $asStartDatePart[3]) Local $iTimeDiff, $iYearDiff, $iStartTimeInSecs, $iEndTimeInSecs If $asStartTimePart[0] > 1 And $asEndTimePart[0] > 1 Then $iStartTimeInSecs = $asStartTimePart[1] * 3600 + $asStartTimePart[2] * 60 + $asStartTimePart[3] $iEndTimeInSecs = $asEndTimePart[1] * 3600 + $asEndTimePart[2] * 60 + $asEndTimePart[3] $iTimeDiff = $iEndTimeInSecs - $iStartTimeInSecs If $iTimeDiff < 0 Then $aDaysDiff = $aDaysDiff - 1 $iTimeDiff = $iTimeDiff + 24 * 60 * 60 EndIf Else $iTimeDiff = 0 EndIf Select Case $sType = "d" Return $aDaysDiff Case $sType = "m" $iYearDiff = $asEndDatePart[1] - $asStartDatePart[1] Local $iMonthDiff = $asEndDatePart[2] - $asStartDatePart[2] + $iYearDiff * 12 If $asEndDatePart[3] < $asStartDatePart[3] Then $iMonthDiff = $iMonthDiff - 1 $iStartTimeInSecs = $asStartTimePart[1] * 3600 + $asStartTimePart[2] * 60 + $asStartTimePart[3] $iEndTimeInSecs = $asEndTimePart[1] * 3600 + $asEndTimePart[2] * 60 + $asEndTimePart[3] $iTimeDiff = $iEndTimeInSecs - $iStartTimeInSecs If $asEndDatePart[3] = $asStartDatePart[3] And $iTimeDiff < 0 Then $iMonthDiff = $iMonthDiff - 1 Return $iMonthDiff Case $sType = "y" $iYearDiff = $asEndDatePart[1] - $asStartDatePart[1] If $asEndDatePart[2] < $asStartDatePart[2] Then $iYearDiff = $iYearDiff - 1 If $asEndDatePart[2] = $asStartDatePart[2] And $asEndDatePart[3] < $asStartDatePart[3] Then $iYearDiff = $iYearDiff - 1 $iStartTimeInSecs = $asStartTimePart[1] * 3600 + $asStartTimePart[2] * 60 + $asStartTimePart[3] $iEndTimeInSecs = $asEndTimePart[1] * 3600 + $asEndTimePart[2] * 60 + $asEndTimePart[3] $iTimeDiff = $iEndTimeInSecs - $iStartTimeInSecs If $asEndDatePart[2] = $asStartDatePart[2] And $asEndDatePart[3] = $asStartDatePart[3] And $iTimeDiff < 0 Then $iYearDiff = $iYearDiff - 1 Return $iYearDiff Case $sType = "w" Return Int($aDaysDiff / 7) Case $sType = "h" Return $aDaysDiff * 24 + Int($iTimeDiff / 3600) Case $sType = "n" Return $aDaysDiff * 24 * 60 + Int($iTimeDiff / 60) Case $sType = "s" Return $aDaysDiff * 24 * 60 * 60 + $iTimeDiff EndSelect EndFunc Func _DateIsLeapYear($iYear) If StringIsInt($iYear) Then Select Case Mod($iYear, 4) = 0 And Mod($iYear, 100) <> 0 Return 1 Case Mod($iYear, 400) = 0 Return 1 Case Else Return 0 EndSelect EndIf Return SetError(1, 0, 0) EndFunc Func __DateIsMonth($iNumber) $iNumber = Int($iNumber) Return $iNumber >= 1 And $iNumber <= 12 EndFunc Func _DateIsValid($sDate) Local $asDatePart[4], $asTimePart[4] _DateTimeSplit($sDate, $asDatePart, $asTimePart) If Not StringIsInt($asDatePart[1]) Then Return 0 If Not StringIsInt($asDatePart[2]) Then Return 0 If Not StringIsInt($asDatePart[3]) Then Return 0 $asDatePart[1] = Int($asDatePart[1]) $asDatePart[2] = Int($asDatePart[2]) $asDatePart[3] = Int($asDatePart[3]) Local $iNumDays = _DaysInMonth($asDatePart[1]) If $asDatePart[1] < 1000 Or $asDatePart[1] > 2999 Then Return 0 If $asDatePart[2] < 1 Or $asDatePart[2] > 12 Then Return 0 If $asDatePart[3] < 1 Or $asDatePart[3] > $iNumDays[$asDatePart[2]] Then Return 0 If $asTimePart[0] < 1 Then Return 1 If $asTimePart[0] < 2 Then Return 0 If $asTimePart[0] = 2 Then $asTimePart[3] = "00" If Not StringIsInt($asTimePart[1]) Then Return 0 If Not StringIsInt($asTimePart[2]) Then Return 0 If Not StringIsInt($asTimePart[3]) Then Return 0 $asTimePart[1] = Int($asTimePart[1]) $asTimePart[2] = Int($asTimePart[2]) $asTimePart[3] = Int($asTimePart[3]) If $asTimePart[1] < 0 Or $asTimePart[1] > 23 Then Return 0 If $asTimePart[2] < 0 Or $asTimePart[2] > 59 Then Return 0 If $asTimePart[3] < 0 Or $asTimePart[3] > 59 Then Return 0 Return 1 EndFunc Func __DateIsYear($iNumber) Return StringLen($iNumber) = 4 EndFunc Func _DateLastWeekdayNum($iWeekdayNum) Select Case Not StringIsInt($iWeekdayNum) Return SetError(1, 0, 0) Case $iWeekdayNum < 1 Or $iWeekdayNum > 7 Return SetError(2, 0, 0) Case Else Local $iLastWeekdayNum If $iWeekdayNum = 1 Then $iLastWeekdayNum = 7 Else $iLastWeekdayNum = $iWeekdayNum - 1 EndIf Return $iLastWeekdayNum EndSelect EndFunc Func _DateLastMonthNum($iMonthNum) Select Case Not StringIsInt($iMonthNum) Return SetError(1, 0, 0) Case Not __DateIsMonth($iMonthNum) Return SetError(2, 0, 0) Case Else Local $iLastMonthNum If $iMonthNum = 1 Then $iLastMonthNum = 12 Else $iLastMonthNum = $iMonthNum - 1 EndIf $iLastMonthNum = StringFormat("%02d", $iLastMonthNum) Return $iLastMonthNum EndSelect EndFunc Func _DateLastMonthYear($iMonthNum, $iYear) Select Case Not StringIsInt($iMonthNum) Or Not StringIsInt($iYear) Return SetError(1, 0, 0) Case Not __DateIsMonth($iMonthNum) Return SetError(2, 0, 0) Case Else Local $iLastYear If $iMonthNum = 1 Then $iLastYear = $iYear - 1 Else $iLastYear = $iYear EndIf $iLastYear = StringFormat("%04d", $iLastYear) Return $iLastYear EndSelect EndFunc Func _DateNextWeekdayNum($iWeekdayNum) Select Case Not StringIsInt($iWeekdayNum) Return SetError(1, 0, 0) Case $iWeekdayNum < 1 Or $iWeekdayNum > 7 Return SetError(2, 0, 0) Case Else Local $iNextWeekdayNum If $iWeekdayNum = 7 Then $iNextWeekdayNum = 1 Else $iNextWeekdayNum = $iWeekdayNum + 1 EndIf Return $iNextWeekdayNum EndSelect EndFunc Func _DateNextMonthNum($iMonthNum) Select Case Not StringIsInt($iMonthNum) Return SetError(1, 0, 0) Case Not __DateIsMonth($iMonthNum) Return SetError(2, 0, 0) Case Else Local $iNextMonthNum If $iMonthNum = 12 Then $iNextMonthNum = 1 Else $iNextMonthNum = $iMonthNum + 1 EndIf $iNextMonthNum = StringFormat("%02d", $iNextMonthNum) Return $iNextMonthNum EndSelect EndFunc Func _DateNextMonthYear($iMonthNum, $iYear) Select Case Not StringIsInt($iMonthNum) Or Not StringIsInt($iYear) Return SetError(1, 0, 0) Case Not __DateIsMonth($iMonthNum) Return SetError(2, 0, 0) Case Else Local $iNextYear If $iMonthNum = 12 Then $iNextYear = $iYear + 1 Else $iNextYear = $iYear EndIf $iNextYear = StringFormat("%04d", $iNextYear) Return $iNextYear EndSelect EndFunc Func _DateTimeFormat($sDate, $sType) Local $asDatePart[4], $asTimePart[4] Local $sTempDate = "", $sTempTime = "" Local $sAM, $sPM, $sTempString = "" If Not _DateIsValid($sDate) Then Return SetError(1, 0, "") EndIf If $sType < 0 Or $sType > 5 Or Not IsInt($sType) Then Return SetError(2, 0, "") EndIf _DateTimeSplit($sDate, $asDatePart, $asTimePart) Switch $sType Case 0 $sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_SSHORTDATE) If Not @error And Not ($sTempString = '') Then $sTempDate = $sTempString Else $sTempDate = "M/d/yyyy" EndIf If $asTimePart[0] > 1 Then $sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_STIMEFORMAT) If Not @error And Not ($sTempString = '') Then $sTempTime = $sTempString Else $sTempTime = "h:mm:ss tt" EndIf EndIf Case 1 $sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_SLONGDATE) If Not @error And Not ($sTempString = '') Then $sTempDate = $sTempString Else $sTempDate = "dddd, MMMM dd, yyyy" EndIf Case 2 $sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_SSHORTDATE) If Not @error And Not ($sTempString = '') Then $sTempDate = $sTempString Else $sTempDate = "M/d/yyyy" EndIf Case 3 If $asTimePart[0] > 1 Then $sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_STIMEFORMAT) If Not @error And Not ($sTempString = '') Then $sTempTime = $sTempString Else $sTempTime = "h:mm:ss tt" EndIf EndIf Case 4 If $asTimePart[0] > 1 Then $sTempTime = "hh:mm" EndIf Case 5 If $asTimePart[0] > 1 Then $sTempTime = "hh:mm:ss" EndIf EndSwitch If $sTempDate <> "" Then $sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_SDATE) If Not @error And Not ($sTempString = '') Then $sTempDate = StringReplace($sTempDate, "/", $sTempString) EndIf Local $iWday = _DateToDayOfWeek($asDatePart[1], $asDatePart[2], $asDatePart[3]) $asDatePart[3] = StringRight("0" & $asDatePart[3], 2) $asDatePart[2] = StringRight("0" & $asDatePart[2], 2) $sTempDate = StringReplace($sTempDate, "d", "@") $sTempDate = StringReplace($sTempDate, "m", "#") $sTempDate = StringReplace($sTempDate, "y", "&") $sTempDate = StringReplace($sTempDate, "@@@@", _DateDayOfWeek($iWday, 0)) $sTempDate = StringReplace($sTempDate, "@@@", _DateDayOfWeek($iWday, 1)) $sTempDate = StringReplace($sTempDate, "@@", $asDatePart[3]) $sTempDate = StringReplace($sTempDate, "@", StringReplace(StringLeft($asDatePart[3], 1), "0", "") & StringRight($asDatePart[3], 1)) $sTempDate = StringReplace($sTempDate, "####", _DateToMonth($asDatePart[2], 0)) $sTempDate = StringReplace($sTempDate, "###", _DateToMonth($asDatePart[2], 1)) $sTempDate = StringReplace($sTempDate, "##", $asDatePart[2]) $sTempDate = StringReplace($sTempDate, "#", StringReplace(StringLeft($asDatePart[2], 1), "0", "") & StringRight($asDatePart[2], 1)) $sTempDate = StringReplace($sTempDate, "&&&&", $asDatePart[1]) $sTempDate = StringReplace($sTempDate, "&&", StringRight($asDatePart[1], 2)) EndIf If $sTempTime <> "" Then $sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_S1159) If Not @error And Not ($sTempString = '') Then $sAM = $sTempString Else $sAM = "AM" EndIf $sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_S2359) If Not @error And Not ($sTempString = '') Then $sPM = $sTempString Else $sPM = "PM" EndIf $sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_STIME) If Not @error And Not ($sTempString = '') Then $sTempTime = StringReplace($sTempTime, ":", $sTempString) EndIf If StringInStr($sTempTime, "tt") Then If $asTimePart[1] < 12 Then $sTempTime = StringReplace($sTempTime, "tt", $sAM) If $asTimePart[1] = 0 Then $asTimePart[1] = 12 Else $sTempTime = StringReplace($sTempTime, "tt", $sPM) If $asTimePart[1] > 12 Then $asTimePart[1] = $asTimePart[1] - 12 EndIf EndIf $asTimePart[1] = StringRight("0" & $asTimePart[1], 2) $asTimePart[2] = StringRight("0" & $asTimePart[2], 2) $asTimePart[3] = StringRight("0" & $asTimePart[3], 2) $sTempTime = StringReplace($sTempTime, "hh", StringFormat("%02d", $asTimePart[1])) $sTempTime = StringReplace($sTempTime, "h", StringReplace(StringLeft($asTimePart[1], 1), "0", "") & StringRight($asTimePart[1], 1)) $sTempTime = StringReplace($sTempTime, "mm", StringFormat("%02d", $asTimePart[2])) $sTempTime = StringReplace($sTempTime, "ss", StringFormat("%02d", $asTimePart[3])) $sTempDate = StringStripWS($sTempDate & " " & $sTempTime, $STR_STRIPLEADING + $STR_STRIPTRAILING) EndIf Return $sTempDate EndFunc Func _DateTimeSplit($sDate, ByRef $aDatePart, ByRef $iTimePart) Local $sDateTime = StringSplit($sDate, " T") If $sDateTime[0] > 0 Then $aDatePart = StringSplit($sDateTime[1], "/-.") If $sDateTime[0] > 1 Then $iTimePart = StringSplit($sDateTime[2], ":") If UBound($iTimePart) < 4 Then ReDim $iTimePart[4] Else Dim $iTimePart[4] EndIf If UBound($aDatePart) < 4 Then ReDim $aDatePart[4] For $x = 1 To 3 If StringIsInt($aDatePart[$x]) Then $aDatePart[$x] = Int($aDatePart[$x]) Else $aDatePart[$x] = -1 EndIf If StringIsInt($iTimePart[$x]) Then $iTimePart[$x] = Int($iTimePart[$x]) Else $iTimePart[$x] = 0 EndIf Next Return 1 EndFunc Func _DateToDayOfWeek($iYear, $iMonth, $iDay) If Not _DateIsValid($iYear & "/" & $iMonth & "/" & $iDay) Then Return SetError(1, 0, "") EndIf Local $i_FactorA = Int((14 - $iMonth) / 12) Local $i_FactorY = $iYear - $i_FactorA Local $i_FactorM = $iMonth + (12 * $i_FactorA) - 2 Local $i_FactorD = Mod($iDay + $i_FactorY + Int($i_FactorY / 4) - Int($i_FactorY / 100) + Int($i_FactorY / 400) + Int((31 * $i_FactorM) / 12), 7) Return $i_FactorD + 1 EndFunc Func _DateToDayOfWeekISO($iYear, $iMonth, $iDay) Local $iDow = _DateToDayOfWeek($iYear, $iMonth, $iDay) If @error Then Return SetError(1, 0, "") EndIf If $iDow >= 2 Then Return $iDow - 1 Return 7 EndFunc Func _DateToDayValue($iYear, $iMonth, $iDay) If Not _DateIsValid(StringFormat("%04d/%02d/%02d", $iYear, $iMonth, $iDay)) Then Return SetError(1, 0, "") EndIf If $iMonth < 3 Then $iMonth = $iMonth + 12 $iYear = $iYear - 1 EndIf Local $i_FactorA = Int($iYear / 100) Local $i_FactorB = Int($i_FactorA / 4) Local $i_FactorC = 2 - $i_FactorA + $i_FactorB Local $i_FactorE = Int(1461 * ($iYear + 4716) / 4) Local $i_FactorF = Int(153 * ($iMonth + 1) / 5) Local $iJulianDate = $i_FactorC + $iDay + $i_FactorE + $i_FactorF - 1524.5 Return $iJulianDate EndFunc Func _DateToMonth($iMonNum, $iFormat = Default) If $iFormat = Default Then $iFormat = 0 $iMonNum = Int($iMonNum) If Not __DateIsMonth($iMonNum) Then Return SetError(1, 0, "") Local $tSYSTEMTIME = DllStructCreate($tagSYSTEMTIME) DllStructSetData($tSYSTEMTIME, "Year", @YEAR) DllStructSetData($tSYSTEMTIME, "Month", $iMonNum) DllStructSetData($tSYSTEMTIME, "Day", 1) Return _WinAPI_GetDateFormat(BitAND($iFormat, $DMW_LOCALE_LONGNAME) ? $LOCALE_USER_DEFAULT : $LOCALE_INVARIANT, $tSYSTEMTIME, 0, BitAND($iFormat, $DMW_SHORTNAME) ? "MMM" : "MMMM") EndFunc Func _DayValueToDate($iJulianDate, ByRef $iYear, ByRef $iMonth, ByRef $iDay) If $iJulianDate < 0 Or Not IsNumber($iJulianDate) Then Return SetError(1, 0, 0) EndIf Local $i_FactorZ = Int($iJulianDate + 0.5) Local $i_FactorW = Int(($i_FactorZ - 1867216.25) / 36524.25) Local $i_FactorX = Int($i_FactorW / 4) Local $i_FactorA = $i_FactorZ + 1 + $i_FactorW - $i_FactorX Local $i_FactorB = $i_FactorA + 1524 Local $i_FactorC = Int(($i_FactorB - 122.1) / 365.25) Local $i_FactorD = Int(365.25 * $i_FactorC) Local $i_FactorE = Int(($i_FactorB - $i_FactorD) / 30.6001) Local $i_FactorF = Int(30.6001 * $i_FactorE) $iDay = $i_FactorB - $i_FactorD - $i_FactorF If $i_FactorE - 1 < 13 Then $iMonth = $i_FactorE - 1 Else $iMonth = $i_FactorE - 13 EndIf If $iMonth < 3 Then $iYear = $i_FactorC - 4715 Else $iYear = $i_FactorC - 4716 EndIf $iYear = StringFormat("%04d", $iYear) $iMonth = StringFormat("%02d", $iMonth) $iDay = StringFormat("%02d", $iDay) Return $iYear & "/" & $iMonth & "/" & $iDay EndFunc Func _Date_JulianDayNo($iYear, $iMonth, $iDay) Local $sFullDate = StringFormat("%04d/%02d/%02d", $iYear, $iMonth, $iDay) If Not _DateIsValid($sFullDate) Then Return SetError(1, 0, "") EndIf Local $iJDay = 0 Local $aiDaysInMonth = _DaysInMonth($iYear) For $iCntr = 1 To $iMonth - 1 $iJDay = $iJDay + $aiDaysInMonth[$iCntr] Next $iJDay = ($iYear * 1000) + ($iJDay + $iDay) Return $iJDay EndFunc Func _JulianToDate($iJDay, $sSep = "/") Local $iYear = Int($iJDay / 1000) Local $iDays = Mod($iJDay, 1000) Local $iMaxDays = 365 If _DateIsLeapYear($iYear) Then $iMaxDays = 366 If $iDays > $iMaxDays Then Return SetError(1, 0, "") EndIf Local $aiDaysInMonth = _DaysInMonth($iYear) Local $iMonth = 1 While $iDays > $aiDaysInMonth[$iMonth] $iDays = $iDays - $aiDaysInMonth[$iMonth] $iMonth = $iMonth + 1 WEnd Return StringFormat("%04d%s%02d%s%02d", $iYear, $sSep, $iMonth, $sSep, $iDays) EndFunc Func _Now() Return _DateTimeFormat(@YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, 0) EndFunc Func _NowCalc() Return @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC EndFunc Func _NowCalcDate() Return @YEAR & "/" & @MON & "/" & @MDAY EndFunc Func _NowDate() Return _DateTimeFormat(@YEAR & "/" & @MON & "/" & @MDAY, 0) EndFunc Func _NowTime($sType = 3) If $sType < 3 Or $sType > 5 Then $sType = 3 Return _DateTimeFormat(@YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC, $sType) EndFunc Func _SetDate($iDay, $iMonth = 0, $iYear = 0) If $iYear = 0 Then $iYear = @YEAR If $iMonth = 0 Then $iMonth = @MON If Not _DateIsValid($iYear & "/" & $iMonth & "/" & $iDay) Then Return 1 Local $tSYSTEMTIME = DllStructCreate($tagSYSTEMTIME) DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tSYSTEMTIME) If @error Then Return SetError(@error, @extended, 0) DllStructSetData($tSYSTEMTIME, "Day", $iDay) If $iMonth > 0 Then DllStructSetData($tSYSTEMTIME, "Month", $iMonth) If $iYear > 0 Then DllStructSetData($tSYSTEMTIME, "Year", $iYear) Local $iReturn = _Date_Time_SetLocalTime($tSYSTEMTIME) If @error Then Return SetError(@error + 10, @extended, 0) Return Int($iReturn) EndFunc Func _SetTime($iHour, $iMinute, $iSecond = 0, $iMSeconds = 0) If $iHour < 0 Or $iHour > 23 Then Return 1 If $iMinute < 0 Or $iMinute > 59 Then Return 1 If $iSecond < 0 Or $iSecond > 59 Then Return 1 If $iMSeconds < 0 Or $iMSeconds > 999 Then Return 1 Local $tSYSTEMTIME = DllStructCreate($tagSYSTEMTIME) DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tSYSTEMTIME) If @error Then Return SetError(@error, @extended, 0) DllStructSetData($tSYSTEMTIME, "Hour", $iHour) DllStructSetData($tSYSTEMTIME, "Minute", $iMinute) If $iSecond > 0 Then DllStructSetData($tSYSTEMTIME, "Second", $iSecond) If $iMSeconds > 0 Then DllStructSetData($tSYSTEMTIME, "MSeconds", $iMSeconds) Local $iReturn = _Date_Time_SetLocalTime($tSYSTEMTIME) If @error Then Return SetError(@error + 10, @extended, 0) Return Int($iReturn) EndFunc Func _TicksToTime($iTicks, ByRef $iHours, ByRef $iMins, ByRef $iSecs) If Number($iTicks) > 0 Then $iTicks = Int($iTicks / 1000) $iHours = Int($iTicks / 3600) $iTicks = Mod($iTicks, 3600) $iMins = Int($iTicks / 60) $iSecs = Mod($iTicks, 60) Return 1 ElseIf Number($iTicks) = 0 Then $iHours = 0 $iTicks = 0 $iMins = 0 $iSecs = 0 Return 1 Else Return SetError(1, 0, 0) EndIf EndFunc Func _TimeToTicks($iHours = @HOUR, $iMins = @MIN, $iSecs = @SEC) If StringIsInt($iHours) And StringIsInt($iMins) And StringIsInt($iSecs) Then Local $iTicks = 1000 * ((3600 * $iHours) + (60 * $iMins) + $iSecs) Return $iTicks Else Return SetError(1, 0, 0) EndIf EndFunc Func _WeekNumberISO($iYear = @YEAR, $iMonth = @MON, $iDay = @MDAY) If $iDay > 31 Or $iDay < 1 Then Return SetError(1, 0, -1) ElseIf Not __DateIsMonth($iMonth) Then Return SetError(2, 0, -1) ElseIf $iYear < 1 Or $iYear > 2999 Then Return SetError(3, 0, -1) EndIf Local $iDow = _DateToDayOfWeekISO($iYear, $iMonth, $iDay) - 1 Local $iDow0101 = _DateToDayOfWeekISO($iYear, 1, 1) - 1 If ($iMonth = 1 And 3 < $iDow0101 And $iDow0101 < 7 - ($iDay - 1)) Then $iDow = $iDow0101 - 1 $iDow0101 = _DateToDayOfWeekISO($iYear - 1, 1, 1) - 1 $iMonth = 12 $iDay = 31 $iYear = $iYear - 1 ElseIf ($iMonth = 12 And 30 - ($iDay - 1) < _DateToDayOfWeekISO($iYear + 1, 1, 1) - 1 And _DateToDayOfWeekISO($iYear + 1, 1, 1) - 1 < 4) Then Return 1 EndIf Return Int((_DateToDayOfWeekISO($iYear, 1, 1) - 1 < 4) + 4 * ($iMonth - 1) + (2 * ($iMonth - 1) + ($iDay - 1) + $iDow0101 - $iDow + 6) * 36 / 256) EndFunc Func _WeekNumber($iYear = @YEAR, $iMonth = @MON, $iDay = @MDAY, $iWeekStart = 1) If $iDay > 31 Or $iDay < 1 Then Return SetError(1, 0, -1) ElseIf Not __DateIsMonth($iMonth) Then Return SetError(3, 0, -1) ElseIf $iYear < 1 Or $iYear > 2999 Then Return SetError(4, 0, -1) ElseIf $iWeekStart < 1 Or $iWeekStart > 2 Then Return SetError(2, 0, -1) EndIf Local $iStartWeek1, $iEndWeek1 Local $iDow0101 = _DateToDayOfWeekISO($iYear, 1, 1) Local $iDate = $iYear & '/' & $iMonth & '/' & $iDay If $iWeekStart = 1 Then If $iDow0101 = 6 Then $iStartWeek1 = 0 Else $iStartWeek1 = -1 * $iDow0101 - 1 EndIf $iEndWeek1 = $iStartWeek1 + 6 Else $iStartWeek1 = $iDow0101 * -1 $iEndWeek1 = $iStartWeek1 + 6 EndIf Local $iStartWeek1ny Local $iEndWeek1Date = _DateAdd('d', $iEndWeek1, $iYear & '/01/01') Local $iDow0101ny = _DateToDayOfWeekISO($iYear + 1, 1, 1) If $iWeekStart = 1 Then If $iDow0101ny = 6 Then $iStartWeek1ny = 0 Else $iStartWeek1ny = -1 * $iDow0101ny - 1 EndIf Else $iStartWeek1ny = $iDow0101ny * -1 EndIf Local $iStartWeek1Dateny = _DateAdd('d', $iStartWeek1ny, $iYear + 1 & '/01/01') Local $iCurrDateDiff = _DateDiff('d', $iEndWeek1Date, $iDate) - 1 Local $iCurrDateDiffny = _DateDiff('d', $iStartWeek1Dateny, $iDate) If $iCurrDateDiff >= 0 And $iCurrDateDiffny < 0 Then Return 2 + Int($iCurrDateDiff / 7) If $iCurrDateDiff < 0 Or $iCurrDateDiffny >= 0 Then Return 1 EndFunc Func _DaysInMonth($iYear) Local $aDays = [12, 31, (_DateIsLeapYear($iYear) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] Return $aDays EndFunc Func __Date_Time_CloneSystemTime($pSystemTime) Local $tSystemTime1 = DllStructCreate($tagSYSTEMTIME, $pSystemTime) Local $tSystemTime2 = DllStructCreate($tagSYSTEMTIME) DllStructSetData($tSystemTime2, "Month", DllStructGetData($tSystemTime1, "Month")) DllStructSetData($tSystemTime2, "Day", DllStructGetData($tSystemTime1, "Day")) DllStructSetData($tSystemTime2, "Year", DllStructGetData($tSystemTime1, "Year")) DllStructSetData($tSystemTime2, "Hour", DllStructGetData($tSystemTime1, "Hour")) DllStructSetData($tSystemTime2, "Minute", DllStructGetData($tSystemTime1, "Minute")) DllStructSetData($tSystemTime2, "Second", DllStructGetData($tSystemTime1, "Second")) DllStructSetData($tSystemTime2, "MSeconds", DllStructGetData($tSystemTime1, "MSeconds")) DllStructSetData($tSystemTime2, "DOW", DllStructGetData($tSystemTime1, "DOW")) Return $tSystemTime2 EndFunc Func _Date_Time_CompareFileTime($tFileTime1, $tFileTime2) Local $aResult = DllCall("kernel32.dll", "long", "CompareFileTime", "struct*", $tFileTime1, "struct*", $tFileTime2) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _Date_Time_DOSDateTimeToFileTime($iFatDate, $iFatTime) Local $tTime = DllStructCreate($tagFILETIME) Local $aResult = DllCall("kernel32.dll", "bool", "DosDateTimeToFileTime", "word", $iFatDate, "word", $iFatTime, "struct*", $tTime) If @error Then Return SetError(@error, @extended, 0) Return SetExtended($aResult[0], $tTime) EndFunc Func _Date_Time_DOSDateToArray($iDosDate) Local $aDate[3] $aDate[0] = BitAND($iDosDate, 0x1F) $aDate[1] = BitAND(BitShift($iDosDate, 5), 0x0F) $aDate[2] = BitAND(BitShift($iDosDate, 9), 0x3F) + 1980 Return $aDate EndFunc Func _Date_Time_DOSDateTimeToArray($iDosDate, $iDosTime) Local $aDate[6] $aDate[0] = BitAND($iDosDate, 0x1F) $aDate[1] = BitAND(BitShift($iDosDate, 5), 0x0F) $aDate[2] = BitAND(BitShift($iDosDate, 9), 0x3F) + 1980 $aDate[5] = BitAND($iDosTime, 0x1F) * 2 $aDate[4] = BitAND(BitShift($iDosTime, 5), 0x3F) $aDate[3] = BitAND(BitShift($iDosTime, 11), 0x1F) Return $aDate EndFunc Func _Date_Time_DOSDateTimeToStr($iDosDate, $iDosTime) Local $aDate = _Date_Time_DOSDateTimeToArray($iDosDate, $iDosTime) Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $aDate[0], $aDate[1], $aDate[2], $aDate[3], $aDate[4], $aDate[5]) EndFunc Func _Date_Time_DOSDateToStr($iDosDate) Local $aDate = _Date_Time_DOSDateToArray($iDosDate) Return StringFormat("%02d/%02d/%04d", $aDate[0], $aDate[1], $aDate[2]) EndFunc Func _Date_Time_DOSTimeToArray($iDosTime) Local $aTime[3] $aTime[2] = BitAND($iDosTime, 0x1F) * 2 $aTime[1] = BitAND(BitShift($iDosTime, 5), 0x3F) $aTime[0] = BitAND(BitShift($iDosTime, 11), 0x1F) Return $aTime EndFunc Func _Date_Time_DOSTimeToStr($iDosTime) Local $aTime = _Date_Time_DOSTimeToArray($iDosTime) Return StringFormat("%02d:%02d:%02d", $aTime[0], $aTime[1], $aTime[2]) EndFunc Func _Date_Time_EncodeFileTime($iMonth, $iDay, $iYear, $iHour = 0, $iMinute = 0, $iSecond = 0, $iMSeconds = 0) Local $tSYSTEMTIME = _Date_Time_EncodeSystemTime($iMonth, $iDay, $iYear, $iHour, $iMinute, $iSecond, $iMSeconds) Return _Date_Time_SystemTimeToFileTime($tSYSTEMTIME) EndFunc Func _Date_Time_EncodeSystemTime($iMonth, $iDay, $iYear, $iHour = 0, $iMinute = 0, $iSecond = 0, $iMSeconds = 0) Local $tSYSTEMTIME = DllStructCreate($tagSYSTEMTIME) DllStructSetData($tSYSTEMTIME, "Month", $iMonth) DllStructSetData($tSYSTEMTIME, "Day", $iDay) DllStructSetData($tSYSTEMTIME, "Year", $iYear) DllStructSetData($tSYSTEMTIME, "Hour", $iHour) DllStructSetData($tSYSTEMTIME, "Minute", $iMinute) DllStructSetData($tSYSTEMTIME, "Second", $iSecond) DllStructSetData($tSYSTEMTIME, "MSeconds", $iMSeconds) Return $tSYSTEMTIME EndFunc Func _Date_Time_FileTimeToArray(ByRef $tFileTime) If ((DllStructGetData($tFileTime, 1) + DllStructGetData($tFileTime, 2)) = 0) Then Return SetError(10, 0, 0) Local $tSYSTEMTIME = _Date_Time_FileTimeToSystemTime($tFileTime) If @error Then Return SetError(@error, @extended, 0) Return _Date_Time_SystemTimeToArray($tSYSTEMTIME) EndFunc Func _Date_Time_FileTimeToStr(ByRef $tFileTime, $iFmt = 0) Local $aDate = _Date_Time_FileTimeToArray($tFileTime) If @error Then Return SetError(@error, @extended, "") If $iFmt Then Return StringFormat("%04d/%02d/%02d %02d:%02d:%02d", $aDate[2], $aDate[0], $aDate[1], $aDate[3], $aDate[4], $aDate[5]) Else Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $aDate[0], $aDate[1], $aDate[2], $aDate[3], $aDate[4], $aDate[5]) EndIf EndFunc Func _Date_Time_FileTimeToDOSDateTime($tFileTime) Local $aDate[2] Local $aResult = DllCall("kernel32.dll", "bool", "FileTimeToDosDateTime", "struct*", $tFileTime, "word*", 0, "word*", 0) If @error Then Return SetError(@error, @extended, $aDate) $aDate[0] = $aResult[2] $aDate[1] = $aResult[3] Return SetExtended($aResult[0], $aDate) EndFunc Func _Date_Time_FileTimeToLocalFileTime($tFileTime) Local $tLocal = DllStructCreate($tagFILETIME) Local $aResult = DllCall("kernel32.dll", "bool", "FileTimeToLocalFileTime", "struct*", $tFileTime, "struct*", $tLocal) If @error Then Return SetError(@error, @extended, 0) Return SetExtended($aResult[0], $tLocal) EndFunc Func _Date_Time_FileTimeToSystemTime($tFileTime) Local $tSystTime = DllStructCreate($tagSYSTEMTIME) Local $aResult = DllCall("kernel32.dll", "bool", "FileTimeToSystemTime", "struct*", $tFileTime, "struct*", $tSystTime) If @error Then Return SetError(@error, @extended, 0) Return SetExtended($aResult[0], $tSystTime) EndFunc Func _Date_Time_GetFileTime($hFile) Local $aDate[3] $aDate[0] = DllStructCreate($tagFILETIME) $aDate[1] = DllStructCreate($tagFILETIME) $aDate[2] = DllStructCreate($tagFILETIME) Local $aResult = DllCall("kernel32.dll", "bool", "GetFileTime", "handle", $hFile, "struct*", $aDate[0], "struct*", $aDate[1], "struct*", $aDate[2]) If @error Then Return SetError(@error, @extended, 0) Return SetExtended($aResult[0], $aDate) EndFunc Func _Date_Time_GetLocalTime() Local $tSystTime = DllStructCreate($tagSYSTEMTIME) DllCall("kernel32.dll", "none", "GetLocalTime", "struct*", $tSystTime) If @error Then Return SetError(@error, @extended, 0) Return $tSystTime EndFunc Func _Date_Time_GetSystemTime() Local $tSystTime = DllStructCreate($tagSYSTEMTIME) DllCall("kernel32.dll", "none", "GetSystemTime", "struct*", $tSystTime) If @error Then Return SetError(@error, @extended, 0) Return $tSystTime EndFunc Func _Date_Time_GetSystemTimeAdjustment() Local $aInfo[3] Local $aResult = DllCall("kernel32.dll", "bool", "GetSystemTimeAdjustment", "dword*", 0, "dword*", 0, "bool*", 0) If @error Then Return SetError(@error, @extended, 0) $aInfo[0] = $aResult[1] $aInfo[1] = $aResult[2] $aInfo[2] = $aResult[3] <> 0 Return SetExtended($aResult[0], $aInfo) EndFunc Func _Date_Time_GetSystemTimeAsFileTime() Local $tFileTime = DllStructCreate($tagFILETIME) DllCall("kernel32.dll", "none", "GetSystemTimeAsFileTime", "struct*", $tFileTime) If @error Then Return SetError(@error, @extended, 0) Return $tFileTime EndFunc Func _Date_Time_GetSystemTimes() Local $aInfo[3] $aInfo[0] = DllStructCreate($tagFILETIME) $aInfo[1] = DllStructCreate($tagFILETIME) $aInfo[2] = DllStructCreate($tagFILETIME) Local $aResult = DllCall("kernel32.dll", "bool", "GetSystemTimes", "struct*", $aInfo[0], "struct*", $aInfo[1], "struct*", $aInfo[2]) If @error Then Return SetError(@error, @extended, 0) Return SetExtended($aResult[0], $aInfo) EndFunc Func _Date_Time_GetTickCount() Local $aResult = DllCall("kernel32.dll", "dword", "GetTickCount") If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _Date_Time_GetTimeZoneInformation() Local $tTimeZone = DllStructCreate($tagTIME_ZONE_INFORMATION) Local $aResult = DllCall("kernel32.dll", "dword", "GetTimeZoneInformation", "struct*", $tTimeZone) If @error Or $aResult[0] = -1 Then Return SetError(@error, @extended, 0) Local $aInfo[8] $aInfo[0] = $aResult[0] $aInfo[1] = DllStructGetData($tTimeZone, "Bias") $aInfo[2] = DllStructGetData($tTimeZone, "StdName") $aInfo[3] = __Date_Time_CloneSystemTime(DllStructGetPtr($tTimeZone, "StdDate")) $aInfo[4] = DllStructGetData($tTimeZone, "StdBias") $aInfo[5] = DllStructGetData($tTimeZone, "DayName") $aInfo[6] = __Date_Time_CloneSystemTime(DllStructGetPtr($tTimeZone, "DayDate")) $aInfo[7] = DllStructGetData($tTimeZone, "DayBias") Return $aInfo EndFunc Func _Date_Time_LocalFileTimeToFileTime($tLocalTime) Local $tFileTime = DllStructCreate($tagFILETIME) Local $aResult = DllCall("kernel32.dll", "bool", "LocalFileTimeToFileTime", "struct*", $tLocalTime, "struct*", $tFileTime) If @error Then Return SetError(@error, @extended, 0) Return SetExtended($aResult[0], $tFileTime) EndFunc Func _Date_Time_SetFileTime($hFile, $tCreateTime, $tLastAccess, $tLastWrite) Local $aResult = DllCall("kernel32.dll", "bool", "SetFileTime", "handle", $hFile, "struct*", $tCreateTime, "struct*", $tLastAccess, "struct*", $tLastWrite) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _Date_Time_SetLocalTime($tSYSTEMTIME) Local $aResult = DllCall("kernel32.dll", "bool", "SetLocalTime", "struct*", $tSYSTEMTIME) If @error Or Not $aResult[0] Then Return SetError(@error + 10, @extended, False) $aResult = DllCall("kernel32.dll", "bool", "SetLocalTime", "struct*", $tSYSTEMTIME) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _Date_Time_SetSystemTime($tSYSTEMTIME) Local $aResult = DllCall("kernel32.dll", "bool", "SetSystemTime", "struct*", $tSYSTEMTIME) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _Date_Time_SetSystemTimeAdjustment($iAdjustment, $bDisabled) Local $hToken = _Security__OpenThreadTokenEx(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY)) If @error Then Return SetError(@error + 10, @extended, False) _Security__SetPrivilege($hToken, "SeSystemtimePrivilege", True) Local $iError = @error Local $iLastError = @extended Local $bRet = False If Not @error Then Local $aResult = DllCall("kernel32.dll", "bool", "SetSystemTimeAdjustment", "dword", $iAdjustment, "bool", $bDisabled) If @error Then $iError = @error $iLastError = @extended ElseIf $aResult[0] Then $bRet = True Else $iError = 20 $iLastError = _WinAPI_GetLastError() EndIf _Security__SetPrivilege($hToken, "SeSystemtimePrivilege", False) If Not $iError And @error Then $iError = 22 EndIf _WinAPI_CloseHandle($hToken) Return SetError($iError, $iLastError, $bRet) EndFunc Func _Date_Time_SetTimeZoneInformation($iBias, $sStdName, $tStdDate, $iStdBias, $sDayName, $tDayDate, $iDayBias) Local $tZoneInfo = DllStructCreate($tagTIME_ZONE_INFORMATION) DllStructSetData($tZoneInfo, "Bias", $iBias) DllStructSetData($tZoneInfo, "StdName", $sStdName) _MemMoveMemory($tStdDate, DllStructGetPtr($tZoneInfo, "StdDate"), DllStructGetSize($tStdDate)) DllStructSetData($tZoneInfo, "StdBias", $iStdBias) DllStructSetData($tZoneInfo, "DayName", $sDayName) _MemMoveMemory($tDayDate, DllStructGetPtr($tZoneInfo, "DayDate"), DllStructGetSize($tDayDate)) DllStructSetData($tZoneInfo, "DayBias", $iDayBias) Local $hToken = _Security__OpenThreadTokenEx(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY)) If @error Then Return SetError(@error + 10, @extended, False) _Security__SetPrivilege($hToken, "SeTimeZonePrivilege", True) Local $iError = @error Local $iLastError = @extended Local $bRet = False If Not @error Then Local $aResult = DllCall("kernel32.dll", "bool", "SetTimeZoneInformation", "struct*", $tZoneInfo) If @error Then $iError = @error $iLastError = @extended ElseIf $aResult[0] Then $iLastError = 0 $bRet = True Else $iError = 20 $iLastError = _WinAPI_GetLastError() EndIf _Security__SetPrivilege($hToken, "SeTimeZonePrivilege", False) If Not $iError And @error Then $iError = 22 EndIf _WinAPI_CloseHandle($hToken) Return SetError($iError, $iLastError, $bRet) EndFunc Func _Date_Time_SystemTimeToArray(ByRef $tSYSTEMTIME) Local $aInfo[8] $aInfo[0] = DllStructGetData($tSYSTEMTIME, "Month") $aInfo[1] = DllStructGetData($tSYSTEMTIME, "Day") $aInfo[2] = DllStructGetData($tSYSTEMTIME, "Year") $aInfo[3] = DllStructGetData($tSYSTEMTIME, "Hour") $aInfo[4] = DllStructGetData($tSYSTEMTIME, "Minute") $aInfo[5] = DllStructGetData($tSYSTEMTIME, "Second") $aInfo[6] = DllStructGetData($tSYSTEMTIME, "MSeconds") $aInfo[7] = DllStructGetData($tSYSTEMTIME, "DOW") Return $aInfo EndFunc Func _Date_Time_SystemTimeToDateStr(ByRef $tSYSTEMTIME, $iFmt = 0) Local $aInfo = _Date_Time_SystemTimeToArray($tSYSTEMTIME) If @error Then Return SetError(@error, @extended, "") If $iFmt Then Return StringFormat("%04d/%02d/%02d", $aInfo[2], $aInfo[0], $aInfo[1]) Else Return StringFormat("%02d/%02d/%04d", $aInfo[0], $aInfo[1], $aInfo[2]) EndIf EndFunc Func _Date_Time_SystemTimeToDateTimeStr(ByRef $tSYSTEMTIME, $iFmt = 0) Local $aInfo = _Date_Time_SystemTimeToArray($tSYSTEMTIME) If @error Then Return SetError(@error, @extended, "") If $iFmt Then Return StringFormat("%04d/%02d/%02d %02d:%02d:%02d", $aInfo[2], $aInfo[0], $aInfo[1], $aInfo[3], $aInfo[4], $aInfo[5]) Else Return StringFormat("%02d/%02d/%04d %02d:%02d:%02d", $aInfo[0], $aInfo[1], $aInfo[2], $aInfo[3], $aInfo[4], $aInfo[5]) EndIf EndFunc Func _Date_Time_SystemTimeToFileTime($tSYSTEMTIME) Local $tFileTime = DllStructCreate($tagFILETIME) Local $aResult = DllCall("kernel32.dll", "bool", "SystemTimeToFileTime", "struct*", $tSYSTEMTIME, "struct*", $tFileTime) If @error Then Return SetError(@error, @extended, 0) Return SetExtended($aResult[0], $tFileTime) EndFunc Func _Date_Time_SystemTimeToTimeStr(ByRef $tSYSTEMTIME) Local $aInfo = _Date_Time_SystemTimeToArray($tSYSTEMTIME) Return StringFormat("%02d:%02d:%02d", $aInfo[3], $aInfo[4], $aInfo[5]) EndFunc Func _Date_Time_SystemTimeToTzSpecificLocalTime($tUTC, $tTimeZone = 0) Local $tLocalTime = DllStructCreate($tagSYSTEMTIME) Local $aResult = DllCall("kernel32.dll", "bool", "SystemTimeToTzSpecificLocalTime", "struct*", $tTimeZone, "struct*", $tUTC, "struct*", $tLocalTime) If @error Then Return SetError(@error, @extended, 0) Return SetExtended($aResult[0], $tLocalTime) EndFunc Func _Date_Time_TzSpecificLocalTimeToSystemTime($tLocalTime, $tTimeZone = 0) Local $tUTC = DllStructCreate($tagSYSTEMTIME) Local $aResult = DllCall("kernel32.dll", "bool", "TzSpecificLocalTimeToSystemTime", "struct*", $tTimeZone, "struct*", $tLocalTime, "struct*", $tUTC) If @error Then Return SetError(@error, @extended, 0) Return SetExtended($aResult[0], $tUTC) EndFunc #Region Global Variables and Constants #EndRegion Global Variables and Constants #Region Functions list #EndRegion Functions list #Region Public Functions Func _WinAPI_CharToOem($sStr) Local $aRet = DllCall('user32.dll', 'bool', 'CharToOemW', 'wstr', $sStr, 'wstr', '') If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, '') Return $aRet[2] EndFunc Func _WinAPI_ClientToScreen($hWnd, ByRef $tPoint) Local $aRet = DllCall("user32.dll", "bool", "ClientToScreen", "hwnd", $hWnd, "struct*", $tPoint) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return $tPoint EndFunc Func _WinAPI_DWordToFloat($iValue) Local $tDWord = DllStructCreate('dword') Local $tFloat = DllStructCreate('float', DllStructGetPtr($tDWord)) DllStructSetData($tDWord, 1, $iValue) Return DllStructGetData($tFloat, 1) EndFunc Func _WinAPI_DWordToInt($iValue) Local $tData = DllStructCreate('int') DllStructSetData($tData, 1, $iValue) Return DllStructGetData($tData, 1) EndFunc Func _WinAPI_FloatToDWord($iValue) Local $tFloat = DllStructCreate('float') Local $tDWord = DllStructCreate('dword', DllStructGetPtr($tFloat)) DllStructSetData($tFloat, 1, $iValue) Return DllStructGetData($tDWord, 1) EndFunc Func _WinAPI_FloatToInt($nFloat) Local $tFloat = DllStructCreate("float") Local $tInt = DllStructCreate("int", DllStructGetPtr($tFloat)) DllStructSetData($tFloat, 1, $nFloat) Return DllStructGetData($tInt, 1) EndFunc Func _WinAPI_GetXYFromPoint(ByRef $tPoint, ByRef $iX, ByRef $iY) $iX = DllStructGetData($tPoint, "X") $iY = DllStructGetData($tPoint, "Y") EndFunc Func _WinAPI_GUIDFromString($sGUID) Local $tGUID = DllStructCreate($tagGUID) _WinAPI_GUIDFromStringEx($sGUID, $tGUID) If @error Then Return SetError(@error + 10, @extended, 0) Return $tGUID EndFunc Func _WinAPI_GUIDFromStringEx($sGUID, $tGUID) Local $aResult = DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $sGUID, "struct*", $tGUID) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_HashData($pMemory, $iSize, $iLength = 32) If ($iLength <= 0) Or ($iLength > 256) Then Return SetError(11, 0, 0) Local $tData = DllStructCreate('byte[' & $iLength & ']') Local $aRet = DllCall('shlwapi.dll', 'uint', 'HashData', 'struct*', $pMemory, 'dword', $iSize, 'struct*', $tData, 'dword', $iLength) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return DllStructGetData($tData, 1) EndFunc Func _WinAPI_HashString($sString, $bCaseSensitive = True, $iLength = 32) Local $iLengthS = StringLen($sString) If Not $iLengthS Or ($iLength > 256) Then Return SetError(12, 0, 0) Local $tString = DllStructCreate('wchar[' & ($iLengthS + 1) & ']') If Not $bCaseSensitive Then $sString = StringLower($sString) EndIf DllStructSetData($tString, 1, $sString) Local $sHash = _WinAPI_HashData($tString, 2 * $iLengthS, $iLength) If @error Then Return SetError(@error, @extended, 0) Return $sHash EndFunc Func _WinAPI_HiByte($iValue) Return BitAND(BitShift($iValue, 8), 0xFF) EndFunc Func _WinAPI_HiDWord($iValue) Local $tInt64 = DllStructCreate('int64') Local $tQWord = DllStructCreate('dword;dword', DllStructGetPtr($tInt64)) DllStructSetData($tInt64, 1, $iValue) Return DllStructGetData($tQWord, 2) EndFunc Func _WinAPI_HiWord($iLong) Return BitShift($iLong, 16) EndFunc Func _WinAPI_IntToDWord($iValue) Local $tData = DllStructCreate('dword') DllStructSetData($tData, 1, $iValue) Return DllStructGetData($tData, 1) EndFunc Func _WinAPI_IntToFloat($iInt) Local $tInt = DllStructCreate("int") Local $tFloat = DllStructCreate("float", DllStructGetPtr($tInt)) DllStructSetData($tInt, 1, $iInt) Return DllStructGetData($tFloat, 1) EndFunc Func _WinAPI_LoByte($iValue) Return BitAND($iValue, 0xFF) EndFunc Func _WinAPI_LoDWord($iValue) Local $tInt64 = DllStructCreate('int64') Local $tQWord = DllStructCreate('dword;dword', DllStructGetPtr($tInt64)) DllStructSetData($tInt64, 1, $iValue) Return DllStructGetData($tQWord, 1) EndFunc Func _WinAPI_LoWord($iLong) Return BitAND($iLong, 0xFFFF) EndFunc Func _WinAPI_LongMid($iValue, $iStart, $iCount) Return BitAND(BitShift($iValue, $iStart), BitOR(BitShift(BitShift(0x7FFFFFFF, 32 - ($iCount + 1)), 1), BitShift(1, -($iCount - 1)))) EndFunc Func _WinAPI_MAKELANGID($iLngIDPrimary, $iLngIDSub) Return BitOR(BitShift($iLngIDSub, -10), $iLngIDPrimary) EndFunc Func _WinAPI_MAKELCID($iLngID, $iSortID) Return BitOR(BitShift($iSortID, -16), $iLngID) EndFunc Func _WinAPI_MakeLong($iLo, $iHi) Return BitOR(BitShift($iHi, -16), BitAND($iLo, 0xFFFF)) EndFunc Func _WinAPI_MakeQWord($iLoDWORD, $iHiDWORD) Local $tInt64 = DllStructCreate("uint64") Local $tDwords = DllStructCreate("dword;dword", DllStructGetPtr($tInt64)) DllStructSetData($tDwords, 1, $iLoDWORD) DllStructSetData($tDwords, 2, $iHiDWORD) Return DllStructGetData($tInt64, 1) EndFunc Func _WinAPI_MakeWord($iLo, $iHi) Local $tWord = DllStructCreate('ushort') Local $tByte = DllStructCreate('byte;byte', DllStructGetPtr($tWord)) DllStructSetData($tByte, 1, $iHi) DllStructSetData($tByte, 2, $iLo) Return DllStructGetData($tWord, 1) EndFunc Func _WinAPI_MultiByteToWideChar($vText, $iCodePage = 0, $iFlags = 0, $bRetString = False) Local $sTextType = "str" If Not IsString($vText) Then $sTextType = "struct*" Local $aResult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $iCodePage, "dword", $iFlags, $sTextType, $vText, "int", -1, "ptr", 0, "int", 0) If @error Or Not $aResult[0] Then Return SetError(@error + 10, @extended, 0) Local $iOut = $aResult[0] Local $tOut = DllStructCreate("wchar[" & $iOut & "]") $aResult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $iCodePage, "dword", $iFlags, $sTextType, $vText, "int", -1, "struct*", $tOut, "int", $iOut) If @error Or Not $aResult[0] Then Return SetError(@error + 20, @extended, 0) If $bRetString Then Return DllStructGetData($tOut, 1) Return $tOut EndFunc Func _WinAPI_MultiByteToWideCharEx($sText, $pText, $iCodePage = 0, $iFlags = 0) Local $aResult = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "uint", $iCodePage, "dword", $iFlags, "STR", $sText, "int", -1, "struct*", $pText, "int", (StringLen($sText) + 1) * 2) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_OemToChar($sStr) Local $aRet = DllCall('user32.dll', 'bool', 'OemToChar', 'str', $sStr, 'str', '') If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, '') Return $aRet[2] EndFunc Func _WinAPI_PointFromRect(ByRef $tRECT, $bCenter = True) Local $iX1 = DllStructGetData($tRECT, "Left") Local $iY1 = DllStructGetData($tRECT, "Top") Local $iX2 = DllStructGetData($tRECT, "Right") Local $iY2 = DllStructGetData($tRECT, "Bottom") If $bCenter Then $iX1 = $iX1 + (($iX2 - $iX1) / 2) $iY1 = $iY1 + (($iY2 - $iY1) / 2) EndIf Local $tPoint = DllStructCreate($tagPOINT) DllStructSetData($tPoint, "X", $iX1) DllStructSetData($tPoint, "Y", $iY1) Return $tPoint EndFunc Func _WinAPI_PrimaryLangId($iLngID) Return BitAND($iLngID, 0x3FF) EndFunc Func _WinAPI_ScreenToClient($hWnd, ByRef $tPoint) Local $aResult = DllCall("user32.dll", "bool", "ScreenToClient", "hwnd", $hWnd, "struct*", $tPoint) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_ShortToWord($iValue) Return BitAND($iValue, 0x0000FFFF) EndFunc Func _WinAPI_StrFormatByteSize($iSize) Local $aRet = DllCall('shlwapi.dll', 'ptr', 'StrFormatByteSizeW', 'int64', $iSize, 'wstr', '', 'uint', 1024) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, '') Return $aRet[2] EndFunc Func _WinAPI_StrFormatByteSizeEx($iSize) Local $aSymbol = DllCall('kernel32.dll', 'int', 'GetLocaleInfoW', 'dword', 0x0400, 'dword', 0x000F, 'wstr', '', 'int', 2048) If @error Then Return SetError(@error + 10, @extended, '') Local $sSize = _WinAPI_StrFormatByteSize(0) If @error Then Return SetError(@error, @extended, '') Return StringReplace($sSize, '0', StringRegExpReplace(Number($iSize), '(?<=\d)(?=(\d{3})+\z)', $aSymbol[3])) EndFunc Func _WinAPI_StrFormatKBSize($iSize) Local $aRet = DllCall('shlwapi.dll', 'ptr', 'StrFormatKBSizeW', 'int64', $iSize, 'wstr', '', 'uint', 1024) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, '') Return $aRet[2] EndFunc Func _WinAPI_StrFromTimeInterval($iTime, $iDigits = 7) Local $aRet = DllCall('shlwapi.dll', 'int', 'StrFromTimeIntervalW', 'wstr', '', 'uint', 1024, 'dword', $iTime, 'int', $iDigits) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, '') Return StringStripWS($aRet[1], $STR_STRIPLEADING + $STR_STRIPTRAILING) EndFunc Func _WinAPI_StringFromGUID($tGUID) Local $aResult = DllCall("ole32.dll", "int", "StringFromGUID2", "struct*", $tGUID, "wstr", "", "int", 40) If @error Or Not $aResult[0] Then Return SetError(@error, @extended, "") Return SetExtended($aResult[0], $aResult[2]) EndFunc Func _WinAPI_SubLangId($iLngID) Return BitShift($iLngID, 10) EndFunc Func _WinAPI_SwapDWord($iValue) Local $tStruct1 = DllStructCreate('dword;dword') Local $tStruct2 = DllStructCreate('byte[4];byte[4]', DllStructGetPtr($tStruct1)) DllStructSetData($tStruct1, 1, $iValue) For $i = 1 To 4 DllStructSetData($tStruct2, 2, DllStructGetData($tStruct2, 1, 5 - $i), $i) Next Return DllStructGetData($tStruct1, 2) EndFunc Func _WinAPI_SwapQWord($iValue) Local $tStruct1 = DllStructCreate('int64;int64') Local $tStruct2 = DllStructCreate('byte[8];byte[8]', DllStructGetPtr($tStruct1)) DllStructSetData($tStruct1, 1, $iValue) For $i = 1 To 8 DllStructSetData($tStruct2, 2, DllStructGetData($tStruct2, 1, 9 - $i), $i) Next Return DllStructGetData($tStruct1, 2) EndFunc Func _WinAPI_SwapWord($iValue) Local $tStruct1 = DllStructCreate('word;word') Local $tStruct2 = DllStructCreate('byte[2];byte[2]', DllStructGetPtr($tStruct1)) DllStructSetData($tStruct1, 1, $iValue) For $i = 1 To 2 DllStructSetData($tStruct2, 2, DllStructGetData($tStruct2, 1, 3 - $i), $i) Next Return DllStructGetData($tStruct1, 2) EndFunc Func _WinAPI_WideCharToMultiByte($vUnicode, $iCodePage = 0, $bRetNoStruct = True, $bRetBinary = False) Local $sUnicodeType = "wstr" If Not IsString($vUnicode) Then $sUnicodeType = "struct*" Local $aResult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $iCodePage, "dword", 0, $sUnicodeType, $vUnicode, "int", -1, "ptr", 0, "int", 0, "ptr", 0, "ptr", 0) If @error Or Not $aResult[0] Then Return SetError(@error + 20, @extended, "") Local $tMultiByte = DllStructCreate((($bRetBinary) ? ("byte") : ("char")) & "[" & $aResult[0] & "]") $aResult = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "uint", $iCodePage, "dword", 0, $sUnicodeType, $vUnicode, "int", -1, "struct*", $tMultiByte, "int", $aResult[0], "ptr", 0, "ptr", 0) If @error Or Not $aResult[0] Then Return SetError(@error + 10, @extended, "") If $bRetNoStruct Then Return DllStructGetData($tMultiByte, 1) Return $tMultiByte EndFunc Func _WinAPI_WordToShort($iValue) If BitAND($iValue, 0x00008000) Then Return BitOR($iValue, 0xFFFF8000) EndIf Return BitAND($iValue, 0x00007FFF) EndFunc #EndRegion Public Functions Global $__g_hWinInet_FTP = -1 Global $__g_hCallback_FTP, $__g_bCallback_FTP = False Global Const $INTERNET_OPEN_TYPE_DIRECT = 1 Global Const $INTERNET_OPEN_TYPE_PRECONFIG = 0 Global Const $INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY = 4 Global Const $INTERNET_OPEN_TYPE_PROXY = 3 Global Const $FTP_TRANSFER_TYPE_UNKNOWN = 0 Global Const $FTP_TRANSFER_TYPE_ASCII = 1 Global Const $FTP_TRANSFER_TYPE_BINARY = 2 Global Const $INTERNET_FLAG_DEFAULT = 0 Global Const $INTERNET_FLAG_PASSIVE = 0x08000000 Global Const $INTERNET_FLAG_TRANSFER_ASCII = $FTP_TRANSFER_TYPE_ASCII Global Const $INTERNET_FLAG_TRANSFER_BINARY = $FTP_TRANSFER_TYPE_BINARY Global Const $INTERNET_DEFAULT_FTP_PORT = 21 Global Const $INTERNET_SERVICE_FTP = 1 Global Const $INTERNET_SERVICE_GOPHER = 2 Global Const $INTERNET_SERVICE_HTTP = 3 Global Const $INTERNET_FLAG_HYPERLINK = 0x00000400 Global Const $INTERNET_FLAG_NEED_FILE = 0x00000010 Global Const $INTERNET_FLAG_NO_CACHE_WRITE = 0x04000000 Global Const $INTERNET_FLAG_RELOAD = 0x80000000 Global Const $INTERNET_FLAG_RESYNCHRONIZE = 0x00000800 Global Const $INTERNET_FLAG_ASYNC = 0x10000000 Global Const $INTERNET_FLAG_FROM_CACHE = 0x01000000 Global Const $INTERNET_FLAG_OFFLINE = $INTERNET_FLAG_FROM_CACHE Global Const $INTERNET_STATUS_CLOSING_CONNECTION = 50 Global Const $INTERNET_STATUS_CONNECTION_CLOSED = 51 Global Const $INTERNET_STATUS_CONNECTING_TO_SERVER = 20 Global Const $INTERNET_STATUS_CONNECTED_TO_SERVER = 21 Global Const $INTERNET_STATUS_CTL_RESPONSE_RECEIVED = 42 Global Const $INTERNET_STATUS_INTERMEDIATE_RESPONSE = 120 Global Const $INTERNET_STATUS_PREFETCH = 43 Global Const $INTERNET_STATUS_REDIRECT = 110 Global Const $INTERNET_STATUS_REQUEST_COMPLETE = 100 Global Const $INTERNET_STATUS_HANDLE_CREATED = 60 Global Const $INTERNET_STATUS_HANDLE_CLOSING = 70 Global Const $INTERNET_STATUS_SENDING_REQUEST = 30 Global Const $INTERNET_STATUS_REQUEST_SENT = 31 Global Const $INTERNET_STATUS_RECEIVING_RESPONSE = 40 Global Const $INTERNET_STATUS_RESPONSE_RECEIVED = 41 Global Const $INTERNET_STATUS_STATE_CHANGE = 200 Global Const $INTERNET_STATUS_RESOLVING_NAME = 10 Global Const $INTERNET_STATUS_NAME_RESOLVED = 11 Func _FTP_Close($hSession) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $aDone = DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $hSession) If @error Or $aDone[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), 0) If $__g_bCallback_FTP = True Then DllCallbackFree($__g_hCallback_FTP) Return $aDone[0] EndFunc Func _FTP_Command($hFTPSession, $sFTPCommand, $iFlags = $FTP_TRANSFER_TYPE_ASCII, $iExpectResponse = 0, $iContext = 0) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $ai_FTPCommand = DllCall($__g_hWinInet_FTP, 'bool', 'FtpCommandW', 'handle', $hFTPSession, 'bool', $iExpectResponse, 'dword', $iFlags, 'wstr', $sFTPCommand, 'dword_ptr', $iContext, 'ptr*', 0) If @error Or $ai_FTPCommand[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), 0) Return SetError(0, $ai_FTPCommand[6], $ai_FTPCommand[0]) EndFunc Func _FTP_Connect($hInternetSession, $sServerName, $sUsername, $sPassword, $iPassive = 0, $iServerPort = 0, $iService = $INTERNET_SERVICE_FTP, $iFlags = 0, $fuContext = 0) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) If $iPassive == 1 Then $iFlags = BitOR($iFlags, $INTERNET_FLAG_PASSIVE) Local $ai_InternetConnect = DllCall($__g_hWinInet_FTP, 'hwnd', 'InternetConnectW', 'handle', $hInternetSession, 'wstr', $sServerName, 'ushort', $iServerPort, 'wstr', $sUsername, 'wstr', $sPassword, 'dword', $iService, 'dword', $iFlags, 'dword_ptr', $fuContext) If @error Or $ai_InternetConnect[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), 0) Return $ai_InternetConnect[0] EndFunc Func _FTP_DecodeInternetStatus($iInternetStatus) Switch $iInternetStatus Case $INTERNET_STATUS_CLOSING_CONNECTION Return 'Closing connection ...' Case $INTERNET_STATUS_CONNECTION_CLOSED Return 'Connection closed' Case $INTERNET_STATUS_CONNECTING_TO_SERVER Return 'Connecting to server ...' Case $INTERNET_STATUS_CONNECTED_TO_SERVER Return 'Connected to server' Case $INTERNET_STATUS_CTL_RESPONSE_RECEIVED Return 'CTL esponse received' Case $INTERNET_STATUS_INTERMEDIATE_RESPONSE Return 'Intermediate response' Case $INTERNET_STATUS_PREFETCH Return 'Prefetch' Case $INTERNET_STATUS_REDIRECT Return 'Redirect' Case $INTERNET_STATUS_REQUEST_COMPLETE Return 'Request complete' Case $INTERNET_STATUS_HANDLE_CREATED Return 'Handle created' Case $INTERNET_STATUS_HANDLE_CLOSING Return 'Handle closing ...' Case $INTERNET_STATUS_SENDING_REQUEST Return 'Sending request ...' Case $INTERNET_STATUS_REQUEST_SENT Return 'Request sent' Case $INTERNET_STATUS_RECEIVING_RESPONSE Return 'Receiving response ...' Case $INTERNET_STATUS_RESPONSE_RECEIVED Return 'Response received' Case $INTERNET_STATUS_STATE_CHANGE Return 'State change' Case $INTERNET_STATUS_RESOLVING_NAME Return 'Resolving name ...' Case $INTERNET_STATUS_NAME_RESOLVED Return 'Name resolved' Case Else Return 'UNKNOWN status = ' & $iInternetStatus EndSwitch EndFunc Func _FTP_DirCreate($hFTPSession, $sRemote) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $ai_FTPMakeDir = DllCall($__g_hWinInet_FTP, 'bool', 'FtpCreateDirectoryW', 'handle', $hFTPSession, 'wstr', $sRemote) If @error Or $ai_FTPMakeDir[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), 0) Return $ai_FTPMakeDir[0] EndFunc Func _FTP_DirDelete($hFTPSession, $sRemote) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $ai_FTPDelDir = DllCall($__g_hWinInet_FTP, 'bool', 'FtpRemoveDirectoryW', 'handle', $hFTPSession, 'wstr', $sRemote) If @error Or $ai_FTPDelDir[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), 0) Return $ai_FTPDelDir[0] EndFunc Func _FTP_DirGetCurrent($hFTPSession) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $ai_FTPGetCurrentDir = DllCall($__g_hWinInet_FTP, 'bool', 'FtpGetCurrentDirectoryW', 'handle', $hFTPSession, 'wstr', "", 'dword*', 260) If @error Or $ai_FTPGetCurrentDir[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), 0) Return $ai_FTPGetCurrentDir[2] EndFunc Func _FTP_DirPutContents($hFTPSession, $sLocalFolder, $sRemoteFolder, $bRecursivePut, $iContext = 0) If StringRight($sLocalFolder, 1) == "\" Then $sLocalFolder = StringTrimRight($sLocalFolder, 1) Local $hSearch = FileFindFirstFile($sLocalFolder & "\*.*") If $hSearch = -1 Then Return SetError(1, 0, 0) Local $sFile While 1 $sFile = FileFindNextFile($hSearch) If @error Then ExitLoop If StringInStr(FileGetAttrib($sLocalFolder & "\" & $sFile), "D") Then _FTP_DirCreate($hFTPSession, $sRemoteFolder & "/" & $sFile) If $bRecursivePut Then _FTP_DirPutContents($hFTPSession, $sLocalFolder & "\" & $sFile, $sRemoteFolder & "/" & $sFile, $bRecursivePut, $iContext) EndIf Else _FTP_FilePut($hFTPSession, $sLocalFolder & "\" & $sFile, $sRemoteFolder & "/" & $sFile, 0, $iContext) EndIf WEnd FileClose($hSearch) Return 1 EndFunc Func _FTP_DirSetCurrent($hFTPSession, $sRemote) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $ai_FTPSetCurrentDir = DllCall($__g_hWinInet_FTP, 'bool', 'FtpSetCurrentDirectoryW', 'handle', $hFTPSession, 'wstr', $sRemote) If @error Or $ai_FTPSetCurrentDir[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), 0) Return $ai_FTPSetCurrentDir[0] EndFunc Func _FTP_FileClose($hFTPFile) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $aDone = DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $hFTPFile) If @error Or $aDone[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), 0) Return $aDone[0] EndFunc Func _FTP_FileDelete($hFTPSession, $sRemoteFile) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $ai_FTPPutFile = DllCall($__g_hWinInet_FTP, 'bool', 'FtpDeleteFileW', 'handle', $hFTPSession, 'wstr', $sRemoteFile) If @error Or $ai_FTPPutFile[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), 0) Return $ai_FTPPutFile[0] EndFunc Func _FTP_FileGet($hFTPSession, $sRemoteFile, $sLocalFile, $bFailIfExists = False, $iFlagsAndAttributes = 0, $iFlags = $FTP_TRANSFER_TYPE_UNKNOWN, $iContext = 0) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $ai_FTPGetFile = DllCall($__g_hWinInet_FTP, 'bool', 'FtpGetFileW', 'handle', $hFTPSession, 'wstr', $sRemoteFile, 'wstr', $sLocalFile, 'bool', $bFailIfExists, 'dword', $iFlagsAndAttributes, 'dword', $iFlags, 'dword_ptr', $iContext) If @error Or $ai_FTPGetFile[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), 0) Return $ai_FTPGetFile[0] EndFunc Func _FTP_FileGetSize($hFTPSession, $sFileName) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $ai_FTPGetSizeHandle = DllCall($__g_hWinInet_FTP, 'handle', 'FtpOpenFileW', 'handle', $hFTPSession, 'wstr', $sFileName, 'dword', $GENERIC_READ, 'dword', $INTERNET_FLAG_NO_CACHE_WRITE + $INTERNET_FLAG_TRANSFER_BINARY, 'dword_ptr', 0) If @error Or $ai_FTPGetSizeHandle[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), 0) Local $ai_FTPGetFileSize = DllCall($__g_hWinInet_FTP, 'dword', 'FtpGetFileSize', 'handle', $ai_FTPGetSizeHandle[0], 'dword*', 0) If @error Or $ai_FTPGetFileSize[0] = 0 Then Local $iLasterror = _WinAPI_GetLastError() DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $ai_FTPGetSizeHandle[0]) Return SetError(-1, $iLasterror, 0) EndIf DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $ai_FTPGetSizeHandle[0]) Return _WinAPI_MakeQWord($ai_FTPGetFileSize[0], $ai_FTPGetFileSize[2]) EndFunc Func _FTP_FileOpen($hConnect, $sFileName, $iAccess = $GENERIC_READ, $iFlags = $INTERNET_FLAG_TRANSFER_BINARY, $iContext = 0) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $ai_FtpOpenfile = DllCall($__g_hWinInet_FTP, 'handle', 'FtpOpenFileW', 'handle', $hConnect, 'wstr', $sFileName, 'dword', $iAccess, 'dword', $iFlags, 'dword_ptr', $iContext) If @error Or $ai_FtpOpenfile[0] == 0 Then Return SetError(-1, _WinAPI_GetLastError(), 0) Return $ai_FtpOpenfile[0] EndFunc Func _FTP_FilePut($hFTPSession, $sLocalFile, $sRemoteFile, $iFlags = 0, $iContext = 0) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $ai_FTPPutFile = DllCall($__g_hWinInet_FTP, 'bool', 'FtpPutFileW', 'handle', $hFTPSession, 'wstr', $sLocalFile, 'wstr', $sRemoteFile, 'dword', $iFlags, 'dword_ptr', $iContext) If @error Or $ai_FTPPutFile[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), 0) Return $ai_FTPPutFile[0] EndFunc Func _FTP_FileRead($hFTPFile, $iNumberOfBytesToRead) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $tBuffer = DllStructCreate("byte[" & $iNumberOfBytesToRead & "]") Local $ai_FTPReadFile = DllCall($__g_hWinInet_FTP, 'bool', 'InternetReadFile', 'handle', $hFTPFile, 'struct*', $tBuffer, 'dword', $iNumberOfBytesToRead, 'dword*', 0) If @error Then Return SetError(1, _WinAPI_GetLastError(), 0) Local $iNumberOfBytesRead = $ai_FTPReadFile[4] If $iNumberOfBytesRead == 0 And $ai_FTPReadFile[0] == 1 Then Return SetError(-1, 0, 0) ElseIf $ai_FTPReadFile[0] == 0 Then Return SetError(2, _WinAPI_GetLastError(), 0) EndIf Local $s_FileRead If $iNumberOfBytesToRead > $iNumberOfBytesRead Then $s_FileRead = BinaryMid(DllStructGetData($tBuffer, 1), 1, $iNumberOfBytesRead) Else $s_FileRead = DllStructGetData($tBuffer, 1) EndIf Return SetError(0, $iNumberOfBytesRead, $s_FileRead) EndFunc Func _FTP_FileRename($hFTPSession, $sExisting, $sNew) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $ai_FTPRenameFile = DllCall($__g_hWinInet_FTP, 'bool', 'FtpRenameFileW', 'handle', $hFTPSession, 'wstr', $sExisting, 'wstr', $sNew) If @error Or $ai_FTPRenameFile[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), 0) Return $ai_FTPRenameFile[0] EndFunc Func _FTP_FileTimeLoHiToStr($iLoDWORD, $iHiDWORD, $iFmt = 0) Local $tFileTime = DllStructCreate($tagFILETIME) If Not $iLoDWORD And Not $iHiDWORD Then Return SetError(1, 0, "") DllStructSetData($tFileTime, 1, $iLoDWORD) DllStructSetData($tFileTime, 2, $iHiDWORD) Local $sDate = _Date_Time_FileTimeToStr($tFileTime, $iFmt) Return SetError(@error, @extended, $sDate) EndFunc Func _FTP_FindFileClose($hFTPFind) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $ai_FTPPutFile = DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $hFTPFind) If @error Or $ai_FTPPutFile[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), "") Return $ai_FTPPutFile[0] EndFunc Func _FTP_FindFileFirst($hFTPSession, $sRemotePath, ByRef $hFTPFind, $iFlags = 0, $iContext = 0) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $t_DllStruct = DllStructCreate($tagWIN32_FIND_DATA) If @error Then Return SetError(-3, 0, "") Local $a_FTPFileList[1] $a_FTPFileList[0] = 0 Local $ai_FTPFirstFile = DllCall($__g_hWinInet_FTP, 'handle', 'FtpFindFirstFileW', 'handle', $hFTPSession, 'wstr', $sRemotePath, 'struct*', $t_DllStruct, 'dword', $iFlags, 'dword_ptr', $iContext) If @error Or $ai_FTPFirstFile[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), $ai_FTPFirstFile) $hFTPFind = $ai_FTPFirstFile[0] Local $a_FTPFileList[12] $a_FTPFileList[0] = 11 $a_FTPFileList[1] = DllStructGetData($t_DllStruct, "dwFileAttributes") $a_FTPFileList[2] = DllStructGetData($t_DllStruct, "ftCreationTime", 1) $a_FTPFileList[3] = DllStructGetData($t_DllStruct, "ftCreationTime", 2) $a_FTPFileList[4] = DllStructGetData($t_DllStruct, "ftLastAccessTime", 1) $a_FTPFileList[5] = DllStructGetData($t_DllStruct, "ftLastAccessTime", 2) $a_FTPFileList[6] = DllStructGetData($t_DllStruct, "ftLastWriteTime", 1) $a_FTPFileList[7] = DllStructGetData($t_DllStruct, "ftLastWriteTime", 2) $a_FTPFileList[8] = DllStructGetData($t_DllStruct, "nFileSizeHigh") $a_FTPFileList[9] = DllStructGetData($t_DllStruct, "nFileSizeLow") $a_FTPFileList[10] = DllStructGetData($t_DllStruct, "cFileName") $a_FTPFileList[11] = DllStructGetData($t_DllStruct, "cAlternateFileName") Return $a_FTPFileList EndFunc Func _FTP_FindFileNext($hFTPFind) Local $t_DllStruct = DllStructCreate($tagWIN32_FIND_DATA) Local $a_FTPFileList[1] $a_FTPFileList[0] = 0 Local $ai_FTPPutFile = DllCall($__g_hWinInet_FTP, 'bool', 'InternetFindNextFileW', 'handle', $hFTPFind, 'struct*', $t_DllStruct) If @error Or $ai_FTPPutFile[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), $a_FTPFileList) Local $a_FTPFileList[12] $a_FTPFileList[0] = 11 $a_FTPFileList[1] = DllStructGetData($t_DllStruct, "dwFileAttributes") $a_FTPFileList[2] = DllStructGetData($t_DllStruct, "ftCreationTime", 1) $a_FTPFileList[3] = DllStructGetData($t_DllStruct, "ftCreationTime", 2) $a_FTPFileList[4] = DllStructGetData($t_DllStruct, "ftLastAccessTime", 1) $a_FTPFileList[5] = DllStructGetData($t_DllStruct, "ftLastAccessTime", 2) $a_FTPFileList[6] = DllStructGetData($t_DllStruct, "ftLastWriteTime", 1) $a_FTPFileList[7] = DllStructGetData($t_DllStruct, "ftLastWriteTime", 2) $a_FTPFileList[8] = DllStructGetData($t_DllStruct, "nFileSizeHigh") $a_FTPFileList[9] = DllStructGetData($t_DllStruct, "nFileSizeLow") $a_FTPFileList[10] = DllStructGetData($t_DllStruct, "cFileName") $a_FTPFileList[11] = DllStructGetData($t_DllStruct, "cAlternateFileName") Return $a_FTPFileList EndFunc Func _FTP_GetLastResponseInfo(ByRef $iError, ByRef $sMessage) Local $ai_LastResponseInfo = DllCall($__g_hWinInet_FTP, 'bool', 'InternetGetLastResponseInfoW', 'dword*', 0, 'wstr', "", 'dword*', 4096) If @error Or $ai_LastResponseInfo[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), 0) $iError = $ai_LastResponseInfo[1] $sMessage = $ai_LastResponseInfo[2] Return $ai_LastResponseInfo[0] EndFunc Func _FTP_ListToArray($hFTPSession, $iReturnType = 0, $iFlags = $INTERNET_FLAG_NO_CACHE_WRITE, $iContext = 0) Local $aArray[1] $aArray[0] = 0 If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, $aArray) $aArray = __FTP_ListToArray($hFTPSession, $iReturnType, $iFlags, 0, 1, $iContext) Return SetError(@error, @extended, $aArray) EndFunc Func _FTP_ListToArray2D($hFTPSession, $iReturnType = 0, $iFlags = $INTERNET_FLAG_NO_CACHE_WRITE, $iContext = 0) Local $aArray[1][1] $aArray[0][0] = 0 If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, $aArray) $aArray = __FTP_ListToArray($hFTPSession, $iReturnType, $iFlags, 0, 2, $iContext) Return SetError(@error, @extended, $aArray) EndFunc Func _FTP_ListToArrayEx($hFTPSession, $iReturnType = 0, $iFlags = $INTERNET_FLAG_NO_CACHE_WRITE, $iFmt = 1, $iContext = 0) Local $aArray[1][1] $aArray[0][0] = 0 If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, $aArray) $aArray = __FTP_ListToArray($hFTPSession, $iReturnType, $iFlags, $iFmt, 6, $iContext) Return SetError(@error, @extended, $aArray) EndFunc Func _FTP_Open($sAgent, $iAccessType = $INTERNET_OPEN_TYPE_DIRECT, $sProxyName = '', $sProxyBypass = '', $iFlags = 0) If $__g_hWinInet_FTP = -1 Then __FTP_Init() Local $ai_InternetOpen = DllCall($__g_hWinInet_FTP, 'handle', 'InternetOpenW', 'wstr', $sAgent, 'dword', $iAccessType, 'wstr', $sProxyName, 'wstr', $sProxyBypass, 'dword', $iFlags) If @error Or $ai_InternetOpen[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), 0) Return $ai_InternetOpen[0] EndFunc Func _FTP_ProgressDownload($hFTPSession, $sLocalFile, $sRemoteFile, $hFunctionToCall = 0) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $hFile = FileOpen($sLocalFile, $FO_OVERWRITE + $FO_BINARY) If $hFile < 0 Then Return SetError(-1, 0, 0) Local $ai_FtpOpenfile = DllCall($__g_hWinInet_FTP, 'handle', 'FtpOpenFileW', 'handle', $hFTPSession, 'wstr', $sRemoteFile, 'dword', $GENERIC_READ, 'dword', $FTP_TRANSFER_TYPE_BINARY, 'dword_ptr', 0) If @error Or $ai_FtpOpenfile[0] = 0 Then Return SetError(-3, _WinAPI_GetLastError(), 0) Local $ai_FTPGetFileSize = DllCall($__g_hWinInet_FTP, 'dword', 'FtpGetFileSize', 'handle', $ai_FtpOpenfile[0], 'dword*', 0) If @error Then Return SetError(-2, _WinAPI_GetLastError(), 0) If Not IsFunc($hFunctionToCall) Then ProgressOn("FTP Download", "Downloading " & $sLocalFile) Local $iLen = _WinAPI_MakeQWord($ai_FTPGetFileSize[0], $ai_FTPGetFileSize[2]) Local Const $iChunkSize = 256 * 1024 Local $iLast = Mod($iLen, $iChunkSize) Local $iParts = Ceiling($iLen / $iChunkSize) Local $tBuffer = DllStructCreate("byte[" & $iChunkSize & "]") Local $aDone, $ai_FTPread, $iOut, $iRet, $iLasterror Local $x = $iChunkSize Local $iDone = 0 For $i = 1 To $iParts If $i = $iParts And $iLast > 0 Then $x = $iLast EndIf $ai_FTPread = DllCall($__g_hWinInet_FTP, 'bool', 'InternetReadFile', 'handle', $ai_FtpOpenfile[0], 'struct*', $tBuffer, 'dword', $x, 'dword*', $iOut) If @error Or $ai_FTPread[0] = 0 Then $iLasterror = _WinAPI_GetLastError() $aDone = DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $ai_FtpOpenfile[0]) FileClose($hFile) If Not IsFunc($hFunctionToCall) Then ProgressOff() Return SetError(-4, $iLasterror, 0) EndIf $iRet = FileWrite($hFile, BinaryMid(DllStructGetData($tBuffer, 1), 1, $ai_FTPread[4])) If Not $iRet Then $iLasterror = _WinAPI_GetLastError() $aDone = DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $ai_FtpOpenfile[0]) FileClose($hFile) FileDelete($sLocalFile) If Not IsFunc($hFunctionToCall) Then ProgressOff() Return SetError(-7, $iLasterror, 0) EndIf $iDone += $ai_FTPread[4] If Not IsFunc($hFunctionToCall) Then ProgressSet(($iDone / $iLen) * 100) Else $iRet = $hFunctionToCall(($iDone / $iLen) * 100) If $iRet <= 0 Then $iLasterror = @error $aDone = DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $ai_FtpOpenfile[0]) FileClose($hFile) FileDelete($sLocalFile) If Not IsFunc($hFunctionToCall) Then ProgressOff() Return SetError(-6, $iLasterror, $iRet) EndIf EndIf Sleep(10) Next FileClose($hFile) If Not IsFunc($hFunctionToCall) Then ProgressOff() $aDone = DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $ai_FtpOpenfile[0]) If @error Or $aDone[0] = 0 Then Return SetError(-5, _WinAPI_GetLastError(), 0) EndIf Return 1 EndFunc Func _FTP_ProgressUpload($hFTPSession, $sLocalFile, $sRemoteFile, $hFunctionToCall = 0) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $hFile = FileOpen($sLocalFile, $FO_BINARY) If @error Then Return SetError(-1, _WinAPI_GetLastError(), 0) Local $ai_FtpOpenfile = DllCall($__g_hWinInet_FTP, 'handle', 'FtpOpenFileW', 'handle', $hFTPSession, 'wstr', $sRemoteFile, 'dword', $GENERIC_WRITE, 'dword', $FTP_TRANSFER_TYPE_BINARY, 'dword_ptr', 0) If @error Or $ai_FtpOpenfile[0] = 0 Then Return SetError(-3, _WinAPI_GetLastError(), 0) If Not IsFunc($hFunctionToCall) Then ProgressOn("FTP Upload", "Uploading " & $sLocalFile) Local $iLen = FileGetSize($sLocalFile) Local Const $iChunkSize = 256 * 1024 Local $iLast = Mod($iLen, $iChunkSize) Local $iParts = Ceiling($iLen / $iChunkSize) Local $tBuffer = DllStructCreate("byte[" & $iChunkSize & "]") Local $aDone, $ai_FtpWrite, $iOut, $iRet, $iLasterror Local $x = $iChunkSize Local $iDone = 0 For $i = 1 To $iParts If $i = $iParts And $iLast > 0 Then $x = $iLast EndIf DllStructSetData($tBuffer, 1, FileRead($hFile, $x)) $ai_FtpWrite = DllCall($__g_hWinInet_FTP, 'bool', 'InternetWriteFile', 'handle', $ai_FtpOpenfile[0], 'struct*', $tBuffer, 'dword', $x, 'dword*', $iOut) If @error Or $ai_FtpWrite[0] = 0 Then $iLasterror = _WinAPI_GetLastError() $aDone = DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $ai_FtpOpenfile[0]) FileClose($hFile) If Not IsFunc($hFunctionToCall) Then ProgressOff() Return SetError(-4, $iLasterror, 0) EndIf $iDone += $x If Not IsFunc($hFunctionToCall) Then ProgressSet(($iDone / $iLen) * 100) Else $iRet = $hFunctionToCall(($iDone / $iLen) * 100) If $iRet <= 0 Then $iLasterror = @error $aDone = DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $ai_FtpOpenfile[0]) DllCall($__g_hWinInet_FTP, 'bool', 'FtpDeleteFileW', 'handle', $hFTPSession, 'wstr', $sRemoteFile) FileClose($hFile) If Not IsFunc($hFunctionToCall) Then ProgressOff() Return SetError(-6, $iLasterror, $iRet) EndIf EndIf Sleep(10) Next FileClose($hFile) If Not IsFunc($hFunctionToCall) Then ProgressOff() $aDone = DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $ai_FtpOpenfile[0]) If @error Or $aDone[0] = 0 Then Return SetError(-5, _WinAPI_GetLastError(), 0) Return 1 EndFunc Func _FTP_SetStatusCallback($hInternetSession, $sFunctionName) #Au3Stripper_Ignore_Funcs=$sFunctionName If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $hCallBack_Register = DllCallbackRegister($sFunctionName, "none", "ptr;ptr;dword;ptr;dword") If Not $hCallBack_Register Then Return SetError(-1, 0, 0) Local $ah_CallBackFunction = DllCall('wininet.dll', "ptr", "InternetSetStatusCallback", "ptr", $hInternetSession, "ulong_ptr", DllCallbackGetPtr($hCallBack_Register)) If @error Then Return SetError(-3, 0, 0) If $ah_CallBackFunction[0] = Ptr(-1) Then Return SetError(-4, 0, 0) $__g_bCallback_FTP = True $__g_hCallback_FTP = $hCallBack_Register Return $ah_CallBackFunction[1] EndFunc Func __FTP_ListToArray($hFTPSession, $iReturnType, $iFlags, $iFmt, $iArrayCount, $iContext) If $iArrayCount = 1 Then Local $asFileArray[1], $aDirectoryArray[1] $asFileArray[0] = 0 Else Local $asFileArray[1][$iArrayCount], $aDirectoryArray[1][$iArrayCount] $asFileArray[0][0] = 0 EndIf If $iReturnType < 0 Or $iReturnType > 2 Then Return SetError(3, 0, $asFileArray) Local $tWIN32_FIND_DATA = DllStructCreate($tagWIN32_FIND_DATA) Local $iLasterror Local $aCallFindFirst = DllCall($__g_hWinInet_FTP, 'handle', 'FtpFindFirstFileW', 'handle', $hFTPSession, 'wstr', "", 'struct*', $tWIN32_FIND_DATA, 'dword', $iFlags, 'dword_ptr', $iContext) If @error Or Not $aCallFindFirst[0] Then $iLasterror = _WinAPI_GetLastError() If $iLasterror = 12003 Then Local $iError, $sMessage _FTP_GetLastResponseInfo($iError, $sMessage) $iLasterror = $iError EndIf Return SetError(1, $iLasterror, $asFileArray) EndIf Local $iDirectoryIndex = 0, $sFileIndex = 0 Local $tFileTime, $bIsDir, $aCallFindNext Do $bIsDir = BitAND(DllStructGetData($tWIN32_FIND_DATA, "dwFileAttributes"), $FILE_ATTRIBUTE_DIRECTORY) = $FILE_ATTRIBUTE_DIRECTORY If $bIsDir And ($iReturnType <> 2) Then $iDirectoryIndex += 1 If $iArrayCount = 1 Then If UBound($aDirectoryArray) < $iDirectoryIndex + 1 Then ReDim $aDirectoryArray[$iDirectoryIndex * 2] $aDirectoryArray[$iDirectoryIndex] = DllStructGetData($tWIN32_FIND_DATA, "cFileName") Else If UBound($aDirectoryArray) < $iDirectoryIndex + 1 Then ReDim $aDirectoryArray[$iDirectoryIndex * 2][$iArrayCount] $aDirectoryArray[$iDirectoryIndex][0] = DllStructGetData($tWIN32_FIND_DATA, "cFileName") $aDirectoryArray[$iDirectoryIndex][1] = _WinAPI_MakeQWord(DllStructGetData($tWIN32_FIND_DATA, "nFileSizeLow"), DllStructGetData($tWIN32_FIND_DATA, "nFileSizeHigh")) If $iArrayCount = 6 Then $aDirectoryArray[$iDirectoryIndex][2] = DllStructGetData($tWIN32_FIND_DATA, "dwFileAttributes") $tFileTime = DllStructCreate($tagFILETIME, DllStructGetPtr($tWIN32_FIND_DATA, "ftLastWriteTime")) $aDirectoryArray[$iDirectoryIndex][3] = _Date_Time_FileTimeToStr($tFileTime, $iFmt) $tFileTime = DllStructCreate($tagFILETIME, DllStructGetPtr($tWIN32_FIND_DATA, "ftCreationTime")) $aDirectoryArray[$iDirectoryIndex][4] = _Date_Time_FileTimeToStr($tFileTime, $iFmt) $tFileTime = DllStructCreate($tagFILETIME, DllStructGetPtr($tWIN32_FIND_DATA, "ftLastAccessTime")) $aDirectoryArray[$iDirectoryIndex][5] = _Date_Time_FileTimeToStr($tFileTime, $iFmt) EndIf EndIf ElseIf Not $bIsDir And $iReturnType <> 1 Then $sFileIndex += 1 If $iArrayCount = 1 Then If UBound($asFileArray) < $sFileIndex + 1 Then ReDim $asFileArray[$sFileIndex * 2] $asFileArray[$sFileIndex] = DllStructGetData($tWIN32_FIND_DATA, "cFileName") Else If UBound($asFileArray) < $sFileIndex + 1 Then ReDim $asFileArray[$sFileIndex * 2][$iArrayCount] $asFileArray[$sFileIndex][0] = DllStructGetData($tWIN32_FIND_DATA, "cFileName") $asFileArray[$sFileIndex][1] = _WinAPI_MakeQWord(DllStructGetData($tWIN32_FIND_DATA, "nFileSizeLow"), DllStructGetData($tWIN32_FIND_DATA, "nFileSizeHigh")) If $iArrayCount = 6 Then $asFileArray[$sFileIndex][2] = DllStructGetData($tWIN32_FIND_DATA, "dwFileAttributes") $tFileTime = DllStructCreate($tagFILETIME, DllStructGetPtr($tWIN32_FIND_DATA, "ftLastWriteTime")) $asFileArray[$sFileIndex][3] = _Date_Time_FileTimeToStr($tFileTime, $iFmt) $tFileTime = DllStructCreate($tagFILETIME, DllStructGetPtr($tWIN32_FIND_DATA, "ftCreationTime")) $asFileArray[$sFileIndex][4] = _Date_Time_FileTimeToStr($tFileTime, $iFmt) $tFileTime = DllStructCreate($tagFILETIME, DllStructGetPtr($tWIN32_FIND_DATA, "ftLastAccessTime")) $asFileArray[$sFileIndex][5] = _Date_Time_FileTimeToStr($tFileTime, $iFmt) EndIf EndIf EndIf $aCallFindNext = DllCall($__g_hWinInet_FTP, 'bool', 'InternetFindNextFileW', 'handle', $aCallFindFirst[0], 'struct*', $tWIN32_FIND_DATA) If @error Then $iLasterror = _WinAPI_GetLastError() DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $aCallFindFirst[0]) Return SetError(2, $iLasterror, $asFileArray) EndIf Until Not $aCallFindNext[0] DllCall($__g_hWinInet_FTP, 'bool', 'InternetCloseHandle', 'handle', $aCallFindFirst[0]) If $iArrayCount = 1 Then $aDirectoryArray[0] = $iDirectoryIndex $asFileArray[0] = $sFileIndex Else $aDirectoryArray[0][0] = $iDirectoryIndex $asFileArray[0][0] = $sFileIndex EndIf Switch $iReturnType Case 0 If $iArrayCount = 1 Then ReDim $aDirectoryArray[$aDirectoryArray[0] + $asFileArray[0] + 1] For $i = 1 To $sFileIndex $aDirectoryArray[$aDirectoryArray[0] + $i] = $asFileArray[$i] Next $aDirectoryArray[0] += $asFileArray[0] Else ReDim $aDirectoryArray[$aDirectoryArray[0][0] + $asFileArray[0][0] + 1][$iArrayCount] For $i = 1 To $sFileIndex For $j = 0 To $iArrayCount - 1 $aDirectoryArray[$aDirectoryArray[0][0] + $i][$j] = $asFileArray[$i][$j] Next Next $aDirectoryArray[0][0] += $asFileArray[0][0] EndIf Return $aDirectoryArray Case 1 If $iArrayCount = 1 Then ReDim $aDirectoryArray[$iDirectoryIndex + 1] Else ReDim $aDirectoryArray[$iDirectoryIndex + 1][$iArrayCount] EndIf Return $aDirectoryArray Case 2 If $iArrayCount = 1 Then ReDim $asFileArray[$sFileIndex + 1] Else ReDim $asFileArray[$sFileIndex + 1][$iArrayCount] EndIf Return $asFileArray EndSwitch EndFunc Func __FTP_Init() $__g_hWinInet_FTP = DllOpen('wininet.dll') EndFunc Global Const $GDIP_DASHCAPFLAT = 0 Global Const $GDIP_DASHCAPROUND = 2 Global Const $GDIP_DASHCAPTRIANGLE = 3 Global Const $GDIP_DASHSTYLESOLID = 0 Global Const $GDIP_DASHSTYLEDASH = 1 Global Const $GDIP_DASHSTYLEDOT = 2 Global Const $GDIP_DASHSTYLEDASHDOT = 3 Global Const $GDIP_DASHSTYLEDASHDOTDOT = 4 Global Const $GDIP_DASHSTYLECUSTOM = 5 Global Const $GDIP_EPGCHROMINANCETABLE = '{F2E455DC-09B3-4316-8260-676ADA32481C}' Global Const $GDIP_EPGCOLORDEPTH = '{66087055-AD66-4C7C-9A18-38A2310B8337}' Global Const $GDIP_EPGCOMPRESSION = '{E09D739D-CCD4-44EE-8EBA-3FBF8BE4FC58}' Global Const $GDIP_EPGLUMINANCETABLE = '{EDB33BCE-0266-4A77-B904-27216099E717}' Global Const $GDIP_EPGQUALITY = '{1D5BE4B5-FA4A-452D-9CDD-5DB35105E7EB}' Global Const $GDIP_EPGRENDERMETHOD = '{6D42C53A-229A-4825-8BB7-5C99E2B9A8B8}' Global Const $GDIP_EPGSAVEFLAG = '{292266FC-AC40-47BF-8CFC-A85B89A655DE}' Global Const $GDIP_EPGSCANMETHOD = '{3A4E2661-3109-4E56-8536-42C156E7DCFA}' Global Const $GDIP_EPGTRANSFORMATION = '{8D0EB2D1-A58E-4EA8-AA14-108074B7B6F9}' Global Const $GDIP_EPGVERSION = '{24D18C76-814A-41A4-BF53-1C219CCCF797}' Global Const $GDIP_EPTBYTE = 1 Global Const $GDIP_EPTASCII = 2 Global Const $GDIP_EPTSHORT = 3 Global Const $GDIP_EPTLONG = 4 Global Const $GDIP_EPTRATIONAL = 5 Global Const $GDIP_EPTLONGRANGE = 6 Global Const $GDIP_EPTUNDEFINED = 7 Global Const $GDIP_EPTRATIONALRANGE = 8 Global Const $GDIP_ERROK = 0 Global Const $GDIP_ERRGENERICERROR = 1 Global Const $GDIP_ERRINVALIDPARAMETER = 2 Global Const $GDIP_ERROUTOFMEMORY = 3 Global Const $GDIP_ERROBJECTBUSY = 4 Global Const $GDIP_ERRINSUFFICIENTBUFFER = 5 Global Const $GDIP_ERRNOTIMPLEMENTED = 6 Global Const $GDIP_ERRWIN32ERROR = 7 Global Const $GDIP_ERRWRONGSTATE = 8 Global Const $GDIP_ERRABORTED = 9 Global Const $GDIP_ERRFILENOTFOUND = 10 Global Const $GDIP_ERRVALUEOVERFLOW = 11 Global Const $GDIP_ERRACCESSDENIED = 12 Global Const $GDIP_ERRUNKNOWNIMAGEFORMAT = 13 Global Const $GDIP_ERRFONTFAMILYNOTFOUND = 14 Global Const $GDIP_ERRFONTSTYLENOTFOUND = 15 Global Const $GDIP_ERRNOTTRUETYPEFONT = 16 Global Const $GDIP_ERRUNSUPPORTEDGDIVERSION = 17 Global Const $GDIP_ERRGDIPLUSNOTINITIALIZED = 18 Global Const $GDIP_ERRPROPERTYNOTFOUND = 19 Global Const $GDIP_ERRPROPERTYNOTSUPPORTED = 20 Global Const $GDIP_EVTCOMPRESSIONLZW = 2 Global Const $GDIP_EVTCOMPRESSIONCCITT3 = 3 Global Const $GDIP_EVTCOMPRESSIONCCITT4 = 4 Global Const $GDIP_EVTCOMPRESSIONRLE = 5 Global Const $GDIP_EVTCOMPRESSIONNONE = 6 Global Const $GDIP_EVTTRANSFORMROTATE90 = 13 Global Const $GDIP_EVTTRANSFORMROTATE180 = 14 Global Const $GDIP_EVTTRANSFORMROTATE270 = 15 Global Const $GDIP_EVTTRANSFORMFLIPHORIZONTAL = 16 Global Const $GDIP_EVTTRANSFORMFLIPVERTICAL = 17 Global Const $GDIP_EVTMULTIFRAME = 18 Global Const $GDIP_EVTLASTFRAME = 19 Global Const $GDIP_EVTFLUSH = 20 Global Const $GDIP_EVTFRAMEDIMENSIONPAGE = 23 Global Const $GDIP_ICFENCODER = 0x00000001 Global Const $GDIP_ICFDECODER = 0x00000002 Global Const $GDIP_ICFSUPPORTBITMAP = 0x00000004 Global Const $GDIP_ICFSUPPORTVECTOR = 0x00000008 Global Const $GDIP_ICFSEEKABLEENCODE = 0x00000010 Global Const $GDIP_ICFBLOCKINGDECODE = 0x00000020 Global Const $GDIP_ICFBUILTIN = 0x00010000 Global Const $GDIP_ICFSYSTEM = 0x00020000 Global Const $GDIP_ICFUSER = 0x00040000 Global Const $GDIP_ILMREAD = 0x0001 Global Const $GDIP_ILMWRITE = 0x0002 Global Const $GDIP_ILMUSERINPUTBUF = 0x0004 Global Const $GDIP_LINECAPFLAT = 0x00 Global Const $GDIP_LINECAPSQUARE = 0x01 Global Const $GDIP_LINECAPROUND = 0x02 Global Const $GDIP_LINECAPTRIANGLE = 0x03 Global Const $GDIP_LINECAPNOANCHOR = 0x10 Global Const $GDIP_LINECAPSQUAREANCHOR = 0x11 Global Const $GDIP_LINECAPROUNDANCHOR = 0x12 Global Const $GDIP_LINECAPDIAMONDANCHOR = 0x13 Global Const $GDIP_LINECAPARROWANCHOR = 0x14 Global Const $GDIP_LINECAPCUSTOM = 0xFF Global Const $GDIP_PXF01INDEXED = 0x00030101 Global Const $GDIP_PXF04INDEXED = 0x00030402 Global Const $GDIP_PXF08INDEXED = 0x00030803 Global Const $GDIP_PXF16GRAYSCALE = 0x00101004 Global Const $GDIP_PXF16RGB555 = 0x00021005 Global Const $GDIP_PXF16RGB565 = 0x00021006 Global Const $GDIP_PXF16ARGB1555 = 0x00061007 Global Const $GDIP_PXF24RGB = 0x00021808 Global Const $GDIP_PXF32RGB = 0x00022009 Global Const $GDIP_PXF32ARGB = 0x0026200A Global Const $GDIP_PXF32PARGB = 0x000E200B Global Const $GDIP_PXF48RGB = 0x0010300C Global Const $GDIP_PXF64ARGB = 0x0034400D Global Const $GDIP_PXF64PARGB = 0x001A400E Global Const $GDIP_IMAGEFORMAT_UNDEFINED = "{B96B3CA9-0728-11D3-9D7B-0000F81EF32E}" Global Const $GDIP_IMAGEFORMAT_MEMORYBMP = "{B96B3CAA-0728-11D3-9D7B-0000F81EF32E}" Global Const $GDIP_IMAGEFORMAT_BMP = "{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}" Global Const $GDIP_IMAGEFORMAT_EMF = "{B96B3CAC-0728-11D3-9D7B-0000F81EF32E}" Global Const $GDIP_IMAGEFORMAT_WMF = "{B96B3CAD-0728-11D3-9D7B-0000F81EF32E}" Global Const $GDIP_IMAGEFORMAT_JPEG = "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}" Global Const $GDIP_IMAGEFORMAT_PNG = "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}" Global Const $GDIP_IMAGEFORMAT_GIF = "{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}" Global Const $GDIP_IMAGEFORMAT_TIFF = "{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}" Global Const $GDIP_IMAGEFORMAT_EXIF = "{B96B3CB2-0728-11D3-9D7B-0000F81EF32E}" Global Const $GDIP_IMAGEFORMAT_ICON = "{B96B3CB5-0728-11D3-9D7B-0000F81EF32E}" Global Const $GDIP_IMAGETYPE_UNKNOWN = 0 Global Const $GDIP_IMAGETYPE_BITMAP = 1 Global Const $GDIP_IMAGETYPE_METAFILE = 2 Global Const $GDIP_IMAGEFLAGS_NONE = 0x0 Global Const $GDIP_IMAGEFLAGS_SCALABLE = 0x0001 Global Const $GDIP_IMAGEFLAGS_HASALPHA = 0x0002 Global Const $GDIP_IMAGEFLAGS_HASTRANSLUCENT = 0x0004 Global Const $GDIP_IMAGEFLAGS_PARTIALLYSCALABLE = 0x0008 Global Const $GDIP_IMAGEFLAGS_COLORSPACE_RGB = 0x0010 Global Const $GDIP_IMAGEFLAGS_COLORSPACE_CMYK = 0x0020 Global Const $GDIP_IMAGEFLAGS_COLORSPACE_GRAY = 0x0040 Global Const $GDIP_IMAGEFLAGS_COLORSPACE_YCBCR = 0x0080 Global Const $GDIP_IMAGEFLAGS_COLORSPACE_YCCK = 0x0100 Global Const $GDIP_IMAGEFLAGS_HASREALDPI = 0x1000 Global Const $GDIP_IMAGEFLAGS_HASREALPIXELSIZE = 0x2000 Global Const $GDIP_IMAGEFLAGS_READONLY = 0x00010000 Global Const $GDIP_IMAGEFLAGS_CACHING = 0x00020000 Global Const $GDIP_SMOOTHINGMODE_INVALID = -1 Global Const $GDIP_SMOOTHINGMODE_DEFAULT = 0 Global Const $GDIP_SMOOTHINGMODE_HIGHSPEED = 1 Global Const $GDIP_SMOOTHINGMODE_HIGHQUALITY = 2 Global Const $GDIP_SMOOTHINGMODE_NONE = 3 Global Const $GDIP_SMOOTHINGMODE_ANTIALIAS8X4 = 4 Global Const $GDIP_SMOOTHINGMODE_ANTIALIAS = $GDIP_SMOOTHINGMODE_ANTIALIAS8X4 Global Const $GDIP_SMOOTHINGMODE_ANTIALIAS8X8 = 5 Global Const $GDIP_RLUM = 0.3086 Global Const $GDIP_GLUM = 0.6094 Global Const $GDIP_BLUM = 0.0820 Global Const $GDIP_INTERPOLATIONMODE_INVALID = -1 Global Const $GDIP_INTERPOLATIONMODE_DEFAULT = 0 Global Const $GDIP_INTERPOLATIONMODE_LOWQUALITY = 1 Global Const $GDIP_INTERPOLATIONMODE_HIGHQUALITY = 2 Global Const $GDIP_INTERPOLATIONMODE_BILINEAR = 3 Global Const $GDIP_INTERPOLATIONMODE_BICUBIC = 4 Global Const $GDIP_INTERPOLATIONMODE_NEARESTNEIGHBOR = 5 Global Const $GDIP_INTERPOLATIONMODE_HIGHQUALITYBILINEAR = 6 Global Const $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC = 7 Global Const $GDIP_TEXTRENDERINGHINT_SYSTEMDEFAULT = 0 Global Const $GDIP_TEXTRENDERINGHINT_SINGLEBITPERPIXELGRIDFIT = 1 Global Const $GDIP_TEXTRENDERINGHINT_SINGLEBITPERPIXEL = 2 Global Const $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT = 3 Global Const $GDIP_TEXTRENDERINGHINT_ANTIALIAS = 4 Global Const $GDIP_TEXTRENDERINGHINT_CLEARTYPEGRIDFIT = 5 Global Const $GDIP_PIXELOFFSETMODE_INVALID = -1 Global Const $GDIP_PIXELOFFSETMODE_DEFAULT = 0 Global Const $GDIP_PIXELOFFSETMODE_HIGHSPEED = 1 Global Const $GDIP_PIXELOFFSETMODE_HIGHQUALITY = 2 Global Const $GDIP_PIXELOFFSETMODE_NONE = 3 Global Const $GDIP_PIXELOFFSETMODE_HALF = 4 Global Const $GDIP_PENSETLINEJOIN_MITER = 0 Global Const $GDIP_PENSETLINEJOIN_BEVEL = 1 Global Const $GDIP_PENSETLINEJOIN_ROUND = 2 Global Const $GDIP_PENSETLINEJOIN_MITERCLIPPED = 3 Global Const $GDIP_FillModeAlternate = 0 Global Const $GDIP_FillModeWinding = 1 Global Const $GDIP_QUALITYMODEINVALID = -1 Global Const $GDIP_QUALITYMODEDEFAULT = 0 Global Const $GDIP_QUALITYMODELOW = 1 Global Const $GDIP_QUALITYMODEHIGH = 2 Global Const $GDIP_COMPOSITINGMODESOURCEOVER = 0 Global Const $GDIP_COMPOSITINGMODESOURCECOPY = 1 Global Const $GDIP_COMPOSITINGQUALITYINVALID = $GDIP_QUALITYMODEINVALID Global Const $GDIP_COMPOSITINGQUALITYDEFAULT = $GDIP_QUALITYMODEDEFAULT Global Const $GDIP_COMPOSITINGQUALITYHIGHSPEED = $GDIP_QUALITYMODELOW Global Const $GDIP_COMPOSITINGQUALITYHIGHQUALITY = $GDIP_QUALITYMODEHIGH Global Const $GDIP_COMPOSITINGQUALITYGAMMACORRECTED = 3 Global Const $GDIP_COMPOSITINGQUALITYASSUMELINEAR = 4 Global Const $GDIP_HATCHSTYLE_HORIZONTAL = 0 Global Const $GDIP_HATCHSTYLE_VERTICAL = 1 Global Const $GDIP_HATCHSTYLE_FORWARDDIAGONAL = 2 Global Const $GDIP_HATCHSTYLE_BACKWARDDIAGONAL = 3 Global Const $GDIP_HATCHSTYLE_CROSS = 4 Global Const $GDIP_HATCHSTYLE_DIAGONALCROSS = 5 Global Const $GDIP_HATCHSTYLE_05PERCENT = 6 Global Const $GDIP_HATCHSTYLE_10PERCENT = 7 Global Const $GDIP_HATCHSTYLE_20PERCENT = 8 Global Const $GDIP_HATCHSTYLE_25PERCENT = 9 Global Const $GDIP_HATCHSTYLE_30PERCENT = 10 Global Const $GDIP_HATCHSTYLE_40PERCENT = 11 Global Const $GDIP_HATCHSTYLE_50PERCENT = 12 Global Const $GDIP_HATCHSTYLE_60PERCENT = 13 Global Const $GDIP_HATCHSTYLE_70PERCENT = 14 Global Const $GDIP_HATCHSTYLE_75PERCENT = 15 Global Const $GDIP_HATCHSTYLE_80PERCENT = 16 Global Const $GDIP_HATCHSTYLE_90PERCENT = 17 Global Const $GDIP_HATCHSTYLE_LIGHTDOWNWARDDIAGONAL = 18 Global Const $GDIP_HATCHSTYLE_LIGHTUPWARDDIAGONAL = 19 Global Const $GDIP_HATCHSTYLE_DARKDOWNWARDDIAGONAL = 20 Global Const $GDIP_HATCHSTYLE_DARKUPWARDDIAGONAL = 21 Global Const $GDIP_HATCHSTYLE_WIDEDOWNWARDDIAGONAL = 22 Global Const $GDIP_HATCHSTYLE_WIDEUPWARDDIAGONAL = 23 Global Const $GDIP_HATCHSTYLE_LIGHTVERTICAL = 24 Global Const $GDIP_HATCHSTYLE_LIGHTHORIZONTAL = 25 Global Const $GDIP_HATCHSTYLE_NARROWVERTICAL = 26 Global Const $GDIP_HATCHSTYLE_NARROWHORIZONTAL = 27 Global Const $GDIP_HATCHSTYLE_DARKVERTICAL = 28 Global Const $GDIP_HATCHSTYLE_DARKHORIZONTAL = 29 Global Const $GDIP_HATCHSTYLE_DASHEDDOWNWARDDIAGONAL = 30 Global Const $GDIP_HATCHSTYLE_DASHEDUPWARDDIAGONAL = 31 Global Const $GDIP_HATCHSTYLE_DASHEDHORIZONTAL = 32 Global Const $GDIP_HATCHSTYLE_DASHEDVERTICAL = 33 Global Const $GDIP_HATCHSTYLE_SMALLCONFETTI = 34 Global Const $GDIP_HATCHSTYLE_LARGECONFETTI = 35 Global Const $GDIP_HATCHSTYLE_ZIGZAG = 36 Global Const $GDIP_HATCHSTYLE_WAVE = 37 Global Const $GDIP_HATCHSTYLE_DIAGONALBRICK = 38 Global Const $GDIP_HATCHSTYLE_HORIZONTALBRICK = 39 Global Const $GDIP_HATCHSTYLE_WEAVE = 40 Global Const $GDIP_HATCHSTYLE_PLAID = 41 Global Const $GDIP_HATCHSTYLE_DIVOT = 42 Global Const $GDIP_HATCHSTYLE_DOTTEDGRID = 43 Global Const $GDIP_HATCHSTYLE_DOTTEDDIAMOND = 44 Global Const $GDIP_HATCHSTYLE_SHINGLE = 45 Global Const $GDIP_HATCHSTYLE_TRELLIS = 46 Global Const $GDIP_HATCHSTYLE_SPHERE = 47 Global Const $GDIP_HATCHSTYLE_SMALLGRID = 48 Global Const $GDIP_HATCHSTYLE_SMALLCHECKERBOARD = 49 Global Const $GDIP_HATCHSTYLE_LARGECHECKERBOARD = 50 Global Const $GDIP_HATCHSTYLE_OUTLINEDDIAMOND = 51 Global Const $GDIP_HATCHSTYLE_SOLIDDIAMOND = 52 Global Const $GDIP_HATCHSTYLE_TOTAL = 53 Global Const $GDIP_HATCHSTYLE_LARGEGRID = $GDIP_HATCHSTYLE_CROSS Global Const $GDIP_HATCHSTYLE_MIN = $GDIP_HATCHSTYLE_HORIZONTAL Global Const $GDIP_HATCHSTYLE_MAX = $GDIP_HATCHSTYLE_TOTAL - 1 Global Const $GDIP_BlurEffectGuid = '{633C80A4-1843-482b-9EF2-BE2834C5FDD4}' Global Const $GDIP_SharpenEffectGuid = '{63CBF3EE-C526-402c-8F71-62C540BF5142}' Global Const $GDIP_ColorMatrixEffectGuid = '{718F2615-7933-40e3-A511-5F68FE14DD74}' Global Const $GDIP_ColorLUTEffectGuid = '{A7CE72A9-0F7F-40d7-B3CC-D0C02D5C3212}' Global Const $GDIP_BrightnessContrastEffectGuid = '{D3A1DBE1-8EC4-4c17-9F4C-EA97AD1C343D}' Global Const $GDIP_HueSaturationLightnessEffectGuid = '{8B2DD6C3-EB07-4d87-A5F0-7108E26A9C5F}' Global Const $GDIP_LevelsEffectGuid = '{99C354EC-2A31-4f3a-8C34-17A803B33A25}' Global Const $GDIP_TintEffectGuid = '{1077AF00-2848-4441-9489-44AD4C2D7A2C}' Global Const $GDIP_ColorBalanceEffectGuid = '{537E597D-251E-48da-9664-29CA496B70F8}' Global Const $GDIP_RedEyeCorrectionEffectGuid = '{74D29D05-69A4-4266-9549-3CC52836B632}' Global Const $GDIP_ColorCurveEffectGuid = '{DD6A0022-58E4-4a67-9D9B-D48EB881A53D}' Global Const $GDIP_AdjustExposure = 0 Global Const $GDIP_AdjustDensity = 1 Global Const $GDIP_AdjustContrast = 2 Global Const $GDIP_AdjustHighlight = 3 Global Const $GDIP_AdjustShadow = 4 Global Const $GDIP_AdjustMidtone = 5 Global Const $GDIP_AdjustWhiteSaturation = 6 Global Const $GDIP_AdjustBlackSaturation = 7 Global Const $GDIP_CurveChannelAll = 0 Global Const $GDIP_CurveChannelRed = 1 Global Const $GDIP_CurveChannelGreen = 2 Global Const $GDIP_CurveChannelBlue = 3 Global Const $GDIP_PaletteTypeCustom = 0 Global Const $GDIP_PaletteTypeOptimal = 1 Global Const $GDIP_PaletteTypeFixedBW = 2 Global Const $GDIP_PaletteTypeFixedHalftone8 = 3 Global Const $GDIP_PaletteTypeFixedHalftone27 = 4 Global Const $GDIP_PaletteTypeFixedHalftone64 = 5 Global Const $GDIP_PaletteTypeFixedHalftone125 = 6 Global Const $GDIP_PaletteTypeFixedHalftone216 = 7 Global Const $GDIP_PaletteTypeFixedHalftone252 = 8 Global Const $GDIP_PaletteTypeFixedHalftone256 = 9 Global Const $GDIP_PaletteFlagsHasAlpha = 0x0001 Global Const $GDIP_PaletteFlagsGrayScale = 0x0002 Global Const $GDIP_PaletteFlagsHalftone = 0x0004 Global Const $GDIP_DitherTypeNone = 0 Global Const $GDIP_DitherTypeSolid = 1 Global Const $GDIP_DitherTypeOrdered4x4 = 2 Global Const $GDIP_DitherTypeOrdered8x8 = 3 Global Const $GDIP_DitherTypeOrdered16x16 = 4 Global Const $GDIP_DitherTypeOrdered91x91 = 5 Global Const $GDIP_DitherTypeSpiral4x4 = 6 Global Const $GDIP_DitherTypeSpiral8x8 = 7 Global Const $GDIP_DitherTypeDualSpiral4x4 = 8 Global Const $GDIP_DitherTypeDualSpiral8x8 = 9 Global Const $GDIP_DitherTypeErrorDiffusion = 10 Global Const $GDIP_DitherTypeMax = 10 Global Const $GDIP_HistogramFormatARGB = 0 Global Const $GDIP_HistogramFormatPARGB = 1 Global Const $GDIP_HistogramFormatRGB = 2 Global Const $GDIP_HistogramFormatGray = 3 Global Const $GDIP_HistogramFormatB = 4 Global Const $GDIP_HistogramFormatG = 5 Global Const $GDIP_HistogramFormatR = 6 Global Const $GDIP_HistogramFormatA = 7 Global Const $GDIP_TextRenderingHintSystemDefault = 0 Global Const $GDIP_TextRenderingHintSingleBitPerPixelGridFit = 1 Global Const $GDIP_TextRenderingHintSingleBitPerPixel = 2 Global Const $GDIP_TextRenderingHintAntialiasGridFit = 3 Global Const $GDIP_TextRenderingHintAntialias = 4 Global Const $GDIP_TextRenderingHintClearTypeGridFit = 5 Global Const $GDIP_RotateNoneFlipNone = 0 Global Const $GDIP_Rotate90FlipNone = 1 Global Const $GDIP_Rotate180FlipNone = 2 Global Const $GDIP_Rotate270FlipNone = 3 Global Const $GDIP_RotateNoneFlipX = 4 Global Const $GDIP_Rotate90FlipX = 5 Global Const $GDIP_Rotate180FlipX = 6 Global Const $GDIP_Rotate270FlipX = 7 Global Const $GDIP_RotateNoneFlipY = $GDIP_Rotate180FlipX Global Const $GDIP_Rotate90FlipY = $GDIP_Rotate270FlipX Global Const $GDIP_Rotate180FlipY = $GDIP_RotateNoneFlipX Global Const $GDIP_Rotate270FlipY = $GDIP_Rotate90FlipX Global Const $GDIP_RotateNoneFlipXY = $GDIP_Rotate180FlipNone Global Const $GDIP_Rotate90FlipXY = $GDIP_Rotate270FlipNone Global Const $GDIP_Rotate270FlipXY = $GDIP_Rotate90FlipNone Global Const $GDIP_FRAMEDIMENSION_TIME = "{6AEDBD6D-3FB5-418A-83A6-7F45229DC872}" Global Const $GDIP_FRAMEDIMENSION_RESOLUTION = "{84236F7B-3BD3-428F-8DAB-4EA1439CA315}" Global Const $GDIP_FRAMEDIMENSION_PAGE = "{7462DC86-6180-4C7E-8E3F-EE7333A7A483}" Global Const $GDIP_COLORADJUSTTYPE_DEFAULT = 0 Global Const $GDIP_COLORADJUSTTYPE_BITMAP = 1 Global Const $GDIP_COLORADJUSTTYPE_BRUSH = 2 Global Const $GDIP_COLORADJUSTTYPE_PEN = 3 Global Const $GDIP_COLORADJUSTTYPE_TEXT = 4 Global Const $GDIP_COLORADJUSTTYPE_COUNT = 5 Global Const $GDIP_COLORADJUSTTYPE_ANY = 6 Global Const $COINIT_APARTMENTTHREADED = 0x02 Global Const $COINIT_DISABLE_OLE1DDE = 0x04 Global Const $COINIT_MULTITHREADED = 0x00 Global Const $COINIT_SPEED_OVER_MEMORY = 0x08 #Region Global Variables and Constants Global Const $__tagWinAPICom_GUID = "struct;ulong Data1;ushort Data2;ushort Data3;byte Data4[8];endstruct" #EndRegion Global Variables and Constants #Region Functions list #EndRegion Functions list #Region Public Functions Func _WinAPI_CLSIDFromProgID($sProgID) Local $tGUID = DllStructCreate($__tagWinAPICom_GUID) Local $aReturn = DllCall('ole32.dll', 'long', 'CLSIDFromProgID', 'wstr', $sProgID, 'struct*', $tGUID) If @error Then Return SetError(@error, @extended, '') If $aReturn[0] Then Return SetError(10, $aReturn[0], '') $aReturn = DllCall('ole32.dll', 'int', 'StringFromGUID2', 'struct*', $tGUID, 'wstr', '', 'int', 39) If @error Or Not $aReturn[0] Then Return SetError(@error + 20, @extended, '') Return $aReturn[2] EndFunc Func _WinAPI_CoInitialize($iFlags = 0) Local $aReturn = DllCall('ole32.dll', 'long', 'CoInitializeEx', 'ptr', 0, 'dword', $iFlags) If @error Then Return SetError(@error, @extended, 0) If $aReturn[0] Then Return SetError(10, $aReturn[0], 0) Return 1 EndFunc Func _WinAPI_CoTaskMemAlloc($iSize) Local $aReturn = DllCall('ole32.dll', 'ptr', 'CoTaskMemAlloc', 'uint_ptr', $iSize) If @error Then Return SetError(@error, @extended, 0) Return $aReturn[0] EndFunc Func _WinAPI_CoTaskMemFree($pMemory) DllCall('ole32.dll', 'none', 'CoTaskMemFree', 'ptr', $pMemory) If @error Then Return SetError(@error, @extended, 0) Return 1 EndFunc Func _WinAPI_CoTaskMemRealloc($pMemory, $iSize) Local $aReturn = DllCall('ole32.dll', 'ptr', 'CoTaskMemRealloc', 'ptr', $pMemory, 'ulong_ptr', $iSize) If @error Then Return SetError(@error, @extended, 0) Return $aReturn[0] EndFunc Func _WinAPI_CoUninitialize() DllCall('ole32.dll', 'none', 'CoUninitialize') If @error Then Return SetError(@error, @extended, 0) Return 1 EndFunc Func _WinAPI_CreateGUID() Local $tGUID = DllStructCreate($__tagWinAPICom_GUID) Local $aReturn = DllCall('ole32.dll', 'long', 'CoCreateGuid', 'struct*', $tGUID) If @error Then Return SetError(@error, @extended, '') If $aReturn[0] Then Return SetError(10, $aReturn[0], '') $aReturn = DllCall('ole32.dll', 'int', 'StringFromGUID2', 'struct*', $tGUID, 'wstr', '', 'int', 65536) If @error Or Not $aReturn[0] Then Return SetError(@error + 20, @extended, '') Return $aReturn[2] EndFunc Func _WinAPI_CreateStreamOnHGlobal($hGlobal = 0, $bDeleteOnRelease = True) Local $aReturn = DllCall('ole32.dll', 'long', 'CreateStreamOnHGlobal', 'handle', $hGlobal, 'bool', $bDeleteOnRelease, 'ptr*', 0) If @error Then Return SetError(@error, @extended, 0) If $aReturn[0] Then Return SetError(10, $aReturn[0], 0) Return $aReturn[3] EndFunc Func _WinAPI_GetHGlobalFromStream($pStream) Local $aReturn = DllCall('ole32.dll', 'uint', 'GetHGlobalFromStream', 'ptr', $pStream, 'ptr*', 0) If @error Then Return SetError(@error, @extended, 0) If $aReturn[0] Then Return SetError(10, $aReturn[0], 0) Return $aReturn[2] EndFunc Func _WinAPI_ProgIDFromCLSID($sCLSID) Local $tGUID = DllStructCreate($__tagWinAPICom_GUID) Local $aReturn = DllCall('ole32.dll', 'uint', 'CLSIDFromString', 'wstr', $sCLSID, 'struct*', $tGUID) If @error Or $aReturn[0] Then Return SetError(@error + 20, @extended, '') $aReturn = DllCall('ole32.dll', 'uint', 'ProgIDFromCLSID', 'struct*', $tGUID, 'ptr*', 0) If @error Then Return SetError(@error, @extended, '') If $aReturn[0] Then Return SetError(10, $aReturn[0], '') Local $sID = _WinAPI_GetString($aReturn[2]) _WinAPI_CoTaskMemFree($aReturn[2]) Return $sID EndFunc Func _WinAPI_ReleaseStream($pStream) Local $aReturn = DllCall('oleaut32.dll', 'long', 'DispCallFunc', 'ptr', $pStream, 'ulong_ptr', 8 * (1 + @AutoItX64), 'uint', 4, 'ushort', 23, 'uint', 0, 'ptr', 0, 'ptr', 0, 'str', '') If @error Then Return SetError(@error, @extended, 0) If $aReturn[0] Then Return SetError(10, $aReturn[0], 0) Return 1 EndFunc #EndRegion Public Functions Global Const $FR_PRIVATE = 0x10 Global Const $FR_NOT_ENUM = 0x20 Global Const $COMPRESSION_BITMAP_PNG = 0 Global Const $COMPRESSION_BITMAP_JPEG = 1 Global Const $BS_DIBPATTERN = 5 Global Const $BS_DIBPATTERN8X8 = 8 Global Const $BS_DIBPATTERNPT = 6 Global Const $BS_HATCHED = 2 Global Const $BS_HOLLOW = 1 Global Const $BS_NULL = 1 Global Const $BS_PATTERN = 3 Global Const $BS_PATTERN8X8 = 7 Global Const $BS_SOLID = 0 Global Const $HS_BDIAGONAL = 3 Global Const $HS_CROSS = 4 Global Const $HS_DIAGCROSS = 5 Global Const $HS_FDIAGONAL = 2 Global Const $HS_HORIZONTAL = 0 Global Const $HS_VERTICAL = 1 Global Const $DIB_PAL_COLORS = 1 Global Const $DIB_RGB_COLORS = 0 Global Const $CA_NEGATIVE = 0x01 Global Const $CA_LOG_FILTER = 0x02 Global Const $ILLUMINANT_DEVICE_DEFAULT = 0 Global Const $ILLUMINANT_A = 1 Global Const $ILLUMINANT_B = 2 Global Const $ILLUMINANT_C = 3 Global Const $ILLUMINANT_D50 = 4 Global Const $ILLUMINANT_D55 = 5 Global Const $ILLUMINANT_D65 = 6 Global Const $ILLUMINANT_D75 = 7 Global Const $ILLUMINANT_F2 = 8 Global Const $ILLUMINANT_TUNGSTEN = $ILLUMINANT_A Global Const $ILLUMINANT_DAYLIGHT = $ILLUMINANT_C Global Const $ILLUMINANT_FLUORESCENT = $ILLUMINANT_F2 Global Const $ILLUMINANT_NTSC = $ILLUMINANT_C Global Const $BI_RGB = 0 Global Const $BI_RLE8 = 1 Global Const $BI_RLE4 = 2 Global Const $BI_BITFIELDS = 3 Global Const $BI_JPEG = 4 Global Const $BI_PNG = 5 Global Const $ALTERNATE = 1 Global Const $WINDING = 2 Global Const $DWMWA_NCRENDERING_ENABLED = 1 Global Const $DWMWA_NCRENDERING_POLICY = 2 Global Const $DWMWA_TRANSITIONS_FORCEDISABLED = 3 Global Const $DWMWA_ALLOW_NCPAINT = 4 Global Const $DWMWA_CAPTION_BUTTON_BOUNDS = 5 Global Const $DWMWA_NONCLIENT_RTL_LAYOUT = 6 Global Const $DWMWA_FORCE_ICONIC_REPRESENTATION = 7 Global Const $DWMWA_FLIP3D_POLICY = 8 Global Const $DWMWA_EXTENDED_FRAME_BOUNDS = 9 Global Const $DWMWA_HAS_ICONIC_BITMAP = 10 Global Const $DWMWA_DISALLOW_PEEK = 11 Global Const $DWMWA_EXCLUDED_FROM_PEEK = 12 Global Const $DWMNCRP_USEWINDOWSTYLE = 0 Global Const $DWMNCRP_DISABLED = 1 Global Const $DWMNCRP_ENABLED = 2 Global Const $DWMFLIP3D_DEFAULT = 0 Global Const $DWMFLIP3D_EXCLUDEBELOW = 1 Global Const $DWMFLIP3D_EXCLUDEABOVE = 2 Global Const $DM_BITSPERPEL = 0x00040000 Global Const $DM_COLLATE = 0x0008000 Global Const $DM_COLOR = 0x00000800 Global Const $DM_COPIES = 0x00000100 Global Const $DM_DEFAULTSOURCE = 0x00000200 Global Const $DM_DISPLAYFIXEDOUTPUT = 0x20000000 Global Const $DM_DISPLAYFLAGS = 0x00200000 Global Const $DM_DISPLAYFREQUENCY = 0x00400000 Global Const $DM_DISPLAYORIENTATION = 0x00000080 Global Const $DM_DITHERTYPE = 0x04000000 Global Const $DM_DUPLEX = 0x0001000 Global Const $DM_FORMNAME = 0x00010000 Global Const $DM_ICMINTENT = 0x01000000 Global Const $DM_ICMMETHOD = 0x00800000 Global Const $DM_LOGPIXELS = 0x00020000 Global Const $DM_MEDIATYPE = 0x02000000 Global Const $DM_NUP = 0x00000040 Global Const $DM_ORIENTATION = 0x00000001 Global Const $DM_PANNINGHEIGHT = 0x10000000 Global Const $DM_PANNINGWIDTH = 0x08000000 Global Const $DM_PAPERLENGTH = 0x00000004 Global Const $DM_PAPERSIZE = 0x00000002 Global Const $DM_PAPERWIDTH = 0x00000008 Global Const $DM_PELSHEIGHT = 0x00100000 Global Const $DM_PELSWIDTH = 0x00080000 Global Const $DM_POSITION = 0x00000020 Global Const $DM_PRINTQUALITY = 0x00000400 Global Const $DM_SCALE = 0x00000010 Global Const $DM_TTOPTION = 0x0004000 Global Const $DM_YRESOLUTION = 0x0002000 Global Const $DMPAPER_LETTER = 1 Global Const $DMPAPER_LETTERSMALL = 2 Global Const $DMPAPER_TABLOID = 3 Global Const $DMPAPER_LEDGER = 4 Global Const $DMPAPER_LEGAL = 5 Global Const $DMPAPER_STATEMENT = 6 Global Const $DMPAPER_EXECUTIVE = 7 Global Const $DMPAPER_A3 = 8 Global Const $DMPAPER_A4 = 9 Global Const $DMPAPER_A4SMALL = 10 Global Const $DMPAPER_A5 = 11 Global Const $DMPAPER_B4 = 12 Global Const $DMPAPER_B5 = 13 Global Const $DMPAPER_FOLIO = 14 Global Const $DMPAPER_QUARTO = 15 Global Const $DMPAPER_10X14 = 16 Global Const $DMPAPER_11X17 = 17 Global Const $DMPAPER_NOTE = 18 Global Const $DMPAPER_ENV_9 = 19 Global Const $DMPAPER_ENV_10 = 20 Global Const $DMPAPER_ENV_11 = 21 Global Const $DMPAPER_ENV_12 = 22 Global Const $DMPAPER_ENV_14 = 23 Global Const $DMPAPER_CSHEET = 24 Global Const $DMPAPER_DSHEET = 25 Global Const $DMPAPER_ESHEET = 26 Global Const $DMPAPER_ENV_DL = 27 Global Const $DMPAPER_ENV_C5 = 28 Global Const $DMPAPER_ENV_C3 = 29 Global Const $DMPAPER_ENV_C4 = 30 Global Const $DMPAPER_ENV_C6 = 31 Global Const $DMPAPER_ENV_C65 = 32 Global Const $DMPAPER_ENV_B4 = 33 Global Const $DMPAPER_ENV_B5 = 34 Global Const $DMPAPER_ENV_B6 = 35 Global Const $DMPAPER_ENV_ITALY = 36 Global Const $DMPAPER_ENV_MONARCH = 37 Global Const $DMPAPER_ENV_PERSONAL = 38 Global Const $DMPAPER_FANFOLD_US = 39 Global Const $DMPAPER_FANFOLD_STD_GERMAN = 40 Global Const $DMPAPER_FANFOLD_LGL_GERMAN = 41 Global Const $DMPAPER_ISO_B4 = 42 Global Const $DMPAPER_JAPANESE_POSTCARD = 43 Global Const $DMPAPER_9X11 = 44 Global Const $DMPAPER_10X11 = 45 Global Const $DMPAPER_15X11 = 46 Global Const $DMPAPER_ENV_INVITE = 47 Global Const $DMPAPER_RESERVED_48 = 48 Global Const $DMPAPER_RESERVED_49 = 49 Global Const $DMPAPER_LETTER_EXTRA = 50 Global Const $DMPAPER_LEGAL_EXTRA = 51 Global Const $DMPAPER_TABLOID_EXTRA = 52 Global Const $DMPAPER_A4_EXTRA = 53 Global Const $DMPAPER_LETTER_TRANSVERSE = 54 Global Const $DMPAPER_A4_TRANSVERSE = 55 Global Const $DMPAPER_LETTER_EXTRA_TRANSVERSE = 56 Global Const $DMPAPER_A_PLUS = 57 Global Const $DMPAPER_B_PLUS = 58 Global Const $DMPAPER_LETTER_PLUS = 59 Global Const $DMPAPER_A4_PLUS = 60 Global Const $DMPAPER_A5_TRANSVERSE = 61 Global Const $DMPAPER_B5_TRANSVERSE = 62 Global Const $DMPAPER_A3_EXTRA = 63 Global Const $DMPAPER_A5_EXTRA = 64 Global Const $DMPAPER_B5_EXTRA = 65 Global Const $DMPAPER_A2 = 66 Global Const $DMPAPER_A3_TRANSVERSE = 67 Global Const $DMPAPER_A3_EXTRA_TRANSVERSE = 68 Global Const $DMPAPER_DBL_JAPANESE_POSTCARD = 69 Global Const $DMPAPER_A6 = 70 Global Const $DMPAPER_JENV_KAKU2 = 71 Global Const $DMPAPER_JENV_KAKU3 = 72 Global Const $DMPAPER_JENV_CHOU3 = 73 Global Const $DMPAPER_JENV_CHOU4 = 74 Global Const $DMPAPER_LETTER_ROTATED = 75 Global Const $DMPAPER_A3_ROTATED = 76 Global Const $DMPAPER_A4_ROTATED = 77 Global Const $DMPAPER_A5_ROTATED = 78 Global Const $DMPAPER_B4_JIS_ROTATED = 79 Global Const $DMPAPER_B5_JIS_ROTATED = 80 Global Const $DMPAPER_JAPANESE_POSTCARD_ROTATED = 81 Global Const $DMPAPER_DBL_JAPANESE_POSTCARD_ROTATED = 82 Global Const $DMPAPER_A6_ROTATED = 83 Global Const $DMPAPER_JENV_KAKU2_ROTATED = 84 Global Const $DMPAPER_JENV_KAKU3_ROTATED = 85 Global Const $DMPAPER_JENV_CHOU3_ROTATED = 86 Global Const $DMPAPER_JENV_CHOU4_ROTATED = 87 Global Const $DMPAPER_B6_JIS = 88 Global Const $DMPAPER_B6_JIS_ROTATED = 89 Global Const $DMPAPER_12X11 = 90 Global Const $DMPAPER_JENV_YOU4 = 91 Global Const $DMPAPER_JENV_YOU4_ROTATED = 92 Global Const $DMPAPER_P16K = 93 Global Const $DMPAPER_P32K = 94 Global Const $DMPAPER_P32KBIG = 95 Global Const $DMPAPER_PENV_1 = 96 Global Const $DMPAPER_PENV_2 = 97 Global Const $DMPAPER_PENV_3 = 98 Global Const $DMPAPER_PENV_4 = 99 Global Const $DMPAPER_PENV_5 = 100 Global Const $DMPAPER_PENV_6 = 101 Global Const $DMPAPER_PENV_7 = 102 Global Const $DMPAPER_PENV_8 = 103 Global Const $DMPAPER_PENV_9 = 104 Global Const $DMPAPER_PENV_10 = 105 Global Const $DMPAPER_P16K_ROTATED = 106 Global Const $DMPAPER_P32K_ROTATED = 107 Global Const $DMPAPER_P32KBIG_ROTATED = 108 Global Const $DMPAPER_PENV_1_ROTATED = 109 Global Const $DMPAPER_PENV_2_ROTATED = 110 Global Const $DMPAPER_PENV_3_ROTATED = 111 Global Const $DMPAPER_PENV_4_ROTATED = 112 Global Const $DMPAPER_PENV_5_ROTATED = 113 Global Const $DMPAPER_PENV_6_ROTATED = 114 Global Const $DMPAPER_PENV_7_ROTATED = 115 Global Const $DMPAPER_PENV_8_ROTATED = 116 Global Const $DMPAPER_PENV_9_ROTATED = 117 Global Const $DMPAPER_PENV_10_ROTATED = 118 Global Const $DMPAPER_USER = 256 Global Const $DMBIN_UPPER = 1 Global Const $DMBIN_LOWER = 2 Global Const $DMBIN_MIDDLE = 3 Global Const $DMBIN_MANUAL = 4 Global Const $DMBIN_ENVELOPE = 5 Global Const $DMBIN_ENVMANUAL = 6 Global Const $DMBIN_AUTO = 7 Global Const $DMBIN_TRACTOR = 8 Global Const $DMBIN_SMALLFMT = 9 Global Const $DMBIN_LARGEFMT = 10 Global Const $DMBIN_LARGECAPACITY = 11 Global Const $DMBIN_CASSETTE = 14 Global Const $DMBIN_FORMSOURCE = 15 Global Const $DMBIN_USER = 256 Global Const $DMRES_DRAFT = -1 Global Const $DMRES_LOW = -2 Global Const $DMRES_MEDIUM = -3 Global Const $DMRES_HIGH = -4 Global Const $DMDO_DEFAULT = 0 Global Const $DMDO_90 = 1 Global Const $DMDO_180 = 2 Global Const $DMDO_270 = 3 Global Const $DMDFO_DEFAULT = 0 Global Const $DMDFO_STRETCH = 1 Global Const $DMDFO_CENTER = 2 Global Const $DMCOLOR_MONOCHROME = 1 Global Const $DMCOLOR_COLOR = 2 Global Const $DMDUP_SIMPLEX = 1 Global Const $DMDUP_VERTICAL = 2 Global Const $DMDUP_HORIZONTAL = 3 Global Const $DMTT_BITMAP = 1 Global Const $DMTT_DOWNLOAD = 2 Global Const $DMTT_SUBDEV = 3 Global Const $DMTT_DOWNLOAD_OUTLINE = 4 Global Const $DMCOLLATE_FALSE = 0 Global Const $DMCOLLATE_TRUE = 1 Global Const $DM_GRAYSCALE = 1 Global Const $DM_INTERLACED = 2 Global Const $DMNUP_SYSTEM = 1 Global Const $DMNUP_ONEUP = 2 Global Const $DMICMMETHOD_NONE = 1 Global Const $DMICMMETHOD_SYSTEM = 2 Global Const $DMICMMETHOD_DRIVER = 3 Global Const $DMICMMETHOD_DEVICE = 4 Global Const $DMICMMETHOD_USER = 256 Global Const $DMICM_SATURATE = 1 Global Const $DMICM_CONTRAST = 2 Global Const $DMICM_COLORIMETRIC = 3 Global Const $DMICM_ABS_COLORIMETRIC = 4 Global Const $DMICM_USER = 256 Global Const $DMMEDIA_STANDARD = 1 Global Const $DMMEDIA_TRANSPARENCY = 2 Global Const $DMMEDIA_GLOSSY = 3 Global Const $DMMEDIA_USER = 256 Global Const $DMDITHER_NONE = 1 Global Const $DMDITHER_COARSE = 2 Global Const $DMDITHER_FINE = 3 Global Const $DMDITHER_LINEART = 4 Global Const $DMDITHER_ERRORDIFFUSION = 5 Global Const $DMDITHER_RESERVED6 = 6 Global Const $DMDITHER_RESERVED7 = 7 Global Const $DMDITHER_RESERVED8 = 8 Global Const $DMDITHER_RESERVED9 = 9 Global Const $DMDITHER_GRAYSCALE = 10 Global Const $DMDITHER_USER = 256 Global Const $ENUM_CURRENT_SETTINGS = -1 Global Const $ENUM_REGISTRY_SETTINGS = -2 Global Const $DEVICE_FONTTYPE = 0x2 Global Const $RASTER_FONTTYPE = 0x1 Global Const $TRUETYPE_FONTTYPE = 0x4 Global Const $NTM_BOLD = 0x00000020 Global Const $NTM_DSIG = 0x00200000 Global Const $NTM_ITALIC = 0x00000001 Global Const $NTM_MULTIPLEMASTER = 0x00080000 Global Const $NTM_NONNEGATIVE_AC = 0x00010000 Global Const $NTM_PS_OPENTYPE = 0x00020000 Global Const $NTM_REGULAR = 0x00000040 Global Const $NTM_TT_OPENTYPE = 0x00040000 Global Const $NTM_TYPE1 = 0x00100000 Global Const $FLOODFILLBORDER = 0 Global Const $FLOODFILLSURFACE = 1 Global Const $AD_COUNTERCLOCKWISE = 1 Global Const $AD_CLOCKWISE = 2 Global Const $DCB_ACCUMULATE = 0x02 Global Const $DCB_DISABLE = 0x08 Global Const $DCB_ENABLE = 0x04 Global Const $DCB_RESET = 0x01 Global Const $DCB_SET = BitOR($DCB_RESET, $DCB_ACCUMULATE) Global Const $DCX_WINDOW = 0x00000001 Global Const $DCX_CACHE = 0x00000002 Global Const $DCX_PARENTCLIP = 0x00000020 Global Const $DCX_CLIPSIBLINGS = 0x00000010 Global Const $DCX_CLIPCHILDREN = 0x00000008 Global Const $DCX_NORESETATTRS = 0x00000004 Global Const $DCX_LOCKWINDOWUPDATE = 0x00000400 Global Const $DCX_EXCLUDERGN = 0x00000040 Global Const $DCX_INTERSECTRGN = 0x00000080 Global Const $DCX_INTERSECTUPDATE = 0x00000200 Global Const $DCX_VALIDATE = 0x00200000 Global Const $GGO_BEZIER = 3 Global Const $GGO_BITMAP = 1 Global Const $GGO_GLYPH_INDEX = 0x0080 Global Const $GGO_GRAY2_BITMAP = 4 Global Const $GGO_GRAY4_BITMAP = 5 Global Const $GGO_GRAY8_BITMAP = 6 Global Const $GGO_METRICS = 0 Global Const $GGO_NATIVE = 2 Global Const $GGO_UNHINTED = 0x0100 Global Const $GM_COMPATIBLE = 1 Global Const $GM_ADVANCED = 2 Global Const $MM_ANISOTROPIC = 8 Global Const $MM_HIENGLISH = 5 Global Const $MM_HIMETRIC = 3 Global Const $MM_ISOTROPIC = 7 Global Const $MM_LOENGLISH = 4 Global Const $MM_LOMETRIC = 2 Global Const $MM_TEXT = 1 Global Const $MM_TWIPS = 6 Global Const $R2_BLACK = 1 Global Const $R2_COPYPEN = 13 Global Const $R2_LAST = 16 Global Const $R2_MASKNOTPEN = 3 Global Const $R2_MASKPEN = 9 Global Const $R2_MASKPENNOT = 5 Global Const $R2_MERGENOTPEN = 12 Global Const $R2_MERGEPEN = 15 Global Const $R2_MERGEPENNOT = 14 Global Const $R2_NOP = 11 Global Const $R2_NOT = 6 Global Const $R2_NOTCOPYPEN = 4 Global Const $R2_NOTMASKPEN = 8 Global Const $R2_NOTMERGEPEN = 2 Global Const $R2_NOTXORPEN = 10 Global Const $R2_WHITE = 16 Global Const $R2_XORPEN = 7 Global Const $BLACKONWHITE = 1 Global Const $COLORONCOLOR = 3 Global Const $HALFTONE = 4 Global Const $WHITEONBLACK = 2 Global Const $STRETCH_ANDSCANS = $BLACKONWHITE Global Const $STRETCH_DELETESCANS = $COLORONCOLOR Global Const $STRETCH_HALFTONE = $HALFTONE Global Const $STRETCH_ORSCANS = $WHITEONBLACK Global Const $TA_BASELINE = 0x0018 Global Const $TA_BOTTOM = 0x0008 Global Const $TA_TOP = 0x0000 Global Const $TA_CENTER = 0x0006 Global Const $TA_LEFT = 0x0000 Global Const $TA_RIGHT = 0x0002 Global Const $TA_NOUPDATECP = 0x0000 Global Const $TA_RTLREADING = 0x0100 Global Const $TA_UPDATECP = 0x0001 Global Const $VTA_BASELINE = $TA_BASELINE Global Const $VTA_BOTTOM = $TA_RIGHT Global Const $VTA_TOP = $TA_LEFT Global Const $VTA_CENTER = $TA_CENTER Global Const $VTA_LEFT = $TA_BOTTOM Global Const $VTA_RIGHT = $TA_TOP Global Const $UDF_BGR = 1 Global Const $UDF_RGB = 0 Global Const $MWT_IDENTITY = 0x01 Global Const $MWT_LEFTMULTIPLY = 0x02 Global Const $MWT_RIGHTMULTIPLY = 0x03 Global Const $MWT_SET = 0x04 Global Const $MONITOR_DEFAULTTONEAREST = 2 Global Const $MONITOR_DEFAULTTONULL = 0 Global Const $MONITOR_DEFAULTTOPRIMARY = 1 Global Const $PT_BEZIERTO = 4 Global Const $PT_LINETO = 2 Global Const $PT_MOVETO = 6 Global Const $PT_CLOSEFIGURE = 1 #Region Global Variables and Constants Global $__g_hHeap = 0 #EndRegion Global Variables and Constants #Region Functions list #EndRegion Functions list #Region Public Functions Func _WinAPI_CreateBuffer($iLength, $pBuffer = 0, $bAbort = True) $pBuffer = __HeapReAlloc($pBuffer, $iLength, 0, $bAbort) If @error Then Return SetError(@error, @extended, 0) Return $pBuffer EndFunc Func _WinAPI_CreateBufferFromStruct($tStruct, $pBuffer = 0, $bAbort = True) If Not IsDllStruct($tStruct) Then Return SetError(1, 0, 0) $pBuffer = __HeapReAlloc($pBuffer, DllStructGetSize($tStruct), 0, $bAbort) If @error Then Return SetError(@error + 100, @extended, 0) _WinAPI_MoveMemory($pBuffer, $tStruct, DllStructGetSize($tStruct)) Return $pBuffer EndFunc Func _WinAPI_CreateString($sString, $pString = 0, $iLength = -1, $bUnicode = True, $bAbort = True) $iLength = Number($iLength) If $iLength >= 0 Then $sString = StringLeft($sString, $iLength) Else $iLength = StringLen($sString) EndIf Local $iSize = $iLength + 1 If $bUnicode Then $iSize *= 2 EndIf $pString = __HeapReAlloc($pString, $iSize, 0, $bAbort) If @error Then Return SetError(@error, @extended, 0) DllStructSetData(DllStructCreate(($bUnicode ? 'wchar' : 'char') & '[' & ($iLength + 1) & ']', $pString), 1, $sString) Return SetExtended($iLength, $pString) EndFunc Func _WinAPI_EqualMemory($pSource1, $pSource2, $iLength) If _WinAPI_IsBadReadPtr($pSource1, $iLength) Then Return SetError(11, @extended, 0) If _WinAPI_IsBadReadPtr($pSource2, $iLength) Then Return SetError(12, @extended, 0) Local $aRet = DllCall('ntdll.dll', 'ulong_ptr', 'RtlCompareMemory', 'struct*', $pSource1, 'struct*', $pSource2, 'ulong_ptr', $iLength) If @error Then Return SetError(@error, @extended, 0) Return Number($aRet[0] = $iLength) EndFunc Func _WinAPI_FillMemory($pMemory, $iLength, $iValue = 0) If _WinAPI_IsBadWritePtr($pMemory, $iLength) Then Return SetError(11, @extended, 0) DllCall('ntdll.dll', 'none', 'RtlFillMemory', 'struct*', $pMemory, 'ulong_ptr', $iLength, 'byte', $iValue) If @error Then Return SetError(@error, @extended, 0) Return 1 EndFunc Func _WinAPI_FreeMemory($pMemory) If Not __HeapFree($pMemory, 1) Then Return SetError(@error, @extended, 0) Return 1 EndFunc Func _WinAPI_GetMemorySize($pMemory) Local $iResult = __HeapSize($pMemory, 1) If @error Then Return SetError(@error, @extended, 0) Return $iResult EndFunc Func _WinAPI_GlobalMemoryStatus() Local Const $tagMEMORYSTATUSEX = "dword Length;dword MemoryLoad;" & "uint64 TotalPhys;uint64 AvailPhys;uint64 TotalPageFile;uint64 AvailPageFile;" & "uint64 TotalVirtual;uint64 AvailVirtual;uint64 AvailExtendedVirtual" Local $tMem = DllStructCreate($tagMEMORYSTATUSEX) DllStructSetData($tMem, 1, DllStructGetSize($tMem)) Local $aRet = DllCall("kernel32.dll", "bool", "GlobalMemoryStatusEx", "struct*", $tMem) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Local $aMem[7] $aMem[0] = DllStructGetData($tMem, 2) $aMem[1] = DllStructGetData($tMem, 3) $aMem[2] = DllStructGetData($tMem, 4) $aMem[3] = DllStructGetData($tMem, 5) $aMem[4] = DllStructGetData($tMem, 6) $aMem[5] = DllStructGetData($tMem, 7) $aMem[6] = DllStructGetData($tMem, 8) Return $aMem EndFunc Func _WinAPI_IsBadCodePtr($pAddress) Local $aRet = DllCall('kernel32.dll', 'bool', 'IsBadCodePtr', 'struct*', $pAddress) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_IsBadReadPtr($pAddress, $iLength) Local $aRet = DllCall('kernel32.dll', 'bool', 'IsBadReadPtr', 'struct*', $pAddress, 'uint_ptr', $iLength) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_IsBadStringPtr($pAddress, $iLength) Local $aRet = DllCall('kernel32.dll', 'bool', 'IsBadStringPtr', 'struct*', $pAddress, 'uint_ptr', $iLength) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_IsBadWritePtr($pAddress, $iLength) Local $aRet = DllCall('kernel32.dll', 'bool', 'IsBadWritePtr', 'struct*', $pAddress, 'uint_ptr', $iLength) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_IsMemory($pMemory) Local $bResult = __HeapValidate($pMemory) Return SetError(@error, @extended, $bResult) EndFunc Func _WinAPI_LocalFree($hMemory) Local $aResult = DllCall("kernel32.dll", "handle", "LocalFree", "handle", $hMemory) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_MoveMemory($pDestination, $pSource, $iLength) If _WinAPI_IsBadReadPtr($pSource, $iLength) Then Return SetError(10, @extended, 0) If _WinAPI_IsBadWritePtr($pDestination, $iLength) Then Return SetError(11, @extended, 0) DllCall('ntdll.dll', 'none', 'RtlMoveMemory', 'struct*', $pDestination, 'struct*', $pSource, 'ulong_ptr', $iLength) If @error Then Return SetError(@error, @extended, 0) Return 1 EndFunc Func _WinAPI_ReadProcessMemory($hProcess, $pBaseAddress, $pBuffer, $iSize, ByRef $iRead) Local $aResult = DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $hProcess, "ptr", $pBaseAddress, "struct*", $pBuffer, "ulong_ptr", $iSize, "ulong_ptr*", 0) If @error Then Return SetError(@error, @extended, False) $iRead = $aResult[5] Return $aResult[0] EndFunc Func _WinAPI_WriteProcessMemory($hProcess, $pBaseAddress, $pBuffer, $iSize, ByRef $iWritten, $sBuffer = "ptr") Local $aResult = DllCall("kernel32.dll", "bool", "WriteProcessMemory", "handle", $hProcess, "ptr", $pBaseAddress, $sBuffer, $pBuffer, "ulong_ptr", $iSize, "ulong_ptr*", 0) If @error Then Return SetError(@error, @extended, False) $iWritten = $aResult[5] Return $aResult[0] EndFunc Func _WinAPI_ZeroMemory($pMemory, $iLength) If _WinAPI_IsBadWritePtr($pMemory, $iLength) Then Return SetError(11, @extended, 0) DllCall('ntdll.dll', 'none', 'RtlZeroMemory', 'struct*', $pMemory, 'ulong_ptr', $iLength) If @error Then Return SetError(@error, @extended, 0) Return 1 EndFunc #EndRegion Public Functions #Region Internal Functions Func __HeapAlloc($iSize, $bAbort = False) Local $aRet If Not $__g_hHeap Then $aRet = DllCall('kernel32.dll', 'handle', 'HeapCreate', 'dword', 0, 'ulong_ptr', 0, 'ulong_ptr', 0) If @error Or Not $aRet[0] Then __FatalExit(1, 'Error allocating memory.') $__g_hHeap = $aRet[0] EndIf $aRet = DllCall('kernel32.dll', 'ptr', 'HeapAlloc', 'handle', $__g_hHeap, 'dword', 0x00000008, 'ulong_ptr', $iSize) If @error Or Not $aRet[0] Then If $bAbort Then __FatalExit(1, 'Error allocating memory.') Return SetError(@error + 30, @extended, 0) EndIf Return $aRet[0] EndFunc Func __HeapFree(ByRef $pMemory, $bCheck = False, $iCurErr = @error, $iCurExt = @extended) If $bCheck And (Not __HeapValidate($pMemory)) Then Return SetError(@error, @extended, 0) Local $aRet = DllCall('kernel32.dll', 'int', 'HeapFree', 'handle', $__g_hHeap, 'dword', 0, 'ptr', $pMemory) If @error Or Not $aRet[0] Then Return SetError(@error + 40, @extended, 0) $pMemory = 0 Return SetError($iCurErr, $iCurExt, 1) EndFunc Func __HeapReAlloc($pMemory, $iSize, $bAmount = False, $bAbort = False) Local $aRet, $pRet If __HeapValidate($pMemory) Then If $bAmount And (__HeapSize($pMemory) >= $iSize) Then Return SetExtended(1, Ptr($pMemory)) $aRet = DllCall('kernel32.dll', 'ptr', 'HeapReAlloc', 'handle', $__g_hHeap, 'dword', 0x00000008, 'ptr', $pMemory, 'ulong_ptr', $iSize) If @error Or Not $aRet[0] Then If $bAbort Then __FatalExit(1, 'Error allocating memory.') Return SetError(@error + 20, @extended, Ptr($pMemory)) EndIf $pRet = $aRet[0] Else $pRet = __HeapAlloc($iSize, $bAbort) If @error Then Return SetError(@error, @extended, 0) EndIf Return $pRet EndFunc Func __HeapSize($pMemory, $bCheck = False) If $bCheck And (Not __HeapValidate($pMemory)) Then Return SetError(@error, @extended, 0) Local $aRet = DllCall('kernel32.dll', 'ulong_ptr', 'HeapSize', 'handle', $__g_hHeap, 'dword', 0, 'ptr', $pMemory) If @error Or ($aRet[0] = Ptr(-1)) Then Return SetError(@error + 50, @extended, 0) Return $aRet[0] EndFunc Func __HeapValidate($pMemory) If (Not $__g_hHeap) Or (Not Ptr($pMemory)) Then Return SetError(9, 0, False) Local $aRet = DllCall('kernel32.dll', 'int', 'HeapValidate', 'handle', $__g_hHeap, 'dword', 0, 'ptr', $pMemory) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc #EndRegion Internal Functions Global Const $SND_APPLICATION = 0x00000080 Global Const $SND_ALIAS = 0x00010000 Global Const $SND_ALIAS_ID = 0x00110000 Global Const $SND_ASYNC = 0x00000001 Global Const $SND_FILENAME = 0x00020000 Global Const $SND_LOOP = 0x00000008 Global Const $SND_MEMORY = 0x00000004 Global Const $SND_NODEFAULT = 0x00000002 Global Const $SND_NOSTOP = 0x00000010 Global Const $SND_NOWAIT = 0x00002000 Global Const $SND_PURGE = 0x00000040 Global Const $SND_RESOURCE = 0x00040004 Global Const $SND_SENTRY = 0x00080000 Global Const $SND_SYNC = 0x00000000 Global Const $SND_SYSTEM = 0x00200000 Global Const $SND_SYSTEM_NOSTOP = 0x00200010 Global Const $SND_ALIAS_SYSTEMASTERISK = 'SystemAsterisk' Global Const $SND_ALIAS_SYSTEMDEFAULT = 'SystemDefault' Global Const $SND_ALIAS_SYSTEMEXCLAMATION = 'SystemExclamation' Global Const $SND_ALIAS_SYSTEMEXIT = 'SystemExit' Global Const $SND_ALIAS_SYSTEMHAND = 'SystemHand' Global Const $SND_ALIAS_SYSTEMQUESTION = 'SystemQuestion' Global Const $SND_ALIAS_SYSTEMSTART = 'SystemStart' Global Const $SND_ALIAS_SYSTEMWELCOME = 'SystemWelcome' #Region Global Variables and Constants #EndRegion Global Variables and Constants #Region Functions list #EndRegion Functions list #Region Public Functions Func _WinAPI_ArrayToStruct(Const ByRef $aData, $iStart = 0, $iEnd = -1) If __CheckErrorArrayBounds($aData, $iStart, $iEnd) Then Return SetError(@error + 10, @extended, 0) Local $tagStruct = '' For $i = $iStart To $iEnd $tagStruct &= 'wchar[' & (StringLen($aData[$i]) + 1) & '];' Next Local $tData = DllStructCreate($tagStruct & 'wchar[1]') Local $iCount = 1 For $i = $iStart To $iEnd DllStructSetData($tData, $iCount, $aData[$i]) $iCount += 1 Next DllStructSetData($tData, $iCount, ChrW(0)) Return $tData EndFunc Func _WinAPI_CreateMargins($iLeftWidth, $iRightWidth, $iTopHeight, $iBottomHeight) Local $tMARGINS = DllStructCreate($tagMARGINS) DllStructSetData($tMARGINS, 1, $iLeftWidth) DllStructSetData($tMARGINS, 2, $iRightWidth) DllStructSetData($tMARGINS, 3, $iTopHeight) DllStructSetData($tMARGINS, 4, $iBottomHeight) Return $tMARGINS EndFunc Func _WinAPI_CreatePoint($iX, $iY) Local $tPOINT = DllStructCreate($tagPOINT) DllStructSetData($tPOINT, 1, $iX) DllStructSetData($tPOINT, 2, $iY) Return $tPOINT EndFunc Func _WinAPI_CreateRect($iLeft, $iTop, $iRight, $iBottom) Local $tRECT = DllStructCreate($tagRECT) DllStructSetData($tRECT, 1, $iLeft) DllStructSetData($tRECT, 2, $iTop) DllStructSetData($tRECT, 3, $iRight) DllStructSetData($tRECT, 4, $iBottom) Return $tRECT EndFunc Func _WinAPI_CreateRectEx($iX, $iY, $iWidth, $iHeight) Local $tRECT = DllStructCreate($tagRECT) DllStructSetData($tRECT, 1, $iX) DllStructSetData($tRECT, 2, $iY) DllStructSetData($tRECT, 3, $iX + $iWidth) DllStructSetData($tRECT, 4, $iY + $iHeight) Return $tRECT EndFunc Func _WinAPI_CreateSize($iWidth, $iHeight) Local $tSIZE = DllStructCreate($tagSIZE) DllStructSetData($tSIZE, 1, $iWidth) DllStructSetData($tSIZE, 2, $iHeight) Return $tSIZE EndFunc Func _WinAPI_CopyStruct($tStruct, $sStruct = '') Local $iSize = DllStructGetSize($tStruct) If Not $iSize Then Return SetError(1, 0, 0) Local $tResult If Not StringStripWS($sStruct, $STR_STRIPLEADING + $STR_STRIPTRAILING + $STR_STRIPSPACES) Then $tResult = DllStructCreate('byte[' & $iSize & ']') Else $tResult = DllStructCreate($sStruct) EndIf If DllStructGetSize($tResult) < $iSize Then Return SetError(2, 0, 0) _WinAPI_MoveMemory($tResult, $tStruct, $iSize) Return $tResult EndFunc Func _WinAPI_GetExtended() Return $__g_vExt EndFunc Func _WinAPI_GetMousePos($bToClient = False, $hWnd = 0) Local $iMode = Opt("MouseCoordMode", 1) Local $aPos = MouseGetPos() Opt("MouseCoordMode", $iMode) Local $tPoint = DllStructCreate($tagPOINT) DllStructSetData($tPoint, "X", $aPos[0]) DllStructSetData($tPoint, "Y", $aPos[1]) If $bToClient And Not _WinAPI_ScreenToClient($hWnd, $tPoint) Then Return SetError(@error + 20, @extended, 0) Return $tPoint EndFunc Func _WinAPI_GetMousePosX($bToClient = False, $hWnd = 0) Local $tPoint = _WinAPI_GetMousePos($bToClient, $hWnd) If @error Then Return SetError(@error, @extended, 0) Return DllStructGetData($tPoint, "X") EndFunc Func _WinAPI_GetMousePosY($bToClient = False, $hWnd = 0) Local $tPoint = _WinAPI_GetMousePos($bToClient, $hWnd) If @error Then Return SetError(@error, @extended, 0) Return DllStructGetData($tPoint, "Y") EndFunc Func _WinAPI_MulDiv($iNumber, $iNumerator, $iDenominator) Local $aResult = DllCall("kernel32.dll", "int", "MulDiv", "int", $iNumber, "int", $iNumerator, "int", $iDenominator) If @error Then Return SetError(@error, @extended, -1) Return $aResult[0] EndFunc Func _WinAPI_PlaySound($sSound, $iFlags = $SND_SYSTEM_NOSTOP, $hInstance = 0) Local $sTypeOfSound = 'ptr' If $sSound Then If IsString($sSound) Then $sTypeOfSound = 'wstr' EndIf Else $sSound = 0 $iFlags = 0 EndIf Local $aRet = DllCall('winmm.dll', 'bool', 'PlaySoundW', $sTypeOfSound, $sSound, 'handle', $hInstance, 'dword', $iFlags) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_StringLenA(Const ByRef $tString) Local $aResult = DllCall("kernel32.dll", "int", "lstrlenA", "struct*", $tString) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_StringLenW(Const ByRef $tString) Local $aResult = DllCall("kernel32.dll", "int", "lstrlenW", "struct*", $tString) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_StructToArray(ByRef $tStruct, $iItems = 0) Local $iSize = 2 * Floor(DllStructGetSize($tStruct) / 2) Local $pStruct = DllStructGetPtr($tStruct) If Not $iSize Or Not $pStruct Then Return SetError(1, 0, 0) Local $tData, $iLength, $iOffset = 0 Local $aResult[101] = [0] While 1 $iLength = _WinAPI_StrLen($pStruct + $iOffset) If Not $iLength Then ExitLoop EndIf If 2 * (1 + $iLength) + $iOffset > $iSize Then Return SetError(3, 0, 0) $tData = DllStructCreate('wchar[' & (1 + $iLength) & ']', $pStruct + $iOffset) If @error Then Return SetError(@error + 10, 0, 0) __Inc($aResult) $aResult[$aResult[0]] = DllStructGetData($tData, 1) If $aResult[0] = $iItems Then ExitLoop EndIf $iOffset += 2 * (1 + $iLength) If $iOffset >= $iSize Then Return SetError(3, 0, 0) WEnd If Not $aResult[0] Then Return SetError(2, 0, 0) __Inc($aResult, -1) Return $aResult EndFunc Func _WinAPI_UnionStruct($tStruct1, $tStruct2, $sStruct = '') Local $aSize[2] = [DllStructGetSize($tStruct1), DllStructGetSize($tStruct2)] If Not $aSize[0] Or Not $aSize[1] Then Return SetError(1, 0, 0) Local $tResult If Not StringStripWS($sStruct, $STR_STRIPLEADING + $STR_STRIPTRAILING + $STR_STRIPSPACES) Then $tResult = DllStructCreate('byte[' & ($aSize[0] + $aSize[1]) & ']') Else $tResult = DllStructCreate($sStruct) EndIf If DllStructGetSize($tResult) < ($aSize[0] + $aSize[1]) Then Return SetError(2, 0, 0) _WinAPI_MoveMemory($tResult, $tStruct1, $aSize[0]) _WinAPI_MoveMemory(DllStructGetPtr($tResult) + $aSize[0], $tStruct2, $aSize[1]) Return $tResult EndFunc #EndRegion Public Functions #Region Global Variables and Constants Global Const $tagBITMAP = 'struct;long bmType;long bmWidth;long bmHeight;long bmWidthBytes;ushort bmPlanes;ushort bmBitsPixel;ptr bmBits;endstruct' Global Const $tagBITMAPV5HEADER = 'struct;dword bV5Size;long bV5Width;long bV5Height;ushort bV5Planes;ushort bV5BitCount;dword bV5Compression;dword bV5SizeImage;long bV5XPelsPerMeter;long bV5YPelsPerMeter;dword bV5ClrUsed;dword bV5ClrImportant;dword bV5RedMask;dword bV5GreenMask;dword bV5BlueMask;dword bV5AlphaMask;dword bV5CSType;int bV5Endpoints[9];dword bV5GammaRed;dword bV5GammaGreen;dword bV5GammaBlue;dword bV5Intent;dword bV5ProfileData;dword bV5ProfileSize;dword bV5Reserved;endstruct' Global Const $tagDIBSECTION = $tagBITMAP & ';' & $tagBITMAPINFOHEADER & ';dword dsBitfields[3];ptr dshSection;dword dsOffset' Global Const $TMPF_FIXED_PITCH = 0x01 Global Const $TMPF_VECTOR = 0x02 Global Const $TMPF_TRUETYPE = 0x04 Global Const $TMPF_DEVICE = 0x08 Global Const $__WINAPICONSTANT_FW_NORMAL = 400 Global Const $__WINAPICONSTANT_DEFAULT_CHARSET = 1 Global Const $__WINAPICONSTANT_OUT_DEFAULT_PRECIS = 0 Global Const $__WINAPICONSTANT_CLIP_DEFAULT_PRECIS = 0 Global Const $__WINAPICONSTANT_DEFAULT_QUALITY = 0 #EndRegion Global Variables and Constants #Region Functions list #EndRegion Functions list #Region Public Functions Func _WinAPI_BitBlt($hDestDC, $iXDest, $iYDest, $iWidth, $iHeight, $hSrcDC, $iXSrc, $iYSrc, $iROP) 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) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_CombineRgn($hRgnDest, $hRgnSrc1, $hRgnSrc2, $iCombineMode) Local $aResult = DllCall("gdi32.dll", "int", "CombineRgn", "handle", $hRgnDest, "handle", $hRgnSrc1, "handle", $hRgnSrc2, "int", $iCombineMode) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_CopyBitmap($hBitmap) $hBitmap = _WinAPI_CopyImage($hBitmap, 0, 0, 0, 0x2000) Return SetError(@error, @extended, $hBitmap) EndFunc Func _WinAPI_CopyImage($hImage, $iType = 0, $iXDesiredPixels = 0, $iYDesiredPixels = 0, $iFlags = 0) Local $aRet = DllCall('user32.dll', 'handle', 'CopyImage', 'handle', $hImage, 'uint', $iType, 'int', $iXDesiredPixels, 'int', $iYDesiredPixels, 'uint', $iFlags) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_CreateANDBitmap($hBitmap) Local $iError = 0, $hDib = 0 $hBitmap = _WinAPI_CopyBitmap($hBitmap) If Not $hBitmap Then Return SetError(@error + 20, @extended, 0) Do Local $atDIB[2] $atDIB[0] = DllStructCreate($tagDIBSECTION) If (Not _WinAPI_GetObject($hBitmap, DllStructGetSize($atDIB[0]), $atDIB[0])) Or (DllStructGetData($atDIB[0], 'bmBitsPixel') <> 32) Or (DllStructGetData($atDIB[0], 'biCompression')) Then $iError = 10 ExitLoop EndIf $atDIB[1] = DllStructCreate($tagBITMAP) $hDib = _WinAPI_CreateDIB(DllStructGetData($atDIB[0], 'bmWidth'), DllStructGetData($atDIB[0], 'bmHeight'), 1) If Not _WinAPI_GetObject($hDib, DllStructGetSize($atDIB[1]), $atDIB[1]) Then $iError = 11 ExitLoop EndIf Local $aRet = DllCall('user32.dll', 'lresult', 'CallWindowProc', 'ptr', __ANDProc(), 'ptr', 0, 'uint', 0, 'wparam', DllStructGetPtr($atDIB[0]), 'lparam', DllStructGetPtr($atDIB[1])) If @error Then $iError = @error ExitLoop EndIf If Not $aRet[0] Then $iError = 12 ExitLoop EndIf $iError = 0 Until 1 _WinAPI_DeleteObject($hBitmap) If $iError Then If $hDib Then _WinAPI_DeleteObject($hDib) EndIf $hDib = 0 EndIf Return SetError($iError, 0, $hDib) EndFunc Func _WinAPI_CreateBitmap($iWidth, $iHeight, $iPlanes = 1, $iBitsPerPel = 1, $pBits = 0) Local $aResult = DllCall("gdi32.dll", "handle", "CreateBitmap", "int", $iWidth, "int", $iHeight, "uint", $iPlanes, "uint", $iBitsPerPel, "struct*", $pBits) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight) Local $aResult = DllCall("gdi32.dll", "handle", "CreateCompatibleBitmap", "handle", $hDC, "int", $iWidth, "int", $iHeight) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_CreateDIB($iWidth, $iHeight, $iBitsPerPel = 32, $tColorTable = 0, $iColorCount = 0) Local $aRGBQ[2], $iColors, $tagRGBQ Switch $iBitsPerPel Case 1 $iColors = 2 Case 4 $iColors = 16 Case 8 $iColors = 256 Case Else $iColors = 0 EndSwitch If $iColors Then If Not IsDllStruct($tColorTable) Then Switch $iBitsPerPel Case 1 $aRGBQ[0] = 0 $aRGBQ[1] = 0xFFFFFF $tColorTable = _WinAPI_CreateDIBColorTable($aRGBQ) Case Else EndSwitch Else If $iColors > $iColorCount Then $iColors = $iColorCount EndIf If (Not $iColors) Or ((4 * $iColors) > DllStructGetSize($tColorTable)) Then Return SetError(20, 0, 0) EndIf EndIf $tagRGBQ = ';dword aRGBQuad[' & $iColors & ']' Else $tagRGBQ = '' EndIf Local $tBITMAPINFO = DllStructCreate($tagBITMAPINFOHEADER & $tagRGBQ) DllStructSetData($tBITMAPINFO, 'biSize', 40) DllStructSetData($tBITMAPINFO, 'biWidth', $iWidth) DllStructSetData($tBITMAPINFO, 'biHeight', $iHeight) DllStructSetData($tBITMAPINFO, 'biPlanes', 1) DllStructSetData($tBITMAPINFO, 'biBitCount', $iBitsPerPel) DllStructSetData($tBITMAPINFO, 'biCompression', 0) DllStructSetData($tBITMAPINFO, 'biSizeImage', 0) DllStructSetData($tBITMAPINFO, 'biXPelsPerMeter', 0) DllStructSetData($tBITMAPINFO, 'biYPelsPerMeter', 0) DllStructSetData($tBITMAPINFO, 'biClrUsed', $iColors) DllStructSetData($tBITMAPINFO, 'biClrImportant', 0) If $iColors Then If IsDllStruct($tColorTable) Then _WinAPI_MoveMemory(DllStructGetPtr($tBITMAPINFO, 'aRGBQuad'), $tColorTable, 4 * $iColors) Else _WinAPI_ZeroMemory(DllStructGetPtr($tBITMAPINFO, 'aRGBQuad'), 4 * $iColors) EndIf EndIf Local $hBitmap = _WinAPI_CreateDIBSection(0, $tBITMAPINFO, 0, $__g_vExt) If Not $hBitmap Then Return SetError(@error, @extended, 0) Return $hBitmap EndFunc Func _WinAPI_CreateDIBSection($hDC, $tBITMAPINFO, $iUsage, ByRef $pBits, $hSection = 0, $iOffset = 0) $pBits = 0 Local $aRet = DllCall('gdi32.dll', 'handle', 'CreateDIBSection', 'handle', $hDC, 'struct*', $tBITMAPINFO, 'uint', $iUsage, 'ptr*', 0, 'handle', $hSection, 'dword', $iOffset) If @error Or Not $aRet[0] Then Return SetError(@error, @extended, 0) $pBits = $aRet[4] Return $aRet[0] EndFunc Func _WinAPI_CreateDIBColorTable(Const ByRef $aColorTable, $iStart = 0, $iEnd = -1) If __CheckErrorArrayBounds($aColorTable, $iStart, $iEnd) Then Return SetError(@error + 10, @extended, 0) Local $tColorTable = DllStructCreate('dword[' & ($iEnd - $iStart + 1) & ']') Local $iCount = 1 For $i = $iStart To $iEnd DllStructSetData($tColorTable, 1, _WinAPI_SwitchColor(__RGB($aColorTable[$i])), $iCount) $iCount += 1 Next Return $tColorTable EndFunc Func _WinAPI_CreateFont($iHeight, $iWidth, $iEscape = 0, $iOrientn = 0, $iWeight = $__WINAPICONSTANT_FW_NORMAL, $bItalic = False, $bUnderline = False, $bStrikeout = False, $iCharset = $__WINAPICONSTANT_DEFAULT_CHARSET, $iOutputPrec = $__WINAPICONSTANT_OUT_DEFAULT_PRECIS, $iClipPrec = $__WINAPICONSTANT_CLIP_DEFAULT_PRECIS, $iQuality = $__WINAPICONSTANT_DEFAULT_QUALITY, $iPitch = 0, $sFace = 'Arial') Local $aResult = DllCall("gdi32.dll", "handle", "CreateFontW", "int", $iHeight, "int", $iWidth, "int", $iEscape, "int", $iOrientn, "int", $iWeight, "dword", $bItalic, "dword", $bUnderline, "dword", $bStrikeout, "dword", $iCharset, "dword", $iOutputPrec, "dword", $iClipPrec, "dword", $iQuality, "dword", $iPitch, "wstr", $sFace) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_CreateFontIndirect($tLogFont) Local $aResult = DllCall("gdi32.dll", "handle", "CreateFontIndirectW", "struct*", $tLogFont) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_CreateRectRgn($iLeftRect, $iTopRect, $iRightRect, $iBottomRect) Local $aResult = DllCall("gdi32.dll", "handle", "CreateRectRgn", "int", $iLeftRect, "int", $iTopRect, "int", $iRightRect, "int", $iBottomRect) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_CreateRoundRectRgn($iLeftRect, $iTopRect, $iRightRect, $iBottomRect, $iWidthEllipse, $iHeightEllipse) Local $aResult = DllCall("gdi32.dll", "handle", "CreateRoundRectRgn", "int", $iLeftRect, "int", $iTopRect, "int", $iRightRect, "int", $iBottomRect, "int", $iWidthEllipse, "int", $iHeightEllipse) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_CreateSolidBrush($iColor) Local $aResult = DllCall("gdi32.dll", "handle", "CreateSolidBrush", "INT", $iColor) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_GetBitmapDimension($hBitmap) Local $tObj = DllStructCreate($tagBITMAP) Local $aRet = DllCall('gdi32.dll', 'int', 'GetObject', 'handle', $hBitmap, 'int', DllStructGetSize($tObj), 'struct*', $tObj) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return _WinAPI_CreateSize(DllStructGetData($tObj, 'bmWidth'), DllStructGetData($tObj, 'bmHeight')) EndFunc Func _WinAPI_GetSysColorBrush($iIndex) Local $aResult = DllCall("user32.dll", "handle", "GetSysColorBrush", "int", $iIndex) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_GetTextExtentPoint32($hDC, $sText) Local $tSize = DllStructCreate($tagSIZE) Local $iSize = StringLen($sText) Local $aRet = DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sText, "int", $iSize, "struct*", $tSize) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return $tSize EndFunc Func _WinAPI_GetTextMetrics($hDC) Local $tTEXTMETRIC = DllStructCreate($tagTEXTMETRIC) Local $aRet = DllCall('gdi32.dll', 'bool', 'GetTextMetricsW', 'handle', $hDC, 'struct*', $tTEXTMETRIC) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return $tTEXTMETRIC EndFunc Func _WinAPI_GetWindowRgn($hWnd, $hRgn) Local $aResult = DllCall("user32.dll", "int", "GetWindowRgn", "hwnd", $hWnd, "handle", $hRgn) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_IsAlphaBitmap($hBitmap) $hBitmap = _WinAPI_CopyBitmap($hBitmap) If Not $hBitmap Then Return SetError(@error + 20, @extended, 0) Local $aRet, $iError = 0 Do Local $tDIB = DllStructCreate($tagDIBSECTION) If (Not _WinAPI_GetObject($hBitmap, DllStructGetSize($tDIB), $tDIB)) Or (DllStructGetData($tDIB, 'bmBitsPixel') <> 32) Or (DllStructGetData($tDIB, 'biCompression')) Then $iError = 1 ExitLoop EndIf $aRet = DllCall('user32.dll', 'int', 'CallWindowProc', 'ptr', __AlphaProc(), 'ptr', 0, 'uint', 0, 'struct*', $tDIB, 'ptr', 0) If @error Or ($aRet[0] = -1) Then $iError = @error + 10 ExitLoop EndIf Until 1 _WinAPI_DeleteObject($hBitmap) If $iError Then Return SetError($iError, 0, 0) Return $aRet[0] EndFunc Func _WinAPI_PtInRect(ByRef $tRECT, ByRef $tPoint) Local $aResult = DllCall("user32.dll", "bool", "PtInRect", "struct*", $tRECT, "struct", $tPoint) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_RedrawWindow($hWnd, $tRECT = 0, $hRegion = 0, $iFlags = 5) Local $aResult = DllCall("user32.dll", "bool", "RedrawWindow", "hwnd", $hWnd, "struct*", $tRECT, "handle", $hRegion, "uint", $iFlags) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_SetWindowRgn($hWnd, $hRgn, $bRedraw = True) Local $aResult = DllCall("user32.dll", "int", "SetWindowRgn", "hwnd", $hWnd, "handle", $hRgn, "bool", $bRedraw) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc #EndRegion Public Functions #Region Embedded DLL Functions Func __AlphaProc() Static $pProc = 0 If Not $pProc Then If @AutoItX64 Then $pProc = __Init(Binary( '0x48894C240848895424104C894424184C894C24205541574831C050504883EC28' & '48837C24600074054831C0EB0748C7C0010000004821C0751F488B6C24604883' & '7D180074054831C0EB0748C7C0010000004821C07502EB0948C7C001000000EB' & '034831C04821C0740C48C7C0FFFFFFFF4863C0EB6F48C744242800000000488B' & '6C24604C637D04488B6C2460486345084C0FAFF849C1E7024983C7FC4C3B7C24' & '287C36488B6C24604C8B7D184C037C24284983C7034C897C2430488B6C243080' & '7D0000740C48C7C0010000004863C0EB1348834424280471A54831C04863C0EB' & '034831C04883C438415F5DC3')) Else $pProc = __Init(Binary( '0x555331C05050837C241C00740431C0EB05B80100000021C075198B6C241C837D' & '1400740431C0EB05B80100000021C07502EB07B801000000EB0231C021C07407' & 'B8FFFFFFFFEB4FC70424000000008B6C241C8B5D048B6C241C0FAF5D08C1E302' & '83C3FC3B1C247C288B6C241C8B5D14031C2483C303895C24048B6C2404807D00' & '007407B801000000EB0C8304240471BE31C0EB0231C083C4085B5DC21000')) EndIf EndIf Return $pProc EndFunc Func __ANDProc() Static $pProc = 0 If Not $pProc Then If @AutoItX64 Then $pProc = __Init(Binary( '0x48894C240848895424104C894424184C894C2420554157415648C7C009000000' & '4883EC0848C704240000000048FFC875EF4883EC284883BC24A0000000007405' & '4831C0EB0748C7C0010000004821C00F85840000004883BC24A8000000007405' & '4831C0EB0748C7C0010000004821C07555488BAC24A000000048837D18007405' & '4831C0EB0748C7C0010000004821C07522488BAC24A800000048837D18007405' & '4831C0EB0748C7C0010000004821C07502EB0948C7C001000000EB034831C048' & '21C07502EB0948C7C001000000EB034831C04821C07502EB0948C7C001000000' & 'EB034831C04821C0740B4831C04863C0E9D701000048C74424280000000048C7' & '44243000000000488BAC24A00000004C637D0849FFCF4C3B7C24300F8C9C0100' & '0048C74424380000000048C74424400000000048C744244800000000488BAC24' & 'A00000004C637D0449FFCF4C3B7C24480F8CDB000000488BAC24A00000004C8B' & '7D184C037C24284983C7034C897C2450488B6C2450807D000074264C8B7C2440' & '4C8B74243849F7DE4983C61F4C89F148C7C00100000048D3E04909C74C897C24' & '4048FF4424384C8B7C24384983FF1F7E6F4C8B7C244049F7D74C897C244048C7' & '442458180000004831C0483B4424587F3D488BAC24A80000004C8B7D184C037C' & '24604C897C24504C8B7C2440488B4C245849D3FF4C89F850488B6C2458588845' & '0048FF4424604883442458F871B948C74424380000000048C744244000000000' & '48834424280448FF4424480F810BFFFFFF48837C24380074794C8B7C244049F7' & 'D74C8B74243849F7DE4983C6204C89F148C7C0FFFFFFFF48D3E04921C74C897C' & '244048C7442458180000004831C0483B4424587F3D488BAC24A80000004C8B7D' & '184C037C24604C897C24504C8B7C2440488B4C245849D3FF4C89F850488B6C24' & '585888450048FF4424604883442458F871B948FF4424300F814AFEFFFF48C7C0' & '010000004863C0EB034831C04883C470415E415F5DC3')) Else $pProc = __Init(Binary( '0x555357BA0800000083EC04C70424000000004A75F3837C243800740431C0EB05' & 'B80100000021C07562837C243C00740431C0EB05B80100000021C0753F8B6C24' & '38837D1400740431C0EB05B80100000021C075198B6C243C837D1400740431C0' & 'EB05B80100000021C07502EB07B801000000EB0231C021C07502EB07B8010000' & '00EB0231C021C07502EB07B801000000EB0231C021C0740731C0E969010000C7' & '042400000000C7442404000000008B6C24388B5D084B3B5C24040F8C3F010000' & 'C744240800000000C744240C00000000C7442410000000008B6C24388B5D044B' & '3B5C24100F8CA90000008B6C24388B5D14031C2483C303895C24148B6C241480' & '7D0000741C8B5C240C8B7C2408F7DF83C71F89F9B801000000D3E009C3895C24' & '0CFF4424088B5C240883FB1F7E578B5C240CF7D3895C240CC744241818000000' & '31C03B4424187F2D8B6C243C8B5D14035C241C895C24148B5C240C8B4C2418D3' & 'FB538B6C241858884500FF44241C83442418F871CBC744240800000000C74424' & '0C0000000083042404FF4424100F8145FFFFFF837C240800745B8B5C240CF7D3' & '8B7C2408F7DF83C72089F9B8FFFFFFFFD3E021C3895C240CC744241818000000' & '31C03B4424187F2D8B6C243C8B5D14035C241C895C24148B5C240C8B4C2418D3' & 'FB538B6C241858884500FF44241C83442418F871CBFF4424040F81AFFEFFFFB8' & '01000000EB0231C083C4205F5B5DC21000')) EndIf EndIf Return $pProc EndFunc Func __XORProc() Static $pProc = 0 If Not $pProc Then If @AutoItX64 Then $pProc = __Init(Binary( '0x48894C240848895424104C894424184C894C24205541574831C050504883EC28' & '48837C24600074054831C0EB0748C7C0010000004821C0751B48837C24680074' & '054831C0EB0748C7C0010000004821C07502EB0948C7C001000000EB034831C0' & '4821C074084831C04863C0EB7748C7442428000000004C637C24584983C7FC4C' & '3B7C24287C4F4C8B7C24604C037C24284C897C2430488B6C2430807D00007405' & '4831C0EB0748C7C0010000004821C0741C4C8B7C24684C037C24284983C7034C' & '897C2430488B6C2430C64500FF48834424280471A148C7C0010000004863C0EB' & '034831C04883C438415F5DC3')) Else $pProc = __Init(Binary( '0x555331C05050837C241C00740431C0EB05B80100000021C07516837C24200074' & '0431C0EB05B80100000021C07502EB07B801000000EB0231C021C0740431C0EB' & '5AC70424000000008B5C241883C3FC3B1C247C3E8B5C241C031C24895C24048B' & '6C2404807D0000740431C0EB05B80100000021C074168B5C2420031C2483C303' & '895C24048B6C2404C64500FF8304240471B6B801000000EB0231C083C4085B5D' & 'C21000')) EndIf EndIf Return $pProc EndFunc #EndRegion Embedded DLL Functions #Region Internal Functions Func __Init($dData) Local $iLength = BinaryLen($dData) Local $aRet = DllCall('kernel32.dll', 'ptr', 'VirtualAlloc', 'ptr', 0, 'ulong_ptr', $iLength, 'dword', 0x00001000, 'dword', 0x00000040) If @error Or Not $aRet[0] Then __FatalExit(1, 'Error allocating memory.') Local $tData = DllStructCreate('byte[' & $iLength & "]", $aRet[0]) DllStructSetData($tData, 1, $dData) Return $aRet[0] EndFunc #EndRegion Internal Functions #Region Global Variables and Constants Global Const $DI_MASK = 0x0001 Global Const $DI_IMAGE = 0x0002 Global Const $DI_NORMAL = 0x0003 Global Const $DI_COMPAT = 0x0004 Global Const $DI_DEFAULTSIZE = 0x0008 Global Const $DI_NOMIRROR = 0x0010 Global Const $DISPLAY_DEVICE_ATTACHED_TO_DESKTOP = 0x00000001 Global Const $DISPLAY_DEVICE_MULTI_DRIVER = 0x00000002 Global Const $DISPLAY_DEVICE_PRIMARY_DEVICE = 0x00000004 Global Const $DISPLAY_DEVICE_MIRRORING_DRIVER = 0x00000008 Global Const $DISPLAY_DEVICE_VGA_COMPATIBLE = 0x00000010 Global Const $DISPLAY_DEVICE_REMOVABLE = 0x00000020 Global Const $DISPLAY_DEVICE_DISCONNECT = 0x02000000 Global Const $DISPLAY_DEVICE_REMOTE = 0x04000000 Global Const $DISPLAY_DEVICE_MODESPRUNED = 0x08000000 #EndRegion Global Variables and Constants #Region Functions list #EndRegion Functions list #Region Public Functions Func _WinAPI_CreateCompatibleDC($hDC) Local $aResult = DllCall("gdi32.dll", "handle", "CreateCompatibleDC", "handle", $hDC) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_DeleteDC($hDC) Local $aResult = DllCall("gdi32.dll", "bool", "DeleteDC", "handle", $hDC) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_DrawEdge($hDC, $tRECT, $iEdgeType, $iFlags) Local $aResult = DllCall("user32.dll", "bool", "DrawEdge", "handle", $hDC, "struct*", $tRECT, "uint", $iEdgeType, "uint", $iFlags) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_DrawFrameControl($hDC, $tRECT, $iType, $iState) Local $aResult = DllCall("user32.dll", "bool", "DrawFrameControl", "handle", $hDC, "struct*", $tRECT, "uint", $iType, "uint", $iState) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_DrawIcon($hDC, $iX, $iY, $hIcon) Local $aResult = DllCall("user32.dll", "bool", "DrawIcon", "handle", $hDC, "int", $iX, "int", $iY, "handle", $hIcon) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_DrawIconEx($hDC, $iX, $iY, $hIcon, $iWidth = 0, $iHeight = 0, $iStep = 0, $hBrush = 0, $iFlags = 3) Local $iOptions Switch $iFlags Case 1 $iOptions = $DI_MASK Case 2 $iOptions = $DI_IMAGE Case 3 $iOptions = $DI_NORMAL Case 4 $iOptions = $DI_COMPAT Case 5 $iOptions = $DI_DEFAULTSIZE Case Else $iOptions = $DI_NOMIRROR EndSwitch 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) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_DrawText($hDC, $sText, ByRef $tRECT, $iFlags) Local $aResult = DllCall("user32.dll", "int", "DrawTextW", "handle", $hDC, "wstr", $sText, "int", -1, "struct*", $tRECT, "uint", $iFlags) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_EnumDisplayDevices($sDevice, $iDevNum) Local $tName = 0, $iFlags = 0, $aDevice[5] If $sDevice <> "" Then $tName = DllStructCreate("wchar Text[" & StringLen($sDevice) + 1 & "]") DllStructSetData($tName, "Text", $sDevice) EndIf Local Const $tagDISPLAY_DEVICE = "dword Size;wchar Name[32];wchar String[128];dword Flags;wchar ID[128];wchar Key[128]" Local $tDevice = DllStructCreate($tagDISPLAY_DEVICE) Local $iDevice = DllStructGetSize($tDevice) DllStructSetData($tDevice, "Size", $iDevice) Local $aRet = DllCall("user32.dll", "bool", "EnumDisplayDevicesW", "struct*", $tName, "dword", $iDevNum, "struct*", $tDevice, "dword", 1) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Local $iN = DllStructGetData($tDevice, "Flags") If BitAND($iN, $DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) <> 0 Then $iFlags = BitOR($iFlags, 1) If BitAND($iN, $DISPLAY_DEVICE_PRIMARY_DEVICE) <> 0 Then $iFlags = BitOR($iFlags, 2) If BitAND($iN, $DISPLAY_DEVICE_MIRRORING_DRIVER) <> 0 Then $iFlags = BitOR($iFlags, 4) If BitAND($iN, $DISPLAY_DEVICE_VGA_COMPATIBLE) <> 0 Then $iFlags = BitOR($iFlags, 8) If BitAND($iN, $DISPLAY_DEVICE_REMOVABLE) <> 0 Then $iFlags = BitOR($iFlags, 16) If BitAND($iN, $DISPLAY_DEVICE_MODESPRUNED) <> 0 Then $iFlags = BitOR($iFlags, 32) $aDevice[0] = True $aDevice[1] = DllStructGetData($tDevice, "Name") $aDevice[2] = DllStructGetData($tDevice, "String") $aDevice[3] = $iFlags $aDevice[4] = DllStructGetData($tDevice, "ID") Return $aDevice EndFunc Func _WinAPI_FillRect($hDC, $tRECT, $hBrush) Local $aResult If IsPtr($hBrush) Then $aResult = DllCall("user32.dll", "int", "FillRect", "handle", $hDC, "struct*", $tRECT, "handle", $hBrush) Else $aResult = DllCall("user32.dll", "int", "FillRect", "handle", $hDC, "struct*", $tRECT, "dword_ptr", $hBrush) EndIf If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_FrameRect($hDC, $tRECT, $hBrush) Local $aResult = DllCall("user32.dll", "int", "FrameRect", "handle", $hDC, "struct*", $tRECT, "handle", $hBrush) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_GetBkMode($hDC) Local $aResult = DllCall("gdi32.dll", "int", "GetBkMode", "handle", $hDC) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_GetDC($hWnd) Local $aResult = DllCall("user32.dll", "handle", "GetDC", "hwnd", $hWnd) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_GetDCEx($hWnd, $hRgn, $iFlags) Local $aRet = DllCall('user32.dll', 'handle', 'GetDCEx', 'hwnd', $hWnd, 'handle', $hRgn, 'dword', $iFlags) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetDeviceCaps($hDC, $iIndex) Local $aResult = DllCall("gdi32.dll", "int", "GetDeviceCaps", "handle", $hDC, "int", $iIndex) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_GetTextColor($hDC) Local $aRet = DllCall('gdi32.dll', 'dword', 'GetTextColor', 'handle', $hDC) If @error Or ($aRet[0] = 4294967295) Then Return SetError(@error, @extended, -1) Return __RGB($aRet[0]) EndFunc Func _WinAPI_GetWindowDC($hWnd) Local $aResult = DllCall("user32.dll", "handle", "GetWindowDC", "hwnd", $hWnd) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_PrintWindow($hWnd, $hDC, $bClient = False) Local $aRet = DllCall('user32.dll', 'bool', 'PrintWindow', 'hwnd', $hWnd, 'handle', $hDC, 'uint', $bClient) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_ReleaseDC($hWnd, $hDC) Local $aResult = DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hWnd, "handle", $hDC) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_RestoreDC($hDC, $iID) Local $aRet = DllCall('gdi32.dll', 'bool', 'RestoreDC', 'handle', $hDC, 'int', $iID) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_SaveDC($hDC) Local $aRet = DllCall('gdi32.dll', 'int', 'SaveDC', 'handle', $hDC) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_SetBkColor($hDC, $iColor) Local $aResult = DllCall("gdi32.dll", "INT", "SetBkColor", "handle", $hDC, "INT", $iColor) If @error Then Return SetError(@error, @extended, -1) Return $aResult[0] EndFunc Func _WinAPI_SetBkMode($hDC, $iBkMode) Local $aResult = DllCall("gdi32.dll", "int", "SetBkMode", "handle", $hDC, "int", $iBkMode) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_SetTextColor($hDC, $iColor) Local $aResult = DllCall("gdi32.dll", "INT", "SetTextColor", "handle", $hDC, "INT", $iColor) If @error Then Return SetError(@error, @extended, -1) Return $aResult[0] EndFunc Func _WinAPI_TwipsPerPixelX() Local $hDC, $iTwipsPerPixelX $hDC = _WinAPI_GetDC(0) Local Const $__WINAPICONSTANT_LOGPIXELSX = 88 $iTwipsPerPixelX = 1440 / _WinAPI_GetDeviceCaps($hDC, $__WINAPICONSTANT_LOGPIXELSX) _WinAPI_ReleaseDC(0, $hDC) Return $iTwipsPerPixelX EndFunc Func _WinAPI_TwipsPerPixelY() Local $hDC, $iTwipsPerPixelY $hDC = _WinAPI_GetDC(0) Local Const $__WINAPICONSTANT_LOGPIXELSY = 90 $iTwipsPerPixelY = 1440 / _WinAPI_GetDeviceCaps($hDC, $__WINAPICONSTANT_LOGPIXELSY) _WinAPI_ReleaseDC(0, $hDC) Return $iTwipsPerPixelY EndFunc #EndRegion Public Functions #Region Internal Functions #EndRegion Internal Functions #Region Global Variables and Constants #EndRegion Global Variables and Constants #Region Functions list #EndRegion Functions list #Region Public Functions Global Const $tagICONINFO = "bool Icon;dword XHotSpot;dword YHotSpot;handle hMask;handle hColor" Func _WinAPI_AddIconTransparency($hIcon, $iPercent = 50, $bDelete = False) Local $tBITMAP, $hDib = 0, $hResult = 0 Local $ahBitmap[2] Local $tICONINFO = DllStructCreate($tagICONINFO) Local $aRet = DllCall('user32.dll', 'bool', 'GetIconInfo', 'handle', $hIcon, 'struct*', $tICONINFO) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) For $i = 0 To 1 $ahBitmap[$i] = DllStructGetData($tICONINFO, $i + 4) Next Local $iError = 0 Do $hDib = _WinAPI_CopyBitmap($ahBitmap[1]) If Not $hDib Then $iError = 20 ExitLoop EndIf $tBITMAP = DllStructCreate($tagBITMAP) If (Not _WinAPI_GetObject($hDib, DllStructGetSize($tBITMAP), $tBITMAP)) Or (DllStructGetData($tBITMAP, 'bmBitsPixel') <> 32) Then $iError = 21 ExitLoop EndIf $aRet = DllCall('user32.dll', 'lresult', 'CallWindowProc', 'PTR', __TransparencyProc(), 'hwnd', 0, 'uint', $iPercent, 'wparam', DllStructGetPtr($tBITMAP), 'lparam', 0) If @error Or Not $aRet[0] Then $iError = @error + 30 ExitLoop EndIf If $aRet[0] = -1 Then $hResult = _WinAPI_CreateEmptyIcon(DllStructGetData($tBITMAP, 'bmWidth'), DllStructGetData($tBITMAP, 'bmHeight')) Else $hResult = _WinAPI_CreateIconIndirect($hDib, $ahBitmap[0]) EndIf If Not $hResult Then $iError = 22 Until 1 If $hDib Then _WinAPI_DeleteObject($hDib) EndIf For $i = 0 To 1 If $ahBitmap[$i] Then _WinAPI_DeleteObject($ahBitmap[$i]) EndIf Next If $iError Then Return SetError($iError, 0, 0) If $bDelete Then _WinAPI_DestroyIcon($hIcon) EndIf Return $hResult EndFunc Func _WinAPI_CopyIcon($hIcon) Local $aResult = DllCall("user32.dll", "handle", "CopyIcon", "handle", $hIcon) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_Create32BitHICON($hIcon, $bDelete = False) Local $ahBitmap[2], $hResult = 0 Local $aDIB[2][2] = [[0, 0], [0, 0]] Local $tICONINFO = DllStructCreate($tagICONINFO) Local $aRet = DllCall('user32.dll', 'bool', 'GetIconInfo', 'handle', $hIcon, 'struct*', $tICONINFO) If @error Then Return SetError(@error, @extended, 0) If Not $aRet[0] Then Return SetError(10, 0, 0) For $i = 0 To 1 $ahBitmap[$i] = DllStructGetData($tICONINFO, $i + 4) Next If _WinAPI_IsAlphaBitmap($ahBitmap[1]) Then $aDIB[0][0] = _WinAPI_CreateANDBitmap($ahBitmap[1]) If Not @error Then $hResult = _WinAPI_CreateIconIndirect($ahBitmap[1], $aDIB[0][0]) EndIf Else Local $tSIZE = _WinAPI_GetBitmapDimension($ahBitmap[1]) Local $aSize[2] For $i = 0 To 1 $aSize[$i] = DllStructGetData($tSIZE, $i + 1) Next Local $hSrcDC = _WinAPI_CreateCompatibleDC(0) Local $hDstDC = _WinAPI_CreateCompatibleDC(0) Local $hSrcSv, $hDstSv For $i = 0 To 1 $aDIB[$i][0] = _WinAPI_CreateDIB($aSize[0], $aSize[1]) $aDIB[$i][1] = $__g_vExt $hSrcSv = _WinAPI_SelectObject($hSrcDC, $ahBitmap[$i]) $hDstSv = _WinAPI_SelectObject($hDstDC, $aDIB[$i][0]) _WinAPI_BitBlt($hDstDC, 0, 0, $aSize[0], $aSize[1], $hSrcDC, 0, 0, 0x00C000CA) _WinAPI_SelectObject($hSrcDC, $hSrcSv) _WinAPI_SelectObject($hDstDC, $hDstSv) Next _WinAPI_DeleteDC($hSrcDC) _WinAPI_DeleteDC($hDstDC) $aRet = DllCall('user32.dll', 'lresult', 'CallWindowProc', 'ptr', __XORProc(), 'ptr', 0, 'uint', $aSize[0] * $aSize[1] * 4, 'wparam', $aDIB[0][1], 'lparam', $aDIB[1][1]) If Not @error And $aRet[0] Then $hResult = _WinAPI_CreateIconIndirect($aDIB[1][0], $ahBitmap[0]) EndIf EndIf For $i = 0 To 1 _WinAPI_DeleteObject($ahBitmap[$i]) If $aDIB[$i][0] Then _WinAPI_DeleteObject($aDIB[$i][0]) EndIf Next If Not $hResult Then Return SetError(11, 0, 0) If $bDelete Then _WinAPI_DestroyIcon($hIcon) EndIf Return $hResult EndFunc Func _WinAPI_CreateEmptyIcon($iWidth, $iHeight, $iBitsPerPel = 32) Local $hXOR = _WinAPI_CreateDIB($iWidth, $iHeight, $iBitsPerPel) Local $hAND = _WinAPI_CreateDIB($iWidth, $iHeight, 1) Local $hDC = _WinAPI_CreateCompatibleDC(0) Local $hSv = _WinAPI_SelectObject($hDC, $hAND) Local $hBrush = _WinAPI_CreateSolidBrush(0xFFFFFF) Local $tRECT = _WinAPI_CreateRect(0, 0, $iWidth, $iHeight) _WinAPI_FillRect($hDC, $tRECT, $hBrush) _WinAPI_DeleteObject($hBrush) _WinAPI_SelectObject($hDC, $hSv) _WinAPI_DeleteDC($hDC) Local $hIcon = _WinAPI_CreateIconIndirect($hXOR, $hAND) Local $iError = @error If $hXOR Then _WinAPI_DeleteObject($hXOR) EndIf If $hAND Then _WinAPI_DeleteObject($hAND) EndIf If Not $hIcon Then Return SetError($iError + 10, 0, 0) Return $hIcon EndFunc Func _WinAPI_CreateIcon($hInstance, $iWidth, $iHeight, $iPlanes, $iBitsPixel, $pANDBits, $pXORBits) Local $aRet = DllCall('user32.dll', 'handle', 'CreateIcon', 'handle', $hInstance, 'int', $iWidth, 'int', $iHeight, 'byte', $iPlanes, 'byte', $iBitsPixel, 'struct*', $pANDBits, 'struct*', $pXORBits) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_CreateIconFromResourceEx($pData, $iSize, $bIcon = True, $iXDesiredPixels = 0, $iYDesiredPixels = 0, $iFlags = 0) Local $aRet = DllCall('user32.dll', 'handle', 'CreateIconFromResourceEx', 'ptr', $pData, 'dword', $iSize, 'bool', $bIcon, 'dword', 0x00030000, 'int', $iXDesiredPixels, 'int', $iYDesiredPixels, 'uint', $iFlags) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_CreateIconIndirect($hBitmap, $hMask, $iXHotspot = 0, $iYHotspot = 0, $bIcon = True) Local $tICONINFO = DllStructCreate($tagICONINFO) DllStructSetData($tICONINFO, 1, $bIcon) DllStructSetData($tICONINFO, 2, $iXHotspot) DllStructSetData($tICONINFO, 3, $iYHotspot) DllStructSetData($tICONINFO, 4, $hMask) DllStructSetData($tICONINFO, 5, $hBitmap) Local $aRet = DllCall('user32.dll', 'handle', 'CreateIconIndirect', 'struct*', $tICONINFO) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_DestroyIcon($hIcon) Local $aResult = DllCall("user32.dll", "bool", "DestroyIcon", "handle", $hIcon) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_ExtractIcon($sIcon, $iIndex, $bSmall = False) Local $pLarge, $pSmall, $tPtr = DllStructCreate('ptr') If $bSmall Then $pLarge = 0 $pSmall = DllStructGetPtr($tPtr) Else $pLarge = DllStructGetPtr($tPtr) $pSmall = 0 EndIf DllCall('shell32.dll', 'uint', 'ExtractIconExW', 'wstr', $sIcon, 'int', $iIndex, 'ptr', $pLarge, 'ptr', $pSmall, 'uint', 1) If @error Then Return SetError(@error, @extended, 0) Return DllStructGetData($tPtr, 1) EndFunc Func _WinAPI_ExtractIconEx($sFilePath, $iIndex, $paLarge, $paSmall, $iIcons) Local $aResult = DllCall("shell32.dll", "uint", "ExtractIconExW", "wstr", $sFilePath, "int", $iIndex, "struct*", $paLarge, "struct*", $paSmall, "uint", $iIcons) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_FileIconInit($bRestore = True) Local $aRet = DllCall('shell32.dll', 'int', 660, 'int', $bRestore) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return 1 EndFunc Func _WinAPI_GetIconDimension($hIcon) Local $tICONINFO = DllStructCreate($tagICONINFO) Local $aRet = DllCall('user32.dll', 'bool', 'GetIconInfo', 'handle', $hIcon, 'struct*', $tICONINFO) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Local $tSIZE = _WinAPI_GetBitmapDimension(DllStructGetData($tICONINFO, 5)) For $i = 4 To 5 _WinAPI_DeleteObject(DllStructGetData($tICONINFO, $i)) Next If Not IsDllStruct($tSIZE) Then Return SetError(20, 0, 0) Return $tSIZE EndFunc Func _WinAPI_GetIconInfo($hIcon) Local $tInfo = DllStructCreate($tagICONINFO) Local $aRet = DllCall("user32.dll", "bool", "GetIconInfo", "handle", $hIcon, "struct*", $tInfo) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Local $aIcon[6] $aIcon[0] = True $aIcon[1] = DllStructGetData($tInfo, "Icon") <> 0 $aIcon[2] = DllStructGetData($tInfo, "XHotSpot") $aIcon[3] = DllStructGetData($tInfo, "YHotSpot") $aIcon[4] = DllStructGetData($tInfo, "hMask") $aIcon[5] = DllStructGetData($tInfo, "hColor") Return $aIcon EndFunc Func _WinAPI_GetIconInfoEx($hIcon) Local $tIIEX = DllStructCreate('dword;int;dword;dword;ptr;ptr;ushort;wchar[260];wchar[260]') DllStructSetData($tIIEX, 1, DllStructGetSize($tIIEX)) Local $aRet = DllCall('user32.dll', 'bool', 'GetIconInfoExW', 'handle', $hIcon, 'struct*', $tIIEX) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Local $aResult[8] For $i = 0 To 7 $aResult[$i] = DllStructGetData($tIIEX, $i + 2) Next Return $aResult EndFunc Func _WinAPI_LoadIcon($hInstance, $sName) Local $sTypeOfName = 'int' If IsString($sName) Then $sTypeOfName = 'wstr' EndIf Local $aRet = DllCall('user32.dll', 'handle', 'LoadIconW', 'handle', $hInstance, $sTypeOfName, $sName) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_LoadIconMetric($hInstance, $sName, $iMetric) Local $sTypeOfName = 'int' If IsString($sName) Then $sTypeOfName = 'wstr' EndIf Local $aRet = DllCall('comctl32.dll', 'long', 'LoadIconMetric', 'handle', $hInstance, $sTypeOfName, $sName, 'int', $iMetric, 'handle*', 0) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return $aRet[4] EndFunc Func _WinAPI_LoadIconWithScaleDown($hInstance, $sName, $iWidth, $iHeight) Local $sTypeOfName = 'int' If IsString($sName) Then $sTypeOfName = 'wstr' EndIf Local $aRet = DllCall('comctl32.dll', 'long', 'LoadIconWithScaleDown', 'handle', $hInstance, $sTypeOfName, $sName, 'int', $iWidth, 'int', $iHeight, 'handle*', 0) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return $aRet[5] EndFunc Func _WinAPI_LoadShell32Icon($iIconID) Local $tIcons = DllStructCreate("ptr Data") Local $iIcons = _WinAPI_ExtractIconEx("shell32.dll", $iIconID, 0, $tIcons, 1) If @error Then Return SetError(@error, @extended, 0) If $iIcons <= 0 Then Return SetError(10, 0, 0) Return DllStructGetData($tIcons, "Data") EndFunc Func _WinAPI_LookupIconIdFromDirectoryEx($pData, $bIcon = True, $iXDesiredPixels = 0, $iYDesiredPixels = 0, $iFlags = 0) Local $aRet = DllCall('user32.dll', 'int', 'LookupIconIdFromDirectoryEx', 'ptr', $pData, 'bool', $bIcon, 'int', $iXDesiredPixels, 'int', $iYDesiredPixels, 'uint', $iFlags) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_MirrorIcon($hIcon, $bDelete = False) If Not $bDelete Then $hIcon = _WinAPI_CopyIcon($hIcon) EndIf Local $aRet = DllCall('comctl32.dll', 'int', 414, 'ptr', 0, 'ptr*', $hIcon) If @error Or Not $aRet[0] Then Local $iError = @error + 10 If $hIcon And Not $bDelete Then _WinAPI_DestroyIcon($hIcon) EndIf Return SetError($iError, 0, 0) EndIf Return $aRet[2] EndFunc #EndRegion Public Functions #Region Embedded DLL Functions Func __TransparencyProc() Static $pProc = 0 If Not $pProc Then If @AutoItX64 Then $pProc = __Init(Binary( '0x48894C240848895424104C894424184C894C24205541574831C0505050505050' & '4883EC284883BC24800000000074054831C0EB0748C7C0010000004821C07522' & '488BAC248000000048837D180074054831C0EB0748C7C0010000004821C07502' & 'EB0948C7C001000000EB034831C04821C0740B4831C04863C0E93C0100004C63' & '7C24784983FF647E0F48C7C0010000004863C0E9220100004C637C24784D21FF' & '7D08C74424780000000048C74424280100000048C74424300000000048C74424' & '3800000000488BAC24800000004C637D04488BAC2480000000486345084C0FAF' & 'F849C1E7024983C7FC4C3B7C24380F8C88000000488BAC24800000004C8B7D18' & '4C037C24384983C7034C897C2440488B6C2440480FB64500505888442448807C' & '244800744B4C0FB67C244848634424784C0FAFF84C89F848C7C1640000004899' & '48F7F94989C74C89F850488B6C244858884500488B6C2440807D0000740948C7' & '4424280000000048C7442430010000004883442438040F8149FFFFFF48837C24' & '3000741148837C242800740948C7C001000000EB034831C04821C0740E48C7C0' & 'FFFFFFFF4863C0EB11EB0C48C7C0010000004863C0EB034831C04883C458415F' & '5DC3')) Else $pProc = __Init(Binary( '0x555331C05050505050837C242800740431C0EB05B80100000021C075198B6C24' & '28837D1400740431C0EB05B80100000021C07502EB07B801000000EB0231C021' & 'C0740731C0E9E50000008B5C242483FB647E0AB801000000E9D20000008B5C24' & '2421DB7D08C744242400000000C7042401000000C744240400000000C7442408' & '000000008B6C24288B5D048B6C24280FAF5D08C1E30283C3FC3B5C24087C648B' & '6C24288B5D14035C240883C303895C240C8B6C240C0FB6450088442410807C24' & '100074380FB65C24100FAF5C242489D8B96400000099F7F989C3538B6C241058' & '8845008B6C240C807D00007407C7042400000000C74424040100000083442408' & '047181837C240400740D833C24007407B801000000EB0231C021C07409B8FFFF' & 'FFFFEB0BEB07B801000000EB0231C083C4145B5DC21000')) EndIf EndIf Return $pProc EndFunc #EndRegion Embedded DLL Functions #Region Global Variables and Constants Global Const $tagBITMAPV4HEADER = 'struct;dword bV4Size;long bV4Width;long bV4Height;ushort bV4Planes;ushort bV4BitCount;dword bV4Compression;dword bV4SizeImage;long bV4XPelsPerMeter;long bV4YPelsPerMeter;dword bV4ClrUsed;dword bV4ClrImportant;dword bV4RedMask;dword bV4GreenMask;dword bV4BlueMask;dword bV4AlphaMask;dword bV4CSType;int bV4Endpoints[9];dword bV4GammaRed;dword bV4GammaGreen;dword bV4GammaBlue;endstruct' Global Const $tagCOLORADJUSTMENT = 'ushort Size;ushort Flags;ushort IlluminantIndex;ushort RedGamma;ushort GreenGamma;ushort BlueGamma;ushort ReferenceBlack;ushort ReferenceWhite;short Contrast;short Brightness;short Colorfulness;short RedGreenTint' Global Const $tagDEVMODE = 'wchar DeviceName[32];ushort SpecVersion;ushort DriverVersion;ushort Size;ushort DriverExtra;dword Fields;short Orientation;short PaperSize;short PaperLength;short PaperWidth;short Scale;short Copies;short DefaultSource;short PrintQuality;short Color;short Duplex;short YResolution;short TTOption;short Collate;wchar FormName[32];ushort Unused1;dword Unused2[3];dword Nup;dword Unused3;dword ICMMethod;dword ICMIntent;dword MediaType;dword DitherType;dword Reserved1;dword Reserved2;dword PanningWidth;dword PanningHeight' Global Const $tagDEVMODE_DISPLAY = 'wchar DeviceName[32];ushort SpecVersion;ushort DriverVersion;ushort Size;ushort DriverExtra;dword Fields;' & $tagPOINT & ';dword DisplayOrientation;dword DisplayFixedOutput;short Unused1[5];wchar Unused2[32];ushort LogPixels;dword BitsPerPel;dword PelsWidth;dword PelsHeight;dword DisplayFlags;dword DisplayFrequency' Global Const $tagDWM_COLORIZATION_PARAMETERS = 'dword Color;dword AfterGlow;uint ColorBalance;uint AfterGlowBalance;uint BlurBalance;uint GlassReflectionIntensity; uint OpaqueBlend' Global Const $tagENHMETAHEADER = 'struct;dword Type;dword Size;long rcBounds[4];long rcFrame[4];dword Signature;dword Version;dword Bytes;dword Records;ushort Handles;ushort Reserved;dword Description;dword OffDescription;dword PalEntries;long Device[2];long Millimeters[2];dword PixelFormat;dword OffPixelFormat;dword OpenGL;long Micrometers[2];endstruct' Global Const $tagEXTLOGPEN = 'dword PenStyle;dword Width;uint BrushStyle;dword Color;ulong_ptr Hatch;dword NumEntries' Global Const $tagFONTSIGNATURE = 'dword fsUsb[4];dword fsCsb[2]' Global Const $tagGLYPHMETRICS = 'uint BlackBoxX;uint BlackBoxY;' & $tagPOINT & ';short CellIncX;short CellIncY' Global Const $tagLOGBRUSH = 'uint Style;dword Color;ulong_ptr Hatch' Global Const $tagLOGPEN = 'uint Style;dword Width;dword Color' Global Const $tagMAT2 = 'short eM11[2];short eM12[2];short eM21[2];short eM22[2]' Global Const $tagNEWTEXTMETRIC = $tagTEXTMETRIC & ';dword ntmFlags;uint ntmSizeEM;uint ntmCellHeight;uint ntmAvgWidth' Global Const $tagNEWTEXTMETRICEX = $tagNEWTEXTMETRIC & ';' & $tagFONTSIGNATURE Global Const $tagPANOSE = 'struct;byte bFamilyType;byte bSerifStyle;byte bWeight;byte bProportion;byte bContrast;byte bStrokeVariation;byte bArmStyle;byte bLetterform;byte bMidline;byte bXHeight;endstruct' Global Const $tagOUTLINETEXTMETRIC = 'struct;uint otmSize;' & $tagTEXTMETRIC & ';byte otmFiller;' & $tagPANOSE & ';byte bugFiller[3];uint otmSelection;uint otmType;int otmCharSlopeRise;int otmCharSlopeRun;int otmItalicAngle;uint otmEMSquare;int otmAscent;int otmDescent;uint otmLineGap;uint otmCapEmHeight;uint otmXHeight;long otmFontBox[4];int otmMacAscent;int otmMacDescent;uint otmMacLineGap;uint otmMinimumPPEM;long otmSubscriptSize[2];long otmSubscriptOffset[2];long otmSuperscriptSize[2];long otmSuperscriptOffse[2];uint otmStrikeoutSize;int otmStrikeoutPosition;int otmUnderscoreSize;int otmUnderscorePosition;uint_ptr otmFamilyName;uint_ptr otmFaceName;uint_ptr otmStyleName;uint_ptr otmFullName;endstruct' Global Const $tagPAINTSTRUCT = 'hwnd hDC;int fErase;dword rPaint[4];int fRestore;int fIncUpdate;byte rgbReserved[32]' Global Const $tagRGNDATAHEADER = 'struct;dword Size;dword Type;dword Count;dword RgnSize;' & $tagRECT & ';endstruct' Global Const $tagXFORM = 'float eM11;float eM12;float eM21;float eM22;float eDx;float eDy' #EndRegion Global Variables and Constants #Region Functions list #EndRegion Functions list #Region Public Functions Func _WinAPI_AbortPath($hDC) Local $aRet = DllCall('gdi32.dll', 'bool', 'AbortPath', 'handle', $hDC) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_AddFontMemResourceEx($pData, $iSize) Local $aRet = DllCall('gdi32.dll', 'handle', 'AddFontMemResourceEx', 'ptr', $pData, 'dword', $iSize, 'ptr', 0, 'dword*', 0) If @error Then Return SetError(@error, @extended, 0) Return SetExtended($aRet[4], $aRet[0]) EndFunc Func _WinAPI_AddFontResourceEx($sFont, $iFlag = 0, $bNotify = False) Local $aRet = DllCall('gdi32.dll', 'int', 'AddFontResourceExW', 'wstr', $sFont, 'dword', $iFlag, 'ptr', 0) If @error Or Not $aRet[0] Then Return SetError(@error, @extended, 0) If $bNotify Then Local Const $WM_FONTCHANGE = 0x001D Local Const $HWND_BROADCAST = 0xFFFF DllCall('user32.dll', 'lresult', 'SendMessage', 'hwnd', $HWND_BROADCAST, 'uint', $WM_FONTCHANGE, 'wparam', 0, 'lparam', 0) EndIf Return $aRet[0] EndFunc Func _WinAPI_AddIconOverlay($hIcon, $hOverlay) Local $aRet, $hResult = 0, $iError = 0 Local $ahDev[2] = [0, 0] Local $tSIZE = _WinAPI_GetIconDimension($hIcon) Local $hIL = DllCall('comctl32.dll', 'handle', 'ImageList_Create', 'int', DllStructGetData($tSIZE, 1), 'int', DllStructGetData($tSIZE, 2), 'uint', 0x0021, 'int', 2, 'int', 2) If @error Or Not $hIL[0] Then Return SetError(@error + 10, @extended, 0) Do $ahDev[0] = _WinAPI_Create32BitHICON($hIcon) If @error Then $iError = @error + 100 ExitLoop EndIf $aRet = DllCall('comctl32.dll', 'int', 'ImageList_ReplaceIcon', 'handle', $hIL[0], 'int', -1, 'handle', $ahDev[0]) If @error Or ($aRet[0] = -1) Then $iError = @error + 200 ExitLoop EndIf $ahDev[1] = _WinAPI_Create32BitHICON($hOverlay) If @error Then $iError = @error + 300 ExitLoop EndIf $aRet = DllCall('comctl32.dll', 'int', 'ImageList_ReplaceIcon', 'handle', $hIL[0], 'int', -1, 'handle', $ahDev[1]) If @error Or ($aRet[0] = -1) Then $iError = @error + 400 ExitLoop EndIf $aRet = DllCall('comctl32.dll', 'bool', 'ImageList_SetOverlayImage', 'handle', $hIL[0], 'int', 1, 'int', 1) If @error Or Not $aRet[0] Then $iError = @error + 500 ExitLoop EndIf $aRet = DllCall('comctl32.dll', 'handle', 'ImageList_GetIcon', 'handle', $hIL[0], 'int', 0, 'uint', 0x00000100) If @error Or Not $aRet[0] Then $iError = @error + 600 ExitLoop EndIf $hResult = $aRet[0] Until 1 DllCall('comctl32.dll', 'bool', 'ImageList_Destroy', 'handle', $hIL[0]) For $i = 0 To 1 If $ahDev[$i] Then _WinAPI_DestroyIcon($ahDev[$i]) EndIf Next If Not $hResult Then Return SetError($iError, 0, 0) Return $hResult EndFunc Func _WinAPI_AdjustBitmap($hBitmap, $iWidth, $iHeight, $iMode = 3, $tAdjustment = 0) Local $tObj = DllStructCreate($tagBITMAP) Local $aRet = DllCall('gdi32.dll', 'int', 'GetObject', 'handle', $hBitmap, 'int', DllStructGetSize($tObj), 'struct*', $tObj) If @error Or Not $aRet[0] Then Return SetError(@error, @extended, 0) If $iWidth = -1 Then $iWidth = DllStructGetData($tObj, 'bmWidth') EndIf If $iHeight = -1 Then $iHeight = DllStructGetData($tObj, 'bmHeight') EndIf $aRet = DllCall('user32.dll', 'handle', 'GetDC', 'hwnd', 0) Local $hDC = $aRet[0] $aRet = DllCall('gdi32.dll', 'handle', 'CreateCompatibleDC', 'handle', $hDC) Local $hDestDC = $aRet[0] $aRet = DllCall('gdi32.dll', 'handle', 'CreateCompatibleBitmap', 'handle', $hDC, 'int', $iWidth, 'int', $iHeight) Local $hBmp = $aRet[0] $aRet = DllCall('gdi32.dll', 'handle', 'SelectObject', 'handle', $hDestDC, 'handle', $hBmp) Local $hDestSv = $aRet[0] $aRet = DllCall('gdi32.dll', 'handle', 'CreateCompatibleDC', 'handle', $hDC) Local $hSrcDC = $aRet[0] $aRet = DllCall('gdi32.dll', 'handle', 'SelectObject', 'handle', $hSrcDC, 'handle', $hBitmap) Local $hSrcSv = $aRet[0] If _WinAPI_SetStretchBltMode($hDestDC, $iMode) Then Switch $iMode Case 4 If IsDllStruct($tAdjustment) Then If Not _WinAPI_SetColorAdjustment($hDestDC, $tAdjustment) Then EndIf EndIf Case Else EndSwitch EndIf $aRet = _WinAPI_StretchBlt($hDestDC, 0, 0, $iWidth, $iHeight, $hSrcDC, 0, 0, DllStructGetData($tObj, 'bmWidth'), DllStructGetData($tObj, 'bmHeight'), 0x00CC0020) DllCall('user32.dll', 'int', 'ReleaseDC', 'hwnd', 0, 'handle', $hDC) DllCall('gdi32.dll', 'handle', 'SelectObject', 'handle', $hDestDC, 'handle', $hDestSv) DllCall('gdi32.dll', 'handle', 'SelectObject', 'handle', $hSrcDC, 'handle', $hSrcSv) DllCall('gdi32.dll', 'bool', 'DeleteDC', 'handle', $hDestDC) DllCall('gdi32.dll', 'bool', 'DeleteDC', 'handle', $hSrcDC) If Not $aRet Then Return SetError(10, 0, 0) Return $hBmp EndFunc Func _WinAPI_AlphaBlend($hDestDC, $iXDest, $iYDest, $iWidthDest, $iHeightDest, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iAlpha, $bAlpha = False) Local $iBlend = BitOR(BitShift(Not ($bAlpha = False), -24), BitShift(BitAND($iAlpha, 0xFF), -16)) Local $aRet = DllCall('gdi32.dll', 'bool', 'GdiAlphaBlend', 'handle', $hDestDC, 'int', $iXDest, 'int', $iYDest, 'int', $iWidthDest, 'int', $iHeightDest, 'handle', $hSrcDC, 'int', $iXSrc, 'int', $iYSrc, 'int', $iWidthSrc, 'int', $iHeightSrc, 'dword', $iBlend) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_AngleArc($hDC, $iX, $iY, $iRadius, $nStartAngle, $nSweepAngle) Local $aRet = DllCall('gdi32.dll', 'bool', 'AngleArc', 'handle', $hDC, 'int', $iX, 'int', $iY, 'dword', $iRadius, 'float', $nStartAngle, 'float', $nSweepAngle) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_Arc($hDC, $tRECT, $iXStartArc, $iYStartArc, $iXEndArc, $iYEndArc) Local $aRet = DllCall('gdi32.dll', 'bool', 'Arc', 'handle', $hDC, 'int', DllStructGetData($tRECT, 1), 'int', DllStructGetData($tRECT, 2), 'int', DllStructGetData($tRECT, 3), 'int', DllStructGetData($tRECT, 4), 'int', $iXStartArc, 'int', $iYStartArc, 'int', $iXEndArc, 'int', $iYEndArc) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_ArcTo($hDC, $tRECT, $iXRadial1, $iYRadial1, $iXRadial2, $iYRadial2) Local $aRet = DllCall('gdi32.dll', 'bool', 'ArcTo', 'handle', $hDC, 'int', DllStructGetData($tRECT, 1), 'int', DllStructGetData($tRECT, 2), 'int', DllStructGetData($tRECT, 3), 'int', DllStructGetData($tRECT, 4), 'int', $iXRadial1, 'int', $iYRadial1, 'int', $iXRadial2, 'int', $iYRadial2) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_BeginPaint($hWnd, ByRef $tPAINTSTRUCT) $tPAINTSTRUCT = DllStructCreate($tagPAINTSTRUCT) Local $aRet = DllCall('user32.dll', 'handle', 'BeginPaint', 'hwnd', $hWnd, 'struct*', $tPAINTSTRUCT) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_BeginPath($hDC) Local $aRet = DllCall('gdi32.dll', 'bool', 'BeginPath', 'handle', $hDC) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_CloseEnhMetaFile($hDC) Local $aRet = DllCall('gdi32.dll', 'handle', 'CloseEnhMetaFile', 'handle', $hDC) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_CloseFigure($hDC) Local $aRet = DllCall('gdi32.dll', 'bool', 'CloseFigure', 'handle', $hDC) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_ColorAdjustLuma($iRGB, $iPercent, $bScale = True) If $iRGB = -1 Then Return SetError(10, 0, -1) If $bScale Then $iPercent = Floor($iPercent * 10) EndIf Local $aRet = DllCall('shlwapi.dll', 'dword', 'ColorAdjustLuma', 'dword', __RGB($iRGB), 'int', $iPercent, 'bool', $bScale) If @error Then Return SetError(@error, @extended, -1) Return __RGB($aRet[0]) EndFunc Func _WinAPI_ColorHLSToRGB($iHue, $iLuminance, $iSaturation) If Not $iSaturation Then $iHue = 160 Local $aRet = DllCall('shlwapi.dll', 'dword', 'ColorHLSToRGB', 'word', $iHue, 'word', $iLuminance, 'word', $iSaturation) If @error Then Return SetError(@error, @extended, -1) Return __RGB($aRet[0]) EndFunc Func _WinAPI_ColorRGBToHLS($iRGB, ByRef $iHue, ByRef $iLuminance, ByRef $iSaturation) Local $aRet = DllCall('shlwapi.dll', 'none', 'ColorRGBToHLS', 'dword', __RGB($iRGB), 'word*', 0, 'word*', 0, 'word*', 0) If @error Then Return SetError(@error, @extended, 0) $iHue = $aRet[2] $iLuminance = $aRet[3] $iSaturation = $aRet[4] Return 1 EndFunc Func _WinAPI_CombineTransform($tXFORM1, $tXFORM2) Local $tXFORM = DllStructCreate($tagXFORM) Local $aRet = DllCall('gdi32.dll', 'bool', 'CombineTransform', 'struct*', $tXFORM, 'struct*', $tXFORM1, 'struct*', $tXFORM2) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return $tXFORM EndFunc Func _WinAPI_CompressBitmapBits($hBitmap, ByRef $pBuffer, $iCompression = 0, $iQuality = 100) If Not __DLL('gdiplus.dll') Then Return SetError(103, 0, 0) Local $aSize[2], $iCount, $iFormat, $iLength, $sMime, $aRet, $hDC, $hSv, $hMem, $tBits, $tData, $pData, $iError = 1 Local $hSource = 0, $hImage = 0, $hToken = 0, $pStream = 0, $tParam = 0 Local $tDIB = DllStructCreate($tagDIBSECTION) Do Switch $iCompression Case 0 $sMime = 'image/png' Case 1 $sMime = 'image/jpeg' Case Else $iError = 10 ExitLoop EndSwitch While $hBitmap If Not _WinAPI_GetObject($hBitmap, DllStructGetSize($tDIB), $tDIB) Then $iError = 11 ExitLoop 2 EndIf If (DllStructGetData($tDIB, 'bmBitsPixel') = 32) And (Not DllStructGetData($tDIB, 'biCompression')) Then $iError = 12 ExitLoop EndIf If $hSource Then $iError = 13 ExitLoop 2 EndIf $hSource = _WinAPI_CreateDIB(DllStructGetData($tDIB, 'bmWidth'), DllStructGetData($tDIB, 'bmHeight')) If Not $hSource Then $iError = @error + 100 ExitLoop 2 EndIf $hDC = _WinAPI_CreateCompatibleDC(0) $hSv = _WinAPI_SelectObject($hDC, $hSource) If _WinAPI_DrawBitmap($hDC, 0, 0, $hBitmap) Then $hBitmap = $hSource Else $iError = @error + 200 $hBitmap = 0 EndIf _WinAPI_SelectObject($hDC, $hSv) _WinAPI_DeleteDC($hDC) WEnd If Not $hBitmap Then ExitLoop EndIf For $i = 0 To 1 $aSize[$i] = DllStructGetData($tDIB, $i + 2) Next $tBits = DllStructCreate('byte[' & ($aSize[0] * $aSize[1] * 4) & ']') If Not _WinAPI_GetBitmapBits($hBitmap, DllStructGetSize($tBits), $tBits) Then $iError = @error + 300 ExitLoop EndIf $tData = DllStructCreate($tagGDIPSTARTUPINPUT) DllStructSetData($tData, "Version", 1) $aRet = DllCall('gdiplus.dll', 'int', 'GdiplusStartup', 'ulong_ptr*', 0, 'struct*', $tData, 'ptr', 0) If @error Or $aRet[0] Then $iError = @error + 400 ExitLoop EndIf If _WinAPI_IsAlphaBitmap($hBitmap) Then $iFormat = 0x0026200A Else $iFormat = 0x00022009 EndIf $hToken = $aRet[1] $aRet = DllCall('gdiplus.dll', 'int', 'GdipCreateBitmapFromScan0', 'int', $aSize[0], 'int', $aSize[1], 'uint', $aSize[0] * 4, 'int', $iFormat, 'struct*', $tBits, 'ptr*', 0) If @error Or $aRet[0] Then $iError = @error + 500 ExitLoop EndIf $hImage = $aRet[6] $aRet = DllCall('gdiplus.dll', 'int', 'GdipGetImageEncodersSize', 'uint*', 0, 'uint*', 0) If @error Or $aRet[0] Then $iError = @error + 600 ExitLoop EndIf $iCount = $aRet[1] $tData = DllStructCreate('byte[' & $aRet[2] & ']') If @error Then $iError = @error + 700 ExitLoop EndIf $pData = DllStructGetPtr($tData) $aRet = DllCall('gdiplus.dll', 'int', 'GdipGetImageEncoders', 'uint', $iCount, 'uint', $aRet[2], 'struct*', $tData) If @error Or $aRet[0] Then $iError = @error + 800 ExitLoop EndIf Local $tCodec, $pEncoder = 0 For $i = 1 To $iCount $tCodec = DllStructCreate($tagGDIPIMAGECODECINFO, $pData) If Not StringInStr(_WinAPI_WideCharToMultiByte(DllStructGetData($tCodec, 'MimeType')), $sMime) Then $pData += DllStructGetSize($tagGDIPIMAGECODECINFO) Else $pEncoder = $pData $iError = 0 ExitLoop EndIf Next If Not $pEncoder Then $iError = 15 ExitLoop EndIf Switch $iCompression Case 0 Case 1 Local Const $tagENCODERPARAMETER = 'byte[16] GUID;ulong NumberOfValues;dword Type;ptr pValue' $tParam = DllStructCreate('dword Count;' & $tagENCODERPARAMETER & ';ulong Quality') DllStructSetData($tParam, 'Count', 1) DllStructSetData($tParam, 'NumberOfValues', 1) DllStructSetData($tParam, 'Type', 4) DllStructSetData($tParam, 'pValue', DllStructGetPtr($tParam, 'Quality')) DllStructSetData($tParam, 'Quality', $iQuality) $aRet = DllCall('ole32.dll', 'long', 'CLSIDFromString', 'wstr', '{1D5BE4B5-FA4A-452D-9CDD-5DB35105E7EB}', 'ptr', DllStructGetPtr($tParam, 2)) If @error Or $aRet[0] Then $tParam = 0 EndIf EndSwitch $pStream = _WinAPI_CreateStreamOnHGlobal() $aRet = DllCall('gdiplus.dll', 'int', 'GdipSaveImageToStream', 'handle', $hImage, 'ptr', $pStream, 'ptr', $pEncoder, 'struct*', $tParam) If @error Or $aRet[0] Then $iError = @error + 900 ExitLoop EndIf $hMem = _WinAPI_GetHGlobalFromStream($pStream) $aRet = DllCall('kernel32.dll', 'ulong_ptr', 'GlobalSize', 'handle', $hMem) If @error Or Not $aRet[0] Then $iError = @error + 1000 ExitLoop EndIf $iLength = $aRet[0] $aRet = DllCall('kernel32.dll', 'ptr', 'GlobalLock', 'handle', $hMem) If @error Or Not $aRet[0] Then $iError = @error + 1100 ExitLoop EndIf $pBuffer = __HeapReAlloc($pBuffer, $iLength, 1) If Not @error Then _WinAPI_MoveMemory($pBuffer, $aRet[0], $iLength) Else $iError = @error + 1300 EndIf Until 1 If $pStream Then _WinAPI_ReleaseStream($pStream) EndIf If $hImage Then DllCall('gdiplus.dll', 'int', 'GdipDisposeImage', 'handle', $hImage) EndIf If $hToken Then DllCall('gdiplus.dll', 'none', 'GdiplusShutdown', 'ulong_ptr', $hToken) EndIf If $hSource Then _WinAPI_DeleteObject($hSource) EndIf If $iError Then Return SetError($iError, 0, 0) Return $iLength EndFunc Func _WinAPI_CopyEnhMetaFile($hEmf, $sFilePath = '') Local $sTypeOfFile = 'wstr' If Not StringStripWS($sFilePath, $STR_STRIPLEADING + $STR_STRIPTRAILING) Then $sTypeOfFile = 'ptr' $sFilePath = 0 EndIf Local $aRet = DllCall('gdi32.dll', 'handle', 'CopyEnhMetaFileW', 'handle', $hEmf, $sTypeOfFile, $sFilePath) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_CopyRect($tRECT) Local $tData = DllStructCreate($tagRECT) Local $aRet = DllCall('user32.dll', 'bool', 'CopyRect', 'struct*', $tData, 'struct*', $tRECT) If @error Or Not $aRet[0] Then SetError(@error + 10, @extended, 0) Return $tData EndFunc Func _WinAPI_Create32BitHBITMAP($hIcon, $bDib = False, $bDelete = False) Local $hBitmap = 0 Local $aDIB[2] = [0, 0] Local $hTemp = _WinAPI_Create32BitHICON($hIcon) If @error Then Return SetError(@error, @extended, 0) Local $iError = 0 Do Local $tICONINFO = DllStructCreate($tagICONINFO) Local $aRet = DllCall('user32.dll', 'bool', 'GetIconInfo', 'handle', $hTemp, 'struct*', $tICONINFO) If @error Or Not $aRet[0] Then $iError = @error + 10 ExitLoop EndIf For $i = 0 To 1 $aDIB[$i] = DllStructGetData($tICONINFO, $i + 4) Next Local $tBITMAP = DllStructCreate($tagBITMAP) If Not _WinAPI_GetObject($aDIB[0], DllStructGetSize($tBITMAP), $tBITMAP) Then $iError = @error + 20 ExitLoop EndIf If $bDib Then $hBitmap = _WinAPI_CreateDIB(DllStructGetData($tBITMAP, 'bmWidth'), DllStructGetData($tBITMAP, 'bmHeight')) Local $hDC = _WinAPI_CreateCompatibleDC(0) Local $hSv = _WinAPI_SelectObject($hDC, $hBitmap) _WinAPI_DrawIconEx($hDC, 0, 0, $hTemp) _WinAPI_SelectObject($hDC, $hSv) _WinAPI_DeleteDC($hDC) Else $hBitmap = $aDIB[1] $aDIB[1] = 0 EndIf Until 1 For $i = 0 To 1 If $aDIB[$i] Then _WinAPI_DeleteObject($aDIB[$i]) EndIf Next _WinAPI_DestroyIcon($hTemp) If $iError Then Return SetError($iError, 0, 0) If Not $hBitmap Then Return SetError(12, 0, 0) If $bDelete Then _WinAPI_DestroyIcon($hIcon) EndIf Return $hBitmap EndFunc Func _WinAPI_CreateBitmapIndirect(ByRef $tBITMAP) Local $aRet = DllCall('gdi32.dll', 'handle', 'CreateBitmapIndirect', 'struct*', $tBITMAP) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_CreateBrushIndirect($iStyle, $iRGB, $iHatch = 0) Local $tLOGBRUSH = DllStructCreate($tagLOGBRUSH) DllStructSetData($tLOGBRUSH, 1, $iStyle) DllStructSetData($tLOGBRUSH, 2, __RGB($iRGB)) DllStructSetData($tLOGBRUSH, 3, $iHatch) Local $aRet = DllCall('gdi32.dll', 'handle', 'CreateBrushIndirect', 'struct*', $tLOGBRUSH) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_CreateColorAdjustment($iFlags = 0, $iIlluminant = 0, $iGammaR = 10000, $iGammaG = 10000, $iGammaB = 10000, $iBlack = 0, $iWhite = 10000, $iContrast = 0, $iBrightness = 0, $iColorfulness = 0, $iTint = 0) Local $tCA = DllStructCreate($tagCOLORADJUSTMENT) DllStructSetData($tCA, 1, DllStructGetSize($tCA)) DllStructSetData($tCA, 2, $iFlags) DllStructSetData($tCA, 3, $iIlluminant) DllStructSetData($tCA, 4, $iGammaR) DllStructSetData($tCA, 5, $iGammaG) DllStructSetData($tCA, 6, $iGammaB) DllStructSetData($tCA, 7, $iBlack) DllStructSetData($tCA, 8, $iWhite) DllStructSetData($tCA, 9, $iContrast) DllStructSetData($tCA, 10, $iBrightness) DllStructSetData($tCA, 11, $iColorfulness) DllStructSetData($tCA, 12, $iTint) Return $tCA EndFunc Func _WinAPI_CreateCompatibleBitmapEx($hDC, $iWidth, $iHeight, $iRGB) Local $hBrush = _WinAPI_CreateBrushIndirect(0, $iRGB) Local $aRet = DllCall('gdi32.dll', 'handle', 'CreateCompatibleDC', 'handle', $hDC) Local $hDestDC = $aRet[0] $aRet = DllCall('gdi32.dll', 'handle', 'CreateCompatibleBitmap', 'handle', $hDC, 'int', $iWidth, 'int', $iHeight) Local $hBmp = $aRet[0] $aRet = DllCall('gdi32.dll', 'handle', 'SelectObject', 'handle', $hDestDC, 'handle', $hBmp) Local $hDestSv = $aRet[0] Local $tRECT = _WinAPI_CreateRectEx(0, 0, $iWidth, $iHeight) Local $iError = 0 $aRet = DllCall('user32.dll', 'int', 'FillRect', 'handle', $hDestDC, 'struct*', $tRECT, 'handle', $hBrush) If @error Or Not $aRet[0] Then $iError = @error + 10 _WinAPI_DeleteObject($hBmp) EndIf _WinAPI_DeleteObject($hBrush) DllCall('gdi32.dll', 'handle', 'SelectObject', 'handle', $hDestDC, 'handle', $hDestSv) DllCall('gdi32.dll', 'bool', 'DeleteDC', 'handle', $hDestDC) If $iError Then Return SetError($iError, 0, 0) Return $hBmp EndFunc Func _WinAPI_CreateDIBitmap($hDC, ByRef $tBITMAPINFO, $iUsage, $pBits = 0) Local $iInit = 0 If $pBits Then $iInit = 0x04 EndIf Local $aRet = DllCall('gdi32.dll', 'handle', 'CreateDIBitmap', 'handle', $hDC, 'struct*', $tBITMAPINFO, 'dword', $iInit, 'struct*', $pBits, 'struct*', $tBITMAPINFO, 'uint', $iUsage) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_CreateEllipticRgn($tRECT) Local $aRet = DllCall('gdi32.dll', 'handle', 'CreateEllipticRgnIndirect', 'struct*', $tRECT) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_CreateEnhMetaFile($hDC = 0, $tRECT = 0, $bPixels = False, $sFilePath = '', $sDescription = '') Local $sTypeOfFile = 'wstr' If Not StringStripWS($sFilePath, $STR_STRIPLEADING + $STR_STRIPTRAILING) Then $sTypeOfFile = 'ptr' $sFilePath = 0 EndIf Local $tData = 0, $aData = StringSplit($sDescription, '|', $STR_NOCOUNT) If UBound($aData) < 2 Then ReDim $aData[2] $aData[1] = '' EndIf For $i = 0 To 1 $aData[$i] = StringStripWS($aData[$i], $STR_STRIPLEADING + $STR_STRIPTRAILING) Next If ($aData[0]) Or ($aData[1]) Then $tData = _WinAPI_ArrayToStruct($aData) EndIf Local $iXp, $iYp, $iXm, $iYm, $hRef = 0 If $bPixels And (IsDllStruct($tRECT)) Then If Not $hDC Then $hRef = _WinAPI_GetDC(0) EndIf $iXp = _WinAPI_GetDeviceCaps($hRef, 8) $iYp = _WinAPI_GetDeviceCaps($hRef, 10) $iXm = _WinAPI_GetDeviceCaps($hRef, 4) $iYm = _WinAPI_GetDeviceCaps($hRef, 6) If $hRef Then _WinAPI_ReleaseDC(0, $hRef) EndIf For $i = 1 To 3 Step 2 DllStructSetData($tRECT, $i, Round(DllStructGetData($tRECT, $i) * $iXm / $iXp * 100)) Next For $i = 2 To 4 Step 2 DllStructSetData($tRECT, $i, Round(DllStructGetData($tRECT, $i) * $iYm / $iYp * 100)) Next EndIf Local $aRet = DllCall('gdi32.dll', 'handle', 'CreateEnhMetaFileW', 'handle', $hDC, $sTypeOfFile, $sFilePath, 'struct*', $tRECT, 'struct*', $tData) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_CreateFontEx($iHeight, $iWidth = 0, $iEscapement = 0, $iOrientation = 0, $iWeight = 400, $bItalic = False, $bUnderline = False, $bStrikeOut = False, $iCharSet = 1, $iOutPrecision = 0, $iClipPrecision = 0, $iQuality = 0, $iPitchAndFamily = 0, $sFaceName = '', $iStyle = 0) Local $aRet = DllCall('gdi32.dll', 'handle', 'CreateFontW', 'int', $iHeight, 'int', $iWidth, 'int', $iEscapement, 'int', $iOrientation, 'int', $iWeight, 'dword', $bItalic, 'dword', $bUnderline, 'dword', $bStrikeOut, 'dword', $iCharSet, 'dword', $iOutPrecision, 'dword', $iClipPrecision, 'dword', $iQuality, 'dword', $iPitchAndFamily, 'wstr', _WinAPI_GetFontName($sFaceName, $iStyle, $iCharSet)) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_CreateNullRgn() Local $aRet = DllCall('gdi32.dll', 'handle', 'CreateRectRgn', 'int', 0, 'int', 0, 'int', 0, 'int', 0) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_CreatePen($iPenStyle, $iWidth, $iColor) Local $aResult = DllCall("gdi32.dll", "handle", "CreatePen", "int", $iPenStyle, "int", $iWidth, "INT", $iColor) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func _WinAPI_CreatePolygonRgn(Const ByRef $aPoint, $iStart = 0, $iEnd = -1, $iMode = 1) If __CheckErrorArrayBounds($aPoint, $iStart, $iEnd, 2, 2) Then Return SetError(@error + 10, @extended, 0) Local $tagStruct = '' For $i = $iStart To $iEnd $tagStruct &= 'int[2];' Next Local $tData = DllStructCreate($tagStruct) Local $iCount = 1 For $i = $iStart To $iEnd For $j = 0 To 1 DllStructSetData($tData, $iCount, $aPoint[$i][$j], $j + 1) Next $iCount += 1 Next Local $aRet = DllCall('gdi32.dll', 'handle', 'CreatePolygonRgn', 'struct*', $tData, 'int', $iCount - 1, 'int', $iMode) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_CreateRectRgnIndirect($tRECT) Local $aRet = DllCall('gdi32.dll', 'handle', 'CreateRectRgnIndirect', 'struct*', $tRECT) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_CreateSolidBitmap($hWnd, $iColor, $iWidth, $iHeight, $bRGB = 1) Local $hDC = _WinAPI_GetDC($hWnd) Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight) Local $hOld = _WinAPI_SelectObject($hDestDC, $hBitmap) Local $tRECT = DllStructCreate($tagRECT) DllStructSetData($tRECT, 1, 0) DllStructSetData($tRECT, 2, 0) DllStructSetData($tRECT, 3, $iWidth) DllStructSetData($tRECT, 4, $iHeight) If $bRGB Then $iColor = BitOR(BitAND($iColor, 0x00FF00), BitShift(BitAND($iColor, 0x0000FF), -16), BitShift(BitAND($iColor, 0xFF0000), 16)) EndIf Local $hBrush = _WinAPI_CreateSolidBrush($iColor) If Not _WinAPI_FillRect($hDestDC, $tRECT, $hBrush) Then _WinAPI_DeleteObject($hBitmap) $hBitmap = 0 EndIf _WinAPI_DeleteObject($hBrush) _WinAPI_ReleaseDC($hWnd, $hDC) _WinAPI_SelectObject($hDestDC, $hOld) _WinAPI_DeleteDC($hDestDC) If Not $hBitmap Then Return SetError(1, 0, 0) Return $hBitmap EndFunc Func _WinAPI_CreateTransform($nM11 = 1, $nM12 = 0, $nM21 = 0, $nM22 = 1, $nDX = 0, $nDY = 0) Local $tXFORM = DllStructCreate($tagXFORM) DllStructSetData($tXFORM, 1, $nM11) DllStructSetData($tXFORM, 2, $nM12) DllStructSetData($tXFORM, 3, $nM21) DllStructSetData($tXFORM, 4, $nM22) DllStructSetData($tXFORM, 5, $nDX) DllStructSetData($tXFORM, 6, $nDY) Return $tXFORM EndFunc Func _WinAPI_DeleteEnhMetaFile($hEmf) Local $aRet = DllCall('gdi32.dll', 'bool', 'DeleteEnhMetaFile', 'handle', $hEmf) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_DPtoLP($hDC, ByRef $tPOINT, $iCount = 1) Local $aRet = DllCall('gdi32.dll', 'bool', 'DPtoLP', 'handle', $hDC, 'struct*', $tPOINT, 'int', $iCount) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_DrawAnimatedRects($hWnd, $tRectFrom, $tRectTo) Local $aRet = DllCall('user32.dll', 'bool', 'DrawAnimatedRects', 'hwnd', $hWnd, 'int', 3, 'struct*', $tRectFrom, 'struct*', $tRectTo) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_DrawBitmap($hDC, $iX, $iY, $hBitmap, $iRop = 0x00CC0020) Local $tObj = DllStructCreate($tagBITMAP) Local $aRet = DllCall('gdi32.dll', 'int', 'GetObject', 'handle', $hBitmap, 'int', DllStructGetSize($tObj), 'struct*', $tObj) If @error Or Not $aRet[0] Then Return SetError(@error + 20, @extended, 0) $aRet = DllCall('user32.dll', 'handle', 'GetDC', 'hwnd', 0) Local $_hDC = $aRet[0] $aRet = DllCall('gdi32.dll', 'handle', 'CreateCompatibleDC', 'handle', $_hDC) Local $hSrcDC = $aRet[0] $aRet = DllCall('gdi32.dll', 'handle', 'SelectObject', 'handle', $hSrcDC, 'handle', $hBitmap) Local $hSrcSv = $aRet[0] Local $iError = 0 $aRet = DllCall('gdi32.dll', 'int', 'BitBlt', 'hwnd', $hDC, 'int', $iX, 'int', $iY, 'int', DllStructGetData($tObj, 'bmWidth'), 'int', DllStructGetData($tObj, 'bmHeight'), 'hwnd', $hSrcDC, 'int', 0, 'int', 0, 'int', $iRop) If @error Or Not $aRet[0] Then $iError = @error + 1 EndIf DllCall('user32.dll', 'int', 'ReleaseDC', 'hwnd', 0, 'handle', $_hDC) DllCall('gdi32.dll', 'handle', 'SelectObject', 'handle', $hSrcDC, 'handle', $hSrcSv) DllCall('gdi32.dll', 'bool', 'DeleteDC', 'handle', $hSrcDC) If $iError Then Return SetError(10, 0, 0) Return 1 EndFunc Func _WinAPI_DrawFocusRect($hDC, $tRECT) Local $aRet = DllCall('user32.dll', 'bool', 'DrawFocusRect', 'handle', $hDC, 'struct*', $tRECT) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_DrawLine($hDC, $iX1, $iY1, $iX2, $iY2) _WinAPI_MoveTo($hDC, $iX1, $iY1) If @error Then Return SetError(@error, @extended, False) _WinAPI_LineTo($hDC, $iX2, $iY2) If @error Then Return SetError(@error + 10, @extended, False) Return True EndFunc Func _WinAPI_DrawShadowText($hDC, $sText, $iRGBText, $iRGBShadow, $iXOffset = 0, $iYOffset = 0, $tRECT = 0, $iFlags = 0) Local $aRet If Not IsDllStruct($tRECT) Then $tRECT = DllStructCreate($tagRECT) $aRet = DllCall('user32.dll', 'bool', 'GetClientRect', 'hwnd', _WinAPI_WindowFromDC($hDC), 'struct*', $tRECT) If @error Then Return SetError(@error + 10, @extended, 0) If Not $aRet[0] Then Return SetError(10, 0, 0) EndIf $aRet = DllCall('comctl32.dll', 'int', 'DrawShadowText', 'handle', $hDC, 'wstr', $sText, 'uint', -1, 'struct*', $tRECT, 'dword', $iFlags, 'int', __RGB($iRGBText), 'int', __RGB($iRGBShadow), 'int', $iXOffset, 'int', $iYOffset) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_DwmDefWindowProc($hWnd, $iMsg, $wParam, $lParam) Local $aRet = DllCall('dwmapi.dll', 'bool', 'DwmDefWindowProc', 'hwnd', $hWnd, 'uint', $iMsg, 'wparam', $wParam, 'lparam', $lParam, 'lresult*', 0) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return $aRet[5] EndFunc Func _WinAPI_DwmEnableBlurBehindWindow($hWnd, $bEnable = True, $bTransition = False, $hRgn = 0) Local $tBLURBEHIND = DllStructCreate('dword;bool;handle;bool') Local $iFlags = 0 If $hRgn Then $iFlags += 2 DllStructSetData($tBLURBEHIND, 3, $hRgn) EndIf DllStructSetData($tBLURBEHIND, 1, BitOR($iFlags, 0x05)) DllStructSetData($tBLURBEHIND, 2, $bEnable) DllStructSetData($tBLURBEHIND, 4, $bTransition) Local $aRet = DllCall('dwmapi.dll', 'long', 'DwmEnableBlurBehindWindow', 'hwnd', $hWnd, 'struct*', $tBLURBEHIND) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return 1 EndFunc Func _WinAPI_DwmEnableComposition($bEnable) If $bEnable Then $bEnable = 1 Local $aRet = DllCall('dwmapi.dll', 'long', 'DwmEnableComposition', 'uint', $bEnable) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return 1 EndFunc Func _WinAPI_DwmExtendFrameIntoClientArea($hWnd, $tMARGINS = 0) If Not IsDllStruct($tMARGINS) Then $tMARGINS = _WinAPI_CreateMargins(-1, -1, -1, -1) EndIf Local $aRet = DllCall('dwmapi.dll', 'long', 'DwmExtendFrameIntoClientArea', 'hwnd', $hWnd, 'struct*', $tMARGINS) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return 1 EndFunc Func _WinAPI_DwmGetColorizationColor() Local $aRet = DllCall('dwmapi.dll', 'long', 'DwmGetColorizationColor', 'dword*', 0, 'bool*', 0) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return SetExtended($aRet[2], $aRet[1]) EndFunc Func _WinAPI_DwmGetColorizationParameters() Local $tDWMCP = DllStructCreate($tagDWM_COLORIZATION_PARAMETERS) Local $aRet = DllCall('dwmapi.dll', 'uint', 127, 'struct*', $tDWMCP) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return $tDWMCP EndFunc Func _WinAPI_DwmGetWindowAttribute($hWnd, $iAttribute) Local $tagStruct Switch $iAttribute Case 5, 9 $tagStruct = $tagRECT Case 1 $tagStruct = 'uint' Case Else Return SetError(11, 0, 0) EndSwitch Local $tData = DllStructCreate($tagStruct) Local $aRet = DllCall('dwmapi.dll', 'long', 'DwmGetWindowAttribute', 'hwnd', $hWnd, 'dword', $iAttribute, 'struct*', $tData, 'dword', DllStructGetSize($tData)) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Switch $iAttribute Case 1 Return DllStructGetData($tData, 1) Case Else Return $tData EndSwitch EndFunc Func _WinAPI_DwmInvalidateIconicBitmaps($hWnd) Local $aRet = DllCall('dwmapi.dll', 'long', 'DwmInvalidateIconicBitmaps', 'hwnd', $hWnd) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return 1 EndFunc Func _WinAPI_DwmIsCompositionEnabled() Local $aRet = DllCall('dwmapi.dll', 'long', 'DwmIsCompositionEnabled', 'bool*', 0) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return $aRet[1] EndFunc Func _WinAPI_DwmQueryThumbnailSourceSize($hThumbnail) Local $tSIZE = DllStructCreate($tagSIZE) Local $aRet = DllCall('dwmapi.dll', 'long', 'DwmQueryThumbnailSourceSize', 'handle', $hThumbnail, 'struct*', $tSIZE) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return $tSIZE EndFunc Func _WinAPI_DwmRegisterThumbnail($hDestination, $hSource) Local $aRet = DllCall('dwmapi.dll', 'long', 'DwmRegisterThumbnail', 'hwnd', $hDestination, 'hwnd', $hSource, 'handle*', 0) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return $aRet[3] EndFunc Func _WinAPI_DwmSetColorizationParameters($tDWMCP) Local $aRet = DllCall('dwmapi.dll', 'uint', 131, 'struct*', $tDWMCP, 'uint', 0) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return 1 EndFunc Func _WinAPI_DwmSetIconicLivePreviewBitmap($hWnd, $hBitmap, $bFrame = False, $tClient = 0) Local $iFlags If $bFrame Then $iFlags = 0x00000001 Else $iFlags = 0 EndIf Local $aRet = DllCall('dwmapi.dll', 'uint', 'DwmSetIconicLivePreviewBitmap', 'hwnd', $hWnd, 'handle', $hBitmap, 'struct*', $tClient, 'dword', $iFlags) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return 1 EndFunc Func _WinAPI_DwmSetIconicThumbnail($hWnd, $hBitmap, $bFrame = False) Local $iFlags If $bFrame Then $iFlags = 0x00000001 Else $iFlags = 0 EndIf Local $aRet = DllCall('dwmapi.dll', 'long', 'DwmSetIconicThumbnail', 'hwnd', $hWnd, 'handle', $hBitmap, 'dword', $iFlags) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return 1 EndFunc Func _WinAPI_DwmSetWindowAttribute($hWnd, $iAttribute, $iData) Switch $iAttribute Case 2, 3, 4, 6, 7, 8, 10, 11, 12 Case Else Return SetError(1, 0, 0) EndSwitch Local $aRet = DllCall('dwmapi.dll', 'long', 'DwmSetWindowAttribute', 'hwnd', $hWnd, 'dword', $iAttribute, 'dword*', $iData, 'dword', 4) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return 1 EndFunc Func _WinAPI_DwmUnregisterThumbnail($hThumbnail) Local $aRet = DllCall('dwmapi.dll', 'long', 'DwmUnregisterThumbnail', 'handle', $hThumbnail) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return 1 EndFunc Func _WinAPI_DwmUpdateThumbnailProperties($hThumbnail, $bVisible = True, $bClientAreaOnly = False, $iOpacity = 255, $tRectDest = 0, $tRectSrc = 0) Local Const $tagDWM_THUMBNAIL_PROPERTIES = 'struct;dword dwFlags;int rcDestination[4];int rcSource[4];byte opacity;bool opacity;bool fSourceClientAreaOnly;endstruct' Local $tTHUMBNAILPROPERTIES = DllStructCreate($tagDWM_THUMBNAIL_PROPERTIES) Local $tSIZE, $iFlags = 0 If Not IsDllStruct($tRectDest) Then $tSIZE = _WinAPI_DwmQueryThumbnailSourceSize($hThumbnail) If @error Then Return SetError(@error + 10, @extended, 0) EndIf $tRectDest = _WinAPI_CreateRectEx(0, 0, DllStructGetData($tSIZE, 1), DllStructGetData($tSIZE, 2)) EndIf For $i = 1 To 4 DllStructSetData($tTHUMBNAILPROPERTIES, 2, DllStructGetData($tRectDest, $i), $i) Next If IsDllStruct($tRectSrc) Then $iFlags += 2 For $i = 1 To 4 DllStructSetData($tTHUMBNAILPROPERTIES, 3, DllStructGetData($tRectSrc, $i), $i) Next EndIf DllStructSetData($tTHUMBNAILPROPERTIES, 1, BitOR($iFlags, 0x1D)) DllStructSetData($tTHUMBNAILPROPERTIES, 4, $iOpacity) DllStructSetData($tTHUMBNAILPROPERTIES, 5, $bVisible) DllStructSetData($tTHUMBNAILPROPERTIES, 6, $bClientAreaOnly) Local $aRet = DllCall('dwmapi.dll', 'long', 'DwmUpdateThumbnailProperties', 'handle', $hThumbnail, 'struct*', $tTHUMBNAILPROPERTIES) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] Then Return SetError(10, $aRet[0], 0) Return 1 EndFunc Func _WinAPI_Ellipse($hDC, $tRECT) Local $aRet = DllCall('gdi32.dll', 'bool', 'Ellipse', 'handle', $hDC, 'int', DllStructGetData($tRECT, 1), 'int', DllStructGetData($tRECT, 2), 'int', DllStructGetData($tRECT, 3), 'int', DllStructGetData($tRECT, 4)) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_EndPaint($hWnd, ByRef $tPAINTSTRUCT) Local $aRet = DllCall('user32.dll', 'bool', 'EndPaint', 'hwnd', $hWnd, 'struct*', $tPAINTSTRUCT) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_EndPath($hDC) Local $aRet = DllCall('gdi32.dll', 'bool', 'EndPath', 'handle', $hDC) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_EnumDisplayMonitors($hDC = 0, $tRECT = 0) Local $hEnumProc = DllCallbackRegister('__EnumDisplayMonitorsProc', 'bool', 'handle;handle;ptr;lparam') Dim $__g_vEnum[101][2] = [[0]] Local $aRet = DllCall('user32.dll', 'bool', 'EnumDisplayMonitors', 'handle', $hDC, 'struct*', $tRECT, 'ptr', DllCallbackGetPtr($hEnumProc), 'lparam', 0) If @error Or Not $aRet[0] Or Not $__g_vEnum[0][0] Then $__g_vEnum = @error + 10 EndIf DllCallbackFree($hEnumProc) If $__g_vEnum Then Return SetError($__g_vEnum, 0, 0) __Inc($__g_vEnum, -1) Return $__g_vEnum EndFunc Func _WinAPI_EnumDisplaySettings($sDevice, $iMode) Local $sTypeOfDevice = 'wstr' If Not StringStripWS($sDevice, $STR_STRIPLEADING + $STR_STRIPTRAILING) Then $sTypeOfDevice = 'ptr' $sDevice = 0 EndIf Local $tDEVMODE = DllStructCreate($tagDEVMODE_DISPLAY) DllStructSetData($tDEVMODE, 'Size', DllStructGetSize($tDEVMODE)) DllStructSetData($tDEVMODE, 'DriverExtra', 0) Local $aRet = DllCall('user32.dll', 'bool', 'EnumDisplaySettingsW', $sTypeOfDevice, $sDevice, 'dword', $iMode, 'struct*', $tDEVMODE) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Local $aResult[5] $aResult[0] = DllStructGetData($tDEVMODE, 'PelsWidth') $aResult[1] = DllStructGetData($tDEVMODE, 'PelsHeight') $aResult[2] = DllStructGetData($tDEVMODE, 'BitsPerPel') $aResult[3] = DllStructGetData($tDEVMODE, 'DisplayFrequency') $aResult[4] = DllStructGetData($tDEVMODE, 'DisplayFlags') Return $aResult EndFunc Func _WinAPI_EnumFontFamilies($hDC = 0, $sFaceName = '', $iCharSet = 1, $iFontType = 0x07, $sPattern = '', $bExclude = False) Local $tLOGFONT = DllStructCreate($tagLOGFONT) Local $tPattern = DllStructCreate('uint;uint;ptr;wchar[' & (StringLen($sPattern) + 1) & ']') DllStructSetData($tPattern, 1, $iFontType) If Not $sPattern Then DllStructSetData($tPattern, 2, 0) DllStructSetData($tPattern, 3, 0) Else DllStructSetData($tPattern, 2, $bExclude) DllStructSetData($tPattern, 3, DllStructGetPtr($tPattern, 4)) DllStructSetData($tPattern, 4, $sPattern) EndIf DllStructSetData($tLOGFONT, 9, $iCharSet) DllStructSetData($tLOGFONT, 13, 0) DllStructSetData($tLOGFONT, 14, StringLeft($sFaceName, 31)) Local $hCDC If Not $hDC Then $hCDC = _WinAPI_CreateCompatibleDC(0) Else $hCDC = $hDC EndIf Dim $__g_vEnum[101][8] = [[0]] Local $hEnumProc = DllCallbackRegister('__EnumFontFamiliesProc', 'int', 'ptr;ptr;dword;PTR') Local $aRet = DllCall('gdi32.dll', 'int', 'EnumFontFamiliesExW', 'handle', $hCDC, 'struct*', $tLOGFONT, 'ptr', DllCallbackGetPtr($hEnumProc), 'struct*', $tPattern, 'dword', 0) If @error Or Not $aRet[0] Or Not $__g_vEnum[0][0] Then $__g_vEnum = @error + 10 EndIf DllCallbackFree($hEnumProc) If Not $hDC Then _WinAPI_DeleteDC($hCDC) EndIf If $__g_vEnum Then Return SetError($__g_vEnum, 0, 0) __Inc($__g_vEnum, -1) Return $__g_vEnum EndFunc Func _WinAPI_EqualRect($tRECT1, $tRECT2) Local $aRet = DllCall('user32.dll', 'bool', 'EqualRect', 'struct*', $tRECT1, 'struct*', $tRECT2) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_EqualRgn($hRgn1, $hRgn2) Local $aRet = DllCall('gdi32.dll', 'bool', 'EqualRgn', 'handle', $hRgn1, 'handle', $hRgn2) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_ExcludeClipRect($hDC, $tRECT) Local $aRet = DllCall('gdi32.dll', 'int', 'ExcludeClipRect', 'handle', $hDC, 'int', DllStructGetData($tRECT, 1), 'int', DllStructGetData($tRECT, 2), 'int', DllStructGetData($tRECT, 3), 'int', DllStructGetData($tRECT, 4)) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_ExtCreatePen($iPenStyle, $iWidth, $iBrushStyle, $iRGB, $iHatch = 0, $aUserStyle = 0, $iStart = 0, $iEnd = -1) Local $iCount = 0, $tStyle = 0 If BitAND($iPenStyle, 0xFF) = 7 Then If __CheckErrorArrayBounds($aUserStyle, $iStart, $iEnd) Then Return SetError(@error + 10, @extended, 0) $tStyle = DllStructCreate('dword[' & ($iEnd - $iStart + 1) & ']') For $i = $iStart To $iEnd DllStructSetData($tStyle, 1, $aUserStyle[$i], $iCount + 1) $iCount += 1 Next EndIf Local $tLOGBRUSH = DllStructCreate($tagLOGBRUSH) DllStructSetData($tLOGBRUSH, 1, $iBrushStyle) DllStructSetData($tLOGBRUSH, 2, __RGB($iRGB)) DllStructSetData($tLOGBRUSH, 3, $iHatch) Local $aRet = DllCall('gdi32.dll', 'handle', 'ExtCreatePen', 'dword', $iPenStyle, 'dword', $iWidth, 'struct*', $tLOGBRUSH, 'dword', $iCount, 'struct*', $tStyle) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_ExtCreateRegion($tRGNDATA, $tXFORM = 0) Local $aRet = DllCall('gdi32.dll', 'handle', 'ExtCreateRegion', 'struct*', $tXFORM, 'dword', DllStructGetSize($tRGNDATA), 'struct*', $tRGNDATA) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_ExtFloodFill($hDC, $iX, $iY, $iRGB, $iType = 0) Local $aRet = DllCall('gdi32.dll', 'bool', 'ExtFloodFill', 'handle', $hDC, 'int', $iX, 'int', $iY, 'dword', __RGB($iRGB), 'uint', $iType) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_ExtSelectClipRgn($hDC, $hRgn, $iMode = 5) Local $aRet = DllCall('gdi32.dll', 'int', 'ExtSelectClipRgn', 'handle', $hDC, 'handle', $hRgn, 'int', $iMode) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_FillPath($hDC) Local $aRet = DllCall('gdi32.dll', 'bool', 'FillPath', 'handle', $hDC) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_FillRgn($hDC, $hRgn, $hBrush) Local $aRet = DllCall('gdi32.dll', 'bool', 'FillRgn', 'handle', $hDC, 'handle', $hRgn, 'handle', $hBrush) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_FlattenPath($hDC) Local $aRet = DllCall('gdi32.dll', 'bool', 'FlattenPath', 'handle', $hDC) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_FrameRgn($hDC, $hRgn, $hBrush, $iWidth, $iHeight) Local $aRet = DllCall('gdi32.dll', 'bool', 'FrameRgn', 'handle', $hDC, 'handle', $hRgn, 'handle', $hBrush, 'int', $iWidth, 'int', $iHeight) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_GdiComment($hDC, $pBuffer, $iSize) Local $aRet = DllCall('gdi32.dll', 'bool', 'GdiComment', 'handle', $hDC, 'uint', $iSize, 'struct*', $pBuffer) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_GetArcDirection($hDC) Local $aRet = DllCall('gdi32.dll', 'int', 'GetArcDirection', 'handle', $hDC) If @error Then Return SetError(@error, @extended, 0) If ($aRet[0] < 1) Or ($aRet[0] > 2) Then Return SetError(10, $aRet[0], 0) Return $aRet[0] EndFunc Func _WinAPI_GetBitmapBits($hBitmap, $iSize, $pBits) Local $aRet = DllCall('gdi32.dll', 'long', 'GetBitmapBits', 'handle', $hBitmap, 'long', $iSize, 'struct*', $pBits) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetBitmapDimensionEx($hBitmap) Local $tSIZE = DllStructCreate($tagSIZE) Local $aRet = DllCall('gdi32.dll', 'bool', 'GetBitmapDimensionEx', 'handle', $hBitmap, 'struct*', $tSIZE) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return $tSIZE EndFunc Func _WinAPI_GetBkColor($hDC) Local $aRet = DllCall('gdi32.dll', 'dword', 'GetBkColor', 'handle', $hDC) If @error Or ($aRet[0] = -1) Then Return SetError(@error, @extended, -1) Return __RGB($aRet[0]) EndFunc Func _WinAPI_GetBoundsRect($hDC, $iFlags = 0) Local $tRECT = DllStructCreate($tagRECT) Local $aRet = DllCall('gdi32.dll', 'uint', 'GetBoundsRect', 'handle', $hDC, 'struct*', $tRECT, 'uint', $iFlags) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return SetExtended($aRet[0], $tRECT) EndFunc Func _WinAPI_GetBrushOrg($hDC) Local $tPOINT = DllStructCreate($tagPOINT) Local $aRet = DllCall('gdi32.dll', 'bool', 'GetBrushOrgEx', 'handle', $hDC, 'struct*', $tPOINT) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return $tPOINT EndFunc Func _WinAPI_GetBValue($iRGB) Return BitShift(BitAND(__RGB($iRGB), 0xFF0000), 16) EndFunc Func _WinAPI_GetClipBox($hDC, ByRef $tRECT) $tRECT = DllStructCreate($tagRECT) Local $aRet = DllCall('gdi32.dll', 'int', 'GetClipBox', 'handle', $hDC, 'struct*', $tRECT) If @error Or Not $aRet[0] Then $tRECT = 0 Return SetError(@error, @extended, 0) EndIf Return $aRet[0] EndFunc Func _WinAPI_GetClipRgn($hDC) Local $hRgn = _WinAPI_CreateRectRgn(0, 0, 0, 0) Local $iError = 0 Local $aRet = DllCall('gdi32.dll', 'int', 'GetClipRgn', 'handle', $hDC, 'handle', $hRgn) If @error Or ($aRet[0] = -1) Then $iError = @error + 10 If $iError Or Not $aRet[0] Then _WinAPI_DeleteObject($hRgn) $hRgn = 0 EndIf Return SetError($iError, 0, $hRgn) EndFunc Func _WinAPI_GetColorAdjustment($hDC) Local $tAdjustment = DllStructCreate($tagCOLORADJUSTMENT) Local $aRet = DllCall('gdi32.dll', 'bool', 'GetColorAdjustment', 'handle', $hDC, 'struct*', $tAdjustment) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return $tAdjustment EndFunc Func _WinAPI_GetCurrentPosition($hDC) Local $tPOINT = DllStructCreate($tagPOINT) Local $aRet = DllCall('gdi32.dll', 'int', 'GetCurrentPositionEx', 'handle', $hDC, 'struct*', $tPOINT) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return $tPOINT EndFunc Func _WinAPI_GetDeviceGammaRamp($hDC, ByRef $aRamp) $aRamp = 0 Local $tData = DllStructCreate('word[256];word[256];word[256]') Local $aRet = DllCall('gdi32.dll', 'bool', 'GetDeviceGammaRamp', 'handle', $hDC, 'struct*', $tData) If @error Or Not $aRet[0] Then Return SetError(@error, @extended, 0) Dim $aRamp[256][3] For $i = 0 To 2 For $j = 0 To 255 $aRamp[$j][$i] = DllStructGetData($tData, $i + 1, $j + 1) Next Next Return 1 EndFunc Func _WinAPI_GetDIBColorTable($hBitmap) Local $hDC = _WinAPI_CreateCompatibleDC(0) Local $hSv = _WinAPI_SelectObject($hDC, $hBitmap) Local $tPeak = DllStructCreate('dword[256]') Local $iError = 0 Local $aRet = DllCall('gdi32.dll', 'uint', 'GetDIBColorTable', 'handle', $hDC, 'uint', 0, 'uint', 256, 'struct*', $tPeak) If @error Or Not $aRet[0] Then $iError = @error + 10 _WinAPI_SelectObject($hDC, $hSv) _WinAPI_DeleteDC($hDC) If $iError Then Return SetError($iError, 0, 0) Local $tData = DllStructCreate('dword[' & $aRet[0] & ']') If @error Then Return SetError(@error + 20, @extended, 0) _WinAPI_MoveMemory($tData, $aRet[4], 4 * $aRet[0]) Return SetExtended($aRet[0], $tData) EndFunc Func _WinAPI_GetDIBits($hDC, $hBitmap, $iStartScan, $iScanLines, $pBits, $tBI, $iUsage) Local $aResult = DllCall("gdi32.dll", "int", "GetDIBits", "handle", $hDC, "handle", $hBitmap, "uint", $iStartScan, "uint", $iScanLines, "struct*", $pBits, "struct*", $tBI, "uint", $iUsage) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_GetEnhMetaFile($sFilePath) Local $aRet = DllCall('gdi32.dll', 'handle', 'GetEnhMetaFileW', 'wstr', $sFilePath) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetEnhMetaFileBits($hEmf, ByRef $pBuffer) Local $aRet = DllCall('gdi32.dll', 'uint', 'GetEnhMetaFileBits', 'handle', $hEmf, 'uint', 0, 'ptr', 0) If @error Or Not $aRet[0] Then Return SetError(@error + 50, @extended, 0) $pBuffer = __HeapReAlloc($pBuffer, $aRet[0], 1) If @error Then Return SetError(@error, @extended, 0) $aRet = DllCall('gdi32.dll', 'uint', 'GetEnhMetaFileBits', 'handle', $hEmf, 'uint', $aRet[0], 'ptr', $pBuffer) If Not $aRet[0] Then Return SetError(60, 0, 0) Return $aRet[2] EndFunc Func _WinAPI_GetEnhMetaFileDescription($hEmf) Local $tData = DllStructCreate('wchar[4096]') Local $aRet = DllCall('gdi32.dll', 'uint', 'GetEnhMetaFileDescriptionW', 'handle', $hEmf, 'uint', 4096, 'struct*', $tData) If @error Or ($aRet[0] = 4294967295) Then Return SetError(@error + 20, $aRet[0], 0) If Not $aRet[0] Then Return 0 Local $aData = _WinAPI_StructToArray($tData) If @error Then Return SetError(@error, @extended, 0) Local $aResult[2] For $i = 0 To 1 If $aData[0] > $i Then $aResult[$i] = $aData[$i + 1] Else $aResult[$i] = '' EndIf Next Return $aResult EndFunc Func _WinAPI_GetEnhMetaFileDimension($hEmf) Local $tENHMETAHEADER = _WinAPI_GetEnhMetaFileHeader($hEmf) If @error Then Return SetError(@error, @extended, 0) Local $tSIZE = DllStructCreate($tagSIZE) DllStructSetData($tSIZE, 1, Round((DllStructGetData($tENHMETAHEADER, 'rcFrame', 3) - DllStructGetData($tENHMETAHEADER, 'rcFrame', 1)) * DllStructGetData($tENHMETAHEADER, 'Device', 1) / DllStructGetData($tENHMETAHEADER, 'Millimeters', 1) / 100)) DllStructSetData($tSIZE, 2, Round((DllStructGetData($tENHMETAHEADER, 'rcFrame', 4) - DllStructGetData($tENHMETAHEADER, 'rcFrame', 2)) * DllStructGetData($tENHMETAHEADER, 'Device', 2) / DllStructGetData($tENHMETAHEADER, 'Millimeters', 2) / 100)) Return $tSIZE EndFunc Func _WinAPI_GetEnhMetaFileHeader($hEmf) Local $tENHMETAHEADER = DllStructCreate($tagENHMETAHEADER) Local $aRet = DllCall('gdi32.dll', 'uint', 'GetEnhMetaFileHeader', 'handle', $hEmf, 'uint', DllStructGetSize($tENHMETAHEADER), 'struct*', $tENHMETAHEADER) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return SetExtended($aRet[0], $tENHMETAHEADER) EndFunc Func _WinAPI_GetFontName($sFaceName, $iStyle = 0, $iCharSet = 1) If Not $sFaceName Then Return SetError(1, 0, '') Local $iFlags = 0 If BitAND($iStyle, 0x01) Then $iFlags += 0x00000020 EndIf If BitAND($iStyle, 0x02) Then $iFlags += 0x00000001 EndIf If Not $iFlags Then $iFlags = 0x00000040 EndIf Local $tLOGFONT = DllStructCreate($tagLOGFONT) DllStructSetData($tLOGFONT, 9, $iCharSet) DllStructSetData($tLOGFONT, 13, 0) DllStructSetData($tLOGFONT, 14, StringLeft($sFaceName, 31)) Local $tFN = DllStructCreate('dword;wchar[64]') DllStructSetData($tFN, 1, $iFlags) DllStructSetData($tFN, 2, '') Local $hDC = _WinAPI_CreateCompatibleDC(0) Local $hEnumProc = DllCallbackRegister('__EnumFontStylesProc', 'int', 'ptr;ptr;dword;lparam') Local $sRet = '' Local $aRet = DllCall('gdi32.dll', 'int', 'EnumFontFamiliesExW', 'handle', $hDC, 'struct*', $tLOGFONT, 'ptr', DllCallbackGetPtr($hEnumProc), 'struct*', $tFN, 'dword', 0) If Not @error And Not $aRet[0] Then $sRet = DllStructGetData($tFN, 2) DllCallbackFree($hEnumProc) _WinAPI_DeleteDC($hDC) If Not $sRet Then Return SetError(2, 0, '') Return $sRet EndFunc Func _WinAPI_GetFontResourceInfo($sFont, $bForce = False, $iFlag = Default) If $iFlag = Default Then If $bForce Then If Not _WinAPI_AddFontResourceEx($sFont, $FR_NOT_ENUM) Then Return SetError(@error + 20, @extended, '') EndIf Local $iError = 0 Local $aRet = DllCall('gdi32.dll', 'bool', 'GetFontResourceInfoW', 'wstr', $sFont, 'dword*', 4096, 'wstr', '', 'dword', 0x01) If @error Or Not $aRet[0] Then $iError = @error + 10 If $bForce Then _WinAPI_RemoveFontResourceEx($sFont, $FR_NOT_ENUM) EndIf If $iError Then Return SetError($iError, 0, '') Return $aRet[3] Else If Not FileExists($sFont) Then $sFont = RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "Fonts") & "\" & $sFont If Not FileExists($sFont) Then Return SetError(31, 0, "") EndIf Local Const $hFile = _WinAPI_CreateFile($sFont, 2, 2, 2) If Not $hFile Then Return SetError(32, _WinAPI_GetLastError(), "") Local Const $iFile = FileGetSize($sFont) Local Const $tBuffer = DllStructCreate("byte[" & $iFile + 1 & "]") Local Const $pFile = DllStructGetPtr($tBuffer) Local $iRead _WinAPI_ReadFile($hFile, $pFile, $iFile, $iRead) _WinAPI_CloseHandle($hFile) Local $sTTFName = _WinAPI_GetFontMemoryResourceInfo($pFile, $iFlag) If @error Then If @error = 1 And $iFlag = 4 Then $sTTFName = _WinAPI_GetFontResourceInfo($sFont, True) Return SetError(@error, @extended, $sTTFName) EndIf Return SetError(33, @error, "") EndIf Return $sTTFName EndIf EndFunc Func _WinAPI_GetFontMemoryResourceInfo($pMemory, $iFlag = 1) Local Const $tagTT_OFFSET_TABLE = "USHORT uMajorVersion;USHORT uMinorVersion;USHORT uNumOfTables;USHORT uSearchRange;USHORT uEntrySelector;USHORT uRangeShift" Local Const $tagTT_TABLE_DIRECTORY = "char szTag[4];ULONG uCheckSum;ULONG uOffset;ULONG uLength" Local Const $tagTT_NAME_TABLE_HEADER = "USHORT uFSelector;USHORT uNRCount;USHORT uStorageOffset" Local Const $tagTT_NAME_RECORD = "USHORT uPlatformID;USHORT uEncodingID;USHORT uLanguageID;USHORT uNameID;USHORT uStringLength;USHORT uStringOffset" Local $tTTOffsetTable = DllStructCreate($tagTT_OFFSET_TABLE, $pMemory) Local $iNumOfTables = _WinAPI_SwapWord(DllStructGetData($tTTOffsetTable, "uNumOfTables")) If Not (_WinAPI_SwapWord(DllStructGetData($tTTOffsetTable, "uMajorVersion")) = 1 And _WinAPI_SwapWord(DllStructGetData($tTTOffsetTable, "uMinorVersion")) = 0) Then Return SetError(1, 0, "") Local $iTblDirSize = DllStructGetSize(DllStructCreate($tagTT_TABLE_DIRECTORY)) Local $bFound = False, $iOffset, $tTblDir For $i = 0 To $iNumOfTables - 1 $tTblDir = DllStructCreate($tagTT_TABLE_DIRECTORY, $pMemory + DllStructGetSize($tTTOffsetTable) + $i * $iTblDirSize) If StringLeft(DllStructGetData($tTblDir, "szTag"), 4) = "name" Then $bFound = True $iOffset = _WinAPI_SwapDWord(DllStructGetData($tTblDir, "uOffset")) ExitLoop EndIf Next If Not $bFound Then Return SetError(2, 0, "") Local $tNTHeader = DllStructCreate($tagTT_NAME_TABLE_HEADER, $pMemory + $iOffset) Local $iNTHeaderSize = DllStructGetSize($tNTHeader) Local $iNRCount = _WinAPI_SwapWord(DllStructGetData($tNTHeader, "uNRCount")) Local $iStorageOffset = _WinAPI_SwapWord(DllStructGetData($tNTHeader, "uStorageOffset")) Local $iTTRecordSize = DllStructGetSize(DllStructCreate($tagTT_NAME_RECORD)) Local $tResult, $sResult, $iStringLength, $iStringOffset, $iEncodingID, $tTTRecord For $i = 0 To $iNRCount - 1 $tTTRecord = DllStructCreate($tagTT_NAME_RECORD, $pMemory + $iOffset + $iNTHeaderSize + $i * $iTTRecordSize) If _WinAPI_SwapWord($tTTRecord.uNameID) = $iFlag Then $iStringLength = _WinAPI_SwapWord(DllStructGetData($tTTRecord, "uStringLength")) $iStringOffset = _WinAPI_SwapWord(DllStructGetData($tTTRecord, "uStringOffset")) $iEncodingID = _WinAPI_SwapWord(DllStructGetData($tTTRecord, "uEncodingID")) Local $sWchar = "char" If $iEncodingID = 1 Then $sWchar = "word" $iStringLength = $iStringLength / 2 EndIf $tResult = DllStructCreate($sWchar & " szTTFName[" & $iStringLength & "]", $pMemory + $iOffset + $iStringOffset + $iStorageOffset) If $iEncodingID = 1 Then $sResult = "" For $j = 1 To $iStringLength $sResult &= ChrW(_WinAPI_SwapWord(DllStructGetData($tResult, 1, $j))) Next Else $sResult = $tResult.szTTFName EndIf If StringLen($sResult) > 0 Then ExitLoop EndIf Next Return $sResult EndFunc Func _WinAPI_GetGlyphOutline($hDC, $sChar, $iFormat, ByRef $pBuffer, $tMAT2 = 0) Local $tGM = DllStructCreate($tagGLYPHMETRICS) Local $aRet, $iLength = 0 If Not IsDllStruct($tMAT2) Then $tMAT2 = DllStructCreate('short[8]') DllStructSetData($tMAT2, 1, 1, 2) DllStructSetData($tMAT2, 1, 1, 8) EndIf If $iFormat Then $aRet = DllCall('gdi32.dll', 'dword', 'GetGlyphOutlineW', 'handle', $hDC, 'uint', AscW($sChar), 'uint', $iFormat, 'struct*', $tGM, 'dword', 0, 'ptr', 0, 'struct*', $tMAT2) If @error Or ($aRet[0] = 4294967295) Then Return SetError(@error + 10, @extended, 0) $iLength = $aRet[0] $pBuffer = __HeapReAlloc($pBuffer, $iLength, 1) If @error Then Return SetError(@error + 20, @extended, 0) EndIf $aRet = DllCall('gdi32.dll', 'dword', 'GetGlyphOutlineW', 'handle', $hDC, 'uint', AscW($sChar), 'uint', $iFormat, 'struct*', $tGM, 'dword', $iLength, 'ptr', $pBuffer, 'struct*', $tMAT2) If @error Then Return SetError(@error, @extended, 0) If $aRet[0] = 4294967295 Then Return SetError(10, -1, 0) Return SetExtended($iLength, $tGM) EndFunc Func _WinAPI_GetGraphicsMode($hDC) Local $aRet = DllCall('gdi32.dll', 'int', 'GetGraphicsMode', 'handle', $hDC) If @error Or Not $aRet[0] Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetGValue($iRGB) Return BitShift(BitAND(__RGB($iRGB), 0x00FF00), 8) EndFunc Func _WinAPI_GetMapMode($hDC) Local $aRet = DllCall('gdi32.dll', 'int', 'GetMapMode', 'handle', $hDC) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetMonitorInfo($hMonitor) Local $tMIEX = DllStructCreate('dword;long[4];long[4];dword;wchar[32]') DllStructSetData($tMIEX, 1, DllStructGetSize($tMIEX)) Local $aRet = DllCall('user32.dll', 'bool', 'GetMonitorInfoW', 'handle', $hMonitor, 'struct*', $tMIEX) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Local $aResult[4] For $i = 0 To 1 $aResult[$i] = DllStructCreate($tagRECT) _WinAPI_MoveMemory($aResult[$i], DllStructGetPtr($tMIEX, $i + 2), 16) Next $aResult[3] = DllStructGetData($tMIEX, 5) Switch DllStructGetData($tMIEX, 4) Case 1 $aResult[2] = 1 Case Else $aResult[2] = 0 EndSwitch Return $aResult EndFunc Func _WinAPI_GetOutlineTextMetrics($hDC) Local $aRet = DllCall('gdi32.dll', 'uint', 'GetOutlineTextMetricsW', 'handle', $hDC, 'uint', 0, 'ptr', 0) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Local $tData = DllStructCreate('byte[' & $aRet[0] & ']') Local $tOLTM = DllStructCreate($tagOUTLINETEXTMETRIC, DllStructGetPtr($tData)) $aRet = DllCall('gdi32.dll', 'uint', 'GetOutlineTextMetricsW', 'handle', $hDC, 'uint', $aRet[0], 'struct*', $tData) If Not $aRet[0] Then Return SetError(20, 0, 0) Return $tOLTM EndFunc Func _WinAPI_GetPixel($hDC, $iX, $iY) Local $aRet = DllCall('gdi32.dll', 'dword', 'GetPixel', 'handle', $hDC, 'int', $iX, 'int', $iY) If @error Or ($aRet[0] = 4294967295) Then Return SetError(@error, @extended, -1) Return __RGB($aRet[0]) EndFunc Func _WinAPI_GetPolyFillMode($hDC) Local $aRet = DllCall('gdi32.dll', 'int', 'GetPolyFillMode', 'handle', $hDC) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetPosFromRect($tRECT) Local $aResult[4] For $i = 0 To 3 $aResult[$i] = DllStructGetData($tRECT, $i + 1) If @error Then Return SetError(@error, @extended, 0) Next For $i = 2 To 3 $aResult[$i] -= $aResult[$i - 2] Next Return $aResult EndFunc Func _WinAPI_GetRegionData($hRgn, ByRef $tRGNDATA) Local $aRet = DllCall('gdi32.dll', 'dword', 'GetRegionData', 'handle', $hRgn, 'dword', 0, 'ptr', 0) If @error Or Not $aRet[0] Then $tRGNDATA = 0 Return SetError(@error, @extended, False) EndIf $tRGNDATA = DllStructCreate($tagRGNDATAHEADER) Local $iRectSize = $aRet[0] - DllStructGetSize($tRGNDATA) If $iRectSize > 0 Then $tRGNDATA = DllStructCreate($tagRGNDATAHEADER & ';byte[' & $iRectSize & ']') $aRet = DllCall('gdi32.dll', 'dword', 'GetRegionData', 'handle', $hRgn, 'dword', $aRet[0], 'struct*', $tRGNDATA) If Not $aRet[0] Then $tRGNDATA = 0 Return $aRet[0] EndFunc Func _WinAPI_GetRgnBox($hRgn, ByRef $tRECT) $tRECT = DllStructCreate($tagRECT) Local $aRet = DllCall('gdi32.dll', 'int', 'GetRgnBox', 'handle', $hRgn, 'struct*', $tRECT) If @error Or Not $aRet[0] Then $tRECT = 0 Return SetError(@error, @extended, 0) EndIf Return $aRet[0] EndFunc Func _WinAPI_GetROP2($hDC) Local $aRet = DllCall('gdi32.dll', 'int', 'GetROP2', 'handle', $hDC) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetRValue($iRGB) Return BitAND(__RGB($iRGB), 0x0000FF) EndFunc Func _WinAPI_GetStretchBltMode($hDC) Local $aRet = DllCall('gdi32.dll', 'int', 'GetStretchBltMode', 'handle', $hDC) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetTabbedTextExtent($hDC, $sText, $aTab = 0, $iStart = 0, $iEnd = -1) Local $iTab, $iCount If Not IsArray($aTab) Then If $aTab Then $iTab = $aTab Dim $aTab[1] = [$iTab] $iStart = 0 $iEnd = 0 $iCount = 1 Else $iCount = 0 EndIf Else $iCount = 1 EndIf Local $tTab = 0 If $iCount Then If __CheckErrorArrayBounds($aTab, $iStart, $iEnd) Then Return SetError(@error + 10, @extended, 0) $iCount = $iEnd - $iStart + 1 $tTab = DllStructCreate('uint[' & $iCount & ']') $iTab = 1 For $i = $iStart To $iEnd DllStructSetData($tTab, 1, $aTab[$i], $iTab) $iTab += 1 Next EndIf Local $aRet = DllCall('user32.dll', 'dword', 'GetTabbedTextExtentW', 'handle', $hDC, 'wstr', $sText, 'int', StringLen($sText), 'int', $iCount, 'struct*', $tTab) If @error Or Not $aRet[0] Then Return SetError(@error + 20, @extended, 0) Return _WinAPI_CreateSize(_WinAPI_LoWord($aRet[0]), _WinAPI_HiWord($aRet[0])) EndFunc Func _WinAPI_GetTextAlign($hDC) Local $aRet = DllCall('gdi32.dll', 'uint', 'GetTextAlign', 'handle', $hDC) If @error Or ($aRet[0] = 4294967295) Then Return SetError(@error, @extended, -1) Return $aRet[0] EndFunc Func _WinAPI_GetTextCharacterExtra($hDC) Local $aRet = DllCall('gdi32.dll', 'int', 'GetTextCharacterExtra', 'handle', $hDC) If @error Or ($aRet[0] = 0x8000000) Then Return SetError(@error, @extended, -1) Return $aRet[0] EndFunc Func _WinAPI_GetTextFace($hDC) Local $aRet = DllCall('gdi32.dll', 'int', 'GetTextFaceW', 'handle', $hDC, 'int', 2048, 'wstr', '') If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, '') Return $aRet[3] EndFunc Func _WinAPI_GetUDFColorMode() Return Number($__g_iRGBMode) EndFunc Func _WinAPI_GetUpdateRect($hWnd, $bErase = True) Local $tRECT = DllStructCreate($tagRECT) Local $aRet = DllCall('user32.dll', 'bool', 'GetUpdateRect', 'hwnd', $hWnd, 'struct*', $tRECT, 'bool', $bErase) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return $tRECT EndFunc Func _WinAPI_GetUpdateRgn($hWnd, $hRgn, $bErase = True) Local $aRet = DllCall('user32.dll', 'int', 'GetUpdateRgn', 'hwnd', $hWnd, 'handle', $hRgn, 'bool', $bErase) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetWindowExt($hDC) Local $tSIZE = DllStructCreate($tagSIZE) Local $aRet = DllCall('gdi32.dll', 'bool', 'GetWindowExtEx', 'handle', $hDC, 'struct*', $tSIZE) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return $tSIZE EndFunc Func _WinAPI_GetWindowOrg($hDC) Local $tPOINT = DllStructCreate($tagPOINT) Local $aRet = DllCall('gdi32.dll', 'bool', 'GetWindowOrgEx', 'handle', $hDC, 'struct*', $tPOINT) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return $tPOINT EndFunc Func _WinAPI_GetWindowRgnBox($hWnd, ByRef $tRECT) $tRECT = DllStructCreate($tagRECT) Local $aRet = DllCall('gdi32.dll', 'int', 'GetWindowRgnBox', 'hwnd', $hWnd, 'struct*', $tRECT) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_GetWorldTransform($hDC) Local $tXFORM = DllStructCreate($tagXFORM) Local $aRet = DllCall('gdi32.dll', 'bool', 'GetWorldTransform', 'handle', $hDC, 'struct*', $tXFORM) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return $tXFORM EndFunc Func _WinAPI_GradientFill($hDC, Const ByRef $aVertex, $iStart = 0, $iEnd = -1, $bRotate = False) If __CheckErrorArrayBounds($aVertex, $iStart, $iEnd, 2) Then Return SetError(@error + 10, @extended, 0) If UBound($aVertex, $UBOUND_COLUMNS) < 3 Then Return SetError(13, 0, 0) Local $iPoint = $iEnd - $iStart + 1 If $iPoint > 3 Then $iEnd = $iStart + 2 $iPoint = 3 EndIf Local $iMode Switch $iPoint Case 2 $iMode = Number(Not $bRotate) Case 3 $iMode = 2 Case Else Return SetError(15, 0, 0) EndSwitch Local $tagStruct = '' For $i = $iStart To $iEnd $tagStruct &= 'ushort[8];' Next Local $tVertex = DllStructCreate($tagStruct) Local $iCount = 1 Local $tGradient = DllStructCreate('ulong[' & $iPoint & ']') For $i = $iStart To $iEnd DllStructSetData($tGradient, 1, $iCount - 1, $iCount) DllStructSetData($tVertex, $iCount, _WinAPI_LoWord($aVertex[$i][0]), 1) DllStructSetData($tVertex, $iCount, _WinAPI_HiWord($aVertex[$i][0]), 2) DllStructSetData($tVertex, $iCount, _WinAPI_LoWord($aVertex[$i][1]), 3) DllStructSetData($tVertex, $iCount, _WinAPI_HiWord($aVertex[$i][1]), 4) DllStructSetData($tVertex, $iCount, BitShift(_WinAPI_GetRValue($aVertex[$i][2]), -8), 5) DllStructSetData($tVertex, $iCount, BitShift(_WinAPI_GetGValue($aVertex[$i][2]), -8), 6) DllStructSetData($tVertex, $iCount, BitShift(_WinAPI_GetBValue($aVertex[$i][2]), -8), 7) DllStructSetData($tVertex, $iCount, 0, 8) $iCount += 1 Next Local $aRet = DllCall('gdi32.dll', 'bool', 'GdiGradientFill', 'handle', $hDC, 'struct*', $tVertex, 'ulong', $iPoint, 'struct*', $tGradient, 'ulong', 1, 'ulong', $iMode) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_InflateRect(ByRef $tRECT, $iDX, $iDY) Local $aRet = DllCall('user32.dll', 'bool', 'InflateRect', 'struct*', $tRECT, 'int', $iDX, 'int', $iDY) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_IntersectClipRect($hDC, $tRECT) Local $aRet = DllCall('gdi32.dll', 'int', 'IntersectClipRect', 'handle', $hDC, 'int', DllStructGetData($tRECT, 1), 'int', DllStructGetData($tRECT, 2), 'int', DllStructGetData($tRECT, 3), 'int', DllStructGetData($tRECT, 4)) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_IntersectRect($tRECT1, $tRECT2) Local $tRECT = DllStructCreate($tagRECT) Local $aRet = DllCall('user32.dll', 'bool', 'IntersectRect', 'struct*', $tRECT, 'struct*', $tRECT1, 'struct*', $tRECT2) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return $tRECT EndFunc Func _WinAPI_InvalidateRgn($hWnd, $hRgn = 0, $bErase = True) Local $aRet = DllCall('user32.dll', 'bool', 'InvalidateRgn', 'hwnd', $hWnd, 'handle', $hRgn, 'bool', $bErase) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_InvertANDBitmap($hBitmap, $bDelete = False) Local $tBITMAP = DllStructCreate($tagBITMAP) If Not _WinAPI_GetObject($hBitmap, DllStructGetSize($tBITMAP), $tBITMAP) Or (DllStructGetData($tBITMAP, 'bmBitsPixel') <> 1) Then Return SetError(@error + 10, @extended, 0) EndIf Local $hResult = _WinAPI_CreateDIB(DllStructGetData($tBITMAP, 'bmWidth'), DllStructGetData($tBITMAP, 'bmHeight'), 1) If Not $hResult Then Return SetError(@error, @extended, 0) Local $hSrcDC = _WinAPI_CreateCompatibleDC(0) Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hBitmap) Local $hDstDC = _WinAPI_CreateCompatibleDC(0) Local $hDstSv = _WinAPI_SelectObject($hDstDC, $hResult) _WinAPI_BitBlt($hDstDC, 0, 0, DllStructGetData($tBITMAP, 'bmWidth'), DllStructGetData($tBITMAP, 'bmHeight'), $hSrcDC, 0, 0, 0x00330008) _WinAPI_SelectObject($hSrcDC, $hSrcSv) _WinAPI_DeleteDC($hSrcDC) _WinAPI_SelectObject($hDstDC, $hDstSv) _WinAPI_DeleteDC($hDstDC) If $bDelete Then _WinAPI_DeleteObject($hBitmap) EndIf Return $hResult EndFunc Func _WinAPI_InvertColor($iColor) If $iColor = -1 Then Return 0 Return 0xFFFFFF - BitAND($iColor, 0xFFFFFF) EndFunc Func _WinAPI_InvertRect($hDC, ByRef $tRECT) Local $aRet = DllCall('user32.dll', 'bool', 'InvertRect', 'handle', $hDC, 'struct*', $tRECT) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_InvertRgn($hDC, $hRgn) Local $aRet = DllCall('gdi32.dll', 'bool', 'InvertRgn', 'handle', $hDC, 'handle', $hRgn) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_IsRectEmpty(ByRef $tRECT) Local $aRet = DllCall('user32.dll', 'bool', 'IsRectEmpty', 'struct*', $tRECT) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_LineDDA($iX1, $iY1, $iX2, $iY2, $pLineProc, $pData = 0) Local $aRet = DllCall('gdi32.dll', 'bool', 'LineDDA', 'int', $iX1, 'int', $iY1, 'int', $iX2, 'int', $iY2, 'ptr', $pLineProc, 'lparam', $pData) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_LineTo($hDC, $iX, $iY) Local $aResult = DllCall("gdi32.dll", "bool", "LineTo", "handle", $hDC, "int", $iX, "int", $iY) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_LockWindowUpdate($hWnd) Local $aRet = DllCall('user32.dll', 'bool', 'LockWindowUpdate', 'hwnd', $hWnd) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_LPtoDP($hDC, ByRef $tPOINT, $iCount = 1) Local $aRet = DllCall('gdi32.dll', 'bool', 'LPtoDP', 'handle', $hDC, 'struct*', $tPOINT, 'int', $iCount) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_MaskBlt($hDestDC, $iXDest, $iYDest, $iWidth, $iHeight, $hSrcDC, $iXSrc, $iYSrc, $hMask, $iXMask, $iYMask, $iRop) Local $aRet = DllCall('gdi32.dll', 'bool', 'MaskBlt', 'handle', $hDestDC, 'int', $iXDest, 'int', $iYDest, 'int', $iWidth, 'int', $iHeight, 'hwnd', $hSrcDC, 'int', $iXSrc, 'int', $iYSrc, 'handle', $hMask, 'int', $iXMask, 'int', $iYMask, 'dword', $iRop) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_ModifyWorldTransform($hDC, ByRef $tXFORM, $iMode) Local $aRet = DllCall('gdi32.dll', 'bool', 'ModifyWorldTransform', 'handle', $hDC, 'struct*', $tXFORM, 'dword', $iMode) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_MonitorFromPoint(ByRef $tPOINT, $iFlag = 1) If DllStructGetSize($tPOINT) <> 8 Then Return SetError(@error + 10, @extended, 0) Local $aRet = DllCall('user32.dll', 'handle', 'MonitorFromPoint', 'struct', $tPOINT, 'dword', $iFlag) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_MonitorFromRect(ByRef $tRECT, $iFlag = 1) Local $aRet = DllCall('user32.dll', 'ptr', 'MonitorFromRect', 'struct*', $tRECT, 'dword', $iFlag) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_MonitorFromWindow($hWnd, $iFlag = 1) Local $aRet = DllCall('user32.dll', 'handle', 'MonitorFromWindow', 'hwnd', $hWnd, 'dword', $iFlag) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_MoveTo($hDC, $iX, $iY) Local $aResult = DllCall("gdi32.dll", "bool", "MoveToEx", "handle", $hDC, "int", $iX, "int", $iY, "ptr", 0) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_MoveToEx($hDC, $iX, $iY) Local $tPOINT = DllStructCreate($tagPOINT) Local $aRet = DllCall('gdi32.dll', 'bool', 'MoveToEx', 'handle', $hDC, 'int', $iX, 'int', $iY, 'struct*', $tPOINT) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return $tPOINT EndFunc Func _WinAPI_OffsetClipRgn($hDC, $iXOffset, $iYOffset) Local $aRet = DllCall('gdi32.dll', 'int', 'OffsetClipRgn', 'handle', $hDC, 'int', $iXOffset, 'int', $iYOffset) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_OffsetPoints(ByRef $aPoint, $iXOffset, $iYOffset, $iStart = 0, $iEnd = -1) If __CheckErrorArrayBounds($aPoint, $iStart, $iEnd, 2) Then Return SetError(@error + 10, @extended, 0) If UBound($aPoint, $UBOUND_COLUMNS) < 2 Then Return SetError(13, 0, 0) For $i = $iStart To $iEnd $aPoint[$i][0] += $iXOffset $aPoint[$i][1] += $iYOffset Next Return 1 EndFunc Func _WinAPI_OffsetRect(ByRef $tRECT, $iDX, $iDY) Local $aRet = DllCall('user32.dll', 'bool', 'OffsetRect', 'struct*', $tRECT, 'int', $iDX, 'int', $iDY) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_OffsetRgn($hRgn, $iXOffset, $iYOffset) Local $aRet = DllCall('gdi32.dll', 'int', 'OffsetRgn', 'handle', $hRgn, 'int', $iXOffset, 'int', $iYOffset) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_OffsetWindowOrg($hDC, $iXOffset, $iYOffset) $__g_vExt = DllStructCreate($tagPOINT) Local $aRet = DllCall('gdi32.dll', 'bool', 'OffsetWindowOrgEx', 'handle', $hDC, 'int', $iXOffset, 'int', $iYOffset, 'struct*', $__g_vExt) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_PaintDesktop($hDC) Local $aRet = DllCall('user32.dll', 'bool', 'PaintDesktop', 'handle', $hDC) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_PaintRgn($hDC, $hRgn) Local $aRet = DllCall('gdi32.dll', 'bool', 'PaintRgn', 'handle', $hDC, 'handle', $hRgn) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_PatBlt($hDC, $iX, $iY, $iWidth, $iHeight, $iRop) Local $aRet = DllCall('gdi32.dll', 'bool', 'PatBlt', 'handle', $hDC, 'int', $iX, 'int', $iY, 'int', $iWidth, 'int', $iHeight, 'dword', $iRop) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_PathToRegion($hDC) Local $aRet = DllCall('gdi32.dll', 'handle', 'PathToRegion', 'handle', $hDC) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_PlayEnhMetaFile($hDC, $hEmf, ByRef $tRECT) Local $aRet = DllCall('gdi32.dll', 'bool', 'PlayEnhMetaFile', 'handle', $hDC, 'handle', $hEmf, 'struct*', $tRECT) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_PlgBlt($hDestDC, Const ByRef $aPoint, $hSrcDC, $iXSrc, $iYSrc, $iWidth, $iHeight, $hMask = 0, $iXMask = 0, $iYMask = 0) If (UBound($aPoint) < 3) Or (UBound($aPoint, $UBOUND_COLUMNS) < 2) Then Return SetError(12, 0, False) Local $tPoints = DllStructCreate('long[2];long[2];long[2]') For $i = 0 To 2 For $j = 0 To 1 DllStructSetData($tPoints, $i + 1, $aPoint[$i][$j], $j + 1) Next Next Local $aRet = DllCall('gdi32.dll', 'bool', 'PlgBlt', 'handle', $hDestDC, 'struct*', $tPoints, 'handle', $hSrcDC, 'int', $iXSrc, 'int', $iYSrc, 'int', $iWidth, 'int', $iHeight, 'handle', $hMask, 'int', $iXMask, 'int', $iYMask) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_PolyBezier($hDC, Const ByRef $aPoint, $iStart = 0, $iEnd = -1) If __CheckErrorArrayBounds($aPoint, $iStart, $iEnd, 2, 2) Then Return SetError(@error + 10, @extended, False) Local $iPoint = 1 + 3 * Floor(($iEnd - $iStart) / 3) If $iPoint < 1 Then Return SetError(15, 0, False) $iEnd = $iStart + $iPoint - 1 Local $tagStruct = '' For $i = $iStart To $iEnd $tagStruct &= 'long[2];' Next Local $tPOINT = DllStructCreate($tagStruct) Local $iCount = 0 For $i = $iStart To $iEnd $iCount += 1 For $j = 0 To 1 DllStructSetData($tPOINT, $iCount, $aPoint[$i][$j], $j + 1) Next Next Local $aRet = DllCall('gdi32.dll', 'bool', 'PolyBezier', 'handle', $hDC, 'struct*', $tPOINT, 'dword', $iPoint) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_PolyBezierTo($hDC, Const ByRef $aPoint, $iStart = 0, $iEnd = -1) If __CheckErrorArrayBounds($aPoint, $iStart, $iEnd, 2, 2) Then Return SetError(@error + 10, @extended, False) Local $iPoint = 3 * Floor(($iEnd - $iStart + 1) / 3) If $iPoint < 3 Then Return SetError(15, 0, False) $iEnd = $iStart + $iPoint - 1 Local $tagStruct = '' For $i = $iStart To $iEnd $tagStruct &= 'long[2];' Next Local $tPOINT = DllStructCreate($tagStruct) Local $iCount = 0 For $i = $iStart To $iEnd $iCount += 1 For $j = 0 To 1 DllStructSetData($tPOINT, $iCount, $aPoint[$i][$j], $j + 1) Next Next Local $aRet = DllCall('gdi32.dll', 'bool', 'PolyBezierTo', 'handle', $hDC, 'struct*', $tPOINT, 'dword', $iPoint) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_PolyDraw($hDC, Const ByRef $aPoint, $iStart = 0, $iEnd = -1) If __CheckErrorArrayBounds($aPoint, $iStart, $iEnd, 2) Then Return SetError(@error + 10, @extended, 0) If UBound($aPoint, $UBOUND_COLUMNS) < 3 Then Return SetError(13, 0, False) Local $iPoint = $iEnd - $iStart + 1 Local $tagStruct = '' For $i = $iStart To $iEnd $tagStruct &= 'long[2];' Next Local $tPOINT = DllStructCreate($tagStruct) Local $tTypes = DllStructCreate('byte[' & $iPoint & ']') Local $iCount = 0 For $i = $iStart To $iEnd $iCount += 1 For $j = 0 To 1 DllStructSetData($tPOINT, $iCount, $aPoint[$i][$j], $j + 1) Next DllStructSetData($tTypes, 1, $aPoint[$i][2], $iCount) Next Local $aRet = DllCall('gdi32.dll', 'bool', 'PolyDraw', 'handle', $hDC, 'struct*', $tPOINT, 'struct*', $tTypes, 'dword', $iPoint) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_Polygon($hDC, Const ByRef $aPoint, $iStart = 0, $iEnd = -1) If __CheckErrorArrayBounds($aPoint, $iStart, $iEnd, 2, 2) Then Return SetError(@error + 10, @extended, False) Local $tagStruct = '' For $i = $iStart To $iEnd $tagStruct &= 'int[2];' Next Local $tData = DllStructCreate($tagStruct) Local $iCount = 1 For $i = $iStart To $iEnd For $j = 0 To 1 DllStructSetData($tData, $iCount, $aPoint[$i][$j], $j + 1) Next $iCount += 1 Next Local $aRet = DllCall('gdi32.dll', 'bool', 'Polygon', 'handle', $hDC, 'struct*', $tData, 'int', $iCount - 1) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_PtInRectEx($iX, $iY, $iLeft, $iTop, $iRight, $iBottom) Local $tRECT = _WinAPI_CreateRect($iLeft, $iTop, $iRight, $iBottom) Local $tPOINT = _WinAPI_CreatePoint($iX, $iY) Local $aRet = DllCall('user32.dll', 'bool', 'PtInRect', 'struct*', $tRECT, 'struct', $tPOINT) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_PtInRegion($hRgn, $iX, $iY) Local $aRet = DllCall('gdi32.dll', 'bool', 'PtInRegion', 'handle', $hRgn, 'int', $iX, 'int', $iY) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_PtVisible($hDC, $iX, $iY) Local $aRet = DllCall('gdi32.dll', 'bool', 'PtVisible', 'handle', $hDC, 'int', $iX, 'int', $iY) If @error Then Return SetError(@error + 10, @extended, 0) If $aRet[0] = -1 Then Return SetError(10, $aRet[0], 0) Return $aRet[0] EndFunc Func _WinAPI_RadialGradientFill($hDC, $iX, $iY, $iRadius, $iRGB1, $iRGB2, $fAngleStart = 0, $fAngleEnd = 360, $fStep = 5) If Abs($fAngleStart) > 360 Then $fAngleStart = Mod($fAngleStart, 360) EndIf If Abs($fAngleEnd) > 360 Then $fAngleEnd = Mod($fAngleEnd, 360) EndIf If ($fAngleStart < 0) Or ($fAngleEnd < 0) Then $fAngleStart += 360 $fAngleEnd += 360 EndIf If $fAngleStart > $fAngleEnd Then Local $fVal = $fAngleStart $fAngleStart = $fAngleEnd $fAngleEnd = $fVal EndIf If $fStep < 1 Then $fStep = 1 EndIf Local $fKi = ATan(1) / 45 Local $iXp = Round($iX + $iRadius * Cos($fKi * $fAngleStart)) Local $iYp = Round($iY + $iRadius * Sin($fKi * $fAngleStart)) Local $iXn, $iYn, $fAn = $fAngleStart Local $aVertex[3][3] While $fAn < $fAngleEnd $fAn += $fStep If $fAn > $fAngleEnd Then $fAn = $fAngleEnd EndIf $iXn = Round($iX + $iRadius * Cos($fKi * $fAn)) $iYn = Round($iY + $iRadius * Sin($fKi * $fAn)) $aVertex[0][0] = $iX $aVertex[0][1] = $iY $aVertex[0][2] = $iRGB1 $aVertex[1][0] = $iXp $aVertex[1][1] = $iYp $aVertex[1][2] = $iRGB2 $aVertex[2][0] = $iXn $aVertex[2][1] = $iYn $aVertex[2][2] = $iRGB2 If Not _WinAPI_GradientFill($hDC, $aVertex, 0, 2) Then Return SetError(@error, @extended, 0) EndIf $iXp = $iXn $iYp = $iYn WEnd Return 1 EndFunc Func _WinAPI_Rectangle($hDC, $tRECT) Local $aRet = DllCall('gdi32.dll', 'bool', 'Rectangle', 'handle', $hDC, 'int', DllStructGetData($tRECT, 1), 'int', DllStructGetData($tRECT, 2), 'int', DllStructGetData($tRECT, 3), 'int', DllStructGetData($tRECT, 4)) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_RectInRegion($hRgn, $tRECT) Local $aRet = DllCall('gdi32.dll', 'bool', 'RectInRegion', 'handle', $hRgn, 'struct*', $tRECT) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_RectIsEmpty(ByRef $tRECT) Return (DllStructGetData($tRECT, "Left") = 0) And (DllStructGetData($tRECT, "Top") = 0) And (DllStructGetData($tRECT, "Right") = 0) And (DllStructGetData($tRECT, "Bottom") = 0) EndFunc Func _WinAPI_RectVisible($hDC, $tRECT) Local $aRet = DllCall('gdi32.dll', 'bool', 'RectVisible', 'handle', $hDC, 'struct*', $tRECT) If @error Then Return SetError(@error, @extended, 0) Switch $aRet[0] Case 0, 1, 2 Case Else Return SetError(10, $aRet[0], 0) EndSwitch Return $aRet[0] EndFunc Func _WinAPI_RemoveFontMemResourceEx($hFont) Local $aRet = DllCall('gdi32.dll', 'bool', 'RemoveFontMemResourceEx', 'handle', $hFont) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_RemoveFontResourceEx($sFont, $iFlag = 0, $bNotify = False) Local $aRet = DllCall('gdi32.dll', 'bool', 'RemoveFontResourceExW', 'wstr', $sFont, 'dword', $iFlag, 'ptr', 0) If @error Or Not $aRet[0] Then Return SetError(@error, @extended, False) If $bNotify Then Local Const $WM_FONTCHANGE = 0x001D Local Const $HWND_BROADCAST = 0xFFFF DllCall('user32.dll', 'none', 'SendMessage', 'hwnd', $HWND_BROADCAST, 'uint', $WM_FONTCHANGE, 'wparam', 0, 'lparam', 0) EndIf Return $aRet[0] EndFunc Func _WinAPI_RGB($iRed, $iGreen, $iBlue) Return __RGB(BitOR(BitShift($iBlue, -16), BitShift($iGreen, -8), $iRed)) EndFunc Func _WinAPI_RotatePoints(ByRef $aPoint, $iXC, $iYC, $fAngle, $iStart = 0, $iEnd = -1) If __CheckErrorArrayBounds($aPoint, $iStart, $iEnd, 2) Then Return SetError(@error + 10, @extended, 0) If UBound($aPoint, $UBOUND_COLUMNS) < 2 Then Return SetError(13, 0, 0) Local $fCos = Cos(ATan(1) / 45 * $fAngle) Local $fSin = Sin(ATan(1) / 45 * $fAngle) Local $iXn, $iYn For $i = $iStart To $iEnd $iXn = $aPoint[$i][0] - $iXC $iYn = $aPoint[$i][1] - $iYC $aPoint[$i][0] = $iXC + Round($iXn * $fCos - $iYn * $fSin) $aPoint[$i][1] = $iYC + Round($iXn * $fSin + $iYn * $fCos) Next Return 1 EndFunc Func _WinAPI_RoundRect($hDC, $tRECT, $iWidth, $iHeight) Local $aRet = DllCall('gdi32.dll', 'bool', 'RoundRect', 'handle', $hDC, 'int', DllStructGetData($tRECT, 1), 'int', DllStructGetData($tRECT, 2), 'int', DllStructGetData($tRECT, 3), 'int', DllStructGetData($tRECT, 4), 'int', $iWidth, 'int', $iHeight) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_SaveHBITMAPToFile($sFilePath, $hBitmap, $iXPelsPerMeter = Default, $iYPelsPerMeter = Default) Local $tBMP = DllStructCreate('align 1;ushort bfType;dword bfSize;ushort bfReserved1;ushort bfReserved2;dword bfOffset') Local $tDIB = DllStructCreate($tagDIBSECTION) Local $hDC, $hSv, $hSource = 0 While $hBitmap If (Not _WinAPI_GetObject($hBitmap, DllStructGetSize($tDIB), $tDIB)) Or (DllStructGetData($tDIB, 'biCompression')) Then $hBitmap = 0 Else Switch DllStructGetData($tDIB, 'bmBitsPixel') Case 32 If Not _WinAPI_IsAlphaBitmap($hBitmap) Then If Not $hSource Then $hSource = _WinAPI_CreateDIB(DllStructGetData($tDIB, 'bmWidth'), DllStructGetData($tDIB, 'bmHeight'), 24) If Not $hSource Then $hBitmap = 0 EndIf $hDC = _WinAPI_CreateCompatibleDC(0) $hSv = _WinAPI_SelectObject($hDC, $hSource) If _WinAPI_DrawBitmap($hDC, 0, 0, $hBitmap) Then $hBitmap = $hSource Else $hBitmap = 0 EndIf _WinAPI_SelectObject($hDC, $hSv) _WinAPI_DeleteDC($hDC) Else $hBitmap = 0 EndIf ContinueLoop EndIf Case Else EndSwitch If (Not DllStructGetData($tDIB, 'bmBits')) Or (Not DllStructGetData($tDIB, 'biSizeImage')) Then If Not $hSource Then $hBitmap = _WinAPI_CopyBitmap($hBitmap) $hSource = $hBitmap Else $hBitmap = 0 EndIf Else ExitLoop EndIf EndIf WEnd Local $hFile = 0, $iError = 0, $iResult = 0 Do If Not $hBitmap Then $iError = 1 ExitLoop EndIf Local $aData[4][2] $aData[0][0] = DllStructGetPtr($tBMP) $aData[0][1] = DllStructGetSize($tBMP) $aData[1][0] = DllStructGetPtr($tDIB, 'biSize') $aData[1][1] = 40 $aData[2][1] = DllStructGetData($tDIB, 'biClrUsed') * 4 Local $tTable = 0 If $aData[2][1] Then $tTable = _WinAPI_GetDIBColorTable($hBitmap) If @error Or (@extended <> $aData[2][1] / 4) Then $iError = @error + 10 ExitLoop EndIf EndIf $aData[2][0] = DllStructGetPtr($tTable) $aData[3][0] = DllStructGetData($tDIB, 'bmBits') $aData[3][1] = DllStructGetData($tDIB, 'biSizeImage') DllStructSetData($tBMP, 'bfType', 0x4D42) DllStructSetData($tBMP, 'bfSize', $aData[0][1] + $aData[1][1] + $aData[2][1] + $aData[3][1]) DllStructSetData($tBMP, 'bfReserved1', 0) DllStructSetData($tBMP, 'bfReserved2', 0) DllStructSetData($tBMP, 'bfOffset', $aData[0][1] + $aData[1][1] + $aData[2][1]) $hDC = _WinAPI_GetDC(0) If $iXPelsPerMeter = Default Then If Not DllStructGetData($tDIB, 'biXPelsPerMeter') Then DllStructSetData($tDIB, 'biXPelsPerMeter', _WinAPI_GetDeviceCaps($hDC, 8) / _WinAPI_GetDeviceCaps($hDC, 4) * 1000) EndIf Else DllStructSetData($tDIB, 'biXPelsPerMeter', $iXPelsPerMeter) EndIf If $iYPelsPerMeter = Default Then If Not DllStructGetData($tDIB, 'biYPelsPerMeter') Then DllStructSetData($tDIB, 'biYPelsPerMeter', _WinAPI_GetDeviceCaps($hDC, 10) / _WinAPI_GetDeviceCaps($hDC, 6) * 1000) EndIf Else DllStructSetData($tDIB, 'biYPelsPerMeter', $iYPelsPerMeter) EndIf _WinAPI_ReleaseDC(0, $hDC) $hFile = _WinAPI_CreateFile($sFilePath, 1, 4) If @error Then $iError = @error + 20 ExitLoop EndIf Local $iBytes For $i = 0 To 3 If $aData[$i][1] Then If Not _WinAPI_WriteFile($hFile, $aData[$i][0], $aData[$i][1], $iBytes) Then $iError = @error + 30 ExitLoop 2 EndIf EndIf Next $iResult = 1 Until 1 If $hSource Then _WinAPI_DeleteObject($hSource) EndIf _WinAPI_CloseHandle($hFile) If Not $iResult Then FileDelete($sFilePath) EndIf Return SetError($iError, 0, $iResult) EndFunc Func _WinAPI_SaveHICONToFile($sFilePath, Const ByRef $vIcon, $bCompress = 0, $iStart = 0, $iEnd = -1) Local $aIcon, $aTemp, $iCount = 1 If Not IsArray($vIcon) Then Dim $aIcon[1] = [$vIcon] Dim $aTemp[1] = [0] Else If __CheckErrorArrayBounds($vIcon, $iStart, $iEnd) Then Return SetError(@error + 10, @extended, 0) $iCount = $iEnd - $iStart + 1 If $iCount Then Dim $aIcon[$iCount] Dim $aTemp[$iCount] For $i = 0 To $iCount - 1 $aIcon[$i] = $vIcon[$iStart + $i] $aTemp[$i] = 0 Next EndIf EndIf Local $hFile = _WinAPI_CreateFile($sFilePath, 1, 4) If @error Then Return SetError(@error + 20, @extended, 0) Local $tIco = DllStructCreate('align 1;ushort Reserved;ushort Type;ushort Count;byte Data[' & (16 * $iCount) & ']') Local $iLength = DllStructGetSize($tIco) Local $tBI = DllStructCreate($tagBITMAPINFOHEADER) Local $tII = DllStructCreate($tagICONINFO) Local $tDIB = DllStructCreate($tagDIBSECTION) Local $iDIB = DllStructGetSize($tDIB) Local $pDIB = DllStructGetPtr($tDIB) Local $iOffset = $iLength DllStructSetData($tBI, 'biSize', 40) DllStructSetData($tBI, 'biPlanes', 1) DllStructSetData($tBI, 'biXPelsPerMeter', 0) DllStructSetData($tBI, 'biYPelsPerMeter', 0) DllStructSetData($tBI, 'biClrUsed', 0) DllStructSetData($tBI, 'biClrImportant', 0) DllStructSetData($tIco, 'Reserved', 0) DllStructSetData($tIco, 'Type', 1) DllStructSetData($tIco, 'Count', $iCount) Local $iResult = 0, $iError = 0, $iBytes Local $aInfo[8], $aRet, $pData = 0, $iIndex = 0 Local $aSize[2], $tData = 0 Do If Not _WinAPI_WriteFile($hFile, $tIco, $iLength, $iBytes) Then $iError = @error + 30 ExitLoop EndIf While $iCount > $iIndex $aRet = DllCall('user32.dll', 'bool', 'GetIconInfo', 'handle', $aIcon[$iIndex], 'struct*', $tII) If @error Or Not $aRet[0] Then $iError = @error + 40 ExitLoop 2 EndIf For $i = 4 To 5 $aInfo[$i] = _WinAPI_CopyImage(DllStructGetData($tII, $i), 0, 0, 0, 0x2008) If _WinAPI_GetObject($aInfo[$i], $iDIB, $pDIB) Then $aInfo[$i - 4] = DllStructGetData($tDIB, 'biSizeImage') $aInfo[$i - 2] = DllStructGetData($tDIB, 'bmBits') Else $iError = @error + 50 EndIf Next $aInfo[6] = 40 $aInfo[7] = DllStructGetData($tDIB, 'bmBitsPixel') Switch $aInfo[7] Case 16, 24 Case 32 If Not _WinAPI_IsAlphaBitmap($aInfo[5]) Then If Not $aTemp[$iIndex] Then $aIcon[$iIndex] = _WinAPI_Create32BitHICON($aIcon[$iIndex]) $aTemp[$iIndex] = $aIcon[$iIndex] If Not @error Then ContinueLoop Else ContinueCase EndIf EndIf Else If ($aInfo[1] >= 256 * 256 * 4) And ($bCompress) Then $iBytes = _WinAPI_CompressBitmapBits($aInfo[5], $pData) If Not @error Then $aInfo[0] = 0 $aInfo[1] = $iBytes $aInfo[2] = 0 $aInfo[3] = $pData $aInfo[6] = 0 EndIf EndIf EndIf Case Else $iError = 60 EndSwitch If Not $iError Then $tData = DllStructCreate('byte Width;byte Height;byte ColorCount;byte Reserved;ushort Planes;ushort BitCount;long Size;long Offset', DllStructGetPtr($tIco) + 6 + 16 * $iIndex) DllStructSetData($tData, 'ColorCount', 0) DllStructSetData($tData, 'Reserved', 0) DllStructSetData($tData, 'Planes', 1) DllStructSetData($tData, 'BitCount', $aInfo[7]) DllStructSetData($tData, 'Size', $aInfo[0] + $aInfo[1] + $aInfo[6]) DllStructSetData($tData, 'Offset', $iOffset) For $i = 0 To 1 $aSize[$i] = DllStructGetData($tDIB, $i + 2) If $aSize[$i] < 256 Then DllStructSetData($tData, $i + 1, $aSize[$i]) Else DllStructSetData($tData, $i + 1, 0) EndIf Next DllStructSetData($tBI, 'biWidth', $aSize[0]) DllStructSetData($tBI, 'biHeight', 2 * $aSize[1]) DllStructSetData($tBI, 'biBitCount', $aInfo[7]) DllStructSetData($tBI, 'biCompression', 0) DllStructSetData($tBI, 'biSizeImage', $aInfo[0] + $aInfo[1]) $iOffset += $aInfo[0] + $aInfo[1] + $aInfo[6] Do If $aInfo[6] Then If Not _WinAPI_WriteFile($hFile, $tBI, $aInfo[6], $iBytes) Then $iError = @error + 70 ExitLoop EndIf For $i = 1 To 0 Step -1 If Not _WinAPI_WriteFile($hFile, $aInfo[$i + 2], $aInfo[$i], $iBytes) Then $iError = @error + 80 ExitLoop 2 EndIf Next Else If Not _WinAPI_WriteFile($hFile, $aInfo[3], $aInfo[1], $iBytes) Then $iError = @error + 90 ExitLoop EndIf EndIf Until 1 EndIf For $i = 4 To 5 _WinAPI_DeleteObject($aInfo[$i]) Next If $iError Then ExitLoop 2 EndIf $iIndex += 1 WEnd $aRet = DllCall('kernel32.dll', 'bool', 'SetFilePointerEx', 'handle', $hFile, 'int64', 0, 'int64*', 0, 'dword', 0) If @error Or Not $aRet[0] Then $iError = @error + 100 ExitLoop EndIf If Not _WinAPI_WriteFile($hFile, $tIco, $iLength, $iBytes) Then $iError = @error + 110 ExitLoop EndIf $iResult = 1 Until 1 For $i = 0 To $iCount - 1 If $aTemp[$i] Then _WinAPI_DestroyIcon($aTemp[$i]) EndIf Next If $pData Then __HeapFree($pData) EndIf _WinAPI_CloseHandle($hFile) If Not $iResult Then FileDelete($sFilePath) EndIf Return SetError($iError, 0, $iResult) EndFunc Func _WinAPI_ScaleWindowExt($hDC, $iXNum, $iXDenom, $iYNum, $iYDenom) $__g_vExt = DllStructCreate($tagSIZE) Local $aRet = DllCall('gdi32.dll', 'bool', 'ScaleWindowExtEx', 'handle', $hDC, 'int', $iXNum, 'int', $iXDenom, 'int', $iYNum, 'int', $iYDenom, 'struct*', $__g_vExt) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_SelectClipPath($hDC, $iMode = 5) Local $aRet = DllCall('gdi32.dll', 'bool', 'SelectClipPath', 'handle', $hDC, 'int', $iMode) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_SelectClipRgn($hDC, $hRgn) Local $aRet = DllCall('gdi32.dll', 'int', 'SelectClipRgn', 'handle', $hDC, 'handle', $hRgn) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_SetArcDirection($hDC, $iDirection) Local $aRet = DllCall('gdi32.dll', 'int', 'SetArcDirection', 'handle', $hDC, 'int', $iDirection) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_SetBitmapBits($hBitmap, $iSize, $pBits) Local $aRet = DllCall('gdi32.dll', 'long', 'SetBitmapBits', 'handle', $hBitmap, 'dword', $iSize, 'struct*', $pBits) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_SetBitmapDimensionEx($hBitmap, $iWidth, $iHeight) $__g_vExt = DllStructCreate($tagSIZE) Local $aRet = DllCall('gdi32.dll', 'bool', 'SetBitmapDimensionEx', 'handle', $hBitmap, 'int', $iWidth, 'int', $iHeight, 'struct*', $__g_vExt) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_SetBoundsRect($hDC, $iFlags, $tRECT = 0) Local $aRet = DllCall('gdi32.dll', 'uint', 'SetBoundsRect', 'handle', $hDC, 'struct*', $tRECT, 'uint', $iFlags) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_SetBrushOrg($hDC, $iX, $iY) $__g_vExt = DllStructCreate($tagPOINT) Local $aRet = DllCall('gdi32.dll', 'bool', 'SetBrushOrgEx', 'handle', $hDC, 'int', $iX, 'int', $iY, 'struct*', $__g_vExt) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_SetColorAdjustment($hDC, $tAdjustment) Local $aRet = DllCall('gdi32.dll', 'bool', 'SetColorAdjustment', 'handle', $hDC, 'struct*', $tAdjustment) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_SetDCBrushColor($hDC, $iRGB) Local $aRet = DllCall('gdi32.dll', 'dword', 'SetDCBrushColor', 'handle', $hDC, 'dword', __RGB($iRGB)) If @error Or ($aRet[0] = 4294967295) Then Return SetError(@error, @extended, -1) Return __RGB($aRet[0]) EndFunc Func _WinAPI_SetDCPenColor($hDC, $iRGB) Local $aRet = DllCall('gdi32.dll', 'dword', 'SetDCPenColor', 'handle', $hDC, 'dword', __RGB($iRGB)) If @error Or ($aRet[0] = 4294967295) Then Return SetError(@error, @extended, -1) Return __RGB($aRet[0]) EndFunc Func _WinAPI_SetDeviceGammaRamp($hDC, Const ByRef $aRamp) If (UBound($aRamp, $UBOUND_DIMENSIONS) <> 2) Or (UBound($aRamp, $UBOUND_ROWS) <> 256) Or (UBound($aRamp, $UBOUND_COLUMNS) <> 3) Then Return SetError(12, 0, 0) EndIf Local $tData = DllStructCreate('ushort[256];ushort[256];ushort[256]') For $i = 0 To 2 For $j = 0 To 255 DllStructSetData($tData, $i + 1, $aRamp[$j][$i], $j + 1) Next Next Local $aRet = DllCall('gdi32.dll', 'bool', 'SetDeviceGammaRamp', 'handle', $hDC, 'struct*', $tData) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_SetDIBColorTable($hBitmap, $tColorTable, $iColorCount) If $iColorCount > DllStructGetSize($tColorTable) / 4 Then Return SetError(1, 0, 0) Local $hDC = _WinAPI_CreateCompatibleDC(0) Local $hSv = _WinAPI_SelectObject($hDC, $hBitmap) Local $iError = 0 Local $aRet = DllCall('gdi32.dll', 'uint', 'SetDIBColorTable', 'handle', $hDC, 'uint', 0, 'uint', $iColorCount, 'struct*', $tColorTable) If @error Then $iError = @error _WinAPI_SelectObject($hDC, $hSv) _WinAPI_DeleteDC($hDC) If $iError Then Return SetError($iError, 0, 0) Return $aRet[0] EndFunc Func _WinAPI_SetDIBits($hDC, $hBitmap, $iStartScan, $iScanLines, $pBits, $tBMI, $iColorUse = 0) Local $aResult = DllCall("gdi32.dll", "int", "SetDIBits", "handle", $hDC, "handle", $hBitmap, "uint", $iStartScan, "uint", $iScanLines, "struct*", $pBits, "struct*", $tBMI, "INT", $iColorUse) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc Func _WinAPI_SetDIBitsToDevice($hDC, $iXDest, $iYDest, $iWidth, $iHeight, $iXSrc, $iYSrc, $iStartScan, $iScanLines, $tBITMAPINFO, $iUsage, $pBits) Local $aRet = DllCall('gdi32.dll', 'int', 'SetDIBitsToDevice', 'handle', $hDC, 'int', $iXDest, 'int', $iYDest, 'dword', $iWidth, 'dword', $iHeight, 'int', $iXSrc, 'int', $iYSrc, 'uint', $iStartScan, 'uint', $iScanLines, 'struct*', $pBits, 'struct*', $tBITMAPINFO, 'uint', $iUsage) If @error Or ($aRet[0] = -1) Then Return SetError(@error + 10, $aRet[0], 0) Return $aRet[0] EndFunc Func _WinAPI_SetEnhMetaFileBits($pData, $iLength) Local $aRet = DllCall('gdi32.dll', 'handle', 'SetEnhMetaFileBits', 'uint', $iLength, 'struct*', $pData) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_SetGraphicsMode($hDC, $iMode) Local $aRet = DllCall('gdi32.dll', 'int', 'SetGraphicsMode', 'handle', $hDC, 'int', $iMode) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_SetMapMode($hDC, $iMode) Local $aRet = DllCall('gdi32.dll', 'int', 'SetMapMode', 'handle', $hDC, 'int', $iMode) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_SetPixel($hDC, $iX, $iY, $iRGB) Local $aRet = DllCall('gdi32.dll', 'bool', 'SetPixelV', 'handle', $hDC, 'int', $iX, 'int', $iY, 'dword', __RGB($iRGB)) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_SetPolyFillMode($hDC, $iMode = 1) Local $aRet = DllCall('gdi32.dll', 'int', 'SetPolyFillMode', 'handle', $hDC, 'int', $iMode) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_SetRectRgn($hRgn, $tRECT) Local $aRet = DllCall('gdi32.dll', 'bool', 'SetRectRgn', 'handle', $hRgn, 'int', DllStructGetData($tRECT, 1), 'int', DllStructGetData($tRECT, 2), 'int', DllStructGetData($tRECT, 3), 'int', DllStructGetData($tRECT, 4)) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_SetROP2($hDC, $iMode) Local $aRet = DllCall('gdi32.dll', 'int', 'SetROP2', 'handle', $hDC, 'int', $iMode) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_SetStretchBltMode($hDC, $iMode) Local $aRet = DllCall('gdi32.dll', 'int', 'SetStretchBltMode', 'handle', $hDC, 'int', $iMode) If @error Or Not $aRet[0] Or ($aRet[0] = 87) Then Return SetError(@error + 10, $aRet[0], 0) Return $aRet[0] EndFunc Func _WinAPI_SetTextAlign($hDC, $iMode = 0) Local $aRet = DllCall('gdi32.dll', 'uint', 'SetTextAlign', 'handle', $hDC, 'uint', $iMode) If @error Or ($aRet[0] = 4294967295) Then Return SetError(@error, @extended, -1) Return $aRet[0] EndFunc Func _WinAPI_SetTextCharacterExtra($hDC, $iCharExtra) Local $aRet = DllCall('gdi32.dll', 'int', 'SetTextCharacterExtra', 'handle', $hDC, 'int', $iCharExtra) If @error Or ($aRet[0] = 0x80000000) Then Return SetError(@error, @extended, -1) Return $aRet[0] EndFunc Func _WinAPI_SetTextJustification($hDC, $iBreakExtra, $iBreakCount) Local $aRet = DllCall('gdi32.dll', 'bool', 'SetTextJustification', 'handle', $hDC, 'int', $iBreakExtra, 'int', $iBreakCount) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_SetUDFColorMode($iMode) $__g_iRGBMode = Not ($iMode = 0) EndFunc Func _WinAPI_SetWindowExt($hDC, $iXExtent, $iYExtent) $__g_vExt = DllStructCreate($tagSIZE) Local $aRet = DllCall('gdi32.dll', 'bool', 'SetWindowExtEx', 'handle', $hDC, 'int', $iXExtent, 'int', $iYExtent, 'struct*', $__g_vExt) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_SetWindowOrg($hDC, $iX, $iY) $__g_vExt = DllStructCreate($tagPOINT) Local $aRet = DllCall('gdi32.dll', 'bool', 'SetWindowOrgEx', 'handle', $hDC, 'int', $iX, 'int', $iY, 'struct*', $__g_vExt) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_SetWorldTransform($hDC, ByRef $tXFORM) Local $aRet = DllCall('gdi32.dll', 'bool', 'SetWorldTransform', 'handle', $hDC, 'struct*', $tXFORM) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_StretchBlt($hDestDC, $iXDest, $iYDest, $iWidthDest, $iHeightDest, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iRop) Local $aRet = DllCall('gdi32.dll', 'bool', 'StretchBlt', 'handle', $hDestDC, 'int', $iXDest, 'int', $iYDest, 'int', $iWidthDest, 'int', $iHeightDest, 'hwnd', $hSrcDC, 'int', $iXSrc, 'int', $iYSrc, 'int', $iWidthSrc, 'int', $iHeightSrc, 'dword', $iRop) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_StretchDIBits($hDestDC, $iXDest, $iYDest, $iWidthDest, $iHeightDest, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $tBITMAPINFO, $iUsage, $pBits, $iRop) Local $aRet = DllCall('gdi32.dll', 'int', 'StretchDIBits', 'handle', $hDestDC, 'int', $iXDest, 'int', $iYDest, 'int', $iWidthDest, 'int', $iHeightDest, 'int', $iXSrc, 'int', $iYSrc, 'int', $iWidthSrc, 'int', $iHeightSrc, 'struct*', $pBits, 'struct*', $tBITMAPINFO, 'uint', $iUsage, 'dword', $iRop) If @error Or ($aRet[0] = -1) Then Return SetError(@error + 10, $aRet[0], 0) Return $aRet[0] EndFunc Func _WinAPI_StrokeAndFillPath($hDC) Local $aRet = DllCall('gdi32.dll', 'bool', 'StrokeAndFillPath', 'handle', $hDC) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_StrokePath($hDC) Local $aRet = DllCall('gdi32.dll', 'bool', 'StrokePath', 'handle', $hDC) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_SubtractRect(ByRef $tRECT1, ByRef $tRECT2) Local $tRECT = DllStructCreate($tagRECT) Local $aRet = DllCall('user32.dll', 'bool', 'SubtractRect', 'struct*', $tRECT, 'struct*', $tRECT1, 'struct*', $tRECT2) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return $tRECT EndFunc Func _WinAPI_TabbedTextOut($hDC, $iX, $iY, $sText, $aTab = 0, $iStart = 0, $iEnd = -1, $iOrigin = 0) Local $iTab, $iCount If Not IsArray($aTab) Then If $aTab Then $iTab = $aTab Dim $aTab[1] = [$iTab] $iStart = 0 $iEnd = 0 $iCount = 1 Else $iCount = 0 EndIf Else $iCount = 1 EndIf Local $tTab = 0 If $iCount Then If __CheckErrorArrayBounds($aTab, $iStart, $iEnd) Then Return SetError(@error + 10, @extended, 0) $iCount = $iEnd - $iStart + 1 $tTab = DllStructCreate('uint[' & $iCount & ']') $iTab = 1 For $i = $iStart To $iEnd DllStructSetData($tTab, 1, $aTab[$i], $iTab) $iTab += 1 Next EndIf Local $aRet = DllCall('user32.dll', 'long', 'TabbedTextOutW', 'handle', $hDC, 'int', $iX, 'int', $iY, 'wstr', $sText, 'int', StringLen($sText), 'int', $iCount, 'struct*', $tTab, 'int', $iOrigin) If @error Or Not $aRet[0] Then Return SetError(@error, @extended, 0) $__g_vExt = _WinAPI_CreateSize(_WinAPI_LoWord($aRet[0]), _WinAPI_HiWord($aRet[0])) Return 1 EndFunc Func _WinAPI_TextOut($hDC, $iX, $iY, $sText) Local $aRet = DllCall('gdi32.dll', 'bool', 'TextOutW', 'handle', $hDC, 'int', $iX, 'int', $iY, 'wstr', $sText, 'int', StringLen($sText)) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_TransparentBlt($hDestDC, $iXDest, $iYDest, $iWidthDest, $iHeightDest, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iRGB) Local $aRet = DllCall('gdi32.dll', 'bool', 'GdiTransparentBlt', 'handle', $hDestDC, 'int', $iXDest, 'int', $iYDest, 'int', $iWidthDest, 'int', $iHeightDest, 'hwnd', $hSrcDC, 'int', $iXSrc, 'int', $iYSrc, 'int', $iWidthSrc, 'int', $iHeightSrc, 'dword', __RGB($iRGB)) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func _WinAPI_UnionRect(ByRef $tRECT1, ByRef $tRECT2) Local $tRECT = DllStructCreate($tagRECT) Local $aRet = DllCall('user32.dll', 'bool', 'UnionRect', 'struct*', $tRECT, 'struct*', $tRECT1, 'struct*', $tRECT2) If @error Or Not $aRet[0] Then Return SetError(@error + 10, 0, 0) Return $tRECT EndFunc Func _WinAPI_ValidateRect($hWnd, $tRECT = 0) Local $aRet = DllCall('user32.dll', 'bool', 'ValidateRect', 'hwnd', $hWnd, 'struct*', $tRECT) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_ValidateRgn($hWnd, $hRgn = 0) Local $aRet = DllCall('user32.dll', 'bool', 'ValidateRgn', 'hwnd', $hWnd, 'handle', $hRgn) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_WidenPath($hDC) Local $aRet = DllCall('gdi32.dll', 'bool', 'WidenPath', 'handle', $hDC) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func _WinAPI_WindowFromDC($hDC) Local $aRet = DllCall('user32.dll', 'hwnd', 'WindowFromDC', 'handle', $hDC) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc #EndRegion Public Functions #Region Internal Functions Func __EnumDisplayMonitorsProc($hMonitor, $hDC, $pRECT, $lParam) #forceref $hDC, $lParam __Inc($__g_vEnum) $__g_vEnum[$__g_vEnum[0][0]][0] = $hMonitor If Not $pRECT Then $__g_vEnum[$__g_vEnum[0][0]][1] = 0 Else $__g_vEnum[$__g_vEnum[0][0]][1] = DllStructCreate($tagRECT) If Not _WinAPI_MoveMemory(DllStructGetPtr($__g_vEnum[$__g_vEnum[0][0]][1]), $pRECT, 16) Then Return 0 EndIf Return 1 EndFunc Func __EnumFontFamiliesProc($pELFEX, $pNTMEX, $iFontType, $pPattern) Local $tELFEX = DllStructCreate($tagLOGFONT & ';wchar FullName[64];wchar Style[32];wchar Script[32]', $pELFEX) Local $tNTMEX = DllStructCreate($tagNEWTEXTMETRICEX, $pNTMEX) Local $tPattern = DllStructCreate('uint;uint;ptr', $pPattern) If $iFontType And Not BitAND($iFontType, DllStructGetData($tPattern, 1)) Then Return 1 EndIf If DllStructGetData($tPattern, 3) Then Local $aRet = DllCall('shlwapi.dll', 'bool', 'PathMatchSpecW', 'ptr', DllStructGetPtr($tELFEX, 14), 'ptr', DllStructGetData($tPattern, 3)) If Not @error Then If DllStructGetData($tPattern, 2) Then If $aRet[0] Then Return 1 Else EndIf Else If $aRet[0] Then Else Return 1 EndIf EndIf EndIf EndIf __Inc($__g_vEnum) $__g_vEnum[$__g_vEnum[0][0]][0] = DllStructGetData($tELFEX, 14) $__g_vEnum[$__g_vEnum[0][0]][1] = DllStructGetData($tELFEX, 16) $__g_vEnum[$__g_vEnum[0][0]][2] = DllStructGetData($tELFEX, 15) $__g_vEnum[$__g_vEnum[0][0]][3] = DllStructGetData($tELFEX, 17) $__g_vEnum[$__g_vEnum[0][0]][4] = $iFontType $__g_vEnum[$__g_vEnum[0][0]][5] = DllStructGetData($tNTMEX, 19) $__g_vEnum[$__g_vEnum[0][0]][6] = DllStructGetData($tNTMEX, 20) $__g_vEnum[$__g_vEnum[0][0]][7] = DllStructGetData($tNTMEX, 21) Return 1 EndFunc Func __EnumFontStylesProc($pELFEX, $pNTMEX, $iFontType, $pFN) #forceref $iFontType Local $tELFEX = DllStructCreate($tagLOGFONT & ';wchar FullName[64];wchar Style[32];wchar Script[32]', $pELFEX) Local $tNTMEX = DllStructCreate($tagNEWTEXTMETRICEX, $pNTMEX) Local $tFN = DllStructCreate('dword;wchar[64]', $pFN) If BitAND(DllStructGetData($tNTMEX, 'ntmFlags'), 0x0061) = DllStructGetData($tFN, 1) Then DllStructSetData($tFN, 2, DllStructGetData($tELFEX, 'FullName')) Return 0 Else Return 1 EndIf EndFunc #EndRegion Internal Functions Global $__g_hGDIPBrush = 0 Global $__g_hGDIPDll = 0 Global $__g_hGDIPPen = 0 Global $__g_iGDIPRef = 0 Global $__g_iGDIPToken = 0 Global $__g_bGDIP_V1_0 = True Func _GDIPlus_ArrowCapCreate($fHeight, $fWidth, $bFilled = True) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateAdjustableArrowCap", "float", $fHeight, "float", $fWidth, "bool", $bFilled, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[4] EndFunc Func _GDIPlus_ArrowCapDispose($hCap) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDeleteCustomLineCap", "handle", $hCap) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_ArrowCapGetFillState($hArrowCap) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetAdjustableArrowCapFillState", "handle", $hArrowCap, "bool*", 0) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_ArrowCapGetHeight($hArrowCap) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetAdjustableArrowCapHeight", "handle", $hArrowCap, "float*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_ArrowCapGetMiddleInset($hArrowCap) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetAdjustableArrowCapMiddleInset", "handle", $hArrowCap, "float*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_ArrowCapGetWidth($hArrowCap) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetAdjustableArrowCapWidth", "handle", $hArrowCap, "float*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_ArrowCapSetFillState($hArrowCap, $bFilled = True) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetAdjustableArrowCapFillState", "handle", $hArrowCap, "bool", $bFilled) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_ArrowCapSetHeight($hArrowCap, $fHeight) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetAdjustableArrowCapHeight", "handle", $hArrowCap, "float", $fHeight) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_ArrowCapSetMiddleInset($hArrowCap, $fInset) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetAdjustableArrowCapMiddleInset", "handle", $hArrowCap, "float", $fInset) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_ArrowCapSetWidth($hArrowCap, $fWidth) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetAdjustableArrowCapWidth", "handle", $hArrowCap, "float", $fWidth) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_BitmapCloneArea($hBitmap, $nLeft, $nTop, $nWidth, $nHeight, $iFormat = 0x00021808) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCloneBitmapArea", "float", $nLeft, "float", $nTop, "float", $nWidth, "float", $nHeight, "int", $iFormat, "handle", $hBitmap, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[7] EndFunc Func _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap) Local $aRet = DllCall($__g_hGDIPDll, "uint", "GdipGetImageDimension", "handle", $hBitmap, "float*", 0, "float*", 0) If @error Or $aRet[0] Then Return SetError(@error + 10, $aRet[0], 0) Local $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $aRet[2], $aRet[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local $pBits = DllStructGetData($tData, "Scan0") If Not $pBits Then Return 0 Local $tBIHDR = DllStructCreate($tagBITMAPV5HEADER) DllStructSetData($tBIHDR, "bV5Size", DllStructGetSize($tBIHDR)) DllStructSetData($tBIHDR, "bV5Width", $aRet[2]) DllStructSetData($tBIHDR, "bV5Height", $aRet[3]) DllStructSetData($tBIHDR, "bV5Planes", 1) DllStructSetData($tBIHDR, "bV5BitCount", 32) DllStructSetData($tBIHDR, "bV5Compression", 0) DllStructSetData($tBIHDR, "bV5SizeImage", $aRet[3] * DllStructGetData($tData, "Stride")) DllStructSetData($tBIHDR, "bV5AlphaMask", 0xFF000000) DllStructSetData($tBIHDR, "bV5RedMask", 0x00FF0000) DllStructSetData($tBIHDR, "bV5GreenMask", 0x0000FF00) DllStructSetData($tBIHDR, "bV5BlueMask", 0x000000FF) DllStructSetData($tBIHDR, "bV5CSType", 2) DllStructSetData($tBIHDR, "bV5Intent", 4) Local $hHBitmapv5 = DllCall("gdi32.dll", "ptr", "CreateDIBSection", "hwnd", 0, "struct*", $tBIHDR, "uint", 0, "ptr*", 0, "ptr", 0, "dword", 0) If Not @error And $hHBitmapv5[0] Then DllCall("gdi32.dll", "dword", "SetBitmapBits", "ptr", $hHBitmapv5[0], "dword", $aRet[2] * $aRet[3] * 4, "ptr", DllStructGetData($tData, "Scan0")) $hHBitmapv5 = $hHBitmapv5[0] Else $hHBitmapv5 = 0 EndIf _GDIPlus_BitmapUnlockBits($hBitmap, $tData) $tData = 0 $tBIHDR = 0 Return $hHBitmapv5 EndFunc Func _GDIPlus_BitmapCreateFromFile($sFileName) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateBitmapFromFile", "wstr", $sFileName, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateBitmapFromGraphics", "int", $iWidth, "int", $iHeight, "handle", $hGraphics, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[4] EndFunc Func _GDIPlus_BitmapCreateFromHBITMAP($hBitmap, $hPal = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateBitmapFromHBITMAP", "handle", $hBitmap, "handle", $hPal, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[3] EndFunc Func _GDIPlus_BitmapCreateFromMemory($dImage, $bHBITMAP = False) If Not IsBinary($dImage) Then Return SetError(1, 0, 0) Local $aResult = 0 Local Const $dMemBitmap = Binary($dImage) Local Const $iLen = BinaryLen($dMemBitmap) Local Const $GMEM_MOVEABLE = 0x0002 $aResult = DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", $GMEM_MOVEABLE, "ulong_ptr", $iLen) If @error Then Return SetError(4, 0, 0) Local Const $hData = $aResult[0] $aResult = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", $hData) If @error Then Return SetError(5, 0, 0) Local $tMem = DllStructCreate("byte[" & $iLen & "]", $aResult[0]) DllStructSetData($tMem, 1, $dMemBitmap) DllCall("kernel32.dll", "bool", "GlobalUnlock", "handle", $hData) If @error Then Return SetError(6, 0, 0) Local Const $hStream = _WinAPI_CreateStreamOnHGlobal($hData) If @error Then Return SetError(2, 0, 0) Local Const $hBitmap = _GDIPlus_BitmapCreateFromStream($hStream) If @error Then Return SetError(3, 0, 0) DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "ulong_ptr", 8 * (1 + @AutoItX64), "uint", 4, "ushort", 23, "uint", 0, "ptr", 0, "ptr", 0, "str", "") If $bHBITMAP Then Local Const $hHBmp = _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hHBmp EndIf Return $hBitmap EndFunc Func _GDIPlus_BitmapCreateFromResource($hInst, $vResourceName) Local $sType = "int" If IsString($vResourceName) Then $sType = "wstr" Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateBitmapFromResource", "handle", $hInst, $sType, $vResourceName, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[3] EndFunc Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iPixelFormat = $GDIP_PXF32ARGB, $iStride = 0, $pScan0 = 0) Local $aResult = DllCall($__g_hGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "struct*", $pScan0, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[6] EndFunc Func _GDIPlus_BitmapCreateFromStream($pStream) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateBitmapFromStream", "ptr", $pStream, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap, $iARGB = 0xFF000000) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateHBITMAPFromBitmap", "handle", $hBitmap, "handle*", 0, "dword", $iARGB) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_BitmapDispose($hBitmap) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDisposeImage", "handle", $hBitmap) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_BitmapCreateFromHICON($hIcon) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateBitmapFromHICON", "handle", $hIcon, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_BitmapCreateFromHICON32($hIcon) Local $tSIZE = _WinAPI_GetIconDimension($hIcon) Local $iWidth = DllStructGetData($tSIZE, 'X') Local $iHeight = DllStructGetData($tSIZE, 'Y') If $iWidth <= 0 Or $iHeight <= 0 Then Return SetError(10, -1, 0) Local $tBITMAPINFO = DllStructCreate("dword Size;long Width;long Height;word Planes;word BitCount;dword Compression;dword SizeImage;long XPelsPerMeter;long YPelsPerMeter;dword ClrUsed;dword ClrImportant;dword RGBQuad") DllStructSetData($tBITMAPINFO, 'Size', DllStructGetSize($tBITMAPINFO) - 4) DllStructSetData($tBITMAPINFO, 'Width', $iWidth) DllStructSetData($tBITMAPINFO, 'Height', -$iHeight) DllStructSetData($tBITMAPINFO, 'Planes', 1) DllStructSetData($tBITMAPINFO, 'BitCount', 32) DllStructSetData($tBITMAPINFO, 'Compression', 0) DllStructSetData($tBITMAPINFO, 'SizeImage', 0) Local $hDC = _WinAPI_CreateCompatibleDC(0) Local $pBits Local $hBmp = _WinAPI_CreateDIBSection(0, $tBITMAPINFO, 0, $pBits) Local $hOrig = _WinAPI_SelectObject($hDC, $hBmp) _WinAPI_DrawIconEx($hDC, 0, 0, $hIcon, $iWidth, $iHeight) Local $hBitmapIcon = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $GDIP_PXF32ARGB, $iWidth * 4, $pBits) Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsDrawImage($hContext, $hBitmapIcon, 0, 0) _GDIPlus_GraphicsDispose($hContext) _GDIPlus_BitmapDispose($hBitmapIcon) _WinAPI_SelectObject($hDC, $hOrig) _WinAPI_DeleteDC($hDC) _WinAPI_DeleteObject($hBmp) Return $hBitmap EndFunc Func _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipBitmapGetPixel", "handle", $hBitmap, "int", $iX, "int", $iY, "uint*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[4] EndFunc Func _GDIPlus_BitmapLockBits($hBitmap, $iLeft, $iTop, $iWidth, $iHeight, $iFlags = $GDIP_ILMREAD, $iFormat = $GDIP_PXF32RGB) Local $tData = DllStructCreate($tagGDIPBITMAPDATA) Local $tRECT = DllStructCreate($tagRECT) DllStructSetData($tRECT, "Left", $iLeft) DllStructSetData($tRECT, "Top", $iTop) DllStructSetData($tRECT, "Right", $iWidth) DllStructSetData($tRECT, "Bottom", $iHeight) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipBitmapLockBits", "handle", $hBitmap, "struct*", $tRECT, "uint", $iFlags, "int", $iFormat, "struct*", $tData) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $tData EndFunc Func _GDIPlus_BitmapSetPixel($hBitmap, $iX, $iY, $iARGB) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipBitmapSetPixel", "handle", $hBitmap, "int", $iX, "int", $iY, "uint", $iARGB) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_BitmapSetResolution($hBitmap, $fDpiX, $fDpiY) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipBitmapSetResolution", "handle", $hBitmap, "float", $fDpiX, "float", $fDpiY) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_BitmapUnlockBits($hBitmap, $tBitmapData) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipBitmapUnlockBits", "handle", $hBitmap, "struct*", $tBitmapData) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_BrushClone($hBrush) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCloneBrush", "handle", $hBrush, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_BrushCreateSolid($iARGB = 0xFF000000) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateSolidFill", "int", $iARGB, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_BrushDispose($hBrush) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDeleteBrush", "handle", $hBrush) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_BrushGetSolidColor($hBrush) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetSolidFillColor", "handle", $hBrush, "dword*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_BrushGetType($hBrush) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetBrushType", "handle", $hBrush, "int*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_BrushSetSolidColor($hBrush, $iARGB = 0xFF000000) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetSolidFillColor", "handle", $hBrush, "dword", $iARGB) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_ColorMatrixCreate() Return _GDIPlus_ColorMatrixCreateScale(1, 1, 1, 1) EndFunc Func _GDIPlus_ColorMatrixCreateGrayScale() Local $iI, $iJ, $tCM, $aLums[4] = [$GDIP_RLUM, $GDIP_GLUM, $GDIP_BLUM, 0] $tCM = DllStructCreate($tagGDIPCOLORMATRIX) For $iI = 0 To 3 For $iJ = 1 To 3 DllStructSetData($tCM, "m", $aLums[$iI], $iI * 5 + $iJ) Next Next DllStructSetData($tCM, "m", 1, 19) DllStructSetData($tCM, "m", 1, 25) Return $tCM EndFunc Func _GDIPlus_ColorMatrixCreateNegative() Local $iI, $tCM $tCM = _GDIPlus_ColorMatrixCreateScale(-1, -1, -1, 1) For $iI = 1 To 4 DllStructSetData($tCM, "m", 1, 20 + $iI) Next Return $tCM EndFunc Func _GDIPlus_ColorMatrixCreateSaturation($fSat) Local $fSatComp, $tCM $tCM = DllStructCreate($tagGDIPCOLORMATRIX) $fSatComp = (1 - $fSat) DllStructSetData($tCM, "m", $fSatComp * $GDIP_RLUM + $fSat, 1) DllStructSetData($tCM, "m", $fSatComp * $GDIP_RLUM, 2) DllStructSetData($tCM, "m", $fSatComp * $GDIP_RLUM, 3) DllStructSetData($tCM, "m", $fSatComp * $GDIP_GLUM, 6) DllStructSetData($tCM, "m", $fSatComp * $GDIP_GLUM + $fSat, 7) DllStructSetData($tCM, "m", $fSatComp * $GDIP_GLUM, 8) DllStructSetData($tCM, "m", $fSatComp * $GDIP_BLUM, 11) DllStructSetData($tCM, "m", $fSatComp * $GDIP_BLUM, 12) DllStructSetData($tCM, "m", $fSatComp * $GDIP_BLUM + $fSat, 13) DllStructSetData($tCM, "m", 1, 19) DllStructSetData($tCM, "m", 1, 25) Return $tCM EndFunc Func _GDIPlus_ColorMatrixCreateScale($fRed, $fGreen, $fBlue, $fAlpha = 1) Local $tCM $tCM = DllStructCreate($tagGDIPCOLORMATRIX) DllStructSetData($tCM, "m", $fRed, 1) DllStructSetData($tCM, "m", $fGreen, 7) DllStructSetData($tCM, "m", $fBlue, 13) DllStructSetData($tCM, "m", $fAlpha, 19) DllStructSetData($tCM, "m", 1, 25) Return $tCM EndFunc Func _GDIPlus_ColorMatrixCreateTranslate($fRed, $fGreen, $fBlue, $fAlpha = 0) Local $iI, $tCM, $aFactors[4] = [$fRed, $fGreen, $fBlue, $fAlpha] $tCM = _GDIPlus_ColorMatrixCreate() For $iI = 0 To 3 DllStructSetData($tCM, "m", $aFactors[$iI], 21 + $iI) Next Return $tCM EndFunc Func _GDIPlus_CustomLineCapClone($hCustomLineCap) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCloneCustomLineCap", "handle", $hCustomLineCap, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_CustomLineCapCreate($hPathFill, $hPathStroke, $iLineCap = 0, $nBaseInset = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateCustomLineCap", "handle", $hPathFill, "handle", $hPathStroke, "int", $iLineCap, "float", $nBaseInset, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[5] EndFunc Func _GDIPlus_CustomLineCapDispose($hCap) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDeleteCustomLineCap", "handle", $hCap) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_CustomLineCapGetStrokeCaps($hCustomLineCap) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetCustomLineCapStrokeCaps", "hwnd", $hCustomLineCap, "ptr*", 0, "ptr*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then SetError(10, $aResult[0], 0) Local $aCaps[2] $aCaps[0] = $aResult[2] $aCaps[1] = $aResult[3] Return $aCaps EndFunc Func _GDIPlus_CustomLineCapSetStrokeCaps($hCustomLineCap, $iStartCap, $iEndCap) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetCustomLineCapStrokeCaps", "handle", $hCustomLineCap, "int", $iStartCap, "int", $iEndCap) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_Decoders() Local $iCount = _GDIPlus_DecodersGetCount() Local $iSize = _GDIPlus_DecodersGetSize() Local $tBuffer = DllStructCreate("byte[" & $iSize & "]") Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImageDecoders", "uint", $iCount, "uint", $iSize, "struct*", $tBuffer) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Local $pBuffer = DllStructGetPtr($tBuffer) Local $tCodec, $aInfo[$iCount + 1][14] $aInfo[0][0] = $iCount For $iI = 1 To $iCount $tCodec = DllStructCreate($tagGDIPIMAGECODECINFO, $pBuffer) $aInfo[$iI][1] = _WinAPI_StringFromGUID(DllStructGetPtr($tCodec, "CLSID")) $aInfo[$iI][2] = _WinAPI_StringFromGUID(DllStructGetPtr($tCodec, "FormatID")) $aInfo[$iI][3] = _WinAPI_WideCharToMultiByte(DllStructGetData($tCodec, "CodecName")) $aInfo[$iI][4] = _WinAPI_WideCharToMultiByte(DllStructGetData($tCodec, "DllName")) $aInfo[$iI][5] = _WinAPI_WideCharToMultiByte(DllStructGetData($tCodec, "FormatDesc")) $aInfo[$iI][6] = _WinAPI_WideCharToMultiByte(DllStructGetData($tCodec, "FileExt")) $aInfo[$iI][7] = _WinAPI_WideCharToMultiByte(DllStructGetData($tCodec, "MimeType")) $aInfo[$iI][8] = DllStructGetData($tCodec, "Flags") $aInfo[$iI][9] = DllStructGetData($tCodec, "Version") $aInfo[$iI][10] = DllStructGetData($tCodec, "SigCount") $aInfo[$iI][11] = DllStructGetData($tCodec, "SigSize") $aInfo[$iI][12] = DllStructGetData($tCodec, "SigPattern") $aInfo[$iI][13] = DllStructGetData($tCodec, "SigMask") $pBuffer += DllStructGetSize($tCodec) Next Return $aInfo EndFunc Func _GDIPlus_DecodersGetCount() Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImageDecodersSize", "uint*", 0, "uint*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[1] EndFunc Func _GDIPlus_DecodersGetSize() Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImageDecodersSize", "uint*", 0, "uint*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_DrawImagePoints($hGraphic, $hImage, $nULX, $nULY, $nURX, $nURY, $nLLX, $nLLY, $iCount = 3) Local $tPoint = DllStructCreate("float X;float Y;float X2;float Y2;float X3;float Y3") DllStructSetData($tPoint, "X", $nULX) DllStructSetData($tPoint, "Y", $nULY) DllStructSetData($tPoint, "X2", $nURX) DllStructSetData($tPoint, "Y2", $nURY) DllStructSetData($tPoint, "X3", $nLLX) DllStructSetData($tPoint, "Y3", $nLLY) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawImagePoints", "handle", $hGraphic, "handle", $hImage, "struct*", $tPoint, "int", $iCount) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_Encoders() Local $iCount = _GDIPlus_EncodersGetCount() Local $iSize = _GDIPlus_EncodersGetSize() Local $tBuffer = DllStructCreate("byte[" & $iSize & "]") Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImageEncoders", "uint", $iCount, "uint", $iSize, "struct*", $tBuffer) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Local $pBuffer = DllStructGetPtr($tBuffer) Local $tCodec, $aInfo[$iCount + 1][14] $aInfo[0][0] = $iCount For $iI = 1 To $iCount $tCodec = DllStructCreate($tagGDIPIMAGECODECINFO, $pBuffer) $aInfo[$iI][1] = _WinAPI_StringFromGUID(DllStructGetPtr($tCodec, "CLSID")) $aInfo[$iI][2] = _WinAPI_StringFromGUID(DllStructGetPtr($tCodec, "FormatID")) $aInfo[$iI][3] = _WinAPI_WideCharToMultiByte(DllStructGetData($tCodec, "CodecName")) $aInfo[$iI][4] = _WinAPI_WideCharToMultiByte(DllStructGetData($tCodec, "DllName")) $aInfo[$iI][5] = _WinAPI_WideCharToMultiByte(DllStructGetData($tCodec, "FormatDesc")) $aInfo[$iI][6] = _WinAPI_WideCharToMultiByte(DllStructGetData($tCodec, "FileExt")) $aInfo[$iI][7] = _WinAPI_WideCharToMultiByte(DllStructGetData($tCodec, "MimeType")) $aInfo[$iI][8] = DllStructGetData($tCodec, "Flags") $aInfo[$iI][9] = DllStructGetData($tCodec, "Version") $aInfo[$iI][10] = DllStructGetData($tCodec, "SigCount") $aInfo[$iI][11] = DllStructGetData($tCodec, "SigSize") $aInfo[$iI][12] = DllStructGetData($tCodec, "SigPattern") $aInfo[$iI][13] = DllStructGetData($tCodec, "SigMask") $pBuffer += DllStructGetSize($tCodec) Next Return $aInfo EndFunc Func _GDIPlus_EncodersGetCLSID($sFileExtension) Local $aEncoders = _GDIPlus_Encoders() If @error Then Return SetError(@error, 0, "") For $iI = 1 To $aEncoders[0][0] If StringInStr($aEncoders[$iI][6], "*." & $sFileExtension) > 0 Then Return $aEncoders[$iI][1] Next Return SetError(-1, -1, "") EndFunc Func _GDIPlus_EncodersGetCount() Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImageEncodersSize", "uint*", 0, "uint*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[1] EndFunc Func _GDIPlus_EncodersGetParamList($hImage, $sEncoder) Local $iSize = _GDIPlus_EncodersGetParamListSize($hImage, $sEncoder) If @error Then Return SetError(@error + 10, @extended, 0) Local $tGUID = _WinAPI_GUIDFromString($sEncoder) Local $iRemainingSize = $iSize - 4 - _GDIPlus_ParamSize() Local $tBuffer If $iRemainingSize Then $tBuffer = DllStructCreate("dword Count;" & $tagGDIPENCODERPARAM & ";byte [" & $iRemainingSize & "]") Else $tBuffer = DllStructCreate("dword Count;" & $tagGDIPENCODERPARAM) EndIf Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetEncoderParameterList", "handle", $hImage, "struct*", $tGUID, "uint", $iSize, "struct*", $tBuffer) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $tBuffer EndFunc Func _GDIPlus_EncodersGetParamListSize($hImage, $sEncoder) Local $tGUID = _WinAPI_GUIDFromString($sEncoder) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetEncoderParameterListSize", "handle", $hImage, "struct*", $tGUID, "uint*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[3] EndFunc Func _GDIPlus_EncodersGetSize() Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImageEncodersSize", "uint*", 0, "uint*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_FontCreate($hFamily, $fSize, $iStyle = 0, $iUnit = 3) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateFont", "handle", $hFamily, "float", $fSize, "int", $iStyle, "int", $iUnit, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[5] EndFunc Func _GDIPlus_FontDispose($hFont) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDeleteFont", "handle", $hFont) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_FontFamilyCreate($sFamily, $pCollection = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateFontFamilyFromName", "wstr", $sFamily, "ptr", $pCollection, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[3] EndFunc Func _GDIPlus_FontFamilyCreateFromCollection($sFontName, $hFontCollection) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateFontFamilyFromName", "wstr", $sFontName, "ptr", $hFontCollection, "ptr*", 0) If @error Then Return SetError(@error, @extended, "") If $aResult[0] Then Return SetError(10, $aResult[0], "") Return $aResult[3] EndFunc Func _GDIPlus_FontFamilyDispose($hFamily) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDeleteFontFamily", "handle", $hFamily) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_FontFamilyGetCellAscent($hFontFamily, $iStyle = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetCellAscent", "handle", $hFontFamily, "int", $iStyle, "ushort*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[3] EndFunc Func _GDIPlus_FontFamilyGetCellDescent($hFontFamily, $iStyle = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetCellDescent", "handle", $hFontFamily, "int", $iStyle, "ushort*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[3] EndFunc Func _GDIPlus_FontFamilyGetEmHeight($hFontFamily, $iStyle = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetEmHeight", "handle", $hFontFamily, "int", $iStyle, "ushort*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[3] EndFunc Func _GDIPlus_FontFamilyGetLineSpacing($hFontFamily, $iStyle = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetLineSpacing", "handle", $hFontFamily, "int", $iStyle, "ushort*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[3] EndFunc Func _GDIPlus_FontGetHeight($hFont, $hGraphics) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetFontHeight", "handle", $hFont, "handle", $hGraphics, "float*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[3] EndFunc Func _GDIPlus_FontPrivateAddFont($hFontCollection, $sFontFile) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipPrivateAddFontFile", "ptr", $hFontCollection, "wstr", $sFontFile) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_FontPrivateAddMemoryFont($hFontCollection, $tFont) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipPrivateAddMemoryFont", "handle", $hFontCollection, "struct*", $tFont, "int", DllStructGetSize($tFont)) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_FontPrivateCollectionDispose($hFontCollection) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDeletePrivateFontCollection", "handle*", $hFontCollection) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_FontPrivateCreateCollection() Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipNewPrivateFontCollection", "ptr*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[1] EndFunc Func _GDIPlus_GraphicsClear($hGraphics, $iARGB = 0xFF000000) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGraphicsClear", "handle", $hGraphics, "dword", $iARGB) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsCreateFromHDC($hDC) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateFromHDC", "handle", $hDC, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_GraphicsCreateFromHWND($hWnd) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateFromHWND", "hwnd", $hWnd, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_GraphicsDispose($hGraphics) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDeleteGraphics", "handle", $hGraphics) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsDrawArc($hGraphics, $nX, $nY, $nWidth, $nHeight, $fStartAngle, $fSweepAngle, $hPen = 0) __GDIPlus_PenDefCreate($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawArc", "handle", $hGraphics, "handle", $hPen, "float", $nX, "float", $nY, "float", $nWidth, "float", $nHeight, "float", $fStartAngle, "float", $fSweepAngle) __GDIPlus_PenDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsDrawBezier($hGraphics, $nX1, $nY1, $nX2, $nY2, $nX3, $nY3, $nX4, $nY4, $hPen = 0) __GDIPlus_PenDefCreate($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawBezier", "handle", $hGraphics, "handle", $hPen, "float", $nX1, "float", $nY1, "float", $nX2, "float", $nY2, "float", $nX3, "float", $nY3, "float", $nX4, "float", $nY4) __GDIPlus_PenDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsDrawClosedCurve($hGraphics, $aPoints, $hPen = 0) Local $iCount = $aPoints[0][0] Local $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2) Next __GDIPlus_PenDefCreate($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawClosedCurve", "handle", $hGraphics, "handle", $hPen, "struct*", $tPoints, "int", $iCount) __GDIPlus_PenDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsDrawClosedCurve2($hGraphics, $aPoints, $nTension, $hPen = 0) Local $iI, $iCount, $tPoints, $aResult __GDIPlus_PenDefCreate($hPen) $iCount = $aPoints[0][0] $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2) Next $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawClosedCurve2", "handle", $hGraphics, "handle", $hPen, "struct*", $tPoints, "int", $iCount, "float", $nTension) __GDIPlus_PenDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsDrawCurve($hGraphics, $aPoints, $hPen = 0) Local $iCount = $aPoints[0][0] Local $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2) Next __GDIPlus_PenDefCreate($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawCurve", "handle", $hGraphics, "handle", $hPen, "struct*", $tPoints, "int", $iCount) __GDIPlus_PenDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsDrawCurve2($hGraphics, $aPoints, $nTension, $hPen = 0) Local $iI, $iCount, $tPoints, $aResult __GDIPlus_PenDefCreate($hPen) $iCount = $aPoints[0][0] $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2) Next $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawCurve2", "handle", $hGraphics, "handle", $hPen, "struct*", $tPoints, "int", $iCount, "float", $nTension) __GDIPlus_PenDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsDrawEllipse($hGraphics, $nX, $nY, $nWidth, $nHeight, $hPen = 0) __GDIPlus_PenDefCreate($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawEllipse", "handle", $hGraphics, "handle", $hPen, "float", $nX, "float", $nY, "float", $nWidth, "float", $nHeight) __GDIPlus_PenDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsDrawImage($hGraphics, $hImage, $nX, $nY) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawImage", "handle", $hGraphics, "handle", $hImage, "float", $nX, "float", $nY) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsDrawImagePointsRect($hGraphics, $hImage, $nULX, $nULY, $nURX, $nURY, $nLLX, $nLLY, $nSrcX, $nSrcY, $nSrcWidth, $nSrcHeight, $hImageAttributes = 0, $iUnit = 2) Local $tPoints = DllStructCreate("float X; float Y; float X2; float Y2; float X3; float Y3;") DllStructSetData($tPoints, "X", $nULX) DllStructSetData($tPoints, "Y", $nULY) DllStructSetData($tPoints, "X2", $nURX) DllStructSetData($tPoints, "Y2", $nURY) DllStructSetData($tPoints, "X3", $nLLX) DllStructSetData($tPoints, "Y3", $nLLY) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawImagePointsRect", "handle", $hGraphics, "handle", $hImage, "struct*", $tPoints, "int", 3, "float", $nSrcX, "float", $nSrcY, "float", $nSrcWidth, "float", $nSrcHeight, "int", $iUnit, "handle", $hImageAttributes, "ptr", 0, "ptr", 0) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, $nX, $nY, $nW, $nH) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawImageRect", "handle", $hGraphics, "handle", $hImage, "float", $nX, "float", $nY, "float", $nW, "float", $nH) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hImage, $nSrcX, $nSrcY, $nSrcWidth, $nSrcHeight, $nDstX, $nDstY, $nDstWidth, $nDstHeight, $pAttributes = 0, $iUnit = 2) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawImageRectRect", "handle", $hGraphics, "handle", $hImage, "float", $nDstX, "float", $nDstY, "float", $nDstWidth, "float", $nDstHeight, "float", $nSrcX, "float", $nSrcY, "float", $nSrcWidth, "float", $nSrcHeight, "int", $iUnit, "handle", $pAttributes, "ptr", 0, "ptr", 0) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsDrawLine($hGraphics, $nX1, $nY1, $nX2, $nY2, $hPen = 0) __GDIPlus_PenDefCreate($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawLine", "handle", $hGraphics, "handle", $hPen, "float", $nX1, "float", $nY1, "float", $nX2, "float", $nY2) __GDIPlus_PenDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsDrawPath($hGraphics, $hPath, $hPen = 0) __GDIPlus_PenDefCreate($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawPath", "handle", $hGraphics, "handle", $hPen, "handle", $hPath) __GDIPlus_PenDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsDrawPie($hGraphics, $nX, $nY, $nWidth, $nHeight, $fStartAngle, $fSweepAngle, $hPen = 0) __GDIPlus_PenDefCreate($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawPie", "handle", $hGraphics, "handle", $hPen, "float", $nX, "float", $nY, "float", $nWidth, "float", $nHeight, "float", $fStartAngle, "float", $fSweepAngle) __GDIPlus_PenDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsDrawPolygon($hGraphics, $aPoints, $hPen = 0) Local $iCount = $aPoints[0][0] Local $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2) Next __GDIPlus_PenDefCreate($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawPolygon", "handle", $hGraphics, "handle", $hPen, "struct*", $tPoints, "int", $iCount) __GDIPlus_PenDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsDrawRect($hGraphics, $nX, $nY, $nWidth, $nHeight, $hPen = 0) __GDIPlus_PenDefCreate($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawRectangle", "handle", $hGraphics, "handle", $hPen, "float", $nX, "float", $nY, "float", $nWidth, "float", $nHeight) __GDIPlus_PenDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsDrawString($hGraphics, $sString, $nX, $nY, $sFont = "Arial", $fSize = 10, $iFormat = 0) Local $hBrush = _GDIPlus_BrushCreateSolid() Local $hFormat = _GDIPlus_StringFormatCreate($iFormat) Local $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $hFont = _GDIPlus_FontCreate($hFamily, $fSize) Local $tLayout = _GDIPlus_RectFCreate($nX, $nY, 0.0, 0.0) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat) If @error Then Return SetError(@error, @extended, 0) Local $aResult = _GDIPlus_GraphicsDrawStringEx($hGraphics, $sString, $hFont, $aInfo[0], $hFormat, $hBrush) Local $iError = @error, $iExtended = @extended _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) Return SetError($iError, $iExtended, $aResult) EndFunc Func _GDIPlus_GraphicsDrawStringEx($hGraphics, $sString, $hFont, $tLayout, $hFormat, $hBrush) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawString", "handle", $hGraphics, "wstr", $sString, "int", -1, "handle", $hFont, "struct*", $tLayout, "handle", $hFormat, "handle", $hBrush) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsFillClosedCurve($hGraphics, $aPoints, $hBrush = 0) Local $iCount = $aPoints[0][0] Local $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2) Next __GDIPlus_BrushDefCreate($hBrush) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipFillClosedCurve", "handle", $hGraphics, "handle", $hBrush, "struct*", $tPoints, "int", $iCount) __GDIPlus_BrushDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsFillClosedCurve2($hGraphics, $aPoints, $nTension, $hBrush = 0, $iFillMode = 0) Local $iI, $iCount, $tPoints, $aResult __GDIPlus_BrushDefCreate($hBrush) $iCount = $aPoints[0][0] $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2) Next $aResult = DllCall($__g_hGDIPDll, "int", "GdipFillClosedCurve2", "handle", $hGraphics, "handle", $hBrush, "struct*", $tPoints, "int", $iCount, "float", $nTension, "int", $iFillMode) __GDIPlus_BrushDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsFillEllipse($hGraphics, $nX, $nY, $nWidth, $nHeight, $hBrush = 0) __GDIPlus_BrushDefCreate($hBrush) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipFillEllipse", "handle", $hGraphics, "handle", $hBrush, "float", $nX, "float", $nY, "float", $nWidth, "float", $nHeight) __GDIPlus_BrushDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsFillPath($hGraphics, $hPath, $hBrush = 0) __GDIPlus_BrushDefCreate($hBrush) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipFillPath", "handle", $hGraphics, "handle", $hBrush, "handle", $hPath) __GDIPlus_BrushDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsFillPie($hGraphics, $nX, $nY, $nWidth, $nHeight, $fStartAngle, $fSweepAngle, $hBrush = 0) __GDIPlus_BrushDefCreate($hBrush) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipFillPie", "handle", $hGraphics, "handle", $hBrush, "float", $nX, "float", $nY, "float", $nWidth, "float", $nHeight, "float", $fStartAngle, "float", $fSweepAngle) __GDIPlus_BrushDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsFillPolygon($hGraphics, $aPoints, $hBrush = 0) Local $iCount = $aPoints[0][0] Local $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2) Next __GDIPlus_BrushDefCreate($hBrush) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipFillPolygon", "handle", $hGraphics, "handle", $hBrush, "struct*", $tPoints, "int", $iCount, "int", "FillModeAlternate") __GDIPlus_BrushDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsFillRect($hGraphics, $nX, $nY, $nWidth, $nHeight, $hBrush = 0) __GDIPlus_BrushDefCreate($hBrush) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hGraphics, "handle", $hBrush, "float", $nX, "float", $nY, "float", $nWidth, "float", $nHeight) __GDIPlus_BrushDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsFillRegion($hGraphics, $hRegion, $hBrush = 0) __GDIPlus_BrushDefCreate($hBrush) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipFillRegion", "handle", $hGraphics, "handle", $hBrush, "handle", $hRegion) __GDIPlus_BrushDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsGetCompositingMode($hGraphics) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetCompositingMode", "handle", $hGraphics, "int*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_GraphicsGetCompositingQuality($hGraphics) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetCompositingQuality", "handle", $hGraphics, "int*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_GraphicsGetDC($hGraphics) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDC", "handle", $hGraphics, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_GraphicsGetInterpolationMode($hGraphics) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetInterpolationMode", "handle", $hGraphics, "int*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_GraphicsGetSmoothingMode($hGraphics) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetSmoothingMode", "handle", $hGraphics, "int*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Switch $aResult[2] Case $GDIP_SMOOTHINGMODE_NONE Return 0 Case $GDIP_SMOOTHINGMODE_HIGHQUALITY, $GDIP_SMOOTHINGMODE_ANTIALIAS8X4 Return 1 Case $GDIP_SMOOTHINGMODE_ANTIALIAS8X8 Return 2 Case Else Return 0 EndSwitch EndFunc Func _GDIPlus_GraphicsGetTransform($hGraphics, $hMatrix) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetWorldTransform", "handle", $hGraphics, "handle", $hMatrix) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsMeasureCharacterRanges($hGraphics, $sString, $hFont, $tLayout, $hStringFormat) Local $iCount = _GDIPlus_StringFormatGetMeasurableCharacterRangeCount($hStringFormat) If @error Then Return SetError(@error, @extended, 0) Local $tRegions = DllStructCreate("handle[" & $iCount & "]") Local $aRegions[$iCount + 1] = [$iCount] For $iI = 1 To $iCount $aRegions[$iI] = _GDIPlus_RegionCreate() DllStructSetData($tRegions, 1, $aRegions[$iI], $iI) Next DllCall($__g_hGDIPDll, "int", "GdipMeasureCharacterRanges", "handle", $hGraphics, "wstr", $sString, "int", -1, "hwnd", $hFont, "struct*", $tLayout, "handle", $hStringFormat, "int", $iCount, "struct*", $tRegions) Local $iError = @error, $iExtended = @extended If $iError Then For $iI = 1 To $iCount _GDIPlus_RegionDispose($aRegions[$iI]) Next Return SetError($iError + 10, $iExtended, 0) EndIf Return $aRegions EndFunc Func _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat) Local $tRECTF = DllStructCreate($tagGDIPRECTF) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipMeasureString", "handle", $hGraphics, "wstr", $sString, "int", -1, "handle", $hFont, "struct*", $tLayout, "handle", $hFormat, "struct*", $tRECTF, "int*", 0, "int*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Local $aInfo[3] $aInfo[0] = $tRECTF $aInfo[1] = $aResult[8] $aInfo[2] = $aResult[9] Return $aInfo EndFunc Func _GDIPlus_GraphicsReleaseDC($hGraphics, $hDC) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipReleaseDC", "handle", $hGraphics, "handle", $hDC) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_GraphicsResetClip($hGraphics) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipResetClip", "handle", $hGraphics) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsResetTransform($hGraphics) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipResetWorldTransform", "handle", $hGraphics) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsRestore($hGraphics, $iState) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipRestoreGraphics", "handle", $hGraphics, "uint", $iState) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsRotateTransform($hGraphics, $fAngle, $iOrder = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipRotateWorldTransform", "handle", $hGraphics, "float", $fAngle, "int", $iOrder) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsSave($hGraphics) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSaveGraphics", "handle", $hGraphics, "uint*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_GraphicsScaleTransform($hGraphics, $fScaleX, $fScaleY, $iOrder = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipScaleWorldTransform", "handle", $hGraphics, "float", $fScaleX, "float", $fScaleY, "int", $iOrder) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsSetClipPath($hGraphics, $hPath, $iCombineMode = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetClipPath", "handle", $hGraphics, "handle", $hPath, "int", $iCombineMode) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsSetClipRect($hGraphics, $nX, $nY, $nWidth, $nHeight, $iCombineMode = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetClipRect", "handle", $hGraphics, "float", $nX, "float", $nY, "float", $nWidth, "float", $nHeight, "int", $iCombineMode) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsSetClipRegion($hGraphics, $hRegion, $iCombineMode = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetClipRegion", "handle", $hGraphics, "handle", $hRegion, "int", $iCombineMode) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsSetCompositingMode($hGraphics, $iCompositionMode) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetCompositingMode", "handle", $hGraphics, "int", $iCompositionMode) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsSetCompositingQuality($hGraphics, $iCompositionQuality) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetCompositingQuality", "handle", $hGraphics, "int", $iCompositionQuality) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsSetInterpolationMode($hGraphics, $iInterpolationMode) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetInterpolationMode", "handle", $hGraphics, "int", $iInterpolationMode) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsSetPixelOffsetMode($hGraphics, $iPixelOffsetMode) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPixelOffsetMode", "handle", $hGraphics, "int", $iPixelOffsetMode) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $iSmooth) If $iSmooth < $GDIP_SMOOTHINGMODE_DEFAULT Or $iSmooth > $GDIP_SMOOTHINGMODE_ANTIALIAS8X8 Then $iSmooth = $GDIP_SMOOTHINGMODE_DEFAULT Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetSmoothingMode", "handle", $hGraphics, "int", $iSmooth) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsSetTextRenderingHint($hGraphics, $iTextRenderingHint) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetTextRenderingHint", "handle", $hGraphics, "int", $iTextRenderingHint) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsSetTransform($hGraphics, $hMatrix) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetWorldTransform", "handle", $hGraphics, "handle", $hMatrix) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_GraphicsTransformPoints($hGraphics, ByRef $aPoints, $iCoordSpaceTo = 0, $iCoordSpaceFrom = 1) Local $iCount = $aPoints[0][0] Local $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], ($iI - 1) * 2 + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], ($iI - 1) * 2 + 2) Next Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipTransformPoints", "handle", $hGraphics, "int", $iCoordSpaceTo, "int", $iCoordSpaceFrom, "struct*", $tPoints, "int", $iCount) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) For $iI = 1 To $iCount $aPoints[$iI][0] = DllStructGetData($tPoints, 1, ($iI - 1) * 2 + 1) $aPoints[$iI][1] = DllStructGetData($tPoints, 1, ($iI - 1) * 2 + 2) Next Return True EndFunc Func _GDIPlus_GraphicsTranslateTransform($hGraphics, $nDX, $nDY, $iOrder = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipTranslateWorldTransform", "handle", $hGraphics, "float", $nDX, "float", $nDY, "int", $iOrder) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_HatchBrushCreate($iHatchStyle = 0, $iARGBForeground = 0xFFFFFFFF, $iARGBBackground = 0xFFFFFFFF) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateHatchBrush", "int", $iHatchStyle, "uint", $iARGBForeground, "uint", $iARGBBackground, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[4] EndFunc Func _GDIPlus_HICONCreateFromBitmap($hBitmap) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateHICONFromBitmap", "handle", $hBitmap, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_ImageAttributesCreate() Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateImageAttributes", "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[1] EndFunc Func _GDIPlus_ImageAttributesDispose($hImageAttributes) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDisposeImageAttributes", "handle", $hImageAttributes) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_ImageAttributesSetColorKeys($hImageAttributes, $iColorAdjustType = 0, $bEnable = False, $iARGBLow = 0, $iARGBHigh = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetImageAttributesColorKeys", "handle", $hImageAttributes, "int", $iColorAdjustType, "int", $bEnable, "uint", $iARGBLow, "uint", $iARGBHigh) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_ImageAttributesSetColorMatrix($hImageAttributes, $iColorAdjustType = 0, $bEnable = False, $tClrMatrix = 0, $tGrayMatrix = 0, $iColorMatrixFlags = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetImageAttributesColorMatrix", "handle", $hImageAttributes, "int", $iColorAdjustType, "int", $bEnable, "struct*", $tClrMatrix, "struct*", $tGrayMatrix, "int", $iColorMatrixFlags) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_ImageAttributesSetRemapTable($hImageAttributes, $aColorMap = 0, $iColorAdjustType = 0, $bEnable = True) Local $aResult If IsArray($aColorMap) Then Local $iCount = $aColorMap[0][0] Local $tColorMap = DllStructCreate("uint[" & $iCount * 2 & "]") For $i = 1 To $iCount DllStructSetData($tColorMap, 1, $aColorMap[$i][0], ($i - 1) * 2 + 1) DllStructSetData($tColorMap, 1, $aColorMap[$i][1], ($i - 1) * 2 + 2) Next $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetImageAttributesRemapTable", "handle", $hImageAttributes, "int", $iColorAdjustType, "int", $bEnable, "int", $iCount, "struct*", $tColorMap) Else $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetImageAttributesRemapTable", "handle", $hImageAttributes, "int", $iColorAdjustType, "int", $bEnable, "int", 0, "struct*", 0) EndIf If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_ImageAttributesSetThreshold($hImageAttributes, $fThreshold, $iColorAdjustType = $GDIP_COLORADJUSTTYPE_DEFAULT, $bEnable = True) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetImageAttributesThreshold", "handle", $hImageAttributes, "int", $iColorAdjustType, "bool", $bEnable, "float", $fThreshold) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_ImageClone($hImage) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCloneImage", "handle", $hImage, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_ImageDispose($hImage) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDisposeImage", "handle", $hImage) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_ImageGetDimension($hImage) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImageDimension", "handle", $hImage, "float*", 0, "float*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Local $aImgDim[2] = [$aResult[2], $aResult[3]] Return $aImgDim EndFunc Func _GDIPlus_ImageGetFlags($hImage) Local $aFlag[2] = [0, ""] If ($hImage = -1) Or (Not $hImage) Then Return SetError(11, 0, $aFlag) Local $aImageFlags[13][2] = [["Pixel data Cacheable", $GDIP_IMAGEFLAGS_CACHING], ["Pixel data read-only", $GDIP_IMAGEFLAGS_READONLY], ["Pixel size in image", $GDIP_IMAGEFLAGS_HASREALPIXELSIZE], ["DPI info in image", $GDIP_IMAGEFLAGS_HASREALDPI], ["YCCK color space", $GDIP_IMAGEFLAGS_COLORSPACE_YCCK], ["YCBCR color space", $GDIP_IMAGEFLAGS_COLORSPACE_YCBCR], ["Grayscale image", $GDIP_IMAGEFLAGS_COLORSPACE_GRAY], ["CMYK color space", $GDIP_IMAGEFLAGS_COLORSPACE_CMYK], ["RGB color space", $GDIP_IMAGEFLAGS_COLORSPACE_RGB], ["Partially scalable", $GDIP_IMAGEFLAGS_PARTIALLYSCALABLE], ["Alpha values other than 0 (transparent) and 255 (opaque)", $GDIP_IMAGEFLAGS_HASTRANSLUCENT], ["Alpha values", $GDIP_IMAGEFLAGS_HASALPHA], ["Scalable", $GDIP_IMAGEFLAGS_SCALABLE]] Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImageFlags", "handle", $hImage, "long*", 0) If @error Then Return SetError(@error, @extended, $aFlag) If $aResult[0] Then Return SetError(10, $aResult[0], $aFlag) If $aResult[2] = $GDIP_IMAGEFLAGS_NONE Then $aFlag[1] = "No pixel data" Return SetError(12, $aResult[2], $aFlag) EndIf $aFlag[0] = $aResult[2] For $i = 0 To 12 If BitAND($aResult[2], $aImageFlags[$i][1]) = $aImageFlags[$i][1] Then If StringLen($aFlag[1]) Then $aFlag[1] &= "|" $aResult[2] -= $aImageFlags[$i][1] $aFlag[1] &= $aImageFlags[$i][0] EndIf Next Return $aFlag EndFunc Func _GDIPlus_ImageGetFrameCount($hImage, $sDimensionID) Local $tGUID = _WinAPI_GUIDFromString($sDimensionID) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipImageGetFrameCount", "handle", $hImage, "struct*", $tGUID, "uint*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[3] EndFunc Func _GDIPlus_ImageGetGraphicsContext($hImage) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImageGraphicsContext", "handle", $hImage, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_ImageGetHeight($hImage) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImageHeight", "handle", $hImage, "uint*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_ImageGetHorizontalResolution($hImage) If ($hImage = -1) Or (Not $hImage) Then Return SetError(11, 0, 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImageHorizontalResolution", "handle", $hImage, "float*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return Round($aResult[2]) EndFunc Func _GDIPlus_ImageGetPixelFormat($hImage) Local $aFormat[2] = [0, ""] If ($hImage = -1) Or (Not $hImage) Then Return SetError(11, 0, $aFormat) Local $aPixelFormat[14][2] = [["1 Bpp Indexed", $GDIP_PXF01INDEXED], ["4 Bpp Indexed", $GDIP_PXF04INDEXED], ["8 Bpp Indexed", $GDIP_PXF08INDEXED], ["16 Bpp Grayscale", $GDIP_PXF16GRAYSCALE], ["16 Bpp RGB 555", $GDIP_PXF16RGB555], ["16 Bpp RGB 565", $GDIP_PXF16RGB565], ["16 Bpp ARGB 1555", $GDIP_PXF16ARGB1555], ["24 Bpp RGB", $GDIP_PXF24RGB], ["32 Bpp RGB", $GDIP_PXF32RGB], ["32 Bpp ARGB", $GDIP_PXF32ARGB], ["32 Bpp PARGB", $GDIP_PXF32PARGB], ["48 Bpp RGB", $GDIP_PXF48RGB], ["64 Bpp ARGB", $GDIP_PXF64ARGB], ["64 Bpp PARGB", $GDIP_PXF64PARGB]] Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImagePixelFormat", "handle", $hImage, "int*", 0) If @error Then Return SetError(@error, @extended, $aFormat) If $aResult[0] Then Return SetError(10, $aResult[0], $aFormat) For $i = 0 To 13 If $aPixelFormat[$i][1] = $aResult[2] Then $aFormat[0] = $aPixelFormat[$i][1] $aFormat[1] = $aPixelFormat[$i][0] Return $aFormat EndIf Next Return SetError(12, 0, $aFormat) EndFunc Func __GDIPlus_ImageGetPropertyCount($hImage) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPropertyCount", "handle", $hImage, "uint*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_ImageGetPropertyIdList($hImage) Local $iCount = __GDIPlus_ImageGetPropertyCount($hImage) If @error Then Return SetError(@error, @extended, False) Local $tProperties = DllStructCreate("uint[" & $iCount & "]") Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPropertyIdList", "handle", $hImage, "int", $iCount, "struct*", $tProperties) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Local $sPropertyTagInfo = "0x0000=GpsVer;0x0001=GpsLatitudeRef;0x0002=GpsLatitude;0x0003=GpsLongitudeRef;0x0004=GpsLongitude;0x0005=GpsAltitudeRef;0x0006=GpsAltitude;0x0007=GpsGpsTime;0x0008=GpsGpsSatellites;0x0009=GpsGpsStatus;0x000A=GpsGpsMeasureMode;0x000B=GpsGpsDop;0x000C=GpsSpeedRef;0x000D=GpsSpeed;0x000E=GpsTrackRef;0x000F=GpsTrack;0x0010=GpsImgDirRef;0x0011=GpsImgDir;0x0012=GpsMapDatum;0x0013=GpsDestLatRef;0x0014=GpsDestLat;0x0015=GpsDestLongRef;0x0016=GpsDestLong;0x0017=GpsDestBearRef;0x0018=GpsDestBear;0x0019=GpsDestDistRef;0x001A=GpsDestDist;0x00FE=NewSubfileType;0x00FF=SubfileType;0x0100=ImageWidth;0x0101=ImageHeight;0x0102=BitsPerSample;0x0103=Compression;0x0106=PhotometricInterp;0x0107=ThreshHolding;0x0108=CellWidth;0x0109=CellHeight;0x010A=FillOrder;0x010D=DocumentName;0x010E=ImageDescription;0x010F=EquipMake;0x0110=EquipModel;0x0111=StripOffsets;0x0112=Orientation;0x0115=SamplesPerPixel;0x0116=RowsPerStrip;0x0117=StripBytesCount;0x0118=MinSampleValue;0x0119=MaxSampleValue;0x011A=XResolution;0x011B=YResolution;0x011C=PlanarConfig;0x011D=PageName;0x011E=XPosition;0x011F=YPosition;0x0120=FreeOffset;0x0121=FreeByteCounts;0x0122=GrayResponseUnit;0x0123=GrayResponseCurve;0x0124=T4Option;0x0125=T6Option;0x0128=ResolutionUnit;0x0129=PageNumber;0x012D=TransferFunction;0x0131=SoftwareUsed;0x0132=DateTime;0x013B=Artist;0x013C=HostComputer;0x013D=Predictor;0x013E=WhitePoint;0x013F=PrimaryChromaticities;0x0140=ColorMap;0x0141=HalftoneHints;0x0142=TileWidth;0x0143=TileLength;0x0144=TileOffset;0x0145=TileByteCounts;0x014C=InkSet;0x014D=InkNames;0x014E=NumberOfInks;0x0150=DotRange;0x0151=TargetPrinter;0x0152=ExtraSamples;0x0153=SampleFormat;0x0154=SMinSampleValue;0x0155=SMaxSampleValue;0x0156=TransferRange;0x0200=JPEGProc;0x0201=JPEGInterFormat;0x0202=JPEGInterLength;0x0203=JPEGRestartInterval;0x0205=JPEGLosslessPredictors;0x0206=JPEGPointTransforms;0x0207=JPEGQTables;0x0208=JPEGDCTables;0x0209=JPEGACTables;0x0211=YCbCrCoefficients;0x0212=YCbCrSubsampling;0x0213=YCbCrPositioning;0x0214=REFBlackWhite;0x0301=Gamma;0x0302=ICCProfileDescriptor;0x0303=SRGBRenderingIntent;0x0320=ImageTitle;0x5001=ResolutionXUnit;0x5002=ResolutionYUnit;0x5003=ResolutionXLengthUnit;0x5004=ResolutionYLengthUnit;0x5005=PrintFlags;0x5006=PrintFlagsVersion;0x5007=PrintFlagsCrop;0x5008=PrintFlagsBleedWidth;0x5009=PrintFlagsBleedWidthScale;0x500A=HalftoneLPI;0x500B=HalftoneLPIUnit;0x500C=HalftoneDegree;" & _ "0x500D=HalftoneShape;0x500E=HalftoneMisc;0x500F=HalftoneScreen;0x5010=JPEGQuality;0x5011=GridSize;0x5012=ThumbnailFormat;0x5013=ThumbnailWidth;0x5014=ThumbnailHeight;0x5015=ThumbnailColorDepth;0x5016=ThumbnailPlanes;0x5017=ThumbnailRawBytes;0x5018=ThumbnailSize;0x5019=ThumbnailCompressedSize;0x501A=ColorTransferFunction;0x501B=ThumbnailData;0x5020=ThumbnailImageWidth;0x5021=ThumbnailImageHeight;0x5022=ThumbnailBitsPerSample;0x5023=ThumbnailCompression;0x5024=ThumbnailPhotometricInterp;0x5025=ThumbnailImageDescription;0x5026=ThumbnailEquipMake;0x5027=ThumbnailEquipModel;0x5028=ThumbnailStripOffsets;0x5029=ThumbnailOrientation;0x502A=ThumbnailSamplesPerPixel;0x502B=ThumbnailRowsPerStrip;0x502C=ThumbnailStripBytesCount;0x502D=ThumbnailResolutionX;0x502E=ThumbnailResolutionY;0x502F=ThumbnailPlanarConfig;0x5030=ThumbnailResolutionUnit;0x5031=ThumbnailTransferFunction;0x5032=ThumbnailSoftwareUsed;0x5033=ThumbnailDateTime;0x5034=ThumbnailArtist;0x5035=ThumbnailWhitePoint;0x5036=ThumbnailPrimaryChromaticities;0x5037=ThumbnailYCbCrCoefficients;0x5038=ThumbnailYCbCrSubsampling;0x5039=ThumbnailYCbCrPositioning;0x503A=ThumbnailRefBlackWhite;0x503B=ThumbnailCopyRight;0x5090=LuminanceTable;0x5091=ChrominanceTable;0x5100=FrameDelay;0x5101=LoopCount;0x5102=GlobalPalette;0x5103=IndexBackground;0x5104=IndexTransparent;0x5110=PixelUnit;0x5111=PixelPerUnitX;0x5112=PixelPerUnitY;0x5113=PaletteHistogram;0x8298=Copyright;0x829A=ExifExposureTime;0x829D=ExifFNumber;0x8769=ExifIFD;0x8773=ICCProfile;0x8822=ExifExposureProg;0x8824=ExifSpectralSense;0x8825=GpsIFD;0x8827=ExifISOSpeed;0x8828=ExifOECF;0x9000=ExifVer;0x9003=ExifDTOrig;0x9004=ExifDTDigitized;0x9101=ExifCompConfig;0x9102=ExifCompBPP;0x9201=ExifShutterSpeed;0x9202=ExifAperture;0x9203=ExifBrightness;0x9204=ExifExposureBias;0x9205=ExifMaxAperture;0x9206=ExifSubjectDist;0x9207=ExifMeteringMode;0x9208=ExifLightSource;0x9209=ExifFlash;0x920A=ExifFocalLength;0x927C=ExifMakerNote;0x9286=ExifUserComment;0x9290=ExifDTSubsec;0x9291=ExifDTOrigSS;0x9292=ExifDTDigSS;0xA000=ExifFPXVer;0xA001=ExifColorSpace;0xA002=ExifPixXDim;0xA003=ExifPixYDim;0xA004=ExifRelatedWav;0xA005=ExifInterop;0xA20B=ExifFlashEnergy;0xA20C=ExifSpatialFR;0xA20E=ExifFocalXRes;0xA20F=ExifFocalYRes;0xA210=ExifFocalResUnit;0xA214=ExifSubjectLoc;0xA215=ExifExposureIndex;0xA217=ExifSensingMethod;0xA300=ExifFileSource;0xA301=ExifSceneType;0xA302=ExifCfaPattern" Local $aProperties[$iCount + 1][2] = [[$iCount]] Local $aRegExp For $i = 1 To $iCount $aProperties[$i][0] = DllStructGetData($tProperties, 1, $i) $aRegExp = StringRegExp($sPropertyTagInfo, "(?i)" & Hex(DllStructGetData($tProperties, 1, $i), 4) & "=(\w+)", 3) Switch IsArray($aRegExp) Case True $aProperties[$i][1] = $aRegExp[0] Case Else $aProperties[$i][1] = "PropertyTagUnKnown" EndSwitch Next Return $aProperties EndFunc Func __GDIPlus_ImageGetPropertyItemSize($hImage, $iPropID) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPropertyItemSize", "handle", $hImage, "uint", $iPropID, "uint*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[3] EndFunc Func _GDIPlus_ImageGetPropertyItem($hImage, $iPropID) Local $iSize = __GDIPlus_ImageGetPropertyItemSize($hImage, $iPropID) If @error Then Return SetError(@error, @extended, False) Local $tBuffer = DllStructCreate("byte[" & $iSize & "];") Local $pBuffer = DllStructGetPtr($tBuffer) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPropertyItem", "handle", $hImage, "uint", $iPropID, "uint", $iSize, "struct*", $tBuffer) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], False) Local $tPropertyItem = DllStructCreate("int id; int length; short type; ptr value;", $pBuffer) Local $iBytes = DllStructGetData($tPropertyItem, "length") Local $pValue = DllStructGetData($tPropertyItem, "value") Local $tValues, $iValues Switch DllStructGetData($tPropertyItem, "type") Case 2 $iValues = 1 $tValues = DllStructCreate("char[" & $iBytes & "];", $pValue) Case 3 $iValues = Int($iBytes / 2) $tValues = DllStructCreate("ushort[" & $iValues & "];", $pValue) Case 4, 5 $iValues = Int($iBytes / 4) $tValues = DllStructCreate("uint[" & $iValues & "];", $pValue) Case 9, 10 $iValues = Int($iBytes / 4) $tValues = DllStructCreate("int[" & $iValues & "];", $pValue) Case Else $iValues = 1 $tValues = DllStructCreate("byte[" & $iBytes & "];", $pValue) EndSwitch Local $aValues[$iValues + 1] = [$iValues] Switch DllStructGetData($tPropertyItem, "type") Case 5, 10 $iValues = Int($iValues / 2) ReDim $aValues[$iValues + 1] $aValues[0] = $iValues For $j = 1 To $iValues $aValues[$j] = DllStructGetData($tValues, 1, ($j - 1) * 2 + 1) / DllStructGetData($tValues, 1, ($j - 1) * 2 + 2) Next Case 3, 4, 9 For $j = 1 To $iValues $aValues[$j] = DllStructGetData($tValues, 1, $j) Next Case Else $aValues[1] = DllStructGetData($tValues, 1) EndSwitch Return $aValues EndFunc Func _GDIPlus_ImageGetRawFormat($hImage) Local $aGuid[2] If ($hImage = -1) Or (Not $hImage) Then Return SetError(11, 0, $aGuid) Local $aImageType[11][2] = [["UNDEFINED", $GDIP_IMAGEFORMAT_UNDEFINED], ["MEMORYBMP", $GDIP_IMAGEFORMAT_MEMORYBMP], ["BMP", $GDIP_IMAGEFORMAT_BMP], ["EMF", $GDIP_IMAGEFORMAT_EMF], ["WMF", $GDIP_IMAGEFORMAT_WMF], ["JPEG", $GDIP_IMAGEFORMAT_JPEG], ["PNG", $GDIP_IMAGEFORMAT_PNG], ["GIF", $GDIP_IMAGEFORMAT_GIF], ["TIFF", $GDIP_IMAGEFORMAT_TIFF], ["EXIF", $GDIP_IMAGEFORMAT_EXIF], ["ICON", $GDIP_IMAGEFORMAT_ICON]] Local $tStruct = DllStructCreate("byte[16]") Local $aResult1 = DllCall($__g_hGDIPDll, "int", "GdipGetImageRawFormat", "handle", $hImage, "struct*", $tStruct) If @error Then Return SetError(@error, @extended, $aGuid) If $aResult1[0] Then Return SetError(10, $aResult1[0], $aGuid) Local $sResult2 = _WinAPI_StringFromGUID($aResult1[2]) If @error Then Return SetError(@error + 20, @extended, $aGuid) If $sResult2 = "" Then Return SetError(12, 0, $aGuid) For $i = 0 To 10 If $aImageType[$i][1] == $sResult2 Then $aGuid[0] = $aImageType[$i][1] $aGuid[1] = $aImageType[$i][0] Return $aGuid EndIf Next Return SetError(13, 0, $aGuid) EndFunc Func _GDIPlus_ImageGetThumbnail($hImage, $iWidth = 0, $iHeight = 0, $bKeepRatio = True, $hCallback = Null, $hCallbackData = Null) If $bKeepRatio Then Local $aImgDim = _GDIPlus_ImageGetDimension($hImage) If @error Then Return SetError(@error + 20, @extended, False) Local $f If $iWidth < 1 Or $iHeight < 1 Then $iWidth = 0 $iHeight = 0 Else If ($aImgDim[0] / $aImgDim[1]) > 1 Then $f = $aImgDim[0] / $iWidth Else $f = $aImgDim[1] / $iHeight EndIf $iWidth = Int($aImgDim[0] / $f) $iHeight = Int($aImgDim[1] / $f) EndIf EndIf Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImageThumbnail", "handle", $hImage, "uint", $iWidth, "uint", $iHeight, "ptr*", 0, "ptr", $hCallback, "ptr", $hCallbackData) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return $aResult[4] EndFunc Func _GDIPlus_ImageGetType($hImage) If ($hImage = -1) Or (Not $hImage) Then Return SetError(11, 0, -1) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImageType", "handle", $hImage, "int*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_ImageGetVerticalResolution($hImage) If ($hImage = -1) Or (Not $hImage) Then Return SetError(11, 0, 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImageVerticalResolution", "handle", $hImage, "float*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return Round($aResult[2]) EndFunc Func _GDIPlus_ImageGetWidth($hImage) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImageWidth", "handle", $hImage, "uint*", -1) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_ImageLoadFromFile($sFileName) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipLoadImageFromFile", "wstr", $sFileName, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_ImageLoadFromStream($pStream) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipLoadImageFromStream", "ptr", $pStream, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_ImageRotateFlip($hImage, $iRotateFlipType) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipImageRotateFlip", "handle", $hImage, "int", $iRotateFlipType) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_ImageSaveAdd($hImage, $tParams) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSaveAdd", "handle", $hImage, "struct*", $tParams) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_ImageSaveAddImage($hImage, $hImageNew, $tParams) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSaveAddImage", "handle", $hImage, "handle", $hImageNew, "struct*", $tParams) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_ImageSaveToFile($hImage, $sFileName) Local $sExt = __GDIPlus_ExtractFileExt($sFileName) Local $sCLSID = _GDIPlus_EncodersGetCLSID($sExt) If $sCLSID = "" Then Return SetError(-1, 0, False) Local $bRet = _GDIPlus_ImageSaveToFileEx($hImage, $sFileName, $sCLSID, 0) Return SetError(@error, @extended, $bRet) EndFunc Func _GDIPlus_ImageSaveToFileEx($hImage, $sFileName, $sEncoder, $tParams = 0) Local $tGUID = _WinAPI_GUIDFromString($sEncoder) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSaveImageToFile", "handle", $hImage, "wstr", $sFileName, "struct*", $tGUID, "struct*", $tParams) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_ImageSaveToStream($hImage, $pStream, $tEncoder, $tParams = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSaveImageToStream", "handle", $hImage, "ptr", $pStream, "struct*", $tEncoder, "struct*", $tParams) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_ImageScale($hImage, $iScaleW, $iScaleH, $iInterpolationMode = $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC) Local $iWidth = _GDIPlus_ImageGetWidth($hImage) * $iScaleW If @error Then Return SetError(1, 0, 0) Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * $iScaleH If @error Then Return SetError(2, 0, 0) Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) If @error Then Return SetError(3, 0, 0) Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) If @error Then _GDIPlus_BitmapDispose($hBitmap) Return SetError(4, 0, 0) EndIf _GDIPlus_GraphicsSetInterpolationMode($hBmpCtxt, $iInterpolationMode) If @error Then _GDIPlus_GraphicsDispose($hBmpCtxt) _GDIPlus_BitmapDispose($hBitmap) Return SetError(5, 0, 0) EndIf _GDIPlus_GraphicsDrawImageRect($hBmpCtxt, $hImage, 0, 0, $iWidth, $iHeight) If @error Then _GDIPlus_GraphicsDispose($hBmpCtxt) _GDIPlus_BitmapDispose($hBitmap) Return SetError(6, 0, 0) EndIf _GDIPlus_GraphicsDispose($hBmpCtxt) Return $hBitmap EndFunc Func _GDIPlus_ImageSelectActiveFrame($hImage, $sDimensionID, $iFrameIndex) Local $tGUID = _WinAPI_GUIDFromString($sDimensionID) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipImageSelectActiveFrame", "handle", $hImage, "struct*", $tGUID, "uint", $iFrameIndex) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_ImageResize($hImage, $iNewWidth, $iNewHeight, $iInterpolationMode = $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC) Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iNewWidth, $iNewHeight) If @error Then Return SetError(1, 0, 0) Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) If @error Then _GDIPlus_BitmapDispose($hBitmap) Return SetError(2, @extended, 0) EndIf _GDIPlus_GraphicsSetInterpolationMode($hBmpCtxt, $iInterpolationMode) If @error Then _GDIPlus_GraphicsDispose($hBmpCtxt) _GDIPlus_BitmapDispose($hBitmap) Return SetError(3, @extended, 0) EndIf _GDIPlus_GraphicsDrawImageRect($hBmpCtxt, $hImage, 0, 0, $iNewWidth, $iNewHeight) If @error Then _GDIPlus_GraphicsDispose($hBmpCtxt) _GDIPlus_BitmapDispose($hBitmap) Return SetError(4, @extended, 0) EndIf _GDIPlus_GraphicsDispose($hBmpCtxt) Return $hBitmap EndFunc Func _GDIPlus_LineBrushCreate($nX1, $nY1, $nX2, $nY2, $iARGBClr1, $iARGBClr2, $iWrapMode = 0) Local $tPointF1, $tPointF2, $aResult $tPointF1 = DllStructCreate("float;float") $tPointF2 = DllStructCreate("float;float") DllStructSetData($tPointF1, 1, $nX1) DllStructSetData($tPointF1, 2, $nY1) DllStructSetData($tPointF2, 1, $nX2) DllStructSetData($tPointF2, 2, $nY2) $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateLineBrush", "struct*", $tPointF1, "struct*", $tPointF2, "uint", $iARGBClr1, "uint", $iARGBClr2, "int", $iWrapMode, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[6] EndFunc Func _GDIPlus_LineBrushCreateFromRect($tRECTF, $iARGBClr1, $iARGBClr2, $iGradientMode = 0, $iWrapMode = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateLineBrushFromRect", "struct*", $tRECTF, "uint", $iARGBClr1, "uint", $iARGBClr2, "int", $iGradientMode, "int", $iWrapMode, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[6] EndFunc Func _GDIPlus_LineBrushCreateFromRectWithAngle($tRECTF, $iARGBClr1, $iARGBClr2, $fAngle, $bIsAngleScalable = True, $iWrapMode = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateLineBrushFromRectWithAngle", "struct*", $tRECTF, "uint", $iARGBClr1, "uint", $iARGBClr2, "float", $fAngle, "int", $bIsAngleScalable, "int", $iWrapMode, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[7] EndFunc Func _GDIPlus_LineBrushGetColors($hLineGradientBrush) Local $tARGBs, $aARGBs[2], $aResult $tARGBs = DllStructCreate("uint;uint") $aResult = DllCall($__g_hGDIPDll, "uint", "GdipGetLineColors", "handle", $hLineGradientBrush, "struct*", $tARGBs) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) $aARGBs[0] = DllStructGetData($tARGBs, 1) $aARGBs[1] = DllStructGetData($tARGBs, 2) Return $aARGBs EndFunc Func _GDIPlus_LineBrushGetRect($hLineGradientBrush) Local $tRECTF = DllStructCreate($tagGDIPRECTF) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetLineRect", "handle", $hLineGradientBrush, "struct*", $tRECTF) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Local $aRectF[4] For $iI = 1 To 4 $aRectF[$iI - 1] = DllStructGetData($tRECTF, $iI) Next Return $aRectF EndFunc Func _GDIPlus_LineBrushMultiplyTransform($hLineGradientBrush, $hMatrix, $iOrder = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipMultiplyLineTransform", "handle", $hLineGradientBrush, "handle", $hMatrix, "int", $iOrder) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_LineBrushResetTransform($hLineGradientBrush) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipResetLineTransform", "handle", $hLineGradientBrush) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_LineBrushSetBlend($hLineGradientBrush, $aBlends) Local $iI, $iCount, $tFactors, $tPositions, $aResult $iCount = $aBlends[0][0] $tFactors = DllStructCreate("float[" & $iCount & "]") $tPositions = DllStructCreate("float[" & $iCount & "]") For $iI = 1 To $iCount DllStructSetData($tFactors, 1, $aBlends[$iI][0], $iI) DllStructSetData($tPositions, 1, $aBlends[$iI][1], $iI) Next $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetLineBlend", "handle", $hLineGradientBrush, "struct*", $tFactors, "struct*", $tPositions, "int", $iCount) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_LineBrushSetColors($hLineGradientBrush, $iARGBStart, $iARGBEnd) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetLineColors", "handle", $hLineGradientBrush, "uint", $iARGBStart, "uint", $iARGBEnd) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_LineBrushSetGammaCorrection($hLineGradientBrush, $bUseGammaCorrection = True) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetLineGammaCorrection", "handle", $hLineGradientBrush, "int", $bUseGammaCorrection) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_LineBrushSetLinearBlend($hLineGradientBrush, $fFocus, $fScale = 1) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetLineLinearBlend", "handle", $hLineGradientBrush, "float", $fFocus, "float", $fScale) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_LineBrushSetPresetBlend($hLineGradientBrush, $aInterpolations) Local $iI, $iCount, $tColors, $tPositions, $aResult $iCount = $aInterpolations[0][0] $tColors = DllStructCreate("uint[" & $iCount & "]") $tPositions = DllStructCreate("float[" & $iCount & "]") For $iI = 1 To $iCount DllStructSetData($tColors, 1, $aInterpolations[$iI][0], $iI) DllStructSetData($tPositions, 1, $aInterpolations[$iI][1], $iI) Next $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetLinePresetBlend", "handle", $hLineGradientBrush, "struct*", $tColors, "struct*", $tPositions, "int", $iCount) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_LineBrushSetSigmaBlend($hLineGradientBrush, $fFocus, $fScale = 1) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetLineSigmaBlend", "handle", $hLineGradientBrush, "float", $fFocus, "float", $fScale) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_LineBrushSetTransform($hLineGradientBrush, $hMatrix) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetLineTransform", "handle", $hLineGradientBrush, "handle", $hMatrix) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_MatrixCreate() Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateMatrix", "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[1] EndFunc Func _GDIPlus_MatrixCreate2($nM11 = 1, $nM12 = 1, $nM21 = 1, $nM22 = 1, $nDX = 0, $nDY = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateMatrix2", "float", $nM11, "float", $nM12, "float", $nM21, "float", $nM22, "float", $nDX, "float", $nDY, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[7] EndFunc Func _GDIPlus_MatrixClone($hMatrix) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCloneMatrix", "handle", $hMatrix, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_MatrixDispose($hMatrix) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDeleteMatrix", "handle", $hMatrix) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_MatrixGetElements($hMatrix) Local $tElements = DllStructCreate("float[6]") Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetMatrixElements", "handle", $hMatrix, "struct*", $tElements) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Local $aElements[6] For $iI = 1 To 6 $aElements[$iI - 1] = DllStructGetData($tElements, 1, $iI) Next Return $aElements EndFunc Func _GDIPlus_MatrixInvert($hMatrix) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipInvertMatrix", "handle", $hMatrix) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_MatrixMultiply($hMatrix1, $hMatrix2, $iOrder = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipMultiplyMatrix", "handle", $hMatrix1, "handle", $hMatrix2, "int", $iOrder) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_MatrixRotate($hMatrix, $fAngle, $bAppend = False) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipRotateMatrix", "handle", $hMatrix, "float", $fAngle, "int", $bAppend) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_MatrixScale($hMatrix, $fScaleX, $fScaleY, $bOrder = False) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipScaleMatrix", "handle", $hMatrix, "float", $fScaleX, "float", $fScaleY, "int", $bOrder) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_MatrixSetElements($hMatrix, $nM11 = 1, $nM12 = 0, $nM21 = 0, $nM22 = 1, $nDX = 0, $nDY = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetMatrixElements", "handle", $hMatrix, "float", $nM11, "float", $nM12, "float", $nM21, "float", $nM22, "float", $nDX, "float", $nDY) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_MatrixShear($hMatrix, $fShearX, $fShearY, $iOrder = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipShearMatrix", "handle", $hMatrix, "float", $fShearX, "float", $fShearY, "int", $iOrder) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_MatrixTransformPoints($hMatrix, ByRef $aPoints) Local $iCount = $aPoints[0][0] Local $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], ($iI - 1) * 2 + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], ($iI - 1) * 2 + 2) Next Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipTransformMatrixPoints", "handle", $hMatrix, "struct*", $tPoints, "int", $iCount) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) For $iI = 1 To $iCount $aPoints[$iI][0] = DllStructGetData($tPoints, 1, ($iI - 1) * 2 + 1) $aPoints[$iI][1] = DllStructGetData($tPoints, 1, ($iI - 1) * 2 + 2) Next Return True EndFunc Func _GDIPlus_MatrixTranslate($hMatrix, $fOffsetX, $fOffsetY, $bAppend = False) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipTranslateMatrix", "handle", $hMatrix, "float", $fOffsetX, "float", $fOffsetY, "int", $bAppend) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_ParamAdd(ByRef $tParams, $sGUID, $iNbOfValues, $iType, $pValues) Local $iCount = DllStructGetData($tParams, "Count") Local $pGUID = DllStructGetPtr($tParams, "GUID") + ($iCount * _GDIPlus_ParamSize()) Local $tParam = DllStructCreate($tagGDIPENCODERPARAM, $pGUID) _WinAPI_GUIDFromStringEx($sGUID, $pGUID) DllStructSetData($tParam, "Type", $iType) DllStructSetData($tParam, "NumberOfValues", $iNbOfValues) DllStructSetData($tParam, "Values", $pValues) DllStructSetData($tParams, "Count", $iCount + 1) EndFunc Func _GDIPlus_ParamInit($iCount) Local $sStruct = $tagGDIPENCODERPARAMS For $i = 2 To $iCount $sStruct &= ";struct;byte[16];ulong;ulong;ptr;endstruct" Next Return DllStructCreate($sStruct) EndFunc Func _GDIPlus_ParamSize() Local $tParam = DllStructCreate($tagGDIPENCODERPARAM) Return DllStructGetSize($tParam) EndFunc Func _GDIPlus_PathAddArc($hPath, $nX, $nY, $nWidth, $nHeight, $fStartAngle, $fSweepAngle) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipAddPathArc", "handle", $hPath, "float", $nX, "float", $nY, "float", $nWidth, "float", $nHeight, "float", $fStartAngle, "float", $fSweepAngle) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathAddBezier($hPath, $nX1, $nY1, $nX2, $nY2, $nX3, $nY3, $nX4, $nY4) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipAddPathBezier", "handle", $hPath, "float", $nX1, "float", $nY1, "float", $nX2, "float", $nY2, "float", $nX3, "float", $nY3, "float", $nX4, "float", $nY4) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathAddClosedCurve($hPath, $aPoints) Local $iCount = $aPoints[0][0] Local $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2) Next Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipAddPathClosedCurve", "handle", $hPath, "struct*", $tPoints, "int", $iCount) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathAddClosedCurve2($hPath, $aPoints, $nTension = 0.5) Local $iCount = $aPoints[0][0] Local $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2) Next Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipAddPathClosedCurve2", "handle", $hPath, "struct*", $tPoints, "int", $iCount, "float", $nTension) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathAddCurve($hPath, $aPoints) Local $iCount = $aPoints[0][0] Local $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2) Next Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipAddPathCurve", "handle", $hPath, "struct*", $tPoints, "int", $iCount) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathAddCurve2($hPath, $aPoints, $nTension = 0.5) Local $iCount = $aPoints[0][0] Local $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2) Next Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipAddPathCurve2", "handle", $hPath, "struct*", $tPoints, "int", $iCount, "float", $nTension) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathAddCurve3($hPath, $aPoints, $iOffset, $iNumOfSegments, $nTension = 0.5) Local $iCount = $aPoints[0][0] Local $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2) Next Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipAddPathCurve3", "handle", $hPath, "struct*", $tPoints, "int", $iCount, "int", $iOffset, "int", $iNumOfSegments, "float", $nTension) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathAddEllipse($hPath, $nX, $nY, $nWidth, $nHeight) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipAddPathEllipse", "handle", $hPath, "float", $nX, "float", $nY, "float", $nWidth, "float", $nHeight) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathAddLine($hPath, $nX1, $nY1, $nX2, $nY2) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipAddPathLine", "handle", $hPath, "float", $nX1, "float", $nY1, "float", $nX2, "float", $nY2) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathAddLine2($hPath, $aPoints) Local $iCount = $aPoints[0][0] Local $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2) Next Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipAddPathLine2", "handle", $hPath, "struct*", $tPoints, "int", $iCount) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathAddPath($hPath1, $hPath2, $bConnect = True) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipAddPathPath", "handle", $hPath1, "handle", $hPath2, "int", $bConnect) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathAddPie($hPath, $nX, $nY, $nWidth, $nHeight, $fStartAngle, $fSweepAngle) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipAddPathPie", "handle", $hPath, "float", $nX, "float", $nY, "float", $nWidth, "float", $nHeight, "float", $fStartAngle, "float", $fSweepAngle) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathAddPolygon($hPath, $aPoints) Local $iCount = $aPoints[0][0] Local $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2) Next Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipAddPathPolygon", "handle", $hPath, "struct*", $tPoints, "int", $iCount) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathAddRectangle($hPath, $nX, $nY, $nWidth, $nHeight) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipAddPathRectangle", "handle", $hPath, "float", $nX, "float", $nY, "float", $nWidth, "float", $nHeight) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathAddString($hPath, $sString, $tLayout, $hFamily, $iStyle = 0, $fSize = 8.5, $hFormat = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipAddPathString", "handle", $hPath, "wstr", $sString, "int", -1, "handle", $hFamily, "int", $iStyle, "float", $fSize, "struct*", $tLayout, "handle", $hFormat) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathBrushCreate($aPoints, $iWrapMode = 0) Local $iCount = $aPoints[0][0] Local $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2) Next Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreatePathGradient", "struct*", $tPoints, "int", $iCount, "int", $iWrapMode, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[4] EndFunc Func _GDIPlus_PathBrushCreateFromPath($hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreatePathGradientFromPath", "handle", $hPath, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_PathBrushGetCenterPoint($hPathGradientBrush) Local $tPointF = DllStructCreate("float;float") Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPathGradientCenterPoint", "handle", $hPathGradientBrush, "struct*", $tPointF) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Local $aPointF[2] $aPointF[0] = DllStructGetData($tPointF, 1) $aPointF[1] = DllStructGetData($tPointF, 2) Return $aPointF EndFunc Func _GDIPlus_PathBrushGetFocusScales($hPathGradientBrush) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPathGradientFocusScales", "handle", $hPathGradientBrush, "float*", 0, "float*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Local $aScales[2] $aScales[0] = $aResult[2] $aScales[1] = $aResult[3] Return $aScales EndFunc Func _GDIPlus_PathBrushGetPointCount($hPathGradientBrush) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPathGradientPointCount", "handle", $hPathGradientBrush, "int*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_PathBrushGetRect($hPathGradientBrush) Local $tRECTF = DllStructCreate($tagGDIPRECTF) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPathGradientRect", "handle", $hPathGradientBrush, "struct*", $tRECTF) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Local $aRectF[4] For $iI = 1 To 4 $aRectF[$iI - 1] = DllStructGetData($tRECTF, $iI) Next Return $aRectF EndFunc Func _GDIPlus_PathBrushGetWrapMode($hPathGradientBrush) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPathGradientWrapMode", "handle", $hPathGradientBrush, "int*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_PathBrushMultiplyTransform($hPathGradientBrush, $hMatrix, $iOrder = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipMultiplyPathGradientTransform", "handle", $hPathGradientBrush, "handle", $hMatrix, "int", $iOrder) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathBrushResetTransform($hPathGradientBrush) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipResetPathGradientTransform", "handle", $hPathGradientBrush) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathBrushSetBlend($hPathGradientBrush, $aBlends) Local $iCount = $aBlends[0][0] Local $tFactors = DllStructCreate("float[" & $iCount & "]") Local $tPositions = DllStructCreate("float[" & $iCount & "]") For $iI = 1 To $iCount DllStructSetData($tFactors, 1, $aBlends[$iI][0], $iI) DllStructSetData($tPositions, 1, $aBlends[$iI][1], $iI) Next Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPathGradientBlend", "handle", $hPathGradientBrush, "struct*", $tFactors, "struct*", $tPositions, "int", $iCount) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathBrushSetCenterColor($hPathGradientBrush, $iARGB) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPathGradientCenterColor", "handle", $hPathGradientBrush, "uint", $iARGB) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathBrushSetCenterPoint($hPathGradientBrush, $nX, $nY) Local $tPointF = DllStructCreate("float;float") DllStructSetData($tPointF, 1, $nX) DllStructSetData($tPointF, 2, $nY) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPathGradientCenterPoint", "handle", $hPathGradientBrush, "struct*", $tPointF) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathBrushSetFocusScales($hPathGradientBrush, $fScaleX, $fScaleY) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPathGradientFocusScales", "handle", $hPathGradientBrush, "float", $fScaleX, "float", $fScaleY) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathBrushSetGammaCorrection($hPathGradientBrush, $bUseGammaCorrection) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPathGradientGammaCorrection", "handle", $hPathGradientBrush, "int", $bUseGammaCorrection) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathBrushSetLinearBlend($hPathGradientBrush, $fFocus, $fScale = 1) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPathGradientLinearBlend", "handle", $hPathGradientBrush, "float", $fFocus, "float", $fScale) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathBrushSetPresetBlend($hPathGradientBrush, $aInterpolations) Local $iCount = $aInterpolations[0][0] Local $tColors = DllStructCreate("uint[" & $iCount & "]") Local $tPositions = DllStructCreate("float[" & $iCount & "]") For $iI = 1 To $iCount DllStructSetData($tColors, 1, $aInterpolations[$iI][0], $iI) DllStructSetData($tPositions, 1, $aInterpolations[$iI][1], $iI) Next Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPathGradientPresetBlend", "handle", $hPathGradientBrush, "struct*", $tColors, "struct*", $tPositions, "int", $iCount) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathBrushSetSigmaBlend($hPathGradientBrush, $fFocus, $fScale = 1) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPathGradientSigmaBlend", "handle", $hPathGradientBrush, "float", $fFocus, "float", $fScale) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathBrushSetSurroundColor($hPathGradientBrush, $iARGB) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPathGradientSurroundColorsWithCount", "handle", $hPathGradientBrush, "uint*", $iARGB, "int*", 1) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathBrushSetSurroundColorsWithCount($hPathGradientBrush, $aColors) Local $iCount = $aColors[0] Local $iColors = _GDIPlus_PathBrushGetPointCount($hPathGradientBrush) If $iColors < $iCount Then $iCount = $iColors Local $tColors = DllStructCreate("uint[" & $iCount & "]") For $iI = 1 To $iCount DllStructSetData($tColors, 1, $aColors[$iI], $iI) Next Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPathGradientSurroundColorsWithCount", "handle", $hPathGradientBrush, "struct*", $tColors, "int*", $iCount) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[3] EndFunc Func _GDIPlus_PathBrushSetTransform($hPathGradientBrush, $hMatrix) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPathGradientTransform", "handle", $hPathGradientBrush, "handle", $hMatrix) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathBrushSetWrapMode($hPathGradientBrush, $iWrapMode) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPathGradientWrapMode", "handle", $hPathGradientBrush, "int", $iWrapMode) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathClone($hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipClonePath", "handle", $hPath, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_PathCloseFigure($hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipClosePathFigure", "handle", $hPath) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathCreate($iFillMode = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreatePath", "int", $iFillMode, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_PathCreate2($aPathData, $iFillMode = 0) Local $iCount = $aPathData[0][0] Local $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") Local $tTypes = DllStructCreate("byte[" & $iCount & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPathData[$iI][0], (($iI - 1) * 2) + 1) DllStructSetData($tPoints, 1, $aPathData[$iI][1], (($iI - 1) * 2) + 2) DllStructSetData($tTypes, 1, $aPathData[$iI][2], $iI) Next Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreatePath2", "struct*", $tPoints, "struct*", $tTypes, "int", $iCount, "int", $iFillMode, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[5] EndFunc Func _GDIPlus_PathDispose($hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDeletePath", "handle", $hPath) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathFlatten($hPath, $fFlatness = 0.25, $hMatrix = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipFlattenPath", "handle", $hPath, "handle", $hMatrix, "float", $fFlatness) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathGetData($hPath) Local $iCount = _GDIPlus_PathGetPointCount($hPath) Local $tPathData = DllStructCreate("int Count; ptr Points; ptr Types;") Local $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") Local $tTypes = DllStructCreate("byte[" & $iCount & "]") DllStructSetData($tPathData, "Count", $iCount) DllStructSetData($tPathData, "Points", DllStructGetPtr($tPoints)) DllStructSetData($tPathData, "Types", DllStructGetPtr($tTypes)) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPathData", "handle", $hPath, "struct*", $tPathData) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError($aResult[0], $aResult[0], -1) Local $aData[$iCount + 1][3] $aData[0][0] = $iCount For $iI = 1 To $iCount $aData[$iI][0] = DllStructGetData($tPoints, 1, (($iI - 1) * 2) + 1) $aData[$iI][1] = DllStructGetData($tPoints, 1, (($iI - 1) * 2) + 2) $aData[$iI][2] = DllStructGetData($tTypes, 1, $iI) Next Return $aData EndFunc Func _GDIPlus_PathGetFillMode($hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPathFillMode", "handle", $hPath, "int*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_PathGetLastPoint($hPath) Local $tPointF = DllStructCreate("float;float") Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPathLastPoint", "handle", $hPath, "struct*", $tPointF) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Local $aPointF[2] $aPointF[0] = DllStructGetData($tPointF, 1) $aPointF[1] = DllStructGetData($tPointF, 2) Return $aPointF EndFunc Func _GDIPlus_PathGetPointCount($hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPointCount", "handle", $hPath, "int*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_PathGetPoints($hPath) Local $iI, $iCount, $tPoints, $aPoints[1][1], $aResult $iCount = _GDIPlus_PathGetPointCount($hPath) If @error Then Return SetError(@error + 10, @extended, -1) $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPathPoints", "handle", $hPath, "struct*", $tPoints, "int", $iCount) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Local $aPoints[$iCount + 1][2] $aPoints[0][0] = $iCount For $iI = 1 To $iCount $aPoints[$iI][0] = DllStructGetData($tPoints, 1, (($iI - 1) * 2) + 1) $aPoints[$iI][1] = DllStructGetData($tPoints, 1, (($iI - 1) * 2) + 2) Next Return $aPoints EndFunc Func _GDIPlus_PathGetWorldBounds($hPath, $hMatrix = 0, $hPen = 0) Local $tRECTF = DllStructCreate($tagGDIPRECTF) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPathWorldBounds", "handle", $hPath, "struct*", $tRECTF, "handle", $hMatrix, "handle", $hPen) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Local $aRectF[4] For $iI = 1 To 4 $aRectF[$iI - 1] = DllStructGetData($tRECTF, $iI) Next Return $aRectF EndFunc Func _GDIPlus_PathIsOutlineVisiblePoint($hPath, $nX, $nY, $hPen = 0, $hGraphics = 0) __GDIPlus_PenDefCreate($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipIsOutlineVisiblePathPoint", "handle", $hPath, "float", $nX, "float", $nY, "handle", $hPen, "handle", $hGraphics, "int*", 0) __GDIPlus_PenDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return $aResult[6] <> 0 EndFunc Func _GDIPlus_PathIsVisiblePoint($hPath, $nX, $nY, $hGraphics = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipIsVisiblePathPoint", "handle", $hPath, "float", $nX, "float", $nY, "handle", $hGraphics, "int*", 0) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return $aResult[5] <> 0 EndFunc Func _GDIPlus_PathIterCreate($hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreatePathIter", "handle*", 0, "handle", $hPath) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[1] EndFunc Func _GDIPlus_PathIterDispose($hPathIter) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDeletePathIter", "handle", $hPathIter) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathIterGetSubpathCount($hPathIter) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipPathIterGetSubpathCount", "handle", $hPathIter, "int*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_PathIterNextMarkerPath($hPathIter, $hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipPathIterNextMarkerPath", "handle", $hPathIter, "int*", 0, "handle", $hPath) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_PathIterNextSubpathPath($hPathIter, $hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipPathIterNextSubpathPath", "handle", $hPathIter, "int*", 0, "handle", $hPath, "bool*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Local $aReturn[2] $aReturn[0] = $aResult[2] $aReturn[1] = $aResult[4] Return $aReturn EndFunc Func _GDIPlus_PathIterRewind($hPathIter) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipPathIterRewind", "handle", $hPathIter) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathReset($hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipResetPath", "handle", $hPath) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathReverse($hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipReversePath", "handle", $hPath) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathSetFillMode($hPath, $iFillMode) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPathFillMode", "handle", $hPath, "int", $iFillMode) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathSetMarker($hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPathMarker", "handle", $hPath) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathStartFigure($hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipStartPathFigure", "handle", $hPath) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathTransform($hPath, $hMatrix) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipTransformPath", "handle", $hPath, "handle", $hMatrix) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathWarp($hPath, $hMatrix, $aPoints, $nX, $nY, $nWidth, $nHeight, $iWarpMode = 0, $fFlatness = 0.25) Local $iCount = $aPoints[0][0] If $iCount <> 3 And $iCount <> 4 Then Return SetError(11, 0, False) Local $tPoints = DllStructCreate("float[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tPoints, 1, $aPoints[$iI][0], ($iI - 1) * 2 + 1) DllStructSetData($tPoints, 1, $aPoints[$iI][1], ($iI - 1) * 2 + 2) Next Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipWarpPath", "handle", $hPath, "handle", $hMatrix, "struct*", $tPoints, "int", $iCount, "float", $nX, "float", $nY, "float", $nWidth, "float", $nHeight, "int", $iWarpMode, "float", $fFlatness) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathWiden($hPath, $hPen, $hMatrix = 0, $fFlatness = 0.25) __GDIPlus_PenDefCreate($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipWidenPath", "handle", $hPath, "handle", $hPen, "handle", $hMatrix, "float", $fFlatness) __GDIPlus_PenDefDispose() If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PathWindingModeOutline($hPath, $hMatrix = 0, $fFlatness = 0.25) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipWindingModeOutline", "handle", $hPath, "handle", $hMatrix, "float", $fFlatness) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PenCreate($iARGB = 0xFF000000, $nWidth = 1, $iUnit = 2) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreatePen1", "dword", $iARGB, "float", $nWidth, "int", $iUnit, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[4] EndFunc Func _GDIPlus_PenCreate2($hBrush, $nWidth = 1, $iUnit = 2) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreatePen2", "handle", $hBrush, "float", $nWidth, "int", $iUnit, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[4] EndFunc Func _GDIPlus_PenDispose($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDeletePen", "handle", $hPen) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PenGetAlignment($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPenMode", "handle", $hPen, "int*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_PenGetColor($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPenColor", "handle", $hPen, "dword*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_PenGetCustomEndCap($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPenCustomEndCap", "handle", $hPen, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_PenGetDashCap($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPenDashCap197819", "handle", $hPen, "int*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_PenGetDashStyle($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPenDashStyle", "handle", $hPen, "int*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_PenGetEndCap($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPenEndCap", "handle", $hPen, "int*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_PenGetMiterLimit($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPenMiterLimit", "handle", $hPen, "float*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_PenGetWidth($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPenWidth", "handle", $hPen, "float*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_PenResetTransform($hPen) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipResetPenTransform", "handle", $hPen) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PenRotateTransform($hPen, $fAngle, $iOrder = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipRotatePenTransform", "handle", $hPen, "float", $fAngle, "int", $iOrder) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PenScaleTransform($hPen, $fScaleX, $fScaleY, $iOrder = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipScalePenTransform", "handle", $hPen, "float", $fScaleX, "float", $fScaleY, "int", $iOrder) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PenSetAlignment($hPen, $iAlignment = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPenMode", "handle", $hPen, "int", $iAlignment) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PenSetColor($hPen, $iARGB) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPenColor", "handle", $hPen, "dword", $iARGB) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PenSetCompound($hPen, $aCompounds) Local $iCount = $aCompounds[0] Local $tCompounds = DllStructCreate("float[" & $iCount & "];") For $i = 1 To $iCount DllStructSetData($tCompounds, 1, $aCompounds[$i], $i) Next Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPenCompoundArray", "handle", $hPen, "struct*", $tCompounds, "int", $iCount) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PenSetCustomEndCap($hPen, $hEndCap) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPenCustomEndCap", "handle", $hPen, "handle", $hEndCap) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PenSetDashCap($hPen, $iDash = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPenDashCap197819", "handle", $hPen, "int", $iDash) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PenSetDashStyle($hPen, $iStyle = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPenDashStyle", "handle", $hPen, "int", $iStyle) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PenSetEndCap($hPen, $iEndCap) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPenEndCap", "handle", $hPen, "int", $iEndCap) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PenSetLineCap($hPen, $iStartCap, $iEndCap, $iDashCap) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPenLineCap197819", "handle", $hPen, "int", $iStartCap, "int", $iEndCap, "int", $iDashCap) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PenSetLineJoin($hPen, $iLineJoin) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPenLineJoin", "handle", $hPen, "int", $iLineJoin) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PenSetMiterLimit($hPen, $fMiterLimit) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPenMiterLimit", "handle", $hPen, "float", $fMiterLimit) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PenSetStartCap($hPen, $iLineCap) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPenStartCap", "handle", $hPen, "int", $iLineCap) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PenSetTransform($hPen, $hMatrix) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPenTransform", "handle", $hPen, "handle", $hMatrix) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PenSetWidth($hPen, $fWidth) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPenWidth", "handle", $hPen, "float", $fWidth) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_RectFCreate($nX = 0, $nY = 0, $nWidth = 0, $nHeight = 0) Local $tRECTF = DllStructCreate($tagGDIPRECTF) DllStructSetData($tRECTF, "X", $nX) DllStructSetData($tRECTF, "Y", $nY) DllStructSetData($tRECTF, "Width", $nWidth) DllStructSetData($tRECTF, "Height", $nHeight) Return $tRECTF EndFunc Func _GDIPlus_RegionClone($hRegion) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCloneRegion", "handle", $hRegion, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_RegionCombinePath($hRegion, $hPath, $iCombineMode = 2) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCombineRegionPath", "handle", $hRegion, "handle", $hPath, "int", $iCombineMode) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_RegionCombineRect($hRegion, $nX, $nY, $nWidth, $nHeight, $iCombineMode = 2) Local $tRECTF = _GDIPlus_RectFCreate($nX, $nY, $nWidth, $nHeight) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCombineRegionRect", "handle", $hRegion, "struct*", $tRECTF, "int", $iCombineMode) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_RegionCombineRegion($hRegionDst, $hRegionSrc, $iCombineMode = 2) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCombineRegionRegion", "handle", $hRegionDst, "handle", $hRegionSrc, "int", $iCombineMode) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_RegionCreate() Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateRegion", "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[1] EndFunc Func _GDIPlus_RegionCreateFromPath($hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateRegionPath", "handle", $hPath, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_RegionCreateFromRect($nX, $nY, $nWidth, $nHeight) Local $tRECTF = _GDIPlus_RectFCreate($nX, $nY, $nWidth, $nHeight) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateRegionRect", "struct*", $tRECTF, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_RegionDispose($hRegion) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDeleteRegion", "handle", $hRegion) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_RegionGetBounds($hRegion, $hGraphics) Local $tRECTF = DllStructCreate($tagGDIPRECTF) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetRegionBounds", "handle", $hRegion, "handle", $hGraphics, "struct*", $tRECTF) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Local $aBounds[4] For $iI = 1 To 4 $aBounds[$iI - 1] = DllStructGetData($tRECTF, $iI) Next Return $aBounds EndFunc Func _GDIPlus_RegionGetHRgn($hRegion, $hGraphics = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetRegionHRgn", "handle", $hRegion, "handle", $hGraphics, "handle*", 0) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return $aResult[3] EndFunc Func _GDIPlus_RegionSetEmpty($hRegion) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetEmpty", "handle", $hRegion) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_RegionSetInfinite($hRegion) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetInfinite", "handle", $hRegion) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_RegionTransform($hRegion, $hMatrix) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipTransformRegion", "handle", $hRegion, "handle", $hMatrix) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_RegionTranslate($hRegion, $nDX, $nDY) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipTranslateRegion", "handle", $hRegion, "float", $nDX, "float", $nDY) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_Shutdown() If $__g_hGDIPDll = 0 Then Return SetError(-1, -1, False) $__g_iGDIPRef -= 1 If $__g_iGDIPRef = 0 Then DllCall($__g_hGDIPDll, "none", "GdiplusShutdown", "ulong_ptr", $__g_iGDIPToken) DllClose($__g_hGDIPDll) $__g_hGDIPDll = 0 EndIf Return True EndFunc Func _GDIPlus_Startup($sGDIPDLL = Default, $bRetDllHandle = False) $__g_iGDIPRef += 1 If $__g_iGDIPRef > 1 Then Return True If $sGDIPDLL = Default Then $sGDIPDLL = "gdiplus.dll" $__g_hGDIPDll = DllOpen($sGDIPDLL) If $__g_hGDIPDll = -1 Then $__g_iGDIPRef = 0 Return SetError(1, 2, False) EndIf Local $sVer = FileGetVersion($sGDIPDLL) $sVer = StringSplit($sVer, ".") If $sVer[1] > 5 Then $__g_bGDIP_V1_0 = False Local $tInput = DllStructCreate($tagGDIPSTARTUPINPUT) Local $tToken = DllStructCreate("ulong_ptr Data") DllStructSetData($tInput, "Version", 1) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdiplusStartup", "struct*", $tToken, "struct*", $tInput, "ptr", 0) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) $__g_iGDIPToken = DllStructGetData($tToken, "Data") If $bRetDllHandle Then Return $__g_hGDIPDll Return SetExtended($sVer[1], True) EndFunc Func _GDIPlus_StringFormatCreate($iFormat = 0, $iLangID = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateStringFormat", "int", $iFormat, "word", $iLangID, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[3] EndFunc Func _GDIPlus_StringFormatDispose($hFormat) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDeleteStringFormat", "handle", $hFormat) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_StringFormatGetMeasurableCharacterRangeCount($hStringFormat) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetStringFormatMeasurableCharacterRangeCount", "handle", $hStringFormat, "int*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_StringFormatSetAlign($hStringFormat, $iFlag) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetStringFormatAlign", "handle", $hStringFormat, "int", $iFlag) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_StringFormatSetLineAlign($hStringFormat, $iStringAlign) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetStringFormatLineAlign", "handle", $hStringFormat, "int", $iStringAlign) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_StringFormatSetMeasurableCharacterRanges($hStringFormat, $aRanges) Local $iCount = $aRanges[0][0] Local $tCharacterRanges = DllStructCreate("int[" & $iCount * 2 & "]") For $iI = 1 To $iCount DllStructSetData($tCharacterRanges, 1, $aRanges[$iI][0], (($iI - 1) * 2) + 1) DllStructSetData($tCharacterRanges, 1, $aRanges[$iI][1], (($iI - 1) * 2) + 2) Next Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetStringFormatMeasurableCharacterRanges", "handle", $hStringFormat, "int", $iCount, "struct*", $tCharacterRanges) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_TextureCreate($hImage, $iWrapMode = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateTexture", "handle", $hImage, "int", $iWrapMode, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[3] EndFunc Func _GDIPlus_TextureCreate2($hImage, $nX, $nY, $nWidth, $nHeight, $iWrapMode = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateTexture2", "handle", $hImage, "int", $iWrapMode, "float", $nX, "float", $nY, "float", $nWidth, "float", $nHeight, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[7] EndFunc Func _GDIPlus_TextureCreateIA($hImage, $nX, $nY, $nWidth, $nHeight, $pImageAttributes = 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateTextureIA", "handle", $hImage, "handle", $pImageAttributes, "float", $nX, "float", $nY, "float", $nWidth, "float", $nHeight, "ptr*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[7] EndFunc Func __GDIPlus_BrushDefCreate(ByRef $hBrush) If $hBrush = 0 Then $__g_hGDIPBrush = _GDIPlus_BrushCreateSolid() $hBrush = $__g_hGDIPBrush EndIf EndFunc Func __GDIPlus_BrushDefDispose($iCurError = @error, $iCurExtended = @extended) If $__g_hGDIPBrush <> 0 Then _GDIPlus_BrushDispose($__g_hGDIPBrush) $__g_hGDIPBrush = 0 EndIf Return SetError($iCurError, $iCurExtended) EndFunc Func __GDIPlus_ExtractFileExt($sFileName, $bNoDot = True) Local $iIndex = __GDIPlus_LastDelimiter(".\:", $sFileName) If ($iIndex > 0) And (StringMid($sFileName, $iIndex, 1) = '.') Then If $bNoDot Then Return StringMid($sFileName, $iIndex + 1) Else Return StringMid($sFileName, $iIndex) EndIf Else Return "" EndIf EndFunc Func __GDIPlus_LastDelimiter($sDelimiters, $sString) Local $sDelimiter, $iN For $iI = 1 To StringLen($sDelimiters) $sDelimiter = StringMid($sDelimiters, $iI, 1) $iN = StringInStr($sString, $sDelimiter, $STR_NOCASESENSEBASIC, -1) If $iN > 0 Then Return $iN Next EndFunc Func __GDIPlus_PenDefCreate(ByRef $hPen) If $hPen = 0 Then $__g_hGDIPPen = _GDIPlus_PenCreate() $hPen = $__g_hGDIPPen EndIf EndFunc Func __GDIPlus_PenDefDispose($iCurError = @error, $iCurExtended = @extended) If $__g_hGDIPPen <> 0 Then _GDIPlus_PenDispose($__g_hGDIPPen) $__g_hGDIPPen = 0 EndIf Return SetError($iCurError, $iCurExtended) EndFunc Func _GDIPlus_BitmapApplyEffect($hBitmap, $hEffect, $tRECT = Null) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, False) If Not IsPtr($hEffect) Then Return SetError(10, 0, False) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipBitmapApplyEffect", "handle", $hBitmap, "handle", $hEffect, "struct*", $tRECT, "int", 0, "ptr*", 0, "int*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_BitmapApplyEffectEx($hBitmap, $hEffect, $iX = 0, $iY = 0, $iW = 0, $iH = 0) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, False) Local $tRECT = 0 If BitOR($iX, $iY, $iW, $iH) Then $tRECT = DllStructCreate("int Left; int Top; int Right; int Bottom;") DllStructSetData($tRECT, "Right", $iW + DllStructSetData($tRECT, "Left", $iX)) DllStructSetData($tRECT, "Bottom", $iH + DllStructSetData($tRECT, "Top", $iY)) EndIf Local $iStatus = _GDIPlus_BitmapApplyEffect($hBitmap, $hEffect, $tRECT) If Not $iStatus Then Return SetError(@error, @extended, False) Return True EndFunc Func _GDIPlus_BitmapConvertFormat($hBitmap, $iPixelFormat, $iDitherType, $iPaletteType, $tPalette, $fAlphaThresholdPercent = 0.0) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, False) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipBitmapConvertFormat", "handle", $hBitmap, "uint", $iPixelFormat, "uint", $iDitherType, "uint", $iPaletteType, "struct*", $tPalette, "float", $fAlphaThresholdPercent) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_BitmapCreateApplyEffect($hBitmap, $hEffect, $tRECT = Null, $tOutRECT = Null) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipBitmapCreateApplyEffect", "handle*", $hBitmap, "int", 1, "handle", $hEffect, "struct*", $tRECT, "struct*", $tOutRECT, "handle*", 0, "int", 0, "ptr*", 0, "int*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[6] EndFunc Func _GDIPlus_BitmapCreateApplyEffectEx($hBitmap, $hEffect, $iX = 0, $iY = 0, $iW = 0, $iH = 0) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, 0) Local $tRECT = 0 If BitOR($iX, $iY, $iW, $iH) Then $tRECT = DllStructCreate("int Left; int Top; int Right; int Bottom;") DllStructSetData($tRECT, "Right", $iW + DllStructSetData($tRECT, "Left", $iX)) DllStructSetData($tRECT, "Bottom", $iH + DllStructSetData($tRECT, "Top", $iY)) EndIf Local $hBitmap_FX = _GDIPlus_BitmapCreateApplyEffect($hBitmap, $hEffect, $tRECT, Null) Return SetError(@error, @extended, $hBitmap_FX) EndFunc Func _GDIPlus_BitmapGetHistogram($hBitmap, $iHistogramFormat, $iHistogramSize, $tChannel_0, $tChannel_1 = 0, $tChannel_2 = 0, $tChannel_3 = 0) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, False) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipBitmapGetHistogram", "handle", $hBitmap, "uint", $iHistogramFormat, "uint", $iHistogramSize, "struct*", $tChannel_0, "struct*", $tChannel_1, "struct*", $tChannel_2, "struct*", $tChannel_3) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_BitmapGetHistogramEx($hBitmap) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, 0) Local $iSize = _GDIPlus_BitmapGetHistogramSize($GDIP_HistogramFormatARGB) Local $tHistogram = DllStructCreate("int Size; uint Red[" & $iSize & "]; uint MaxRed; uint Green[" & $iSize & "]; uint MaxGreen; uint Blue[" & $iSize & "]; uint MaxBlue; uint Alpha[" & $iSize & "]; uint MaxAlpha; uint Grey[" & $iSize & "]; uint MaxGrey;") DllStructSetData($tHistogram, "Size", $iSize) Local $iStatus = _GDIPlus_BitmapGetHistogram($hBitmap, $GDIP_HistogramFormatARGB, $iSize, DllStructGetPtr($tHistogram, "Alpha"), DllStructGetPtr($tHistogram, "Red"), DllStructGetPtr($tHistogram, "Green"), DllStructGetPtr($tHistogram, "Blue")) If Not $iStatus Then Return SetError(@error, @extended, 0) $iStatus = _GDIPlus_BitmapGetHistogram($hBitmap, $GDIP_HistogramFormatGray, $iSize, DllStructGetPtr($tHistogram, "Grey")) If Not $iStatus Then Return SetError(@error + 10, @extended, 0) Local $iMaxRed = 0, $iMaxGreen = 0, $iMaxBlue = 0, $iMaxAlpha = 0, $iMaxGrey = 0 For $i = 1 To $iSize If DllStructGetData($tHistogram, "Red", $i) > $iMaxRed Then $iMaxRed = DllStructGetData($tHistogram, "Red", $i) If DllStructGetData($tHistogram, "Green", $i) > $iMaxGreen Then $iMaxGreen = DllStructGetData($tHistogram, "Green", $i) If DllStructGetData($tHistogram, "Blue", $i) > $iMaxBlue Then $iMaxBlue = DllStructGetData($tHistogram, "Blue", $i) If DllStructGetData($tHistogram, "Alpha", $i) > $iMaxAlpha Then $iMaxAlpha = DllStructGetData($tHistogram, "Alpha", $i) If DllStructGetData($tHistogram, "Grey", $i) > $iMaxGrey Then $iMaxGrey = DllStructGetData($tHistogram, "Grey", $i) Next DllStructSetData($tHistogram, "MaxRed", $iMaxRed) DllStructSetData($tHistogram, "MaxGreen", $iMaxGreen) DllStructSetData($tHistogram, "MaxBlue", $iMaxBlue) DllStructSetData($tHistogram, "MaxAlpha", $iMaxAlpha) DllStructSetData($tHistogram, "MaxGrey", $iMaxGrey) Return $tHistogram EndFunc Func _GDIPlus_BitmapGetHistogramSize($iFormat) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipBitmapGetHistogramSize", "uint", $iFormat, "uint*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc Func _GDIPlus_DrawImageFX($hGraphics, $hImage, $hEffect, $tRECTF = 0, $hMatrix = 0, $hImgAttributes = 0, $iUnit = 2) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, False) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDrawImageFX", "handle", $hGraphics, "handle", $hImage, "struct*", $tRECTF, "handle", $hMatrix, "handle", $hEffect, "handle", $hImgAttributes, "uint", $iUnit) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_DrawImageFXEx($hGraphics, $hImage, $hEffect, $nX = 0, $nY = 0, $nW = 0, $nH = 0, $hMatrix = 0, $hImgAttributes = 0, $iUnit = 2) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, False) Local $tRECTF = 0 If BitOR($nX, $nY, $nW, $nH) Then $tRECTF = _GDIPlus_RectFCreate($nX, $nY, $nW, $nH) Local $iStatus = _GDIPlus_DrawImageFX($hGraphics, $hImage, $hEffect, $tRECTF, $hMatrix, $hImgAttributes, $iUnit) Return SetError(@error, @extended, $iStatus) EndFunc Func _GDIPlus_EffectCreate($sEffectGUID) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, 0) Local $tGUID = _WinAPI_GUIDFromString($sEffectGUID) Local $aResult = 0 If @AutoItX64 Then $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateEffect", "struct*", $tGUID, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndIf Local $tElem = DllStructCreate("uint64[2];", DllStructGetPtr($tGUID)) $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreateEffect", "uint64", DllStructGetData($tElem, 1, 1), "uint64", DllStructGetData($tElem, 1, 2), "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[3] EndFunc Func _GDIPlus_EffectCreateBlur($fRadius = 10.0, $bExpandEdge = False) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, 0) Local $tEffectParameters = DllStructCreate($tagGDIP_EFFECTPARAMS_Blur) DllStructSetData($tEffectParameters, "Radius", $fRadius) DllStructSetData($tEffectParameters, "ExpandEdge", $bExpandEdge) Local $hEffect = _GDIPlus_EffectCreate($GDIP_BlurEffectGuid) If @error Then Return SetError(@error, @extended, 0) _GDIPlus_EffectSetParameters($hEffect, $tEffectParameters) If @error Then Return SetError(@error + 10, @extended, 0) Return $hEffect EndFunc Func _GDIPlus_EffectCreateBrightnessContrast($iBrightnessLevel = 0, $iContrastLevel = 0) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, 0) Local $tEffectParameters = DllStructCreate($tagGDIP_EFFECTPARAMS_BrightnessContrast) DllStructSetData($tEffectParameters, "BrightnessLevel", $iBrightnessLevel) DllStructSetData($tEffectParameters, "ContrastLevel", $iContrastLevel) Local $hEffect = _GDIPlus_EffectCreate($GDIP_BrightnessContrastEffectGuid) If @error Then Return SetError(@error, @extended, 0) _GDIPlus_EffectSetParameters($hEffect, $tEffectParameters) If @error Then Return SetError(@error + 10, @extended, 0) Return $hEffect EndFunc Func _GDIPlus_EffectCreateColorBalance($iCyanRed = 0, $iMagentaGreen = 0, $iYellowBlue = 0) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, 0) Local $tEffectParameters = DllStructCreate($tagGDIP_EFFECTPARAMS_ColorBalance) DllStructSetData($tEffectParameters, "CyanRed", $iCyanRed) DllStructSetData($tEffectParameters, "MagentaGreen", $iMagentaGreen) DllStructSetData($tEffectParameters, "YellowBlue", $iYellowBlue) Local $hEffect = _GDIPlus_EffectCreate($GDIP_ColorBalanceEffectGuid) If @error Then Return SetError(@error, @extended, 0) _GDIPlus_EffectSetParameters($hEffect, $tEffectParameters) If @error Then Return SetError(@error + 10, @extended, 0) Return $hEffect EndFunc Func _GDIPlus_EffectCreateColorCurve($iAdjustment, $iChannel, $iAdjustValue) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, 0) Local $tEffectParameters = DllStructCreate($tagGDIP_EFFECTPARAMS_ColorCurve) DllStructSetData($tEffectParameters, "Adjustment", $iAdjustment) DllStructSetData($tEffectParameters, "Channel", $iChannel) DllStructSetData($tEffectParameters, "AdjustValue", $iAdjustValue) Local $hEffect = _GDIPlus_EffectCreate($GDIP_ColorCurveEffectGuid) If @error Then Return SetError(@error, @extended, 0) _GDIPlus_EffectSetParameters($hEffect, $tEffectParameters) If @error Then Return SetError(@error + 10, @extended, 0) Return $hEffect EndFunc Func _GDIPlus_EffectCreateColorLUT($aColorLUT) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, 0) Local $tEffectParameters = DllStructCreate($tagGDIP_EFFECTPARAMS_ColorLUT) For $iI = 0 To 255 DllStructSetData($tEffectParameters, "LutA", $aColorLUT[$iI][0], $iI + 1) DllStructSetData($tEffectParameters, "LutR", $aColorLUT[$iI][1], $iI + 1) DllStructSetData($tEffectParameters, "LutG", $aColorLUT[$iI][2], $iI + 1) DllStructSetData($tEffectParameters, "LutB", $aColorLUT[$iI][3], $iI + 1) Next Local $hEffect = _GDIPlus_EffectCreate($GDIP_ColorLUTEffectGuid) If @error Then Return SetError(@error, @extended, 0) _GDIPlus_EffectSetParameters($hEffect, $tEffectParameters) If @error Then Return SetError(@error + 10, @extended, 0) Return $hEffect EndFunc Func _GDIPlus_EffectCreateColorMatrix($tColorMatrix) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, 0) Local $hEffect = _GDIPlus_EffectCreate($GDIP_ColorMatrixEffectGuid) If @error Then Return SetError(@error, @extended, 0) _GDIPlus_EffectSetParameters($hEffect, $tColorMatrix) If @error Then Return SetError(@error + 10, @extended, 0) Return $hEffect EndFunc Func _GDIPlus_EffectCreateHueSaturationLightness($iHueLevel = 0, $iSaturationLevel = 0, $iLightnessLevel = 0) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, 0) Local $tEffectParameters = DllStructCreate($tagGDIP_EFFECTPARAMS_HueSaturationLightness) DllStructSetData($tEffectParameters, "HueLevel", $iHueLevel) DllStructSetData($tEffectParameters, "SaturationLevel", $iSaturationLevel) DllStructSetData($tEffectParameters, "LightnessLevel", $iLightnessLevel) Local $hEffect = _GDIPlus_EffectCreate($GDIP_HueSaturationLightnessEffectGuid) If @error Then Return SetError(@error, @extended, 0) _GDIPlus_EffectSetParameters($hEffect, $tEffectParameters) If @error Then Return SetError(@error + 10, @extended, 0) Return $hEffect EndFunc Func _GDIPlus_EffectCreateLevels($iHighlight = 100, $iMidtone = 0, $iShadow = 0) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, 0) Local $tEffectParameters = DllStructCreate($tagGDIP_EFFECTPARAMS_Levels) DllStructSetData($tEffectParameters, "Highlight", $iHighlight) DllStructSetData($tEffectParameters, "Midtone", $iMidtone) DllStructSetData($tEffectParameters, "Shadow", $iShadow) Local $hEffect = _GDIPlus_EffectCreate($GDIP_LevelsEffectGuid) If @error Then Return SetError(@error, @extended, 0) _GDIPlus_EffectSetParameters($hEffect, $tEffectParameters) If @error Then Return SetError(@error + 10, @extended, 0) Return $hEffect EndFunc Func _GDIPlus_EffectCreateRedEyeCorrection($aAreas) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, 0) Local $iCount = $aAreas[0][0] Local $tAreas = DllStructCreate("long[" & $iCount * 4 & "]") For $iI = 1 To $iCount DllStructSetData($tAreas, 1, DllStructSetData($tAreas, 1, $aAreas[$iI][0], (($iI - 1) * 4) + 1) + $aAreas[$iI][2], (($iI - 1) * 4) + 3) DllStructSetData($tAreas, 1, DllStructSetData($tAreas, 1, $aAreas[$iI][1], (($iI - 1) * 4) + 2) + $aAreas[$iI][3], (($iI - 1) * 4) + 4) Next Local $tEffectParameters = DllStructCreate($tagGDIP_EFFECTPARAMS_RedEyeCorrection) DllStructSetData($tEffectParameters, "NumberOfAreas", $iCount) DllStructSetData($tEffectParameters, "Areas", DllStructGetPtr($tAreas)) Local $hEffect = _GDIPlus_EffectCreate($GDIP_RedEyeCorrectionEffectGuid) If @error Then Return SetError(@error, @extended, 0) _GDIPlus_EffectSetParameters($hEffect, $tEffectParameters, (DllStructGetSize($tAreas) + DllStructGetSize($tEffectParameters)) / DllStructGetSize($tEffectParameters)) If @error Then Return SetError(@error + 10, @extended, 0) Return $hEffect EndFunc Func _GDIPlus_EffectCreateSharpen($fRadius = 10.0, $fAmount = 50.0) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, 0) Local $tEffectParameters = DllStructCreate($tagGDIP_EFFECTPARAMS_Sharpen) DllStructSetData($tEffectParameters, "Radius", $fRadius) DllStructSetData($tEffectParameters, "Amount", $fAmount) Local $hEffect = _GDIPlus_EffectCreate($GDIP_SharpenEffectGuid) If @error Then Return SetError(@error, @extended, 0) _GDIPlus_EffectSetParameters($hEffect, $tEffectParameters) If @error Then Return SetError(@error + 10, @extended, 0) Return $hEffect EndFunc Func _GDIPlus_EffectCreateTint($iHue = 0, $iAmount = 0) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, 0) Local $tEffectParameters = DllStructCreate($tagGDIP_EFFECTPARAMS_Tint) DllStructSetData($tEffectParameters, "Hue", $iHue) DllStructSetData($tEffectParameters, "Amount", $iAmount) Local $hEffect = _GDIPlus_EffectCreate($GDIP_TintEffectGuid) If @error Then Return SetError(@error, @extended, 0) _GDIPlus_EffectSetParameters($hEffect, $tEffectParameters) If @error Then Return SetError(@error + 10, @extended, 0) Return $hEffect EndFunc Func _GDIPlus_EffectDispose($hEffect) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, False) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipDeleteEffect", "handle", $hEffect) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_EffectGetParameters($hEffect, $tEffectParameters) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, False) If DllStructGetSize($tEffectParameters) < __GDIPlus_EffectGetParameterSize($hEffect) Then Return SetError(2, 5, False) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetEffectParameters", "handle", $hEffect, "uint*", DllStructGetSize($tEffectParameters), "struct*", $tEffectParameters) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func __GDIPlus_EffectGetParameterSize($hEffect) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, -1) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetEffectParameterSize", "handle", $hEffect, "uint*", 0) If @error Then Return SetError(@error, @extended, -1) If $aResult[0] Then Return SetError(10, $aResult[0], -1) Return $aResult[2] EndFunc Func _GDIPlus_EffectSetParameters($hEffect, $tEffectParameters, $iSizeAdjust = 1) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, False) Local $iSize = __GDIPlus_EffectGetParameterSize($hEffect) If @error Then Return SetError(@error, @extended, False) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetEffectParameters", "handle", $hEffect, "struct*", $tEffectParameters, "uint", $iSize * $iSizeAdjust) If @error Then Return SetError(@error, @extended, False) If $aResult[0] Then Return SetError(10, $aResult[0], False) Return True EndFunc Func _GDIPlus_PaletteInitialize($iEntries, $iPaletteType = $GDIP_PaletteTypeOptimal, $iOptimalColors = 0, $bUseTransparentColor = True, $hBitmap = Null) If $__g_bGDIP_V1_0 Then Return SetError(-1, 0, 0) If $iOptimalColors > 0 Then $iPaletteType = $GDIP_PaletteTypeOptimal Local $tPalette = DllStructCreate("uint Flags; uint Count; uint ARGB[" & $iEntries & "];") DllStructSetData($tPalette, "Flags", $iPaletteType) DllStructSetData($tPalette, "Count", $iEntries) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipInitializePalette", "struct*", $tPalette, "uint", $iPaletteType, "uint", $iOptimalColors, "bool", $bUseTransparentColor, "handle", $hBitmap) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $tPalette EndFunc Global Const $INET_LOCALCACHE = 0 Global Const $INET_FORCERELOAD = 1 Global Const $INET_IGNORESSL = 2 Global Const $INET_ASCIITRANSFER = 4 Global Const $INET_BINARYTRANSFER = 8 Global Const $INET_FORCEBYPASS = 16 Global Const $INET_DOWNLOADWAIT = 0 Global Const $INET_DOWNLOADBACKGROUND = 1 Global Const $INET_DOWNLOADREAD = 0 Global Const $INET_DOWNLOADSIZE = 1 Global Const $INET_DOWNLOADCOMPLETE = 2 Global Const $INET_DOWNLOADSUCCESS = 3 Global Const $INET_DOWNLOADERROR = 4 Global Const $INET_DOWNLOADEXTENDED = 5 Func _GetIP() Local Const $GETIP_TIMER = 300000 Local Static $hTimer = 0 Local Static $sLastIP = 0 If TimerDiff($hTimer) < $GETIP_TIMER And Not $sLastIP Then Return SetExtended(1, $sLastIP) EndIf Local $aGetIPURL = ["https://api.ipify.org", "http://checkip.dyndns.org", "http://www.myexternalip.com/raw", "http://bot.whatismyipaddress.com"], $aReturn = 0, $sReturn = "" For $i = 0 To UBound($aGetIPURL) - 1 $sReturn = InetRead($aGetIPURL[$i]) If @error Or $sReturn == "" Then ContinueLoop $aReturn = StringRegExp(BinaryToString($sReturn), "((?:\d{1,3}\.){3}\d{1,3})", $STR_REGEXPARRAYGLOBALMATCH) If Not @error Then $sReturn = $aReturn[0] ExitLoop EndIf $sReturn = "" Next $hTimer = TimerInit() $sLastIP = $sReturn If $sReturn == "" Then Return SetError(1, 0, -1) Return $sReturn EndFunc Func _INetExplorerCapable($sIEString) If StringLen($sIEString) <= 0 Then Return SetError(1, 0, '') Local $s_IEReturn Local $n_IEChar For $i_IECount = 1 To StringLen($sIEString) $n_IEChar = '0x' & Hex(Asc(StringMid($sIEString, $i_IECount, 1)), 2) If $n_IEChar < 0x21 Or $n_IEChar = 0x25 Or $n_IEChar = 0x2f Or $n_IEChar > 0x7f Then $s_IEReturn = $s_IEReturn & '%' & StringRight($n_IEChar, 2) Else $s_IEReturn = $s_IEReturn & Chr($n_IEChar) EndIf Next Return $s_IEReturn EndFunc Func _INetGetSource($sURL, $bString = True) Local $sString = InetRead($sURL, $INET_FORCERELOAD) Local $iError = @error, $iExtended = @extended If $bString = Default Or $bString Then $sString = BinaryToString($sString) Return SetError($iError, $iExtended, $sString) EndFunc Func _INetMail($sMailTo, $sMailSubject, $sMailBody) Local $iPrev = Opt("ExpandEnvStrings", 1) Local $sVar, $sDflt = RegRead('HKCU\Software\Clients\Mail', "") If $sDflt = "Windows Live Mail" Then $sVar = RegRead('HKCR\WLMail.Url.Mailto\Shell\open\command', "") Else $sVar = RegRead('HKCR\mailto\shell\open\command', "") EndIf Local $iRet = Run(StringReplace($sVar, '%1', _INetExplorerCapable('mailto:' & $sMailTo & '?subject=' & $sMailSubject & '&body=' & $sMailBody))) Local $iError = @error, $iExtended = @extended Opt("ExpandEnvStrings", $iPrev) Return SetError($iError, $iExtended, $iRet) EndFunc Func _INetSmtpMail($sSMTPServer, $sFromName, $sFromAddress, $sToAddress, $sSubject = "", $aBody = "", $sEHLO = "", $sFirst = "", $bTrace = 0) If $sSMTPServer = "" Or $sFromAddress = "" Or $sToAddress = "" Or $sFromName = "" Or StringLen($sFromName) > 256 Then Return SetError(1, 0, 0) If $sEHLO = "" Then $sEHLO = @ComputerName If TCPStartup() = 0 Then Return SetError(2, 0, 0) Local $s_IPAddress, $i_Count If StringRegExp($sSMTPServer, "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$") Then $s_IPAddress = $sSMTPServer Else $s_IPAddress = TCPNameToIP($sSMTPServer) EndIf If $s_IPAddress = "" Then TCPShutdown() Return SetError(3, 0, 0) EndIf Local $vSocket = TCPConnect($s_IPAddress, 25) If $vSocket = -1 Then TCPShutdown() Return SetError(4, 0, 0) EndIf Local $aSend[6], $aReplyCode[6] $aSend[0] = "HELO " & $sEHLO & @CRLF If StringLeft($sEHLO, 5) = "EHLO " Then $aSend[0] = $sEHLO & @CRLF $aReplyCode[0] = "250" $aSend[1] = "MAIL FROM: <" & $sFromAddress & ">" & @CRLF $aReplyCode[1] = "250" $aSend[2] = "RCPT TO: <" & $sToAddress & ">" & @CRLF $aReplyCode[2] = "250" $aSend[3] = "DATA" & @CRLF $aReplyCode[3] = "354" Local $aResult = _Date_Time_GetTimeZoneInformation() Local $iBias = -$aResult[1] / 60 Local $iBiasH = Int($iBias) Local $iBiasM = 0 If $iBiasH <> $iBias Then $iBiasM = Abs($iBias - $iBiasH) * 60 $iBias = StringFormat(" (%+.2d%.2d)", $iBiasH, $iBiasM) $aSend[4] = "From:" & $sFromName & "<" & $sFromAddress & ">" & @CRLF & "To:" & "<" & $sToAddress & ">" & @CRLF & "Subject:" & $sSubject & @CRLF & "Mime-Version: 1.0" & @CRLF & "Date: " & _DateDayOfWeek(@WDAY, 1) & ", " & @MDAY & " " & _DateToMonth(@MON, 1) & " " & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & $iBias & @CRLF & "Content-Type: text/plain; charset=US-ASCII" & @CRLF & @CRLF $aReplyCode[4] = "" $aSend[5] = @CRLF & "." & @CRLF $aReplyCode[5] = "250" If __SmtpSend($vSocket, $aSend[0], $aReplyCode[0], $bTrace, "220", $sFirst) Then Return SetError(50, 0, 0) For $i_Count = 1 To UBound($aSend) - 2 If __SmtpSend($vSocket, $aSend[$i_Count], $aReplyCode[$i_Count], $bTrace) Then Return SetError(50 + $i_Count, 0, 0) Next For $i_Count = 0 To UBound($aBody) - 1 If StringLeft($aBody[$i_Count], 1) = "." Then $aBody[$i_Count] = "." & $aBody[$i_Count] If __SmtpSend($vSocket, $aBody[$i_Count] & @CRLF, "", $bTrace) Then Return SetError(500 + $i_Count, 0, 0) Next $i_Count = UBound($aSend) - 1 If __SmtpSend($vSocket, $aSend[$i_Count], $aReplyCode[$i_Count], $bTrace) Then Return SetError(5000, 0, 0) TCPCloseSocket($vSocket) TCPShutdown() Return 1 EndFunc Func __SmtpTrace($sStr, $iTimeout = 0) Local $sW_TITLE = "SMTP trace" Local $sSmtpTrace = ControlGetText($sW_TITLE, "", "Static1") $sStr = StringLeft(StringReplace($sStr, @CRLF, ""), 70) $sSmtpTrace &= @HOUR & ":" & @MIN & ":" & @SEC & " " & $sStr & @LF If WinExists($sW_TITLE) Then ControlSetText($sW_TITLE, "", "Static1", $sSmtpTrace) Else SplashTextOn($sW_TITLE, $sSmtpTrace, 400, 500, 500, 100, 4 + 16, "", 8) EndIf If $iTimeout Then Sleep($iTimeout * 1000) EndFunc Func __SmtpSend($vSocket, $sSend, $sReplyCode, $bTrace, $sIntReply = "", $sFirst = "") Local $sReceive, $i, $hTimer If $bTrace Then __SmtpTrace($sSend) If $sIntReply <> "" Then If $sFirst <> -1 Then If TCPSend($vSocket, $sFirst) = 0 Then TCPCloseSocket($vSocket) TCPShutdown() Return 1 EndIf EndIf $sReceive = "" $hTimer = TimerInit() While StringLeft($sReceive, StringLen($sIntReply)) <> $sIntReply And TimerDiff($hTimer) < 45000 $sReceive = TCPRecv($vSocket, 1000) If $bTrace And $sReceive <> "" Then __SmtpTrace("intermediate->" & $sReceive) WEnd EndIf If TCPSend($vSocket, $sSend) = 0 Then TCPCloseSocket($vSocket) TCPShutdown() Return 1 EndIf $hTimer = TimerInit() $sReceive = "" While $sReceive = "" And TimerDiff($hTimer) < 45000 $i += 1 $sReceive = TCPRecv($vSocket, 1000) If $sReplyCode = "" Then ExitLoop WEnd If $sReplyCode <> "" Then If $bTrace Then __SmtpTrace($i & " <- " & $sReceive) If StringLeft($sReceive, StringLen($sReplyCode)) <> $sReplyCode Then TCPCloseSocket($vSocket) TCPShutdown() If $bTrace Then __SmtpTrace("<-> " & $sReplyCode, 5) Return 2 EndIf EndIf Return 0 EndFunc Func _TCPIpToName($sIp, $iOption = Default, $hDll = Default) Local $iINADDR_NONE = 0xffffffff, $iAF_INET = 2, $sSeparator = @CR If $iOption = Default Then $iOption = 0 If $hDll = Default Then $hDll = "ws2_32.dll" Local $avDllCall = DllCall($hDll, "ulong", "inet_addr", "STR", $sIp) If @error Then Return SetError(1, 0, "") Local $vBinIP = $avDllCall[0] If $vBinIP = $iINADDR_NONE Then Return SetError(2, 0, "") $avDllCall = DllCall($hDll, "ptr", "gethostbyaddr", "ptr*", $vBinIP, "int", 4, "int", $iAF_INET) If @error Then Return SetError(3, 0, "") Local $pvHostent = $avDllCall[0] If $pvHostent = 0 Then $avDllCall = DllCall($hDll, "int", "WSAGetLastError") If @error Then Return SetError(5, 0, "") Return SetError(4, $avDllCall[0], "") EndIf Local $tHostent = DllStructCreate("ptr;ptr;short;short;ptr", $pvHostent) Local $sHostnames = __TCPIpToName_szStringRead(DllStructGetData($tHostent, 1)) If @error Then Return SetError(6, 0, $sHostnames) If $iOption = 1 Then Local $tAliases $sHostnames &= $sSeparator For $i = 0 To 63 $tAliases = DllStructCreate("ptr", DllStructGetData($tHostent, 2) + ($i * 4)) If DllStructGetData($tAliases, 1) = 0 Then ExitLoop $sHostnames &= __TCPIpToName_szStringRead(DllStructGetData($tAliases, 1)) If @error Then SetError(7) ExitLoop EndIf Next Return StringSplit(StringStripWS($sHostnames, $STR_STRIPTRAILING), @CR) Else Return $sHostnames EndIf EndFunc Func __TCPIpToName_szStringRead($pStr, $iLen = -1) Local $tString If $pStr < 1 Then Return "" If $iLen < 0 Then $iLen = _WinAPI_StrLen($pStr, False) $tString = DllStructCreate("char[" & $iLen & "]", $pStr) If @error Then Return SetError(2, 0, "") Return SetExtended($iLen, DllStructGetData($tString, 1)) EndFunc #Region #AutoIt3Wrapper_Icon=Resources\phoenixtray.ico #AutoIt3Wrapper_Outfile=Builds\UniFiCameraImageArchiverFTPUploader_v1.0.exe #AutoIt3Wrapper_Res_Comment=UniFi Camera Image Archiver & FTP Uploader by Phoenix125.com #AutoIt3Wrapper_Res_Description=UniFi Camera Image Archiver & FTP Uploader #AutoIt3Wrapper_Res_Fileversion=1.0 #AutoIt3Wrapper_Res_ProductName=UniFi Camera Image Archiver & FTP Uploader #AutoIt3Wrapper_Res_ProductVersion=1.0 #AutoIt3Wrapper_Res_CompanyName=http://www.Phoenix125.com #AutoIt3Wrapper_Res_LegalCopyright=http://www.Phoenix125.com #AutoIt3Wrapper_Res_Language=1033 #AutoIt3Wrapper_Run_AU3Check=n #AutoIt3Wrapper_Run_Tidy=y #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/mo #EndRegion Local $tExit = False Global $aUtilName = "UniFiCameraImageArchiverFTPUploader" Global $aUtilVersion = "v1.0" Global $aIniFile = @ScriptDir & "\" & $aUtilName & ".ini" Global $aFolderTemp = "" Global $aUtilUpdateLinkVer = "http://www.phoenix125.com/share/" & StringLower($aUtilName) & "/latestver.txt" Global $aUtilUpdateLinkDL = "http://www.phoenix125.com/share/" & StringLower($aUtilName) & "/" & $aUtilName & ".zip" Global $aUtilReadMeLink = "http://www.phoenix125.com/share/" & StringLower($aUtilName) & "/ReadMe.pdf" Global $aUtilUpdateFile = @ScriptDir & "\__UTIL_UPDATE_AVAILABLE___.txt" Global $cIntervalGetImage = _NowCalc() Global $cIntervalFTP = _NowCalc() Global $cIntervalSave = _NowCalc() Global $aStartText = $aUtilName & " " & $aUtilVersion & " starting . . ." & @CRLF & @CRLF Global $aSplash = _Splash($aStartText, 0, 475) ControlSetText($aSplash, "", "Static1", $aStartText & "Creating startup batch file") CreateStartupBatchFile() ControlSetText($aSplash, "", "Static1", $aStartText & "Importing config settings") Local $tChanged = ReadIni() If $aLogLevel < 3 Then LogWrite("----- ===== " & $aUtilName & " started ===== -----") ControlSetText($aSplash, "", "Static1", $aStartText & "Creating tray icon menu") Opt("TrayMenuMode", 3) Opt("TrayOnEventMode", 1) Local $iTrayVersion = TrayCreateItem($aUtilName & " " & $aUtilVersion) TrayItemSetOnEvent(-1, "TrayAbout") TrayCreateItem("") Local $iTrayAbout = TrayCreateItem("About") TrayItemSetOnEvent(-1, "TrayAbout") Local $iTrayUpdateUtilCheck = TrayCreateItem("Check for Update") TrayItemSetOnEvent(-1, "TrayUpdateUtilCheck") Local $iTrayUpdateUtilCheck = TrayCreateItem("Restart") TrayItemSetOnEvent(-1, "TrayRestartUtil") Local $iTrayUpdateUtilCheck = TrayCreateItem("Open ReadMe") TrayItemSetOnEvent(-1, "TrayOpenReadMe") TrayCreateItem("") Local $iTrayExitCloseN = TrayCreateItem("Open LOG (Latest)") TrayItemSetOnEvent(-1, "TrayOpenLog") Local $iTrayExitCloseN = TrayCreateItem("Open CONFIG") TrayItemSetOnEvent(-1, "TrayOpenConfig") Local $iTrayExitCloseN = TrayCreateItem("Open IMAGE folder") TrayItemSetOnEvent(-1, "TrayOpenImageFolder") TrayCreateItem("") Local $iTrayUpdateUtilPause = TrayCreateItem("Pause") TrayItemSetOnEvent(-1, "TrayUpdatePause") TrayCreateItem("") Local $iTrayExitCloseY = TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "TrayExit") ControlSetText($aSplash, "", "Static1", $aStartText & "Saving config settings") WriteINI() If $tChanged = "new" Then ShellExecute($aIniFile) Sleep(1000) SplashOff() MsgBox(0, $aUtilName, "Welcome! Please make changes to the " & $aUtilName & ".ini file.") _ExitUtil() ElseIf $tChanged = "changed" Then ReadIni() WriteINI() ShellExecute($aIniFile) Sleep(1000) SplashOff() MsgBox(0, $aUtilName, "Number of cameras changed in config. Please make changes to the " & $aUtilName & ".ini file.") _ExitUtil() EndIf ControlSetText($aSplash, "", "Static1", $aStartText & "Checking for updates") If $aUtilCheckForUpdateYN <> "no" Then UtilUpdate($aUtilUpdateLinkVer, $aUtilUpdateLinkDL, $aUtilVersion, $aUtilName, $aSplash, "show", "yes") Else FileDelete($aUtilUpdateFile) EndIf Local $tDiffSave = True Local $tDiffFTP = True Local $tDiffGetImage = True Local $tErrorImageSave = False Local $tGetImageInterval = 0 Local $xFileName1 = "" Local $tDiffSec = "" Local $cTimerGetImage = TimerInit() Local $cTimerRestartSave = TimerInit() Local $cTimerRestartFTP = TimerInit() Local $cTimerIniChanges = TimerInit() If $aIntervalSave <= $aIntervalFTP Then $tGetImageInterval = $aIntervalSave Else $tGetImageInterval = $aIntervalFTP EndIf ControlSetText($aSplash, "", "Static1", $aStartText & "Startup complete.") Sleep(2500) SplashOff() FileDelete($aFolderTemp & $aUtilName & "_Delay_Restart.bat") Do If TimerDiff($cTimerRestartSave) > $aIntervalSave * 1000 Then $cTimerRestartSave = TimerInit() $tDiffSave = True EndIf If TimerDiff($cTimerRestartFTP) > $aIntervalFTP * 1000 Then $tDiffFTP = True $cTimerRestartFTP = TimerInit() EndIf If TimerDiff($cTimerGetImage) > $tGetImageInterval * 1000 Then $tDiffGetImage = True $cTimerGetImage = TimerInit() EndIf If $tDiffGetImage Then $tDiffGetImage = False For $x = 0 To (UBound($xFileNameOriginal) - 1) Local $tImageSize = 0 Local $sFile = $aFolderImage & $xFileNameOriginal[$x] Local $tGet = InetGet($xURL[$x], $sFile, $INET_FORCERELOAD) Local $tImageSize = FileGetSize($sFile) If $tImageSize < 10000 Then $tErrorImageSave = True If $aLogLevel < 3 Then LogWrite("[ERROR] File failed to download from camera:" & $xURL[$x]) Else $tErrorImageSave = False If $xResizeImageSize[$x] <> "" Then Local $xImageSplit = StringSplit($xResizeImageSize[$x], "x", 2) Local $tResizeX = Abs($xImageSplit[0]) Local $tResizeY = Abs($xImageSplit[1]) _ImageResizer($sFile, $aFolderImage & $xFileNameResized[$x], $tResizeX, $tResizeY) EndIf EndIf Next EndIf If $tDiffSave And $tErrorImageSave = False Then $tDiffSave = False For $x = 0 To (UBound($xFileNameOriginal) - 1) If StringInStr($xSaveType[$x], "B") Or StringInStr($xSaveType[$x], "F") Then Local $xFileNameSplit = _PathSplit($aFolderImage & $xFileNameOriginal[$x], "", "", "", "") Local $tFileNameSave = $xFileNameSplit[3] & "_" & @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & @MIN & @SEC & $xFileNameSplit[4] DirCreate($aFolderImage & $xFileNameSplit[3]) FileCopy($aFolderImage & $xFileNameOriginal[$x], $aFolderImage & $xFileNameSplit[3] & "\" & $tFileNameSave) EndIf If (StringInStr($xSaveType[$x], "B") Or StringInStr($xSaveType[$x], "R")) And $xResizeImageSize[$x] <> "" Then Local $xFileNameSplit = _PathSplit($aFolderImage & $xFileNameResized[$x], "", "", "", "") Local $tFileNameSave = $xFileNameSplit[3] & "_" & @YEAR & "-" & @MON & "-" & @MDAY & "_" & @HOUR & @MIN & @SEC & $xFileNameSplit[4] FileCopy($aFolderImage & $xFileNameResized[$x], $aFolderImage & $xFileNameSplit[3] & "\" & $tFileNameSave) EndIf Next EndIf If $tDiffFTP And $tErrorImageSave = False Then $tDiffFTP = False For $x = 0 To (UBound($xFileNameOriginal) - 1) Local $tTimerUpload = TimerInit() If (StringInStr($xFTPUploadType[$x], "B") Or StringInStr($xFTPUploadType[$x], "F")) Then Local $tError = FTPFiles($aFolderImage & $xFileNameOriginal[$x], $xFTPFolder[$x], $xFTPURL[$x], $xUserID[$x], $xPwd[$x]) $tDiffSec = StringFormat("%.2f", TimerDiff($tTimerUpload) / 1000, 2) If $tError = 0 Then If $aLogLevel = 1 Then LogWrite("[OK] Code[" & $tError & "] Time[" & $tDiffSec & "s] Upload successful [" & $xFileNameOriginal[$x] & "] FTP[" & $xFTPURL[$x] & "] UserID[" & $xUserID[$x] & "] Pwd[" & $xPwd[$x] & "]") Else If $aLogLevel < 3 Then LogWrite("[ERROR] Code[" & $tError & "] Time[" & $tDiffSec & "s] Upload FAILED. [" & $xFileNameOriginal[$x] & "] FTP[" & $xFTPURL[$x] & "] UserID[" & $xUserID[$x] & "] Pwd[" & $xPwd[$x] & "]") EndIf EndIf If (StringInStr($xFTPUploadType[$x], "B") Or StringInStr($xFTPUploadType[$x], "R")) And $xResizeImageSize[$x] <> "" Then Local $tError = FTPFiles($aFolderImage & $xFileNameResized[$x], $xFTPFolder[$x], $xFTPURL[$x], $xUserID[$x], $xPwd[$x]) $tDiffSec = StringFormat("%.2f", TimerDiff($tTimerUpload) / 1000, 2) If $tError = 0 Then If $aLogLevel = 1 Then LogWrite("[OK] Code[" & $tError & "] Time[" & $tDiffSec & "s] Upload successful [" & $xFileNameResized[$x] & "] FTP[" & $xFTPURL[$x] & "] UserID[" & $xUserID[$x] & "] Pwd[" & $xPwd[$x] & "]") Else If $aLogLevel < 3 Then LogWrite("[ERROR] Code[" & $tError & "] Time[" & $tDiffSec & "s] Upload FAILED. [" & $xFileNameResized[$x] & "] FTP[" & $xFTPURL[$x] & "] UserID[" & $xUserID[$x] & "] Pwd[" & $xPwd[$x] & "]") EndIf EndIf Next EndIf Sleep(100) Until $tExit Func ReadIni() Local $tChanged = "nope" Local $iniCheck = "" Local $aChar[3] For $i = 1 To 13 $aChar[0] = Chr(Random(97, 122, 1)) $aChar[1] = Chr(Random(48, 57, 1)) $iniCheck &= $aChar[Random(0, 1, 1)] Next Global $aNumberOfEntries = IniRead($aIniFile, " --------------- " & StringUpper($aUtilName) & " --------------- ", "Number of cameras/files to manage (1-100) ###", $iniCheck) Global $aIntervalFTP = IniRead($aIniFile, " --------------- " & StringUpper($aUtilName) & " OPTIONS --------------- ", "Number of seconds between FTP uploads (5-86400) ###", "60") Global $aIntervalSave = IniRead($aIniFile, " --------------- " & StringUpper($aUtilName) & " OPTIONS --------------- ", "Number of seconds between archive images (5-86400) ###", "60") Global $aFolderLog = IniRead($aIniFile, " --------------- " & StringUpper($aUtilName) & " OPTIONS --------------- ", "Log folder ###", @ScriptDir & "\Logs\") Global $aFolderImage = IniRead($aIniFile, " --------------- " & StringUpper($aUtilName) & " OPTIONS --------------- ", "Images folder ###", @ScriptDir & "\Images\") Global $aLogLevel = IniRead($aIniFile, " --------------- " & StringUpper($aUtilName) & " OPTIONS --------------- ", "Log Level 1-All, 2-Fails, 3-None (1-3) ###", "1") Global $aUtilCheckForUpdateYN = IniRead($aIniFile, " --------------- " & StringUpper($aUtilName) & " OPTIONS --------------- ", "Check for updates at program start? (yes/no) ###", "yes") Global $aPreviousNumberOfEntries = IniRead($aIniFile, " --------------- " & StringUpper($aUtilName) & " OPTIONS --------------- ", "System Use: Previous number of entries ###", "0") If $aNumberOfEntries = $iniCheck Then $aNumberOfEntries = 1 $tChanged = "new" Else If $aNumberOfEntries <> $aPreviousNumberOfEntries Then $tChanged = "changed" EndIf If $aNumberOfEntries < 1 Then $aNumberOfEntries = 1 If $aNumberOfEntries > 100 Then $aNumberOfEntries = 100 If $aIntervalFTP < 5 Then $aIntervalFTP = 5 If $aIntervalFTP > 86400 Then $aIntervalFTP = 86400 If $aIntervalSave < 5 Then $aIntervalSave = 5 If $aIntervalSave > 86400 Then $aIntervalSave = 86400 If $aLogLevel < 1 Then $aLogLevel = 1 If $aLogLevel > 3 Then $aLogLevel = 3 DirCreate($aFolderLog) DirCreate($aFolderImage) Global $xNotes[$aNumberOfEntries] Global $xURL[$aNumberOfEntries] Global $xFileNameOriginal[$aNumberOfEntries] Global $xFileNameResized[$aNumberOfEntries] Global $xUserID[$aNumberOfEntries] Global $xPwd[$aNumberOfEntries] Global $xFTPURL[$aNumberOfEntries] Global $xFTPFolder[$aNumberOfEntries] Global $xResizeImageSize[$aNumberOfEntries] Global $xSaveType[$aNumberOfEntries] Global $xFTPUploadType[$aNumberOfEntries] For $x = 0 To ($aNumberOfEntries - 1) $xNotes[$x] = IniRead($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "Note (optional for comment in this config file) ###", "") $xURL[$x] = IniRead($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "Image URL from camera (ex. http://192.168.1.5/snap.jpeg) ###", "http://192.168.1.5/snap.jpeg") $xFileNameOriginal[$x] = IniRead($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "Full-size image filename (ex. camerawest.jpg) ###", "camera" & $x + 1 & ".jpg") $xFileNameResized[$x] = IniRead($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "Resized image filename (leave blank if not resizing image) ###", "") $xFTPURL[$x] = IniRead($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "FTP URL (for Wunderground, use webcam.wunderground.com) ###", "webcam.wunderground.com") $xFTPFolder[$x] = IniRead($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "FTP folder (for Wunderground, leave blank) ###", "") $xUserID[$x] = IniRead($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "FTP userName (for Wunderground, use camera ID, ex. WU_7883133CAM3) ###", "") $xPwd[$x] = IniRead($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "FTP password (for Wunderground, use key, ex. QqOQqKRy) ###", "") $xResizeImageSize[$x] = IniRead($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "Resize image size: Leave blank to disable (ex. 1280x720) ###", "") $xSaveType[$x] = IniRead($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "Archive image: (F)ull-size (R)esized (B)oth (N)one (FRBN)###", "B") $xFTPUploadType[$x] = IniRead($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "FTP Upload image: (F)ull-size (R)esized (B)oth (N)one (FRBN)###", "R") If $xResizeImageSize[$x] <> "" Then Local $xImageSplit = StringSplit($xResizeImageSize[$x], "x", 2) If StringInStr($xResizeImageSize[$x], "x") = 0 Or UBound($xImageSplit) <> 2 Then LogWrite("[Error] Resize image dimension for camera " & $x + 1 & " formated improperly. [" & $xResizeImageSize[$x] & "]") EndIf Next Return $tChanged EndFunc Func WriteINI() FileDelete($aIniFile) IniWrite($aIniFile, " --------------- " & StringUpper($aUtilName) & " --------------- ", "Number of cameras/files to manage (1-100) ###", $aNumberOfEntries) FileWriteLine($aIniFile, "(Changes to the number above will require restarting the program so that it can add or remove entries)") FileWriteLine($aIniFile, "") IniWrite($aIniFile, " --------------- " & StringUpper($aUtilName) & " OPTIONS --------------- ", "Number of seconds between FTP uploads (5-86400) ###", $aIntervalFTP) IniWrite($aIniFile, " --------------- " & StringUpper($aUtilName) & " OPTIONS --------------- ", "Number of seconds between archive images (5-86400) ###", $aIntervalSave) IniWrite($aIniFile, " --------------- " & StringUpper($aUtilName) & " OPTIONS --------------- ", "Log folder ###", $aFolderLog) IniWrite($aIniFile, " --------------- " & StringUpper($aUtilName) & " OPTIONS --------------- ", "Images folder ###", $aFolderImage) IniWrite($aIniFile, " --------------- " & StringUpper($aUtilName) & " OPTIONS --------------- ", "Log Level 1-All, 2-Fails, 3-None (1-3) ###", $aLogLevel) IniWrite($aIniFile, " --------------- " & StringUpper($aUtilName) & " OPTIONS --------------- ", "Check for updates at program start? (yes/no) ###", $aUtilCheckForUpdateYN) IniWrite($aIniFile, " --------------- " & StringUpper($aUtilName) & " OPTIONS --------------- ", "System Use: Previous number of entries ###", $aNumberOfEntries) For $x = 0 To ($aNumberOfEntries - 1) FileWriteLine($aIniFile, "") IniWrite($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "Note (optional for comment in this config file) ###", $xNotes[$x]) IniWrite($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "Image URL from camera (ex. http://192.168.1.5/snap.jpeg) ###", $xURL[$x]) IniWrite($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "Full-size image filename (ex. camerawest.jpg) ###", $xFileNameOriginal[$x]) IniWrite($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "Resized image filename (leave blank if not resizing image) ###", $xFileNameResized[$x]) IniWrite($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "FTP URL (for Wunderground, use webcam.wunderground.com) ###", $xFTPURL[$x]) IniWrite($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "FTP folder (for Wunderground, leave blank) ###", $xFTPFolder[$x]) IniWrite($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "FTP userName (for Wunderground, use camera ID, ex. WU_7883133CAM3) ###", $xUserID[$x]) IniWrite($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "FTP password (for Wunderground, use key, ex. QqOQqKRy) ###", $xPwd[$x]) IniWrite($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "Resize image size: Leave blank to disable (ex. 1280x720) ###", $xResizeImageSize[$x]) IniWrite($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "Archive image: (F)ull-size (R)esized (B)oth (N)one (FRBN)###", $xSaveType[$x]) IniWrite($aIniFile, " --------------- CAMERA " & $x + 1 & " --------------- ", "FTP Upload image: (F)ull-size (R)esized (B)oth (N)one (FRBN)###", $xFTPUploadType[$x]) Next EndFunc Func FTPFiles($tFile, $tFTP_Folder, $tFTP_URL, $tFTP_UserName, $tFPT_Pwd) Local $hFTPOpen = _FTP_Open("website") Local $hFTPConn = _FTP_Connect($hFTPOpen, $tFTP_URL, $tFTP_UserName, $tFPT_Pwd) Local $hFTPDir = _FTP_DirSetCurrent($hFTPConn, $tFTP_Folder) Local $xFileName = _PathSplit($tFile, "", "", "", "") Local $tFileName = $xFileName[3] & $xFileName[4] _FTP_FilePut($hFTPConn, $tFile, $tFileName) Local $tERR = @error $tFTPClose = _FTP_Close($hFTPOpen) Return $tERR EndFunc Func LogWrite($Msg, $msgdebug = -1) $aLogFile = $aFolderLog & $aUtilName & "_Log_" & @YEAR & "-" & @MON & "-" & @MDAY & ".txt" Local $tFileSize = FileGetSize($aLogFile) If $tFileSize > 10000000 Then FileMove($aLogFile, $aFolderLog & $aUtilName & "_Log_" & @YEAR & "-" & @MON & "-" & @MDAY & "-Part1.txt") FileWriteLine($aLogFile, _NowCalc() & " Log File Split. First file:" & $aFolderLog & $aUtilName & "_Log_" & @YEAR & "-" & @MON & "-" & @MDAY & "-Part1.txt") EndIf If $tFileSize > 10000000 Then FileWriteLine($aLogFile, _NowCalc() & " Log File Split. First file:" & $aFolderLog & $aUtilName & "_LogFull_" & @YEAR & "-" & @MON & "-" & @MDAY & "-Part1.txt") If $Msg <> "" Then FileWriteLine($aLogFile, _NowCalc() & " " & $Msg) EndFunc Func _ImageResizer($tFileBefore, $tFileAfter, $tWidth = 16, $tHeight = 16) _GDIPlus_Startup() Local $GDIpBmpLarge, $GDIpBmpResized, $GDIbmp $GDIpBmpLarge = _GDIPlus_ImageLoadFromFile($tFileBefore) $GDIpBmpResized = _GDIPlus_ImageResize($GDIpBmpLarge, $tWidth, $tHeight) _GDIPlus_ImageSaveToFile($GDIpBmpResized, $tFileAfter) _GDIPlus_ImageDispose($GDIpBmpLarge) _GDIPlus_ImageDispose($GDIpBmpResized) _GDIPlus_Shutdown() EndFunc Func _RestartProgram() If @Compiled = 1 Then Run(FileGetShortName(@ScriptFullPath)) Else Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)) EndIf Exit EndFunc Func _Splash($tTxt, $tTime = 0, $tWidth = 400, $tHeight = 125) Local $tPID = SplashTextOn($aUtilName, $tTxt, $tWidth, $tHeight, -1, -1, $DLG_MOVEABLE, "") If $tTime > 0 Then Sleep($tTime) SplashOff() EndIf Return $tPID EndFunc Func TrayAbout() MsgBox($MB_SYSTEMMODAL, $aUtilName, $aUtilName & @CRLF & "Version: " & $aUtilVersion & @CRLF & @CRLF & "Install Path: " & @ScriptDir & @CRLF & @CRLF & "Discord: http://discord.gg/EU7pzPs" & @CRLF & "Website: http://www.phoenix125.com", 15) EndFunc Func TrayUpdateUtilCheck() UtilUpdate($aUtilUpdateLinkVer, $aUtilUpdateLinkDL, $aUtilVersion, $aUtilName, 0, "show") SplashOff() EndFunc Func TrayRestartUtil() _RestartUtil() EndFunc Func TrayOpenReadMe() ShellExecute($aUtilReadMeLink) EndFunc Func TrayOpenLog() ShellExecute($aFolderLog & $aUtilName & "_Log_" & @YEAR & "-" & @MON & "-" & @MDAY & ".txt") EndFunc Func TrayOpenConfig() ShellExecute($aIniFile) EndFunc Func TrayOpenImageFolder() ShellExecute($aFolderImage) EndFunc Func TrayUpdatePause() MsgBox($MB_OK, $aUtilName, $aUtilName & " Paused. Press OK to resume.") EndFunc Func TrayExit() LogWrite("----- ===== " & $aUtilName & " exited ===== -----") MsgBox(0, $aUtilName, "For more programs, visit phoenix125.com" & @CRLF & "Thank you!", 10) Exit EndFunc Func CreateStartupBatchFile() Global $aServerBatchFile = @ScriptDir & "\_start_" & $aUtilName & ".bat" If @AutoItX64 = 1 Then Global $aUtilExe = $aUtilName & "_" & $aUtilVersion & "_64-bit(x64).exe" Else Global $aUtilExe = $aUtilName & "_" & $aUtilVersion & ".exe" EndIf FileDelete($aServerBatchFile) FileWrite($aServerBatchFile, '@echo off' & @CRLF & 'START "' & $aUtilName & '" "' & @ScriptDir & '\' & $aUtilExe & '"' & @CRLF & "EXIT") EndFunc Func _RestartUtil($fQuickRebootTF = True, $tAdmin = False) Local $Pid Local $xArray[13] $xArray[0] = '@echo off' $xArray[1] = 'echo --------------------------------------------' $xArray[2] = 'echo Waiting 5 seconds for shutdown to complete' $xArray[3] = 'echo --------------------------------------------' $xArray[4] = 'timeout 5' $xArray[5] = 'start "Starting ' & $aUtilName & '" "' & $aServerBatchFile & '"' $xArray[6] = 'echo --------------------------------------------' $xArray[7] = 'echo ' & $aUtilName & ' started . . .' $xArray[8] = 'echo --------------------------------------------' $xArray[9] = 'timeout 3' $xArray[10] = 'exit' Local $tBatFile = $aFolderTemp & $aUtilName & "_Delay_Restart.bat" FileDelete($tBatFile) _FileWriteFromArray($tBatFile, $xArray) If @Compiled Then If $tAdmin Then ShellExecute($tBatFile, "", "", "runas") Else $Pid = Run($tBatFile, "", @SW_HIDE) EndIf Else If $tAdmin Then _Splash("Run as administrator selected", 2000) ShellExecute(@AutoItExe & ' "' & @ScriptFullPath & '" ' & $CmdLineRaw, "", "", "runas") Else $Pid = Run(@AutoItExe & ' "' & @ScriptFullPath & '" ' & $CmdLineRaw, @ScriptDir, Default, 1) EndIf If @error Then Return SetError(@error, 0, 0) EndIf StdinWrite($Pid, @AutoItPID) EndIf Sleep(50) _ExitUtil() EndFunc Func _ExitUtil() Exit EndFunc Func UtilUpdate($tLink, $tDL, $tUtil, $tUtilName, $tSplash = 0, $tUpdate = "show", $tShowStartupTextYN = "no") $tUtilUpdateAvailableTF = False If $tUpdate = "show" Then If $tShowStartupTextYN = "yes" Then Local $tTxt = $aStartText & "Checking for updates." Else Local $tTxt = "Checking for updates." EndIf If $tSplash > 0 Then ControlSetText($tSplash, "", "Static1", $tTxt) Else $tSplash = _Splash($tTxt) EndIf EndIf Local $tVer[2] Local $sFilePath = $aFolderTemp & $aUtilName & "_latest_ver.tmp" $iGet = _InetGetMulti(20, $sFilePath, $tLink) If $iGet = "Error" Then LogWrite(" [Util] Update check failed to download latest version: " & $tLink) If $tUpdate = "show" Then If $tShowStartupTextYN = "yes" Then Local $tTxt = $aStartText & "Update check failed." & @CRLF & "Please try again later." Else Local $tTxt = "Update check failed." & @CRLF & "Please try again later." EndIf If $tSplash > 0 Then ControlSetText($tSplash, "", "Static1", $tTxt) Else _Splash($tTxt) EndIf Sleep(4000) EndIf Else $tVer = StringSplit($iGet, "^", 2) If UBound($tVer) < 2 Then Return False Local $tTxt1 = ReplaceCRLF(ReplaceCRwithCRLF($tVer[1])) If $tVer[0] = $tUtil Then $tUtilUpdateAvailableTF = False LogWrite(" [Util] " & $tUtilName & " up to date. Version: " & $tVer[0], " [Util] " & $tUtilName & " up to date. Version : " & $tVer[0] & ", Notes : " & $tTxt1) If FileExists($aUtilUpdateFile) Then FileDelete($aUtilUpdateFile) If $tUpdate = "show" Then If $tShowStartupTextYN = "yes" Then Local $tTxt = $aStartText & "No update available." & @CRLF & "Installed version: " & $tUtil & @CRLF & "Latest version: " & $tVer[0] Else Local $tTxt = "No update available." & @CRLF & @CRLF & "Installed version: " & $tUtil & @CRLF & "Latest version: " & $tVer[0] EndIf If $tSplash > 0 Then ControlSetText($tSplash, "", "Static1", $tTxt) Else _Splash($tTxt) EndIf Sleep(2000) EndIf Else $tUtilUpdateAvailableTF = True LogWrite("[Update] !!! New " & $aUtilName & " update available. Installed version: " & $tUtil & ", Latest version: " & $tVer[0], "[Update] New " & $aUtilName & " update available. Installed version: " & $tUtil & ", Latest version: " & $tVer[0] & ", Notes: " & $tTxt1) FileWrite($aUtilUpdateFile, _NowCalc() & " [Util] New " & $aUtilName & " update available. Installed version: " & $tUtil & ", Latest version: " & $tVer[0] & ", Notes: " & $tTxt1) If ($tUpdate = "show") Or ($tUpdate = "auto") Then SplashOff() If ($tUpdate = "Auto") And ($aUpdateAutoUtil = "yes") Then Local $tMB = 6 Else Local $tMB = MsgBox($MB_YESNOCANCEL, $aUtilName, "New " & $aUtilName & " update available. " & @CRLF & "Installed version: " & $tUtil & @CRLF & "Latest version: " & $tVer[0] & @CRLF & @CRLF & "Notes: " & @CRLF & $tVer[1] & @CRLF & @CRLF & "Click (YES) to download update to " & @CRLF & @ScriptDir & @CRLF & "Click (NO) to stop checking for updates." & @CRLF & "Click (CANCEL) to skip this update check.", 15) EndIf If $tMB = 6 Then _Splash(" Downloading latest version of " & @CRLF & $tUtilName) Local $tZIP = @ScriptDir & "\" & $tUtilName & "_" & $tVer[0] & ".zip" If FileExists($tZIP) Then FileDelete($tZIP) EndIf If FileExists($tUtilName & "_" & $tVer[0] & ".exe") Then FileDelete($tUtilName & "_" & $tVer[0] & ".exe") EndIf If FileExists($tUtilName & "_" & $tVer[0] & "_64-bit(x64).exe") Then FileDelete($tUtilName & "_" & $tVer[0] & "_64-bit(x64).exe") EndIf If FileExists(@ScriptDir & "\readme.txt") Then FileDelete(@ScriptDir & "\readme.txt") EndIf InetGet($tDL, $tZIP, 1) _ExtractZipAll($tZIP, @ScriptDir) If Not FileExists(@ScriptDir & "\" & $tUtilName & "_" & $tVer[0] & ".exe") Then LogWrite("[Update] ERROR! " & $tUtilName & ".exe download failed.") SplashOff() $tMB = MsgBox($MB_OKCANCEL, $aUtilName, "Utility update download failed . . . " & @CRLF & "Go to """ & $tLink & """ to download latest version." & @CRLF & @CRLF & "Click (OK), (CANCEL), or wait 60 seconds, to resume current version.", 60) Else SplashOff() If ($tUpdate = "Auto") And ($aUpdateAutoUtil = "yes") Then $tMB = MsgBox($MB_OKCANCEL, $aUtilName, "Auto utility update download complete. . . " & @CRLF & @CRLF & "Click (OK) to run new version or wait 60 seconds (servers will remain running) OR" & @CRLF & "Click (CANCEL) to resume current version.", 60) If $tMB = 1 Then ElseIf $tMB = -1 Then $tMB = 1 ElseIf $tMB = 2 Then EndIf Else $tMB = MsgBox($MB_OKCANCEL, $aUtilName, "Utility update download complete. . . " & @CRLF & @CRLF & "Click (OK) to run new version (servers will remain running) OR" & @CRLF & "Click (CANCEL), or wait 15 seconds, to resume current version.", 15) EndIf If $tMB = 1 Then LogWrite("[Update] Update download complete. Shutting down current version and starting new version. Initiated by User or Auto Update.") Local $xArray[13] $xArray[0] = '@echo off' $xArray[1] = 'echo --------------------------------------------' $xArray[2] = 'echo Waiting 5 seconds for shutdown to complete' $xArray[3] = 'echo --------------------------------------------' $xArray[4] = 'timeout 5' If @AutoItX64 = 1 Then $xArray[5] = 'start "Starting ' & $aUtilName & '" "' & @ScriptDir & "\" & $tUtilName & "_" & $tVer[0] & "_64-bit(x64).exe" & '"' Else $xArray[5] = 'start "Starting ' & $aUtilName & '" "' & @ScriptDir & "\" & $tUtilName & "_" & $tVer[0] & ".exe" & '"' EndIf $xArray[6] = 'echo --------------------------------------------' $xArray[7] = 'echo ' & $aUtilName & ' started . . .' $xArray[8] = 'echo --------------------------------------------' $xArray[9] = 'timeout 3' $xArray[10] = 'exit' Local $tBatFile = $aFolderTemp & $aUtilName & "_Delay_Restart.bat" FileDelete($tBatFile) _FileWriteFromArray($tBatFile, $xArray) If FileExists($tBatFile) Then Run($tBatFile) Else Run(@ScriptDir & "\" & $tUtilName & "_" & $tVer[0] & ".exe") EndIf Exit Else LogWrite("[Update] Update download complete. Per user request, continuing to run current version. Resuming utility . . .") _Splash("Update check canceled by user." & @CRLF & "Resuming utility . . .", 2000) EndIf EndIf ElseIf $tMB = 7 Then $aUtilCheckForUpdateYN = "no" IniWrite($aIniFile, " --------------- " & StringUpper($aUtilName) & " OPTIONS --------------- ", "Check for updates at program start? (yes/no) ###", $aUtilCheckForUpdateYN) LogWrite("[Update] " & "Update check at startup disabled. To enable, change [Check for updates at program start? (yes/no) ###=yes] in the config.") _Splash("Update check at startup disabled." & @CRLF & "To enable update check, change" & @CRLF & "[Check for updates at program start? (yes/no) ###=yes]" & @CRLF & "in the config.", 5000, 500) ElseIf $tMB = 2 Then LogWrite("[Update] Update check canceled by user. Resuming utility . . .") _Splash("Update check canceled by user." & @CRLF & "Resuming utility . . .", 2000) EndIf EndIf EndIf EndIf FileDelete($sFilePath) Return $tUtilUpdateAvailableTF EndFunc Func _InetGetMulti($tCnt, $tFile, $tLink1, $tLink2 = "0") FileDelete($tFile) Local $i = 0 Local $tTmp1 = InetGet($tLink1, $tFile, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) Do Sleep(100) $i += 1 Until InetGetInfo($tTmp1, $INET_DOWNLOADCOMPLETE) Or $i = $tCnt InetClose($tTmp1) If $i = $tCnt And $tLink2 <> "0" Then $tTmp2 = InetGet($tLink2, $tFile, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) Do Sleep(100) $i += 1 Until InetGetInfo($tTmp2, $INET_DOWNLOADCOMPLETE) Or $i = $tCnt InetClose($tTmp2) EndIf Local $hFileOpen = FileOpen($tFile, 0) Local $hFileRead = FileRead($hFileOpen, 100000000) If $hFileOpen = -1 Then InetClose($tTmp1) Sleep(200) FileClose($hFileOpen) Local $hFileRead = _INetGetSource($tLink1) If @error Then If $tLink2 <> "0" Then $hFileRead = _INetGetSource($tLink2) If @error Then Return "Error" Else FileClose($hFileOpen) FileDelete($tFile) FileWrite($tFile, $hFileRead) EndIf Else Return True EndIf Else FileClose($hFileOpen) FileDelete($tFile) FileWrite($tFile, $hFileRead) EndIf Else FileClose($hFileOpen) EndIf Return $hFileRead EndFunc Func ReplaceCRLF($tMsg0) Return StringReplace($tMsg0, @CRLF, "|") EndFunc Func ReplaceCRwithCRLF($sString) Return StringRegExpReplace($sString, '(*BSR_ANYCRLF)\R', @CRLF) EndFunc Func _ExtractZipAll($sZipFile, $sDestinationFolder, $sFolderStructure = "") Local $i Do $i += 1 $sTempZipFolder = @TempDir & "\Temporary Directory " & $i & " for " & StringRegExpReplace($sZipFile, ".*\\", "") Until Not FileExists($sTempZipFolder) Local $oShell = ObjCreate("Shell.Application") If Not IsObj($oShell) Then Return SetError(1, 0, 0) EndIf Local $oDestinationFolder = $oShell.NameSpace($sDestinationFolder) If Not IsObj($oDestinationFolder) Then DirCreate($sDestinationFolder) EndIf Local $oOriginFolder = $oShell.NameSpace($sZipFile & "\" & $sFolderStructure) If Not IsObj($oOriginFolder) Then Return SetError(3, 0, 0) EndIf Local $oOriginFile = $oOriginFolder.Items() If Not IsObj($oOriginFile) Then Return SetError(4, 0, 0) EndIf $oDestinationFolder.CopyHere($oOriginFile, 20) DirRemove($sTempZipFolder, 1) Return 1 EndFunc